diff --git a/assets/index-CM8D-1C5.js b/assets/index-CT45GBBR.js similarity index 99% rename from assets/index-CM8D-1C5.js rename to assets/index-CT45GBBR.js index 5a187ad..a0ebcac 100644 --- a/assets/index-CM8D-1C5.js +++ b/assets/index-CT45GBBR.js @@ -1,4 +1,4 @@ -import{T as $t,M as oe,R as N,E as k,C as $,a as X,b as Br,O as Z,c as ht}from"./index-DnxKYT5P.js";import{e as Wr,d as Ur}from"./index-BLNnbgD0.js";/** +import{T as $t,M as oe,R as N,E as k,C as $,a as X,b as Br,O as Z,c as ht}from"./index-DrMoPmBj.js";import{e as Wr,d as Ur}from"./index-kgT-H_GF.js";/** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause diff --git a/assets/index-DnxKYT5P.js b/assets/index-DrMoPmBj.js similarity index 98% rename from assets/index-DnxKYT5P.js rename to assets/index-DrMoPmBj.js index 4079362..6c4701d 100644 --- a/assets/index-DnxKYT5P.js +++ b/assets/index-DrMoPmBj.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CM8D-1C5.js","assets/index-BLNnbgD0.js","assets/index-BqexNBF0.css"])))=>i.map(i=>d[i]); -import{B as pe,_ as me}from"./index-BLNnbgD0.js";const he=Symbol(),ee=Object.getPrototypeOf,Y=new WeakMap,ge=e=>e&&(Y.has(e)?Y.get(e):ee(e)===Object.prototype||ee(e)===Array.prototype),ye=e=>ge(e)&&e[he]||null,te=(e,t=!0)=>{Y.set(e,t)},z={BASE_URL:"/push-wallet/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_APP_BACKEND_URL:"https://push-auth.push.org",VITE_APP_DYNAMIC_ENV_ID:"fbb6bfb2-f61f-4105-a9c8-76d8cfc4c1a9",VITE_APP_ENV:"dev",VITE_DEV_MODE:"testing"},F=e=>typeof e=="object"&&e!==null,L=new WeakMap,x=new WeakSet,ve=(e=Object.is,t=(o,g)=>new Proxy(o,g),s=o=>F(o)&&!x.has(o)&&(Array.isArray(o)||!(Symbol.iterator in o))&&!(o instanceof WeakMap)&&!(o instanceof WeakSet)&&!(o instanceof Error)&&!(o instanceof Number)&&!(o instanceof Date)&&!(o instanceof String)&&!(o instanceof RegExp)&&!(o instanceof ArrayBuffer),n=o=>{switch(o.status){case"fulfilled":return o.value;case"rejected":throw o.reason;default:throw o}},l=new WeakMap,c=(o,g,I=n)=>{const v=l.get(o);if((v==null?void 0:v[0])===g)return v[1];const b=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o));return te(b,!0),l.set(o,[g,b]),Reflect.ownKeys(o).forEach(j=>{if(Object.getOwnPropertyDescriptor(b,j))return;const O=Reflect.get(o,j),A={value:O,enumerable:!0,configurable:!0};if(x.has(O))te(O,!1);else if(O instanceof Promise)delete A.value,A.get=()=>I(O);else if(L.has(O)){const[y,H]=L.get(O);A.value=c(y,H(),I)}Object.defineProperty(b,j,A)}),Object.preventExtensions(b)},d=new WeakMap,f=[1,1],W=o=>{if(!F(o))throw new Error("object required");const g=d.get(o);if(g)return g;let I=f[0];const v=new Set,b=(i,a=++f[0])=>{I!==a&&(I=a,v.forEach(r=>r(i,a)))};let j=f[1];const O=(i=++f[1])=>(j!==i&&!v.size&&(j=i,y.forEach(([a])=>{const r=a[1](i);r>I&&(I=r)})),I),A=i=>(a,r)=>{const h=[...a];h[1]=[i,...h[1]],b(h,r)},y=new Map,H=(i,a)=>{if((z?"production":void 0)!=="production"&&y.has(i))throw new Error("prop listener already exists");if(v.size){const r=a[3](A(i));y.set(i,[a,r])}else y.set(i,[a])},Z=i=>{var a;const r=y.get(i);r&&(y.delete(i),(a=r[1])==null||a.call(r))},ue=i=>(v.add(i),v.size===1&&y.forEach(([r,h],U)=>{if((z?"production":void 0)!=="production"&&h)throw new Error("remove already exists");const $=r[3](A(U));y.set(U,[r,$])}),()=>{v.delete(i),v.size===0&&y.forEach(([r,h],U)=>{h&&(h(),y.set(U,[r]))})}),q=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o)),R=t(q,{deleteProperty(i,a){const r=Reflect.get(i,a);Z(a);const h=Reflect.deleteProperty(i,a);return h&&b(["delete",[a],r]),h},set(i,a,r,h){const U=Reflect.has(i,a),$=Reflect.get(i,a,h);if(U&&(e($,r)||d.has(r)&&e($,d.get(r))))return!0;Z(a),F(r)&&(r=ye(r)||r);let V=r;if(r instanceof Promise)r.then(C=>{r.status="fulfilled",r.value=C,b(["resolve",[a],C])}).catch(C=>{r.status="rejected",r.reason=C,b(["reject",[a],C])});else{!L.has(r)&&s(r)&&(V=W(r));const C=!x.has(V)&&L.get(V);C&&H(a,C)}return Reflect.set(i,a,V,h),b(["set",[a],r,$]),!0}});d.set(o,R);const fe=[q,O,c,ue];return L.set(R,fe),Reflect.ownKeys(o).forEach(i=>{const a=Object.getOwnPropertyDescriptor(o,i);"value"in a&&(R[i]=o[i],delete a.value,delete a.writable),Object.defineProperty(q,i,a)}),R})=>[W,L,x,e,t,s,n,l,c,d,f],[be]=ve();function P(e={}){return be(e)}function S(e,t,s){const n=L.get(e);(z?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let l;const c=[],d=n[3];let f=!1;const o=d(g=>{c.push(g),l||(l=Promise.resolve().then(()=>{l=void 0,f&&t(c.splice(0))}))});return f=!0,()=>{f=!1,o()}}function we(e,t){const s=L.get(e);(z?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[n,l,c]=s;return c(n,l(),t)}const u=P({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),de={state:u,subscribe(e){return S(u,()=>e(u))},push(e,t){e!==u.view&&(u.view=e,t&&(u.data=t),u.history.push(e))},reset(e){u.view=e,u.history=[e]},replace(e){u.history.length>1&&(u.history[u.history.length-1]=e,u.view=e)},goBack(){if(u.history.length>1){u.history.pop();const[e]=u.history.slice(-1);u.view=e}},setData(e){u.data=e}},m={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return m.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return m.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},formatNativeUrl(e,t,s){if(m.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let n=e;n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!m.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let n=e;if(n.startsWith("https://t.me")){const c=pe.from(t).toString("base64").replace(/[=]/g,"");n.endsWith("/")&&(n=n.slice(0,-1)),this.setWalletConnectDeepLink(n,s);const d=new URL(n);return d.searchParams.set("startapp",c),d.toString()}n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){const s=this.isTelegram()?"_blank":t;window.open(e,s,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(m.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(m.WCM_VERSION,"2.7.0")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=de.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},Ie=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),p=P({enabled:Ie,userSessionId:"",events:[],connectedWalletId:void 0}),_e={state:p,subscribe(e){return S(p.events,()=>e(we(p.events[p.events.length-1])))},initialize(){p.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(p.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){p.connectedWalletId=e},click(e){if(p.enabled){const t={type:"CLICK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},track(e){if(p.enabled){const t={type:"TRACK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},view(e){if(p.enabled){const t={type:"VIEW",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}}},_=P({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),w={state:_,subscribe(e){return S(_,()=>e(_))},setChains(e){_.chains=e},setWalletConnectUri(e){_.walletConnectUri=e},setIsCustomDesktop(e){_.isCustomDesktop=e},setIsCustomMobile(e){_.isCustomMobile=e},setIsDataLoaded(e){_.isDataLoaded=e},setIsUiLoaded(e){_.isUiLoaded=e},setIsAuth(e){_.isAuth=e}},B=P({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),N={state:B,subscribe(e){return S(B,()=>e(B))},setConfig(e){var t,s;_e.initialize(),w.setChains(e.chains),w.setIsAuth(!!e.enableAuthMode),w.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),w.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),m.setModalVersionInStorage(),Object.assign(B,e)}};var Ee=Object.defineProperty,se=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable,ne=(e,t,s)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ce=(e,t)=>{for(var s in t||(t={}))Oe.call(t,s)&&ne(e,s,t[s]);if(se)for(var s of se(t))We.call(t,s)&&ne(e,s,t[s]);return e};const G="https://explorer-api.walletconnect.com",Q="wcm",X="js-2.7.0";async function K(e,t){const s=Ce({sdkType:Q,sdkVersion:X},t),n=new URL(e,G);return n.searchParams.append("projectId",N.state.projectId),Object.entries(s).forEach(([c,d])=>{d&&n.searchParams.append(c,String(d))}),(await fetch(n)).json()}const M={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${G}/w3m/v1/getWalletImage/${e}?projectId=${N.state.projectId}&sdkType=${Q}&sdkVersion=${X}`},getAssetImageUrl(e){return`${G}/w3m/v1/getAssetImage/${e}?projectId=${N.state.projectId}&sdkType=${Q}&sdkVersion=${X}`}};var Le=Object.defineProperty,oe=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,re=(e,t,s)=>t in e?Le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Me=(e,t)=>{for(var s in t||(t={}))Pe.call(t,s)&&re(e,s,t[s]);if(oe)for(var s of oe(t))Ae.call(t,s)&&re(e,s,t[s]);return e};const ae=m.isMobile(),E=P({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Re={state:E,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=N.state;if(e==="NONE"||t==="ALL"&&!e)return E.recomendedWallets;if(m.isArray(e)){const n={recommendedIds:e.join(",")},{listings:l}=await M.getAllListings(n),c=Object.values(l);c.sort((d,f)=>{const W=e.indexOf(d.id),o=e.indexOf(f.id);return W-o}),E.recomendedWallets=c}else{const{chains:s,isAuth:n}=w.state,l=s==null?void 0:s.join(","),c=m.isArray(t),d={page:1,sdks:n?"auth_v1":void 0,entries:m.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:f}=ae?await M.getMobileListings(d):await M.getDesktopListings(d);E.recomendedWallets=Object.values(f)}return E.recomendedWallets},async getWallets(e){const t=Me({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:n}=N.state,{recomendedWallets:l}=E;if(n==="ALL")return E.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):m.isArray(s)&&(t.excludedIds=s.join(",")),m.isArray(n)&&(t.excludedIds=[t.excludedIds,n].filter(Boolean).join(",")),w.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:d}=e,{listings:f,total:W}=ae?await M.getMobileListings(t):await M.getDesktopListings(t),o=Object.values(f),g=d?"search":"wallets";return E[g]={listings:[...E[g].listings,...o],total:W,page:c??1},{listings:o,total:W}},getWalletImageUrl(e){return M.getWalletImageUrl(e)},getAssetImageUrl(e){return M.getAssetImageUrl(e)},resetSearch(){E.search={listings:[],total:0,page:1}}},T=P({open:!1}),J={state:T,subscribe(e){return S(T,()=>e(T))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:n}=w.state;if(m.removeWalletConnectDeepLink(),w.setWalletConnectUri(e==null?void 0:e.uri),w.setChains(e==null?void 0:e.chains),de.reset("ConnectWallet"),s&&n)T.open=!0,t();else{const l=setInterval(()=>{const c=w.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),T.open=!0,t())},200)}})},close(){T.open=!1}};var De=Object.defineProperty,ie=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable,le=(e,t,s)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ue=(e,t)=>{for(var s in t||(t={}))Se.call(t,s)&&le(e,s,t[s]);if(ie)for(var s of ie(t))je.call(t,s)&&le(e,s,t[s]);return e};function Te(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const k=P({themeMode:Te()?"dark":"light"}),ce={state:k,subscribe(e){return S(k,()=>e(k))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(k.themeMode=t),s&&(k.themeVariables=Ue({},s))}},D=P({open:!1,message:"",variant:"success"}),Ve={state:D,subscribe(e){return S(D,()=>e(D))},openToast(e,t){D.open=!0,D.message=e,D.variant=t},closeToast(){D.open=!1}};class Ne{constructor(t){this.openModal=J.open,this.closeModal=J.close,this.subscribeModal=J.subscribe,this.setTheme=ce.setThemeConfig,ce.setThemeConfig(t),N.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await me(()=>import("./index-CM8D-1C5.js"),__vite__mapDeps([0,1,2]));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),w.setIsUiLoaded(!0)}}}const xe=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Ne},Symbol.toStringTag,{value:"Module"}));export{m as C,Re as E,J as M,w as O,de as R,ce as T,Ve as a,_e as b,N as c,xe as i}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CT45GBBR.js","assets/index-kgT-H_GF.js","assets/index-BqexNBF0.css"])))=>i.map(i=>d[i]); +import{B as pe,_ as me}from"./index-kgT-H_GF.js";const he=Symbol(),ee=Object.getPrototypeOf,Y=new WeakMap,ge=e=>e&&(Y.has(e)?Y.get(e):ee(e)===Object.prototype||ee(e)===Array.prototype),ye=e=>ge(e)&&e[he]||null,te=(e,t=!0)=>{Y.set(e,t)},z={BASE_URL:"/push-wallet/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_APP_BACKEND_URL:"https://push-auth.push.org",VITE_APP_DYNAMIC_ENV_ID:"fbb6bfb2-f61f-4105-a9c8-76d8cfc4c1a9",VITE_APP_ENV:"dev",VITE_DEV_MODE:"testing"},F=e=>typeof e=="object"&&e!==null,L=new WeakMap,x=new WeakSet,ve=(e=Object.is,t=(o,g)=>new Proxy(o,g),s=o=>F(o)&&!x.has(o)&&(Array.isArray(o)||!(Symbol.iterator in o))&&!(o instanceof WeakMap)&&!(o instanceof WeakSet)&&!(o instanceof Error)&&!(o instanceof Number)&&!(o instanceof Date)&&!(o instanceof String)&&!(o instanceof RegExp)&&!(o instanceof ArrayBuffer),n=o=>{switch(o.status){case"fulfilled":return o.value;case"rejected":throw o.reason;default:throw o}},l=new WeakMap,c=(o,g,I=n)=>{const v=l.get(o);if((v==null?void 0:v[0])===g)return v[1];const b=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o));return te(b,!0),l.set(o,[g,b]),Reflect.ownKeys(o).forEach(j=>{if(Object.getOwnPropertyDescriptor(b,j))return;const O=Reflect.get(o,j),A={value:O,enumerable:!0,configurable:!0};if(x.has(O))te(O,!1);else if(O instanceof Promise)delete A.value,A.get=()=>I(O);else if(L.has(O)){const[y,H]=L.get(O);A.value=c(y,H(),I)}Object.defineProperty(b,j,A)}),Object.preventExtensions(b)},d=new WeakMap,f=[1,1],W=o=>{if(!F(o))throw new Error("object required");const g=d.get(o);if(g)return g;let I=f[0];const v=new Set,b=(i,a=++f[0])=>{I!==a&&(I=a,v.forEach(r=>r(i,a)))};let j=f[1];const O=(i=++f[1])=>(j!==i&&!v.size&&(j=i,y.forEach(([a])=>{const r=a[1](i);r>I&&(I=r)})),I),A=i=>(a,r)=>{const h=[...a];h[1]=[i,...h[1]],b(h,r)},y=new Map,H=(i,a)=>{if((z?"production":void 0)!=="production"&&y.has(i))throw new Error("prop listener already exists");if(v.size){const r=a[3](A(i));y.set(i,[a,r])}else y.set(i,[a])},Z=i=>{var a;const r=y.get(i);r&&(y.delete(i),(a=r[1])==null||a.call(r))},ue=i=>(v.add(i),v.size===1&&y.forEach(([r,h],U)=>{if((z?"production":void 0)!=="production"&&h)throw new Error("remove already exists");const $=r[3](A(U));y.set(U,[r,$])}),()=>{v.delete(i),v.size===0&&y.forEach(([r,h],U)=>{h&&(h(),y.set(U,[r]))})}),q=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o)),R=t(q,{deleteProperty(i,a){const r=Reflect.get(i,a);Z(a);const h=Reflect.deleteProperty(i,a);return h&&b(["delete",[a],r]),h},set(i,a,r,h){const U=Reflect.has(i,a),$=Reflect.get(i,a,h);if(U&&(e($,r)||d.has(r)&&e($,d.get(r))))return!0;Z(a),F(r)&&(r=ye(r)||r);let V=r;if(r instanceof Promise)r.then(C=>{r.status="fulfilled",r.value=C,b(["resolve",[a],C])}).catch(C=>{r.status="rejected",r.reason=C,b(["reject",[a],C])});else{!L.has(r)&&s(r)&&(V=W(r));const C=!x.has(V)&&L.get(V);C&&H(a,C)}return Reflect.set(i,a,V,h),b(["set",[a],r,$]),!0}});d.set(o,R);const fe=[q,O,c,ue];return L.set(R,fe),Reflect.ownKeys(o).forEach(i=>{const a=Object.getOwnPropertyDescriptor(o,i);"value"in a&&(R[i]=o[i],delete a.value,delete a.writable),Object.defineProperty(q,i,a)}),R})=>[W,L,x,e,t,s,n,l,c,d,f],[be]=ve();function P(e={}){return be(e)}function S(e,t,s){const n=L.get(e);(z?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let l;const c=[],d=n[3];let f=!1;const o=d(g=>{c.push(g),l||(l=Promise.resolve().then(()=>{l=void 0,f&&t(c.splice(0))}))});return f=!0,()=>{f=!1,o()}}function we(e,t){const s=L.get(e);(z?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[n,l,c]=s;return c(n,l(),t)}const u=P({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),de={state:u,subscribe(e){return S(u,()=>e(u))},push(e,t){e!==u.view&&(u.view=e,t&&(u.data=t),u.history.push(e))},reset(e){u.view=e,u.history=[e]},replace(e){u.history.length>1&&(u.history[u.history.length-1]=e,u.view=e)},goBack(){if(u.history.length>1){u.history.pop();const[e]=u.history.slice(-1);u.view=e}},setData(e){u.data=e}},m={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return m.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return m.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},formatNativeUrl(e,t,s){if(m.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let n=e;n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!m.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let n=e;if(n.startsWith("https://t.me")){const c=pe.from(t).toString("base64").replace(/[=]/g,"");n.endsWith("/")&&(n=n.slice(0,-1)),this.setWalletConnectDeepLink(n,s);const d=new URL(n);return d.searchParams.set("startapp",c),d.toString()}n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){const s=this.isTelegram()?"_blank":t;window.open(e,s,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(m.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(m.WCM_VERSION,"2.7.0")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=de.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},Ie=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),p=P({enabled:Ie,userSessionId:"",events:[],connectedWalletId:void 0}),_e={state:p,subscribe(e){return S(p.events,()=>e(we(p.events[p.events.length-1])))},initialize(){p.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(p.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){p.connectedWalletId=e},click(e){if(p.enabled){const t={type:"CLICK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},track(e){if(p.enabled){const t={type:"TRACK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},view(e){if(p.enabled){const t={type:"VIEW",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}}},_=P({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),w={state:_,subscribe(e){return S(_,()=>e(_))},setChains(e){_.chains=e},setWalletConnectUri(e){_.walletConnectUri=e},setIsCustomDesktop(e){_.isCustomDesktop=e},setIsCustomMobile(e){_.isCustomMobile=e},setIsDataLoaded(e){_.isDataLoaded=e},setIsUiLoaded(e){_.isUiLoaded=e},setIsAuth(e){_.isAuth=e}},B=P({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),N={state:B,subscribe(e){return S(B,()=>e(B))},setConfig(e){var t,s;_e.initialize(),w.setChains(e.chains),w.setIsAuth(!!e.enableAuthMode),w.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),w.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),m.setModalVersionInStorage(),Object.assign(B,e)}};var Ee=Object.defineProperty,se=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable,ne=(e,t,s)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ce=(e,t)=>{for(var s in t||(t={}))Oe.call(t,s)&&ne(e,s,t[s]);if(se)for(var s of se(t))We.call(t,s)&&ne(e,s,t[s]);return e};const G="https://explorer-api.walletconnect.com",Q="wcm",X="js-2.7.0";async function K(e,t){const s=Ce({sdkType:Q,sdkVersion:X},t),n=new URL(e,G);return n.searchParams.append("projectId",N.state.projectId),Object.entries(s).forEach(([c,d])=>{d&&n.searchParams.append(c,String(d))}),(await fetch(n)).json()}const M={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${G}/w3m/v1/getWalletImage/${e}?projectId=${N.state.projectId}&sdkType=${Q}&sdkVersion=${X}`},getAssetImageUrl(e){return`${G}/w3m/v1/getAssetImage/${e}?projectId=${N.state.projectId}&sdkType=${Q}&sdkVersion=${X}`}};var Le=Object.defineProperty,oe=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,re=(e,t,s)=>t in e?Le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Me=(e,t)=>{for(var s in t||(t={}))Pe.call(t,s)&&re(e,s,t[s]);if(oe)for(var s of oe(t))Ae.call(t,s)&&re(e,s,t[s]);return e};const ae=m.isMobile(),E=P({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Re={state:E,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=N.state;if(e==="NONE"||t==="ALL"&&!e)return E.recomendedWallets;if(m.isArray(e)){const n={recommendedIds:e.join(",")},{listings:l}=await M.getAllListings(n),c=Object.values(l);c.sort((d,f)=>{const W=e.indexOf(d.id),o=e.indexOf(f.id);return W-o}),E.recomendedWallets=c}else{const{chains:s,isAuth:n}=w.state,l=s==null?void 0:s.join(","),c=m.isArray(t),d={page:1,sdks:n?"auth_v1":void 0,entries:m.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:f}=ae?await M.getMobileListings(d):await M.getDesktopListings(d);E.recomendedWallets=Object.values(f)}return E.recomendedWallets},async getWallets(e){const t=Me({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:n}=N.state,{recomendedWallets:l}=E;if(n==="ALL")return E.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):m.isArray(s)&&(t.excludedIds=s.join(",")),m.isArray(n)&&(t.excludedIds=[t.excludedIds,n].filter(Boolean).join(",")),w.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:d}=e,{listings:f,total:W}=ae?await M.getMobileListings(t):await M.getDesktopListings(t),o=Object.values(f),g=d?"search":"wallets";return E[g]={listings:[...E[g].listings,...o],total:W,page:c??1},{listings:o,total:W}},getWalletImageUrl(e){return M.getWalletImageUrl(e)},getAssetImageUrl(e){return M.getAssetImageUrl(e)},resetSearch(){E.search={listings:[],total:0,page:1}}},T=P({open:!1}),J={state:T,subscribe(e){return S(T,()=>e(T))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:n}=w.state;if(m.removeWalletConnectDeepLink(),w.setWalletConnectUri(e==null?void 0:e.uri),w.setChains(e==null?void 0:e.chains),de.reset("ConnectWallet"),s&&n)T.open=!0,t();else{const l=setInterval(()=>{const c=w.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),T.open=!0,t())},200)}})},close(){T.open=!1}};var De=Object.defineProperty,ie=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable,le=(e,t,s)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ue=(e,t)=>{for(var s in t||(t={}))Se.call(t,s)&&le(e,s,t[s]);if(ie)for(var s of ie(t))je.call(t,s)&&le(e,s,t[s]);return e};function Te(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const k=P({themeMode:Te()?"dark":"light"}),ce={state:k,subscribe(e){return S(k,()=>e(k))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(k.themeMode=t),s&&(k.themeVariables=Ue({},s))}},D=P({open:!1,message:"",variant:"success"}),Ve={state:D,subscribe(e){return S(D,()=>e(D))},openToast(e,t){D.open=!0,D.message=e,D.variant=t},closeToast(){D.open=!1}};class Ne{constructor(t){this.openModal=J.open,this.closeModal=J.close,this.subscribeModal=J.subscribe,this.setTheme=ce.setThemeConfig,ce.setThemeConfig(t),N.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await me(()=>import("./index-CT45GBBR.js"),__vite__mapDeps([0,1,2]));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),w.setIsUiLoaded(!0)}}}const xe=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Ne},Symbol.toStringTag,{value:"Module"}));export{m as C,Re as E,J as M,w as O,de as R,ce as T,Ve as a,_e as b,N as c,xe as i}; diff --git a/assets/index-BLNnbgD0.js b/assets/index-kgT-H_GF.js similarity index 99% rename from assets/index-BLNnbgD0.js rename to assets/index-kgT-H_GF.js index 9a998fe..c62253b 100644 --- a/assets/index-BLNnbgD0.js +++ b/assets/index-kgT-H_GF.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/webcrypto-BG4hfxBn.js","assets/utils-XOiObzyy.js","assets/nodecrypto-DBt_cM49.js"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/webcrypto-D3OqlkPG.js","assets/utils-kOKXth6J.js","assets/nodecrypto-D6j4PjE1.js"])))=>i.map(i=>d[i]); var pS=Object.defineProperty;var mS=(fr,br,wr)=>br in fr?pS(fr,br,{enumerable:!0,configurable:!0,writable:!0,value:wr}):fr[br]=wr;var Uu=(fr,br,wr)=>mS(fr,typeof br!="symbol"?br+"":br,wr);function _mergeNamespaces(fr,br){for(var wr=0;wrEr[kr]})}}}return Object.freeze(Object.defineProperty(fr,Symbol.toStringTag,{value:"Module"}))}(function(){const br=document.createElement("link").relList;if(br&&br.supports&&br.supports("modulepreload"))return;for(const kr of document.querySelectorAll('link[rel="modulepreload"]'))Er(kr);new MutationObserver(kr=>{for(const jr of kr)if(jr.type==="childList")for(const Br of jr.addedNodes)Br.tagName==="LINK"&&Br.rel==="modulepreload"&&Er(Br)}).observe(document,{childList:!0,subtree:!0});function wr(kr){const jr={};return kr.integrity&&(jr.integrity=kr.integrity),kr.referrerPolicy&&(jr.referrerPolicy=kr.referrerPolicy),kr.crossOrigin==="use-credentials"?jr.credentials="include":kr.crossOrigin==="anonymous"?jr.credentials="omit":jr.credentials="same-origin",jr}function Er(kr){if(kr.ep)return;kr.ep=!0;const jr=wr(kr);fetch(kr.href,jr)}})();var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs$2(fr){return fr&&fr.__esModule&&Object.prototype.hasOwnProperty.call(fr,"default")?fr.default:fr}function getAugmentedNamespace(fr){if(fr.__esModule)return fr;var br=fr.default;if(typeof br=="function"){var wr=function Er(){return this instanceof Er?Reflect.construct(br,arguments,this.constructor):br.apply(this,arguments)};wr.prototype=br.prototype}else wr={};return Object.defineProperty(wr,"__esModule",{value:!0}),Object.keys(fr).forEach(function(Er){var kr=Object.getOwnPropertyDescriptor(fr,Er);Object.defineProperty(wr,Er,kr.get?kr:{enumerable:!0,get:function(){return fr[Er]}})}),wr}var jsxRuntime={exports:{}},reactJsxRuntime_production_min={},react={exports:{}},react_production_min={};/** * @license React * react.production.min.js @@ -1655,7 +1655,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho :hover { border: var(--border-sm, 1px) solid var(--stroke-brand-medium); } - `,display:"flex",padding:"spacing-xs",borderRadius:"radius-xs",border:"border-sm solid stroke-tertiary",backgroundColor:"surface-transparent",alignItems:"center",justifyContent:"space-between",onClick:()=>fr==null?void 0:fr(br.value),children:[jsxRuntimeExports.jsxs(Box,{alignItems:"center",display:"flex",gap:"spacing-xxs",children:[br.icon,jsxRuntimeExports.jsx(Text,{variant:"bs-semibold",color:"text-primary",children:br.label})]}),jsxRuntimeExports.jsx(CaretRight,{size:24,color:"icon-tertiary"})]},br.value))}),Footer=()=>jsxRuntimeExports.jsxs(Box,{textAlign:"center",width:"280px",children:[jsxRuntimeExports.jsxs(Text,{as:"span",variant:"bes-semibold",color:"text-secondary",children:["By using Push Wallet, you agree to our"," "]}),jsxRuntimeExports.jsxs(Link,{to:"https://push.org/tos/",target:"_blank",textProps:{as:"span",variant:"bes-semibold",color:"text-brand-medium"},children:["Terms of Service"," "]}),jsxRuntimeExports.jsxs(Text,{as:"span",variant:"bes-semibold",color:"text-secondary",children:["and"," "]}),jsxRuntimeExports.jsx(Link,{to:"https://push.org/privacy/",target:"_blank",textProps:{as:"span",variant:"bes-semibold",color:"text-brand-medium"},children:"Privacy Policy"})]}),socialLoginConfig=[{name:"apple",icon:jsxRuntimeExports.jsx(Apple,{color:"icon-hero-icons",size:24})},{name:"github",icon:jsxRuntimeExports.jsx(Github,{color:"icon-hero-icons",size:24})},{name:"twitter",icon:jsxRuntimeExports.jsx(TwitterSimple,{color:"icon-hero-icons",size:24})},{name:"discord",icon:jsxRuntimeExports.jsx(DiscordSimple,{width:24,height:24})}],solanaWallets={backpack:"Backpack",bitgetwallet:"Bitget",brave:"Brave",coin98:"Coin98",coinbase:"Coinbase",exodus:"Exodus Wallet",fallbackconnector:"Fallback Connector",glow:"Glow",magiceden:"Magic Eden",mathwallet:"Math Wallet",nightlysol:"Nightly",okxwallet:"OKX Wallet",onekey:"OneKey",phantom:"Phantom",solflare:"Solflare"},allowedEvmWallets=["metamask","trust","safepal","binance","uniswap","coinbase","walletconnect","rainbow","backpack","zerion","rabby","flowwallet","sequence","unstoppable","frontier","1inch","mewwallet","obvious","enkrypt","krakenwallet"],validationSchema=create$5().shape({email:create$6().email("Invalid email address").required("Required")}),envRouteAlias="/push-wallet",Login=({email:fr,setEmail:br,setConnectMethod:wr})=>{var jr,Br,Wr,qr;const Er=useFormik({initialValues:{email:fr},validationSchema,onSubmit:Hr=>{br(Hr.email),Hr.email&&(window.location.href=`https://push-auth.push.org/auth/authorize-email?email=${encodeURIComponent(Hr.email)}&redirectUri=${encodeURIComponent(window.location.origin+envRouteAlias+"/wallet")}`)}}),kr=Hr=>{window.location.href=`https://push-auth.push.org/auth/authorize-social?provider=${Hr}&redirectUri=${encodeURIComponent(window.location.origin+envRouteAlias+"/wallet")}`};return jsxRuntimeExports.jsxs(Box,{alignItems:"center",flexDirection:"column",display:"flex",justifyContent:"space-between",width:"100%",gap:"spacing-xl",margin:"spacing-md spacing-none spacing-none spacing-none",children:[jsxRuntimeExports.jsxs(Text,{variant:"h3-semibold",color:"text-primary",children:[" ","Welcome to",jsxRuntimeExports.jsx("br",{})," Push Wallet"]}),jsxRuntimeExports.jsx(Box,{flexDirection:"column",display:"flex",gap:"spacing-lg",width:"100%",alignItems:"center",children:jsxRuntimeExports.jsxs(Box,{flexDirection:"column",display:"flex",gap:"spacing-xs",width:"100%",alignItems:"center",children:[jsxRuntimeExports.jsx(Box,{width:"100%",children:jsxRuntimeExports.jsx("form",{onSubmit:Er.handleSubmit,children:jsxRuntimeExports.jsx(TextInput,{value:Er.values.email,onChange:Er.handleChange("email"),placeholder:"Enter your email",error:((jr=Er.touched)==null?void 0:jr.email)&&!!((Br=Er.errors)!=null&&Br.email),errorMessage:(Wr=Er.touched)!=null&&Wr.email?(qr=Er.errors)==null?void 0:qr.email:"",trailingIcon:jsxRuntimeExports.jsx(Front,{size:24,onClick:()=>wr("social")})})})}),jsxRuntimeExports.jsx(Text,{variant:"os-regular",color:"text-tertiary",children:"OR"}),jsxRuntimeExports.jsx(Button,{variant:"outline",block:!0,leadingIcon:jsxRuntimeExports.jsx(Google,{width:24,height:24}),onClick:()=>kr("google"),children:"Continue with Google"}),jsxRuntimeExports.jsx(Box,{display:"flex",gap:"spacing-xs",alignItems:"center",justifyContent:"center",children:socialLoginConfig.map(Hr=>jsxRuntimeExports.jsx(Button,{variant:"outline",iconOnly:Hr.icon,css:Ae$2` + `,display:"flex",padding:"spacing-xs",borderRadius:"radius-xs",border:"border-sm solid stroke-tertiary",backgroundColor:"surface-transparent",alignItems:"center",justifyContent:"space-between",onClick:()=>fr==null?void 0:fr(br.value),children:[jsxRuntimeExports.jsxs(Box,{alignItems:"center",display:"flex",gap:"spacing-xxs",children:[br.icon,jsxRuntimeExports.jsx(Text,{variant:"bs-semibold",color:"text-primary",children:br.label})]}),jsxRuntimeExports.jsx(CaretRight,{size:24,color:"icon-tertiary"})]},br.value))}),Footer=()=>jsxRuntimeExports.jsxs(Box,{textAlign:"center",width:"280px",children:[jsxRuntimeExports.jsxs(Text,{as:"span",variant:"bes-semibold",color:"text-secondary",children:["By using Push Wallet, you agree to our"," "]}),jsxRuntimeExports.jsxs(Link,{to:"https://push.org/tos/",target:"_blank",textProps:{as:"span",variant:"bes-semibold",color:"text-brand-medium"},children:["Terms of Service"," "]}),jsxRuntimeExports.jsxs(Text,{as:"span",variant:"bes-semibold",color:"text-secondary",children:["and"," "]}),jsxRuntimeExports.jsx(Link,{to:"https://push.org/privacy/",target:"_blank",textProps:{as:"span",variant:"bes-semibold",color:"text-brand-medium"},children:"Privacy Policy"})]}),socialLoginConfig=[{name:"apple",icon:jsxRuntimeExports.jsx(Apple,{color:"icon-hero-icons",size:24})},{name:"github",icon:jsxRuntimeExports.jsx(Github,{color:"icon-hero-icons",size:24})},{name:"twitter",icon:jsxRuntimeExports.jsx(TwitterSimple,{color:"icon-hero-icons",size:24})},{name:"discord",icon:jsxRuntimeExports.jsx(DiscordSimple,{width:24,height:24})}],solanaWallets={coinbase:"Coinbase",backpack:"Backpack",bitgetwallet:"Bitget",brave:"Brave",coin98:"Coin98",exodus:"Exodus Wallet",fallbackconnector:"Fallback Connector",glow:"Glow",magiceden:"Magic Eden",mathwallet:"Math Wallet",nightlysol:"Nightly",okxwallet:"OKX Wallet",onekey:"OneKey",phantom:"Phantom",solflare:"Solflare"},allowedEvmWallets=["metamask","trust","safepal","binance","uniswap","coinbase","walletconnect","rainbow","backpack","zerion","rabby","flowwallet","sequence","unstoppable","frontier","1inch","mewwallet","obvious","enkrypt","krakenwallet"],validationSchema=create$5().shape({email:create$6().email("Invalid email address").required("Required")}),envRouteAlias="/push-wallet",Login=({email:fr,setEmail:br,setConnectMethod:wr})=>{var jr,Br,Wr,qr;const Er=useFormik({initialValues:{email:fr},validationSchema,onSubmit:Hr=>{br(Hr.email),Hr.email&&(window.location.href=`https://push-auth.push.org/auth/authorize-email?email=${encodeURIComponent(Hr.email)}&redirectUri=${encodeURIComponent(window.location.origin+envRouteAlias+"/wallet")}`)}}),kr=Hr=>{window.location.href=`https://push-auth.push.org/auth/authorize-social?provider=${Hr}&redirectUri=${encodeURIComponent(window.location.origin+envRouteAlias+"/wallet")}`};return jsxRuntimeExports.jsxs(Box,{alignItems:"center",flexDirection:"column",display:"flex",justifyContent:"space-between",width:"100%",gap:"spacing-xl",margin:"spacing-md spacing-none spacing-none spacing-none",children:[jsxRuntimeExports.jsxs(Text,{variant:"h3-semibold",color:"text-primary",children:[" ","Welcome to",jsxRuntimeExports.jsx("br",{})," Push Wallet"]}),jsxRuntimeExports.jsx(Box,{flexDirection:"column",display:"flex",gap:"spacing-lg",width:"100%",alignItems:"center",children:jsxRuntimeExports.jsxs(Box,{flexDirection:"column",display:"flex",gap:"spacing-xs",width:"100%",alignItems:"center",children:[jsxRuntimeExports.jsx(Box,{width:"100%",children:jsxRuntimeExports.jsx("form",{onSubmit:Er.handleSubmit,children:jsxRuntimeExports.jsx(TextInput,{value:Er.values.email,onChange:Er.handleChange("email"),placeholder:"Enter your email",error:((jr=Er.touched)==null?void 0:jr.email)&&!!((Br=Er.errors)!=null&&Br.email),errorMessage:(Wr=Er.touched)!=null&&Wr.email?(qr=Er.errors)==null?void 0:qr.email:"",trailingIcon:jsxRuntimeExports.jsx(Front,{size:24,onClick:()=>{Er.handleSubmit(),wr("social")}})})})}),jsxRuntimeExports.jsx(Text,{variant:"os-regular",color:"text-tertiary",children:"OR"}),jsxRuntimeExports.jsx(Button,{variant:"outline",block:!0,leadingIcon:jsxRuntimeExports.jsx(Google,{width:24,height:24}),onClick:()=>kr("google"),children:"Continue with Google"}),jsxRuntimeExports.jsx(Box,{display:"flex",gap:"spacing-xs",alignItems:"center",justifyContent:"center",children:socialLoginConfig.map(Hr=>jsxRuntimeExports.jsx(Button,{variant:"outline",iconOnly:Hr.icon,css:Ae$2` width: 73px; `,onClick:()=>kr(Hr.name)},Hr.name))}),jsxRuntimeExports.jsx(Text,{variant:"os-regular",color:"text-tertiary",children:"OR"}),jsxRuntimeExports.jsx(Button,{variant:"outline",block:!0,onClick:()=>wr("connectWallet"),children:"Continue with a Wallet"})]})}),jsxRuntimeExports.jsx(PoweredByPush,{})]})},getGroupedWallets=fr=>fr.reduce((br,wr)=>{const Er=wr.group||wr.key,kr=wr.groupName||wr.name;return br[Er]||(br[Er]=kr),br},{}),filterEthereumWallets=fr=>Object.fromEntries(allowedEvmWallets.filter(wr=>wr in fr).map(wr=>[wr,fr[wr]]));var ENV=(fr=>(fr.PROD="prod",fr.STAGING="staging",fr.DEV="dev",fr.LOCAL="local",fr))(ENV||{});const chainToNamespace={EVM:"eip155",SOL:"solana"},networkToSolChainId={mainnet:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",devnet:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",testnet:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"},APP_ROUTES={AUTH:"/auth",WALLET:"/wallet"},WalletSelection=({setConnectMethod:fr})=>{const[br,wr]=reactExports.useState(""),{primaryWallet:Er}=useDynamicContext(),{walletOptions:kr,selectWalletOption:jr}=useWalletOptions(),Br=useNavigate();reactExports.useEffect(()=>{(async()=>Er&&Br(APP_ROUTES.WALLET))()},[Er]);const Wr=filterEthereumWallets(getGroupedWallets(kr)),qr=br==="ethereum"?Wr:solanaWallets,Hr=()=>{br?wr(""):fr("authentication")},Vr=Jr=>{jr(Jr)},Zr=({walletKey:Jr})=>jsxRuntimeExports.jsx(Text,{color:"text-tertiary",variant:"bes-bold",textAlign:"center",children:Jr.slice(0,2).toUpperCase()});return jsxRuntimeExports.jsxs(Box,{flexDirection:"column",display:"flex",gap:"spacing-lg",width:"100%",children:[jsxRuntimeExports.jsx(Box,{cursor:"pointer",onClick:()=>Hr(),children:jsxRuntimeExports.jsx(Back,{color:"icon-tertiary",size:24})}),jsxRuntimeExports.jsx(Box,{flexDirection:"column",display:"flex",gap:"spacing-md",children:jsxRuntimeExports.jsxs(Box,{flexDirection:"column",display:"flex",gap:"spacing-md",children:[jsxRuntimeExports.jsxs(Box,{flexDirection:"column",display:"flex",textAlign:"center",children:[jsxRuntimeExports.jsx(Text,{color:"text-primary",variant:"h4-semibold",children:"Link Account"}),jsxRuntimeExports.jsx(Text,{color:"text-primary",variant:"bs-regular",children:"Choose what kind of wallet you would like to link with Push"})]}),jsxRuntimeExports.jsx(Box,{flexDirection:"column",display:"flex",gap:"spacing-xxs",height:"299px",overflow:"hidden auto",customScrollbar:!0,children:!Er&&(br?Object.entries(qr).map(([Jr,Qr])=>jsxRuntimeExports.jsxs(Box,{cursor:"pointer",css:Ae$2` :hover { @@ -1664,7 +1664,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho } `,display:"flex",padding:"spacing-xs",borderRadius:"radius-xs",border:"border-sm solid stroke-tertiary",backgroundColor:"surface-transparent",alignItems:"center",gap:"spacing-xxs",onClick:()=>Vr(Jr),children:[jsxRuntimeExports.jsx(Box,{width:"24px",height:"24px",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",css:Ae$2` flex-shrink: 0; - `,children:WALLETS_LOGO[Jr]||jsxRuntimeExports.jsx(Zr,{walletKey:Jr})}),jsxRuntimeExports.jsx(Text,{variant:"bs-semibold",color:"text-primary",children:Qr})]},Jr)):jsxRuntimeExports.jsx(WalletCategories,{setSelectedWalletCategory:wr}))})]})}),jsxRuntimeExports.jsx(PoweredByPush,{})]})},Authentication=()=>{const[fr,br]=reactExports.useState(""),[wr,Er]=reactExports.useState("authentication");return jsxRuntimeExports.jsx(ContentLayout,{footer:jsxRuntimeExports.jsx(Footer,{}),children:jsxRuntimeExports.jsx(BoxLayout,{children:jsxRuntimeExports.jsxs(Box,{alignItems:"center",flexDirection:"column",display:"flex",width:"376px",padding:"spacing-md",children:[wr==="authentication"&&jsxRuntimeExports.jsx(Login,{email:fr,setEmail:br,setConnectMethod:Er}),wr==="connectWallet"&&jsxRuntimeExports.jsx(WalletSelection,{setConnectMethod:Er})]})})})};function __rest$7(fr,br){var wr={};for(var Er in fr)Object.prototype.hasOwnProperty.call(fr,Er)&&br.indexOf(Er)<0&&(wr[Er]=fr[Er]);if(fr!=null&&typeof Object.getOwnPropertySymbols=="function")for(var kr=0,Er=Object.getOwnPropertySymbols(fr);kr>19^fr^fr>>8,(randseed[3]>>>0)/(1<<31>>>0)}function createColor(){const fr=Math.floor(rand()*360),br=(rand()*60+40).toFixed(1)+"%",wr=((rand()+rand()+rand()+rand())*25).toFixed(1)+"%";return"hsl("+fr+","+br+","+wr+")"}function createImageData(fr){const br=fr,wr=fr,Er=Math.ceil(br/2),kr=br-Er,jr=[];for(let Br=0;Br{if(br)if(store[br]&&store[br].opts.size===wr)Hr(store[br].opts),Zr(store[br].imageData);else{const Jr=buildOpts({seed:br,size:wr,scale:Er}),Qr=createImageData(Jr.size);Hr(Jr),Zr(Qr),store[br]={opts:Jr,imageData:Qr}}},[br]),br?qr&&Vr?jsxRuntimeExports.jsxs("svg",Object.assign({},Br,{width:Wr,height:Wr,viewBox:`0 0 ${Wr} ${Wr}`,xmlns:"http://www.w3.org/2000/svg"},{children:[jsxRuntimeExports.jsx("rect",{width:Wr,height:Wr,fill:qr.bgcolor}),jsxRuntimeExports.jsx("g",Object.assign({fill:qr.color},{children:Vr==null?void 0:Vr.map((Jr,Qr)=>{if(Jr===1){const _n=Qr%wr*Er,En=Math.floor(Qr/wr)*Er;return jsxRuntimeExports.jsx("rect",{width:Er,height:Er,x:_n,y:En},`${br}-${Qr}`)}})})),jsxRuntimeExports.jsx("g",Object.assign({fill:qr.spotcolor},{children:Vr==null?void 0:Vr.map((Jr,Qr)=>{if(Jr===2){const _n=Qr%wr*Er,En=Math.floor(Qr/wr)*Er;return jsxRuntimeExports.jsx("rect",{width:Er,height:Er,x:_n,y:En},`${br}-${Qr}`)}})}))]})):jsxRuntimeExports.jsx("svg",Object.assign({},Br,{width:Wr,height:Wr,viewBox:`0 0 ${Wr} ${Wr}`,xmlns:"http://www.w3.org/2000/svg"},{children:jsxRuntimeExports.jsx("rect",{width:Wr,height:Wr,fill:"black"})})):jsxRuntimeExports.jsx("svg",Object.assign({},Br,{width:Wr,height:Wr,viewBox:`0 0 ${Wr} ${Wr}`,xmlns:"http://www.w3.org/2000/svg"},{children:jsxRuntimeExports.jsx("rect",{width:Wr,height:Wr,fill:jr})}))}const WalletProfile=({selectedWallet:fr})=>{const{primaryWallet:br,handleLogOut:wr}=useDynamicContext(),Er=(fr==null?void 0:fr.address)||(br==null?void 0:br.address),kr=(fr==null?void 0:fr.name)??"Guest Wallet",[jr,Br]=reactExports.useState(!1),{dispatch:Wr}=useGlobalState(),qr=useNavigate();return jsxRuntimeExports.jsxs(Box,{display:"flex",flexDirection:"column",gap:"spacing-sm",width:"-webkit-fill-available",children:[jsxRuntimeExports.jsxs(Box,{display:"flex",justifyContent:"space-between",width:"-webkit-fill-available",children:[jsxRuntimeExports.jsx(PushLogo,{height:48,width:48}),jsxRuntimeExports.jsx(Box,{display:"flex",gap:"spacing-xxs",children:jsxRuntimeExports.jsx(Dropdown,{overlay:jsxRuntimeExports.jsx(Menu,{children:jsxRuntimeExports.jsx(MenuItem,{label:"Log Out",icon:jsxRuntimeExports.jsx(Logout,{}),onClick:()=>{sessionStorage.removeItem("jwt"),Wr({type:"RESET_AUTHENTICATED"}),Wr({type:"RESET_USER"}),localStorage.clear(),wr(),qr(APP_ROUTES.AUTH),localStorage.clear()}})}),children:jsxRuntimeExports.jsx(Box,{cursor:"pointer",children:jsxRuntimeExports.jsx(Settings,{size:24,color:"icon-primary"})})})})]}),jsxRuntimeExports.jsx(Box,{width:"56px",height:"56px",borderRadius:"radius-xl",overflow:"hidden",alignSelf:"center",children:jsxRuntimeExports.jsx(BlockiesSvg,{address:Er})}),jsxRuntimeExports.jsxs(Box,{display:"flex",flexDirection:"column",alignItems:"center",gap:"spacing-xxxs",children:[jsxRuntimeExports.jsx(Text,{variant:"bl-semibold",children:kr}),jsxRuntimeExports.jsxs(Box,{display:"flex",gap:"spacing-xxxs",children:[jsxRuntimeExports.jsx(Text,{variant:"bes-semibold",color:"text-tertiary",children:centerMaskWalletAddress(Er)}),jsxRuntimeExports.jsx(Box,{cursor:"pointer",children:jsxRuntimeExports.jsx(Tooltip,{title:jr?"Copy":"Copied",children:jr?jsxRuntimeExports.jsx(TickCircleFilled,{autoSize:!0,size:16,color:"icon-state-success-bold"}):jsxRuntimeExports.jsx(Copy,{color:"icon-tertiary",onClick:()=>handleCopy(Er,Br)})})})]})]})]})};var src$5={};const require$$0$b=getAugmentedNamespace(tslib_es6$4);var lib$1={},pushNetwork={},block$1={},validator$1={},utils$9={},hasRequiredUtils$5;function requireUtils$5(){if(hasRequiredUtils$5)return utils$9;hasRequiredUtils$5=1,Object.defineProperty(utils$9,"__esModule",{value:!0}),utils$9.getRandomElement=void 0;const fr=br=>{if(br.length===0)throw new Error("Array cannot be empty");const wr=Math.floor(Math.random()*br.length);return br[wr]};return utils$9.getRandomElement=fr,utils$9}const require$$2$3=getAugmentedNamespace(axios),version$h="1.0.6";let BaseError$1=class sS extends Error{constructor(br,wr={}){var Br;const Er=wr.cause instanceof sS?wr.cause.details:(Br=wr.cause)!=null&&Br.message?wr.cause.message:wr.details,kr=wr.cause instanceof sS&&wr.cause.docsPath||wr.docsPath,jr=[br||"An error occurred.","",...wr.metaMessages?[...wr.metaMessages,""]:[],...kr?[`Docs: https://abitype.dev${kr}`]:[],...Er?[`Details: ${Er}`]:[],`Version: abitype@${version$h}`].join(` + `,children:WALLETS_LOGO[Jr]||jsxRuntimeExports.jsx(Zr,{walletKey:Jr})}),jsxRuntimeExports.jsx(Text,{variant:"bs-semibold",color:"text-primary",children:Qr})]},Jr)):jsxRuntimeExports.jsx(WalletCategories,{setSelectedWalletCategory:wr}))})]})}),jsxRuntimeExports.jsx(PoweredByPush,{})]})},Authentication=()=>{const[fr,br]=reactExports.useState(""),[wr,Er]=reactExports.useState("authentication");return jsxRuntimeExports.jsx(ContentLayout,{footer:jsxRuntimeExports.jsx(Footer,{}),children:jsxRuntimeExports.jsx(BoxLayout,{children:jsxRuntimeExports.jsxs(Box,{alignItems:"center",flexDirection:"column",display:"flex",width:"376px",padding:"spacing-md",children:[(wr==="authentication"||wr==="social")&&jsxRuntimeExports.jsx(Login,{email:fr,setEmail:br,setConnectMethod:Er}),wr==="connectWallet"&&jsxRuntimeExports.jsx(WalletSelection,{setConnectMethod:Er})]})})})};function __rest$7(fr,br){var wr={};for(var Er in fr)Object.prototype.hasOwnProperty.call(fr,Er)&&br.indexOf(Er)<0&&(wr[Er]=fr[Er]);if(fr!=null&&typeof Object.getOwnPropertySymbols=="function")for(var kr=0,Er=Object.getOwnPropertySymbols(fr);kr>19^fr^fr>>8,(randseed[3]>>>0)/(1<<31>>>0)}function createColor(){const fr=Math.floor(rand()*360),br=(rand()*60+40).toFixed(1)+"%",wr=((rand()+rand()+rand()+rand())*25).toFixed(1)+"%";return"hsl("+fr+","+br+","+wr+")"}function createImageData(fr){const br=fr,wr=fr,Er=Math.ceil(br/2),kr=br-Er,jr=[];for(let Br=0;Br{if(br)if(store[br]&&store[br].opts.size===wr)Hr(store[br].opts),Zr(store[br].imageData);else{const Jr=buildOpts({seed:br,size:wr,scale:Er}),Qr=createImageData(Jr.size);Hr(Jr),Zr(Qr),store[br]={opts:Jr,imageData:Qr}}},[br]),br?qr&&Vr?jsxRuntimeExports.jsxs("svg",Object.assign({},Br,{width:Wr,height:Wr,viewBox:`0 0 ${Wr} ${Wr}`,xmlns:"http://www.w3.org/2000/svg"},{children:[jsxRuntimeExports.jsx("rect",{width:Wr,height:Wr,fill:qr.bgcolor}),jsxRuntimeExports.jsx("g",Object.assign({fill:qr.color},{children:Vr==null?void 0:Vr.map((Jr,Qr)=>{if(Jr===1){const _n=Qr%wr*Er,En=Math.floor(Qr/wr)*Er;return jsxRuntimeExports.jsx("rect",{width:Er,height:Er,x:_n,y:En},`${br}-${Qr}`)}})})),jsxRuntimeExports.jsx("g",Object.assign({fill:qr.spotcolor},{children:Vr==null?void 0:Vr.map((Jr,Qr)=>{if(Jr===2){const _n=Qr%wr*Er,En=Math.floor(Qr/wr)*Er;return jsxRuntimeExports.jsx("rect",{width:Er,height:Er,x:_n,y:En},`${br}-${Qr}`)}})}))]})):jsxRuntimeExports.jsx("svg",Object.assign({},Br,{width:Wr,height:Wr,viewBox:`0 0 ${Wr} ${Wr}`,xmlns:"http://www.w3.org/2000/svg"},{children:jsxRuntimeExports.jsx("rect",{width:Wr,height:Wr,fill:"black"})})):jsxRuntimeExports.jsx("svg",Object.assign({},Br,{width:Wr,height:Wr,viewBox:`0 0 ${Wr} ${Wr}`,xmlns:"http://www.w3.org/2000/svg"},{children:jsxRuntimeExports.jsx("rect",{width:Wr,height:Wr,fill:jr})}))}const WalletProfile=({selectedWallet:fr})=>{const{primaryWallet:br,handleLogOut:wr}=useDynamicContext(),Er=(fr==null?void 0:fr.address)||(br==null?void 0:br.address),kr=(fr==null?void 0:fr.name)??"Guest Wallet",[jr,Br]=reactExports.useState(!1),{dispatch:Wr}=useGlobalState(),qr=useNavigate();return jsxRuntimeExports.jsxs(Box,{display:"flex",flexDirection:"column",gap:"spacing-sm",width:"-webkit-fill-available",children:[jsxRuntimeExports.jsxs(Box,{display:"flex",justifyContent:"space-between",width:"-webkit-fill-available",children:[jsxRuntimeExports.jsx(PushLogo,{height:48,width:48}),jsxRuntimeExports.jsx(Box,{display:"flex",gap:"spacing-xxs",children:jsxRuntimeExports.jsx(Dropdown,{overlay:jsxRuntimeExports.jsx(Menu,{children:jsxRuntimeExports.jsx(MenuItem,{label:"Log Out",icon:jsxRuntimeExports.jsx(Logout,{}),onClick:()=>{sessionStorage.removeItem("jwt"),Wr({type:"RESET_AUTHENTICATED"}),Wr({type:"RESET_USER"}),localStorage.clear(),wr(),qr(APP_ROUTES.AUTH),localStorage.clear()}})}),children:jsxRuntimeExports.jsx(Box,{cursor:"pointer",children:jsxRuntimeExports.jsx(Settings,{size:24,color:"icon-primary"})})})})]}),jsxRuntimeExports.jsx(Box,{width:"56px",height:"56px",borderRadius:"radius-xl",overflow:"hidden",alignSelf:"center",children:jsxRuntimeExports.jsx(BlockiesSvg,{address:Er})}),jsxRuntimeExports.jsxs(Box,{display:"flex",flexDirection:"column",alignItems:"center",gap:"spacing-xxxs",children:[jsxRuntimeExports.jsx(Text,{variant:"bl-semibold",children:kr}),jsxRuntimeExports.jsxs(Box,{display:"flex",gap:"spacing-xxxs",children:[jsxRuntimeExports.jsx(Text,{variant:"bes-semibold",color:"text-tertiary",children:centerMaskWalletAddress(Er)}),jsxRuntimeExports.jsx(Box,{cursor:"pointer",children:jsxRuntimeExports.jsx(Tooltip,{title:jr?"Copy":"Copied",children:jr?jsxRuntimeExports.jsx(TickCircleFilled,{autoSize:!0,size:16,color:"icon-state-success-bold"}):jsxRuntimeExports.jsx(Copy,{color:"icon-tertiary",onClick:()=>handleCopy(Er,Br)})})})]})]})]})};var src$5={};const require$$0$b=getAugmentedNamespace(tslib_es6$4);var lib$1={},pushNetwork={},block$1={},validator$1={},utils$9={},hasRequiredUtils$5;function requireUtils$5(){if(hasRequiredUtils$5)return utils$9;hasRequiredUtils$5=1,Object.defineProperty(utils$9,"__esModule",{value:!0}),utils$9.getRandomElement=void 0;const fr=br=>{if(br.length===0)throw new Error("Array cannot be empty");const wr=Math.floor(Math.random()*br.length);return br[wr]};return utils$9.getRandomElement=fr,utils$9}const require$$2$3=getAugmentedNamespace(axios),version$h="1.0.6";let BaseError$1=class sS extends Error{constructor(br,wr={}){var Br;const Er=wr.cause instanceof sS?wr.cause.details:(Br=wr.cause)!=null&&Br.message?wr.cause.message:wr.details,kr=wr.cause instanceof sS&&wr.cause.docsPath||wr.docsPath,jr=[br||"An error occurred.","",...wr.metaMessages?[...wr.metaMessages,""]:[],...kr?[`Docs: https://abitype.dev${kr}`]:[],...Er?[`Details: ${Er}`]:[],`Version: abitype@${version$h}`].join(` `);super(jr),Object.defineProperty(this,"details",{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,"metaMessages",{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,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),wr.cause&&(this.cause=wr.cause),this.details=Er,this.docsPath=kr,this.metaMessages=wr.metaMessages,this.shortMessage=br}};function execTyped(fr,br){const wr=fr.exec(br);return wr==null?void 0:wr.groups}const bytesRegex$1=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,integerRegex$1=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,isTupleRegex=/^\(.+?\).*?$/,tupleRegex=/^tuple(?(\[(\d*)\])*)$/;function formatAbiParameter(fr){let br=fr.type;if(tupleRegex.test(fr.type)&&"components"in fr){br="(";const wr=fr.components.length;for(let kr=0;kr[a-zA-Z$_][a-zA-Z0-9$_]*)\((?.*?)\)$/;function isErrorSignature(fr){return errorSignatureRegex.test(fr)}function execErrorSignature(fr){return execTyped(errorSignatureRegex,fr)}const eventSignatureRegex=/^event (?[a-zA-Z$_][a-zA-Z0-9$_]*)\((?.*?)\)$/;function isEventSignature(fr){return eventSignatureRegex.test(fr)}function execEventSignature(fr){return execTyped(eventSignatureRegex,fr)}const functionSignatureRegex=/^function (?[a-zA-Z$_][a-zA-Z0-9$_]*)\((?.*?)\)(?: (?external|public{1}))?(?: (?pure|view|nonpayable|payable{1}))?(?: returns\s?\((?.*?)\))?$/;function isFunctionSignature(fr){return functionSignatureRegex.test(fr)}function execFunctionSignature(fr){return execTyped(functionSignatureRegex,fr)}const structSignatureRegex=/^struct (?[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?.*?)\}$/;function isStructSignature(fr){return structSignatureRegex.test(fr)}function execStructSignature(fr){return execTyped(structSignatureRegex,fr)}const constructorSignatureRegex=/^constructor\((?.*?)\)(?:\s(?payable{1}))?$/;function isConstructorSignature(fr){return constructorSignatureRegex.test(fr)}function execConstructorSignature(fr){return execTyped(constructorSignatureRegex,fr)}const fallbackSignatureRegex=/^fallback\(\) external(?:\s(?payable{1}))?$/;function isFallbackSignature(fr){return fallbackSignatureRegex.test(fr)}const receiveSignatureRegex=/^receive\(\) external payable$/;function isReceiveSignature(fr){return receiveSignatureRegex.test(fr)}const modifiers=new Set(["memory","indexed","storage","calldata"]),eventModifiers=new Set(["indexed"]),functionModifiers=new Set(["calldata","memory","storage"]);class InvalidAbiItemError extends BaseError$1{constructor({signature:br}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(br,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class UnknownTypeError extends BaseError$1{constructor({type:br}){super("Unknown type.",{metaMessages:[`Type "${br}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class UnknownSolidityTypeError extends BaseError$1{constructor({type:br}){super("Unknown type.",{metaMessages:[`Type "${br}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class InvalidAbiParameterError extends BaseError$1{constructor({param:br}){super("Failed to parse ABI parameter.",{details:`parseAbiParameter(${JSON.stringify(br,null,2)})`,docsPath:"/api/human#parseabiparameter-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiParameterError"})}}class InvalidAbiParametersError extends BaseError$1{constructor({params:br}){super("Failed to parse ABI parameters.",{details:`parseAbiParameters(${JSON.stringify(br,null,2)})`,docsPath:"/api/human#parseabiparameters-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiParametersError"})}}class InvalidParameterError extends BaseError$1{constructor({param:br}){super("Invalid ABI parameter.",{details:br}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class SolidityProtectedKeywordError extends BaseError$1{constructor({param:br,name:wr}){super("Invalid ABI parameter.",{details:br,metaMessages:[`"${wr}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class InvalidModifierError extends BaseError$1{constructor({param:br,type:wr,modifier:Er}){super("Invalid ABI parameter.",{details:br,metaMessages:[`Modifier "${Er}" not allowed${wr?` in "${wr}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class InvalidFunctionModifierError extends BaseError$1{constructor({param:br,type:wr,modifier:Er}){super("Invalid ABI parameter.",{details:br,metaMessages:[`Modifier "${Er}" not allowed${wr?` in "${wr}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${Er}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class InvalidAbiTypeParameterError extends BaseError$1{constructor({abiParameter:br}){super("Invalid ABI parameter.",{details:JSON.stringify(br,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class InvalidSignatureError extends BaseError$1{constructor({signature:br,type:wr}){super(`Invalid ${wr} signature.`,{details:br}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class UnknownSignatureError extends BaseError$1{constructor({signature:br}){super("Unknown signature.",{details:br}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class InvalidStructSignatureError extends BaseError$1{constructor({signature:br}){super("Invalid struct signature.",{details:br,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class CircularReferenceError extends BaseError$1{constructor({type:br}){super("Circular reference detected.",{metaMessages:[`Struct "${br}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class InvalidParenthesisError extends BaseError$1{constructor({current:br,depth:wr}){super("Unbalanced parentheses.",{metaMessages:[`"${br.trim()}" has too many ${wr>0?"opening":"closing"} parentheses.`],details:`Depth "${wr}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}function getParameterCacheKey(fr,br){return br?`${br}:${fr}`:fr}const parameterCache=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function parseSignature$1(fr,br={}){if(isFunctionSignature(fr)){const wr=execFunctionSignature(fr);if(!wr)throw new InvalidSignatureError({signature:fr,type:"function"});const Er=splitParameters(wr.parameters),kr=[],jr=Er.length;for(let Wr=0;Wr[a-zA-Z$_][a-zA-Z0-9$_]*)(?(?:\[\d*?\])+?)?(?:\s(?calldata|indexed|memory|storage{1}))?(?:\s(?[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,abiParameterWithTupleRegex=/^\((?.+?)\)(?(?:\[\d*?\])+?)?(?:\s(?calldata|indexed|memory|storage{1}))?(?:\s(?[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,dynamicIntegerRegex=/^u?int$/;function parseAbiParameter$1(fr,br){var Zr,Jr;const wr=getParameterCacheKey(fr,br==null?void 0:br.type);if(parameterCache.has(wr))return parameterCache.get(wr);const Er=isTupleRegex.test(fr),kr=execTyped(Er?abiParameterWithTupleRegex:abiParameterWithoutTupleRegex,fr);if(!kr)throw new InvalidParameterError({param:fr});if(kr.name&&isSolidityKeyword(kr.name))throw new SolidityProtectedKeywordError({param:fr,name:kr.name});const jr=kr.name?{name:kr.name}:{},Br=kr.modifier==="indexed"?{indexed:!0}:{},Wr=(br==null?void 0:br.structs)??{};let qr,Hr={};if(Er){qr="tuple";const Qr=splitParameters(kr.type),_n=[],En=Qr.length;for(let Cn=0;Cn[a-zA-Z$_][a-zA-Z0-9$_]*)(?(?:\[\d*?\])+?)?$/;function resolveStructs(fr,br,wr=new Set){const Er=[],kr=fr.length;for(let jr=0;jrbr(fr,jr)}function formatAbiItem(fr,{includeName:br=!1}={}){if(fr.type!=="function"&&fr.type!=="event"&&fr.type!=="error")throw new InvalidDefinitionTypeError(fr.type);return`${fr.name}(${formatAbiParams(fr.inputs,{includeName:br})})`}function formatAbiParams(fr,{includeName:br=!1}={}){return fr?fr.map(wr=>formatAbiParam(wr,{includeName:br})).join(br?", ":","):""}function formatAbiParam(fr,{includeName:br}){return fr.type.startsWith("tuple")?`(${formatAbiParams(fr.components,{includeName:br})})${fr.type.slice(5)}`:fr.type+(br&&fr.name?` ${fr.name}`:"")}function isHex(fr,{strict:br=!0}={}){return!fr||typeof fr!="string"?!1:br?/^0x[0-9a-fA-F]*$/.test(fr):fr.startsWith("0x")}function size$1(fr){return isHex(fr,{strict:!1})?Math.ceil((fr.length-2)/2):fr.length}const version$g="2.21.51";let errorConfig={getDocsUrl:({docsBaseUrl:fr,docsPath:br="",docsSlug:wr})=>br?`${fr??"https://viem.sh"}${br}${wr?`#${wr}`:""}`:void 0,version:`viem@${version$g}`};function setErrorConfig(fr){errorConfig=fr}class BaseError extends Error{constructor(br,wr={}){var Wr;const Er=(()=>{var qr;return wr.cause instanceof BaseError?wr.cause.details:(qr=wr.cause)!=null&&qr.message?wr.cause.message:wr.details})(),kr=wr.cause instanceof BaseError&&wr.cause.docsPath||wr.docsPath,jr=(Wr=errorConfig.getDocsUrl)==null?void 0:Wr.call(errorConfig,{...wr,docsPath:kr}),Br=[br||"An error occurred.","",...wr.metaMessages?[...wr.metaMessages,""]:[],...jr?[`Docs: ${jr}`]:[],...Er?[`Details: ${Er}`]:[],...errorConfig.version?[`Version: ${errorConfig.version}`]:[]].join(` `);super(Br,wr.cause?{cause:wr.cause}:void 0),Object.defineProperty(this,"details",{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,"metaMessages",{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,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=Er,this.docsPath=kr,this.metaMessages=wr.metaMessages,this.name=wr.name??this.name,this.shortMessage=br,this.version=version$g}walk(br){return walk(this,br)}}function walk(fr,br){return br!=null&&br(fr)?fr:fr&&typeof fr=="object"&&"cause"in fr&&fr.cause!==void 0?walk(fr.cause,br):br?null:fr}class AbiConstructorNotFoundError extends BaseError{constructor({docsPath:br}){super(["A constructor was not found on the ABI.","Make sure you are using the correct ABI and that the constructor exists on it."].join(` `),{docsPath:br,name:"AbiConstructorNotFoundError"})}}class AbiConstructorParamsNotFoundError extends BaseError{constructor({docsPath:br}){super(["Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.","Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."].join(` @@ -1705,7 +1705,7 @@ ${prettyStateOverride(Qr)}`),super(br.shortMessage,{cause:br,docsPath:Er,metaMes `),{cause:br,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(InsufficientFundsError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class IntrinsicGasTooHighError extends BaseError{constructor({cause:br,gas:wr}={}){super(`The amount of gas ${wr?`(${wr}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:br,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(IntrinsicGasTooHighError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class IntrinsicGasTooLowError extends BaseError{constructor({cause:br,gas:wr}={}){super(`The amount of gas ${wr?`(${wr}) `:""}provided for the transaction is too low.`,{cause:br,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(IntrinsicGasTooLowError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class TransactionTypeNotSupportedError extends BaseError{constructor({cause:br}){super("The transaction type is not supported for this chain.",{cause:br,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(TransactionTypeNotSupportedError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class TipAboveFeeCapError extends BaseError{constructor({cause:br,maxPriorityFeePerGas:wr,maxFeePerGas:Er}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${wr?` = ${formatGwei(wr)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${Er?` = ${formatGwei(Er)} gwei`:""}).`].join(` `),{cause:br,name:"TipAboveFeeCapError"})}}Object.defineProperty(TipAboveFeeCapError,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class UnknownNodeError extends BaseError{constructor({cause:br}){super(`An error occurred while executing: ${br==null?void 0:br.shortMessage}`,{cause:br,name:"UnknownNodeError"})}}function getNodeError(fr,br){const wr=(fr.details||"").toLowerCase(),Er=fr instanceof BaseError?fr.walk(kr=>(kr==null?void 0:kr.code)===ExecutionRevertedError.code):fr;return Er instanceof BaseError?new ExecutionRevertedError({cause:fr,message:Er.details}):ExecutionRevertedError.nodeMessage.test(wr)?new ExecutionRevertedError({cause:fr,message:fr.details}):FeeCapTooHighError.nodeMessage.test(wr)?new FeeCapTooHighError({cause:fr,maxFeePerGas:br==null?void 0:br.maxFeePerGas}):FeeCapTooLowError.nodeMessage.test(wr)?new FeeCapTooLowError({cause:fr,maxFeePerGas:br==null?void 0:br.maxFeePerGas}):NonceTooHighError.nodeMessage.test(wr)?new NonceTooHighError({cause:fr,nonce:br==null?void 0:br.nonce}):NonceTooLowError.nodeMessage.test(wr)?new NonceTooLowError({cause:fr,nonce:br==null?void 0:br.nonce}):NonceMaxValueError.nodeMessage.test(wr)?new NonceMaxValueError({cause:fr,nonce:br==null?void 0:br.nonce}):InsufficientFundsError.nodeMessage.test(wr)?new InsufficientFundsError({cause:fr}):IntrinsicGasTooHighError.nodeMessage.test(wr)?new IntrinsicGasTooHighError({cause:fr,gas:br==null?void 0:br.gas}):IntrinsicGasTooLowError.nodeMessage.test(wr)?new IntrinsicGasTooLowError({cause:fr,gas:br==null?void 0:br.gas}):TransactionTypeNotSupportedError.nodeMessage.test(wr)?new TransactionTypeNotSupportedError({cause:fr}):TipAboveFeeCapError.nodeMessage.test(wr)?new TipAboveFeeCapError({cause:fr,maxFeePerGas:br==null?void 0:br.maxFeePerGas,maxPriorityFeePerGas:br==null?void 0:br.maxPriorityFeePerGas}):new UnknownNodeError({cause:fr})}function getEstimateGasError(fr,{docsPath:br,...wr}){const Er=(()=>{const kr=getNodeError(fr,wr);return kr instanceof UnknownNodeError?fr:kr})();return new EstimateGasExecutionError(Er,{docsPath:br,...wr})}function extract(fr,{format:br}){if(!br)return{};const wr={};function Er(jr){const Br=Object.keys(jr);for(const Wr of Br)Wr in fr&&(wr[Wr]=fr[Wr]),jr[Wr]&&typeof jr[Wr]=="object"&&!Array.isArray(jr[Wr])&&Er(jr[Wr])}const kr=br(fr||{});return Er(kr),wr}function defineFormatter(fr,br){return({exclude:wr,format:Er})=>({exclude:wr,format:kr=>{const jr=br(kr);if(wr)for(const Br of wr)delete jr[Br];return{...jr,...Er(kr)}},type:fr})}const rpcTransactionType={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function formatTransactionRequest(fr){const br={};return typeof fr.authorizationList<"u"&&(br.authorizationList=formatAuthorizationList$1(fr.authorizationList)),typeof fr.accessList<"u"&&(br.accessList=fr.accessList),typeof fr.blobVersionedHashes<"u"&&(br.blobVersionedHashes=fr.blobVersionedHashes),typeof fr.blobs<"u"&&(typeof fr.blobs[0]!="string"?br.blobs=fr.blobs.map(wr=>bytesToHex$4(wr)):br.blobs=fr.blobs),typeof fr.data<"u"&&(br.data=fr.data),typeof fr.from<"u"&&(br.from=fr.from),typeof fr.gas<"u"&&(br.gas=numberToHex(fr.gas)),typeof fr.gasPrice<"u"&&(br.gasPrice=numberToHex(fr.gasPrice)),typeof fr.maxFeePerBlobGas<"u"&&(br.maxFeePerBlobGas=numberToHex(fr.maxFeePerBlobGas)),typeof fr.maxFeePerGas<"u"&&(br.maxFeePerGas=numberToHex(fr.maxFeePerGas)),typeof fr.maxPriorityFeePerGas<"u"&&(br.maxPriorityFeePerGas=numberToHex(fr.maxPriorityFeePerGas)),typeof fr.nonce<"u"&&(br.nonce=numberToHex(fr.nonce)),typeof fr.to<"u"&&(br.to=fr.to),typeof fr.type<"u"&&(br.type=rpcTransactionType[fr.type]),typeof fr.value<"u"&&(br.value=numberToHex(fr.value)),br}const defineTransactionRequest=defineFormatter("transactionRequest",formatTransactionRequest);function formatAuthorizationList$1(fr){return fr.map(br=>({address:br.contractAddress,r:br.r,s:br.s,chainId:numberToHex(br.chainId),nonce:numberToHex(br.nonce),...typeof br.yParity<"u"?{yParity:numberToHex(br.yParity)}:{},...typeof br.v<"u"&&typeof br.yParity>"u"?{v:numberToHex(br.v)}:{}}))}function serializeStateMapping(fr){if(!(!fr||fr.length===0))return fr.reduce((br,{slot:wr,value:Er})=>{if(wr.length!==66)throw new InvalidBytesLengthError({size:wr.length,targetSize:66,type:"hex"});if(Er.length!==66)throw new InvalidBytesLengthError({size:Er.length,targetSize:66,type:"hex"});return br[wr]=Er,br},{})}function serializeAccountStateOverride(fr){const{balance:br,nonce:wr,state:Er,stateDiff:kr,code:jr}=fr,Br={};if(jr!==void 0&&(Br.code=jr),br!==void 0&&(Br.balance=numberToHex(br)),wr!==void 0&&(Br.nonce=numberToHex(wr)),Er!==void 0&&(Br.state=serializeStateMapping(Er)),kr!==void 0){if(Br.state)throw new StateAssignmentConflictError;Br.stateDiff=serializeStateMapping(kr)}return Br}function serializeStateOverride(fr){if(!fr)return;const br={};for(const{address:wr,...Er}of fr){if(!isAddress(wr,{strict:!1}))throw new InvalidAddressError({address:wr});if(br[wr])throw new AccountStateConflictError({address:wr});br[wr]=serializeAccountStateOverride(Er)}return br}const maxInt8=2n**(8n-1n)-1n,maxInt16=2n**(16n-1n)-1n,maxInt24=2n**(24n-1n)-1n,maxInt32=2n**(32n-1n)-1n,maxInt40=2n**(40n-1n)-1n,maxInt48=2n**(48n-1n)-1n,maxInt56=2n**(56n-1n)-1n,maxInt64=2n**(64n-1n)-1n,maxInt72=2n**(72n-1n)-1n,maxInt80=2n**(80n-1n)-1n,maxInt88=2n**(88n-1n)-1n,maxInt96=2n**(96n-1n)-1n,maxInt104=2n**(104n-1n)-1n,maxInt112=2n**(112n-1n)-1n,maxInt120=2n**(120n-1n)-1n,maxInt128=2n**(128n-1n)-1n,maxInt136=2n**(136n-1n)-1n,maxInt144=2n**(144n-1n)-1n,maxInt152=2n**(152n-1n)-1n,maxInt160=2n**(160n-1n)-1n,maxInt168=2n**(168n-1n)-1n,maxInt176=2n**(176n-1n)-1n,maxInt184=2n**(184n-1n)-1n,maxInt192=2n**(192n-1n)-1n,maxInt200=2n**(200n-1n)-1n,maxInt208=2n**(208n-1n)-1n,maxInt216=2n**(216n-1n)-1n,maxInt224=2n**(224n-1n)-1n,maxInt232=2n**(232n-1n)-1n,maxInt240=2n**(240n-1n)-1n,maxInt248=2n**(248n-1n)-1n,maxInt256=2n**(256n-1n)-1n,minInt8=-(2n**(8n-1n)),minInt16=-(2n**(16n-1n)),minInt24=-(2n**(24n-1n)),minInt32=-(2n**(32n-1n)),minInt40=-(2n**(40n-1n)),minInt48=-(2n**(48n-1n)),minInt56=-(2n**(56n-1n)),minInt64=-(2n**(64n-1n)),minInt72=-(2n**(72n-1n)),minInt80=-(2n**(80n-1n)),minInt88=-(2n**(88n-1n)),minInt96=-(2n**(96n-1n)),minInt104=-(2n**(104n-1n)),minInt112=-(2n**(112n-1n)),minInt120=-(2n**(120n-1n)),minInt128=-(2n**(128n-1n)),minInt136=-(2n**(136n-1n)),minInt144=-(2n**(144n-1n)),minInt152=-(2n**(152n-1n)),minInt160=-(2n**(160n-1n)),minInt168=-(2n**(168n-1n)),minInt176=-(2n**(176n-1n)),minInt184=-(2n**(184n-1n)),minInt192=-(2n**(192n-1n)),minInt200=-(2n**(200n-1n)),minInt208=-(2n**(208n-1n)),minInt216=-(2n**(216n-1n)),minInt224=-(2n**(224n-1n)),minInt232=-(2n**(232n-1n)),minInt240=-(2n**(240n-1n)),minInt248=-(2n**(248n-1n)),minInt256=-(2n**(256n-1n)),maxUint8=2n**8n-1n,maxUint16=2n**16n-1n,maxUint24=2n**24n-1n,maxUint32=2n**32n-1n,maxUint40=2n**40n-1n,maxUint48=2n**48n-1n,maxUint56=2n**56n-1n,maxUint64=2n**64n-1n,maxUint72=2n**72n-1n,maxUint80=2n**80n-1n,maxUint88=2n**88n-1n,maxUint96=2n**96n-1n,maxUint104=2n**104n-1n,maxUint112=2n**112n-1n,maxUint120=2n**120n-1n,maxUint128=2n**128n-1n,maxUint136=2n**136n-1n,maxUint144=2n**144n-1n,maxUint152=2n**152n-1n,maxUint160=2n**160n-1n,maxUint168=2n**168n-1n,maxUint176=2n**176n-1n,maxUint184=2n**184n-1n,maxUint192=2n**192n-1n,maxUint200=2n**200n-1n,maxUint208=2n**208n-1n,maxUint216=2n**216n-1n,maxUint224=2n**224n-1n,maxUint232=2n**232n-1n,maxUint240=2n**240n-1n,maxUint248=2n**248n-1n,maxUint256=2n**256n-1n;function assertRequest(fr){const{account:br,gasPrice:wr,maxFeePerGas:Er,maxPriorityFeePerGas:kr,to:jr}=fr,Br=br?parseAccount(br):void 0;if(Br&&!isAddress(Br.address))throw new InvalidAddressError({address:Br.address});if(jr&&!isAddress(jr))throw new InvalidAddressError({address:jr});if(typeof wr<"u"&&(typeof Er<"u"||typeof kr<"u"))throw new FeeConflictError;if(Er&&Er>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:Er});if(kr&&Er&&kr>Er)throw new TipAboveFeeCapError({maxFeePerGas:Er,maxPriorityFeePerGas:kr})}class BaseFeeScalarError extends BaseError{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class Eip1559FeesNotSupportedError extends BaseError{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class MaxFeePerGasTooLowError extends BaseError{constructor({maxPriorityFeePerGas:br}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${formatGwei(br)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class BlockNotFoundError extends BaseError{constructor({blockHash:br,blockNumber:wr}){let Er="Block";br&&(Er=`Block at hash "${br}"`),wr&&(Er=`Block at number "${wr}"`),super(`${Er} could not be found.`,{name:"BlockNotFoundError"})}}const transactionType={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function formatTransaction(fr){const br={...fr,blockHash:fr.blockHash?fr.blockHash:null,blockNumber:fr.blockNumber?BigInt(fr.blockNumber):null,chainId:fr.chainId?hexToNumber$2(fr.chainId):void 0,gas:fr.gas?BigInt(fr.gas):void 0,gasPrice:fr.gasPrice?BigInt(fr.gasPrice):void 0,maxFeePerBlobGas:fr.maxFeePerBlobGas?BigInt(fr.maxFeePerBlobGas):void 0,maxFeePerGas:fr.maxFeePerGas?BigInt(fr.maxFeePerGas):void 0,maxPriorityFeePerGas:fr.maxPriorityFeePerGas?BigInt(fr.maxPriorityFeePerGas):void 0,nonce:fr.nonce?hexToNumber$2(fr.nonce):void 0,to:fr.to?fr.to:null,transactionIndex:fr.transactionIndex?Number(fr.transactionIndex):null,type:fr.type?transactionType[fr.type]:void 0,typeHex:fr.type?fr.type:void 0,value:fr.value?BigInt(fr.value):void 0,v:fr.v?BigInt(fr.v):void 0};return fr.authorizationList&&(br.authorizationList=formatAuthorizationList(fr.authorizationList)),br.yParity=(()=>{if(fr.yParity)return Number(fr.yParity);if(typeof br.v=="bigint"){if(br.v===0n||br.v===27n)return 0;if(br.v===1n||br.v===28n)return 1;if(br.v>=35n)return br.v%2n===0n?1:0}})(),br.type==="legacy"&&(delete br.accessList,delete br.maxFeePerBlobGas,delete br.maxFeePerGas,delete br.maxPriorityFeePerGas,delete br.yParity),br.type==="eip2930"&&(delete br.maxFeePerBlobGas,delete br.maxFeePerGas,delete br.maxPriorityFeePerGas),br.type==="eip1559"&&delete br.maxFeePerBlobGas,br}const defineTransaction=defineFormatter("transaction",formatTransaction);function formatAuthorizationList(fr){return fr.map(br=>({contractAddress:br.address,chainId:Number(br.chainId),nonce:Number(br.nonce),r:br.r,s:br.s,yParity:Number(br.yParity)}))}function formatBlock(fr){const br=(fr.transactions??[]).map(wr=>typeof wr=="string"?wr:formatTransaction(wr));return{...fr,baseFeePerGas:fr.baseFeePerGas?BigInt(fr.baseFeePerGas):null,blobGasUsed:fr.blobGasUsed?BigInt(fr.blobGasUsed):void 0,difficulty:fr.difficulty?BigInt(fr.difficulty):void 0,excessBlobGas:fr.excessBlobGas?BigInt(fr.excessBlobGas):void 0,gasLimit:fr.gasLimit?BigInt(fr.gasLimit):void 0,gasUsed:fr.gasUsed?BigInt(fr.gasUsed):void 0,hash:fr.hash?fr.hash:null,logsBloom:fr.logsBloom?fr.logsBloom:null,nonce:fr.nonce?fr.nonce:null,number:fr.number?BigInt(fr.number):null,size:fr.size?BigInt(fr.size):void 0,timestamp:fr.timestamp?BigInt(fr.timestamp):void 0,transactions:br,totalDifficulty:fr.totalDifficulty?BigInt(fr.totalDifficulty):null}}const defineBlock=defineFormatter("block",formatBlock);async function getBlock(fr,{blockHash:br,blockNumber:wr,blockTag:Er,includeTransactions:kr}={}){var Vr,Zr,Jr;const jr=Er??"latest",Br=kr??!1,Wr=wr!==void 0?numberToHex(wr):void 0;let qr=null;if(br?qr=await fr.request({method:"eth_getBlockByHash",params:[br,Br]},{dedupe:!0}):qr=await fr.request({method:"eth_getBlockByNumber",params:[Wr||jr,Br]},{dedupe:!!Wr}),!qr)throw new BlockNotFoundError({blockHash:br,blockNumber:wr});return(((Jr=(Zr=(Vr=fr.chain)==null?void 0:Vr.formatters)==null?void 0:Zr.block)==null?void 0:Jr.format)||formatBlock)(qr)}async function getGasPrice(fr){const br=await fr.request({method:"eth_gasPrice"});return BigInt(br)}async function estimateMaxPriorityFeePerGas(fr,br){return internal_estimateMaxPriorityFeePerGas(fr,br)}async function internal_estimateMaxPriorityFeePerGas(fr,br){var jr,Br;const{block:wr,chain:Er=fr.chain,request:kr}=br||{};try{const Wr=((jr=Er==null?void 0:Er.fees)==null?void 0:jr.maxPriorityFeePerGas)??((Br=Er==null?void 0:Er.fees)==null?void 0:Br.defaultPriorityFee);if(typeof Wr=="function"){const Hr=wr||await getAction(fr,getBlock,"getBlock")({}),Vr=await Wr({block:Hr,client:fr,request:kr});if(Vr===null)throw new Error;return Vr}if(typeof Wr<"u")return Wr;const qr=await fr.request({method:"eth_maxPriorityFeePerGas"});return hexToBigInt(qr)}catch{const[Wr,qr]=await Promise.all([wr?Promise.resolve(wr):getAction(fr,getBlock,"getBlock")({}),getAction(fr,getGasPrice,"getGasPrice")({})]);if(typeof Wr.baseFeePerGas!="bigint")throw new Eip1559FeesNotSupportedError;const Hr=qr-Wr.baseFeePerGas;return Hr<0n?0n:Hr}}async function estimateFeesPerGas$1(fr,br){return internal_estimateFeesPerGas(fr,br)}async function internal_estimateFeesPerGas(fr,br){var Jr,Qr;const{block:wr,chain:Er=fr.chain,request:kr,type:jr="eip1559"}=br||{},Br=await(async()=>{var _n,En;return typeof((_n=Er==null?void 0:Er.fees)==null?void 0:_n.baseFeeMultiplier)=="function"?Er.fees.baseFeeMultiplier({block:wr,client:fr,request:kr}):((En=Er==null?void 0:Er.fees)==null?void 0:En.baseFeeMultiplier)??1.2})();if(Br<1)throw new BaseFeeScalarError;const qr=10**(((Jr=Br.toString().split(".")[1])==null?void 0:Jr.length)??0),Hr=_n=>_n*BigInt(Math.ceil(Br*qr))/BigInt(qr),Vr=wr||await getAction(fr,getBlock,"getBlock")({});if(typeof((Qr=Er==null?void 0:Er.fees)==null?void 0:Qr.estimateFeesPerGas)=="function"){const _n=await Er.fees.estimateFeesPerGas({block:wr,client:fr,multiply:Hr,request:kr,type:jr});if(_n!==null)return _n}if(jr==="eip1559"){if(typeof Vr.baseFeePerGas!="bigint")throw new Eip1559FeesNotSupportedError;const _n=typeof(kr==null?void 0:kr.maxPriorityFeePerGas)=="bigint"?kr.maxPriorityFeePerGas:await internal_estimateMaxPriorityFeePerGas(fr,{block:Vr,chain:Er,request:kr}),En=Hr(Vr.baseFeePerGas);return{maxFeePerGas:(kr==null?void 0:kr.maxFeePerGas)??En+_n,maxPriorityFeePerGas:_n}}return{gasPrice:(kr==null?void 0:kr.gasPrice)??Hr(await getAction(fr,getGasPrice,"getGasPrice")({}))}}async function getTransactionCount(fr,{address:br,blockTag:wr="latest",blockNumber:Er}){const kr=await fr.request({method:"eth_getTransactionCount",params:[br,Er?numberToHex(Er):wr]},{dedupe:!!Er});return hexToNumber$2(kr)}function blobsToCommitments(fr){const{kzg:br}=fr,wr=fr.to??(typeof fr.blobs[0]=="string"?"hex":"bytes"),Er=typeof fr.blobs[0]=="string"?fr.blobs.map(jr=>hexToBytes$4(jr)):fr.blobs,kr=[];for(const jr of Er)kr.push(Uint8Array.from(br.blobToKzgCommitment(jr)));return wr==="bytes"?kr:kr.map(jr=>bytesToHex$4(jr))}function blobsToProofs(fr){const{kzg:br}=fr,wr=fr.to??(typeof fr.blobs[0]=="string"?"hex":"bytes"),Er=typeof fr.blobs[0]=="string"?fr.blobs.map(Br=>hexToBytes$4(Br)):fr.blobs,kr=typeof fr.commitments[0]=="string"?fr.commitments.map(Br=>hexToBytes$4(Br)):fr.commitments,jr=[];for(let Br=0;BrbytesToHex$4(Br))}function setBigUint64$2(fr,br,wr,Er){if(typeof fr.setBigUint64=="function")return fr.setBigUint64(br,wr,Er);const kr=BigInt(32),jr=BigInt(4294967295),Br=Number(wr>>kr&jr),Wr=Number(wr&jr),qr=Er?4:0,Hr=Er?0:4;fr.setUint32(br+qr,Br,Er),fr.setUint32(br+Hr,Wr,Er)}const Chi$2=(fr,br,wr)=>fr&br^~fr&wr,Maj$2=(fr,br,wr)=>fr&br^fr&wr^br≀let HashMD$2=class extends Hash$3{constructor(br,wr,Er,kr){super(),this.blockLen=br,this.outputLen=wr,this.padOffset=Er,this.isLE=kr,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(br),this.view=createView$2(this.buffer)}update(br){exists(this);const{view:wr,buffer:Er,blockLen:kr}=this;br=toBytes$2(br);const jr=br.length;for(let Br=0;Brkr-Br&&(this.process(Er,0),Br=0);for(let Zr=Br;ZrVr.length)throw new Error("_sha2: outputLen bigger than state");for(let Zr=0;Zr>>3,En=rotr$2(Qr,17)^rotr$2(Qr,19)^Qr>>>10;SHA256_W$2[Zr]=En+SHA256_W$2[Zr-7]+_n+SHA256_W$2[Zr-16]|0}let{A:Er,B:kr,C:jr,D:Br,E:Wr,F:qr,G:Hr,H:Vr}=this;for(let Zr=0;Zr<64;Zr++){const Jr=rotr$2(Wr,6)^rotr$2(Wr,11)^rotr$2(Wr,25),Qr=Vr+Jr+Chi$2(Wr,qr,Hr)+SHA256_K$2[Zr]+SHA256_W$2[Zr]|0,En=(rotr$2(Er,2)^rotr$2(Er,13)^rotr$2(Er,22))+Maj$2(Er,kr,jr)|0;Vr=Hr,Hr=qr,qr=Wr,Wr=Br+Qr|0,Br=jr,jr=kr,kr=Er,Er=Qr+En|0}Er=Er+this.A|0,kr=kr+this.B|0,jr=jr+this.C|0,Br=Br+this.D|0,Wr=Wr+this.E|0,qr=qr+this.F|0,Hr=Hr+this.G|0,Vr=Vr+this.H|0,this.set(Er,kr,jr,Br,Wr,qr,Hr,Vr)}roundClean(){SHA256_W$2.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const sha256$7=wrapConstructor$2(()=>new SHA256$2);function sha256$6(fr,br){const wr=br||"hex",Er=sha256$7(isHex(fr,{strict:!1})?toBytes$3(fr):fr);return wr==="bytes"?Er:toHex(Er)}function commitmentToVersionedHash(fr){const{commitment:br,version:wr=1}=fr,Er=fr.to??(typeof br=="string"?"hex":"bytes"),kr=sha256$6(br,"bytes");return kr.set([wr],0),Er==="bytes"?kr:bytesToHex$4(kr)}function commitmentsToVersionedHashes(fr){const{commitments:br,version:wr}=fr,Er=fr.to??(typeof br[0]=="string"?"hex":"bytes"),kr=[];for(const jr of br)kr.push(commitmentToVersionedHash({commitment:jr,to:Er,version:wr}));return kr}const blobsPerTransaction=6,bytesPerFieldElement=32,fieldElementsPerBlob=4096,bytesPerBlob=bytesPerFieldElement*fieldElementsPerBlob,maxBytesPerTransaction=bytesPerBlob*blobsPerTransaction-1-1*fieldElementsPerBlob*blobsPerTransaction,versionedHashVersionKzg=1;class BlobSizeTooLargeError extends BaseError{constructor({maxSize:br,size:wr}){super("Blob size is too large.",{metaMessages:[`Max: ${br} bytes`,`Given: ${wr} bytes`],name:"BlobSizeTooLargeError"})}}class EmptyBlobError extends BaseError{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class InvalidVersionedHashSizeError extends BaseError{constructor({hash:br,size:wr}){super(`Versioned hash "${br}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${wr}`],name:"InvalidVersionedHashSizeError"})}}class InvalidVersionedHashVersionError extends BaseError{constructor({hash:br,version:wr}){super(`Versioned hash "${br}" version is invalid.`,{metaMessages:[`Expected: ${versionedHashVersionKzg}`,`Received: ${wr}`],name:"InvalidVersionedHashVersionError"})}}function toBlobs(fr){const br=fr.to??(typeof fr.data=="string"?"hex":"bytes"),wr=typeof fr.data=="string"?hexToBytes$4(fr.data):fr.data,Er=size$1(wr);if(!Er)throw new EmptyBlobError;if(Er>maxBytesPerTransaction)throw new BlobSizeTooLargeError({maxSize:maxBytesPerTransaction,size:Er});const kr=[];let jr=!0,Br=0;for(;jr;){const Wr=createCursor(new Uint8Array(bytesPerBlob));let qr=0;for(;qrWr.bytes):kr.map(Wr=>bytesToHex$4(Wr.bytes))}function toBlobSidecars(fr){const{data:br,kzg:wr,to:Er}=fr,kr=fr.blobs??toBlobs({data:br,to:Er}),jr=fr.commitments??blobsToCommitments({blobs:kr,kzg:wr,to:Er}),Br=fr.proofs??blobsToProofs({blobs:kr,commitments:jr,kzg:wr,to:Er}),Wr=[];for(let qr=0;qr"u"&&Zr)if(qr){const In=await Cn();Jr.nonce=await qr.consume({address:Zr.address,chainId:In,client:fr})}else Jr.nonce=await getAction(fr,getTransactionCount,"getTransactionCount")({address:Zr.address,blockTag:"pending"});if((Hr.includes("fees")||Hr.includes("type"))&&typeof Vr>"u")try{Jr.type=getTransactionType(Jr)}catch{const In=await _n();Jr.type=typeof(In==null?void 0:In.baseFeePerGas)=="bigint"?"eip1559":"legacy"}if(Hr.includes("fees"))if(Jr.type!=="legacy"&&Jr.type!=="eip2930"){if(typeof Jr.maxFeePerGas>"u"||typeof Jr.maxPriorityFeePerGas>"u"){const In=await _n(),{maxFeePerGas:An,maxPriorityFeePerGas:jn}=await internal_estimateFeesPerGas(fr,{block:In,chain:kr,request:Jr});if(typeof br.maxPriorityFeePerGas>"u"&&br.maxFeePerGas&&br.maxFeePerGas"u"&&(Jr.gas=await getAction(fr,estimateGas$1,"estimateGas")({...Jr,account:Zr&&{address:Zr.address,type:"json-rpc"}})),assertRequest(Jr),delete Jr.parameters,Jr}async function getBalance(fr,{address:br,blockNumber:wr,blockTag:Er="latest"}){const kr=wr?numberToHex(wr):void 0,jr=await fr.request({method:"eth_getBalance",params:[br,kr||Er]});return BigInt(jr)}async function estimateGas$1(fr,br){var kr,jr,Br;const{account:wr=fr.account}=br,Er=wr?parseAccount(wr):void 0;try{let Gr=function(Sn){const{block:Rn,request:Pn,rpcStateOverride:On}=Sn;return fr.request({method:"eth_estimateGas",params:On?[Pn,Rn??"latest",On]:Rn?[Pn,Rn]:[Pn]})};const{accessList:Wr,authorizationList:qr,blobs:Hr,blobVersionedHashes:Vr,blockNumber:Zr,blockTag:Jr,data:Qr,gas:_n,gasPrice:En,maxFeePerBlobGas:Cn,maxFeePerGas:In,maxPriorityFeePerGas:An,nonce:jn,value:eo,stateOverride:ro,...to}=await prepareTransactionRequest(fr,{...br,parameters:(Er==null?void 0:Er.type)==="local"?void 0:["blobVersionedHashes"]}),oo=(Zr?numberToHex(Zr):void 0)||Jr,io=serializeStateOverride(ro),co=await(async()=>{if(to.to)return to.to;if(qr&&qr.length>0)return await recoverAuthorizationAddress({authorization:qr[0]}).catch(()=>{throw new BaseError("`to` is required. Could not infer from `authorizationList`")})})();assertRequest(br);const so=(Br=(jr=(kr=fr.chain)==null?void 0:kr.formatters)==null?void 0:jr.transactionRequest)==null?void 0:Br.format,Tn=(so||formatTransactionRequest)({...extract(to,{format:so}),from:Er==null?void 0:Er.address,accessList:Wr,authorizationList:qr,blobs:Hr,blobVersionedHashes:Vr,data:Qr,gas:_n,gasPrice:En,maxFeePerBlobGas:Cn,maxFeePerGas:In,maxPriorityFeePerGas:An,nonce:jn,to:co,value:eo});let Xr=BigInt(await Gr({block:oo,request:Tn,rpcStateOverride:io}));if(qr){const Sn=await getBalance(fr,{address:Tn.from}),Rn=await Promise.all(qr.map(async Pn=>{const{contractAddress:On}=Pn,Zn=await Gr({block:oo,request:{authorizationList:void 0,data:Qr,from:Er==null?void 0:Er.address,to:On,value:numberToHex(Sn)},rpcStateOverride:io}).catch(()=>100000n);return 2n*BigInt(Zn)}));Xr+=Rn.reduce((Pn,On)=>Pn+On,0n)}return Xr}catch(Wr){throw getEstimateGasError(Wr,{...br,account:Er,chain:fr.chain})}}async function estimateContractGas(fr,br){const{abi:wr,address:Er,args:kr,functionName:jr,...Br}=br,Wr=encodeFunctionData({abi:wr,args:kr,functionName:jr});try{return await getAction(fr,estimateGas$1,"estimateGas")({data:Wr,to:Er,...Br})}catch(qr){const Hr=Br.account?parseAccount(Br.account):void 0;throw getContractError(qr,{abi:wr,address:Er,args:kr,docsPath:"/docs/contract/estimateContractGas",functionName:jr,sender:Hr==null?void 0:Hr.address})}}function isAddressEqual(fr,br){if(!isAddress(fr,{strict:!1}))throw new InvalidAddressError({address:fr});if(!isAddress(br,{strict:!1}))throw new InvalidAddressError({address:br});return fr.toLowerCase()===br.toLowerCase()}const docsPath$5="/docs/contract/decodeEventLog";function decodeEventLog(fr){const{abi:br,data:wr,strict:Er,topics:kr}=fr,jr=Er??!0,[Br,...Wr]=kr;if(!Br)throw new AbiEventSignatureEmptyTopicsError({docsPath:docsPath$5});const qr=br.length===1?br[0]:br.find(En=>En.type==="event"&&Br===toEventSelector(formatAbiItem(En)));if(!(qr&&"name"in qr)||qr.type!=="event")throw new AbiEventSignatureNotFoundError(Br,{docsPath:docsPath$5});const{name:Hr,inputs:Vr}=qr,Zr=Vr==null?void 0:Vr.some(En=>!("name"in En&&En.name));let Jr=Zr?[]:{};const Qr=Vr.filter(En=>"indexed"in En&&En.indexed);for(let En=0;En!("indexed"in En&&En.indexed));if(_n.length>0){if(wr&&wr!=="0x")try{const En=decodeAbiParameters(_n,wr);if(En)if(Zr)Jr=[...Jr,...En];else for(let Cn=0;Cn<_n.length;Cn++)Jr[_n[Cn].name]=En[Cn]}catch(En){if(jr)throw En instanceof AbiDecodingDataSizeTooSmallError||En instanceof PositionOutOfBoundsError?new DecodeLogDataMismatch({abiItem:qr,data:wr,params:_n,size:size$1(wr)}):En}else if(jr)throw new DecodeLogDataMismatch({abiItem:qr,data:"0x",params:_n,size:0})}return{eventName:Hr,args:Object.values(Jr).length>0?Jr:void 0}}function decodeTopic({param:fr,value:br}){return fr.type==="string"||fr.type==="bytes"||fr.type==="tuple"||fr.type.match(/^(.*)\[(\d+)?\]$/)?br:(decodeAbiParameters([fr],br)||[])[0]}function parseEventLogs(fr){const{abi:br,args:wr,logs:Er,strict:kr=!0}=fr,jr=(()=>{if(fr.eventName)return Array.isArray(fr.eventName)?fr.eventName:[fr.eventName]})();return Er.map(Br=>{var Wr;try{const qr=br.find(Vr=>Vr.type==="event"&&Br.topics[0]===toEventSelector(Vr));if(!qr)return null;const Hr=decodeEventLog({...Br,abi:[qr],strict:kr});return jr&&!jr.includes(Hr.eventName)||!includesArgs({args:Hr.args,inputs:qr.inputs,matchArgs:wr})?null:{...Hr,...Br}}catch(qr){let Hr,Vr;if(qr instanceof AbiEventSignatureNotFoundError)return null;if(qr instanceof DecodeLogDataMismatch||qr instanceof DecodeLogTopicsMismatch){if(kr)return null;Hr=qr.abiItem.name,Vr=(Wr=qr.abiItem.inputs)==null?void 0:Wr.some(Zr=>!("name"in Zr&&Zr.name))}return{...Br,args:Vr?[]:{},eventName:Hr}}}).filter(Boolean)}function includesArgs(fr){const{args:br,inputs:wr,matchArgs:Er}=fr;if(!Er)return!0;if(!br)return!1;function kr(jr,Br,Wr){try{return jr.type==="address"?isAddressEqual(Br,Wr):jr.type==="string"||jr.type==="bytes"?keccak256(toBytes$3(Br))===Wr:Br===Wr}catch{return!1}}return Array.isArray(br)&&Array.isArray(Er)?Er.every((jr,Br)=>{if(jr==null)return!0;const Wr=wr[Br];return Wr?(Array.isArray(jr)?jr:[jr]).some(Hr=>kr(Wr,Hr,br[Br])):!1}):typeof br=="object"&&!Array.isArray(br)&&typeof Er=="object"&&!Array.isArray(Er)?Object.entries(Er).every(([jr,Br])=>{if(Br==null)return!0;const Wr=wr.find(Hr=>Hr.name===jr);return Wr?(Array.isArray(Br)?Br:[Br]).some(Hr=>kr(Wr,Hr,br[jr])):!1}):!1}function formatLog(fr,{args:br,eventName:wr}={}){return{...fr,blockHash:fr.blockHash?fr.blockHash:null,blockNumber:fr.blockNumber?BigInt(fr.blockNumber):null,logIndex:fr.logIndex?Number(fr.logIndex):null,transactionHash:fr.transactionHash?fr.transactionHash:null,transactionIndex:fr.transactionIndex?Number(fr.transactionIndex):null,...wr?{args:br,eventName:wr}:{}}}async function getLogs(fr,{address:br,blockHash:wr,fromBlock:Er,toBlock:kr,event:jr,events:Br,args:Wr,strict:qr}={}){const Hr=qr??!1,Vr=Br??(jr?[jr]:void 0);let Zr=[];Vr&&(Zr=[Vr.flatMap(En=>encodeEventTopics({abi:[En],eventName:En.name,args:Br?void 0:Wr}))],jr&&(Zr=Zr[0]));let Jr;wr?Jr=await fr.request({method:"eth_getLogs",params:[{address:br,topics:Zr,blockHash:wr}]}):Jr=await fr.request({method:"eth_getLogs",params:[{address:br,topics:Zr,fromBlock:typeof Er=="bigint"?numberToHex(Er):Er,toBlock:typeof kr=="bigint"?numberToHex(kr):kr}]});const Qr=Jr.map(_n=>formatLog(_n));return Vr?parseEventLogs({abi:Vr,args:Wr,logs:Qr,strict:Hr}):Qr}async function getContractEvents(fr,br){const{abi:wr,address:Er,args:kr,blockHash:jr,eventName:Br,fromBlock:Wr,toBlock:qr,strict:Hr}=br,Vr=Br?getAbiItem({abi:wr,name:Br}):void 0,Zr=Vr?void 0:wr.filter(Jr=>Jr.type==="event");return getAction(fr,getLogs,"getLogs")({address:Er,args:kr,blockHash:jr,event:Vr,events:Zr,fromBlock:Wr,toBlock:qr,strict:Hr})}const docsPath$4="/docs/contract/decodeFunctionResult";function decodeFunctionResult(fr){const{abi:br,args:wr,functionName:Er,data:kr}=fr;let jr=br[0];if(Er){const Wr=getAbiItem({abi:br,args:wr,name:Er});if(!Wr)throw new AbiFunctionNotFoundError(Er,{docsPath:docsPath$4});jr=Wr}if(jr.type!=="function")throw new AbiFunctionNotFoundError(void 0,{docsPath:docsPath$4});if(!jr.outputs)throw new AbiFunctionOutputsNotFoundError(jr.name,{docsPath:docsPath$4});const Br=decodeAbiParameters(jr.outputs,kr);if(Br&&Br.length>1)return Br;if(Br&&Br.length===1)return Br[0]}const multicall3Abi=[{inputs:[{components:[{name:"target",type:"address"},{name:"allowFailure",type:"bool"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate3",outputs:[{components:[{name:"success",type:"bool"},{name:"returnData",type:"bytes"}],name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"}],universalResolverErrors=[{inputs:[],name:"ResolverNotFound",type:"error"},{inputs:[],name:"ResolverWildcardNotSupported",type:"error"},{inputs:[],name:"ResolverNotContract",type:"error"},{inputs:[{name:"returnData",type:"bytes"}],name:"ResolverError",type:"error"},{inputs:[{components:[{name:"status",type:"uint16"},{name:"message",type:"string"}],name:"errors",type:"tuple[]"}],name:"HttpError",type:"error"}],universalResolverResolveAbi=[...universalResolverErrors,{name:"resolve",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes"},{name:"data",type:"bytes"}],outputs:[{name:"",type:"bytes"},{name:"address",type:"address"}]},{name:"resolve",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes"},{name:"data",type:"bytes"},{name:"gateways",type:"string[]"}],outputs:[{name:"",type:"bytes"},{name:"address",type:"address"}]}],universalResolverReverseAbi=[...universalResolverErrors,{name:"reverse",type:"function",stateMutability:"view",inputs:[{type:"bytes",name:"reverseName"}],outputs:[{type:"string",name:"resolvedName"},{type:"address",name:"resolvedAddress"},{type:"address",name:"reverseResolver"},{type:"address",name:"resolver"}]},{name:"reverse",type:"function",stateMutability:"view",inputs:[{type:"bytes",name:"reverseName"},{type:"string[]",name:"gateways"}],outputs:[{type:"string",name:"resolvedName"},{type:"address",name:"resolvedAddress"},{type:"address",name:"reverseResolver"},{type:"address",name:"resolver"}]}],textResolverAbi=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],addressResolverAbi=[{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"}],outputs:[{name:"",type:"address"}]},{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"coinType",type:"uint256"}],outputs:[{name:"",type:"bytes"}]}],universalSignatureValidatorAbi=[{inputs:[{name:"_signer",type:"address"},{name:"_hash",type:"bytes32"},{name:"_signature",type:"bytes"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"_signer",type:"address"},{name:"_hash",type:"bytes32"},{name:"_signature",type:"bytes"}],outputs:[{type:"bool"}],stateMutability:"nonpayable",type:"function",name:"isValidSig"}],erc20Abi$1=[{type:"event",name:"Approval",inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"event",name:"Transfer",inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],erc20Abi_bytes32=[{type:"event",name:"Approval",inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"event",name:"Transfer",inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],erc721Abi=[{type:"event",name:"Approval",inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!0,name:"tokenId",type:"uint256"}]},{type:"event",name:"ApprovalForAll",inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"operator",type:"address"},{indexed:!1,name:"approved",type:"bool"}]},{type:"event",name:"Transfer",inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!0,name:"tokenId",type:"uint256"}]},{type:"function",name:"approve",stateMutability:"payable",inputs:[{name:"spender",type:"address"},{name:"tokenId",type:"uint256"}],outputs:[]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"getApproved",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{type:"address"}]},{type:"function",name:"isApprovedForAll",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"operator",type:"address"}],outputs:[{type:"bool"}]},{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"ownerOf",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"owner",type:"address"}]},{type:"function",name:"safeTransferFrom",stateMutability:"payable",inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"}],outputs:[]},{type:"function",name:"safeTransferFrom",stateMutability:"nonpayable",inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"data",type:"bytes"}],outputs:[]},{type:"function",name:"setApprovalForAll",stateMutability:"nonpayable",inputs:[{name:"operator",type:"address"},{name:"approved",type:"bool"}],outputs:[]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"tokenByIndex",stateMutability:"view",inputs:[{name:"index",type:"uint256"}],outputs:[{type:"uint256"}]},{type:"function",name:"tokenByIndex",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"index",type:"uint256"}],outputs:[{name:"tokenId",type:"uint256"}]},{type:"function",name:"tokenURI",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{type:"string"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transferFrom",stateMutability:"payable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"tokeId",type:"uint256"}],outputs:[]}],erc4626Abi=[{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"sender",type:"address"},{indexed:!0,name:"receiver",type:"address"},{indexed:!1,name:"assets",type:"uint256"},{indexed:!1,name:"shares",type:"uint256"}],name:"Deposit",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"sender",type:"address"},{indexed:!0,name:"receiver",type:"address"},{indexed:!0,name:"owner",type:"address"},{indexed:!1,name:"assets",type:"uint256"},{indexed:!1,name:"shares",type:"uint256"}],name:"Withdraw",type:"event"},{inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],name:"allowance",outputs:[{type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],name:"approve",outputs:[{type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"asset",outputs:[{name:"assetTokenAddress",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"balanceOf",outputs:[{type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"shares",type:"uint256"}],name:"convertToAssets",outputs:[{name:"assets",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"assets",type:"uint256"}],name:"convertToShares",outputs:[{name:"shares",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"assets",type:"uint256"},{name:"receiver",type:"address"}],name:"deposit",outputs:[{name:"shares",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"caller",type:"address"}],name:"maxDeposit",outputs:[{name:"maxAssets",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"caller",type:"address"}],name:"maxMint",outputs:[{name:"maxShares",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"owner",type:"address"}],name:"maxRedeem",outputs:[{name:"maxShares",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"owner",type:"address"}],name:"maxWithdraw",outputs:[{name:"maxAssets",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"shares",type:"uint256"},{name:"receiver",type:"address"}],name:"mint",outputs:[{name:"assets",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"assets",type:"uint256"}],name:"previewDeposit",outputs:[{name:"shares",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"shares",type:"uint256"}],name:"previewMint",outputs:[{name:"assets",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"shares",type:"uint256"}],name:"previewRedeem",outputs:[{name:"assets",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"assets",type:"uint256"}],name:"previewWithdraw",outputs:[{name:"shares",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"shares",type:"uint256"},{name:"receiver",type:"address"},{name:"owner",type:"address"}],name:"redeem",outputs:[{name:"assets",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"totalAssets",outputs:[{name:"totalManagedAssets",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"to",type:"address"},{name:"amount",type:"uint256"}],name:"transfer",outputs:[{type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"assets",type:"uint256"},{name:"receiver",type:"address"},{name:"owner",type:"address"}],name:"withdraw",outputs:[{name:"shares",type:"uint256"}],stateMutability:"nonpayable",type:"function"}],aggregate3Signature="0x82ad56cb",deploylessCallViaBytecodeBytecode="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",deploylessCallViaFactoryBytecode="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",universalSignatureValidatorByteCode="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572";class ChainDoesNotSupportContract extends BaseError{constructor({blockNumber:br,chain:wr,contract:Er}){super(`Chain "${wr.name}" does not support contract "${Er.name}".`,{metaMessages:["This could be due to any of the following:",...br&&Er.blockCreated&&Er.blockCreated>br?[`- The contract "${Er.name}" was not deployed until block ${Er.blockCreated} (current block ${br}).`]:[`- The chain does not have the contract "${Er.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class ChainMismatchError extends BaseError{constructor({chain:br,currentChainId:wr}){super(`The current chain of the wallet (id: ${wr}) does not match the target chain for the transaction (id: ${br.id} – ${br.name}).`,{metaMessages:[`Current Chain ID: ${wr}`,`Expected Chain ID: ${br.id} – ${br.name}`],name:"ChainMismatchError"})}}class ChainNotFoundError extends BaseError{constructor(){super(["No chain was provided to the request.","Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."].join(` `),{name:"ChainNotFoundError"})}}class ClientChainNotConfiguredError extends BaseError{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class InvalidChainIdError extends BaseError{constructor({chainId:br}){super(typeof br=="number"?`Chain ID "${br}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}const docsPath$3="/docs/contract/encodeDeployData";function encodeDeployData(fr){const{abi:br,args:wr,bytecode:Er}=fr;if(!wr||wr.length===0)return Er;const kr=br.find(Br=>"type"in Br&&Br.type==="constructor");if(!kr)throw new AbiConstructorNotFoundError({docsPath:docsPath$3});if(!("inputs"in kr))throw new AbiConstructorParamsNotFoundError({docsPath:docsPath$3});if(!kr.inputs||kr.inputs.length===0)throw new AbiConstructorParamsNotFoundError({docsPath:docsPath$3});const jr=encodeAbiParameters(kr.inputs,wr);return concatHex([Er,jr])}function getChainContractAddress({blockNumber:fr,chain:br,contract:wr}){var kr;const Er=(kr=br==null?void 0:br.contracts)==null?void 0:kr[wr];if(!Er)throw new ChainDoesNotSupportContract({chain:br,contract:{name:wr}});if(fr&&Er.blockCreated&&Er.blockCreated>fr)throw new ChainDoesNotSupportContract({blockNumber:fr,chain:br,contract:{name:wr,blockCreated:Er.blockCreated}});return Er.address}function getCallError(fr,{docsPath:br,...wr}){const Er=(()=>{const kr=getNodeError(fr,wr);return kr instanceof UnknownNodeError?fr:kr})();return new CallExecutionError(Er,{docsPath:br,...wr})}function withResolvers(){let fr=()=>{},br=()=>{};return{promise:new Promise((Er,kr)=>{fr=Er,br=kr}),resolve:fr,reject:br}}const schedulerCache=new Map;function createBatchScheduler({fn:fr,id:br,shouldSplitBatch:wr,wait:Er=0,sort:kr}){const jr=async()=>{const Vr=qr();Br();const Zr=Vr.map(({args:Jr})=>Jr);Zr.length!==0&&fr(Zr).then(Jr=>{kr&&Array.isArray(Jr)&&Jr.sort(kr);for(let Qr=0;Qr{for(let Qr=0;QrschedulerCache.delete(br),Wr=()=>qr().map(({args:Vr})=>Vr),qr=()=>schedulerCache.get(br)||[],Hr=Vr=>schedulerCache.set(br,[...qr(),Vr]);return{flush:Br,async schedule(Vr){const{promise:Zr,resolve:Jr,reject:Qr}=withResolvers();return(wr==null?void 0:wr([...Wr(),Vr]))&&jr(),qr().length>0?(Hr({args:Vr,resolve:Jr,reject:Qr}),Zr):(Hr({args:Vr,resolve:Jr,reject:Qr}),setTimeout(jr,Er),Zr)}}}async function call(fr,br){var so,no,Tn,Gr;const{account:wr=fr.account,batch:Er=!!((so=fr.batch)!=null&&so.multicall),blockNumber:kr,blockTag:jr="latest",accessList:Br,blobs:Wr,code:qr,data:Hr,factory:Vr,factoryData:Zr,gas:Jr,gasPrice:Qr,maxFeePerBlobGas:_n,maxFeePerGas:En,maxPriorityFeePerGas:Cn,nonce:In,to:An,value:jn,stateOverride:eo,...ro}=br,to=wr?parseAccount(wr):void 0;if(qr&&(Vr||Zr))throw new BaseError("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(qr&&An)throw new BaseError("Cannot provide both `code` & `to` as parameters.");const _i=qr&&Hr,oo=Vr&&Zr&&An&&Hr,io=_i||oo,co=_i?toDeploylessCallViaBytecodeData({code:qr,data:Hr}):oo?toDeploylessCallViaFactoryData({data:Hr,factory:Vr,factoryData:Zr,to:An}):Hr;try{assertRequest(br);const Sn=(kr?numberToHex(kr):void 0)||jr,Rn=serializeStateOverride(eo),Pn=(Gr=(Tn=(no=fr.chain)==null?void 0:no.formatters)==null?void 0:Tn.transactionRequest)==null?void 0:Gr.format,Zn=(Pn||formatTransactionRequest)({...extract(ro,{format:Pn}),from:to==null?void 0:to.address,accessList:Br,blobs:Wr,data:co,gas:Jr,gasPrice:Qr,maxFeePerBlobGas:_n,maxFeePerGas:En,maxPriorityFeePerGas:Cn,nonce:In,to:io?void 0:An,value:jn});if(Er&&shouldPerformMulticall({request:Zn})&&!Rn)try{return await scheduleMulticall(fr,{...Zn,blockNumber:kr,blockTag:jr})}catch(wn){if(!(wn instanceof ClientChainNotConfiguredError)&&!(wn instanceof ChainDoesNotSupportContract))throw wn}const Nn=await fr.request({method:"eth_call",params:Rn?[Zn,Sn,Rn]:[Zn,Sn]});return Nn==="0x"?{data:void 0}:{data:Nn}}catch(Xr){const Sn=getRevertErrorData(Xr),{offchainLookup:Rn,offchainLookupSignature:Pn}=await __vitePreload(async()=>{const{offchainLookup:On,offchainLookupSignature:Zn}=await Promise.resolve().then(()=>ccip);return{offchainLookup:On,offchainLookupSignature:Zn}},void 0);if(fr.ccipRead!==!1&&(Sn==null?void 0:Sn.slice(0,10))===Pn&&An)return{data:await Rn(fr,{data:Sn,to:An})};throw io&&(Sn==null?void 0:Sn.slice(0,10))==="0x101bb98d"?new CounterfactualDeploymentFailedError({factory:Vr}):getCallError(Xr,{...br,account:to,chain:fr.chain})}}function shouldPerformMulticall({request:fr}){const{data:br,to:wr,...Er}=fr;return!(!br||br.startsWith(aggregate3Signature)||!wr||Object.values(Er).filter(kr=>typeof kr<"u").length>0)}async function scheduleMulticall(fr,br){var En;const{batchSize:wr=1024,wait:Er=0}=typeof((En=fr.batch)==null?void 0:En.multicall)=="object"?fr.batch.multicall:{},{blockNumber:kr,blockTag:jr="latest",data:Br,multicallAddress:Wr,to:qr}=br;let Hr=Wr;if(!Hr){if(!fr.chain)throw new ClientChainNotConfiguredError;Hr=getChainContractAddress({blockNumber:kr,chain:fr.chain,contract:"multicall3"})}const Zr=(kr?numberToHex(kr):void 0)||jr,{schedule:Jr}=createBatchScheduler({id:`${fr.uid}.${Zr}`,wait:Er,shouldSplitBatch(Cn){return Cn.reduce((An,{data:jn})=>An+(jn.length-2),0)>wr*2},fn:async Cn=>{const In=Cn.map(eo=>({allowFailure:!0,callData:eo.data,target:eo.to})),An=encodeFunctionData({abi:multicall3Abi,args:[In],functionName:"aggregate3"}),jn=await fr.request({method:"eth_call",params:[{data:An,to:Hr},Zr]});return decodeFunctionResult({abi:multicall3Abi,args:[In],functionName:"aggregate3",data:jn||"0x"})}}),[{returnData:Qr,success:_n}]=await Jr({data:Br,to:qr});if(!_n)throw new RawContractError({data:Qr});return Qr==="0x"?{data:void 0}:{data:Qr}}function toDeploylessCallViaBytecodeData(fr){const{code:br,data:wr}=fr;return encodeDeployData({abi:parseAbi(["constructor(bytes, bytes)"]),bytecode:deploylessCallViaBytecodeBytecode,args:[br,wr]})}function toDeploylessCallViaFactoryData(fr){const{data:br,factory:wr,factoryData:Er,to:kr}=fr;return encodeDeployData({abi:parseAbi(["constructor(address, bytes, address, bytes)"]),bytecode:deploylessCallViaFactoryBytecode,args:[kr,br,wr,Er]})}function getRevertErrorData(fr){var wr;if(!(fr instanceof BaseError))return;const br=fr.walk();return typeof(br==null?void 0:br.data)=="object"?(wr=br.data)==null?void 0:wr.data:br.data}async function readContract(fr,br){const{abi:wr,address:Er,args:kr,functionName:jr,...Br}=br,Wr=encodeFunctionData({abi:wr,args:kr,functionName:jr});try{const{data:qr}=await getAction(fr,call,"call")({...Br,data:Wr,to:Er});return decodeFunctionResult({abi:wr,args:kr,functionName:jr,data:qr||"0x"})}catch(qr){throw getContractError(qr,{abi:wr,address:Er,args:kr,docsPath:"/docs/contract/readContract",functionName:jr})}}async function simulateContract(fr,br){const{abi:wr,address:Er,args:kr,dataSuffix:jr,functionName:Br,...Wr}=br,qr=Wr.account?parseAccount(Wr.account):fr.account,Hr=encodeFunctionData({abi:wr,args:kr,functionName:Br});try{const{data:Vr}=await getAction(fr,call,"call")({batch:!1,data:`${Hr}${jr?jr.replace("0x",""):""}`,to:Er,...Wr,account:qr}),Zr=decodeFunctionResult({abi:wr,args:kr,functionName:Br,data:Vr||"0x"}),Jr=wr.filter(Qr=>"name"in Qr&&Qr.name===br.functionName);return{result:Zr,request:{abi:Jr,address:Er,args:kr,dataSuffix:jr,functionName:Br,...Wr,account:qr}}}catch(Vr){throw getContractError(Vr,{abi:wr,address:Er,args:kr,docsPath:"/docs/contract/simulateContract",functionName:Br,sender:qr==null?void 0:qr.address})}}const listenersCache=new Map,cleanupCache=new Map;let callbackCount=0;function observe(fr,br,wr){const Er=++callbackCount,kr=()=>listenersCache.get(fr)||[],jr=()=>{const Vr=kr();listenersCache.set(fr,Vr.filter(Zr=>Zr.id!==Er))},Br=()=>{const Vr=cleanupCache.get(fr);kr().length===1&&Vr&&Vr(),jr()},Wr=kr();if(listenersCache.set(fr,[...Wr,{id:Er,fns:br}]),Wr&&Wr.length>0)return Br;const qr={};for(const Vr in br)qr[Vr]=(...Zr)=>{var Qr,_n;const Jr=kr();if(Jr.length!==0)for(const En of Jr)(_n=(Qr=En.fns)[Vr])==null||_n.call(Qr,...Zr)};const Hr=wr(qr);return typeof Hr=="function"&&cleanupCache.set(fr,Hr),Br}async function wait(fr){return new Promise(br=>setTimeout(br,fr))}function poll(fr,{emitOnBegin:br,initialWaitTime:wr,interval:Er}){let kr=!0;const jr=()=>kr=!1;return(async()=>{let Wr;br&&(Wr=await fr({unpoll:jr}));const qr=await(wr==null?void 0:wr(Wr))??Er;await wait(qr);const Hr=async()=>{kr&&(await fr({unpoll:jr}),await wait(Er),Hr())};Hr()})(),jr}const promiseCache$1=new Map,responseCache=new Map;function getCache(fr){const br=(kr,jr)=>({clear:()=>jr.delete(kr),get:()=>jr.get(kr),set:Br=>jr.set(kr,Br)}),wr=br(fr,promiseCache$1),Er=br(fr,responseCache);return{clear:()=>{wr.clear(),Er.clear()},promise:wr,response:Er}}async function withCache(fr,{cacheKey:br,cacheTime:wr=Number.POSITIVE_INFINITY}){const Er=getCache(br),kr=Er.response.get();if(kr&&wr>0&&new Date().getTime()-kr.created.getTime()`blockNumber.${fr}`;async function getBlockNumber(fr,{cacheTime:br=fr.cacheTime}={}){const wr=await withCache(()=>fr.request({method:"eth_blockNumber"}),{cacheKey:cacheKey(fr.uid),cacheTime:br});return BigInt(wr)}async function getFilterChanges(fr,{filter:br}){const wr="strict"in br&&br.strict,Er=await br.request({method:"eth_getFilterChanges",params:[br.id]});if(typeof Er[0]=="string")return Er;const kr=Er.map(jr=>formatLog(jr));return!("abi"in br)||!br.abi?kr:parseEventLogs({abi:br.abi,logs:kr,strict:wr})}async function uninstallFilter(fr,{filter:br}){return br.request({method:"eth_uninstallFilter",params:[br.id]})}function watchContractEvent(fr,br){const{abi:wr,address:Er,args:kr,batch:jr=!0,eventName:Br,fromBlock:Wr,onError:qr,onLogs:Hr,poll:Vr,pollingInterval:Zr=fr.pollingInterval,strict:Jr}=br;return(typeof Vr<"u"?Vr:typeof Wr=="bigint"?!0:!(fr.transport.type==="webSocket"||fr.transport.type==="fallback"&&fr.transport.transports[0].config.type==="webSocket"))?(()=>{const Cn=Jr??!1,In=stringify$4(["watchContractEvent",Er,kr,jr,fr.uid,Br,Zr,Cn,Wr]);return observe(In,{onLogs:Hr,onError:qr},An=>{let jn;Wr!==void 0&&(jn=Wr-1n);let eo,ro=!1;const to=poll(async()=>{var _i;if(!ro){try{eo=await getAction(fr,createContractEventFilter,"createContractEventFilter")({abi:wr,address:Er,args:kr,eventName:Br,strict:Cn,fromBlock:Wr})}catch{}ro=!0;return}try{let oo;if(eo)oo=await getAction(fr,getFilterChanges,"getFilterChanges")({filter:eo});else{const io=await getAction(fr,getBlockNumber,"getBlockNumber")({});jn&&jn{eo&&await getAction(fr,uninstallFilter,"uninstallFilter")({filter:eo}),to()}})})():(()=>{const Cn=Jr??!1,In=stringify$4(["watchContractEvent",Er,kr,jr,fr.uid,Br,Zr,Cn]);let An=!0,jn=()=>An=!1;return observe(In,{onLogs:Hr,onError:qr},eo=>((async()=>{try{const ro=(()=>{if(fr.transport.type==="fallback"){const oo=fr.transport.transports.find(io=>io.config.type==="webSocket");return oo?oo.value:fr.transport}return fr.transport})(),to=Br?encodeEventTopics({abi:wr,eventName:Br,args:kr}):[],{unsubscribe:_i}=await ro.subscribe({params:["logs",{address:Er,topics:to}],onData(oo){var co;if(!An)return;const io=oo.result;try{const{eventName:so,args:no}=decodeEventLog({abi:wr,data:io.data,topics:io.topics,strict:Jr}),Tn=formatLog(io,{args:no,eventName:so});eo.onLogs([Tn])}catch(so){let no,Tn;if(so instanceof DecodeLogDataMismatch||so instanceof DecodeLogTopicsMismatch){if(Jr)return;no=so.abiItem.name,Tn=(co=so.abiItem.inputs)==null?void 0:co.some(Xr=>!("name"in Xr&&Xr.name))}const Gr=formatLog(io,{args:Tn?[]:{},eventName:no});eo.onLogs([Gr])}},onError(oo){var io;(io=eo.onError)==null||io.call(eo,oo)}});jn=_i,An||jn()}catch(ro){qr==null||qr(ro)}})(),()=>jn()))})()}class AccountNotFoundError extends BaseError{constructor({docsPath:br}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join(` -`),{docsPath:br,docsSlug:"account",name:"AccountNotFoundError"})}}class AccountTypeNotSupportedError extends BaseError{constructor({docsPath:br,metaMessages:wr,type:Er}){super(`Account type "${Er}" is not supported.`,{docsPath:br,metaMessages:wr,name:"AccountTypeNotSupportedError"})}}function assertCurrentChain({chain:fr,currentChainId:br}){if(!fr)throw new ChainNotFoundError;if(br!==fr.id)throw new ChainMismatchError({chain:fr,currentChainId:br})}function getTransactionError(fr,{docsPath:br,...wr}){const Er=(()=>{const kr=getNodeError(fr,wr);return kr instanceof UnknownNodeError?fr:kr})();return new TransactionExecutionError(Er,{docsPath:br,...wr})}async function sendRawTransaction(fr,{serializedTransaction:br}){return fr.request({method:"eth_sendRawTransaction",params:[br]},{retryCount:0})}const supportsWalletNamespace=new LruMap(128);async function sendTransaction(fr,br){var In,An,jn,eo;const{account:wr=fr.account,chain:Er=fr.chain,accessList:kr,authorizationList:jr,blobs:Br,data:Wr,gas:qr,gasPrice:Hr,maxFeePerBlobGas:Vr,maxFeePerGas:Zr,maxPriorityFeePerGas:Jr,nonce:Qr,value:_n,...En}=br;if(typeof wr>"u")throw new AccountNotFoundError({docsPath:"/docs/actions/wallet/sendTransaction"});const Cn=wr?parseAccount(wr):null;try{assertRequest(br);const ro=await(async()=>{if(br.to)return br.to;if(jr&&jr.length>0)return await recoverAuthorizationAddress({authorization:jr[0]}).catch(()=>{throw new BaseError("`to` is required. Could not infer from `authorizationList`.")})})();if((Cn==null?void 0:Cn.type)==="json-rpc"||Cn===null){let to;Er!==null&&(to=await getAction(fr,getChainId,"getChainId")({}),assertCurrentChain({currentChainId:to,chain:Er}));const _i=(jn=(An=(In=fr.chain)==null?void 0:In.formatters)==null?void 0:An.transactionRequest)==null?void 0:jn.format,io=(_i||formatTransactionRequest)({...extract(En,{format:_i}),accessList:kr,authorizationList:jr,blobs:Br,chainId:to,data:Wr,from:Cn==null?void 0:Cn.address,gas:qr,gasPrice:Hr,maxFeePerBlobGas:Vr,maxFeePerGas:Zr,maxPriorityFeePerGas:Jr,nonce:Qr,to:ro,value:_n}),co=supportsWalletNamespace.get(fr.uid),so=co?"wallet_sendTransaction":"eth_sendTransaction";try{return await fr.request({method:so,params:[io]},{retryCount:0})}catch(no){if(co===!1)throw no;const Tn=no;if(Tn.name==="InvalidInputRpcError"||Tn.name==="InvalidParamsRpcError"||Tn.name==="MethodNotFoundRpcError"||Tn.name==="MethodNotSupportedRpcError")return await fr.request({method:"wallet_sendTransaction",params:[io]},{retryCount:0}).then(Gr=>(supportsWalletNamespace.set(fr.uid,!0),Gr)).catch(Gr=>{const Xr=Gr;throw Xr.name==="MethodNotFoundRpcError"||Xr.name==="MethodNotSupportedRpcError"?(supportsWalletNamespace.set(fr.uid,!1),Tn):Xr});throw Tn}}if((Cn==null?void 0:Cn.type)==="local"){const to=await getAction(fr,prepareTransactionRequest,"prepareTransactionRequest")({account:Cn,accessList:kr,authorizationList:jr,blobs:Br,chain:Er,data:Wr,gas:qr,gasPrice:Hr,maxFeePerBlobGas:Vr,maxFeePerGas:Zr,maxPriorityFeePerGas:Jr,nonce:Qr,nonceManager:Cn.nonceManager,parameters:[...defaultParameters,"sidecars"],value:_n,...En,to:ro}),_i=(eo=Er==null?void 0:Er.serializers)==null?void 0:eo.transaction,oo=await Cn.signTransaction(to,{serializer:_i});return await getAction(fr,sendRawTransaction,"sendRawTransaction")({serializedTransaction:oo})}throw(Cn==null?void 0:Cn.type)==="smart"?new AccountTypeNotSupportedError({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new AccountTypeNotSupportedError({docsPath:"/docs/actions/wallet/sendTransaction",type:Cn==null?void 0:Cn.type})}catch(ro){throw ro instanceof AccountTypeNotSupportedError?ro:getTransactionError(ro,{...br,account:Cn,chain:br.chain||void 0})}}async function writeContract(fr,br){const{abi:wr,account:Er=fr.account,address:kr,args:jr,dataSuffix:Br,functionName:Wr,...qr}=br;if(typeof Er>"u")throw new AccountNotFoundError({docsPath:"/docs/contract/writeContract"});const Hr=Er?parseAccount(Er):null,Vr=encodeFunctionData({abi:wr,args:jr,functionName:Wr});try{return await getAction(fr,sendTransaction,"sendTransaction")({data:`${Vr}${Br?Br.replace("0x",""):""}`,to:kr,account:Hr,...qr})}catch(Zr){throw getContractError(Zr,{abi:wr,address:kr,args:jr,docsPath:"/docs/contract/writeContract",functionName:Wr,sender:Hr==null?void 0:Hr.address})}}function getContract({abi:fr,address:br,client:wr}){const Er=wr,[kr,jr]=Er?"public"in Er&&"wallet"in Er?[Er.public,Er.wallet]:"public"in Er?[Er.public,void 0]:"wallet"in Er?[void 0,Er.wallet]:[Er,Er]:[void 0,void 0],Br=kr!=null,Wr=jr!=null,qr={};let Hr=!1,Vr=!1,Zr=!1;for(const Jr of fr)if(Jr.type==="function"?Jr.stateMutability==="view"||Jr.stateMutability==="pure"?Hr=!0:Vr=!0:Jr.type==="event"&&(Zr=!0),Hr&&Vr&&Zr)break;return Br&&(Hr&&(qr.read=new Proxy({},{get(Jr,Qr){return(..._n)=>{const{args:En,options:Cn}=getFunctionParameters(_n);return getAction(kr,readContract,"readContract")({abi:fr,address:br,functionName:Qr,args:En,...Cn})}}})),Vr&&(qr.simulate=new Proxy({},{get(Jr,Qr){return(..._n)=>{const{args:En,options:Cn}=getFunctionParameters(_n);return getAction(kr,simulateContract,"simulateContract")({abi:fr,address:br,functionName:Qr,args:En,...Cn})}}})),Zr&&(qr.createEventFilter=new Proxy({},{get(Jr,Qr){return(..._n)=>{const En=fr.find(An=>An.type==="event"&&An.name===Qr),{args:Cn,options:In}=getEventParameters(_n,En);return getAction(kr,createContractEventFilter,"createContractEventFilter")({abi:fr,address:br,eventName:Qr,args:Cn,...In})}}}),qr.getEvents=new Proxy({},{get(Jr,Qr){return(..._n)=>{const En=fr.find(An=>An.type==="event"&&An.name===Qr),{args:Cn,options:In}=getEventParameters(_n,En);return getAction(kr,getContractEvents,"getContractEvents")({abi:fr,address:br,eventName:Qr,args:Cn,...In})}}}),qr.watchEvent=new Proxy({},{get(Jr,Qr){return(..._n)=>{const En=fr.find(An=>An.type==="event"&&An.name===Qr),{args:Cn,options:In}=getEventParameters(_n,En);return getAction(kr,watchContractEvent,"watchContractEvent")({abi:fr,address:br,eventName:Qr,args:Cn,...In})}}}))),Wr&&Vr&&(qr.write=new Proxy({},{get(Jr,Qr){return(..._n)=>{const{args:En,options:Cn}=getFunctionParameters(_n);return getAction(jr,writeContract,"writeContract")({abi:fr,address:br,functionName:Qr,args:En,...Cn})}}})),(Br||Wr)&&Vr&&(qr.estimateGas=new Proxy({},{get(Jr,Qr){return(..._n)=>{const{args:En,options:Cn}=getFunctionParameters(_n);return getAction(kr??jr,estimateContractGas,"estimateContractGas")({abi:fr,address:br,functionName:Qr,args:En,...Cn,account:Cn.account??jr.account})}}})),qr.address=br,qr.abi=fr,qr}function getFunctionParameters(fr){const br=fr.length&&Array.isArray(fr[0]),wr=br?fr[0]:[],Er=(br?fr[1]:fr[0])??{};return{args:wr,options:Er}}function getEventParameters(fr,br){let wr=!1;Array.isArray(fr[0])?wr=!0:fr.length===1?wr=br.inputs.some(jr=>jr.indexed):fr.length===2&&(wr=!0);const Er=wr?fr[0]:void 0,kr=(wr?fr[1]:fr[0])??{};return{args:Er,options:kr}}class Eip712DomainNotFoundError extends BaseError{constructor({address:br}){super(`No EIP-712 domain found on contract "${br}".`,{metaMessages:["Ensure that:",`- The contract is deployed at the address "${br}".`,"- `eip712Domain()` function exists on the contract.","- `eip712Domain()` function matches signature to ERC-5267 specification."],name:"Eip712DomainNotFoundError"})}}async function getEip712Domain$1(fr,br){const{address:wr,factory:Er,factoryData:kr}=br;try{const[jr,Br,Wr,qr,Hr,Vr,Zr]=await getAction(fr,readContract,"readContract")({abi:abi$2,address:wr,functionName:"eip712Domain",factory:Er,factoryData:kr});return{domain:{name:Br,version:Wr,chainId:Number(qr),verifyingContract:Hr,salt:Vr},extensions:Zr,fields:jr}}catch(jr){const Br=jr;throw Br.name==="ContractFunctionExecutionError"&&Br.cause.name==="ContractFunctionZeroDataError"?new Eip712DomainNotFoundError({address:wr}):Br}}const abi$2=[{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"}];async function addChain(fr,{chain:br}){const{id:wr,name:Er,nativeCurrency:kr,rpcUrls:jr,blockExplorers:Br}=br;await fr.request({method:"wallet_addEthereumChain",params:[{chainId:numberToHex(wr),chainName:Er,nativeCurrency:kr,rpcUrls:jr.default.http,blockExplorerUrls:Br?Object.values(Br).map(({url:Wr})=>Wr):void 0}]},{dedupe:!0,retryCount:0})}const size=256;let index=size,buffer$1;function uid(fr=11){if(!buffer$1||index+fr>size*2){buffer$1="",index=0;for(let br=0;br{const An=In(Cn);for(const eo in _n)delete An[eo];const jn={...Cn,...An};return Object.assign(jn,{extend:En(jn)})}}return Object.assign(_n,{extend:En(_n)})}function rpcSchema(){return null}const promiseCache=new LruMap(8192);function withDedupe(fr,{enabled:br=!0,id:wr}){if(!br||!wr)return fr();if(promiseCache.get(wr))return promiseCache.get(wr);const Er=fr().finally(()=>promiseCache.delete(wr));return promiseCache.set(wr,Er),Er}function withRetry(fr,{delay:br=100,retryCount:wr=2,shouldRetry:Er=()=>!0}={}){return new Promise((kr,jr)=>{const Br=async({count:Wr=0}={})=>{const qr=async({error:Hr})=>{const Vr=typeof br=="function"?br({count:Wr,error:Hr}):br;Vr&&await wait(Vr),Br({count:Wr+1})};try{const Hr=await fr();kr(Hr)}catch(Hr){if(Wr{const{dedupe:kr=!1,retryDelay:jr=150,retryCount:Br=3,uid:Wr}={...br,...Er},qr=kr?keccak256(stringToHex(`${Wr}.${stringify$4(wr)}`)):void 0;return withDedupe(()=>withRetry(async()=>{try{return await fr(wr)}catch(Hr){const Vr=Hr;switch(Vr.code){case ParseRpcError.code:throw new ParseRpcError(Vr);case InvalidRequestRpcError.code:throw new InvalidRequestRpcError(Vr);case MethodNotFoundRpcError.code:throw new MethodNotFoundRpcError(Vr,{method:wr.method});case InvalidParamsRpcError.code:throw new InvalidParamsRpcError(Vr);case InternalRpcError.code:throw new InternalRpcError(Vr);case InvalidInputRpcError.code:throw new InvalidInputRpcError(Vr);case ResourceNotFoundRpcError.code:throw new ResourceNotFoundRpcError(Vr);case ResourceUnavailableRpcError.code:throw new ResourceUnavailableRpcError(Vr);case TransactionRejectedRpcError.code:throw new TransactionRejectedRpcError(Vr);case MethodNotSupportedRpcError.code:throw new MethodNotSupportedRpcError(Vr,{method:wr.method});case LimitExceededRpcError.code:throw new LimitExceededRpcError(Vr);case JsonRpcVersionUnsupportedError.code:throw new JsonRpcVersionUnsupportedError(Vr);case UserRejectedRequestError.code:throw new UserRejectedRequestError(Vr);case UnauthorizedProviderError.code:throw new UnauthorizedProviderError(Vr);case UnsupportedProviderMethodError.code:throw new UnsupportedProviderMethodError(Vr);case ProviderDisconnectedError.code:throw new ProviderDisconnectedError(Vr);case ChainDisconnectedError.code:throw new ChainDisconnectedError(Vr);case SwitchChainError.code:throw new SwitchChainError(Vr);case 5e3:throw new UserRejectedRequestError(Vr);default:throw Hr instanceof BaseError?Hr:new UnknownRpcError(Vr)}}},{delay:({count:Hr,error:Vr})=>{var Zr;if(Vr&&Vr instanceof HttpRequestError){const Jr=(Zr=Vr==null?void 0:Vr.headers)==null?void 0:Zr.get("Retry-After");if(Jr!=null&&Jr.match(/\d/))return Number.parseInt(Jr)*1e3}return~~(1<shouldRetry(Hr)}),{enabled:kr,id:qr})}}function shouldRetry(fr){return"code"in fr&&typeof fr.code=="number"?fr.code===-1||fr.code===LimitExceededRpcError.code||fr.code===InternalRpcError.code:fr instanceof HttpRequestError&&fr.status?fr.status===403||fr.status===408||fr.status===413||fr.status===429||fr.status===500||fr.status===502||fr.status===503||fr.status===504:!0}function createTransport({key:fr,name:br,request:wr,retryCount:Er=3,retryDelay:kr=150,timeout:jr,type:Br},Wr){const qr=uid();return{config:{key:fr,name:br,request:wr,retryCount:Er,retryDelay:kr,timeout:jr,type:Br},request:buildRequest(wr,{retryCount:Er,retryDelay:kr,uid:qr}),value:Wr}}function custom(fr,br={}){const{key:wr="custom",name:Er="Custom Provider",retryDelay:kr}=br;return({retryCount:jr})=>createTransport({key:wr,name:Er,request:fr.request.bind(fr),retryCount:br.retryCount??jr,retryDelay:kr,type:"custom"})}function fallback(fr,br={}){const{key:wr="fallback",name:Er="Fallback",rank:kr=!1,retryCount:jr,retryDelay:Br}=br;return({chain:Wr,pollingInterval:qr=4e3,timeout:Hr,...Vr})=>{let Zr=fr,Jr=()=>{};const Qr=createTransport({key:wr,name:Er,async request({method:_n,params:En}){const Cn=async(In=0)=>{const An=Zr[In]({...Vr,chain:Wr,retryCount:0,timeout:Hr});try{const jn=await An.request({method:_n,params:En});return Jr({method:_n,params:En,response:jn,transport:An,status:"success"}),jn}catch(jn){if(Jr({error:jn,method:_n,params:En,transport:An,status:"error"}),shouldThrow(jn)||In===Zr.length-1)throw jn;return Cn(In+1)}};return Cn()},retryCount:jr,retryDelay:Br,type:"fallback"},{onResponse:_n=>Jr=_n,transports:Zr.map(_n=>_n({chain:Wr,retryCount:0}))});if(kr){const _n=typeof kr=="object"?kr:{};rankTransports({chain:Wr,interval:_n.interval??qr,onTransports:En=>Zr=En,sampleCount:_n.sampleCount,timeout:_n.timeout,transports:Zr,weights:_n.weights})}return Qr}}function shouldThrow(fr){return"code"in fr&&typeof fr.code=="number"&&(fr.code===TransactionRejectedRpcError.code||fr.code===UserRejectedRequestError.code||fr.code===5e3)}function rankTransports({chain:fr,interval:br=4e3,onTransports:wr,sampleCount:Er=10,timeout:kr=1e3,transports:jr,weights:Br={}}){const{stability:Wr=.7,latency:qr=.3}=Br,Hr=[],Vr=async()=>{const Zr=await Promise.all(jr.map(async _n=>{const En=_n({chain:fr,retryCount:0,timeout:kr}),Cn=Date.now();let In,An;try{await En.request({method:"net_listening"}),An=1}catch{An=0}finally{In=Date.now()}return{latency:In-Cn,success:An}}));Hr.push(Zr),Hr.length>Er&&Hr.shift();const Jr=Math.max(...Hr.map(_n=>Math.max(..._n.map(({latency:En})=>En)))),Qr=jr.map((_n,En)=>{const Cn=Hr.map(ro=>ro[En].latency),An=1-Cn.reduce((ro,to)=>ro+to,0)/Cn.length/Jr,jn=Hr.map(ro=>ro[En].success),eo=jn.reduce((ro,to)=>ro+to,0)/jn.length;return eo===0?[0,En]:[qr*An+Wr*eo,En]}).sort((_n,En)=>En[0]-_n[0]);wr(Qr.map(([,_n])=>jr[_n])),await wait(br),Vr()};Vr()}class UrlRequiredError extends BaseError{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function withTimeout(fr,{errorInstance:br=new Error("timed out"),timeout:wr,signal:Er}){return new Promise((kr,jr)=>{(async()=>{let Br;try{const Wr=new AbortController;wr>0&&(Br=setTimeout(()=>{Er?Wr.abort():jr(br)},wr)),kr(await fr({signal:(Wr==null?void 0:Wr.signal)||null}))}catch(Wr){(Wr==null?void 0:Wr.name)==="AbortError"&&jr(br),jr(Wr)}finally{clearTimeout(Br)}})()})}function createIdStore(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const idCache=createIdStore();function getHttpRpcClient(fr,br={}){return{async request(wr){var Zr;const{body:Er,onRequest:kr=br.onRequest,onResponse:jr=br.onResponse,timeout:Br=br.timeout??1e4}=wr,Wr={...br.fetchOptions??{},...wr.fetchOptions??{}},{headers:qr,method:Hr,signal:Vr}=Wr;try{const Jr=await withTimeout(async({signal:_n})=>{const En={...Wr,body:Array.isArray(Er)?stringify$4(Er.map(jn=>({jsonrpc:"2.0",id:jn.id??idCache.take(),...jn}))):stringify$4({jsonrpc:"2.0",id:Er.id??idCache.take(),...Er}),headers:{"Content-Type":"application/json",...qr},method:Hr||"POST",signal:Vr||(Br>0?_n:null)},Cn=new Request(fr,En),In=await(kr==null?void 0:kr(Cn,En))??{...En,url:fr};return await fetch(In.url??fr,In)},{errorInstance:new TimeoutError({body:Er,url:fr}),timeout:Br,signal:!0});jr&&await jr(Jr);let Qr;if((Zr=Jr.headers.get("Content-Type"))!=null&&Zr.startsWith("application/json"))Qr=await Jr.json();else{Qr=await Jr.text();try{Qr=JSON.parse(Qr||"{}")}catch(_n){if(Jr.ok)throw _n;Qr={error:Qr}}}if(!Jr.ok)throw new HttpRequestError({body:Er,details:stringify$4(Qr.error)||Jr.statusText,headers:Jr.headers,status:Jr.status,url:fr});return Qr}catch(Jr){throw Jr instanceof HttpRequestError||Jr instanceof TimeoutError?Jr:new HttpRequestError({body:Er,cause:Jr,url:fr})}}}}function http(fr,br={}){const{batch:wr,fetchOptions:Er,key:kr="http",name:jr="HTTP JSON-RPC",onFetchRequest:Br,onFetchResponse:Wr,retryDelay:qr}=br;return({chain:Hr,retryCount:Vr,timeout:Zr})=>{const{batchSize:Jr=1e3,wait:Qr=0}=typeof wr=="object"?wr:{},_n=br.retryCount??Vr,En=Zr??br.timeout??1e4,Cn=fr||(Hr==null?void 0:Hr.rpcUrls.default.http[0]);if(!Cn)throw new UrlRequiredError;const In=getHttpRpcClient(Cn,{fetchOptions:Er,onRequest:Br,onResponse:Wr,timeout:En});return createTransport({key:kr,name:jr,async request({method:An,params:jn}){const eo={method:An,params:jn},{schedule:ro}=createBatchScheduler({id:Cn,wait:Qr,shouldSplitBatch(io){return io.length>Jr},fn:io=>In.request({body:io}),sort:(io,co)=>io.id-co.id}),to=async io=>wr?ro(io):[await In.request({body:io})],[{error:_i,result:oo}]=await to(eo);if(_i)throw new RpcRequestError({body:eo,error:_i,url:Cn});return oo},retryCount:_n,retryDelay:qr,timeout:En,type:"http"},{fetchOptions:Er,url:Cn})}}function isNullUniversalResolverError(fr,br){var Er,kr,jr,Br,Wr,qr;if(!(fr instanceof BaseError))return!1;const wr=fr.walk(Hr=>Hr instanceof ContractFunctionRevertedError);return wr instanceof ContractFunctionRevertedError?!!(((Er=wr.data)==null?void 0:Er.errorName)==="ResolverNotFound"||((kr=wr.data)==null?void 0:kr.errorName)==="ResolverWildcardNotSupported"||((jr=wr.data)==null?void 0:jr.errorName)==="ResolverNotContract"||((Br=wr.data)==null?void 0:Br.errorName)==="ResolverError"||((Wr=wr.data)==null?void 0:Wr.errorName)==="HttpError"||(qr=wr.reason)!=null&&qr.includes("Wildcard on non-extended resolvers is not supported")||br==="reverse"&&wr.reason===panicReasons[50]):!1}function encodedLabelToLabelhash(fr){if(fr.length!==66||fr.indexOf("[")!==0||fr.indexOf("]")!==65)return null;const br=`0x${fr.slice(1,65)}`;return isHex(br)?br:null}function namehash(fr){let br=new Uint8Array(32).fill(0);if(!fr)return bytesToHex$4(br);const wr=fr.split(".");for(let Er=wr.length-1;Er>=0;Er-=1){const kr=encodedLabelToLabelhash(wr[Er]),jr=kr?toBytes$3(kr):keccak256(stringToBytes$1(wr[Er]),"bytes");br=keccak256(concat$1([br,jr]),"bytes")}return bytesToHex$4(br)}function encodeLabelhash(fr){return`[${fr.slice(2)}]`}function labelhash(fr){const br=new Uint8Array(32).fill(0);return fr?encodedLabelToLabelhash(fr)||keccak256(stringToBytes$1(fr)):bytesToHex$4(br)}function packetToBytes(fr){const br=fr.replace(/^\.|\.$/gm,"");if(br.length===0)return new Uint8Array(1);const wr=new Uint8Array(stringToBytes$1(br).byteLength+2);let Er=0;const kr=br.split(".");for(let jr=0;jr255&&(Br=stringToBytes$1(encodeLabelhash(labelhash(kr[jr])))),wr[Er]=Br.length,wr.set(Br,Er+1),Er+=Br.length+1}return wr.byteLength!==Er+1?wr.slice(0,Er+1):wr}async function getEnsAddress(fr,{blockNumber:br,blockTag:wr,coinType:Er,name:kr,gatewayUrls:jr,strict:Br,universalResolverAddress:Wr}){let qr=Wr;if(!qr){if(!fr.chain)throw new Error("client chain not configured. universalResolverAddress is required.");qr=getChainContractAddress({blockNumber:br,chain:fr.chain,contract:"ensUniversalResolver"})}try{const Hr=encodeFunctionData({abi:addressResolverAbi,functionName:"addr",...Er!=null?{args:[namehash(kr),BigInt(Er)]}:{args:[namehash(kr)]}}),Vr={address:qr,abi:universalResolverResolveAbi,functionName:"resolve",args:[toHex(packetToBytes(kr)),Hr],blockNumber:br,blockTag:wr},Zr=getAction(fr,readContract,"readContract"),Jr=jr?await Zr({...Vr,args:[...Vr.args,jr]}):await Zr(Vr);if(Jr[0]==="0x")return null;const Qr=decodeFunctionResult({abi:addressResolverAbi,args:Er!=null?[namehash(kr),BigInt(Er)]:void 0,functionName:"addr",data:Jr[0]});return Qr==="0x"||trim(Qr)==="0x00"?null:Qr}catch(Hr){if(Br)throw Hr;if(isNullUniversalResolverError(Hr,"resolve"))return null;throw Hr}}class EnsAvatarInvalidMetadataError extends BaseError{constructor({data:br}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(br)}`],name:"EnsAvatarInvalidMetadataError"})}}class EnsAvatarInvalidNftUriError extends BaseError{constructor({reason:br}){super(`ENS NFT avatar URI is invalid. ${br}`,{name:"EnsAvatarInvalidNftUriError"})}}class EnsAvatarUriResolutionError extends BaseError{constructor({uri:br}){super(`Unable to resolve ENS avatar URI "${br}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class EnsAvatarUnsupportedNamespaceError extends BaseError{constructor({namespace:br}){super(`ENS NFT avatar namespace "${br}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const networkRegex=/(?https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?\/)?(?ipfs\/|ipns\/)?(?[\w\-.]+)(?\/.*)?/,ipfsHashRegex=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?[\w\-.]+))?(?\/.*)?$/,base64Regex=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,dataURIRegex=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function isImageUri(fr){try{const br=await fetch(fr,{method:"HEAD"});if(br.status===200){const wr=br.headers.get("content-type");return wr==null?void 0:wr.startsWith("image/")}return!1}catch(br){return typeof br=="object"&&typeof br.response<"u"||!globalThis.hasOwnProperty("Image")?!1:new Promise(wr=>{const Er=new Image;Er.onload=()=>{wr(!0)},Er.onerror=()=>{wr(!1)},Er.src=fr})}}function getGateway(fr,br){return fr?fr.endsWith("/")?fr.slice(0,-1):fr:br}function resolveAvatarUri({uri:fr,gatewayUrls:br}){const wr=base64Regex.test(fr);if(wr)return{uri:fr,isOnChain:!0,isEncoded:wr};const Er=getGateway(br==null?void 0:br.ipfs,"https://ipfs.io"),kr=getGateway(br==null?void 0:br.arweave,"https://arweave.net"),jr=fr.match(networkRegex),{protocol:Br,subpath:Wr,target:qr,subtarget:Hr=""}=(jr==null?void 0:jr.groups)||{},Vr=Br==="ipns:/"||Wr==="ipns/",Zr=Br==="ipfs:/"||Wr==="ipfs/"||ipfsHashRegex.test(fr);if(fr.startsWith("http")&&!Vr&&!Zr){let Qr=fr;return br!=null&&br.arweave&&(Qr=fr.replace(/https:\/\/arweave.net/g,br==null?void 0:br.arweave)),{uri:Qr,isOnChain:!1,isEncoded:!1}}if((Vr||Zr)&&qr)return{uri:`${Er}/${Vr?"ipns":"ipfs"}/${qr}${Hr}`,isOnChain:!1,isEncoded:!1};if(Br==="ar:/"&&qr)return{uri:`${kr}/${qr}${Hr||""}`,isOnChain:!1,isEncoded:!1};let Jr=fr.replace(dataURIRegex,"");if(Jr.startsWith("kr.json());return await parseAvatarUri({gatewayUrls:fr,uri:getJsonImage(wr)})}catch{throw new EnsAvatarUriResolutionError({uri:br})}}async function parseAvatarUri({gatewayUrls:fr,uri:br}){const{uri:wr,isOnChain:Er}=resolveAvatarUri({uri:br,gatewayUrls:fr});if(Er||await isImageUri(wr))return wr;throw new EnsAvatarUriResolutionError({uri:br})}function parseNftUri(fr){let br=fr;br.startsWith("did:nft:")&&(br=br.replace("did:nft:","").replace(/_/g,"/"));const[wr,Er,kr]=br.split("/"),[jr,Br]=wr.split(":"),[Wr,qr]=Er.split(":");if(!jr||jr.toLowerCase()!=="eip155")throw new EnsAvatarInvalidNftUriError({reason:"Only EIP-155 supported"});if(!Br)throw new EnsAvatarInvalidNftUriError({reason:"Chain ID not found"});if(!qr)throw new EnsAvatarInvalidNftUriError({reason:"Contract address not found"});if(!kr)throw new EnsAvatarInvalidNftUriError({reason:"Token ID not found"});if(!Wr)throw new EnsAvatarInvalidNftUriError({reason:"ERC namespace not found"});return{chainID:Number.parseInt(Br),namespace:Wr.toLowerCase(),contractAddress:qr,tokenID:kr}}async function getNftTokenUri(fr,{nft:br}){if(br.namespace==="erc721")return readContract(fr,{address:br.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(br.tokenID)]});if(br.namespace==="erc1155")return readContract(fr,{address:br.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(br.tokenID)]});throw new EnsAvatarUnsupportedNamespaceError({namespace:br.namespace})}async function parseAvatarRecord(fr,{gatewayUrls:br,record:wr}){return/eip155:/i.test(wr)?parseNftAvatarUri(fr,{gatewayUrls:br,record:wr}):parseAvatarUri({uri:wr,gatewayUrls:br})}async function parseNftAvatarUri(fr,{gatewayUrls:br,record:wr}){const Er=parseNftUri(wr),kr=await getNftTokenUri(fr,{nft:Er}),{uri:jr,isOnChain:Br,isEncoded:Wr}=resolveAvatarUri({uri:kr,gatewayUrls:br});if(Br&&(jr.includes("data:application/json;base64,")||jr.startsWith("{"))){const Hr=Wr?atob(jr.replace("data:application/json;base64,","")):jr,Vr=JSON.parse(Hr);return parseAvatarUri({uri:getJsonImage(Vr),gatewayUrls:br})}let qr=Er.tokenID;return Er.namespace==="erc1155"&&(qr=qr.replace("0x","").padStart(64,"0")),getMetadataAvatarUri({gatewayUrls:br,uri:jr.replace(/(?:0x)?{id}/,qr)})}async function getEnsText(fr,{blockNumber:br,blockTag:wr,name:Er,key:kr,gatewayUrls:jr,strict:Br,universalResolverAddress:Wr}){let qr=Wr;if(!qr){if(!fr.chain)throw new Error("client chain not configured. universalResolverAddress is required.");qr=getChainContractAddress({blockNumber:br,chain:fr.chain,contract:"ensUniversalResolver"})}try{const Hr={address:qr,abi:universalResolverResolveAbi,functionName:"resolve",args:[toHex(packetToBytes(Er)),encodeFunctionData({abi:textResolverAbi,functionName:"text",args:[namehash(Er),kr]})],blockNumber:br,blockTag:wr},Vr=getAction(fr,readContract,"readContract"),Zr=jr?await Vr({...Hr,args:[...Hr.args,jr]}):await Vr(Hr);if(Zr[0]==="0x")return null;const Jr=decodeFunctionResult({abi:textResolverAbi,functionName:"text",data:Zr[0]});return Jr===""?null:Jr}catch(Hr){if(Br)throw Hr;if(isNullUniversalResolverError(Hr,"resolve"))return null;throw Hr}}async function getEnsAvatar(fr,{blockNumber:br,blockTag:wr,assetGatewayUrls:Er,name:kr,gatewayUrls:jr,strict:Br,universalResolverAddress:Wr}){const qr=await getAction(fr,getEnsText,"getEnsText")({blockNumber:br,blockTag:wr,key:"avatar",name:kr,universalResolverAddress:Wr,gatewayUrls:jr,strict:Br});if(!qr)return null;try{return await parseAvatarRecord(fr,{record:qr,gatewayUrls:Er})}catch{return null}}async function getEnsName(fr,{address:br,blockNumber:wr,blockTag:Er,gatewayUrls:kr,strict:jr,universalResolverAddress:Br}){let Wr=Br;if(!Wr){if(!fr.chain)throw new Error("client chain not configured. universalResolverAddress is required.");Wr=getChainContractAddress({blockNumber:wr,chain:fr.chain,contract:"ensUniversalResolver"})}const qr=`${br.toLowerCase().substring(2)}.addr.reverse`;try{const Hr={address:Wr,abi:universalResolverReverseAbi,functionName:"reverse",args:[toHex(packetToBytes(qr))],blockNumber:wr,blockTag:Er},Vr=getAction(fr,readContract,"readContract"),[Zr,Jr]=kr?await Vr({...Hr,args:[...Hr.args,kr]}):await Vr(Hr);return br.toLowerCase()!==Jr.toLowerCase()?null:Zr}catch(Hr){if(jr)throw Hr;if(isNullUniversalResolverError(Hr,"reverse"))return null;throw Hr}}async function getEnsResolver(fr,{blockNumber:br,blockTag:wr,name:Er,universalResolverAddress:kr}){let jr=kr;if(!jr){if(!fr.chain)throw new Error("client chain not configured. universalResolverAddress is required.");jr=getChainContractAddress({blockNumber:br,chain:fr.chain,contract:"ensUniversalResolver"})}const[Br]=await getAction(fr,readContract,"readContract")({address:jr,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[toHex(packetToBytes(Er))],blockNumber:br,blockTag:wr});return Br}async function createBlockFilter(fr){const br=createFilterRequestScope(fr,{method:"eth_newBlockFilter"}),wr=await fr.request({method:"eth_newBlockFilter"});return{id:wr,request:br(wr),type:"block"}}async function createEventFilter(fr,{address:br,args:wr,event:Er,events:kr,fromBlock:jr,strict:Br,toBlock:Wr}={}){const qr=kr??(Er?[Er]:void 0),Hr=createFilterRequestScope(fr,{method:"eth_newFilter"});let Vr=[];qr&&(Vr=[qr.flatMap(Qr=>encodeEventTopics({abi:[Qr],eventName:Qr.name,args:wr}))],Er&&(Vr=Vr[0]));const Zr=await fr.request({method:"eth_newFilter",params:[{address:br,fromBlock:typeof jr=="bigint"?numberToHex(jr):jr,toBlock:typeof Wr=="bigint"?numberToHex(Wr):Wr,...Vr.length?{topics:Vr}:{}}]});return{abi:qr,args:wr,eventName:Er?Er.name:void 0,fromBlock:jr,id:Zr,request:Hr(Zr),strict:!!Br,toBlock:Wr,type:"event"}}async function createPendingTransactionFilter(fr){const br=createFilterRequestScope(fr,{method:"eth_newPendingTransactionFilter"}),wr=await fr.request({method:"eth_newPendingTransactionFilter"});return{id:wr,request:br(wr),type:"transaction"}}async function getBlobBaseFee(fr){const br=await fr.request({method:"eth_blobBaseFee"});return BigInt(br)}async function getBlockTransactionCount(fr,{blockHash:br,blockNumber:wr,blockTag:Er="latest"}={}){const kr=wr!==void 0?numberToHex(wr):void 0;let jr;return br?jr=await fr.request({method:"eth_getBlockTransactionCountByHash",params:[br]},{dedupe:!0}):jr=await fr.request({method:"eth_getBlockTransactionCountByNumber",params:[kr||Er]},{dedupe:!!kr}),hexToNumber$2(jr)}async function getCode(fr,{address:br,blockNumber:wr,blockTag:Er="latest"}){const kr=wr!==void 0?numberToHex(wr):void 0,jr=await fr.request({method:"eth_getCode",params:[br,kr||Er]},{dedupe:!!kr});if(jr!=="0x")return jr}function formatFeeHistory(fr){var br;return{baseFeePerGas:fr.baseFeePerGas.map(wr=>BigInt(wr)),gasUsedRatio:fr.gasUsedRatio,oldestBlock:BigInt(fr.oldestBlock),reward:(br=fr.reward)==null?void 0:br.map(wr=>wr.map(Er=>BigInt(Er)))}}async function getFeeHistory(fr,{blockCount:br,blockNumber:wr,blockTag:Er="latest",rewardPercentiles:kr}){const jr=wr?numberToHex(wr):void 0,Br=await fr.request({method:"eth_feeHistory",params:[numberToHex(br),jr||Er,kr]},{dedupe:!!jr});return formatFeeHistory(Br)}async function getFilterLogs(fr,{filter:br}){const wr=br.strict??!1,kr=(await br.request({method:"eth_getFilterLogs",params:[br.id]})).map(jr=>formatLog(jr));return br.abi?parseEventLogs({abi:br.abi,logs:kr,strict:wr}):kr}class OffchainLookupError extends BaseError{constructor({callbackSelector:br,cause:wr,data:Er,extraData:kr,sender:jr,urls:Br}){var Wr;super(wr.shortMessage||"An error occurred while fetching for an offchain result.",{cause:wr,metaMessages:[...wr.metaMessages||[],(Wr=wr.metaMessages)!=null&&Wr.length?"":[],"Offchain Gateway Call:",Br&&[" Gateway URL(s):",...Br.map(qr=>` ${getUrl(qr)}`)],` Sender: ${jr}`,` Data: ${Er}`,` Callback selector: ${br}`,` Extra data: ${kr}`].flat(),name:"OffchainLookupError"})}}class OffchainLookupResponseMalformedError extends BaseError{constructor({result:br,url:wr}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${getUrl(wr)}`,`Response: ${stringify$4(br)}`],name:"OffchainLookupResponseMalformedError"})}}class OffchainLookupSenderMismatchError extends BaseError{constructor({sender:br,to:wr}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${wr}`,`OffchainLookup sender address: ${br}`],name:"OffchainLookupSenderMismatchError"})}}const offchainLookupSignature="0x556f1830",offchainLookupAbiItem={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function offchainLookup(fr,{blockNumber:br,blockTag:wr,data:Er,to:kr}){const{args:jr}=decodeErrorResult({data:Er,abi:[offchainLookupAbiItem]}),[Br,Wr,qr,Hr,Vr]=jr,{ccipRead:Zr}=fr,Jr=Zr&&typeof(Zr==null?void 0:Zr.request)=="function"?Zr.request:ccipRequest;try{if(!isAddressEqual(kr,Br))throw new OffchainLookupSenderMismatchError({sender:Br,to:kr});const Qr=await Jr({data:qr,sender:Br,urls:Wr}),{data:_n}=await call(fr,{blockNumber:br,blockTag:wr,data:concat$1([Hr,encodeAbiParameters([{type:"bytes"},{type:"bytes"}],[Qr,Vr])]),to:kr});return _n}catch(Qr){throw new OffchainLookupError({callbackSelector:Hr,cause:Qr,data:Er,extraData:Vr,sender:Br,urls:Wr})}}async function ccipRequest({data:fr,sender:br,urls:wr}){var kr;let Er=new Error("An unknown error occurred.");for(let jr=0;jrwr.id===br)}const arrayRegex=/^(.*)\[([0-9]*)\]$/,bytesRegex=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,integerRegex=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,socketClientCache=new Map;async function getSocketRpcClient(fr){const{getSocket:br,keepAlive:wr=!0,key:Er="socket",reconnect:kr=!0,url:jr}=fr,{interval:Br=3e4}=typeof wr=="object"?wr:{},{attempts:Wr=5,delay:qr=2e3}=typeof kr=="object"?kr:{};let Hr=socketClientCache.get(`${Er}:${jr}`);if(Hr)return Hr;let Vr=0;const{schedule:Zr}=createBatchScheduler({id:`${Er}:${jr}`,fn:async()=>{const _n=new Map,En=new Map;let Cn,In,An;async function jn(){const eo=await br({onClose(){var ro,to;for(const _i of _n.values())(ro=_i.onError)==null||ro.call(_i,new SocketClosedError({url:jr}));for(const _i of En.values())(to=_i.onError)==null||to.call(_i,new SocketClosedError({url:jr}));_n.clear(),En.clear(),kr&&Vr{Vr++,await jn().catch(console.error)},qr)},onError(ro){var to,_i;Cn=ro;for(const oo of _n.values())(to=oo.onError)==null||to.call(oo,Cn);for(const oo of En.values())(_i=oo.onError)==null||_i.call(oo,Cn);_n.clear(),En.clear(),kr&&Vr{Vr++,await jn().catch(console.error)},qr)},onOpen(){Cn=void 0,Vr=0},onResponse(ro){const to=ro.method==="eth_subscription",_i=to?ro.params.subscription:ro.id,oo=to?En:_n,io=oo.get(_i);io&&io.onResponse(ro),to||oo.delete(_i)}});return In=eo,wr&&(An&&clearInterval(An),An=setInterval(()=>{var ro;return(ro=In.ping)==null?void 0:ro.call(In)},Br)),eo}return await jn(),Cn=void 0,Hr={close(){An&&clearInterval(An),In.close(),socketClientCache.delete(`${Er}:${jr}`)},get socket(){return In},request({body:eo,onError:ro,onResponse:to}){Cn&&ro&&ro(Cn);const _i=eo.id??idCache.take(),oo=io=>{var co;typeof io.id=="number"&&_i!==io.id||(eo.method==="eth_subscribe"&&typeof io.result=="string"&&En.set(io.result,{onResponse:oo,onError:ro}),eo.method==="eth_unsubscribe"&&En.delete((co=eo.params)==null?void 0:co[0]),to(io))};_n.set(_i,{onResponse:oo,onError:ro});try{In.request({body:{jsonrpc:"2.0",id:_i,...eo}})}catch(io){ro==null||ro(io)}},requestAsync({body:eo,timeout:ro=1e4}){return withTimeout(()=>new Promise((to,_i)=>this.request({body:eo,onError:_i,onResponse:to})),{errorInstance:new TimeoutError({body:eo,url:jr}),timeout:ro})},requests:_n,subscriptions:En,url:jr},socketClientCache.set(`${Er}:${jr}`,Hr),[Hr]}}),[Jr,[Qr]]=await Zr();return Qr}async function getWebSocketRpcClient(fr,br={}){const{keepAlive:wr,reconnect:Er}=br;return getSocketRpcClient({async getSocket({onClose:kr,onError:jr,onOpen:Br,onResponse:Wr}){const qr=await __vitePreload(()=>import("./native-CVg7kFyP.js"),[]).then(Qr=>Qr.WebSocket),Hr=new qr(fr);function Vr(){kr(),Hr.removeEventListener("close",Vr),Hr.removeEventListener("message",Zr),Hr.removeEventListener("error",jr),Hr.removeEventListener("open",Br)}function Zr({data:Qr}){Wr(JSON.parse(Qr))}Hr.addEventListener("close",Vr),Hr.addEventListener("message",Zr),Hr.addEventListener("error",jr),Hr.addEventListener("open",Br),Hr.readyState===qr.CONNECTING&&await new Promise((Qr,_n)=>{Hr&&(Hr.onopen=Qr,Hr.onerror=_n)});const{close:Jr}=Hr;return Object.assign(Hr,{close(){Jr.bind(Hr)(),kr()},ping(){try{if(Hr.readyState===Hr.CLOSED||Hr.readyState===Hr.CLOSING)throw new WebSocketRequestError({url:Hr.url,cause:new SocketClosedError({url:Hr.url})});const Qr={jsonrpc:"2.0",method:"net_version",params:[]};Hr.send(JSON.stringify(Qr))}catch(Qr){jr(Qr)}},request({body:Qr}){if(Hr.readyState===Hr.CLOSED||Hr.readyState===Hr.CLOSING)throw new WebSocketRequestError({body:Qr,url:Hr.url,cause:new SocketClosedError({url:Hr.url})});return Hr.send(JSON.stringify(Qr))}})},keepAlive:wr,reconnect:Er,url:fr})}async function getSocket(fr){const br=await getWebSocketRpcClient(fr);return Object.assign(br.socket,{requests:br.requests,subscriptions:br.subscriptions})}class InvalidDomainError extends BaseError{constructor({domain:br}){super(`Invalid domain "${stringify$4(br)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class InvalidPrimaryTypeError extends BaseError{constructor({primaryType:br,types:wr}){super(`Invalid primary type \`${br}\` must be one of \`${JSON.stringify(Object.keys(wr))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class InvalidStructTypeError extends BaseError{constructor({type:br}){super(`Struct type "${br}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function hashTypedData(fr){const{domain:br={},message:wr,primaryType:Er}=fr,kr={EIP712Domain:getTypesForEIP712Domain({domain:br}),...fr.types};validateTypedData({domain:br,message:wr,primaryType:Er,types:kr});const jr=["0x1901"];return br&&jr.push(hashDomain({domain:br,types:kr})),Er!=="EIP712Domain"&&jr.push(hashStruct({data:wr,primaryType:Er,types:kr})),keccak256(concat$1(jr))}function hashDomain({domain:fr,types:br}){return hashStruct({data:fr,primaryType:"EIP712Domain",types:br})}function hashStruct({data:fr,primaryType:br,types:wr}){const Er=encodeData$2({data:fr,primaryType:br,types:wr});return keccak256(Er)}function encodeData$2({data:fr,primaryType:br,types:wr}){const Er=[{type:"bytes32"}],kr=[hashType({primaryType:br,types:wr})];for(const jr of wr[br]){const[Br,Wr]=encodeField({types:wr,name:jr.name,type:jr.type,value:fr[jr.name]});Er.push(Br),kr.push(Wr)}return encodeAbiParameters(Er,kr)}function hashType({primaryType:fr,types:br}){const wr=toHex(encodeType({primaryType:fr,types:br}));return keccak256(wr)}function encodeType({primaryType:fr,types:br}){let wr="";const Er=findTypeDependencies({primaryType:fr,types:br});Er.delete(fr);const kr=[fr,...Array.from(Er).sort()];for(const jr of kr)wr+=`${jr}(${br[jr].map(({name:Br,type:Wr})=>`${Wr} ${Br}`).join(",")})`;return wr}function findTypeDependencies({primaryType:fr,types:br},wr=new Set){const Er=fr.match(/^\w*/u),kr=Er==null?void 0:Er[0];if(wr.has(kr)||br[kr]===void 0)return wr;wr.add(kr);for(const jr of br[kr])findTypeDependencies({primaryType:jr.type,types:br},wr);return wr}function encodeField({types:fr,name:br,type:wr,value:Er}){if(fr[wr]!==void 0)return[{type:"bytes32"},keccak256(encodeData$2({data:Er,primaryType:wr,types:fr}))];if(wr==="bytes")return Er=`0x${(Er.length%2?"0":"")+Er.slice(2)}`,[{type:"bytes32"},keccak256(Er)];if(wr==="string")return[{type:"bytes32"},keccak256(toHex(Er))];if(wr.lastIndexOf("]")===wr.length-1){const kr=wr.slice(0,wr.lastIndexOf("[")),jr=Er.map(Br=>encodeField({name:br,type:kr,types:fr,value:Br}));return[{type:"bytes32"},keccak256(encodeAbiParameters(jr.map(([Br])=>Br),jr.map(([,Br])=>Br)))]}return[{type:wr},Er]}function serializeTypedData(fr){const{domain:br,message:wr,primaryType:Er,types:kr}=fr,jr=(qr,Hr)=>{const Vr={...Hr};for(const Zr of qr){const{name:Jr,type:Qr}=Zr;Qr==="address"&&(Vr[Jr]=Vr[Jr].toLowerCase())}return Vr},Br=kr.EIP712Domain?br?jr(kr.EIP712Domain,br):{}:{},Wr=(()=>{if(Er!=="EIP712Domain")return jr(kr[Er],wr)})();return stringify$4({domain:Br,message:Wr,primaryType:Er,types:kr})}function validateTypedData(fr){const{domain:br,message:wr,primaryType:Er,types:kr}=fr,jr=(Br,Wr)=>{for(const qr of Br){const{name:Hr,type:Vr}=qr,Zr=Wr[Hr],Jr=Vr.match(integerRegex);if(Jr&&(typeof Zr=="number"||typeof Zr=="bigint")){const[En,Cn,In]=Jr;numberToHex(Zr,{signed:Cn==="int",size:Number.parseInt(In)/8})}if(Vr==="address"&&typeof Zr=="string"&&!isAddress(Zr))throw new InvalidAddressError({address:Zr});const Qr=Vr.match(bytesRegex);if(Qr){const[En,Cn]=Qr;if(Cn&&size$1(Zr)!==Number.parseInt(Cn))throw new BytesSizeMismatchError({expectedSize:Number.parseInt(Cn),givenSize:size$1(Zr)})}const _n=kr[Vr];_n&&(validateReference(Vr),jr(_n,Zr))}};if(kr.EIP712Domain&&br){if(typeof br!="object")throw new InvalidDomainError({domain:br});jr(kr.EIP712Domain,br)}if(Er!=="EIP712Domain")if(kr[Er])jr(kr[Er],wr);else throw new InvalidPrimaryTypeError({primaryType:Er,types:kr})}function getTypesForEIP712Domain({domain:fr}){return[typeof(fr==null?void 0:fr.name)=="string"&&{name:"name",type:"string"},(fr==null?void 0:fr.version)&&{name:"version",type:"string"},typeof(fr==null?void 0:fr.chainId)=="number"&&{name:"chainId",type:"uint256"},(fr==null?void 0:fr.verifyingContract)&&{name:"verifyingContract",type:"address"},(fr==null?void 0:fr.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}function domainSeparator({domain:fr}){return hashDomain({domain:fr,types:{EIP712Domain:getTypesForEIP712Domain({domain:fr})}})}function validateReference(fr){if(fr==="address"||fr==="bool"||fr==="string"||fr.startsWith("bytes")||fr.startsWith("uint")||fr.startsWith("int"))throw new InvalidStructTypeError({type:fr})}function decodeFunctionData(fr){const{abi:br,data:wr}=fr,Er=slice(wr,0,4),kr=br.find(jr=>jr.type==="function"&&Er===toFunctionSelector(formatAbiItem(jr)));if(!kr)throw new AbiFunctionSignatureNotFoundError(Er,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:kr.name,args:"inputs"in kr&&kr.inputs&&kr.inputs.length>0?decodeAbiParameters(kr.inputs,slice(wr,4)):void 0}}const docsPath$2="/docs/contract/encodeErrorResult";function encodeErrorResult(fr){const{abi:br,errorName:wr,args:Er}=fr;let kr=br[0];if(wr){const qr=getAbiItem({abi:br,args:Er,name:wr});if(!qr)throw new AbiErrorNotFoundError(wr,{docsPath:docsPath$2});kr=qr}if(kr.type!=="error")throw new AbiErrorNotFoundError(void 0,{docsPath:docsPath$2});const jr=formatAbiItem(kr),Br=toFunctionSelector(jr);let Wr="0x";if(Er&&Er.length>0){if(!kr.inputs)throw new AbiErrorInputsNotFoundError(kr.name,{docsPath:docsPath$2});Wr=encodeAbiParameters(kr.inputs,Er)}return concatHex([Br,Wr])}const docsPath$1="/docs/contract/encodeFunctionResult";function encodeFunctionResult(fr){const{abi:br,functionName:wr,result:Er}=fr;let kr=br[0];if(wr){const Br=getAbiItem({abi:br,name:wr});if(!Br)throw new AbiFunctionNotFoundError(wr,{docsPath:docsPath$1});kr=Br}if(kr.type!=="function")throw new AbiFunctionNotFoundError(void 0,{docsPath:docsPath$1});if(!kr.outputs)throw new AbiFunctionOutputsNotFoundError(kr.name,{docsPath:docsPath$1});let jr=Array.isArray(Er)?Er:[Er];return kr.outputs.length===0&&!jr[0]&&(jr=[]),encodeAbiParameters(kr.outputs,jr)}function encodePacked(fr,br){if(fr.length!==br.length)throw new AbiEncodingLengthMismatchError({expectedLength:fr.length,givenLength:br.length});const wr=[];for(let Er=0;ErformatLog(wr)):null,to:fr.to?fr.to:null,transactionIndex:fr.transactionIndex?hexToNumber$2(fr.transactionIndex):null,status:fr.status?receiptStatuses[fr.status]:null,type:fr.type?transactionType[fr.type]||fr.type:null};return fr.blobGasPrice&&(br.blobGasPrice=BigInt(fr.blobGasPrice)),fr.blobGasUsed&&(br.blobGasUsed=BigInt(fr.blobGasUsed)),br}const defineTransactionReceipt=defineFormatter("transactionReceipt",formatTransactionReceipt);function fromRlp(fr,br="hex"){const wr=(()=>{if(typeof fr=="string"){if(fr.length>3&&fr.length%2!==0)throw new InvalidHexValueError(fr);return hexToBytes$4(fr)}return fr})(),Er=createCursor(wr,{recursiveReadLimit:Number.POSITIVE_INFINITY});return fromRlpCursor(Er,br)}function fromRlpCursor(fr,br="hex"){if(fr.bytes.length===0)return br==="hex"?bytesToHex$4(fr.bytes):fr.bytes;const wr=fr.readByte();if(wr<128&&fr.decrementPosition(1),wr<192){const kr=readLength(fr,wr,128),jr=fr.readBytes(kr);return br==="hex"?bytesToHex$4(jr):jr}const Er=readLength(fr,wr,192);return readList(fr,Er,br)}function readLength(fr,br,wr){if(wr===128&&br<128)return 1;if(br<=wr+55)return br-wr;if(br===wr+55+1)return fr.readUint8();if(br===wr+55+2)return fr.readUint16();if(br===wr+55+3)return fr.readUint24();if(br===wr+55+4)return fr.readUint32();throw new BaseError("Invalid RLP prefix")}function readList(fr,br,wr){const Er=fr.position,kr=[];for(;fr.position-Erbr)),Pi$1=Id$1.map(fr=>(9*fr+5)%16);let idxL$1=[Id$1],idxR$1=[Pi$1];for(let fr=0;fr<4;fr++)for(let br of[idxL$1,idxR$1])br.push(br[fr].map(wr=>Rho$1[wr]));const shifts$1=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(fr=>new Uint8Array(fr)),shiftsL$1=idxL$1.map((fr,br)=>fr.map(wr=>shifts$1[br][wr])),shiftsR$1=idxR$1.map((fr,br)=>fr.map(wr=>shifts$1[br][wr])),Kl$1=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Kr$1=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function f$8(fr,br,wr,Er){return fr===0?br^wr^Er:fr===1?br&wr|~br&Er:fr===2?(br|~wr)^Er:fr===3?br&Er|wr&~Er:br^(wr|~Er)}const R_BUF$1=new Uint32Array(16);let RIPEMD160$1=class extends HashMD$2{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:br,h1:wr,h2:Er,h3:kr,h4:jr}=this;return[br,wr,Er,kr,jr]}set(br,wr,Er,kr,jr){this.h0=br|0,this.h1=wr|0,this.h2=Er|0,this.h3=kr|0,this.h4=jr|0}process(br,wr){for(let Qr=0;Qr<16;Qr++,wr+=4)R_BUF$1[Qr]=br.getUint32(wr,!0);let Er=this.h0|0,kr=Er,jr=this.h1|0,Br=jr,Wr=this.h2|0,qr=Wr,Hr=this.h3|0,Vr=Hr,Zr=this.h4|0,Jr=Zr;for(let Qr=0;Qr<5;Qr++){const _n=4-Qr,En=Kl$1[Qr],Cn=Kr$1[Qr],In=idxL$1[Qr],An=idxR$1[Qr],jn=shiftsL$1[Qr],eo=shiftsR$1[Qr];for(let ro=0;ro<16;ro++){const to=rotl$1(Er+f$8(Qr,jr,Wr,Hr)+R_BUF$1[In[ro]]+En,jn[ro])+Zr|0;Er=Zr,Zr=Hr,Hr=rotl$1(Wr,10)|0,Wr=jr,jr=to}for(let ro=0;ro<16;ro++){const to=rotl$1(kr+f$8(_n,Br,qr,Vr)+R_BUF$1[An[ro]]+Cn,eo[ro])+Jr|0;kr=Jr,Jr=Vr,Vr=rotl$1(qr,10)|0,qr=Br,Br=to}}this.set(this.h1+Wr+Vr|0,this.h2+Hr+Jr|0,this.h3+Zr+kr|0,this.h4+Er+Br|0,this.h0+jr+qr|0)}roundClean(){R_BUF$1.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};const ripemd160$3=wrapConstructor$2(()=>new RIPEMD160$1);function ripemd160$2(fr,br){const wr=br||"hex",Er=ripemd160$3(isHex(fr,{strict:!1})?toBytes$3(fr):fr);return wr==="bytes"?Er:toHex(Er)}const presignMessagePrefix=`Ethereum Signed Message: +`),{docsPath:br,docsSlug:"account",name:"AccountNotFoundError"})}}class AccountTypeNotSupportedError extends BaseError{constructor({docsPath:br,metaMessages:wr,type:Er}){super(`Account type "${Er}" is not supported.`,{docsPath:br,metaMessages:wr,name:"AccountTypeNotSupportedError"})}}function assertCurrentChain({chain:fr,currentChainId:br}){if(!fr)throw new ChainNotFoundError;if(br!==fr.id)throw new ChainMismatchError({chain:fr,currentChainId:br})}function getTransactionError(fr,{docsPath:br,...wr}){const Er=(()=>{const kr=getNodeError(fr,wr);return kr instanceof UnknownNodeError?fr:kr})();return new TransactionExecutionError(Er,{docsPath:br,...wr})}async function sendRawTransaction(fr,{serializedTransaction:br}){return fr.request({method:"eth_sendRawTransaction",params:[br]},{retryCount:0})}const supportsWalletNamespace=new LruMap(128);async function sendTransaction(fr,br){var In,An,jn,eo;const{account:wr=fr.account,chain:Er=fr.chain,accessList:kr,authorizationList:jr,blobs:Br,data:Wr,gas:qr,gasPrice:Hr,maxFeePerBlobGas:Vr,maxFeePerGas:Zr,maxPriorityFeePerGas:Jr,nonce:Qr,value:_n,...En}=br;if(typeof wr>"u")throw new AccountNotFoundError({docsPath:"/docs/actions/wallet/sendTransaction"});const Cn=wr?parseAccount(wr):null;try{assertRequest(br);const ro=await(async()=>{if(br.to)return br.to;if(jr&&jr.length>0)return await recoverAuthorizationAddress({authorization:jr[0]}).catch(()=>{throw new BaseError("`to` is required. Could not infer from `authorizationList`.")})})();if((Cn==null?void 0:Cn.type)==="json-rpc"||Cn===null){let to;Er!==null&&(to=await getAction(fr,getChainId,"getChainId")({}),assertCurrentChain({currentChainId:to,chain:Er}));const _i=(jn=(An=(In=fr.chain)==null?void 0:In.formatters)==null?void 0:An.transactionRequest)==null?void 0:jn.format,io=(_i||formatTransactionRequest)({...extract(En,{format:_i}),accessList:kr,authorizationList:jr,blobs:Br,chainId:to,data:Wr,from:Cn==null?void 0:Cn.address,gas:qr,gasPrice:Hr,maxFeePerBlobGas:Vr,maxFeePerGas:Zr,maxPriorityFeePerGas:Jr,nonce:Qr,to:ro,value:_n}),co=supportsWalletNamespace.get(fr.uid),so=co?"wallet_sendTransaction":"eth_sendTransaction";try{return await fr.request({method:so,params:[io]},{retryCount:0})}catch(no){if(co===!1)throw no;const Tn=no;if(Tn.name==="InvalidInputRpcError"||Tn.name==="InvalidParamsRpcError"||Tn.name==="MethodNotFoundRpcError"||Tn.name==="MethodNotSupportedRpcError")return await fr.request({method:"wallet_sendTransaction",params:[io]},{retryCount:0}).then(Gr=>(supportsWalletNamespace.set(fr.uid,!0),Gr)).catch(Gr=>{const Xr=Gr;throw Xr.name==="MethodNotFoundRpcError"||Xr.name==="MethodNotSupportedRpcError"?(supportsWalletNamespace.set(fr.uid,!1),Tn):Xr});throw Tn}}if((Cn==null?void 0:Cn.type)==="local"){const to=await getAction(fr,prepareTransactionRequest,"prepareTransactionRequest")({account:Cn,accessList:kr,authorizationList:jr,blobs:Br,chain:Er,data:Wr,gas:qr,gasPrice:Hr,maxFeePerBlobGas:Vr,maxFeePerGas:Zr,maxPriorityFeePerGas:Jr,nonce:Qr,nonceManager:Cn.nonceManager,parameters:[...defaultParameters,"sidecars"],value:_n,...En,to:ro}),_i=(eo=Er==null?void 0:Er.serializers)==null?void 0:eo.transaction,oo=await Cn.signTransaction(to,{serializer:_i});return await getAction(fr,sendRawTransaction,"sendRawTransaction")({serializedTransaction:oo})}throw(Cn==null?void 0:Cn.type)==="smart"?new AccountTypeNotSupportedError({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new AccountTypeNotSupportedError({docsPath:"/docs/actions/wallet/sendTransaction",type:Cn==null?void 0:Cn.type})}catch(ro){throw ro instanceof AccountTypeNotSupportedError?ro:getTransactionError(ro,{...br,account:Cn,chain:br.chain||void 0})}}async function writeContract(fr,br){const{abi:wr,account:Er=fr.account,address:kr,args:jr,dataSuffix:Br,functionName:Wr,...qr}=br;if(typeof Er>"u")throw new AccountNotFoundError({docsPath:"/docs/contract/writeContract"});const Hr=Er?parseAccount(Er):null,Vr=encodeFunctionData({abi:wr,args:jr,functionName:Wr});try{return await getAction(fr,sendTransaction,"sendTransaction")({data:`${Vr}${Br?Br.replace("0x",""):""}`,to:kr,account:Hr,...qr})}catch(Zr){throw getContractError(Zr,{abi:wr,address:kr,args:jr,docsPath:"/docs/contract/writeContract",functionName:Wr,sender:Hr==null?void 0:Hr.address})}}function getContract({abi:fr,address:br,client:wr}){const Er=wr,[kr,jr]=Er?"public"in Er&&"wallet"in Er?[Er.public,Er.wallet]:"public"in Er?[Er.public,void 0]:"wallet"in Er?[void 0,Er.wallet]:[Er,Er]:[void 0,void 0],Br=kr!=null,Wr=jr!=null,qr={};let Hr=!1,Vr=!1,Zr=!1;for(const Jr of fr)if(Jr.type==="function"?Jr.stateMutability==="view"||Jr.stateMutability==="pure"?Hr=!0:Vr=!0:Jr.type==="event"&&(Zr=!0),Hr&&Vr&&Zr)break;return Br&&(Hr&&(qr.read=new Proxy({},{get(Jr,Qr){return(..._n)=>{const{args:En,options:Cn}=getFunctionParameters(_n);return getAction(kr,readContract,"readContract")({abi:fr,address:br,functionName:Qr,args:En,...Cn})}}})),Vr&&(qr.simulate=new Proxy({},{get(Jr,Qr){return(..._n)=>{const{args:En,options:Cn}=getFunctionParameters(_n);return getAction(kr,simulateContract,"simulateContract")({abi:fr,address:br,functionName:Qr,args:En,...Cn})}}})),Zr&&(qr.createEventFilter=new Proxy({},{get(Jr,Qr){return(..._n)=>{const En=fr.find(An=>An.type==="event"&&An.name===Qr),{args:Cn,options:In}=getEventParameters(_n,En);return getAction(kr,createContractEventFilter,"createContractEventFilter")({abi:fr,address:br,eventName:Qr,args:Cn,...In})}}}),qr.getEvents=new Proxy({},{get(Jr,Qr){return(..._n)=>{const En=fr.find(An=>An.type==="event"&&An.name===Qr),{args:Cn,options:In}=getEventParameters(_n,En);return getAction(kr,getContractEvents,"getContractEvents")({abi:fr,address:br,eventName:Qr,args:Cn,...In})}}}),qr.watchEvent=new Proxy({},{get(Jr,Qr){return(..._n)=>{const En=fr.find(An=>An.type==="event"&&An.name===Qr),{args:Cn,options:In}=getEventParameters(_n,En);return getAction(kr,watchContractEvent,"watchContractEvent")({abi:fr,address:br,eventName:Qr,args:Cn,...In})}}}))),Wr&&Vr&&(qr.write=new Proxy({},{get(Jr,Qr){return(..._n)=>{const{args:En,options:Cn}=getFunctionParameters(_n);return getAction(jr,writeContract,"writeContract")({abi:fr,address:br,functionName:Qr,args:En,...Cn})}}})),(Br||Wr)&&Vr&&(qr.estimateGas=new Proxy({},{get(Jr,Qr){return(..._n)=>{const{args:En,options:Cn}=getFunctionParameters(_n);return getAction(kr??jr,estimateContractGas,"estimateContractGas")({abi:fr,address:br,functionName:Qr,args:En,...Cn,account:Cn.account??jr.account})}}})),qr.address=br,qr.abi=fr,qr}function getFunctionParameters(fr){const br=fr.length&&Array.isArray(fr[0]),wr=br?fr[0]:[],Er=(br?fr[1]:fr[0])??{};return{args:wr,options:Er}}function getEventParameters(fr,br){let wr=!1;Array.isArray(fr[0])?wr=!0:fr.length===1?wr=br.inputs.some(jr=>jr.indexed):fr.length===2&&(wr=!0);const Er=wr?fr[0]:void 0,kr=(wr?fr[1]:fr[0])??{};return{args:Er,options:kr}}class Eip712DomainNotFoundError extends BaseError{constructor({address:br}){super(`No EIP-712 domain found on contract "${br}".`,{metaMessages:["Ensure that:",`- The contract is deployed at the address "${br}".`,"- `eip712Domain()` function exists on the contract.","- `eip712Domain()` function matches signature to ERC-5267 specification."],name:"Eip712DomainNotFoundError"})}}async function getEip712Domain$1(fr,br){const{address:wr,factory:Er,factoryData:kr}=br;try{const[jr,Br,Wr,qr,Hr,Vr,Zr]=await getAction(fr,readContract,"readContract")({abi:abi$2,address:wr,functionName:"eip712Domain",factory:Er,factoryData:kr});return{domain:{name:Br,version:Wr,chainId:Number(qr),verifyingContract:Hr,salt:Vr},extensions:Zr,fields:jr}}catch(jr){const Br=jr;throw Br.name==="ContractFunctionExecutionError"&&Br.cause.name==="ContractFunctionZeroDataError"?new Eip712DomainNotFoundError({address:wr}):Br}}const abi$2=[{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"}];async function addChain(fr,{chain:br}){const{id:wr,name:Er,nativeCurrency:kr,rpcUrls:jr,blockExplorers:Br}=br;await fr.request({method:"wallet_addEthereumChain",params:[{chainId:numberToHex(wr),chainName:Er,nativeCurrency:kr,rpcUrls:jr.default.http,blockExplorerUrls:Br?Object.values(Br).map(({url:Wr})=>Wr):void 0}]},{dedupe:!0,retryCount:0})}const size=256;let index=size,buffer$1;function uid(fr=11){if(!buffer$1||index+fr>size*2){buffer$1="",index=0;for(let br=0;br{const An=In(Cn);for(const eo in _n)delete An[eo];const jn={...Cn,...An};return Object.assign(jn,{extend:En(jn)})}}return Object.assign(_n,{extend:En(_n)})}function rpcSchema(){return null}const promiseCache=new LruMap(8192);function withDedupe(fr,{enabled:br=!0,id:wr}){if(!br||!wr)return fr();if(promiseCache.get(wr))return promiseCache.get(wr);const Er=fr().finally(()=>promiseCache.delete(wr));return promiseCache.set(wr,Er),Er}function withRetry(fr,{delay:br=100,retryCount:wr=2,shouldRetry:Er=()=>!0}={}){return new Promise((kr,jr)=>{const Br=async({count:Wr=0}={})=>{const qr=async({error:Hr})=>{const Vr=typeof br=="function"?br({count:Wr,error:Hr}):br;Vr&&await wait(Vr),Br({count:Wr+1})};try{const Hr=await fr();kr(Hr)}catch(Hr){if(Wr{const{dedupe:kr=!1,retryDelay:jr=150,retryCount:Br=3,uid:Wr}={...br,...Er},qr=kr?keccak256(stringToHex(`${Wr}.${stringify$4(wr)}`)):void 0;return withDedupe(()=>withRetry(async()=>{try{return await fr(wr)}catch(Hr){const Vr=Hr;switch(Vr.code){case ParseRpcError.code:throw new ParseRpcError(Vr);case InvalidRequestRpcError.code:throw new InvalidRequestRpcError(Vr);case MethodNotFoundRpcError.code:throw new MethodNotFoundRpcError(Vr,{method:wr.method});case InvalidParamsRpcError.code:throw new InvalidParamsRpcError(Vr);case InternalRpcError.code:throw new InternalRpcError(Vr);case InvalidInputRpcError.code:throw new InvalidInputRpcError(Vr);case ResourceNotFoundRpcError.code:throw new ResourceNotFoundRpcError(Vr);case ResourceUnavailableRpcError.code:throw new ResourceUnavailableRpcError(Vr);case TransactionRejectedRpcError.code:throw new TransactionRejectedRpcError(Vr);case MethodNotSupportedRpcError.code:throw new MethodNotSupportedRpcError(Vr,{method:wr.method});case LimitExceededRpcError.code:throw new LimitExceededRpcError(Vr);case JsonRpcVersionUnsupportedError.code:throw new JsonRpcVersionUnsupportedError(Vr);case UserRejectedRequestError.code:throw new UserRejectedRequestError(Vr);case UnauthorizedProviderError.code:throw new UnauthorizedProviderError(Vr);case UnsupportedProviderMethodError.code:throw new UnsupportedProviderMethodError(Vr);case ProviderDisconnectedError.code:throw new ProviderDisconnectedError(Vr);case ChainDisconnectedError.code:throw new ChainDisconnectedError(Vr);case SwitchChainError.code:throw new SwitchChainError(Vr);case 5e3:throw new UserRejectedRequestError(Vr);default:throw Hr instanceof BaseError?Hr:new UnknownRpcError(Vr)}}},{delay:({count:Hr,error:Vr})=>{var Zr;if(Vr&&Vr instanceof HttpRequestError){const Jr=(Zr=Vr==null?void 0:Vr.headers)==null?void 0:Zr.get("Retry-After");if(Jr!=null&&Jr.match(/\d/))return Number.parseInt(Jr)*1e3}return~~(1<shouldRetry(Hr)}),{enabled:kr,id:qr})}}function shouldRetry(fr){return"code"in fr&&typeof fr.code=="number"?fr.code===-1||fr.code===LimitExceededRpcError.code||fr.code===InternalRpcError.code:fr instanceof HttpRequestError&&fr.status?fr.status===403||fr.status===408||fr.status===413||fr.status===429||fr.status===500||fr.status===502||fr.status===503||fr.status===504:!0}function createTransport({key:fr,name:br,request:wr,retryCount:Er=3,retryDelay:kr=150,timeout:jr,type:Br},Wr){const qr=uid();return{config:{key:fr,name:br,request:wr,retryCount:Er,retryDelay:kr,timeout:jr,type:Br},request:buildRequest(wr,{retryCount:Er,retryDelay:kr,uid:qr}),value:Wr}}function custom(fr,br={}){const{key:wr="custom",name:Er="Custom Provider",retryDelay:kr}=br;return({retryCount:jr})=>createTransport({key:wr,name:Er,request:fr.request.bind(fr),retryCount:br.retryCount??jr,retryDelay:kr,type:"custom"})}function fallback(fr,br={}){const{key:wr="fallback",name:Er="Fallback",rank:kr=!1,retryCount:jr,retryDelay:Br}=br;return({chain:Wr,pollingInterval:qr=4e3,timeout:Hr,...Vr})=>{let Zr=fr,Jr=()=>{};const Qr=createTransport({key:wr,name:Er,async request({method:_n,params:En}){const Cn=async(In=0)=>{const An=Zr[In]({...Vr,chain:Wr,retryCount:0,timeout:Hr});try{const jn=await An.request({method:_n,params:En});return Jr({method:_n,params:En,response:jn,transport:An,status:"success"}),jn}catch(jn){if(Jr({error:jn,method:_n,params:En,transport:An,status:"error"}),shouldThrow(jn)||In===Zr.length-1)throw jn;return Cn(In+1)}};return Cn()},retryCount:jr,retryDelay:Br,type:"fallback"},{onResponse:_n=>Jr=_n,transports:Zr.map(_n=>_n({chain:Wr,retryCount:0}))});if(kr){const _n=typeof kr=="object"?kr:{};rankTransports({chain:Wr,interval:_n.interval??qr,onTransports:En=>Zr=En,sampleCount:_n.sampleCount,timeout:_n.timeout,transports:Zr,weights:_n.weights})}return Qr}}function shouldThrow(fr){return"code"in fr&&typeof fr.code=="number"&&(fr.code===TransactionRejectedRpcError.code||fr.code===UserRejectedRequestError.code||fr.code===5e3)}function rankTransports({chain:fr,interval:br=4e3,onTransports:wr,sampleCount:Er=10,timeout:kr=1e3,transports:jr,weights:Br={}}){const{stability:Wr=.7,latency:qr=.3}=Br,Hr=[],Vr=async()=>{const Zr=await Promise.all(jr.map(async _n=>{const En=_n({chain:fr,retryCount:0,timeout:kr}),Cn=Date.now();let In,An;try{await En.request({method:"net_listening"}),An=1}catch{An=0}finally{In=Date.now()}return{latency:In-Cn,success:An}}));Hr.push(Zr),Hr.length>Er&&Hr.shift();const Jr=Math.max(...Hr.map(_n=>Math.max(..._n.map(({latency:En})=>En)))),Qr=jr.map((_n,En)=>{const Cn=Hr.map(ro=>ro[En].latency),An=1-Cn.reduce((ro,to)=>ro+to,0)/Cn.length/Jr,jn=Hr.map(ro=>ro[En].success),eo=jn.reduce((ro,to)=>ro+to,0)/jn.length;return eo===0?[0,En]:[qr*An+Wr*eo,En]}).sort((_n,En)=>En[0]-_n[0]);wr(Qr.map(([,_n])=>jr[_n])),await wait(br),Vr()};Vr()}class UrlRequiredError extends BaseError{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function withTimeout(fr,{errorInstance:br=new Error("timed out"),timeout:wr,signal:Er}){return new Promise((kr,jr)=>{(async()=>{let Br;try{const Wr=new AbortController;wr>0&&(Br=setTimeout(()=>{Er?Wr.abort():jr(br)},wr)),kr(await fr({signal:(Wr==null?void 0:Wr.signal)||null}))}catch(Wr){(Wr==null?void 0:Wr.name)==="AbortError"&&jr(br),jr(Wr)}finally{clearTimeout(Br)}})()})}function createIdStore(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const idCache=createIdStore();function getHttpRpcClient(fr,br={}){return{async request(wr){var Zr;const{body:Er,onRequest:kr=br.onRequest,onResponse:jr=br.onResponse,timeout:Br=br.timeout??1e4}=wr,Wr={...br.fetchOptions??{},...wr.fetchOptions??{}},{headers:qr,method:Hr,signal:Vr}=Wr;try{const Jr=await withTimeout(async({signal:_n})=>{const En={...Wr,body:Array.isArray(Er)?stringify$4(Er.map(jn=>({jsonrpc:"2.0",id:jn.id??idCache.take(),...jn}))):stringify$4({jsonrpc:"2.0",id:Er.id??idCache.take(),...Er}),headers:{"Content-Type":"application/json",...qr},method:Hr||"POST",signal:Vr||(Br>0?_n:null)},Cn=new Request(fr,En),In=await(kr==null?void 0:kr(Cn,En))??{...En,url:fr};return await fetch(In.url??fr,In)},{errorInstance:new TimeoutError({body:Er,url:fr}),timeout:Br,signal:!0});jr&&await jr(Jr);let Qr;if((Zr=Jr.headers.get("Content-Type"))!=null&&Zr.startsWith("application/json"))Qr=await Jr.json();else{Qr=await Jr.text();try{Qr=JSON.parse(Qr||"{}")}catch(_n){if(Jr.ok)throw _n;Qr={error:Qr}}}if(!Jr.ok)throw new HttpRequestError({body:Er,details:stringify$4(Qr.error)||Jr.statusText,headers:Jr.headers,status:Jr.status,url:fr});return Qr}catch(Jr){throw Jr instanceof HttpRequestError||Jr instanceof TimeoutError?Jr:new HttpRequestError({body:Er,cause:Jr,url:fr})}}}}function http(fr,br={}){const{batch:wr,fetchOptions:Er,key:kr="http",name:jr="HTTP JSON-RPC",onFetchRequest:Br,onFetchResponse:Wr,retryDelay:qr}=br;return({chain:Hr,retryCount:Vr,timeout:Zr})=>{const{batchSize:Jr=1e3,wait:Qr=0}=typeof wr=="object"?wr:{},_n=br.retryCount??Vr,En=Zr??br.timeout??1e4,Cn=fr||(Hr==null?void 0:Hr.rpcUrls.default.http[0]);if(!Cn)throw new UrlRequiredError;const In=getHttpRpcClient(Cn,{fetchOptions:Er,onRequest:Br,onResponse:Wr,timeout:En});return createTransport({key:kr,name:jr,async request({method:An,params:jn}){const eo={method:An,params:jn},{schedule:ro}=createBatchScheduler({id:Cn,wait:Qr,shouldSplitBatch(io){return io.length>Jr},fn:io=>In.request({body:io}),sort:(io,co)=>io.id-co.id}),to=async io=>wr?ro(io):[await In.request({body:io})],[{error:_i,result:oo}]=await to(eo);if(_i)throw new RpcRequestError({body:eo,error:_i,url:Cn});return oo},retryCount:_n,retryDelay:qr,timeout:En,type:"http"},{fetchOptions:Er,url:Cn})}}function isNullUniversalResolverError(fr,br){var Er,kr,jr,Br,Wr,qr;if(!(fr instanceof BaseError))return!1;const wr=fr.walk(Hr=>Hr instanceof ContractFunctionRevertedError);return wr instanceof ContractFunctionRevertedError?!!(((Er=wr.data)==null?void 0:Er.errorName)==="ResolverNotFound"||((kr=wr.data)==null?void 0:kr.errorName)==="ResolverWildcardNotSupported"||((jr=wr.data)==null?void 0:jr.errorName)==="ResolverNotContract"||((Br=wr.data)==null?void 0:Br.errorName)==="ResolverError"||((Wr=wr.data)==null?void 0:Wr.errorName)==="HttpError"||(qr=wr.reason)!=null&&qr.includes("Wildcard on non-extended resolvers is not supported")||br==="reverse"&&wr.reason===panicReasons[50]):!1}function encodedLabelToLabelhash(fr){if(fr.length!==66||fr.indexOf("[")!==0||fr.indexOf("]")!==65)return null;const br=`0x${fr.slice(1,65)}`;return isHex(br)?br:null}function namehash(fr){let br=new Uint8Array(32).fill(0);if(!fr)return bytesToHex$4(br);const wr=fr.split(".");for(let Er=wr.length-1;Er>=0;Er-=1){const kr=encodedLabelToLabelhash(wr[Er]),jr=kr?toBytes$3(kr):keccak256(stringToBytes$1(wr[Er]),"bytes");br=keccak256(concat$1([br,jr]),"bytes")}return bytesToHex$4(br)}function encodeLabelhash(fr){return`[${fr.slice(2)}]`}function labelhash(fr){const br=new Uint8Array(32).fill(0);return fr?encodedLabelToLabelhash(fr)||keccak256(stringToBytes$1(fr)):bytesToHex$4(br)}function packetToBytes(fr){const br=fr.replace(/^\.|\.$/gm,"");if(br.length===0)return new Uint8Array(1);const wr=new Uint8Array(stringToBytes$1(br).byteLength+2);let Er=0;const kr=br.split(".");for(let jr=0;jr255&&(Br=stringToBytes$1(encodeLabelhash(labelhash(kr[jr])))),wr[Er]=Br.length,wr.set(Br,Er+1),Er+=Br.length+1}return wr.byteLength!==Er+1?wr.slice(0,Er+1):wr}async function getEnsAddress(fr,{blockNumber:br,blockTag:wr,coinType:Er,name:kr,gatewayUrls:jr,strict:Br,universalResolverAddress:Wr}){let qr=Wr;if(!qr){if(!fr.chain)throw new Error("client chain not configured. universalResolverAddress is required.");qr=getChainContractAddress({blockNumber:br,chain:fr.chain,contract:"ensUniversalResolver"})}try{const Hr=encodeFunctionData({abi:addressResolverAbi,functionName:"addr",...Er!=null?{args:[namehash(kr),BigInt(Er)]}:{args:[namehash(kr)]}}),Vr={address:qr,abi:universalResolverResolveAbi,functionName:"resolve",args:[toHex(packetToBytes(kr)),Hr],blockNumber:br,blockTag:wr},Zr=getAction(fr,readContract,"readContract"),Jr=jr?await Zr({...Vr,args:[...Vr.args,jr]}):await Zr(Vr);if(Jr[0]==="0x")return null;const Qr=decodeFunctionResult({abi:addressResolverAbi,args:Er!=null?[namehash(kr),BigInt(Er)]:void 0,functionName:"addr",data:Jr[0]});return Qr==="0x"||trim(Qr)==="0x00"?null:Qr}catch(Hr){if(Br)throw Hr;if(isNullUniversalResolverError(Hr,"resolve"))return null;throw Hr}}class EnsAvatarInvalidMetadataError extends BaseError{constructor({data:br}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(br)}`],name:"EnsAvatarInvalidMetadataError"})}}class EnsAvatarInvalidNftUriError extends BaseError{constructor({reason:br}){super(`ENS NFT avatar URI is invalid. ${br}`,{name:"EnsAvatarInvalidNftUriError"})}}class EnsAvatarUriResolutionError extends BaseError{constructor({uri:br}){super(`Unable to resolve ENS avatar URI "${br}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class EnsAvatarUnsupportedNamespaceError extends BaseError{constructor({namespace:br}){super(`ENS NFT avatar namespace "${br}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const networkRegex=/(?https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?\/)?(?ipfs\/|ipns\/)?(?[\w\-.]+)(?\/.*)?/,ipfsHashRegex=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?[\w\-.]+))?(?\/.*)?$/,base64Regex=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,dataURIRegex=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function isImageUri(fr){try{const br=await fetch(fr,{method:"HEAD"});if(br.status===200){const wr=br.headers.get("content-type");return wr==null?void 0:wr.startsWith("image/")}return!1}catch(br){return typeof br=="object"&&typeof br.response<"u"||!globalThis.hasOwnProperty("Image")?!1:new Promise(wr=>{const Er=new Image;Er.onload=()=>{wr(!0)},Er.onerror=()=>{wr(!1)},Er.src=fr})}}function getGateway(fr,br){return fr?fr.endsWith("/")?fr.slice(0,-1):fr:br}function resolveAvatarUri({uri:fr,gatewayUrls:br}){const wr=base64Regex.test(fr);if(wr)return{uri:fr,isOnChain:!0,isEncoded:wr};const Er=getGateway(br==null?void 0:br.ipfs,"https://ipfs.io"),kr=getGateway(br==null?void 0:br.arweave,"https://arweave.net"),jr=fr.match(networkRegex),{protocol:Br,subpath:Wr,target:qr,subtarget:Hr=""}=(jr==null?void 0:jr.groups)||{},Vr=Br==="ipns:/"||Wr==="ipns/",Zr=Br==="ipfs:/"||Wr==="ipfs/"||ipfsHashRegex.test(fr);if(fr.startsWith("http")&&!Vr&&!Zr){let Qr=fr;return br!=null&&br.arweave&&(Qr=fr.replace(/https:\/\/arweave.net/g,br==null?void 0:br.arweave)),{uri:Qr,isOnChain:!1,isEncoded:!1}}if((Vr||Zr)&&qr)return{uri:`${Er}/${Vr?"ipns":"ipfs"}/${qr}${Hr}`,isOnChain:!1,isEncoded:!1};if(Br==="ar:/"&&qr)return{uri:`${kr}/${qr}${Hr||""}`,isOnChain:!1,isEncoded:!1};let Jr=fr.replace(dataURIRegex,"");if(Jr.startsWith("kr.json());return await parseAvatarUri({gatewayUrls:fr,uri:getJsonImage(wr)})}catch{throw new EnsAvatarUriResolutionError({uri:br})}}async function parseAvatarUri({gatewayUrls:fr,uri:br}){const{uri:wr,isOnChain:Er}=resolveAvatarUri({uri:br,gatewayUrls:fr});if(Er||await isImageUri(wr))return wr;throw new EnsAvatarUriResolutionError({uri:br})}function parseNftUri(fr){let br=fr;br.startsWith("did:nft:")&&(br=br.replace("did:nft:","").replace(/_/g,"/"));const[wr,Er,kr]=br.split("/"),[jr,Br]=wr.split(":"),[Wr,qr]=Er.split(":");if(!jr||jr.toLowerCase()!=="eip155")throw new EnsAvatarInvalidNftUriError({reason:"Only EIP-155 supported"});if(!Br)throw new EnsAvatarInvalidNftUriError({reason:"Chain ID not found"});if(!qr)throw new EnsAvatarInvalidNftUriError({reason:"Contract address not found"});if(!kr)throw new EnsAvatarInvalidNftUriError({reason:"Token ID not found"});if(!Wr)throw new EnsAvatarInvalidNftUriError({reason:"ERC namespace not found"});return{chainID:Number.parseInt(Br),namespace:Wr.toLowerCase(),contractAddress:qr,tokenID:kr}}async function getNftTokenUri(fr,{nft:br}){if(br.namespace==="erc721")return readContract(fr,{address:br.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(br.tokenID)]});if(br.namespace==="erc1155")return readContract(fr,{address:br.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(br.tokenID)]});throw new EnsAvatarUnsupportedNamespaceError({namespace:br.namespace})}async function parseAvatarRecord(fr,{gatewayUrls:br,record:wr}){return/eip155:/i.test(wr)?parseNftAvatarUri(fr,{gatewayUrls:br,record:wr}):parseAvatarUri({uri:wr,gatewayUrls:br})}async function parseNftAvatarUri(fr,{gatewayUrls:br,record:wr}){const Er=parseNftUri(wr),kr=await getNftTokenUri(fr,{nft:Er}),{uri:jr,isOnChain:Br,isEncoded:Wr}=resolveAvatarUri({uri:kr,gatewayUrls:br});if(Br&&(jr.includes("data:application/json;base64,")||jr.startsWith("{"))){const Hr=Wr?atob(jr.replace("data:application/json;base64,","")):jr,Vr=JSON.parse(Hr);return parseAvatarUri({uri:getJsonImage(Vr),gatewayUrls:br})}let qr=Er.tokenID;return Er.namespace==="erc1155"&&(qr=qr.replace("0x","").padStart(64,"0")),getMetadataAvatarUri({gatewayUrls:br,uri:jr.replace(/(?:0x)?{id}/,qr)})}async function getEnsText(fr,{blockNumber:br,blockTag:wr,name:Er,key:kr,gatewayUrls:jr,strict:Br,universalResolverAddress:Wr}){let qr=Wr;if(!qr){if(!fr.chain)throw new Error("client chain not configured. universalResolverAddress is required.");qr=getChainContractAddress({blockNumber:br,chain:fr.chain,contract:"ensUniversalResolver"})}try{const Hr={address:qr,abi:universalResolverResolveAbi,functionName:"resolve",args:[toHex(packetToBytes(Er)),encodeFunctionData({abi:textResolverAbi,functionName:"text",args:[namehash(Er),kr]})],blockNumber:br,blockTag:wr},Vr=getAction(fr,readContract,"readContract"),Zr=jr?await Vr({...Hr,args:[...Hr.args,jr]}):await Vr(Hr);if(Zr[0]==="0x")return null;const Jr=decodeFunctionResult({abi:textResolverAbi,functionName:"text",data:Zr[0]});return Jr===""?null:Jr}catch(Hr){if(Br)throw Hr;if(isNullUniversalResolverError(Hr,"resolve"))return null;throw Hr}}async function getEnsAvatar(fr,{blockNumber:br,blockTag:wr,assetGatewayUrls:Er,name:kr,gatewayUrls:jr,strict:Br,universalResolverAddress:Wr}){const qr=await getAction(fr,getEnsText,"getEnsText")({blockNumber:br,blockTag:wr,key:"avatar",name:kr,universalResolverAddress:Wr,gatewayUrls:jr,strict:Br});if(!qr)return null;try{return await parseAvatarRecord(fr,{record:qr,gatewayUrls:Er})}catch{return null}}async function getEnsName(fr,{address:br,blockNumber:wr,blockTag:Er,gatewayUrls:kr,strict:jr,universalResolverAddress:Br}){let Wr=Br;if(!Wr){if(!fr.chain)throw new Error("client chain not configured. universalResolverAddress is required.");Wr=getChainContractAddress({blockNumber:wr,chain:fr.chain,contract:"ensUniversalResolver"})}const qr=`${br.toLowerCase().substring(2)}.addr.reverse`;try{const Hr={address:Wr,abi:universalResolverReverseAbi,functionName:"reverse",args:[toHex(packetToBytes(qr))],blockNumber:wr,blockTag:Er},Vr=getAction(fr,readContract,"readContract"),[Zr,Jr]=kr?await Vr({...Hr,args:[...Hr.args,kr]}):await Vr(Hr);return br.toLowerCase()!==Jr.toLowerCase()?null:Zr}catch(Hr){if(jr)throw Hr;if(isNullUniversalResolverError(Hr,"reverse"))return null;throw Hr}}async function getEnsResolver(fr,{blockNumber:br,blockTag:wr,name:Er,universalResolverAddress:kr}){let jr=kr;if(!jr){if(!fr.chain)throw new Error("client chain not configured. universalResolverAddress is required.");jr=getChainContractAddress({blockNumber:br,chain:fr.chain,contract:"ensUniversalResolver"})}const[Br]=await getAction(fr,readContract,"readContract")({address:jr,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[toHex(packetToBytes(Er))],blockNumber:br,blockTag:wr});return Br}async function createBlockFilter(fr){const br=createFilterRequestScope(fr,{method:"eth_newBlockFilter"}),wr=await fr.request({method:"eth_newBlockFilter"});return{id:wr,request:br(wr),type:"block"}}async function createEventFilter(fr,{address:br,args:wr,event:Er,events:kr,fromBlock:jr,strict:Br,toBlock:Wr}={}){const qr=kr??(Er?[Er]:void 0),Hr=createFilterRequestScope(fr,{method:"eth_newFilter"});let Vr=[];qr&&(Vr=[qr.flatMap(Qr=>encodeEventTopics({abi:[Qr],eventName:Qr.name,args:wr}))],Er&&(Vr=Vr[0]));const Zr=await fr.request({method:"eth_newFilter",params:[{address:br,fromBlock:typeof jr=="bigint"?numberToHex(jr):jr,toBlock:typeof Wr=="bigint"?numberToHex(Wr):Wr,...Vr.length?{topics:Vr}:{}}]});return{abi:qr,args:wr,eventName:Er?Er.name:void 0,fromBlock:jr,id:Zr,request:Hr(Zr),strict:!!Br,toBlock:Wr,type:"event"}}async function createPendingTransactionFilter(fr){const br=createFilterRequestScope(fr,{method:"eth_newPendingTransactionFilter"}),wr=await fr.request({method:"eth_newPendingTransactionFilter"});return{id:wr,request:br(wr),type:"transaction"}}async function getBlobBaseFee(fr){const br=await fr.request({method:"eth_blobBaseFee"});return BigInt(br)}async function getBlockTransactionCount(fr,{blockHash:br,blockNumber:wr,blockTag:Er="latest"}={}){const kr=wr!==void 0?numberToHex(wr):void 0;let jr;return br?jr=await fr.request({method:"eth_getBlockTransactionCountByHash",params:[br]},{dedupe:!0}):jr=await fr.request({method:"eth_getBlockTransactionCountByNumber",params:[kr||Er]},{dedupe:!!kr}),hexToNumber$2(jr)}async function getCode(fr,{address:br,blockNumber:wr,blockTag:Er="latest"}){const kr=wr!==void 0?numberToHex(wr):void 0,jr=await fr.request({method:"eth_getCode",params:[br,kr||Er]},{dedupe:!!kr});if(jr!=="0x")return jr}function formatFeeHistory(fr){var br;return{baseFeePerGas:fr.baseFeePerGas.map(wr=>BigInt(wr)),gasUsedRatio:fr.gasUsedRatio,oldestBlock:BigInt(fr.oldestBlock),reward:(br=fr.reward)==null?void 0:br.map(wr=>wr.map(Er=>BigInt(Er)))}}async function getFeeHistory(fr,{blockCount:br,blockNumber:wr,blockTag:Er="latest",rewardPercentiles:kr}){const jr=wr?numberToHex(wr):void 0,Br=await fr.request({method:"eth_feeHistory",params:[numberToHex(br),jr||Er,kr]},{dedupe:!!jr});return formatFeeHistory(Br)}async function getFilterLogs(fr,{filter:br}){const wr=br.strict??!1,kr=(await br.request({method:"eth_getFilterLogs",params:[br.id]})).map(jr=>formatLog(jr));return br.abi?parseEventLogs({abi:br.abi,logs:kr,strict:wr}):kr}class OffchainLookupError extends BaseError{constructor({callbackSelector:br,cause:wr,data:Er,extraData:kr,sender:jr,urls:Br}){var Wr;super(wr.shortMessage||"An error occurred while fetching for an offchain result.",{cause:wr,metaMessages:[...wr.metaMessages||[],(Wr=wr.metaMessages)!=null&&Wr.length?"":[],"Offchain Gateway Call:",Br&&[" Gateway URL(s):",...Br.map(qr=>` ${getUrl(qr)}`)],` Sender: ${jr}`,` Data: ${Er}`,` Callback selector: ${br}`,` Extra data: ${kr}`].flat(),name:"OffchainLookupError"})}}class OffchainLookupResponseMalformedError extends BaseError{constructor({result:br,url:wr}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${getUrl(wr)}`,`Response: ${stringify$4(br)}`],name:"OffchainLookupResponseMalformedError"})}}class OffchainLookupSenderMismatchError extends BaseError{constructor({sender:br,to:wr}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${wr}`,`OffchainLookup sender address: ${br}`],name:"OffchainLookupSenderMismatchError"})}}const offchainLookupSignature="0x556f1830",offchainLookupAbiItem={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function offchainLookup(fr,{blockNumber:br,blockTag:wr,data:Er,to:kr}){const{args:jr}=decodeErrorResult({data:Er,abi:[offchainLookupAbiItem]}),[Br,Wr,qr,Hr,Vr]=jr,{ccipRead:Zr}=fr,Jr=Zr&&typeof(Zr==null?void 0:Zr.request)=="function"?Zr.request:ccipRequest;try{if(!isAddressEqual(kr,Br))throw new OffchainLookupSenderMismatchError({sender:Br,to:kr});const Qr=await Jr({data:qr,sender:Br,urls:Wr}),{data:_n}=await call(fr,{blockNumber:br,blockTag:wr,data:concat$1([Hr,encodeAbiParameters([{type:"bytes"},{type:"bytes"}],[Qr,Vr])]),to:kr});return _n}catch(Qr){throw new OffchainLookupError({callbackSelector:Hr,cause:Qr,data:Er,extraData:Vr,sender:Br,urls:Wr})}}async function ccipRequest({data:fr,sender:br,urls:wr}){var kr;let Er=new Error("An unknown error occurred.");for(let jr=0;jrwr.id===br)}const arrayRegex=/^(.*)\[([0-9]*)\]$/,bytesRegex=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,integerRegex=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,socketClientCache=new Map;async function getSocketRpcClient(fr){const{getSocket:br,keepAlive:wr=!0,key:Er="socket",reconnect:kr=!0,url:jr}=fr,{interval:Br=3e4}=typeof wr=="object"?wr:{},{attempts:Wr=5,delay:qr=2e3}=typeof kr=="object"?kr:{};let Hr=socketClientCache.get(`${Er}:${jr}`);if(Hr)return Hr;let Vr=0;const{schedule:Zr}=createBatchScheduler({id:`${Er}:${jr}`,fn:async()=>{const _n=new Map,En=new Map;let Cn,In,An;async function jn(){const eo=await br({onClose(){var ro,to;for(const _i of _n.values())(ro=_i.onError)==null||ro.call(_i,new SocketClosedError({url:jr}));for(const _i of En.values())(to=_i.onError)==null||to.call(_i,new SocketClosedError({url:jr}));_n.clear(),En.clear(),kr&&Vr{Vr++,await jn().catch(console.error)},qr)},onError(ro){var to,_i;Cn=ro;for(const oo of _n.values())(to=oo.onError)==null||to.call(oo,Cn);for(const oo of En.values())(_i=oo.onError)==null||_i.call(oo,Cn);_n.clear(),En.clear(),kr&&Vr{Vr++,await jn().catch(console.error)},qr)},onOpen(){Cn=void 0,Vr=0},onResponse(ro){const to=ro.method==="eth_subscription",_i=to?ro.params.subscription:ro.id,oo=to?En:_n,io=oo.get(_i);io&&io.onResponse(ro),to||oo.delete(_i)}});return In=eo,wr&&(An&&clearInterval(An),An=setInterval(()=>{var ro;return(ro=In.ping)==null?void 0:ro.call(In)},Br)),eo}return await jn(),Cn=void 0,Hr={close(){An&&clearInterval(An),In.close(),socketClientCache.delete(`${Er}:${jr}`)},get socket(){return In},request({body:eo,onError:ro,onResponse:to}){Cn&&ro&&ro(Cn);const _i=eo.id??idCache.take(),oo=io=>{var co;typeof io.id=="number"&&_i!==io.id||(eo.method==="eth_subscribe"&&typeof io.result=="string"&&En.set(io.result,{onResponse:oo,onError:ro}),eo.method==="eth_unsubscribe"&&En.delete((co=eo.params)==null?void 0:co[0]),to(io))};_n.set(_i,{onResponse:oo,onError:ro});try{In.request({body:{jsonrpc:"2.0",id:_i,...eo}})}catch(io){ro==null||ro(io)}},requestAsync({body:eo,timeout:ro=1e4}){return withTimeout(()=>new Promise((to,_i)=>this.request({body:eo,onError:_i,onResponse:to})),{errorInstance:new TimeoutError({body:eo,url:jr}),timeout:ro})},requests:_n,subscriptions:En,url:jr},socketClientCache.set(`${Er}:${jr}`,Hr),[Hr]}}),[Jr,[Qr]]=await Zr();return Qr}async function getWebSocketRpcClient(fr,br={}){const{keepAlive:wr,reconnect:Er}=br;return getSocketRpcClient({async getSocket({onClose:kr,onError:jr,onOpen:Br,onResponse:Wr}){const qr=await __vitePreload(()=>import("./native-bMdAWj-e.js"),[]).then(Qr=>Qr.WebSocket),Hr=new qr(fr);function Vr(){kr(),Hr.removeEventListener("close",Vr),Hr.removeEventListener("message",Zr),Hr.removeEventListener("error",jr),Hr.removeEventListener("open",Br)}function Zr({data:Qr}){Wr(JSON.parse(Qr))}Hr.addEventListener("close",Vr),Hr.addEventListener("message",Zr),Hr.addEventListener("error",jr),Hr.addEventListener("open",Br),Hr.readyState===qr.CONNECTING&&await new Promise((Qr,_n)=>{Hr&&(Hr.onopen=Qr,Hr.onerror=_n)});const{close:Jr}=Hr;return Object.assign(Hr,{close(){Jr.bind(Hr)(),kr()},ping(){try{if(Hr.readyState===Hr.CLOSED||Hr.readyState===Hr.CLOSING)throw new WebSocketRequestError({url:Hr.url,cause:new SocketClosedError({url:Hr.url})});const Qr={jsonrpc:"2.0",method:"net_version",params:[]};Hr.send(JSON.stringify(Qr))}catch(Qr){jr(Qr)}},request({body:Qr}){if(Hr.readyState===Hr.CLOSED||Hr.readyState===Hr.CLOSING)throw new WebSocketRequestError({body:Qr,url:Hr.url,cause:new SocketClosedError({url:Hr.url})});return Hr.send(JSON.stringify(Qr))}})},keepAlive:wr,reconnect:Er,url:fr})}async function getSocket(fr){const br=await getWebSocketRpcClient(fr);return Object.assign(br.socket,{requests:br.requests,subscriptions:br.subscriptions})}class InvalidDomainError extends BaseError{constructor({domain:br}){super(`Invalid domain "${stringify$4(br)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class InvalidPrimaryTypeError extends BaseError{constructor({primaryType:br,types:wr}){super(`Invalid primary type \`${br}\` must be one of \`${JSON.stringify(Object.keys(wr))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class InvalidStructTypeError extends BaseError{constructor({type:br}){super(`Struct type "${br}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function hashTypedData(fr){const{domain:br={},message:wr,primaryType:Er}=fr,kr={EIP712Domain:getTypesForEIP712Domain({domain:br}),...fr.types};validateTypedData({domain:br,message:wr,primaryType:Er,types:kr});const jr=["0x1901"];return br&&jr.push(hashDomain({domain:br,types:kr})),Er!=="EIP712Domain"&&jr.push(hashStruct({data:wr,primaryType:Er,types:kr})),keccak256(concat$1(jr))}function hashDomain({domain:fr,types:br}){return hashStruct({data:fr,primaryType:"EIP712Domain",types:br})}function hashStruct({data:fr,primaryType:br,types:wr}){const Er=encodeData$2({data:fr,primaryType:br,types:wr});return keccak256(Er)}function encodeData$2({data:fr,primaryType:br,types:wr}){const Er=[{type:"bytes32"}],kr=[hashType({primaryType:br,types:wr})];for(const jr of wr[br]){const[Br,Wr]=encodeField({types:wr,name:jr.name,type:jr.type,value:fr[jr.name]});Er.push(Br),kr.push(Wr)}return encodeAbiParameters(Er,kr)}function hashType({primaryType:fr,types:br}){const wr=toHex(encodeType({primaryType:fr,types:br}));return keccak256(wr)}function encodeType({primaryType:fr,types:br}){let wr="";const Er=findTypeDependencies({primaryType:fr,types:br});Er.delete(fr);const kr=[fr,...Array.from(Er).sort()];for(const jr of kr)wr+=`${jr}(${br[jr].map(({name:Br,type:Wr})=>`${Wr} ${Br}`).join(",")})`;return wr}function findTypeDependencies({primaryType:fr,types:br},wr=new Set){const Er=fr.match(/^\w*/u),kr=Er==null?void 0:Er[0];if(wr.has(kr)||br[kr]===void 0)return wr;wr.add(kr);for(const jr of br[kr])findTypeDependencies({primaryType:jr.type,types:br},wr);return wr}function encodeField({types:fr,name:br,type:wr,value:Er}){if(fr[wr]!==void 0)return[{type:"bytes32"},keccak256(encodeData$2({data:Er,primaryType:wr,types:fr}))];if(wr==="bytes")return Er=`0x${(Er.length%2?"0":"")+Er.slice(2)}`,[{type:"bytes32"},keccak256(Er)];if(wr==="string")return[{type:"bytes32"},keccak256(toHex(Er))];if(wr.lastIndexOf("]")===wr.length-1){const kr=wr.slice(0,wr.lastIndexOf("[")),jr=Er.map(Br=>encodeField({name:br,type:kr,types:fr,value:Br}));return[{type:"bytes32"},keccak256(encodeAbiParameters(jr.map(([Br])=>Br),jr.map(([,Br])=>Br)))]}return[{type:wr},Er]}function serializeTypedData(fr){const{domain:br,message:wr,primaryType:Er,types:kr}=fr,jr=(qr,Hr)=>{const Vr={...Hr};for(const Zr of qr){const{name:Jr,type:Qr}=Zr;Qr==="address"&&(Vr[Jr]=Vr[Jr].toLowerCase())}return Vr},Br=kr.EIP712Domain?br?jr(kr.EIP712Domain,br):{}:{},Wr=(()=>{if(Er!=="EIP712Domain")return jr(kr[Er],wr)})();return stringify$4({domain:Br,message:Wr,primaryType:Er,types:kr})}function validateTypedData(fr){const{domain:br,message:wr,primaryType:Er,types:kr}=fr,jr=(Br,Wr)=>{for(const qr of Br){const{name:Hr,type:Vr}=qr,Zr=Wr[Hr],Jr=Vr.match(integerRegex);if(Jr&&(typeof Zr=="number"||typeof Zr=="bigint")){const[En,Cn,In]=Jr;numberToHex(Zr,{signed:Cn==="int",size:Number.parseInt(In)/8})}if(Vr==="address"&&typeof Zr=="string"&&!isAddress(Zr))throw new InvalidAddressError({address:Zr});const Qr=Vr.match(bytesRegex);if(Qr){const[En,Cn]=Qr;if(Cn&&size$1(Zr)!==Number.parseInt(Cn))throw new BytesSizeMismatchError({expectedSize:Number.parseInt(Cn),givenSize:size$1(Zr)})}const _n=kr[Vr];_n&&(validateReference(Vr),jr(_n,Zr))}};if(kr.EIP712Domain&&br){if(typeof br!="object")throw new InvalidDomainError({domain:br});jr(kr.EIP712Domain,br)}if(Er!=="EIP712Domain")if(kr[Er])jr(kr[Er],wr);else throw new InvalidPrimaryTypeError({primaryType:Er,types:kr})}function getTypesForEIP712Domain({domain:fr}){return[typeof(fr==null?void 0:fr.name)=="string"&&{name:"name",type:"string"},(fr==null?void 0:fr.version)&&{name:"version",type:"string"},typeof(fr==null?void 0:fr.chainId)=="number"&&{name:"chainId",type:"uint256"},(fr==null?void 0:fr.verifyingContract)&&{name:"verifyingContract",type:"address"},(fr==null?void 0:fr.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}function domainSeparator({domain:fr}){return hashDomain({domain:fr,types:{EIP712Domain:getTypesForEIP712Domain({domain:fr})}})}function validateReference(fr){if(fr==="address"||fr==="bool"||fr==="string"||fr.startsWith("bytes")||fr.startsWith("uint")||fr.startsWith("int"))throw new InvalidStructTypeError({type:fr})}function decodeFunctionData(fr){const{abi:br,data:wr}=fr,Er=slice(wr,0,4),kr=br.find(jr=>jr.type==="function"&&Er===toFunctionSelector(formatAbiItem(jr)));if(!kr)throw new AbiFunctionSignatureNotFoundError(Er,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:kr.name,args:"inputs"in kr&&kr.inputs&&kr.inputs.length>0?decodeAbiParameters(kr.inputs,slice(wr,4)):void 0}}const docsPath$2="/docs/contract/encodeErrorResult";function encodeErrorResult(fr){const{abi:br,errorName:wr,args:Er}=fr;let kr=br[0];if(wr){const qr=getAbiItem({abi:br,args:Er,name:wr});if(!qr)throw new AbiErrorNotFoundError(wr,{docsPath:docsPath$2});kr=qr}if(kr.type!=="error")throw new AbiErrorNotFoundError(void 0,{docsPath:docsPath$2});const jr=formatAbiItem(kr),Br=toFunctionSelector(jr);let Wr="0x";if(Er&&Er.length>0){if(!kr.inputs)throw new AbiErrorInputsNotFoundError(kr.name,{docsPath:docsPath$2});Wr=encodeAbiParameters(kr.inputs,Er)}return concatHex([Br,Wr])}const docsPath$1="/docs/contract/encodeFunctionResult";function encodeFunctionResult(fr){const{abi:br,functionName:wr,result:Er}=fr;let kr=br[0];if(wr){const Br=getAbiItem({abi:br,name:wr});if(!Br)throw new AbiFunctionNotFoundError(wr,{docsPath:docsPath$1});kr=Br}if(kr.type!=="function")throw new AbiFunctionNotFoundError(void 0,{docsPath:docsPath$1});if(!kr.outputs)throw new AbiFunctionOutputsNotFoundError(kr.name,{docsPath:docsPath$1});let jr=Array.isArray(Er)?Er:[Er];return kr.outputs.length===0&&!jr[0]&&(jr=[]),encodeAbiParameters(kr.outputs,jr)}function encodePacked(fr,br){if(fr.length!==br.length)throw new AbiEncodingLengthMismatchError({expectedLength:fr.length,givenLength:br.length});const wr=[];for(let Er=0;ErformatLog(wr)):null,to:fr.to?fr.to:null,transactionIndex:fr.transactionIndex?hexToNumber$2(fr.transactionIndex):null,status:fr.status?receiptStatuses[fr.status]:null,type:fr.type?transactionType[fr.type]||fr.type:null};return fr.blobGasPrice&&(br.blobGasPrice=BigInt(fr.blobGasPrice)),fr.blobGasUsed&&(br.blobGasUsed=BigInt(fr.blobGasUsed)),br}const defineTransactionReceipt=defineFormatter("transactionReceipt",formatTransactionReceipt);function fromRlp(fr,br="hex"){const wr=(()=>{if(typeof fr=="string"){if(fr.length>3&&fr.length%2!==0)throw new InvalidHexValueError(fr);return hexToBytes$4(fr)}return fr})(),Er=createCursor(wr,{recursiveReadLimit:Number.POSITIVE_INFINITY});return fromRlpCursor(Er,br)}function fromRlpCursor(fr,br="hex"){if(fr.bytes.length===0)return br==="hex"?bytesToHex$4(fr.bytes):fr.bytes;const wr=fr.readByte();if(wr<128&&fr.decrementPosition(1),wr<192){const kr=readLength(fr,wr,128),jr=fr.readBytes(kr);return br==="hex"?bytesToHex$4(jr):jr}const Er=readLength(fr,wr,192);return readList(fr,Er,br)}function readLength(fr,br,wr){if(wr===128&&br<128)return 1;if(br<=wr+55)return br-wr;if(br===wr+55+1)return fr.readUint8();if(br===wr+55+2)return fr.readUint16();if(br===wr+55+3)return fr.readUint24();if(br===wr+55+4)return fr.readUint32();throw new BaseError("Invalid RLP prefix")}function readList(fr,br,wr){const Er=fr.position,kr=[];for(;fr.position-Erbr)),Pi$1=Id$1.map(fr=>(9*fr+5)%16);let idxL$1=[Id$1],idxR$1=[Pi$1];for(let fr=0;fr<4;fr++)for(let br of[idxL$1,idxR$1])br.push(br[fr].map(wr=>Rho$1[wr]));const shifts$1=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(fr=>new Uint8Array(fr)),shiftsL$1=idxL$1.map((fr,br)=>fr.map(wr=>shifts$1[br][wr])),shiftsR$1=idxR$1.map((fr,br)=>fr.map(wr=>shifts$1[br][wr])),Kl$1=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Kr$1=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function f$8(fr,br,wr,Er){return fr===0?br^wr^Er:fr===1?br&wr|~br&Er:fr===2?(br|~wr)^Er:fr===3?br&Er|wr&~Er:br^(wr|~Er)}const R_BUF$1=new Uint32Array(16);let RIPEMD160$1=class extends HashMD$2{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:br,h1:wr,h2:Er,h3:kr,h4:jr}=this;return[br,wr,Er,kr,jr]}set(br,wr,Er,kr,jr){this.h0=br|0,this.h1=wr|0,this.h2=Er|0,this.h3=kr|0,this.h4=jr|0}process(br,wr){for(let Qr=0;Qr<16;Qr++,wr+=4)R_BUF$1[Qr]=br.getUint32(wr,!0);let Er=this.h0|0,kr=Er,jr=this.h1|0,Br=jr,Wr=this.h2|0,qr=Wr,Hr=this.h3|0,Vr=Hr,Zr=this.h4|0,Jr=Zr;for(let Qr=0;Qr<5;Qr++){const _n=4-Qr,En=Kl$1[Qr],Cn=Kr$1[Qr],In=idxL$1[Qr],An=idxR$1[Qr],jn=shiftsL$1[Qr],eo=shiftsR$1[Qr];for(let ro=0;ro<16;ro++){const to=rotl$1(Er+f$8(Qr,jr,Wr,Hr)+R_BUF$1[In[ro]]+En,jn[ro])+Zr|0;Er=Zr,Zr=Hr,Hr=rotl$1(Wr,10)|0,Wr=jr,jr=to}for(let ro=0;ro<16;ro++){const to=rotl$1(kr+f$8(_n,Br,qr,Vr)+R_BUF$1[An[ro]]+Cn,eo[ro])+Jr|0;kr=Jr,Jr=Vr,Vr=rotl$1(qr,10)|0,qr=Br,Br=to}}this.set(this.h1+Wr+Vr|0,this.h2+Hr+Jr|0,this.h3+Zr+kr|0,this.h4+Er+Br|0,this.h0+jr+qr|0)}roundClean(){R_BUF$1.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};const ripemd160$3=wrapConstructor$2(()=>new RIPEMD160$1);function ripemd160$2(fr,br){const wr=br||"hex",Er=ripemd160$3(isHex(fr,{strict:!1})?toBytes$3(fr):fr);return wr==="bytes"?Er:toHex(Er)}const presignMessagePrefix=`Ethereum Signed Message: `;function toPrefixedMessage(fr){const br=typeof fr=="string"?stringToHex(fr):typeof fr.raw=="string"?fr.raw:bytesToHex$4(fr.raw),wr=stringToHex(`${presignMessagePrefix}${size$1(br)}`);return concat$1([wr,br])}function hashMessage(fr,br){return keccak256(toPrefixedMessage(fr),br)}async function recoverMessageAddress({message:fr,signature:br}){return recoverAddress({hash:hashMessage(fr),signature:br})}async function recoverTypedDataAddress(fr){const{domain:br,message:wr,primaryType:Er,signature:kr,types:jr}=fr;return recoverAddress({hash:hashTypedData({domain:br,message:wr,primaryType:Er,types:jr}),signature:kr})}async function verifyHash$1({address:fr,hash:br,signature:wr}){return isAddressEqual(getAddress(fr),await recoverAddress({hash:br,signature:wr}))}async function verifyMessage$1({address:fr,message:br,signature:wr}){return isAddressEqual(getAddress(fr),await recoverMessageAddress({message:br,signature:wr}))}async function verifyTypedData$1(fr){const{address:br,domain:wr,message:Er,primaryType:kr,signature:jr,types:Br}=fr;return isAddressEqual(getAddress(br),await recoverTypedDataAddress({domain:wr,message:Er,primaryType:kr,signature:jr,types:Br}))}const erc6492MagicBytes="0x6492649264926492649264926492649264926492649264926492649264926492",zeroHash="0x0000000000000000000000000000000000000000000000000000000000000000";function isErc6492Signature(fr){return sliceHex(fr,-32)===erc6492MagicBytes}function parseErc6492Signature(fr){if(!isErc6492Signature(fr))return{signature:fr};const[br,wr,Er]=decodeAbiParameters([{type:"address"},{type:"bytes"},{type:"bytes"}],fr);return{address:br,data:wr,signature:Er}}function serializeErc6492Signature(fr){const{address:br,data:wr,signature:Er,to:kr="hex"}=fr,jr=concatHex([encodeAbiParameters([{type:"address"},{type:"bytes"},{type:"bytes"}],[br,wr,Er]),erc6492MagicBytes]);return kr==="hex"?jr:hexToBytes$4(jr)}function getSerializedTransactionType(fr){const br=sliceHex(fr,0,1);if(br==="0x04")return"eip7702";if(br==="0x03")return"eip4844";if(br==="0x02")return"eip1559";if(br==="0x01")return"eip2930";if(br!=="0x"&&hexToNumber$2(br)>=192)return"legacy";throw new InvalidSerializedTransactionTypeError({serializedType:br})}function assertTransactionEIP7702(fr){const{authorizationList:br}=fr;if(br)for(const wr of br){const{contractAddress:Er,chainId:kr}=wr;if(!isAddress(Er))throw new InvalidAddressError({address:Er});if(kr<0)throw new InvalidChainIdError({chainId:kr})}assertTransactionEIP1559(fr)}function assertTransactionEIP4844(fr){const{blobVersionedHashes:br}=fr;if(br){if(br.length===0)throw new EmptyBlobError;for(const wr of br){const Er=size$1(wr),kr=hexToNumber$2(slice(wr,0,1));if(Er!==32)throw new InvalidVersionedHashSizeError({hash:wr,size:Er});if(kr!==versionedHashVersionKzg)throw new InvalidVersionedHashVersionError({hash:wr,version:kr})}}assertTransactionEIP1559(fr)}function assertTransactionEIP1559(fr){const{chainId:br,maxPriorityFeePerGas:wr,maxFeePerGas:Er,to:kr}=fr;if(br<=0)throw new InvalidChainIdError({chainId:br});if(kr&&!isAddress(kr))throw new InvalidAddressError({address:kr});if(Er&&Er>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:Er});if(wr&&Er&&wr>Er)throw new TipAboveFeeCapError({maxFeePerGas:Er,maxPriorityFeePerGas:wr})}function assertTransactionEIP2930(fr){const{chainId:br,maxPriorityFeePerGas:wr,gasPrice:Er,maxFeePerGas:kr,to:jr}=fr;if(br<=0)throw new InvalidChainIdError({chainId:br});if(jr&&!isAddress(jr))throw new InvalidAddressError({address:jr});if(wr||kr)throw new BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(Er&&Er>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:Er})}function assertTransactionLegacy(fr){const{chainId:br,maxPriorityFeePerGas:wr,gasPrice:Er,maxFeePerGas:kr,to:jr}=fr;if(jr&&!isAddress(jr))throw new InvalidAddressError({address:jr});if(typeof br<"u"&&br<=0)throw new InvalidChainIdError({chainId:br});if(wr||kr)throw new BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(Er&&Er>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:Er})}function parseTransaction(fr){const br=getSerializedTransactionType(fr);return br==="eip1559"?parseTransactionEIP1559(fr):br==="eip2930"?parseTransactionEIP2930(fr):br==="eip4844"?parseTransactionEIP4844(fr):br==="eip7702"?parseTransactionEIP7702(fr):parseTransactionLegacy(fr)}function parseTransactionEIP7702(fr){const br=toTransactionArray(fr),[wr,Er,kr,jr,Br,Wr,qr,Hr,Vr,Zr,Jr,Qr,_n]=br;if(br.length!==10&&br.length!==13)throw new InvalidSerializedTransactionError({attributes:{chainId:wr,nonce:Er,maxPriorityFeePerGas:kr,maxFeePerGas:jr,gas:Br,to:Wr,value:qr,data:Hr,accessList:Vr,authorizationList:Zr,...br.length>9?{v:Jr,r:Qr,s:_n}:{}},serializedTransaction:fr,type:"eip7702"});const En={chainId:hexToNumber$2(wr),type:"eip7702"};return isHex(Wr)&&Wr!=="0x"&&(En.to=Wr),isHex(Br)&&Br!=="0x"&&(En.gas=hexToBigInt(Br)),isHex(Hr)&&Hr!=="0x"&&(En.data=Hr),isHex(Er)&&Er!=="0x"&&(En.nonce=hexToNumber$2(Er)),isHex(qr)&&qr!=="0x"&&(En.value=hexToBigInt(qr)),isHex(jr)&&jr!=="0x"&&(En.maxFeePerGas=hexToBigInt(jr)),isHex(kr)&&kr!=="0x"&&(En.maxPriorityFeePerGas=hexToBigInt(kr)),Vr.length!==0&&Vr!=="0x"&&(En.accessList=parseAccessList(Vr)),Zr.length!==0&&Zr!=="0x"&&(En.authorizationList=parseAuthorizationList(Zr)),assertTransactionEIP7702(En),{...br.length===13?parseEIP155Signature(br):void 0,...En}}function parseTransactionEIP4844(fr){const br=toTransactionArray(fr),wr=br.length===4,Er=wr?br[0]:br,kr=wr?br.slice(1):[],[jr,Br,Wr,qr,Hr,Vr,Zr,Jr,Qr,_n,En,Cn,In,An]=Er,[jn,eo,ro]=kr;if(!(Er.length===11||Er.length===14))throw new InvalidSerializedTransactionError({attributes:{chainId:jr,nonce:Br,maxPriorityFeePerGas:Wr,maxFeePerGas:qr,gas:Hr,to:Vr,value:Zr,data:Jr,accessList:Qr,...Er.length>9?{v:Cn,r:In,s:An}:{}},serializedTransaction:fr,type:"eip4844"});const to={blobVersionedHashes:En,chainId:hexToNumber$2(jr),type:"eip4844"};return isHex(Vr)&&Vr!=="0x"&&(to.to=Vr),isHex(Hr)&&Hr!=="0x"&&(to.gas=hexToBigInt(Hr)),isHex(Jr)&&Jr!=="0x"&&(to.data=Jr),isHex(Br)&&Br!=="0x"&&(to.nonce=hexToNumber$2(Br)),isHex(Zr)&&Zr!=="0x"&&(to.value=hexToBigInt(Zr)),isHex(_n)&&_n!=="0x"&&(to.maxFeePerBlobGas=hexToBigInt(_n)),isHex(qr)&&qr!=="0x"&&(to.maxFeePerGas=hexToBigInt(qr)),isHex(Wr)&&Wr!=="0x"&&(to.maxPriorityFeePerGas=hexToBigInt(Wr)),Qr.length!==0&&Qr!=="0x"&&(to.accessList=parseAccessList(Qr)),jn&&eo&&ro&&(to.sidecars=toBlobSidecars({blobs:jn,commitments:eo,proofs:ro})),assertTransactionEIP4844(to),{...Er.length===14?parseEIP155Signature(Er):void 0,...to}}function parseTransactionEIP1559(fr){const br=toTransactionArray(fr),[wr,Er,kr,jr,Br,Wr,qr,Hr,Vr,Zr,Jr,Qr]=br;if(!(br.length===9||br.length===12))throw new InvalidSerializedTransactionError({attributes:{chainId:wr,nonce:Er,maxPriorityFeePerGas:kr,maxFeePerGas:jr,gas:Br,to:Wr,value:qr,data:Hr,accessList:Vr,...br.length>9?{v:Zr,r:Jr,s:Qr}:{}},serializedTransaction:fr,type:"eip1559"});const _n={chainId:hexToNumber$2(wr),type:"eip1559"};return isHex(Wr)&&Wr!=="0x"&&(_n.to=Wr),isHex(Br)&&Br!=="0x"&&(_n.gas=hexToBigInt(Br)),isHex(Hr)&&Hr!=="0x"&&(_n.data=Hr),isHex(Er)&&Er!=="0x"&&(_n.nonce=hexToNumber$2(Er)),isHex(qr)&&qr!=="0x"&&(_n.value=hexToBigInt(qr)),isHex(jr)&&jr!=="0x"&&(_n.maxFeePerGas=hexToBigInt(jr)),isHex(kr)&&kr!=="0x"&&(_n.maxPriorityFeePerGas=hexToBigInt(kr)),Vr.length!==0&&Vr!=="0x"&&(_n.accessList=parseAccessList(Vr)),assertTransactionEIP1559(_n),{...br.length===12?parseEIP155Signature(br):void 0,..._n}}function parseTransactionEIP2930(fr){const br=toTransactionArray(fr),[wr,Er,kr,jr,Br,Wr,qr,Hr,Vr,Zr,Jr]=br;if(!(br.length===8||br.length===11))throw new InvalidSerializedTransactionError({attributes:{chainId:wr,nonce:Er,gasPrice:kr,gas:jr,to:Br,value:Wr,data:qr,accessList:Hr,...br.length>8?{v:Vr,r:Zr,s:Jr}:{}},serializedTransaction:fr,type:"eip2930"});const Qr={chainId:hexToNumber$2(wr),type:"eip2930"};return isHex(Br)&&Br!=="0x"&&(Qr.to=Br),isHex(jr)&&jr!=="0x"&&(Qr.gas=hexToBigInt(jr)),isHex(qr)&&qr!=="0x"&&(Qr.data=qr),isHex(Er)&&Er!=="0x"&&(Qr.nonce=hexToNumber$2(Er)),isHex(Wr)&&Wr!=="0x"&&(Qr.value=hexToBigInt(Wr)),isHex(kr)&&kr!=="0x"&&(Qr.gasPrice=hexToBigInt(kr)),Hr.length!==0&&Hr!=="0x"&&(Qr.accessList=parseAccessList(Hr)),assertTransactionEIP2930(Qr),{...br.length===11?parseEIP155Signature(br):void 0,...Qr}}function parseTransactionLegacy(fr){const br=fromRlp(fr,"hex"),[wr,Er,kr,jr,Br,Wr,qr,Hr,Vr]=br;if(!(br.length===6||br.length===9))throw new InvalidSerializedTransactionError({attributes:{nonce:wr,gasPrice:Er,gas:kr,to:jr,value:Br,data:Wr,...br.length>6?{v:qr,r:Hr,s:Vr}:{}},serializedTransaction:fr,type:"legacy"});const Zr={type:"legacy"};if(isHex(jr)&&jr!=="0x"&&(Zr.to=jr),isHex(kr)&&kr!=="0x"&&(Zr.gas=hexToBigInt(kr)),isHex(Wr)&&Wr!=="0x"&&(Zr.data=Wr),isHex(wr)&&wr!=="0x"&&(Zr.nonce=hexToNumber$2(wr)),isHex(Br)&&Br!=="0x"&&(Zr.value=hexToBigInt(Br)),isHex(Er)&&Er!=="0x"&&(Zr.gasPrice=hexToBigInt(Er)),assertTransactionLegacy(Zr),br.length===6)return Zr;const Jr=isHex(qr)&&qr!=="0x"?hexToBigInt(qr):0n;if(Vr==="0x"&&Hr==="0x")return Jr>0&&(Zr.chainId=Number(Jr)),Zr;const Qr=Jr,_n=Number((Qr-35n)/2n);if(_n>0)Zr.chainId=_n;else if(Qr!==27n&&Qr!==28n)throw new InvalidLegacyVError({v:Qr});return Zr.v=Qr,Zr.s=Vr,Zr.r=Hr,Zr.yParity=Qr%2n===0n?1:0,Zr}function toTransactionArray(fr){return fromRlp(`0x${fr.slice(4)}`,"hex")}function parseAccessList(fr){const br=[];for(let wr=0;wrisHash(jr)?jr:trim(jr))})}return br}function parseAuthorizationList(fr){const br=[];for(let wr=0;wr"u"||typeof Qr>"u")){const jn=typeof fr.blobs[0]=="string"?fr.blobs:fr.blobs.map(to=>bytesToHex$4(to)),eo=fr.kzg,ro=blobsToCommitments({blobs:jn,kzg:eo});if(typeof Jr>"u"&&(Jr=commitmentsToVersionedHashes({commitments:ro})),typeof Qr>"u"){const to=blobsToProofs({blobs:jn,commitments:ro,kzg:eo});Qr=toBlobSidecars({blobs:jn,commitments:ro,proofs:to})}}const _n=serializeAccessList(Vr),En=[toHex(wr),kr?toHex(kr):"0x",Hr?toHex(Hr):"0x",qr?toHex(qr):"0x",Er?toHex(Er):"0x",jr??"0x",Br?toHex(Br):"0x",Zr??"0x",_n,Wr?toHex(Wr):"0x",Jr??[],...toYParitySignatureArray(fr,br)],Cn=[],In=[],An=[];if(Qr)for(let jn=0;jn{if(br.v>=35n)return(br.v-35n)/2n>0?br.v:27n+(br.v===35n?0n:1n);if(wr>0)return BigInt(wr*2)+BigInt(35n+br.v-27n);const Qr=27n+(br.v===27n?0n:1n);if(br.v!==Qr)throw new InvalidLegacyVError({v:br.v});return Qr})(),Zr=trim(br.r),Jr=trim(br.s);Hr=[...Hr,toHex(Vr),Zr==="0x00"?"0x":Zr,Jr==="0x00"?"0x":Jr]}else wr>0&&(Hr=[...Hr,toHex(wr),"0x","0x"]);return toRlp(Hr)}function toYParitySignatureArray(fr,br){const wr=br??fr,{v:Er,yParity:kr}=wr;if(typeof wr.r>"u")return[];if(typeof wr.s>"u")return[];if(typeof Er>"u"&&typeof kr>"u")return[];const jr=trim(wr.r),Br=trim(wr.s);return[typeof kr=="number"?kr?toHex(1):"0x":Er===0n?"0x":Er===1n?toHex(1):Er===27n?"0x":toHex(1),jr==="0x00"?"0x":jr,Br==="0x00"?"0x":Br]}class InvalidDecimalNumberError extends BaseError{constructor({value:br}){super(`Number \`${br}\` is not a valid decimal number.`,{name:"InvalidDecimalNumberError"})}}function parseUnits(fr,br){if(!/^(-?)([0-9]*)\.?([0-9]*)$/.test(fr))throw new InvalidDecimalNumberError({value:fr});let[wr,Er="0"]=fr.split(".");const kr=wr.startsWith("-");if(kr&&(wr=wr.slice(1)),Er=Er.replace(/(0+)$/,""),br===0)Math.round(+`.${Er}`)===1&&(wr=`${BigInt(wr)+1n}`),Er="";else if(Er.length>br){const[jr,Br,Wr]=[Er.slice(0,br-1),Er.slice(br-1,br),Er.slice(br)],qr=Math.round(+`${Br}.${Wr}`);qr>9?Er=`${BigInt(jr)+BigInt(1)}0`.padStart(jr.length+1,"0"):Er=`${jr}${qr}`,Er.length>br&&(Er=Er.slice(1),wr=`${BigInt(wr)+1n}`),Er=Er.slice(0,br)}else Er=Er.padEnd(br,"0");return BigInt(`${kr?"-":""}${wr}${Er}`)}function parseEther$1(fr,br="wei"){return parseUnits(fr,etherUnits[br])}function parseGwei(fr,br="wei"){return parseUnits(fr,gweiUnits[br])}function createNonceManager(fr){const{source:br}=fr,wr=new Map,Er=new LruMap(8192),kr=new Map,jr=({address:Br,chainId:Wr})=>`${Br}.${Wr}`;return{async consume({address:Br,chainId:Wr,client:qr}){const Hr=jr({address:Br,chainId:Wr}),Vr=this.get({address:Br,chainId:Wr,client:qr});this.increment({address:Br,chainId:Wr});const Zr=await Vr;return await br.set({address:Br,chainId:Wr},Zr),Er.set(Hr,Zr),Zr},async increment({address:Br,chainId:Wr}){const qr=jr({address:Br,chainId:Wr}),Hr=wr.get(qr)??0;wr.set(qr,Hr+1)},async get({address:Br,chainId:Wr,client:qr}){const Hr=jr({address:Br,chainId:Wr});let Vr=kr.get(Hr);return Vr||(Vr=(async()=>{try{const Jr=await br.get({address:Br,chainId:Wr,client:qr}),Qr=Er.get(Hr)??0;return Qr>0&&Jr<=Qr?Qr+1:(Er.delete(Hr),Jr)}finally{this.reset({address:Br,chainId:Wr})}})(),kr.set(Hr,Vr)),(wr.get(Hr)??0)+await Vr},reset({address:Br,chainId:Wr}){const qr=jr({address:Br,chainId:Wr});wr.delete(qr),kr.delete(qr)}}}function jsonRpc(){return{async get(fr){const{address:br,client:wr}=fr;return getTransactionCount(wr,{address:br,blockTag:"pending"})},set(){}}}const nonceManager=createNonceManager({source:jsonRpc()});function formatStorageProof(fr){return fr.map(br=>({...br,value:BigInt(br.value)}))}function formatProof(fr){return{...fr,balance:fr.balance?BigInt(fr.balance):void 0,nonce:fr.nonce?hexToNumber$2(fr.nonce):void 0,storageProof:fr.storageProof?formatStorageProof(fr.storageProof):void 0}}async function getProof(fr,{address:br,blockNumber:wr,blockTag:Er,storageKeys:kr}){const jr=Er??"latest",Br=wr!==void 0?numberToHex(wr):void 0,Wr=await fr.request({method:"eth_getProof",params:[br,kr,Br||jr]});return formatProof(Wr)}async function getStorageAt(fr,{address:br,blockNumber:wr,blockTag:Er="latest",slot:kr}){const jr=wr!==void 0?numberToHex(wr):void 0;return await fr.request({method:"eth_getStorageAt",params:[br,kr,jr||Er]})}async function getTransaction(fr,{blockHash:br,blockNumber:wr,blockTag:Er,hash:kr,index:jr}){var Vr,Zr,Jr;const Br=Er||"latest",Wr=wr!==void 0?numberToHex(wr):void 0;let qr=null;if(kr?qr=await fr.request({method:"eth_getTransactionByHash",params:[kr]},{dedupe:!0}):br?qr=await fr.request({method:"eth_getTransactionByBlockHashAndIndex",params:[br,numberToHex(jr)]},{dedupe:!0}):(Wr||Br)&&(qr=await fr.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[Wr||Br,numberToHex(jr)]},{dedupe:!!Wr})),!qr)throw new TransactionNotFoundError({blockHash:br,blockNumber:wr,blockTag:Br,hash:kr,index:jr});return(((Jr=(Zr=(Vr=fr.chain)==null?void 0:Vr.formatters)==null?void 0:Zr.transaction)==null?void 0:Jr.format)||formatTransaction)(qr)}async function getTransactionConfirmations(fr,{hash:br,transactionReceipt:wr}){const[Er,kr]=await Promise.all([getAction(fr,getBlockNumber,"getBlockNumber")({}),br?getAction(fr,getTransaction,"getTransaction")({hash:br}):void 0]),jr=(wr==null?void 0:wr.blockNumber)||(kr==null?void 0:kr.blockNumber);return jr?Er-jr+1n:0n}async function getTransactionReceipt(fr,{hash:br}){var kr,jr,Br;const wr=await fr.request({method:"eth_getTransactionReceipt",params:[br]},{dedupe:!0});if(!wr)throw new TransactionReceiptNotFoundError({hash:br});return(((Br=(jr=(kr=fr.chain)==null?void 0:kr.formatters)==null?void 0:jr.transactionReceipt)==null?void 0:Br.format)||formatTransactionReceipt)(wr)}async function multicall(fr,br){var Cn;const{allowFailure:wr=!0,batchSize:Er,blockNumber:kr,blockTag:jr,multicallAddress:Br,stateOverride:Wr}=br,qr=br.contracts,Hr=Er??(typeof((Cn=fr.batch)==null?void 0:Cn.multicall)=="object"&&fr.batch.multicall.batchSize||1024);let Vr=Br;if(!Vr){if(!fr.chain)throw new Error("client chain not configured. multicallAddress is required.");Vr=getChainContractAddress({blockNumber:kr,chain:fr.chain,contract:"multicall3"})}const Zr=[[]];let Jr=0,Qr=0;for(let In=0;In0&&Qr>Hr&&Zr[Jr].length>0&&(Jr++,Qr=(to.length-2)/2,Zr[Jr]=[]),Zr[Jr]=[...Zr[Jr],{allowFailure:!0,callData:to,target:jn}]}catch(to){const _i=getContractError(to,{abi:An,address:jn,args:eo,docsPath:"/docs/contract/multicall",functionName:ro});if(!wr)throw _i;Zr[Jr]=[...Zr[Jr],{allowFailure:!0,callData:"0x",target:jn}]}}const _n=await Promise.allSettled(Zr.map(In=>getAction(fr,readContract,"readContract")({abi:multicall3Abi,address:Vr,args:[In],blockNumber:kr,blockTag:jr,functionName:"aggregate3",stateOverride:Wr}))),En=[];for(let In=0;In<_n.length;In++){const An=_n[In];if(An.status==="rejected"){if(!wr)throw An.reason;for(let eo=0;eokr?br.create().update(Er).digest():Er);for(let Br=0;Brnew HMAC$3(fr,br).update(wr).digest();hmac$5.create=(fr,br)=>new HMAC$3(fr,br);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$8=BigInt(0),_1n$b=BigInt(1),_2n$7=BigInt(2);function isBytes$7(fr){return fr instanceof Uint8Array||fr!=null&&typeof fr=="object"&&fr.constructor.name==="Uint8Array"}function abytes$3(fr){if(!isBytes$7(fr))throw new Error("Uint8Array expected")}function abool$1(fr,br){if(typeof br!="boolean")throw new Error(`${fr} must be valid boolean, got "${br}".`)}const hexes$2=Array.from({length:256},(fr,br)=>br.toString(16).padStart(2,"0"));function bytesToHex$2(fr){abytes$3(fr);let br="";for(let wr=0;wr=asciis$2._0&&fr<=asciis$2._9)return fr-asciis$2._0;if(fr>=asciis$2._A&&fr<=asciis$2._F)return fr-(asciis$2._A-10);if(fr>=asciis$2._a&&fr<=asciis$2._f)return fr-(asciis$2._a-10)}function hexToBytes$2(fr){if(typeof fr!="string")throw new Error("hex string expected, got "+typeof fr);const br=fr.length,wr=br/2;if(br%2)throw new Error("padded hex string expected, got unpadded hex of length "+br);const Er=new Uint8Array(wr);for(let kr=0,jr=0;krtypeof fr=="bigint"&&_0n$8<=fr;function inRange$2(fr,br,wr){return isPosBig$1(fr)&&isPosBig$1(br)&&isPosBig$1(wr)&&br<=fr&&fr_0n$8;fr>>=_1n$b,br+=1);return br}function bitGet$1(fr,br){return fr>>BigInt(br)&_1n$b}function bitSet$1(fr,br,wr){return fr|(wr?_1n$b:_0n$8)<(_2n$7<new Uint8Array(fr),u8fr$1=fr=>Uint8Array.from(fr);function createHmacDrbg$1(fr,br,wr){if(typeof fr!="number"||fr<2)throw new Error("hashLen must be a number");if(typeof br!="number"||br<2)throw new Error("qByteLen must be a number");if(typeof wr!="function")throw new Error("hmacFn must be a function");let Er=u8n$1(fr),kr=u8n$1(fr),jr=0;const Br=()=>{Er.fill(1),kr.fill(0),jr=0},Wr=(...Zr)=>wr(kr,Er,...Zr),qr=(Zr=u8n$1())=>{kr=Wr(u8fr$1([0]),Zr),Er=Wr(),Zr.length!==0&&(kr=Wr(u8fr$1([1]),Zr),Er=Wr())},Hr=()=>{if(jr++>=1e3)throw new Error("drbg: tried 1000 values");let Zr=0;const Jr=[];for(;Zr{Br(),qr(Zr);let Qr;for(;!(Qr=Jr(Hr()));)qr();return Br(),Qr}}const validatorFns$1={bigint:fr=>typeof fr=="bigint",function:fr=>typeof fr=="function",boolean:fr=>typeof fr=="boolean",string:fr=>typeof fr=="string",stringOrUint8Array:fr=>typeof fr=="string"||isBytes$7(fr),isSafeInteger:fr=>Number.isSafeInteger(fr),array:fr=>Array.isArray(fr),field:(fr,br)=>br.Fp.isValid(fr),hash:fr=>typeof fr=="function"&&Number.isSafeInteger(fr.outputLen)};function validateObject$1(fr,br,wr={}){const Er=(kr,jr,Br)=>{const Wr=validatorFns$1[jr];if(typeof Wr!="function")throw new Error(`Invalid validator "${jr}", expected function`);const qr=fr[kr];if(!(Br&&qr===void 0)&&!Wr(qr,fr))throw new Error(`Invalid param ${String(kr)}=${qr} (${typeof qr}), expected ${jr}`)};for(const[kr,jr]of Object.entries(br))Er(kr,jr,!1);for(const[kr,jr]of Object.entries(wr))Er(kr,jr,!0);return fr}const notImplemented$1=()=>{throw new Error("not implemented")};function memoized$1(fr){const br=new WeakMap;return(wr,...Er)=>{const kr=br.get(wr);if(kr!==void 0)return kr;const jr=fr(wr,...Er);return br.set(wr,jr),jr}}const ut$3=Object.freeze(Object.defineProperty({__proto__:null,aInRange:aInRange$1,abool:abool$1,abytes:abytes$3,bitGet:bitGet$1,bitLen:bitLen$1,bitMask:bitMask$1,bitSet:bitSet$1,bytesToHex:bytesToHex$2,bytesToNumberBE:bytesToNumberBE$1,bytesToNumberLE:bytesToNumberLE$1,concatBytes:concatBytes$3,createHmacDrbg:createHmacDrbg$1,ensureBytes:ensureBytes$1,equalBytes:equalBytes$1,hexToBytes:hexToBytes$2,hexToNumber:hexToNumber$1,inRange:inRange$2,isBytes:isBytes$7,memoized:memoized$1,notImplemented:notImplemented$1,numberToBytesBE:numberToBytesBE$1,numberToBytesLE:numberToBytesLE$1,numberToHexUnpadded:numberToHexUnpadded$1,numberToVarBytesBE:numberToVarBytesBE$1,utf8ToBytes:utf8ToBytes$3,validateObject:validateObject$1},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$7=BigInt(0),_1n$a=BigInt(1),_2n$6=BigInt(2),_3n$3=BigInt(3),_4n$1=BigInt(4),_5n$2=BigInt(5),_8n$3=BigInt(8);BigInt(9);BigInt(16);function mod$1(fr,br){const wr=fr%br;return wr>=_0n$7?wr:br+wr}function pow$1(fr,br,wr){if(wr<=_0n$7||br<_0n$7)throw new Error("Expected power/modulo > 0");if(wr===_1n$a)return _0n$7;let Er=_1n$a;for(;br>_0n$7;)br&_1n$a&&(Er=Er*fr%wr),fr=fr*fr%wr,br>>=_1n$a;return Er}function pow2$1(fr,br,wr){let Er=fr;for(;br-- >_0n$7;)Er*=Er,Er%=wr;return Er}function invert$1(fr,br){if(fr===_0n$7||br<=_0n$7)throw new Error(`invert: expected positive integers, got n=${fr} mod=${br}`);let wr=mod$1(fr,br),Er=br,kr=_0n$7,jr=_1n$a;for(;wr!==_0n$7;){const Wr=Er/wr,qr=Er%wr,Hr=kr-jr*Wr;Er=wr,wr=qr,kr=jr,jr=Hr}if(Er!==_1n$a)throw new Error("invert: does not exist");return mod$1(kr,br)}function tonelliShanks$1(fr){const br=(fr-_1n$a)/_2n$6;let wr,Er,kr;for(wr=fr-_1n$a,Er=0;wr%_2n$6===_0n$7;wr/=_2n$6,Er++);for(kr=_2n$6;kr(Er[kr]="function",Er),br);return validateObject$1(fr,wr)}function FpPow$1(fr,br,wr){if(wr<_0n$7)throw new Error("Expected power > 0");if(wr===_0n$7)return fr.ONE;if(wr===_1n$a)return br;let Er=fr.ONE,kr=br;for(;wr>_0n$7;)wr&_1n$a&&(Er=fr.mul(Er,kr)),kr=fr.sqr(kr),wr>>=_1n$a;return Er}function FpInvertBatch$1(fr,br){const wr=new Array(br.length),Er=br.reduce((jr,Br,Wr)=>fr.is0(Br)?jr:(wr[Wr]=jr,fr.mul(jr,Br)),fr.ONE),kr=fr.inv(Er);return br.reduceRight((jr,Br,Wr)=>fr.is0(Br)?jr:(wr[Wr]=fr.mul(jr,wr[Wr]),fr.mul(jr,Br)),kr),wr}function nLength$1(fr,br){const wr=br!==void 0?br:fr.toString(2).length,Er=Math.ceil(wr/8);return{nBitLength:wr,nByteLength:Er}}function Field$1(fr,br,wr=!1,Er={}){if(fr<=_0n$7)throw new Error(`Expected Field ORDER > 0, got ${fr}`);const{nBitLength:kr,nByteLength:jr}=nLength$1(fr,br);if(jr>2048)throw new Error("Field lengths over 2048 bytes are not supported");const Br=FpSqrt$1(fr),Wr=Object.freeze({ORDER:fr,BITS:kr,BYTES:jr,MASK:bitMask$1(kr),ZERO:_0n$7,ONE:_1n$a,create:qr=>mod$1(qr,fr),isValid:qr=>{if(typeof qr!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof qr}`);return _0n$7<=qr&&qrqr===_0n$7,isOdd:qr=>(qr&_1n$a)===_1n$a,neg:qr=>mod$1(-qr,fr),eql:(qr,Hr)=>qr===Hr,sqr:qr=>mod$1(qr*qr,fr),add:(qr,Hr)=>mod$1(qr+Hr,fr),sub:(qr,Hr)=>mod$1(qr-Hr,fr),mul:(qr,Hr)=>mod$1(qr*Hr,fr),pow:(qr,Hr)=>FpPow$1(Wr,qr,Hr),div:(qr,Hr)=>mod$1(qr*invert$1(Hr,fr),fr),sqrN:qr=>qr*qr,addN:(qr,Hr)=>qr+Hr,subN:(qr,Hr)=>qr-Hr,mulN:(qr,Hr)=>qr*Hr,inv:qr=>invert$1(qr,fr),sqrt:Er.sqrt||(qr=>Br(Wr,qr)),invertBatch:qr=>FpInvertBatch$1(Wr,qr),cmov:(qr,Hr,Vr)=>Vr?Hr:qr,toBytes:qr=>wr?numberToBytesLE$1(qr,jr):numberToBytesBE$1(qr,jr),fromBytes:qr=>{if(qr.length!==jr)throw new Error(`Fp.fromBytes: expected ${jr}, got ${qr.length}`);return wr?bytesToNumberLE$1(qr):bytesToNumberBE$1(qr)}});return Object.freeze(Wr)}function getFieldBytesLength$1(fr){if(typeof fr!="bigint")throw new Error("field order must be bigint");const br=fr.toString(2).length;return Math.ceil(br/8)}function getMinHashLength$1(fr){const br=getFieldBytesLength$1(fr);return br+Math.ceil(br/2)}function mapHashToField$1(fr,br,wr=!1){const Er=fr.length,kr=getFieldBytesLength$1(br),jr=getMinHashLength$1(br);if(Er<16||Er1024)throw new Error(`expected ${jr}-1024 bytes of input, got ${Er}`);const Br=wr?bytesToNumberBE$1(fr):bytesToNumberLE$1(fr),Wr=mod$1(Br,br-_1n$a)+_1n$a;return wr?numberToBytesLE$1(Wr,kr):numberToBytesBE$1(Wr,kr)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$6=BigInt(0),_1n$9=BigInt(1),pointPrecomputes$1=new WeakMap,pointWindowSizes$1=new WeakMap;function wNAF$1(fr,br){const wr=(jr,Br)=>{const Wr=Br.negate();return jr?Wr:Br},Er=jr=>{if(!Number.isSafeInteger(jr)||jr<=0||jr>br)throw new Error(`Wrong window size=${jr}, should be [1..${br}]`)},kr=jr=>{Er(jr);const Br=Math.ceil(br/jr)+1,Wr=2**(jr-1);return{windows:Br,windowSize:Wr}};return{constTimeNegate:wr,unsafeLadder(jr,Br){let Wr=fr.ZERO,qr=jr;for(;Br>_0n$6;)Br&_1n$9&&(Wr=Wr.add(qr)),qr=qr.double(),Br>>=_1n$9;return Wr},precomputeWindow(jr,Br){const{windows:Wr,windowSize:qr}=kr(Br),Hr=[];let Vr=jr,Zr=Vr;for(let Jr=0;Jr>=_n,In>Hr&&(In-=Qr,Wr+=_1n$9);const An=Cn,jn=Cn+Math.abs(In)-1,eo=En%2!==0,ro=In<0;In===0?Zr=Zr.add(wr(eo,Br[An])):Vr=Vr.add(wr(ro,Br[jn]))}return{p:Vr,f:Zr}},wNAFCached(jr,Br,Wr){const qr=pointWindowSizes$1.get(jr)||1;let Hr=pointPrecomputes$1.get(jr);return Hr||(Hr=this.precomputeWindow(jr,qr),qr!==1&&pointPrecomputes$1.set(jr,Wr(Hr))),this.wNAF(qr,Hr,Br)},setWindowSize(jr,Br){Er(Br),pointWindowSizes$1.set(jr,Br),pointPrecomputes$1.delete(jr)}}}function pippenger$1(fr,br,wr,Er){if(!Array.isArray(wr)||!Array.isArray(Er)||Er.length!==wr.length)throw new Error("arrays of points and scalars must have equal length");Er.forEach((Vr,Zr)=>{if(!br.isValid(Vr))throw new Error(`wrong scalar at index ${Zr}`)}),wr.forEach((Vr,Zr)=>{if(!(Vr instanceof fr))throw new Error(`wrong point at index ${Zr}`)});const kr=bitLen$1(BigInt(wr.length)),jr=kr>12?kr-3:kr>4?kr-2:kr?2:1,Br=(1<=0;Vr-=jr){Wr.fill(fr.ZERO);for(let Jr=0;Jr>BigInt(Vr)&BigInt(Br));Wr[_n]=Wr[_n].add(wr[Jr])}let Zr=fr.ZERO;for(let Jr=Wr.length-1,Qr=fr.ZERO;Jr>0;Jr--)Qr=Qr.add(Wr[Jr]),Zr=Zr.add(Qr);if(Hr=Hr.add(Zr),Vr!==0)for(let Jr=0;Jr{const{Err:wr}=DER$1;if(fr<0||fr>256)throw new wr("tlv.encode: wrong tag");if(br.length&1)throw new wr("tlv.encode: unpadded data");const Er=br.length/2,kr=numberToHexUnpadded$1(Er);if(kr.length/2&128)throw new wr("tlv.encode: long form length too big");const jr=Er>127?numberToHexUnpadded$1(kr.length/2|128):"";return`${numberToHexUnpadded$1(fr)}${jr}${kr}${br}`},decode(fr,br){const{Err:wr}=DER$1;let Er=0;if(fr<0||fr>256)throw new wr("tlv.encode: wrong tag");if(br.length<2||br[Er++]!==fr)throw new wr("tlv.decode: wrong tlv");const kr=br[Er++],jr=!!(kr&128);let Br=0;if(!jr)Br=kr;else{const qr=kr&127;if(!qr)throw new wr("tlv.decode(long): indefinite length not supported");if(qr>4)throw new wr("tlv.decode(long): byte length is too big");const Hr=br.subarray(Er,Er+qr);if(Hr.length!==qr)throw new wr("tlv.decode: length bytes not complete");if(Hr[0]===0)throw new wr("tlv.decode(long): zero leftmost byte");for(const Vr of Hr)Br=Br<<8|Vr;if(Er+=qr,Br<128)throw new wr("tlv.decode(long): not minimal encoding")}const Wr=br.subarray(Er,Er+Br);if(Wr.length!==Br)throw new wr("tlv.decode: wrong value length");return{v:Wr,l:br.subarray(Er+Br)}}},_int:{encode(fr){const{Err:br}=DER$1;if(fr<_0n$5)throw new br("integer: negative integers are not allowed");let wr=numberToHexUnpadded$1(fr);if(Number.parseInt(wr[0],16)&8&&(wr="00"+wr),wr.length&1)throw new br("unexpected assertion");return wr},decode(fr){const{Err:br}=DER$1;if(fr[0]&128)throw new br("Invalid signature integer: negative");if(fr[0]===0&&!(fr[1]&128))throw new br("Invalid signature integer: unnecessary leading zero");return b2n$1(fr)}},toSig(fr){const{Err:br,_int:wr,_tlv:Er}=DER$1,kr=typeof fr=="string"?h2b$1(fr):fr;abytes$3(kr);const{v:jr,l:Br}=Er.decode(48,kr);if(Br.length)throw new br("Invalid signature: left bytes after parsing");const{v:Wr,l:qr}=Er.decode(2,jr),{v:Hr,l:Vr}=Er.decode(2,qr);if(Vr.length)throw new br("Invalid signature: left bytes after parsing");return{r:wr.decode(Wr),s:wr.decode(Hr)}},hexFromSig(fr){const{_tlv:br,_int:wr}=DER$1,Er=`${br.encode(2,wr.encode(fr.r))}${br.encode(2,wr.encode(fr.s))}`;return br.encode(48,Er)}},_0n$5=BigInt(0),_1n$8=BigInt(1);BigInt(2);const _3n$2=BigInt(3);BigInt(4);function weierstrassPoints$1(fr){const br=validatePointOpts$1(fr),{Fp:wr}=br,Er=Field$1(br.n,br.nBitLength),kr=br.toBytes||((En,Cn,In)=>{const An=Cn.toAffine();return concatBytes$3(Uint8Array.from([4]),wr.toBytes(An.x),wr.toBytes(An.y))}),jr=br.fromBytes||(En=>{const Cn=En.subarray(1),In=wr.fromBytes(Cn.subarray(0,wr.BYTES)),An=wr.fromBytes(Cn.subarray(wr.BYTES,2*wr.BYTES));return{x:In,y:An}});function Br(En){const{a:Cn,b:In}=br,An=wr.sqr(En),jn=wr.mul(An,En);return wr.add(wr.add(jn,wr.mul(En,Cn)),In)}if(!wr.eql(wr.sqr(br.Gy),Br(br.Gx)))throw new Error("bad generator point: equation left != right");function Wr(En){return inRange$2(En,_1n$8,br.n)}function qr(En){const{allowedPrivateKeyLengths:Cn,nByteLength:In,wrapPrivateKey:An,n:jn}=br;if(Cn&&typeof En!="bigint"){if(isBytes$7(En)&&(En=bytesToHex$2(En)),typeof En!="string"||!Cn.includes(En.length))throw new Error("Invalid key");En=En.padStart(In*2,"0")}let eo;try{eo=typeof En=="bigint"?En:bytesToNumberBE$1(ensureBytes$1("private key",En,In))}catch{throw new Error(`private key must be ${In} bytes, hex or bigint, not ${typeof En}`)}return An&&(eo=mod$1(eo,jn)),aInRange$1("private key",eo,_1n$8,jn),eo}function Hr(En){if(!(En instanceof Jr))throw new Error("ProjectivePoint expected")}const Vr=memoized$1((En,Cn)=>{const{px:In,py:An,pz:jn}=En;if(wr.eql(jn,wr.ONE))return{x:In,y:An};const eo=En.is0();Cn==null&&(Cn=eo?wr.ONE:wr.inv(jn));const ro=wr.mul(In,Cn),to=wr.mul(An,Cn),_i=wr.mul(jn,Cn);if(eo)return{x:wr.ZERO,y:wr.ZERO};if(!wr.eql(_i,wr.ONE))throw new Error("invZ was invalid");return{x:ro,y:to}}),Zr=memoized$1(En=>{if(En.is0()){if(br.allowInfinityPoint&&!wr.is0(En.py))return;throw new Error("bad point: ZERO")}const{x:Cn,y:In}=En.toAffine();if(!wr.isValid(Cn)||!wr.isValid(In))throw new Error("bad point: x or y not FE");const An=wr.sqr(In),jn=Br(Cn);if(!wr.eql(An,jn))throw new Error("bad point: equation left != right");if(!En.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class Jr{constructor(Cn,In,An){if(this.px=Cn,this.py=In,this.pz=An,Cn==null||!wr.isValid(Cn))throw new Error("x required");if(In==null||!wr.isValid(In))throw new Error("y required");if(An==null||!wr.isValid(An))throw new Error("z required");Object.freeze(this)}static fromAffine(Cn){const{x:In,y:An}=Cn||{};if(!Cn||!wr.isValid(In)||!wr.isValid(An))throw new Error("invalid affine point");if(Cn instanceof Jr)throw new Error("projective point not allowed");const jn=eo=>wr.eql(eo,wr.ZERO);return jn(In)&&jn(An)?Jr.ZERO:new Jr(In,An,wr.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(Cn){const In=wr.invertBatch(Cn.map(An=>An.pz));return Cn.map((An,jn)=>An.toAffine(In[jn])).map(Jr.fromAffine)}static fromHex(Cn){const In=Jr.fromAffine(jr(ensureBytes$1("pointHex",Cn)));return In.assertValidity(),In}static fromPrivateKey(Cn){return Jr.BASE.multiply(qr(Cn))}static msm(Cn,In){return pippenger$1(Jr,Er,Cn,In)}_setWindowSize(Cn){_n.setWindowSize(this,Cn)}assertValidity(){Zr(this)}hasEvenY(){const{y:Cn}=this.toAffine();if(wr.isOdd)return!wr.isOdd(Cn);throw new Error("Field doesn't support isOdd")}equals(Cn){Hr(Cn);const{px:In,py:An,pz:jn}=this,{px:eo,py:ro,pz:to}=Cn,_i=wr.eql(wr.mul(In,to),wr.mul(eo,jn)),oo=wr.eql(wr.mul(An,to),wr.mul(ro,jn));return _i&&oo}negate(){return new Jr(this.px,wr.neg(this.py),this.pz)}double(){const{a:Cn,b:In}=br,An=wr.mul(In,_3n$2),{px:jn,py:eo,pz:ro}=this;let to=wr.ZERO,_i=wr.ZERO,oo=wr.ZERO,io=wr.mul(jn,jn),co=wr.mul(eo,eo),so=wr.mul(ro,ro),no=wr.mul(jn,eo);return no=wr.add(no,no),oo=wr.mul(jn,ro),oo=wr.add(oo,oo),to=wr.mul(Cn,oo),_i=wr.mul(An,so),_i=wr.add(to,_i),to=wr.sub(co,_i),_i=wr.add(co,_i),_i=wr.mul(to,_i),to=wr.mul(no,to),oo=wr.mul(An,oo),so=wr.mul(Cn,so),no=wr.sub(io,so),no=wr.mul(Cn,no),no=wr.add(no,oo),oo=wr.add(io,io),io=wr.add(oo,io),io=wr.add(io,so),io=wr.mul(io,no),_i=wr.add(_i,io),so=wr.mul(eo,ro),so=wr.add(so,so),io=wr.mul(so,no),to=wr.sub(to,io),oo=wr.mul(so,co),oo=wr.add(oo,oo),oo=wr.add(oo,oo),new Jr(to,_i,oo)}add(Cn){Hr(Cn);const{px:In,py:An,pz:jn}=this,{px:eo,py:ro,pz:to}=Cn;let _i=wr.ZERO,oo=wr.ZERO,io=wr.ZERO;const co=br.a,so=wr.mul(br.b,_3n$2);let no=wr.mul(In,eo),Tn=wr.mul(An,ro),Gr=wr.mul(jn,to),Xr=wr.add(In,An),Sn=wr.add(eo,ro);Xr=wr.mul(Xr,Sn),Sn=wr.add(no,Tn),Xr=wr.sub(Xr,Sn),Sn=wr.add(In,jn);let Rn=wr.add(eo,to);return Sn=wr.mul(Sn,Rn),Rn=wr.add(no,Gr),Sn=wr.sub(Sn,Rn),Rn=wr.add(An,jn),_i=wr.add(ro,to),Rn=wr.mul(Rn,_i),_i=wr.add(Tn,Gr),Rn=wr.sub(Rn,_i),io=wr.mul(co,Sn),_i=wr.mul(so,Gr),io=wr.add(_i,io),_i=wr.sub(Tn,io),io=wr.add(Tn,io),oo=wr.mul(_i,io),Tn=wr.add(no,no),Tn=wr.add(Tn,no),Gr=wr.mul(co,Gr),Sn=wr.mul(so,Sn),Tn=wr.add(Tn,Gr),Gr=wr.sub(no,Gr),Gr=wr.mul(co,Gr),Sn=wr.add(Sn,Gr),no=wr.mul(Tn,Sn),oo=wr.add(oo,no),no=wr.mul(Rn,Sn),_i=wr.mul(Xr,_i),_i=wr.sub(_i,no),no=wr.mul(Xr,Tn),io=wr.mul(Rn,io),io=wr.add(io,no),new Jr(_i,oo,io)}subtract(Cn){return this.add(Cn.negate())}is0(){return this.equals(Jr.ZERO)}wNAF(Cn){return _n.wNAFCached(this,Cn,Jr.normalizeZ)}multiplyUnsafe(Cn){aInRange$1("scalar",Cn,_0n$5,br.n);const In=Jr.ZERO;if(Cn===_0n$5)return In;if(Cn===_1n$8)return this;const{endo:An}=br;if(!An)return _n.unsafeLadder(this,Cn);let{k1neg:jn,k1:eo,k2neg:ro,k2:to}=An.splitScalar(Cn),_i=In,oo=In,io=this;for(;eo>_0n$5||to>_0n$5;)eo&_1n$8&&(_i=_i.add(io)),to&_1n$8&&(oo=oo.add(io)),io=io.double(),eo>>=_1n$8,to>>=_1n$8;return jn&&(_i=_i.negate()),ro&&(oo=oo.negate()),oo=new Jr(wr.mul(oo.px,An.beta),oo.py,oo.pz),_i.add(oo)}multiply(Cn){const{endo:In,n:An}=br;aInRange$1("scalar",Cn,_1n$8,An);let jn,eo;if(In){const{k1neg:ro,k1:to,k2neg:_i,k2:oo}=In.splitScalar(Cn);let{p:io,f:co}=this.wNAF(to),{p:so,f:no}=this.wNAF(oo);io=_n.constTimeNegate(ro,io),so=_n.constTimeNegate(_i,so),so=new Jr(wr.mul(so.px,In.beta),so.py,so.pz),jn=io.add(so),eo=co.add(no)}else{const{p:ro,f:to}=this.wNAF(Cn);jn=ro,eo=to}return Jr.normalizeZ([jn,eo])[0]}multiplyAndAddUnsafe(Cn,In,An){const jn=Jr.BASE,eo=(to,_i)=>_i===_0n$5||_i===_1n$8||!to.equals(jn)?to.multiplyUnsafe(_i):to.multiply(_i),ro=eo(this,In).add(eo(Cn,An));return ro.is0()?void 0:ro}toAffine(Cn){return Vr(this,Cn)}isTorsionFree(){const{h:Cn,isTorsionFree:In}=br;if(Cn===_1n$8)return!0;if(In)return In(Jr,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:Cn,clearCofactor:In}=br;return Cn===_1n$8?this:In?In(Jr,this):this.multiplyUnsafe(br.h)}toRawBytes(Cn=!0){return abool$1("isCompressed",Cn),this.assertValidity(),kr(Jr,this,Cn)}toHex(Cn=!0){return abool$1("isCompressed",Cn),bytesToHex$2(this.toRawBytes(Cn))}}Jr.BASE=new Jr(br.Gx,br.Gy,wr.ONE),Jr.ZERO=new Jr(wr.ZERO,wr.ONE,wr.ZERO);const Qr=br.nBitLength,_n=wNAF$1(Jr,br.endo?Math.ceil(Qr/2):Qr);return{CURVE:br,ProjectivePoint:Jr,normPrivateKeyToScalar:qr,weierstrassEquation:Br,isWithinCurveOrder:Wr}}function validateOpts$2(fr){const br=validateBasic$1(fr);return validateObject$1(br,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...br})}function weierstrass$1(fr){const br=validateOpts$2(fr),{Fp:wr,n:Er}=br,kr=wr.BYTES+1,jr=2*wr.BYTES+1;function Br(Gr){return mod$1(Gr,Er)}function Wr(Gr){return invert$1(Gr,Er)}const{ProjectivePoint:qr,normPrivateKeyToScalar:Hr,weierstrassEquation:Vr,isWithinCurveOrder:Zr}=weierstrassPoints$1({...br,toBytes(Gr,Xr,Sn){const Rn=Xr.toAffine(),Pn=wr.toBytes(Rn.x),On=concatBytes$3;return abool$1("isCompressed",Sn),Sn?On(Uint8Array.from([Xr.hasEvenY()?2:3]),Pn):On(Uint8Array.from([4]),Pn,wr.toBytes(Rn.y))},fromBytes(Gr){const Xr=Gr.length,Sn=Gr[0],Rn=Gr.subarray(1);if(Xr===kr&&(Sn===2||Sn===3)){const Pn=bytesToNumberBE$1(Rn);if(!inRange$2(Pn,_1n$8,wr.ORDER))throw new Error("Point is not on curve");const On=Vr(Pn);let Zn;try{Zn=wr.sqrt(On)}catch(zn){const fo=zn instanceof Error?": "+zn.message:"";throw new Error("Point is not on curve"+fo)}const Nn=(Zn&_1n$8)===_1n$8;return(Sn&1)===1!==Nn&&(Zn=wr.neg(Zn)),{x:Pn,y:Zn}}else if(Xr===jr&&Sn===4){const Pn=wr.fromBytes(Rn.subarray(0,wr.BYTES)),On=wr.fromBytes(Rn.subarray(wr.BYTES,2*wr.BYTES));return{x:Pn,y:On}}else throw new Error(`Point of length ${Xr} was invalid. Expected ${kr} compressed bytes or ${jr} uncompressed bytes`)}}),Jr=Gr=>bytesToHex$2(numberToBytesBE$1(Gr,br.nByteLength));function Qr(Gr){const Xr=Er>>_1n$8;return Gr>Xr}function _n(Gr){return Qr(Gr)?Br(-Gr):Gr}const En=(Gr,Xr,Sn)=>bytesToNumberBE$1(Gr.slice(Xr,Sn));class Cn{constructor(Xr,Sn,Rn){this.r=Xr,this.s=Sn,this.recovery=Rn,this.assertValidity()}static fromCompact(Xr){const Sn=br.nByteLength;return Xr=ensureBytes$1("compactSignature",Xr,Sn*2),new Cn(En(Xr,0,Sn),En(Xr,Sn,2*Sn))}static fromDER(Xr){const{r:Sn,s:Rn}=DER$1.toSig(ensureBytes$1("DER",Xr));return new Cn(Sn,Rn)}assertValidity(){aInRange$1("r",this.r,_1n$8,Er),aInRange$1("s",this.s,_1n$8,Er)}addRecoveryBit(Xr){return new Cn(this.r,this.s,Xr)}recoverPublicKey(Xr){const{r:Sn,s:Rn,recovery:Pn}=this,On=to(ensureBytes$1("msgHash",Xr));if(Pn==null||![0,1,2,3].includes(Pn))throw new Error("recovery id invalid");const Zn=Pn===2||Pn===3?Sn+br.n:Sn;if(Zn>=wr.ORDER)throw new Error("recovery id 2 or 3 invalid");const Nn=Pn&1?"03":"02",wn=qr.fromHex(Nn+Jr(Zn)),zn=Wr(Zn),fo=Br(-On*zn),vo=Br(Rn*zn),go=qr.BASE.multiplyAndAddUnsafe(wn,fo,vo);if(!go)throw new Error("point at infinify");return go.assertValidity(),go}hasHighS(){return Qr(this.s)}normalizeS(){return this.hasHighS()?new Cn(this.r,Br(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes$2(this.toDERHex())}toDERHex(){return DER$1.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes$2(this.toCompactHex())}toCompactHex(){return Jr(this.r)+Jr(this.s)}}const In={isValidPrivateKey(Gr){try{return Hr(Gr),!0}catch{return!1}},normPrivateKeyToScalar:Hr,randomPrivateKey:()=>{const Gr=getMinHashLength$1(br.n);return mapHashToField$1(br.randomBytes(Gr),br.n)},precompute(Gr=8,Xr=qr.BASE){return Xr._setWindowSize(Gr),Xr.multiply(BigInt(3)),Xr}};function An(Gr,Xr=!0){return qr.fromPrivateKey(Gr).toRawBytes(Xr)}function jn(Gr){const Xr=isBytes$7(Gr),Sn=typeof Gr=="string",Rn=(Xr||Sn)&&Gr.length;return Xr?Rn===kr||Rn===jr:Sn?Rn===2*kr||Rn===2*jr:Gr instanceof qr}function eo(Gr,Xr,Sn=!0){if(jn(Gr))throw new Error("first arg must be private key");if(!jn(Xr))throw new Error("second arg must be public key");return qr.fromHex(Xr).multiply(Hr(Gr)).toRawBytes(Sn)}const ro=br.bits2int||function(Gr){const Xr=bytesToNumberBE$1(Gr),Sn=Gr.length*8-br.nBitLength;return Sn>0?Xr>>BigInt(Sn):Xr},to=br.bits2int_modN||function(Gr){return Br(ro(Gr))},_i=bitMask$1(br.nBitLength);function oo(Gr){return aInRange$1(`num < 2^${br.nBitLength}`,Gr,_0n$5,_i),numberToBytesBE$1(Gr,br.nByteLength)}function io(Gr,Xr,Sn=co){if(["recovered","canonical"].some(lo=>lo in Sn))throw new Error("sign() legacy options not supported");const{hash:Rn,randomBytes:Pn}=br;let{lowS:On,prehash:Zn,extraEntropy:Nn}=Sn;On==null&&(On=!0),Gr=ensureBytes$1("msgHash",Gr),validateSigVerOpts$1(Sn),Zn&&(Gr=ensureBytes$1("prehashed msgHash",Rn(Gr)));const wn=to(Gr),zn=Hr(Xr),fo=[oo(zn),oo(wn)];if(Nn!=null&&Nn!==!1){const lo=Nn===!0?Pn(wr.BYTES):Nn;fo.push(ensureBytes$1("extraEntropy",lo))}const vo=concatBytes$3(...fo),go=wn;function uo(lo){const Eo=ro(lo);if(!Zr(Eo))return;const mo=Wr(Eo),yo=qr.BASE.multiply(Eo).toAffine(),_o=Br(yo.x);if(_o===_0n$5)return;const Bo=Br(mo*Br(go+_o*zn));if(Bo===_0n$5)return;let Lo=(yo.x===_o?0:2)|Number(yo.y&_1n$8),Wo=Bo;return On&&Qr(Bo)&&(Wo=_n(Bo),Lo^=1),new Cn(_o,Wo,Lo)}return{seed:vo,k2sig:uo}}const co={lowS:br.lowS,prehash:!1},so={lowS:br.lowS,prehash:!1};function no(Gr,Xr,Sn=co){const{seed:Rn,k2sig:Pn}=io(Gr,Xr,Sn),On=br;return createHmacDrbg$1(On.hash.outputLen,On.nByteLength,On.hmac)(Rn,Pn)}qr.BASE._setWindowSize(8);function Tn(Gr,Xr,Sn,Rn=so){var yo;const Pn=Gr;if(Xr=ensureBytes$1("msgHash",Xr),Sn=ensureBytes$1("publicKey",Sn),"strict"in Rn)throw new Error("options.strict was renamed to lowS");validateSigVerOpts$1(Rn);const{lowS:On,prehash:Zn}=Rn;let Nn,wn;try{if(typeof Pn=="string"||isBytes$7(Pn))try{Nn=Cn.fromDER(Pn)}catch(_o){if(!(_o instanceof DER$1.Err))throw _o;Nn=Cn.fromCompact(Pn)}else if(typeof Pn=="object"&&typeof Pn.r=="bigint"&&typeof Pn.s=="bigint"){const{r:_o,s:Bo}=Pn;Nn=new Cn(_o,Bo)}else throw new Error("PARSE");wn=qr.fromHex(Sn)}catch(_o){if(_o.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(On&&Nn.hasHighS())return!1;Zn&&(Xr=br.hash(Xr));const{r:zn,s:fo}=Nn,vo=to(Xr),go=Wr(fo),uo=Br(vo*go),lo=Br(zn*go),Eo=(yo=qr.BASE.multiplyAndAddUnsafe(wn,uo,lo))==null?void 0:yo.toAffine();return Eo?Br(Eo.x)===zn:!1}return{CURVE:br,getPublicKey:An,getSharedSecret:eo,sign:no,verify:Tn,ProjectivePoint:qr,Signature:Cn,utils:In}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function getHash$1(fr){return{hash:fr,hmac:(br,...wr)=>hmac$5(fr,br,concatBytes$5(...wr)),randomBytes:randomBytes$2}}function createCurve$1(fr,br){const wr=Er=>weierstrass$1({...fr,...getHash$1(Er)});return Object.freeze({...wr(br),create:wr})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1P$1=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N$1=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n$7=BigInt(1),_2n$5=BigInt(2),divNearest$1=(fr,br)=>(fr+br/_2n$5)/br;function sqrtMod$1(fr){const br=secp256k1P$1,wr=BigInt(3),Er=BigInt(6),kr=BigInt(11),jr=BigInt(22),Br=BigInt(23),Wr=BigInt(44),qr=BigInt(88),Hr=fr*fr*fr%br,Vr=Hr*Hr*fr%br,Zr=pow2$1(Vr,wr,br)*Vr%br,Jr=pow2$1(Zr,wr,br)*Vr%br,Qr=pow2$1(Jr,_2n$5,br)*Hr%br,_n=pow2$1(Qr,kr,br)*Qr%br,En=pow2$1(_n,jr,br)*_n%br,Cn=pow2$1(En,Wr,br)*En%br,In=pow2$1(Cn,qr,br)*Cn%br,An=pow2$1(In,Wr,br)*En%br,jn=pow2$1(An,wr,br)*Vr%br,eo=pow2$1(jn,Br,br)*_n%br,ro=pow2$1(eo,Er,br)*Hr%br,to=pow2$1(ro,_2n$5,br);if(!Fp$1.eql(Fp$1.sqr(to),fr))throw new Error("Cannot find square root");return to}const Fp$1=Field$1(secp256k1P$1,void 0,void 0,{sqrt:sqrtMod$1}),secp256k1$2=createCurve$1({a:BigInt(0),b:BigInt(7),Fp:Fp$1,n:secp256k1N$1,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:fr=>{const br=secp256k1N$1,wr=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),Er=-_1n$7*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),kr=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),jr=wr,Br=BigInt("0x100000000000000000000000000000000"),Wr=divNearest$1(jr*fr,br),qr=divNearest$1(-Er*fr,br);let Hr=mod$1(fr-Wr*wr-qr*kr,br),Vr=mod$1(-Wr*Er-qr*jr,br);const Zr=Hr>Br,Jr=Vr>Br;if(Zr&&(Hr=br-Hr),Jr&&(Vr=br-Vr),Hr>Br||Vr>Br)throw new Error("splitScalar: Endomorphism failed, k="+fr);return{k1neg:Zr,k1:Hr,k2neg:Jr,k2:Vr}}}},sha256$7);BigInt(0);secp256k1$2.ProjectivePoint;const secp256k1$3=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:secp256k1$2},Symbol.toStringTag,{value:"Module"}));function serializeSignature({r:fr,s:br,to:wr="hex",v:Er,yParity:kr}){const jr=(()=>{if(kr===0||kr===1)return kr;if(Er&&(Er===27n||Er===28n||Er>=35n))return Er%2n===0n?1:0;throw new Error("Invalid `v` or `yParity` value")})(),Br=`0x${new secp256k1$2.Signature(hexToBigInt(fr),hexToBigInt(br)).toCompactHex()}${jr===0?"1b":"1c"}`;return wr==="hex"?Br:hexToBytes$4(Br)}async function verifyHash(fr,br){var Zr,Jr,Qr;const{address:wr,factory:Er,factoryData:kr,hash:jr,signature:Br,universalSignatureVerifierAddress:Wr=(Qr=(Jr=(Zr=fr.chain)==null?void 0:Zr.contracts)==null?void 0:Jr.universalSignatureVerifier)==null?void 0:Qr.address,...qr}=br,Hr=isHex(Br)?Br:typeof Br=="object"&&"r"in Br&&"s"in Br?serializeSignature(Br):bytesToHex$4(Br),Vr=await(async()=>!Er&&!kr||isErc6492Signature(Hr)?Hr:serializeErc6492Signature({address:Er,data:kr,signature:Hr}))();try{const _n=Wr?{to:Wr,data:encodeFunctionData({abi:universalSignatureValidatorAbi,functionName:"isValidSig",args:[wr,jr,Vr]}),...qr}:{data:encodeDeployData({abi:universalSignatureValidatorAbi,args:[wr,jr,Vr],bytecode:universalSignatureValidatorByteCode}),...qr},{data:En}=await getAction(fr,call,"call")(_n);return hexToBool(En??"0x0")}catch(_n){try{if(isAddressEqual(getAddress(wr),await recoverAddress({hash:jr,signature:Br})))return!0}catch{}if(_n instanceof CallExecutionError)return!1;throw _n}}async function verifyMessage(fr,{address:br,message:wr,factory:Er,factoryData:kr,signature:jr,...Br}){const Wr=hashMessage(wr);return verifyHash(fr,{address:br,factory:Er,factoryData:kr,hash:Wr,signature:jr,...Br})}async function verifyTypedData(fr,br){const{address:wr,factory:Er,factoryData:kr,signature:jr,message:Br,primaryType:Wr,types:qr,domain:Hr,...Vr}=br,Zr=hashTypedData({message:Br,primaryType:Wr,types:qr,domain:Hr});return verifyHash(fr,{address:wr,factory:Er,factoryData:kr,hash:Zr,signature:jr,...Vr})}function watchBlockNumber(fr,{emitOnBegin:br=!1,emitMissed:wr=!1,onBlockNumber:Er,onError:kr,poll:jr,pollingInterval:Br=fr.pollingInterval}){const Wr=typeof jr<"u"?jr:!(fr.transport.type==="webSocket"||fr.transport.type==="fallback"&&fr.transport.transports[0].config.type==="webSocket");let qr;return Wr?(()=>{const Zr=stringify$4(["watchBlockNumber",fr.uid,br,wr,Br]);return observe(Zr,{onBlockNumber:Er,onError:kr},Jr=>poll(async()=>{var Qr;try{const _n=await getAction(fr,getBlockNumber,"getBlockNumber")({cacheTime:0});if(qr){if(_n===qr)return;if(_n-qr>1&&wr)for(let En=qr+1n;En<_n;En++)Jr.onBlockNumber(En,qr),qr=En}(!qr||_n>qr)&&(Jr.onBlockNumber(_n,qr),qr=_n)}catch(_n){(Qr=Jr.onError)==null||Qr.call(Jr,_n)}},{emitOnBegin:br,interval:Br}))})():(()=>{const Zr=stringify$4(["watchBlockNumber",fr.uid,br,wr]);return observe(Zr,{onBlockNumber:Er,onError:kr},Jr=>{let Qr=!0,_n=()=>Qr=!1;return(async()=>{try{const En=(()=>{if(fr.transport.type==="fallback"){const In=fr.transport.transports.find(An=>An.config.type==="webSocket");return In?In.value:fr.transport}return fr.transport})(),{unsubscribe:Cn}=await En.subscribe({params:["newHeads"],onData(In){var jn;if(!Qr)return;const An=hexToBigInt((jn=In.result)==null?void 0:jn.number);Jr.onBlockNumber(An,qr),qr=An},onError(In){var An;(An=Jr.onError)==null||An.call(Jr,In)}});_n=Cn,Qr||_n()}catch(En){kr==null||kr(En)}})(),()=>_n()})})()}async function waitForTransactionReceipt(fr,{confirmations:br=1,hash:wr,onReplaced:Er,pollingInterval:kr=fr.pollingInterval,retryCount:jr=6,retryDelay:Br=({count:qr})=>~~(1<En(new WaitForTransactionReceiptTimeoutError({hash:wr})),Wr):void 0,In=observe(qr,{onReplaced:Er,resolve:_n,reject:En},An=>{const jn=getAction(fr,watchBlockNumber,"watchBlockNumber")({emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:kr,async onBlockNumber(eo){const ro=_i=>{clearTimeout(Cn),jn(),_i(),In()};let to=eo;if(!Jr)try{if(Zr){if(br>1&&(!Zr.blockNumber||to-Zr.blockNumber+1nAn.resolve(Zr));return}if(Hr||(Jr=!0,await withRetry(async()=>{Hr=await getAction(fr,getTransaction,"getTransaction")({hash:wr}),Hr.blockNumber&&(to=Hr.blockNumber)},{delay:Br,retryCount:jr}),Jr=!1),Zr=await getAction(fr,getTransactionReceipt,"getTransactionReceipt")({hash:wr}),br>1&&(!Zr.blockNumber||to-Zr.blockNumber+1nAn.resolve(Zr))}catch(_i){if(_i instanceof TransactionNotFoundError||_i instanceof TransactionReceiptNotFoundError){if(!Hr){Jr=!1;return}try{Vr=Hr,Jr=!0;const oo=await withRetry(()=>getAction(fr,getBlock,"getBlock")({blockNumber:to,includeTransactions:!0}),{delay:Br,retryCount:jr,shouldRetry:({error:so})=>so instanceof BlockNotFoundError});Jr=!1;const io=oo.transactions.find(({from:so,nonce:no})=>so===Vr.from&&no===Vr.nonce);if(!io||(Zr=await getAction(fr,getTransactionReceipt,"getTransactionReceipt")({hash:io.hash}),br>1&&(!Zr.blockNumber||to-Zr.blockNumber+1n{var so;(so=An.onReplaced)==null||so.call(An,{reason:co,replacedTransaction:Vr,transaction:io,transactionReceipt:Zr}),An.resolve(Zr)})}catch(oo){ro(()=>An.reject(oo))}}else ro(()=>An.reject(_i))}}})});return Qr}function watchBlocks(fr,{blockTag:br="latest",emitMissed:wr=!1,emitOnBegin:Er=!1,onBlock:kr,onError:jr,includeTransactions:Br,poll:Wr,pollingInterval:qr=fr.pollingInterval}){const Hr=typeof Wr<"u"?Wr:!(fr.transport.type==="webSocket"||fr.transport.type==="fallback"&&fr.transport.transports[0].config.type==="webSocket"),Vr=Br??!1;let Zr;return Hr?(()=>{const _n=stringify$4(["watchBlocks",fr.uid,br,wr,Er,Vr,qr]);return observe(_n,{onBlock:kr,onError:jr},En=>poll(async()=>{var Cn;try{const In=await getAction(fr,getBlock,"getBlock")({blockTag:br,includeTransactions:Vr});if(In.number&&(Zr!=null&&Zr.number)){if(In.number===Zr.number)return;if(In.number-Zr.number>1&&wr)for(let An=(Zr==null?void 0:Zr.number)+1n;AnZr.number)&&(En.onBlock(In,Zr),Zr=In)}catch(In){(Cn=En.onError)==null||Cn.call(En,In)}},{emitOnBegin:Er,interval:qr}))})():(()=>{let _n=!0,En=!0,Cn=()=>_n=!1;return(async()=>{try{Er&&getAction(fr,getBlock,"getBlock")({blockTag:br,includeTransactions:Vr}).then(jn=>{_n&&En&&(kr(jn,void 0),En=!1)});const In=(()=>{if(fr.transport.type==="fallback"){const jn=fr.transport.transports.find(eo=>eo.config.type==="webSocket");return jn?jn.value:fr.transport}return fr.transport})(),{unsubscribe:An}=await In.subscribe({params:["newHeads"],async onData(jn){if(!_n)return;const eo=await getAction(fr,getBlock,"getBlock")({blockNumber:jn.blockNumber,includeTransactions:Vr}).catch(()=>{});_n&&(kr(eo,Zr),En=!1,Zr=eo)},onError(jn){jr==null||jr(jn)}});Cn=An,_n||Cn()}catch(In){jr==null||jr(In)}})(),()=>Cn()})()}function watchEvent(fr,{address:br,args:wr,batch:Er=!0,event:kr,events:jr,fromBlock:Br,onError:Wr,onLogs:qr,poll:Hr,pollingInterval:Vr=fr.pollingInterval,strict:Zr}){const Jr=typeof Hr<"u"?Hr:typeof Br=="bigint"?!0:!(fr.transport.type==="webSocket"||fr.transport.type==="fallback"&&fr.transport.transports[0].config.type==="webSocket"),Qr=Zr??!1;return Jr?(()=>{const Cn=stringify$4(["watchEvent",br,wr,Er,fr.uid,kr,Vr,Br]);return observe(Cn,{onLogs:qr,onError:Wr},In=>{let An;Br!==void 0&&(An=Br-1n);let jn,eo=!1;const ro=poll(async()=>{var to;if(!eo){try{jn=await getAction(fr,createEventFilter,"createEventFilter")({address:br,args:wr,event:kr,events:jr,strict:Qr,fromBlock:Br})}catch{}eo=!0;return}try{let _i;if(jn)_i=await getAction(fr,getFilterChanges,"getFilterChanges")({filter:jn});else{const oo=await getAction(fr,getBlockNumber,"getBlockNumber")({});An&&An!==oo?_i=await getAction(fr,getLogs,"getLogs")({address:br,args:wr,event:kr,events:jr,fromBlock:An+1n,toBlock:oo}):_i=[],An=oo}if(_i.length===0)return;if(Er)In.onLogs(_i);else for(const oo of _i)In.onLogs([oo])}catch(_i){jn&&_i instanceof InvalidInputRpcError&&(eo=!1),(to=In.onError)==null||to.call(In,_i)}},{emitOnBegin:!0,interval:Vr});return async()=>{jn&&await getAction(fr,uninstallFilter,"uninstallFilter")({filter:jn}),ro()}})})():(()=>{let Cn=!0,In=()=>Cn=!1;return(async()=>{try{const An=(()=>{if(fr.transport.type==="fallback"){const to=fr.transport.transports.find(_i=>_i.config.type==="webSocket");return to?to.value:fr.transport}return fr.transport})(),jn=jr??(kr?[kr]:void 0);let eo=[];jn&&(eo=[jn.flatMap(_i=>encodeEventTopics({abi:[_i],eventName:_i.name,args:wr}))],kr&&(eo=eo[0]));const{unsubscribe:ro}=await An.subscribe({params:["logs",{address:br,topics:eo}],onData(to){var oo;if(!Cn)return;const _i=to.result;try{const{eventName:io,args:co}=decodeEventLog({abi:jn??[],data:_i.data,topics:_i.topics,strict:Qr}),so=formatLog(_i,{args:co,eventName:io});qr([so])}catch(io){let co,so;if(io instanceof DecodeLogDataMismatch||io instanceof DecodeLogTopicsMismatch){if(Zr)return;co=io.abiItem.name,so=(oo=io.abiItem.inputs)==null?void 0:oo.some(Tn=>!("name"in Tn&&Tn.name))}const no=formatLog(_i,{args:so?[]:{},eventName:co});qr([no])}},onError(to){Wr==null||Wr(to)}});In=ro,Cn||In()}catch(An){Wr==null||Wr(An)}})(),()=>In()})()}function watchPendingTransactions(fr,{batch:br=!0,onError:wr,onTransactions:Er,poll:kr,pollingInterval:jr=fr.pollingInterval}){return(typeof kr<"u"?kr:fr.transport.type!=="webSocket")?(()=>{const Hr=stringify$4(["watchPendingTransactions",fr.uid,br,jr]);return observe(Hr,{onTransactions:Er,onError:wr},Vr=>{let Zr;const Jr=poll(async()=>{var Qr;try{if(!Zr)try{Zr=await getAction(fr,createPendingTransactionFilter,"createPendingTransactionFilter")({});return}catch(En){throw Jr(),En}const _n=await getAction(fr,getFilterChanges,"getFilterChanges")({filter:Zr});if(_n.length===0)return;if(br)Vr.onTransactions(_n);else for(const En of _n)Vr.onTransactions([En])}catch(_n){(Qr=Vr.onError)==null||Qr.call(Vr,_n)}},{emitOnBegin:!0,interval:jr});return async()=>{Zr&&await getAction(fr,uninstallFilter,"uninstallFilter")({filter:Zr}),Jr()}})})():(()=>{let Hr=!0,Vr=()=>Hr=!1;return(async()=>{try{const{unsubscribe:Zr}=await fr.transport.subscribe({params:["newPendingTransactions"],onData(Jr){if(!Hr)return;const Qr=Jr.result;Er([Qr])},onError(Jr){wr==null||wr(Jr)}});Vr=Zr,Hr||Vr()}catch(Zr){wr==null||wr(Zr)}})(),()=>Vr()})()}function parseSiweMessage(fr){var Zr,Jr,Qr;const{scheme:br,statement:wr,...Er}=((Zr=fr.match(prefixRegex))==null?void 0:Zr.groups)??{},{chainId:kr,expirationTime:jr,issuedAt:Br,notBefore:Wr,requestId:qr,...Hr}=((Jr=fr.match(suffixRegex))==null?void 0:Jr.groups)??{},Vr=(Qr=fr.split("Resources:")[1])==null?void 0:Qr.split(` - `).slice(1);return{...Er,...Hr,...kr?{chainId:Number(kr)}:{},...jr?{expirationTime:new Date(jr)}:{},...Br?{issuedAt:new Date(Br)}:{},...Wr?{notBefore:new Date(Wr)}:{},...qr?{requestId:qr}:{},...Vr?{resources:Vr}:{},...br?{scheme:br}:{},...wr?{statement:wr}:{}}}const prefixRegex=/^(?:(?[a-zA-Z][a-zA-Z0-9+-.]*):\/\/)?(?[a-zA-Z0-9+-.]*(?::[0-9]{1,5})?) (?:wants you to sign in with your Ethereum account:\n)(?
0x[a-fA-F0-9]{40})\n\n(?:(?.*)\n\n)?/,suffixRegex=/(?:URI: (?.+))\n(?:Version: (?.+))\n(?:Chain ID: (?\d+))\n(?:Nonce: (?[a-zA-Z0-9]+))\n(?:Issued At: (?.+))(?:\nExpiration Time: (?.+))?(?:\nNot Before: (?.+))?(?:\nRequest ID: (?.+))?/;function validateSiweMessage(fr){const{address:br,domain:wr,message:Er,nonce:kr,scheme:jr,time:Br=new Date}=fr;if(wr&&Er.domain!==wr||kr&&Er.nonce!==kr||jr&&Er.scheme!==jr||Er.expirationTime&&Br>=Er.expirationTime||Er.notBefore&&Brcall(fr,br),createBlockFilter:()=>createBlockFilter(fr),createContractEventFilter:br=>createContractEventFilter(fr,br),createEventFilter:br=>createEventFilter(fr,br),createPendingTransactionFilter:()=>createPendingTransactionFilter(fr),estimateContractGas:br=>estimateContractGas(fr,br),estimateGas:br=>estimateGas$1(fr,br),getBalance:br=>getBalance(fr,br),getBlobBaseFee:()=>getBlobBaseFee(fr),getBlock:br=>getBlock(fr,br),getBlockNumber:br=>getBlockNumber(fr,br),getBlockTransactionCount:br=>getBlockTransactionCount(fr,br),getBytecode:br=>getCode(fr,br),getChainId:()=>getChainId(fr),getCode:br=>getCode(fr,br),getContractEvents:br=>getContractEvents(fr,br),getEip712Domain:br=>getEip712Domain$1(fr,br),getEnsAddress:br=>getEnsAddress(fr,br),getEnsAvatar:br=>getEnsAvatar(fr,br),getEnsName:br=>getEnsName(fr,br),getEnsResolver:br=>getEnsResolver(fr,br),getEnsText:br=>getEnsText(fr,br),getFeeHistory:br=>getFeeHistory(fr,br),estimateFeesPerGas:br=>estimateFeesPerGas$1(fr,br),getFilterChanges:br=>getFilterChanges(fr,br),getFilterLogs:br=>getFilterLogs(fr,br),getGasPrice:()=>getGasPrice(fr),getLogs:br=>getLogs(fr,br),getProof:br=>getProof(fr,br),estimateMaxPriorityFeePerGas:br=>estimateMaxPriorityFeePerGas(fr,br),getStorageAt:br=>getStorageAt(fr,br),getTransaction:br=>getTransaction(fr,br),getTransactionConfirmations:br=>getTransactionConfirmations(fr,br),getTransactionCount:br=>getTransactionCount(fr,br),getTransactionReceipt:br=>getTransactionReceipt(fr,br),multicall:br=>multicall(fr,br),prepareTransactionRequest:br=>prepareTransactionRequest(fr,br),readContract:br=>readContract(fr,br),sendRawTransaction:br=>sendRawTransaction(fr,br),simulateContract:br=>simulateContract(fr,br),verifyMessage:br=>verifyMessage(fr,br),verifySiweMessage:br=>verifySiweMessage(fr,br),verifyTypedData:br=>verifyTypedData(fr,br),uninstallFilter:br=>uninstallFilter(fr,br),waitForTransactionReceipt:br=>waitForTransactionReceipt(fr,br),watchBlocks:br=>watchBlocks(fr,br),watchBlockNumber:br=>watchBlockNumber(fr,br),watchContractEvent:br=>watchContractEvent(fr,br),watchEvent:br=>watchEvent(fr,br),watchPendingTransactions:br=>watchPendingTransactions(fr,br)}}function createPublicClient(fr){const{key:br="public",name:wr="Public Client"}=fr;return createClient({...fr,key:br,name:wr,type:"publicClient"}).extend(publicActions)}async function dropTransaction(fr,{hash:br}){await fr.request({method:`${fr.mode}_dropTransaction`,params:[br]})}async function dumpState(fr){return fr.request({method:`${fr.mode}_dumpState`})}async function getAutomine(fr){return fr.mode==="ganache"?await fr.request({method:"eth_mining"}):await fr.request({method:`${fr.mode}_getAutomine`})}async function getTxpoolContent(fr){return await fr.request({method:"txpool_content"})}async function getTxpoolStatus(fr){const{pending:br,queued:wr}=await fr.request({method:"txpool_status"});return{pending:hexToNumber$2(br),queued:hexToNumber$2(wr)}}async function impersonateAccount(fr,{address:br}){await fr.request({method:`${fr.mode}_impersonateAccount`,params:[br]})}async function increaseTime(fr,{seconds:br}){return await fr.request({method:"evm_increaseTime",params:[numberToHex(br)]})}async function inspectTxpool(fr){return await fr.request({method:"txpool_inspect"})}async function loadState(fr,{state:br}){await fr.request({method:`${fr.mode}_loadState`,params:[br]})}async function mine(fr,{blocks:br,interval:wr}){fr.mode==="ganache"?await fr.request({method:"evm_mine",params:[{blocks:numberToHex(br)}]}):await fr.request({method:`${fr.mode}_mine`,params:[numberToHex(br),numberToHex(wr||0)]})}async function removeBlockTimestampInterval(fr){await fr.request({method:`${fr.mode}_removeBlockTimestampInterval`})}async function reset(fr,{blockNumber:br,jsonRpcUrl:wr}={}){await fr.request({method:`${fr.mode}_reset`,params:[{forking:{blockNumber:Number(br),jsonRpcUrl:wr}}]})}async function revert(fr,{id:br}){await fr.request({method:"evm_revert",params:[br]})}async function sendUnsignedTransaction(fr,br){var In,An,jn;const{accessList:wr,data:Er,from:kr,gas:jr,gasPrice:Br,maxFeePerGas:Wr,maxPriorityFeePerGas:qr,nonce:Hr,to:Vr,value:Zr,...Jr}=br,Qr=(jn=(An=(In=fr.chain)==null?void 0:In.formatters)==null?void 0:An.transactionRequest)==null?void 0:jn.format,En=(Qr||formatTransactionRequest)({...extract(Jr,{format:Qr}),accessList:wr,data:Er,from:kr,gas:jr,gasPrice:Br,maxFeePerGas:Wr,maxPriorityFeePerGas:qr,nonce:Hr,to:Vr,value:Zr});return await fr.request({method:"eth_sendUnsignedTransaction",params:[En]})}async function setAutomine(fr,br){fr.mode==="ganache"?br?await fr.request({method:"miner_start"}):await fr.request({method:"miner_stop"}):await fr.request({method:"evm_setAutomine",params:[br]})}async function setBalance(fr,{address:br,value:wr}){fr.mode==="ganache"?await fr.request({method:"evm_setAccountBalance",params:[br,numberToHex(wr)]}):await fr.request({method:`${fr.mode}_setBalance`,params:[br,numberToHex(wr)]})}async function setBlockGasLimit(fr,{gasLimit:br}){await fr.request({method:"evm_setBlockGasLimit",params:[numberToHex(br)]})}async function setBlockTimestampInterval(fr,{interval:br}){const wr=fr.mode==="hardhat"?br*1e3:br;await fr.request({method:`${fr.mode}_setBlockTimestampInterval`,params:[wr]})}async function setCode(fr,{address:br,bytecode:wr}){fr.mode==="ganache"?await fr.request({method:"evm_setAccountCode",params:[br,wr]}):await fr.request({method:`${fr.mode}_setCode`,params:[br,wr]})}async function setCoinbase(fr,{address:br}){await fr.request({method:`${fr.mode}_setCoinbase`,params:[br]})}async function setIntervalMining(fr,{interval:br}){const wr=fr.mode==="hardhat"?br*1e3:br;await fr.request({method:"evm_setIntervalMining",params:[wr]})}async function setLoggingEnabled(fr,br){await fr.request({method:`${fr.mode}_setLoggingEnabled`,params:[br]})}async function setMinGasPrice(fr,{gasPrice:br}){await fr.request({method:`${fr.mode}_setMinGasPrice`,params:[numberToHex(br)]})}async function setNextBlockBaseFeePerGas(fr,{baseFeePerGas:br}){await fr.request({method:`${fr.mode}_setNextBlockBaseFeePerGas`,params:[numberToHex(br)]})}async function setNextBlockTimestamp(fr,{timestamp:br}){await fr.request({method:"evm_setNextBlockTimestamp",params:[numberToHex(br)]})}async function setNonce(fr,{address:br,nonce:wr}){await fr.request({method:`${fr.mode}_setNonce`,params:[br,numberToHex(wr)]})}async function setRpcUrl(fr,br){await fr.request({method:`${fr.mode}_setRpcUrl`,params:[br]})}async function setStorageAt(fr,{address:br,index:wr,value:Er}){await fr.request({method:`${fr.mode}_setStorageAt`,params:[br,typeof wr=="number"?numberToHex(wr):wr,Er]})}async function snapshot(fr){return await fr.request({method:"evm_snapshot"})}async function stopImpersonatingAccount(fr,{address:br}){await fr.request({method:`${fr.mode}_stopImpersonatingAccount`,params:[br]})}function testActions({mode:fr}){return br=>{const wr=br.extend(()=>({mode:fr}));return{dropTransaction:Er=>dropTransaction(wr,Er),dumpState:()=>dumpState(wr),getAutomine:()=>getAutomine(wr),getTxpoolContent:()=>getTxpoolContent(wr),getTxpoolStatus:()=>getTxpoolStatus(wr),impersonateAccount:Er=>impersonateAccount(wr,Er),increaseTime:Er=>increaseTime(wr,Er),inspectTxpool:()=>inspectTxpool(wr),loadState:Er=>loadState(wr,Er),mine:Er=>mine(wr,Er),removeBlockTimestampInterval:()=>removeBlockTimestampInterval(wr),reset:Er=>reset(wr,Er),revert:Er=>revert(wr,Er),sendUnsignedTransaction:Er=>sendUnsignedTransaction(wr,Er),setAutomine:Er=>setAutomine(wr,Er),setBalance:Er=>setBalance(wr,Er),setBlockGasLimit:Er=>setBlockGasLimit(wr,Er),setBlockTimestampInterval:Er=>setBlockTimestampInterval(wr,Er),setCode:Er=>setCode(wr,Er),setCoinbase:Er=>setCoinbase(wr,Er),setIntervalMining:Er=>setIntervalMining(wr,Er),setLoggingEnabled:Er=>setLoggingEnabled(wr,Er),setMinGasPrice:Er=>setMinGasPrice(wr,Er),setNextBlockBaseFeePerGas:Er=>setNextBlockBaseFeePerGas(wr,Er),setNextBlockTimestamp:Er=>setNextBlockTimestamp(wr,Er),setNonce:Er=>setNonce(wr,Er),setRpcUrl:Er=>setRpcUrl(wr,Er),setStorageAt:Er=>setStorageAt(wr,Er),snapshot:()=>snapshot(wr),stopImpersonatingAccount:Er=>stopImpersonatingAccount(wr,Er)}}}function createTestClient(fr){const{key:br="test",name:wr="Test Client",mode:Er}=fr;return createClient({...fr,key:br,name:wr,type:"testClient"}).extend(jr=>({mode:Er,...testActions({mode:Er})(jr)}))}function deployContract(fr,br){const{abi:wr,args:Er,bytecode:kr,...jr}=br,Br=encodeDeployData({abi:wr,args:Er,bytecode:kr});return sendTransaction(fr,{...jr,data:Br})}async function getAddresses(fr){var wr;return((wr=fr.account)==null?void 0:wr.type)==="local"?[fr.account.address]:(await fr.request({method:"eth_accounts"},{dedupe:!0})).map(Er=>checksumAddress(Er))}async function getPermissions(fr){return await fr.request({method:"wallet_getPermissions"},{dedupe:!0})}async function requestAddresses(fr){return(await fr.request({method:"eth_requestAccounts"},{dedupe:!0,retryCount:0})).map(wr=>getAddress(wr))}async function requestPermissions(fr,br){return fr.request({method:"wallet_requestPermissions",params:[br]},{retryCount:0})}async function signMessage$2(fr,{account:br=fr.account,message:wr}){if(!br)throw new AccountNotFoundError({docsPath:"/docs/actions/wallet/signMessage"});const Er=parseAccount(br);if(Er.signMessage)return Er.signMessage({message:wr});const kr=typeof wr=="string"?stringToHex(wr):wr.raw instanceof Uint8Array?toHex(wr.raw):wr.raw;return fr.request({method:"personal_sign",params:[kr,Er.address]},{retryCount:0})}async function signTransaction$2(fr,br){var Hr,Vr,Zr,Jr;const{account:wr=fr.account,chain:Er=fr.chain,...kr}=br;if(!wr)throw new AccountNotFoundError({docsPath:"/docs/actions/wallet/signTransaction"});const jr=parseAccount(wr);assertRequest({account:jr,...br});const Br=await getAction(fr,getChainId,"getChainId")({});Er!==null&&assertCurrentChain({currentChainId:Br,chain:Er});const Wr=(Er==null?void 0:Er.formatters)||((Hr=fr.chain)==null?void 0:Hr.formatters),qr=((Vr=Wr==null?void 0:Wr.transactionRequest)==null?void 0:Vr.format)||formatTransactionRequest;return jr.signTransaction?jr.signTransaction({...kr,chainId:Br},{serializer:(Jr=(Zr=fr.chain)==null?void 0:Zr.serializers)==null?void 0:Jr.transaction}):await fr.request({method:"eth_signTransaction",params:[{...qr(kr),chainId:numberToHex(Br),from:jr.address}]},{retryCount:0})}async function signTypedData$2(fr,br){const{account:wr=fr.account,domain:Er,message:kr,primaryType:jr}=br;if(!wr)throw new AccountNotFoundError({docsPath:"/docs/actions/wallet/signTypedData"});const Br=parseAccount(wr),Wr={EIP712Domain:getTypesForEIP712Domain({domain:Er}),...br.types};if(validateTypedData({domain:Er,message:kr,primaryType:jr,types:Wr}),Br.signTypedData)return Br.signTypedData({domain:Er,message:kr,primaryType:jr,types:Wr});const qr=serializeTypedData({domain:Er,message:kr,primaryType:jr,types:Wr});return fr.request({method:"eth_signTypedData_v4",params:[Br.address,qr]},{retryCount:0})}async function switchChain(fr,{id:br}){await fr.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(br)}]},{retryCount:0})}async function watchAsset(fr,br){return await fr.request({method:"wallet_watchAsset",params:br},{retryCount:0})}function walletActions(fr){return{addChain:br=>addChain(fr,br),deployContract:br=>deployContract(fr,br),getAddresses:()=>getAddresses(fr),getChainId:()=>getChainId(fr),getPermissions:()=>getPermissions(fr),prepareTransactionRequest:br=>prepareTransactionRequest(fr,br),requestAddresses:()=>requestAddresses(fr),requestPermissions:br=>requestPermissions(fr,br),sendRawTransaction:br=>sendRawTransaction(fr,br),sendTransaction:br=>sendTransaction(fr,br),signMessage:br=>signMessage$2(fr,br),signTransaction:br=>signTransaction$2(fr,br),signTypedData:br=>signTypedData$2(fr,br),switchChain:br=>switchChain(fr,br),watchAsset:br=>watchAsset(fr,br),writeContract:br=>writeContract(fr,br)}}function createWalletClient(fr){const{key:br="wallet",name:wr="Wallet Client",transport:Er}=fr;return createClient({...fr,key:br,name:wr,transport:Er,type:"walletClient"}).extend(walletActions)}function webSocket(fr,br={}){const{keepAlive:wr,key:Er="webSocket",name:kr="WebSocket JSON-RPC",reconnect:jr,retryDelay:Br}=br;return({chain:Wr,retryCount:qr,timeout:Hr})=>{var Qr;const Vr=br.retryCount??qr,Zr=Hr??br.timeout??1e4,Jr=fr||((Qr=Wr==null?void 0:Wr.rpcUrls.default.webSocket)==null?void 0:Qr[0]);if(!Jr)throw new UrlRequiredError;return createTransport({key:Er,name:kr,async request({method:_n,params:En}){const Cn={method:_n,params:En},In=await getWebSocketRpcClient(Jr,{keepAlive:wr,reconnect:jr}),{error:An,result:jn}=await In.requestAsync({body:Cn,timeout:Zr});if(An)throw new RpcRequestError({body:Cn,error:An,url:Jr});return jn},retryCount:Vr,retryDelay:Br,timeout:Zr,type:"webSocket"},{getSocket(){return getSocket(Jr)},getRpcClient(){return getWebSocketRpcClient(Jr)},async subscribe({params:_n,onData:En,onError:Cn}){const In=await getWebSocketRpcClient(Jr),{result:An}=await new Promise((jn,eo)=>In.request({body:{method:"eth_subscribe",params:_n},onError(ro){eo(ro),Cn==null||Cn(ro)},onResponse(ro){if(ro.error){eo(ro.error),Cn==null||Cn(ro.error);return}if(typeof ro.id=="number"){jn(ro);return}ro.method==="eth_subscription"&&En(ro.params)}}));return{subscriptionId:An,async unsubscribe(){return new Promise(jn=>In.request({body:{method:"eth_unsubscribe",params:[An]},onResponse:jn}))}}}})}}const zeroAddress="0x0000000000000000000000000000000000000000";class ProviderRpcError extends Error{constructor(br,wr){super(wr),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=br,this.details=wr}}const docsPath="/docs/contract/decodeDeployData";function decodeDeployData(fr){const{abi:br,bytecode:wr,data:Er}=fr;if(Er===wr)return{bytecode:wr};const kr=br.find(Br=>"type"in Br&&Br.type==="constructor");if(!kr)throw new AbiConstructorNotFoundError({docsPath});if(!("inputs"in kr))throw new AbiConstructorParamsNotFoundError({docsPath});if(!kr.inputs||kr.inputs.length===0)throw new AbiConstructorParamsNotFoundError({docsPath});return{args:decodeAbiParameters(kr.inputs,`0x${Er.replace(wr,"")}`),bytecode:wr}}function compactSignatureToSignature({r:fr,yParityAndS:br}){const wr=hexToBytes$4(br),Er=wr[0]&128?1:0,kr=wr;return Er===1&&(kr[0]&=127),{r:fr,s:bytesToHex$4(kr),yParity:Er}}function parseCompactSignature(fr){const{r:br,s:wr}=secp256k1$2.Signature.fromCompact(fr.slice(2,130));return{r:numberToHex(br,{size:32}),yParityAndS:numberToHex(wr,{size:32})}}function parseSignature(fr){const{r:br,s:wr}=secp256k1$2.Signature.fromCompact(fr.slice(2,130)),Er=+`0x${fr.slice(130)}`,[kr,jr]=(()=>{if(Er===0||Er===1)return[void 0,Er];if(Er===27)return[BigInt(Er),0];if(Er===28)return[BigInt(Er),1];throw new Error("Invalid yParityOrV value")})();return typeof kr<"u"?{r:numberToHex(br,{size:32}),s:numberToHex(wr,{size:32}),v:kr,yParity:jr}:{r:numberToHex(br,{size:32}),s:numberToHex(wr,{size:32}),yParity:jr}}async function recoverTransactionAddress(fr){const{serializedTransaction:br,signature:wr}=fr,Er=parseTransaction(br),kr=wr??{r:Er.r,s:Er.s,v:Er.v,yParity:Er.yParity},jr=serializeTransaction$4({...Er,r:void 0,s:void 0,v:void 0,yParity:void 0,sidecars:void 0});return await recoverAddress({hash:keccak256(jr),signature:kr})}function signatureToCompactSignature(fr){const{r:br,s:wr,v:Er,yParity:kr}=fr,jr=Number(kr??Er-27n);let Br=wr;if(jr===1){const Wr=hexToBytes$4(wr);Wr[0]|=128,Br=bytesToHex$4(Wr)}return{r:br,yParityAndS:Br}}function serializeCompactSignature({r:fr,yParityAndS:br}){return`0x${new secp256k1$2.Signature(hexToBigInt(fr),hexToBigInt(br)).toCompactHex()}`}function sidecarsToVersionedHashes(fr){const{sidecars:br,version:wr}=fr,Er=fr.to??(typeof br[0].blob=="string"?"hex":"bytes"),kr=[];for(const{commitment:jr}of br)kr.push(commitmentToVersionedHash({commitment:jr,to:Er,version:wr}));return kr}function fromBlobs(fr){const br=fr.to??(typeof fr.blobs[0]=="string"?"hex":"bytes"),wr=typeof fr.blobs[0]=="string"?fr.blobs.map(Wr=>hexToBytes$4(Wr)):fr.blobs,Er=wr.reduce((Wr,qr)=>Wr+qr.length,0),kr=createCursor(new Uint8Array(Er));let jr=!0;for(const Wr of wr){const qr=createCursor(Wr);for(;jr&&qr.position{var jr;if(typeof Er=="string")return Er;const kr=(jr=formatters$2.transaction)==null?void 0:jr.format(Er);return kr.typeHex==="0x71"?kr.type="eip712":kr.typeHex==="0xff"&&(kr.type="priority"),kr});return{l1BatchNumber:fr.l1BatchNumber?hexToBigInt(fr.l1BatchNumber):null,l1BatchTimestamp:fr.l1BatchTimestamp?hexToBigInt(fr.l1BatchTimestamp):null,transactions:br}}}),transaction:defineTransaction({format(fr){const br={};return fr.type==="0x71"?br.type="eip712":fr.type==="0xff"&&(br.type="priority"),{...br,l1BatchNumber:fr.l1BatchNumber?hexToBigInt(fr.l1BatchNumber):null,l1BatchTxIndex:fr.l1BatchTxIndex?hexToBigInt(fr.l1BatchTxIndex):null}}}),transactionReceipt:defineTransactionReceipt({format(fr){return{l1BatchNumber:fr.l1BatchNumber?hexToBigInt(fr.l1BatchNumber):null,l1BatchTxIndex:fr.l1BatchTxIndex?hexToBigInt(fr.l1BatchTxIndex):null,logs:fr.logs.map(br=>({...formatLog(br),l1BatchNumber:br.l1BatchNumber?hexToBigInt(br.l1BatchNumber):null,transactionLogIndex:hexToNumber$2(br.transactionLogIndex),logType:br.logType})),l2ToL1Logs:fr.l2ToL1Logs.map(br=>({blockNumber:hexToBigInt(br.blockHash),blockHash:br.blockHash,l1BatchNumber:br.l1BatchNumber?hexToBigInt(br.l1BatchNumber):null,transactionIndex:hexToBigInt(br.transactionIndex),shardId:hexToBigInt(br.shardId),isService:br.isService,sender:br.sender,key:br.key,value:br.value,transactionHash:br.transactionHash,logIndex:hexToBigInt(br.logIndex)}))}}}),transactionRequest:defineTransactionRequest({exclude:["customSignature","factoryDeps","gasPerPubdata","paymaster","paymasterInput"],format(fr){return fr.gasPerPubdata||fr.paymaster&&fr.paymasterInput||fr.factoryDeps||fr.customSignature?{eip712Meta:{...fr.gasPerPubdata?{gasPerPubdata:toHex(fr.gasPerPubdata)}:{gasPerPubdata:toHex(gasPerPubdataDefault)},...fr.paymaster&&fr.paymasterInput?{paymasterParams:{paymaster:fr.paymaster,paymasterInput:Array.from(hexToBytes$4(fr.paymasterInput))}}:{},...fr.factoryDeps?{factoryDeps:fr.factoryDeps.map(br=>Array.from(hexToBytes$4(br)))}:{},...fr.customSignature?{customSignature:Array.from(hexToBytes$4(fr.customSignature))}:{}},type:"0x71"}:{}}})};class InvalidEip712TransactionError extends BaseError{constructor(){super(["Transaction is not an EIP712 transaction.","","Transaction must:",' - include `type: "eip712"`'," - include one of the following: `customSignature`, `paymaster`, `paymasterInput`, `gasPerPubdata`, `factoryDeps`"].join(` `),{name:"InvalidEip712TransactionError"})}}function isEIP712Transaction(fr){return!!(fr.type==="eip712"||"customSignature"in fr&&fr.customSignature||"paymaster"in fr&&fr.paymaster||"paymasterInput"in fr&&fr.paymasterInput||"gasPerPubdata"in fr&&typeof fr.gasPerPubdata=="bigint"||"factoryDeps"in fr&&fr.factoryDeps)}function assertEip712Transaction(fr){const{chainId:br,to:wr,from:Er,paymaster:kr,paymasterInput:jr}=fr;if(!isEIP712Transaction(fr))throw new InvalidEip712TransactionError;if(!br||br<=0)throw new InvalidChainIdError({chainId:br});if(wr&&!isAddress(wr))throw new InvalidAddressError({address:wr});if(Er&&!isAddress(Er))throw new InvalidAddressError({address:Er});if(kr&&!isAddress(kr))throw new InvalidAddressError({address:kr});if(kr&&!jr)throw new BaseError("`paymasterInput` must be provided when `paymaster` is defined");if(!kr&&jr)throw new BaseError("`paymaster` must be provided when `paymasterInput` is defined")}function serializeTransaction$3(fr,br){return isEIP712Transaction(fr)?serializeTransactionEIP712(fr):serializeTransaction$4(fr,br)}const serializers$2={transaction:serializeTransaction$3};function serializeTransactionEIP712(fr){const{chainId:br,gas:wr,nonce:Er,to:kr,from:jr,value:Br,maxFeePerGas:Wr,maxPriorityFeePerGas:qr,customSignature:Hr,factoryDeps:Vr,paymaster:Zr,paymasterInput:Jr,gasPerPubdata:Qr,data:_n}=fr;assertEip712Transaction(fr);const En=[Er?toHex(Er):"0x",qr?toHex(qr):"0x",Wr?toHex(Wr):"0x",wr?toHex(wr):"0x",kr??"0x",Br?toHex(Br):"0x",_n??"0x0",toHex(br),toHex(""),toHex(""),toHex(br),jr??"0x",toHex(Qr||gasPerPubdataDefault),Vr??[],Hr??"0x",Zr&&Jr?[Zr,Jr]:[]];return concatHex(["0x71",toRlp(En)])}class BytecodeLengthExceedsMaxSizeError extends BaseError{constructor({givenLength:br,maxBytecodeSize:wr}){super(`Bytecode cannot be longer than ${wr} bytes. Given length: ${br}`,{name:"BytecodeLengthExceedsMaxSizeError"})}}class BytecodeLengthInWordsMustBeOddError extends BaseError{constructor({givenLengthInWords:br}){super(`Bytecode length in 32-byte words must be odd. Given length in words: ${br}`,{name:"BytecodeLengthInWordsMustBeOddError"})}}class BytecodeLengthMustBeDivisibleBy32Error extends BaseError{constructor({givenLength:br}){super(`The bytecode length in bytes must be divisible by 32. Given length: ${br}`,{name:"BytecodeLengthMustBeDivisibleBy32Error"})}}function hashBytecode(fr){const br=toBytes$3(fr);if(br.length%32!==0)throw new BytecodeLengthMustBeDivisibleBy32Error({givenLength:br.length});if(br.length>maxBytecodeSize)throw new BytecodeLengthExceedsMaxSizeError({givenLength:br.length,maxBytecodeSize});const wr=sha256$6(br),Er=toBytes$3(wr),kr=br.length/32;if(kr%2===0)throw new BytecodeLengthInWordsMustBeOddError({givenLengthInWords:kr});const jr=toBytes$3(kr),Br=pad(jr,{size:2}),Wr=new Uint8Array([1,0]);return Er.set(Wr,0),Er.set(Br,2),Er}const getEip712Domain=fr=>{assertEip712Transaction(fr);const br=transactionToMessage(fr);return{domain:{name:"zkSync",version:"2",chainId:fr.chainId},types:{Transaction:[{name:"txType",type:"uint256"},{name:"from",type:"uint256"},{name:"to",type:"uint256"},{name:"gasLimit",type:"uint256"},{name:"gasPerPubdataByteLimit",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymaster",type:"uint256"},{name:"nonce",type:"uint256"},{name:"value",type:"uint256"},{name:"data",type:"bytes"},{name:"factoryDeps",type:"bytes32[]"},{name:"paymasterInput",type:"bytes"}]},primaryType:"Transaction",message:br}};function transactionToMessage(fr){const{gas:br,nonce:wr,to:Er,from:kr,value:jr,maxFeePerGas:Br,maxPriorityFeePerGas:Wr,factoryDeps:qr,paymaster:Hr,paymasterInput:Vr,gasPerPubdata:Zr,data:Jr}=fr;return{txType:113n,from:BigInt(kr),to:Er?BigInt(Er):0n,gasLimit:br??0n,gasPerPubdataByteLimit:Zr??gasPerPubdataDefault,maxFeePerGas:Br??0n,maxPriorityFeePerGas:Wr??0n,paymaster:Hr?BigInt(Hr):0n,nonce:wr?BigInt(wr):0n,value:jr??0n,data:Jr||"0x0",factoryDeps:(qr==null?void 0:qr.map(Qr=>toHex(hashBytecode(Qr))))??[],paymasterInput:Vr||"0x"}}const chainConfig$3={formatters:formatters$2,serializers:serializers$2,custom:{getEip712Domain}},abstractTestnet=defineChain({...chainConfig$3,id:11124,name:"Abstract Testnet",nativeCurrency:{decimals:18,name:"ETH",symbol:"ETH"},rpcUrls:{default:{http:["https://api.testnet.abs.xyz"]}},blockExplorers:{default:{name:"Abstract Block Explorer",url:"https://explorer.testnet.abs.xyz"}},testnet:!0,contracts:{multicall3:{address:"0xF9cda624FBC7e059355ce98a31693d299FACd963",blockCreated:358349},universalSignatureVerifier:{address:"0xfB688330379976DA81eB64Fe4BF50d7401763B9C",blockCreated:431682}}}),acala=defineChain({id:787,name:"Acala",network:"acala",nativeCurrency:{name:"Acala",symbol:"ACA",decimals:18},rpcUrls:{default:{http:["https://eth-rpc-acala.aca-api.network"],webSocket:["wss://eth-rpc-acala.aca-api.network"]}},blockExplorers:{default:{name:"Acala Blockscout",url:"https://blockscout.acala.network",apiUrl:"https://blockscout.acala.network/api"}},testnet:!1}),acria=defineChain({id:47,name:"Acria IntelliChain",nativeCurrency:{decimals:18,name:"ACRIA",symbol:"ACRIA"},rpcUrls:{default:{http:["https://aic.acria.ai"]}},blockExplorers:{default:{name:"Acria Explorer",url:"https://explorer.acria.ai"}},testnet:!1}),aioz=defineChain({id:168,name:"AIOZ Network",nativeCurrency:{decimals:18,name:"AIOZ",symbol:"AIOZ"},rpcUrls:{default:{http:["https://eth-dataseed.aioz.network"]}},blockExplorers:{default:{name:"AIOZ Explorer",url:"https://explorer.aioz.network"}},testnet:!1}),alienx=defineChain({id:10241024,name:"AlienX Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.alienxchain.io/http"]}},blockExplorers:{default:{name:"AlienX Explorer",url:"https://explorer.alienxchain.io"}},testnet:!1}),alienxHalTestnet=defineChain({id:10241025,name:"ALIENX Hal Testnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://hal-rpc.alienxchain.io/http"]}},blockExplorers:{default:{name:"AlienX Explorer",url:"https://hal-explorer.alienxchain.io"}},testnet:!0}),contracts={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},formatters$1={block:defineBlock({format(fr){var wr;return{transactions:(wr=fr.transactions)==null?void 0:wr.map(Er=>{if(typeof Er=="string")return Er;const kr=formatTransaction(Er);return kr.typeHex==="0x7e"&&(kr.isSystemTx=Er.isSystemTx,kr.mint=Er.mint?hexToBigInt(Er.mint):void 0,kr.sourceHash=Er.sourceHash,kr.type="deposit"),kr}),stateRoot:fr.stateRoot}}}),transaction:defineTransaction({format(fr){const br={};return fr.type==="0x7e"&&(br.isSystemTx=fr.isSystemTx,br.mint=fr.mint?hexToBigInt(fr.mint):void 0,br.sourceHash=fr.sourceHash,br.type="deposit"),br}}),transactionReceipt:defineTransactionReceipt({format(fr){return{l1GasPrice:fr.l1GasPrice?hexToBigInt(fr.l1GasPrice):null,l1GasUsed:fr.l1GasUsed?hexToBigInt(fr.l1GasUsed):null,l1Fee:fr.l1Fee?hexToBigInt(fr.l1Fee):null,l1FeeScalar:fr.l1FeeScalar?Number(fr.l1FeeScalar):null}}})};function serializeTransaction$2(fr,br){return isDeposit(fr)?serializeTransactionDeposit(fr):serializeTransaction$4(fr,br)}const serializers$1={transaction:serializeTransaction$2};function serializeTransactionDeposit(fr){assertTransactionDeposit(fr);const{sourceHash:br,data:wr,from:Er,gas:kr,isSystemTx:jr,mint:Br,to:Wr,value:qr}=fr,Hr=[br,Er,Wr??"0x",Br?toHex(Br):"0x",qr?toHex(qr):"0x",kr?toHex(kr):"0x",jr?"0x1":"0x",wr??"0x"];return concatHex(["0x7e",toRlp(Hr)])}function isDeposit(fr){return fr.type==="deposit"||typeof fr.sourceHash<"u"}function assertTransactionDeposit(fr){const{from:br,to:wr}=fr;if(br&&!isAddress(br))throw new InvalidAddressError({address:br});if(wr&&!isAddress(wr))throw new InvalidAddressError({address:wr})}const chainConfig$2={contracts,formatters:formatters$1,serializers:serializers$1},sourceId$J=1,ancient8=defineChain({...chainConfig$2,id:888888888,name:"Ancient8",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.ancient8.gg"]}},blockExplorers:{default:{name:"Ancient8 explorer",url:"https://scan.ancient8.gg",apiUrl:"https://scan.ancient8.gg/api"}},contracts:{...chainConfig$2.contracts,l2OutputOracle:{[sourceId$J]:{address:"0xB09DC08428C8b4EFB4ff9C0827386CDF34277996"}},portal:{[sourceId$J]:{address:"0x639F2AECE398Aa76b07e59eF6abe2cFe32bacb68",blockCreated:19070571}},l1StandardBridge:{[sourceId$J]:{address:"0xd5e3eDf5b68135D559D572E26bF863FBC1950033",blockCreated:19070571}}},sourceId:sourceId$J}),sourceId$I=11155111,ancient8Sepolia=defineChain({...chainConfig$2,id:28122024,name:"Ancient8 Testnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpcv2-testnet.ancient8.gg"]}},blockExplorers:{default:{name:"Ancient8 Celestia Testnet explorer",url:"https://scanv2-testnet.ancient8.gg",apiUrl:"https://scanv2-testnet.ancient8.gg/api"}},contracts:{...chainConfig$2.contracts,l2OutputOracle:{[sourceId$I]:{address:"0x942fD5017c0F60575930D8574Eaca13BEcD6e1bB"}},portal:{[sourceId$I]:{address:"0xfa1d9E26A6aCD7b22115D27572c1221B9803c960",blockCreated:4972908}},l1StandardBridge:{[sourceId$I]:{address:"0xF6Bc0146d3c74D48306e79Ae134A260E418C9335",blockCreated:4972908}}},sourceId:sourceId$I}),anvil=defineChain({id:31337,name:"Anvil",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["http://127.0.0.1:8545"],webSocket:["ws://127.0.0.1:8545"]}}}),sourceId$H=42161,apeChain=defineChain({id:33139,name:"Ape Chain",nativeCurrency:{name:"ApeCoin",symbol:"APE",decimals:18},rpcUrls:{default:{http:["https://rpc.apechain.com/http"],webSocket:["wss://rpc.apechain.com/ws"]}},blockExplorers:{default:{name:"Apescan",url:"https://apescan.io",apiUrl:"https://api.apescan.io"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:20889}},sourceId:sourceId$H}),apexTestnet=defineChain({id:3993,name:"APEX Testnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc-testnet.apexlayer.xyz"]}},blockExplorers:{default:{name:"Blockscout",url:"https://exp-testnet.apexlayer.xyz",apiUrl:"https://exp-testnet.apexlayer.xyz/api"}},contracts:{multicall3:{address:"0xf7642be33a6b18D16a995657adb5a68CD0438aE2",blockCreated:283775}},testnet:!0}),arbitrum=defineChain({id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io",apiUrl:"https://api.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7654707}}}),arbitrumGoerli=defineChain({id:421613,name:"Arbitrum Goerli",nativeCurrency:{name:"Arbitrum Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://goerli-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://goerli.arbiscan.io"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:88114}},testnet:!0}),arbitrumNova=defineChain({id:42170,name:"Arbitrum Nova",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://nova.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://nova.arbiscan.io",apiUrl:"https://api-nova.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1746963}}}),arbitrumSepolia=defineChain({id:421614,name:"Arbitrum Sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://sepolia.arbiscan.io",apiUrl:"https://api-sepolia.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:81930}},testnet:!0}),areonNetwork=defineChain({id:463,name:"Areon Network",nativeCurrency:{decimals:18,name:"AREA",symbol:"AREA"},rpcUrls:{default:{http:["https://mainnet-rpc.areon.network"],webSocket:["wss://mainnet-ws.areon.network"]}},blockExplorers:{default:{name:"Areonscan",url:"https://areonscan.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:353286}},testnet:!1}),areonNetworkTestnet=defineChain({id:462,name:"Areon Network Testnet",nativeCurrency:{decimals:18,name:"TAREA",symbol:"TAREA"},rpcUrls:{default:{http:["https://testnet-rpc.areon.network"],webSocket:["wss://testnet-ws.areon.network"]}},blockExplorers:{default:{name:"Areonscan",url:"https://areonscan.com"}},testnet:!0}),artelaTestnet=defineChain({id:11822,name:"Artela Testnet",nativeCurrency:{name:"ART",symbol:"ART",decimals:18},rpcUrls:{default:{http:["https://betanet-rpc1.artela.network"]}},blockExplorers:{default:{name:"Artela",url:"https://betanet-scan.artela.network",apiUrl:"https://betanet-scan.artela.network/api"}},contracts:{multicall3:{address:"0xd07c8635f76e8745Ee7092fbb6e8fbc5FeF09DD7",blockCreated:7001871}},testnet:!0}),assetChain=defineChain({id:42420,name:"AssetChain Mainnet",nativeCurrency:{decimals:18,name:"Real World Asset",symbol:"RWA"},rpcUrls:{default:{http:["https://mainnet-rpc.assetchain.org"]}},blockExplorers:{default:{name:"Asset Chain Explorer",url:"https://scan.assetchain.org",apiUrl:"https://scan.assetchain.org/api"}},testnet:!1,contracts:{}}),assetChainTestnet=defineChain({id:42421,name:"AssetChain Testnet",nativeCurrency:{decimals:18,name:"Real World Asset",symbol:"RWA"},rpcUrls:{default:{http:["https://enugu-rpc.assetchain.org"]}},blockExplorers:{default:{name:"Asset Chain Testnet Explorer",url:"https://scan-testnet.assetchain.org",apiUrl:"https://scan-testnet.assetchain.org/api"}},testnet:!0,contracts:{multicall3:{address:"0x989F832D35988cb5e3eB001Fa2Fe789469EC31Ea",blockCreated:17177}}}),astar=defineChain({id:592,name:"Astar",network:"astar-mainnet",nativeCurrency:{name:"Astar",symbol:"ASTR",decimals:18},rpcUrls:{default:{http:["https://astar.api.onfinality.io/public"]}},blockExplorers:{default:{name:"Astar Subscan",url:"https://astar.subscan.io"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:761794}},testnet:!1}),astarZkEVM=defineChain({id:3776,name:"Astar zkEVM",network:"AstarZkEVM",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc-zkevm.astar.network"]}},blockExplorers:{default:{name:"Astar zkEVM Explorer",url:"https://astar-zkevm.explorer.startale.com"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:93528}},testnet:!1}),astarZkyoto=defineChain({id:6038361,name:"Astar zkEVM Testnet zKyoto",network:"zKyoto",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.startale.com/zkyoto"]}},blockExplorers:{default:{name:"zKyoto Explorer",url:"https://zkyoto.explorer.startale.com"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:196153}},testnet:!0}),atletaOlympia=defineChain({id:2340,name:"Atleta Olympia",nativeCurrency:{decimals:18,name:"Atla",symbol:"ATLA"},rpcUrls:{default:{http:["https://testnet-rpc.atleta.network:9944","https://testnet-rpc.atleta.network"],ws:["wss://testnet-rpc.atleta.network:9944"]}},blockExplorers:{default:{name:"Atleta Olympia Explorer",url:"https://blockscout.atleta.network",apiUrl:"https://blockscout.atleta.network/api"}},contracts:{multicall3:{address:"0x1472ec6392180fb84F345d2455bCC75B26577115",blockCreated:1076473}},testnet:!0}),aurora=defineChain({id:1313161554,name:"Aurora",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://mainnet.aurora.dev"]}},blockExplorers:{default:{name:"Aurorascan",url:"https://aurorascan.dev",apiUrl:"https://aurorascan.dev/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:62907816}}}),auroraTestnet=defineChain({id:1313161555,name:"Aurora Testnet",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://testnet.aurora.dev"]}},blockExplorers:{default:{name:"Aurorascan",url:"https://testnet.aurorascan.dev",apiUrl:"https://testnet.aurorascan.dev/api"}},testnet:!0}),auroria=defineChain({id:205205,name:"Auroria Testnet",network:"auroria",nativeCurrency:{name:"Auroria Stratis",symbol:"tSTRAX",decimals:18},rpcUrls:{default:{http:["https://auroria.rpc.stratisevm.com"]}},blockExplorers:{default:{name:"Auroria Testnet Explorer",url:"https://auroria.explorer.stratisevm.com"}},testnet:!0}),avalanche=defineChain({id:43114,name:"Avalanche",nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{default:{name:"SnowTrace",url:"https://snowtrace.io",apiUrl:"https://api.snowtrace.io"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:11907934}}}),avalancheFuji=defineChain({id:43113,name:"Avalanche Fuji",nativeCurrency:{decimals:18,name:"Avalanche Fuji",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax-test.network/ext/bc/C/rpc"]}},blockExplorers:{default:{name:"SnowTrace",url:"https://testnet.snowtrace.io",apiUrl:"https://api-testnet.snowtrace.io"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7096959}},testnet:!0}),sourceId$G=8453,b3=defineChain({id:8333,name:"B3",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet-rpc.b3.fun/http"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.b3.fun"}},sourceId:sourceId$G}),sourceId$F=168587773,b3Sepolia=defineChain({id:1993,name:"B3 Sepolia",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.b3.fun/http"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia.explorer.b3.fun"}},testnet:!0,sourceId:sourceId$F}),bahamut=defineChain({id:5165,network:"bahamut",name:"Bahamut",nativeCurrency:{name:"Fasttoken",symbol:"FTN",decimals:18},rpcUrls:{default:{http:["https://rpc1.bahamut.io","https://bahamut-rpc.publicnode.com","https://rpc2.bahamut.io"],webSocket:["wss://ws1.sahara.bahamutchain.com","wss://bahamut-rpc.publicnode.com","wss://ws2.sahara.bahamutchain.com"]}},blockExplorers:{default:{name:"Ftnscan",url:"https://www.ftnscan.com",apiUrl:"https://www.ftnscan.com/api"}}}),sourceId$E=1,base$7=defineChain({...chainConfig$2,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...chainConfig$2.contracts,disputeGameFactory:{[sourceId$E]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[sourceId$E]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[sourceId$E]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[sourceId$E]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:sourceId$E}),sourceId$D=5,baseGoerli=defineChain({...chainConfig$2,id:84531,name:"Base Goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://goerli.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://goerli.basescan.org",apiUrl:"https://goerli.basescan.org/api"}},contracts:{...chainConfig$2.contracts,l2OutputOracle:{[sourceId$D]:{address:"0x2A35891ff30313CcFa6CE88dcf3858bb075A2298"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1376988},portal:{[sourceId$D]:{address:"0xe93c8cD0D409341205A592f8c4Ac1A5fe5585cfA"}},l1StandardBridge:{[sourceId$D]:{address:"0xfA6D8Ee5BE770F84FC001D098C4bD604Fe01284a"}}},testnet:!0,sourceId:sourceId$D}),sourceId$C=11155111,baseSepolia$1=defineChain({...chainConfig$2,id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://sepolia.basescan.org",apiUrl:"https://api-sepolia.basescan.org/api"}},contracts:{...chainConfig$2.contracts,disputeGameFactory:{[sourceId$C]:{address:"0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"}},l2OutputOracle:{[sourceId$C]:{address:"0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"}},portal:{[sourceId$C]:{address:"0x49f53e41452c74589e85ca1677426ba426459e85",blockCreated:4446677}},l1StandardBridge:{[sourceId$C]:{address:"0xfd0Bf71F60660E2f608ed56e1659C450eB113120",blockCreated:4446677}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1059647}},testnet:!0,sourceId:sourceId$C}),beam=defineChain({id:4337,name:"Beam",network:"beam",nativeCurrency:{decimals:18,name:"Beam",symbol:"BEAM"},rpcUrls:{default:{http:["https://build.onbeam.com/rpc"],webSocket:["wss://build.onbeam.com/ws"]}},blockExplorers:{default:{name:"Beam Explorer",url:"https://subnets.avax.network/beam"}},contracts:{multicall3:{address:"0x4956f15efdc3dc16645e90cc356eafa65ffc65ec",blockCreated:1}}}),beamTestnet=defineChain({id:13337,name:"Beam Testnet",network:"beam",nativeCurrency:{decimals:18,name:"Beam",symbol:"BEAM"},rpcUrls:{default:{http:["https://build.onbeam.com/rpc/testnet"],webSocket:["wss://build.onbeam.com/ws/testnet"]}},blockExplorers:{default:{name:"Beam Explorer",url:"https://subnets-test.avax.network/beam"}},contracts:{multicall3:{address:"0x9bf49b704ee2a095b95c1f2d4eb9010510c41c9e",blockCreated:3}},testnet:!0}),bearNetworkChainMainnet=defineChain({id:641230,name:"Bear Network Chain Mainnet",nativeCurrency:{decimals:18,name:"BearNetworkChain",symbol:"BRNKC"},rpcUrls:{default:{http:["https://brnkc-mainnet.bearnetwork.net"]}},blockExplorers:{default:{name:"BrnkScan",url:"https://brnkscan.bearnetwork.net",apiUrl:"https://brnkscan.bearnetwork.net/api"}}}),bearNetworkChainTestnet=defineChain({id:751230,name:"Bear Network Chain Testnet",nativeCurrency:{decimals:18,name:"tBRNKC",symbol:"tBRNKC"},rpcUrls:{default:{http:["https://brnkc-test.bearnetwork.net"]}},blockExplorers:{default:{name:"BrnkTestScan",url:"https://brnktest-scan.bearnetwork.net",apiUrl:"https://brnktest-scan.bearnetwork.net/api"}},testnet:!0}),berachainTestnet=defineChain({id:80085,name:"Berachain Artio",nativeCurrency:{decimals:18,name:"BERA Token",symbol:"BERA"},rpcUrls:{default:{http:["https://artio.rpc.berachain.com"]}},blockExplorers:{default:{name:"Berachain",url:"https://artio.beratrail.io"}},testnet:!0}),berachainTestnetbArtio=defineChain({id:80084,name:"Berachain bArtio",nativeCurrency:{decimals:18,name:"BERA Token",symbol:"BERA"},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:109269}},rpcUrls:{default:{http:["https://bartio.rpc.berachain.com"]}},blockExplorers:{default:{name:"Berachain bArtio Beratrail",url:"https://bartio.beratrail.io"}},testnet:!0}),bevmMainnet=defineChain({id:11501,name:"BEVM Mainnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:18},rpcUrls:{default:{http:["https://rpc-mainnet-1.bevm.io"]}},blockExplorers:{default:{name:"Bevmscan",url:"https://scan-mainnet.bevm.io",apiUrl:"https://scan-mainnet-api.bevm.io/api"}}}),bifrost=defineChain({id:3068,name:"Bifrost Mainnet",nativeCurrency:{name:"BFC",symbol:"BFC",decimals:18},rpcUrls:{default:{http:["https://public-01.mainnet.bifrostnetwork.com/rpc"]}},blockExplorers:{default:{name:"Bifrost Blockscout",url:"https://explorer.mainnet.bifrostnetwork.com"}},testnet:!1}),bitgert=defineChain({id:32520,name:"Bitgert Mainnet",nativeCurrency:{decimals:18,name:"Brise",symbol:"Brise"},rpcUrls:{default:{http:["https://rpc-bitgert.icecreamswap.com"]}},blockExplorers:{default:{name:"Bitgert Scan",url:"https://brisescan.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:2118034}},testnet:!1}),bitkub=defineChain({id:96,name:"Bitkub",nativeCurrency:{name:"Bitkub",symbol:"KUB",decimals:18},rpcUrls:{default:{http:["https://rpc.bitkubchain.io"]}},blockExplorers:{default:{name:"Bitkub Chain Mainnet Explorer",url:"https://www.bkcscan.com",apiUrl:"https://www.bkcscan.com/api"}}}),bitkubTestnet=defineChain({id:25925,name:"Bitkub Testnet",network:"Bitkub Testnet",nativeCurrency:{name:"Bitkub Test",symbol:"tKUB",decimals:18},rpcUrls:{default:{http:["https://rpc-testnet.bitkubchain.io"]}},blockExplorers:{default:{name:"Bitkub Chain Testnet Explorer",url:"https://testnet.bkcscan.com",apiUrl:"https://testnet.bkcscan.com/api"}},testnet:!0}),bitlayer=defineChain({id:200901,name:"Bitlayer Mainnet",nativeCurrency:{name:"BTC",symbol:"BTC",decimals:18},rpcUrls:{default:{http:["https://rpc.bitlayer.org"],webSocket:["wss://ws.bitlayer.org"]}},blockExplorers:{default:{name:"bitlayer mainnet scan",url:"https://www.btrscan.com"}}}),bitlayerTestnet=defineChain({id:200810,name:"Bitlayer Testnet",nativeCurrency:{name:"BTC",symbol:"BTC",decimals:18},rpcUrls:{default:{http:["https://testnet-rpc.bitlayer.org"],webSocket:["wss://testnet-ws.bitlayer.org"]}},blockExplorers:{default:{name:"bitlayer testnet scan",url:"https://testnet.btrscan.com"}},testnet:!0}),bitrock=defineChain({id:7171,name:"Bitrock Mainnet",nativeCurrency:{name:"BROCK",symbol:"BROCK",decimals:18},rpcUrls:{default:{http:["https://brockrpc.io"]}},blockExplorers:{default:{name:"Bitrock Explorer",url:"https://explorer.bit-rock.io"}},testnet:!1}),bitTorrent=defineChain({id:199,name:"BitTorrent",network:"bittorrent-chain-mainnet",nativeCurrency:{name:"BitTorrent",symbol:"BTT",decimals:18},rpcUrls:{default:{http:["https://rpc.bittorrentchain.io"]}},blockExplorers:{default:{name:"Bttcscan",url:"https://bttcscan.com",apiUrl:"https://api.bttcscan.com/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:31078552}}}),bitTorrentTestnet=defineChain({id:1028,name:"BitTorrent Chain Testnet",network:"bittorrent-chain-testnet",nativeCurrency:{name:"BitTorrent",symbol:"BTT",decimals:18},rpcUrls:{default:{http:["https://testrpc.bittorrentchain.io"]}},blockExplorers:{default:{name:"Bttcscan",url:"https://testnet.bttcscan.com",apiUrl:"https://testnet.bttcscan.com/api"}},testnet:!0}),sourceId$B=1,blast=defineChain({id:81457,name:"Blast",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.blast.io"]}},blockExplorers:{default:{name:"Blastscan",url:"https://blastscan.io",apiUrl:"https://api.blastscan.io/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:212929}},sourceId:sourceId$B}),sourceId$A=11155111,blastSepolia=defineChain({id:168587773,name:"Blast Sepolia",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.blast.io"]}},blockExplorers:{default:{name:"Blastscan",url:"https://sepolia.blastscan.io",apiUrl:"https://api-sepolia.blastscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:756690}},testnet:!0,sourceId:sourceId$A}),sourceId$z=1,bob=defineChain({...chainConfig$2,id:60808,name:"BOB",nativeCurrency:{decimals:18,name:"ETH",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.gobob.xyz"],webSocket:["wss://rpc.gobob.xyz"]}},blockExplorers:{default:{name:"BOB Explorer",url:"https://explorer.gobob.xyz"}},contracts:{...chainConfig$2.contracts,multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:23131},l2OutputOracle:{[sourceId$z]:{address:"0xdDa53E23f8a32640b04D7256e651C1db98dB11C1",blockCreated:4462615}},portal:{[sourceId$z]:{address:"0x8AdeE124447435fE03e3CD24dF3f4cAE32E65a3E",blockCreated:4462615}}},sourceId:sourceId$z}),boba=defineChain({id:288,name:"Boba Network",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://mainnet.boba.network"]}},blockExplorers:{default:{name:"BOBAScan",url:"https://bobascan.com"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:446859}}}),bobaSepolia=defineChain({id:28882,name:"Boba Sepolia",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.boba.network"]}},blockExplorers:{default:{name:"BOBAScan",url:"https://testnet.bobascan.com"}},testnet:!0}),sourceId$y=11155111,bobSepolia=defineChain({...chainConfig$2,id:808813,name:"BOB Sepolia",nativeCurrency:{decimals:18,name:"ETH",symbol:"ETH"},rpcUrls:{default:{http:["https://bob-sepolia.rpc.gobob.xyz"],webSocket:["wss://bob-sepolia.rpc.gobob.xyz"]}},blockExplorers:{default:{name:"BOB Sepolia Explorer",url:"https://bob-sepolia.explorer.gobob.xyz"}},contracts:{...chainConfig$2.contracts,multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:35677},l2OutputOracle:{[sourceId$y]:{address:"0x14D0069452b4AE2b250B395b8adAb771E4267d2f",blockCreated:4462615}},portal:{[sourceId$y]:{address:"0x867B1Aa872b9C8cB5E9F7755feDC45BB24Ad0ae4",blockCreated:4462615}}},testnet:!0,sourceId:sourceId$y}),boolBetaMainnet=defineChain({id:11100,name:"Bool Beta Mainnet",nativeCurrency:{decimals:18,name:"BOL",symbol:"BOL"},rpcUrls:{default:{http:["https://beta-rpc-node-http.bool.network"]}},blockExplorers:{default:{name:"BoolScan",url:"https://beta-mainnet.boolscan.com/"}},testnet:!1}),botanixTestnet=defineChain({id:3636,name:"Botanix Testnet",nativeCurrency:{name:"Botanix",symbol:"BTC",decimals:18},rpcUrls:{default:{http:["https://poa-node.botanixlabs.dev"]}},blockExplorers:{default:{name:"blockscout",url:"https://blockscout.botanixlabs.dev",apiUrl:"https://blockscout.botanixlabs.dev"}},testnet:!0}),bounceBit=defineChain({id:6001,name:"BounceBit Mainnet",nativeCurrency:{name:"BounceBit",symbol:"BB",decimals:18},rpcUrls:{default:{http:["https://fullnode-mainnet.bouncebitapi.com"]}},blockExplorers:{default:{name:"BB Scan",url:"https://bbscan.io"}},testnet:!1}),bounceBitTestnet=defineChain({id:6e3,name:"BounceBit Testnet",nativeCurrency:{name:"BounceBit",symbol:"BB",decimals:18},rpcUrls:{default:{http:["https://fullnode-testnet.bouncebitapi.com"]}},blockExplorers:{default:{name:"BB Scan",url:"https://testnet.bbscan.io"}},testnet:!0}),bronos=defineChain({id:1039,name:"Bronos",nativeCurrency:{decimals:18,name:"BRO",symbol:"BRO"},rpcUrls:{default:{http:["https://evm.bronos.org"]}},blockExplorers:{default:{name:"BronoScan",url:"https://broscan.bronos.org"}}}),bronosTestnet=defineChain({id:1038,name:"Bronos Testnet",nativeCurrency:{decimals:18,name:"Bronos Coin",symbol:"tBRO"},rpcUrls:{default:{http:["https://evm-testnet.bronos.org"]}},blockExplorers:{default:{name:"BronoScan",url:"https://tbroscan.bronos.org"}},testnet:!0}),bsc=defineChain({id:56,name:"BNB Smart Chain",nativeCurrency:{decimals:18,name:"BNB",symbol:"BNB"},rpcUrls:{default:{http:["https://rpc.ankr.com/bsc"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com",apiUrl:"https://api.bscscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:15921452}}}),bscGreenfield=defineChain({id:1017,name:"BNB Greenfield Chain",nativeCurrency:{decimals:18,name:"BNB",symbol:"BNB"},rpcUrls:{default:{http:["https://greenfield-chain.bnbchain.org"]}},blockExplorers:{default:{name:"BNB Greenfield Mainnet Scan",url:"https://greenfieldscan.com"}},testnet:!1}),bscTestnet=defineChain({id:97,name:"Binance Smart Chain Testnet",nativeCurrency:{decimals:18,name:"BNB",symbol:"tBNB"},rpcUrls:{default:{http:["https://data-seed-prebsc-1-s1.bnbchain.org:8545"]}},blockExplorers:{default:{name:"BscScan",url:"https://testnet.bscscan.com",apiUrl:"https://api-testnet.bscscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:17422483}},testnet:!0}),bsquared=defineChain({id:223,name:"B2",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:18},rpcUrls:{default:{http:["https://rpc.bsquared.network"]}},blockExplorers:{default:{name:"blockscout",url:"https://explorer.bsquared.network"}}}),bsquaredTestnet=defineChain({id:1123,name:"B2 Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:18},rpcUrls:{default:{http:["https://testnet-rpc.bsquared.network"]}},blockExplorers:{default:{name:"blockscout",url:"https://testnet-explorer.bsquared.network"}},testnet:!0}),btr=defineChain({id:200901,name:"Bitlayer",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:18},rpcUrls:{default:{http:["https://rpc.bitlayer.org","https://rpc.bitlayer-rpc.com","https://rpc.ankr.com/bitlayer"],webSocket:["wss://ws.bitlayer.org","wss://ws.bitlayer-rpc.com"]}},blockExplorers:{default:{name:"Bitlayer(BTR) Scan",url:"https://www.btrscan.com"}}}),btrTestnet=defineChain({id:200810,name:"Bitlayer Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:18},rpcUrls:{default:{http:["https://testnet-rpc.bitlayer.org"],webSocket:["wss://testnet-ws.bitlayer.org","wss://testnet-ws.bitlayer-rpc.com"]}},blockExplorers:{default:{name:"Bitlayer(BTR) Scan",url:"https://testnet.btrscan.com"}},testnet:!0}),bxn=defineChain({id:4999,name:"BlackFort Exchange Network",nativeCurrency:{name:"BlackFort Token",symbol:"BXN",decimals:18},rpcUrls:{default:{http:["https://mainnet.blackfort.network/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.blackfort.network",apiUrl:"https://explorer.blackfort.network/api"}}}),bxnTestnet=defineChain({id:4777,name:"BlackFort Exchange Network Testnet",nativeCurrency:{name:"BlackFort Testnet Token",symbol:"TBXN",decimals:18},rpcUrls:{default:{http:["https://testnet.blackfort.network/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://testnet-explorer.blackfort.network",apiUrl:"https://testnet-explorer.blackfort.network/api"}},testnet:!0}),cannon=defineChain({id:13370,name:"Cannon",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["http://127.0.0.1:8545"]}}}),canto=defineChain({id:7700,name:"Canto",nativeCurrency:{decimals:18,name:"Canto",symbol:"CANTO"},rpcUrls:{default:{http:["https://canto.gravitychain.io"]}},blockExplorers:{default:{name:"Tuber.Build (Blockscout)",url:"https://tuber.build"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:2905789}}}),fees={estimateFeesPerGas:async fr=>{var kr;if(!((kr=fr.request)!=null&&kr.feeCurrency))return null;const[br,wr]=await Promise.all([estimateFeePerGasInFeeCurrency(fr.client,fr.request.feeCurrency),estimateMaxPriorityFeePerGasInFeeCurrency(fr.client,fr.request.feeCurrency)]);return{maxFeePerGas:fr.multiply(br)+wr,maxPriorityFeePerGas:wr}}};async function estimateFeePerGasInFeeCurrency(fr,br){const wr=await fr.request({method:"eth_gasPrice",params:[br]});return BigInt(wr)}async function estimateMaxPriorityFeePerGasInFeeCurrency(fr,br){const wr=await fr.request({method:"eth_maxPriorityFeePerGas",params:[br]});return BigInt(wr)}function isEmpty(fr){return fr===0||fr===0n||fr===void 0||fr===null||fr==="0"||fr===""||typeof fr=="string"&&(trim(fr).toLowerCase()==="0x"||trim(fr).toLowerCase()==="0x00")}function isPresent(fr){return!isEmpty(fr)}function isEIP1559(fr){return typeof fr.maxFeePerGas<"u"&&typeof fr.maxPriorityFeePerGas<"u"}function isCIP64(fr){return fr.type==="cip64"?!0:isEIP1559(fr)&&isPresent(fr.feeCurrency)}const formatters={block:defineBlock({format(fr){var wr;return{transactions:(wr=fr.transactions)==null?void 0:wr.map(Er=>typeof Er=="string"?Er:{...formatTransaction(Er),...Er.gatewayFee?{gatewayFee:hexToBigInt(Er.gatewayFee),gatewayFeeRecipient:Er.gatewayFeeRecipient}:{},feeCurrency:Er.feeCurrency}),...fr.randomness?{randomness:fr.randomness}:{}}}}),transaction:defineTransaction({format(fr){if(fr.type==="0x7e")return{isSystemTx:fr.isSystemTx,mint:fr.mint?hexToBigInt(fr.mint):void 0,sourceHash:fr.sourceHash,type:"deposit"};const br={feeCurrency:fr.feeCurrency};return fr.type==="0x7b"?br.type="cip64":(fr.type==="0x7c"&&(br.type="cip42"),br.gatewayFee=fr.gatewayFee?hexToBigInt(fr.gatewayFee):null,br.gatewayFeeRecipient=fr.gatewayFeeRecipient),br}}),transactionRequest:defineTransactionRequest({format(fr){const br={};return fr.feeCurrency&&(br.feeCurrency=fr.feeCurrency),isCIP64(fr)&&(br.type="0x7b"),br}})};function serializeTransaction$1(fr,br){return isCIP64(fr)?serializeTransactionCIP64(fr,br):serializeTransaction$2(fr,br)}const serializers={transaction:serializeTransaction$1};function serializeTransactionCIP64(fr,br){assertTransactionCIP64(fr);const{chainId:wr,gas:Er,nonce:kr,to:jr,value:Br,maxFeePerGas:Wr,maxPriorityFeePerGas:qr,accessList:Hr,feeCurrency:Vr,data:Zr}=fr,Jr=[toHex(wr),kr?toHex(kr):"0x",qr?toHex(qr):"0x",Wr?toHex(Wr):"0x",Er?toHex(Er):"0x",jr??"0x",Br?toHex(Br):"0x",Zr??"0x",serializeAccessList(Hr),Vr,...toYParitySignatureArray(fr,br)];return concatHex(["0x7b",toRlp(Jr)])}const MAX_MAX_FEE_PER_GAS=maxUint256;function assertTransactionCIP64(fr){const{chainId:br,maxPriorityFeePerGas:wr,gasPrice:Er,maxFeePerGas:kr,to:jr,feeCurrency:Br}=fr;if(br<=0)throw new InvalidChainIdError({chainId:br});if(jr&&!isAddress(jr))throw new InvalidAddressError({address:jr});if(Er)throw new BaseError("`gasPrice` is not a valid CIP-64 Transaction attribute.");if(isPresent(kr)&&kr>MAX_MAX_FEE_PER_GAS)throw new FeeCapTooHighError({maxFeePerGas:kr});if(isPresent(wr)&&isPresent(kr)&&wr>kr)throw new TipAboveFeeCapError({maxFeePerGas:kr,maxPriorityFeePerGas:wr});if(isPresent(Br)&&!isAddress(Br))throw new BaseError("`feeCurrency` MUST be a token address for CIP-64 transactions.");if(isEmpty(Br))throw new BaseError("`feeCurrency` must be provided for CIP-64 transactions.")}const chainConfig$1={contracts,formatters,serializers,fees},celo=defineChain({...chainConfig$1,id:42220,name:"Celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://celoscan.io",apiUrl:"https://api.celoscan.io/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:13112599}},testnet:!1}),sourceId$x=17e3,celoAlfajores=defineChain({...chainConfig$1,id:44787,name:"Alfajores",nativeCurrency:{decimals:18,name:"CELO",symbol:"A-CELO"},rpcUrls:{default:{http:["https://alfajores-forno.celo-testnet.org"]}},blockExplorers:{default:{name:"Celo Alfajores Explorer",url:"https://celo-alfajores.blockscout.com",apiUrl:"https://celo-alfajores.blockscout.com/api"}},contracts:{...chainConfig$1.contracts,multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:14569001},portal:{[sourceId$x]:{address:"0x82527353927d8D069b3B452904c942dA149BA381",blockCreated:2411324}},disputeGameFactory:{[sourceId$x]:{address:"0xE28AAdcd9883746c0e5068F58f9ea06027b214cb",blockCreated:2411324}},l2OutputOracle:{[sourceId$x]:{address:"0x4a2635e9e4f6e45817b1D402ac4904c1d1752438",blockCreated:2411324}},l1StandardBridge:{[sourceId$x]:{address:"0xD1B0E0581973c9eB7f886967A606b9441A897037",blockCreated:2411324}}},testnet:!0}),chang=defineChain({id:5858,name:"Chang Chain Foundation Mainnet",nativeCurrency:{decimals:18,name:"CTH",symbol:"CTH"},rpcUrls:{default:{http:["https://rpc.cthscan.com"]}},blockExplorers:{default:{name:"Chang Chain explorer",url:"https://cthscan.com"}}}),chiliz=defineChain({id:88888,name:"Chiliz Chain",network:"chiliz-chain",nativeCurrency:{decimals:18,name:"CHZ",symbol:"CHZ"},rpcUrls:{default:{http:["https://rpc.ankr.com/chiliz","https://chiliz-rpc.publicnode.com"]}},blockExplorers:{default:{name:"Chiliz Explorer",url:"https://scan.chiliz.com",apiUrl:"https://scan.chiliz.com/api"}}}),chips=defineChain({id:2882,name:"Chips Network",network:"CHIPS",nativeCurrency:{decimals:18,name:"IOTA",symbol:"IOTA"},rpcUrls:{default:{http:["https://node.chips.ooo/wasp/api/v1/chains/iota1pp3d3mnap3ufmgqnjsnw344sqmf5svjh26y2khnmc89sv6788y3r207a8fn/evm"]}}}),classic=defineChain({id:61,name:"Ethereum Classic",nativeCurrency:{decimals:18,name:"ETC",symbol:"ETC"},rpcUrls:{default:{http:["https://etc.rivet.link"]}},blockExplorers:{default:{name:"Blockscout",url:"https://blockscout.com/etc/mainnet"}}}),coinbit=defineChain({id:112,name:"Coinbit Mainnet",nativeCurrency:{name:"GIDR",symbol:"GIDR",decimals:18},rpcUrls:{default:{http:["https://coinbit-rpc-mainnet.chain.sbcrypto.app"]}},blockExplorers:{default:{name:"Coinbit Explorer",url:"https://coinbit-explorer.chain.sbcrypto.app"}},testnet:!1}),coinex=defineChain({id:52,name:"CoinEx Mainnet",nativeCurrency:{name:"cet",symbol:"cet",decimals:18},rpcUrls:{default:{http:["https://rpc.coinex.net"]}},blockExplorers:{default:{name:"CoinEx Explorer",url:"https://www.coinex.net"}},testnet:!1}),confluxESpace=defineChain({id:1030,name:"Conflux eSpace",nativeCurrency:{name:"Conflux",symbol:"CFX",decimals:18},rpcUrls:{default:{http:["https://evm.confluxrpc.com"],webSocket:["wss://evm.confluxrpc.com/ws"]}},blockExplorers:{default:{name:"ConfluxScan",url:"https://evm.confluxscan.io"}},contracts:{multicall3:{address:"0xEFf0078910f638cd81996cc117bccD3eDf2B072F",blockCreated:68602935}}}),confluxESpaceTestnet=defineChain({id:71,name:"Conflux eSpace Testnet",network:"cfx-espace-testnet",testnet:!0,nativeCurrency:{name:"Conflux",symbol:"CFX",decimals:18},rpcUrls:{default:{http:["https://evmtestnet.confluxrpc.com"],webSocket:["wss://evmtestnet.confluxrpc.com/ws"]}},blockExplorers:{default:{name:"ConfluxScan",url:"https://evmtestnet.confluxscan.io"}},contracts:{multicall3:{address:"0xEFf0078910f638cd81996cc117bccD3eDf2B072F",blockCreated:117499050}}}),coreDao=defineChain({id:1116,name:"Core Dao",nativeCurrency:{decimals:18,name:"Core",symbol:"CORE"},rpcUrls:{default:{http:["https://rpc.coredao.org"]}},blockExplorers:{default:{name:"CoreDao",url:"https://scan.coredao.org"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:11907934}},testnet:!1}),crab=defineChain({id:44,name:"Crab Network",nativeCurrency:{decimals:18,name:"Crab Network Native Token",symbol:"CRAB"},rpcUrls:{default:{http:["https://crab-rpc.darwinia.network"],webSocket:["wss://crab-rpc.darwinia.network"]}},blockExplorers:{default:{name:"Blockscout",url:"https://crab-scan.darwinia.network"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:3032593}}}),cronos=defineChain({id:25,name:"Cronos Mainnet",nativeCurrency:{decimals:18,name:"Cronos",symbol:"CRO"},rpcUrls:{default:{http:["https://evm.cronos.org"]}},blockExplorers:{default:{name:"Cronos Explorer",url:"https://explorer.cronos.org",apiUrl:"https://explorer-api.cronos.org/mainnet/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:1963112}}}),cronosTestnet=defineChain({id:338,name:"Cronos Testnet",nativeCurrency:{decimals:18,name:"CRO",symbol:"tCRO"},rpcUrls:{default:{http:["https://evm-t3.cronos.org"]}},blockExplorers:{default:{name:"Cronos Explorer",url:"https://cronos.org/explorer/testnet3"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:10191251}},testnet:!0}),cronoszkEVM=defineChain({id:388,name:"Cronos zkEVM Mainnet",nativeCurrency:{decimals:18,name:"Cronos zkEVM CRO",symbol:"zkCRO"},rpcUrls:{default:{http:["https://mainnet.zkevm.cronos.org"]}},blockExplorers:{default:{name:"Cronos zkEVM (Mainnet) Chain Explorer",url:"https://explorer.zkevm.cronos.org"}}}),cronoszkEVMTestnet=defineChain({id:282,name:"Cronos zkEVM Testnet",nativeCurrency:{decimals:18,name:"Cronos zkEVM Test Coin",symbol:"zkTCRO"},rpcUrls:{default:{http:["https://testnet.zkevm.cronos.org"]}},blockExplorers:{default:{name:"Cronos zkEVM Testnet Explorer",url:"https://explorer.zkevm.cronos.org/testnet"}},testnet:!0}),crossbell=defineChain({id:3737,name:"Crossbell",nativeCurrency:{decimals:18,name:"CSB",symbol:"CSB"},rpcUrls:{default:{http:["https://rpc.crossbell.io"]}},blockExplorers:{default:{name:"CrossScan",url:"https://scan.crossbell.io",apiUrl:"https://scan.crossbell.io/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:38246031}}}),curtis=defineChain({id:33111,name:"Curtis",nativeCurrency:{name:"ApeCoin",symbol:"APE",decimals:18},rpcUrls:{default:{http:["https://rpc.curtis.apechain.com"]}},blockExplorers:{default:{name:"Curtis Explorer",url:"https://explorer.curtis.apechain.com"}},testnet:!0}),cyber=defineChain({id:7560,name:"Cyber",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://cyber.alt.technology"]}},blockExplorers:{default:{name:"Blockscout",url:"https://cyberscan.co",apiUrl:"https://cyberscan.co/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:0}}}),cyberTestnet=defineChain({id:111557560,name:"Cyber Testnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://cyber-testnet.alt.technology"]}},blockExplorers:{default:{name:"Blockscout",url:"https://testnet.cyberscan.co",apiUrl:"https://testnet.cyberscan.co/api"}},contracts:{multicall3:{address:"0xffc391F0018269d4758AEA1a144772E8FB99545E",blockCreated:304545}},testnet:!0}),darwinia=defineChain({id:46,name:"Darwinia Network",nativeCurrency:{decimals:18,name:"RING",symbol:"RING"},rpcUrls:{default:{http:["https://rpc.darwinia.network"],webSocket:["wss://rpc.darwinia.network"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.darwinia.network"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:69420}}}),dchain=defineChain({...chainConfig$2,id:2716446429837e3,name:"Dchain",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://dchain-2716446429837000-1.jsonrpc.sagarpc.io"]}},blockExplorers:{default:{name:"Dchain Explorer",url:"https://dchain-2716446429837000-1.sagaexplorer.io",apiUrl:"https://api-dchain-2716446429837000-1.sagaexplorer.io/api"}},contracts:{...chainConfig$2.contracts}}),dchainTestnet=defineChain({...chainConfig$2,id:2713017997578e3,name:"Dchain Testnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://dchaintestnet-2713017997578000-1.jsonrpc.testnet.sagarpc.io"]}},blockExplorers:{default:{name:"Dchain Explorer",url:"https://dchaintestnet-2713017997578000-1.testnet.sagaexplorer.io",apiUrl:"https://api-dchaintestnet-2713017997578000-1.testnet.sagaexplorer.io/api"}},contracts:{...chainConfig$2.contracts}}),defichainEvm=defineChain({id:1130,network:"defichain-evm",name:"DeFiChain EVM Mainnet",nativeCurrency:{name:"DeFiChain",symbol:"DFI",decimals:18},rpcUrls:{default:{http:["https://eth.mainnet.ocean.jellyfishsdk.com"]}},blockExplorers:{default:{name:"DeFiScan",url:"https://meta.defiscan.live"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:137852}}}),defichainEvmTestnet=defineChain({id:1131,network:"defichain-evm-testnet",name:"DeFiChain EVM Testnet",nativeCurrency:{name:"DeFiChain",symbol:"DFI",decimals:18},rpcUrls:{default:{http:["https://eth.testnet.ocean.jellyfishsdk.com"]}},blockExplorers:{default:{name:"DeFiScan",url:"https://meta.defiscan.live/?network=TestNet"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:156462}},testnet:!0}),degen=defineChain({id:666666666,name:"Degen",nativeCurrency:{decimals:18,name:"Degen",symbol:"DEGEN"},rpcUrls:{default:{http:["https://rpc.degen.tips"],webSocket:["wss://rpc.degen.tips"]}},blockExplorers:{default:{name:"Degen Chain Explorer",url:"https://explorer.degen.tips",apiUrl:"https://explorer.degen.tips/api/v2"}}}),dfk=defineChain({id:53935,name:"DFK Chain",nativeCurrency:{decimals:18,name:"Jewel",symbol:"JEWEL"},rpcUrls:{default:{http:["https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"]}},blockExplorers:{default:{name:"DFKSubnetScan",url:"https://subnets.avax.network/defi-kingdoms"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14790551}}}),diode=defineChain({id:15,name:"Diode Prenet",nativeCurrency:{decimals:18,name:"DIODE",symbol:"DIODE"},rpcUrls:{default:{http:["https://prenet.diode.io:8443"],webSocket:["wss://prenet.diode.io:8443/ws"]}},blockExplorers:{default:{name:"Diode Explorer",url:"https://diode.io/prenet"}},testnet:!1}),disChain=defineChain({id:513100,name:"DisChain",nativeCurrency:{decimals:18,name:"DIS",symbol:"DIS"},rpcUrls:{default:{http:["https://rpc.dischain.xyz"]}},blockExplorers:{default:{name:"DisChain Explorer",url:"https://www.oklink.com/dis"}}}),dodochainTestnet=defineChain({id:53457,name:"DODOchain Testnet",nativeCurrency:{decimals:18,name:"DODO",symbol:"DODO"},rpcUrls:{default:{http:["https://dodochain-testnet.alt.technology"],webSocket:["wss://dodochain-testnet.alt.technology/ws"]}},blockExplorers:{default:{name:"DODOchain Testnet (Sepolia) Explorer",url:"https://testnet-scan.dodochain.com"}},testnet:!0}),dogechain=defineChain({id:2e3,name:"Dogechain",nativeCurrency:{decimals:18,name:"Wrapped Dogecoin",symbol:"WDOGE"},rpcUrls:{default:{http:["https://rpc.dogechain.dog"]}},blockExplorers:{default:{name:"DogeChainExplorer",url:"https://explorer.dogechain.dog",apiUrl:"https://explorer.dogechain.dog/api"}},contracts:{multicall3:{address:"0x68a8609a60a008EFA633dfdec592c03B030cC508",blockCreated:25384031}}}),dosChain=defineChain({id:7979,name:"DOS Chain",nativeCurrency:{decimals:18,name:"DOS Chain",symbol:"DOS"},rpcUrls:{default:{http:["https://main.doschain.com"]}},blockExplorers:{default:{name:"DOS Chain Explorer",url:"https://doscan.io",apiUrl:"https://api.doscan.io"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:161908}}}),dosChainTestnet=defineChain({id:3939,name:"DOS Chain Testnet",nativeCurrency:{decimals:18,name:"DOS Chain Testnet",symbol:"DOS"},rpcUrls:{default:{http:["https://test.doschain.com"]}},blockExplorers:{default:{name:"DOS Chain Testnet Explorer",url:"https://test.doscan.io",apiUrl:"https://api-test.doscan.io"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:69623}},testnet:!0}),dreyerxMainnet=defineChain({id:23451,name:"DreyerX Mainnet",nativeCurrency:{name:"DreyerX",symbol:"DRX",decimals:18},rpcUrls:{default:{http:["https://rpc.dreyerx.com"]}},blockExplorers:{default:{name:"DreyerX Scan",url:"https://scan.dreyerx.com"}}}),dreyerxTestnet=defineChain({id:23452,name:"DreyerX Testnet",nativeCurrency:{name:"DreyerX",symbol:"DRX",decimals:18},rpcUrls:{default:{http:["http://testnet-rpc.dreyerx.com"]}},blockExplorers:{default:{name:"DreyerX Testnet Scan",url:"https://testnet-scan.dreyerx.com"}},testnet:!0}),dustboyIoT=defineChain({id:555888,name:"DustBoy IoT",nativeCurrency:{name:"Ether",symbol:"DST",decimals:18},rpcUrls:{default:{http:["https://dustboy-rpc.jibl2.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://dustboy.jibl2.com",apiUrl:"https://dustboy.jibl2.com/api"}},contracts:{multicall3:{address:"0xFFD34aa2C62B2D52E00A361e466C229788f4eD6a",blockCreated:526569}},testnet:!1}),dymension=defineChain({id:1100,name:"Dymension",nativeCurrency:{name:"DYM",symbol:"DYM",decimals:18},rpcUrls:{default:{http:["https://dymension-evm-rpc.publicnode.com"],webSocket:["wss://dymension-evm-rpc.publicnode.com"]}},blockExplorers:{default:{name:"Dym FYI",url:"https://dym.fyi"}},testnet:!1}),edgeless=defineChain({id:2026,name:"Edgeless Network",nativeCurrency:{name:"Edgeless Wrapped ETH",symbol:"EwETH",decimals:18},rpcUrls:{default:{http:["https://rpc.edgeless.network/http"],webSocket:["wss://rpc.edgeless.network/ws"]}},blockExplorers:{default:{name:"Edgeless Explorer",url:"https://explorer.edgeless.network"}}}),edgelessTestnet=defineChain({id:202,name:"Edgeless Testnet",nativeCurrency:{name:"Edgeless Wrapped ETH",symbol:"EwETH",decimals:18},rpcUrls:{default:{http:["https://edgeless-testnet.rpc.caldera.xyz/http"],webSocket:["wss://edgeless-testnet.rpc.caldera.xyz/ws"]}},blockExplorers:{default:{name:"Edgeless Testnet Explorer",url:"https://testnet.explorer.edgeless.network"}}}),edgeware=defineChain({id:2021,name:"Edgeware EdgeEVM Mainnet",nativeCurrency:{decimals:18,name:"Edgeware",symbol:"EDG"},rpcUrls:{default:{http:["https://edgeware-evm.jelliedowl.net"]}},blockExplorers:{default:{name:"Edgscan by Bharathcoorg",url:"https://edgscan.live",apiUrl:"https://edgscan.live/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:18117872}}}),edgewareTestnet=defineChain({id:2022,name:"Beresheet BereEVM Testnet",nativeCurrency:{decimals:18,name:"Testnet EDG",symbol:"tEDG"},rpcUrls:{default:{http:["https://beresheet-evm.jelliedowl.net"]}},blockExplorers:{default:{name:"Edgscan by Bharathcoorg",url:"https://testnet.edgscan.live",apiUrl:"https://testnet.edgscan.live/api"}}}),ekta=defineChain({id:1994,name:"Ekta",nativeCurrency:{decimals:18,name:"EKTA",symbol:"EKTA"},rpcUrls:{default:{http:["https://main.ekta.io"]}},blockExplorers:{default:{name:"Ektascan",url:"https://ektascan.io",apiUrl:"https://ektascan.io/api"}}}),ektaTestnet=defineChain({id:1004,name:"Ekta Testnet",nativeCurrency:{decimals:18,name:"EKTA",symbol:"EKTA"},rpcUrls:{default:{http:["https://test.ekta.io:8545"]}},blockExplorers:{default:{name:"Test Ektascan",url:"https://test.ektascan.io",apiUrl:"https://test.ektascan.io/api"}},testnet:!0}),elastos=defineChain({id:20,name:"Elastos Smart Chain",nativeCurrency:{name:"ELA",symbol:"ELA",decimals:18},rpcUrls:{default:{http:["https://api2.elastos.io/eth"]}},blockExplorers:{default:{name:"Elastos Explorer",url:"https://esc.elastos.io"}},testnet:!1}),elastosTestnet=defineChain({id:21,name:"Elastos Smart Chain Testnet",nativeCurrency:{name:"tELA",symbol:"tELA",decimals:18},rpcUrls:{default:{http:["https://api-testnet.elastos.io/eth"]}},blockExplorers:{default:{name:"Elastos Explorer",url:"https://esc-testnet.elastos.io"}},testnet:!0}),electroneum=defineChain({id:52014,name:"Electroneum Mainnet",nativeCurrency:{name:"ETN",symbol:"ETN",decimals:18},rpcUrls:{default:{http:["https://rpc.electroneum.com"]}},blockExplorers:{default:{name:"Electroneum Block Explorer",url:"https://blockexplorer.electroneum.com"}},testnet:!1}),electroneumTestnet=defineChain({id:5201420,name:"Electroneum Testnet",nativeCurrency:{name:"ETN",symbol:"ETN",decimals:18},rpcUrls:{default:{http:["https://testnet-rpc.electroneum.com"]}},blockExplorers:{default:{name:"Electroneum Block Explorer",url:"https://blockexplorer.thesecurityteam.rocks"}},testnet:!0}),elysiumTestnet=defineChain({...chainConfig$2,id:1338,name:"Elysium Testnet",nativeCurrency:{decimals:18,name:"LAVA",symbol:"LAVA"},rpcUrls:{default:{http:["https://elysium-test-rpc.vulcanforged.com"]}},blockExplorers:{default:{name:"Elysium testnet explorer",url:"https://elysium-explorer.vulcanforged.com"}},testnet:!0}),energy=defineChain({id:246,name:"Energy Mainnet",nativeCurrency:{name:"EWT",symbol:"EWT",decimals:18},rpcUrls:{default:{http:["https://rpc.energyweb.org"]}},blockExplorers:{default:{name:"EnergyWeb Explorer",url:"https://explorer.energyweb.org"}},testnet:!1}),enuls=defineChain({id:119,name:"ENULS Mainnet",nativeCurrency:{decimals:18,name:"NULS",symbol:"NULS"},rpcUrls:{default:{http:["https://evmapi2.nuls.io"]}},blockExplorers:{default:{name:"ENULS Explorer",url:"https://evmscan.nuls.io"}},testnet:!1}),eon=defineChain({id:7332,name:"Horizen EON",nativeCurrency:{decimals:18,name:"ZEN",symbol:"ZEN"},rpcUrls:{default:{http:["https://eon-rpc.horizenlabs.io/ethv1"]}},blockExplorers:{default:{name:"EON Explorer",url:"https://eon-explorer.horizenlabs.io"}},contracts:{}}),eos=defineChain({id:17777,name:"EOS EVM",nativeCurrency:{decimals:18,name:"EOS",symbol:"EOS"},rpcUrls:{default:{http:["https://api.evm.eosnetwork.com"]}},blockExplorers:{default:{name:"EOS EVM Explorer",url:"https://explorer.evm.eosnetwork.com",apiUrl:"https://explorer.evm.eosnetwork.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7943933}}}),eosTestnet=defineChain({id:15557,name:"EOS EVM Testnet",nativeCurrency:{decimals:18,name:"EOS",symbol:"EOS"},rpcUrls:{default:{http:["https://api.testnet.evm.eosnetwork.com"]}},blockExplorers:{default:{name:"EOS EVM Testnet Explorer",url:"https://explorer.testnet.evm.eosnetwork.com",apiUrl:"https://explorer.testnet.evm.eosnetwork.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:9067940}},testnet:!0}),etherlink=defineChain({id:42793,name:"Etherlink",nativeCurrency:{decimals:18,name:"Tez",symbol:"XTZ"},rpcUrls:{default:{http:["https://node.mainnet.etherlink.com"]}},blockExplorers:{default:{name:"Etherlink",url:"https://explorer.etherlink.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:33899}}}),etherlinkTestnet=defineChain({id:128123,name:"Etherlink Testnet",nativeCurrency:{decimals:18,name:"Tez",symbol:"XTZ"},rpcUrls:{default:{http:["https://node.ghostnet.etherlink.com"]}},blockExplorers:{default:{name:"Etherlink Testnet",url:"https://testnet-explorer.etherlink.com"}},testnet:!0}),evmos=defineChain({id:9001,name:"Evmos",nativeCurrency:{decimals:18,name:"Evmos",symbol:"EVMOS"},rpcUrls:{default:{http:["https://eth.bd.evmos.org:8545"]}},blockExplorers:{default:{name:"Evmos Block Explorer",url:"https://escan.live"}}}),evmosTestnet=defineChain({id:9e3,name:"Evmos Testnet",nativeCurrency:{decimals:18,name:"Evmos",symbol:"EVMOS"},rpcUrls:{default:{http:["https://eth.bd.evmos.dev:8545"]}},blockExplorers:{default:{name:"Evmos Testnet Block Explorer",url:"https://evm.evmos.dev/"}}}),excelonMainnet=defineChain({id:22052002,name:"Excelon Mainnet",network:"XLON",nativeCurrency:{decimals:18,name:"Excelon",symbol:"xlon"},rpcUrls:{default:{http:["https://edgewallet1.xlon.org"]}},blockExplorers:{default:{name:"Excelon explorer",url:"https://explorer.excelon.io"}}}),expanse=defineChain({id:2,name:"Expanse Network",nativeCurrency:{decimals:18,name:"EXP",symbol:"EXP"},rpcUrls:{default:{http:["https://node.expanse.tech"]}},blockExplorers:{default:{name:"Expanse Explorer",url:"https://explorer.expanse.tech"}},testnet:!1}),fantom=defineChain({id:250,name:"Fantom",nativeCurrency:{decimals:18,name:"Fantom",symbol:"FTM"},rpcUrls:{default:{http:["https://rpc.ankr.com/fantom"]}},blockExplorers:{default:{name:"FTMScan",url:"https://ftmscan.com",apiUrl:"https://api.ftmscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:33001987}}}),fantomSonicTestnet=defineChain({id:64240,name:"Fantom Sonic Open Testnet",network:"fantom-sonic-testnet",nativeCurrency:{decimals:18,name:"Fantom",symbol:"FTM"},rpcUrls:{default:{http:["https://rpcapi.sonic.fantom.network"]}},blockExplorers:{default:{name:"Fantom Sonic Open Testnet Explorer",url:"https://public-sonic.fantom.network"}},testnet:!0}),fantomTestnet=defineChain({id:4002,name:"Fantom Testnet",nativeCurrency:{decimals:18,name:"Fantom",symbol:"FTM"},rpcUrls:{default:{http:["https://rpc.testnet.fantom.network"]}},blockExplorers:{default:{name:"FTMScan",url:"https://testnet.ftmscan.com",apiUrl:"https://testnet.ftmscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:8328688}},testnet:!0}),fibo=defineChain({id:12306,name:"Fibo Chain",nativeCurrency:{decimals:18,name:"fibo",symbol:"FIBO"},rpcUrls:{default:{http:["https://network.hzroc.art"]}},blockExplorers:{default:{name:"FiboScan",url:"https://scan.fibochain.org"}}}),filecoin=defineChain({id:314,name:"Filecoin Mainnet",nativeCurrency:{decimals:18,name:"filecoin",symbol:"FIL"},rpcUrls:{default:{http:["https://api.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filfox",url:"https://filfox.info/en"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:3328594}}}),filecoinCalibration=defineChain({id:314159,name:"Filecoin Calibration",nativeCurrency:{decimals:18,name:"testnet filecoin",symbol:"tFIL"},rpcUrls:{default:{http:["https://api.calibration.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filscan",url:"https://calibration.filscan.io"}},testnet:!0}),filecoinHyperspace=defineChain({id:3141,name:"Filecoin Hyperspace",nativeCurrency:{decimals:18,name:"testnet filecoin",symbol:"tFIL"},rpcUrls:{default:{http:["https://api.hyperspace.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filfox",url:"https://hyperspace.filfox.info/en"}},testnet:!0}),fireChain=defineChain({id:995,name:"5ireChain",nativeCurrency:{name:"5ire Token",symbol:"5IRE",decimals:18},rpcUrls:{default:{http:["https://rpc.5ire.network"]}},blockExplorers:{default:{name:"5ireChain Mainnet Explorer",url:"https://5irescan.io/"}},testnet:!1}),flare=defineChain({id:14,name:"Flare Mainnet",nativeCurrency:{decimals:18,name:"Flare",symbol:"FLR"},rpcUrls:{default:{http:["https://flare-api.flare.network/ext/C/rpc"]}},blockExplorers:{default:{name:"Flare Explorer",url:"https://flare-explorer.flare.network",apiUrl:"https://flare-explorer.flare.network/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:3002461}}}),flareTestnet=defineChain({id:114,name:"Flare Testnet Coston2",nativeCurrency:{decimals:18,name:"Coston2 Flare",symbol:"C2FLR"},rpcUrls:{default:{http:["https://coston2-api.flare.network/ext/C/rpc"]}},blockExplorers:{default:{name:"Coston2 Explorer",url:"https://coston2-explorer.flare.network",apiUrl:"https://coston2-explorer.flare.network/api"}},testnet:!0}),flowMainnet=defineChain({id:747,name:"FlowEVM Mainnet",nativeCurrency:{decimals:18,name:"Flow",symbol:"FLOW"},rpcUrls:{default:{http:["https://mainnet.evm.nodes.onflow.org"]}},blockExplorers:{default:{name:"Mainnet Explorer",url:"https://flowdiver.io"}}}),flowPreviewnet=defineChain({id:646,name:"FlowEVM Previewnet",nativeCurrency:{decimals:18,name:"Flow",symbol:"FLOW"},rpcUrls:{default:{http:["https://previewnet.evm.nodes.onflow.org"]}},blockExplorers:{default:{name:"Previewnet Explorer",url:"https://previewnet.flowdiver.io"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:6205}}}),flowTestnet=defineChain({id:545,name:"FlowEVM Testnet",nativeCurrency:{decimals:18,name:"Flow",symbol:"FLOW"},rpcUrls:{default:{http:["https://testnet.evm.nodes.onflow.org"]}},blockExplorers:{default:{name:"Flow Diver",url:"https://testnet.flowdiver.io"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:137518}}}),fluence=defineChain({id:9999999,name:"Fluence",nativeCurrency:{name:"FLT",symbol:"FLT",decimals:18},rpcUrls:{default:{http:["https://rpc.mainnet.fluence.dev"],webSocket:["wss://ws.mainnet.fluence.dev"]}},blockExplorers:{default:{name:"Blockscout",url:"https://blockscout.mainnet.fluence.dev",apiUrl:"https://blockscout.mainnet.fluence.dev/api"}}}),fluenceStage=defineChain({id:123420000220,name:"Fluence Stage",nativeCurrency:{name:"tFLT",symbol:"tFLT",decimals:18},rpcUrls:{default:{http:["https://rpc.stage.fluence.dev"],webSocket:["wss://ws.stage.fluence.dev"]}},blockExplorers:{default:{name:"Blockscout",url:"https://blockscout.stage.fluence.dev",apiUrl:"https://blockscout.stage.fluence.dev/api"}},testnet:!0}),fluenceTestnet=defineChain({id:52164803,name:"Fluence Testnet",nativeCurrency:{name:"tFLT",symbol:"tFLT",decimals:18},rpcUrls:{default:{http:["https://rpc.testnet.fluence.dev"],webSocket:["wss://ws.testnet.fluence.dev"]}},blockExplorers:{default:{name:"Blockscout",url:"https://blockscout.testnet.fluence.dev",apiUrl:"https://blockscout.testnet.fluence.dev/api"}},testnet:!0}),forma=defineChain({id:984122,name:"Forma",network:"forma",nativeCurrency:{symbol:"TIA",name:"TIA",decimals:18},rpcUrls:{default:{http:["https://rpc.forma.art"],webSocket:["wss://ws.forma.art"]}},blockExplorers:{default:{name:"Forma Explorer",url:"https://explorer.forma.art"}},contracts:{multicall3:{address:"0xd53C6FFB123F7349A32980F87faeD8FfDc9ef079",blockCreated:252705}}}),foundry=defineChain({id:31337,name:"Foundry",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["http://127.0.0.1:8545"],webSocket:["ws://127.0.0.1:8545"]}}}),sourceId$w=1,fraxtal=defineChain({...chainConfig$2,id:252,name:"Fraxtal",nativeCurrency:{name:"Frax Ether",symbol:"frxETH",decimals:18},rpcUrls:{default:{http:["https://rpc.frax.com"]}},blockExplorers:{default:{name:"fraxscan",url:"https://fraxscan.com",apiUrl:"https://api.fraxscan.com/api"}},contracts:{...chainConfig$2.contracts,l2OutputOracle:{[sourceId$w]:{address:"0x66CC916Ed5C6C2FA97014f7D1cD141528Ae171e4"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11"},portal:{[sourceId$w]:{address:"0x36cb65c1967A0Fb0EEE11569C51C2f2aA1Ca6f6D",blockCreated:19135323}},l1StandardBridge:{[sourceId$w]:{address:"0x34C0bD5877A5Ee7099D0f5688D65F4bB9158BDE2",blockCreated:19135323}}},sourceId:sourceId$w}),sourceId$v=17e3,fraxtalTestnet=defineChain({...chainConfig$2,id:2522,name:"Fraxtal Testnet",nativeCurrency:{name:"Frax Ether",symbol:"frxETH",decimals:18},rpcUrls:{default:{http:["https://rpc.testnet.frax.com"]}},blockExplorers:{default:{name:"fraxscan testnet",url:"https://holesky.fraxscan.com",apiUrl:"https://api-holesky.fraxscan.com/api"}},contracts:{...chainConfig$2.contracts,l2OutputOracle:{[sourceId$v]:{address:"0x715EA64DA13F4d0831ece4Ad3E8c1aa013167F32"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11"},portal:{[sourceId$v]:{address:"0xB9c64BfA498d5b9a8398Ed6f46eb76d90dE5505d",blockCreated:318416}},l1StandardBridge:{[sourceId$v]:{address:"0x0BaafC217162f64930909aD9f2B27125121d6332",blockCreated:318416}}},sourceId:sourceId$v}),sourceId$u=1,funkiMainnet=defineChain({...chainConfig$2,id:33979,name:"Funki",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc-mainnet.funkichain.com"]}},blockExplorers:{default:{name:"Funki Mainnet Explorer",url:"https://funkiscan.io"}},contracts:{...chainConfig$2.contracts},sourceId:sourceId$u}),sourceId$t=11155111,funkiSepolia=defineChain({...chainConfig$2,id:3397901,network:"funkiSepolia",name:"Funki Sepolia Sandbox",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://funki-testnet.alt.technology"]}},blockExplorers:{default:{name:"Funki Sepolia Sandbox Explorer",url:"https://sepolia-sandbox.funkichain.com/"}},testnet:!0,contracts:{...chainConfig$2.contracts,multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1620204}},sourceId:sourceId$t}),fuse=defineChain({id:122,name:"Fuse",nativeCurrency:{name:"Fuse",symbol:"FUSE",decimals:18},rpcUrls:{default:{http:["https://rpc.fuse.io"]}},blockExplorers:{default:{name:"Fuse Explorer",url:"https://explorer.fuse.io",apiUrl:"https://explorer.fuse.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:16146628}}}),fuseSparknet=defineChain({id:123,name:"Fuse Sparknet",nativeCurrency:{name:"Spark",symbol:"SPARK",decimals:18},rpcUrls:{default:{http:["https://rpc.fusespark.io"]}},blockExplorers:{default:{name:"Sparkent Explorer",url:"https://explorer.fusespark.io",apiUrl:"https://explorer.fusespark.io/api"}}}),fusion=defineChain({id:32659,name:"Fusion Mainnet",nativeCurrency:{name:"Fusion",symbol:"FSN",decimals:18},rpcUrls:{default:{http:["https://mainnet.fusionnetwork.io"],webSocket:["wss://mainnet.fusionnetwork.io"]}},blockExplorers:{default:{name:"FSNscan",url:"https://fsnscan.com"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:10441605}},testnet:!1}),fusionTestnet=defineChain({id:46688,name:"Fusion Testnet",nativeCurrency:{name:"Fusion",symbol:"FSN",decimals:18},rpcUrls:{default:{http:["https://testnet.fusionnetwork.io"],webSocket:["wss://testnet.fusionnetwork.io"]}},blockExplorers:{default:{name:"FSNscan",url:"https://testnet.fsnscan.com"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:10428309}},testnet:!0}),sourceId$s=17e3,garnet=defineChain({...chainConfig$2,name:"Garnet Testnet",testnet:!0,id:17069,sourceId:sourceId$s,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.garnetchain.com"],webSocket:["wss://rpc.garnetchain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.garnetchain.com"}},contracts:{...chainConfig$2.contracts,multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11"},portal:{[sourceId$s]:{address:"0x57ee40586fbE286AfC75E67cb69511A6D9aF5909",blockCreated:1274684}},l2OutputOracle:{[sourceId$s]:{address:"0xCb8E7AC561b8EF04F2a15865e9fbc0766FEF569B",blockCreated:1274684}},l1StandardBridge:{[sourceId$s]:{address:"0x09bcDd311FE398F80a78BE37E489f5D440DB95DE",blockCreated:1274684}}}}),geist=defineChain({id:63157,name:"Geist Mainnet",nativeCurrency:{decimals:18,name:"Aavegotchi GHST Token",symbol:"GHST"},rpcUrls:{default:{http:["https://geist-mainnet.g.alchemy.com/public"]}},blockExplorers:{default:{name:"Blockscout",url:"https://geist-mainnet.explorer.alchemy.com"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:660735}}}),genesys=defineChain({id:16507,name:"Genesys Mainnet",nativeCurrency:{decimals:18,name:"GSYS",symbol:"GSYS"},rpcUrls:{default:{http:["https://rpc.genesys.network"]}},blockExplorers:{default:{name:"Genesys Explorer",url:"https://gchainexplorer.genesys.network"}},testnet:!1}),glideL1Protocol=defineChain({id:251,name:"Glide L1 Protocol XP",nativeCurrency:{name:"GLXP",symbol:"GLXP",decimals:18},rpcUrls:{default:{http:["https://rpc-api.glideprotocol.xyz/l1-rpc"],webSocket:["wss://rpc-api.glideprotocol.xyz/l1-rpc"]}},blockExplorers:{default:{name:"Glide Protocol Explore",url:"https://blockchain-explorer.glideprotocol.xyz"}},testnet:!1}),glideL2Protocol=defineChain({id:253,name:"Glide L2 Protocol XP",nativeCurrency:{name:"GLXP",symbol:"GLXP",decimals:18},rpcUrls:{default:{http:["https://rpc-api.glideprotocol.xyz/l2-rpc"],webSocket:["wss://rpc-api.glideprotocol.xyz/l2-rpc"]}},blockExplorers:{default:{name:"Glide Protocol Explore",url:"https://blockchain-explorer.glideprotocol.xyz"}},testnet:!1}),gnosis=defineChain({id:100,name:"Gnosis",nativeCurrency:{decimals:18,name:"xDAI",symbol:"XDAI"},rpcUrls:{default:{http:["https://rpc.gnosischain.com"],webSocket:["wss://rpc.gnosischain.com/wss"]}},blockExplorers:{default:{name:"Gnosisscan",url:"https://gnosisscan.io",apiUrl:"https://api.gnosisscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:21022491}}}),gnosisChiado=defineChain({id:10200,name:"Gnosis Chiado",nativeCurrency:{decimals:18,name:"Gnosis",symbol:"xDAI"},rpcUrls:{default:{http:["https://rpc.chiadochain.net"],webSocket:["wss://rpc.chiadochain.net/wss"]}},blockExplorers:{default:{name:"Blockscout",url:"https://blockscout.chiadochain.net",apiUrl:"https://blockscout.chiadochain.net/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:4967313}},testnet:!0}),gobi=defineChain({id:1663,name:"Horizen Gobi Testnet",nativeCurrency:{decimals:18,name:"Test ZEN",symbol:"tZEN"},rpcUrls:{default:{http:["https://gobi-testnet.horizenlabs.io/ethv1"]}},blockExplorers:{default:{name:"Gobi Explorer",url:"https://gobi-explorer.horizen.io"}},contracts:{},testnet:!0}),goChain=defineChain({id:60,name:"GoChain",nativeCurrency:{decimals:18,name:"GO",symbol:"GO"},rpcUrls:{default:{http:["https://rpc.gochain.io"]}},blockExplorers:{default:{name:"GoChain Explorer",url:"https://explorer.gochain.io"}},testnet:!1}),godwoken=defineChain({id:71402,name:"Godwoken Mainnet",nativeCurrency:{decimals:18,name:"pCKB",symbol:"pCKB"},rpcUrls:{default:{http:["https://v1.mainnet.godwoken.io/rpc"]}},blockExplorers:{default:{name:"GW Scan",url:"https://v1.gwscan.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:15034}},testnet:!1}),goerli=defineChain({id:5,name:"Goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.ankr.com/eth_goerli"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.etherscan.io",apiUrl:"https://api-goerli.etherscan.io/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xfc4AC75C46C914aF5892d6d3eFFcebD7917293F1",blockCreated:10339206},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:6507670}},testnet:!0}),gravity=defineChain({id:1625,name:"Gravity Alpha Mainnet",nativeCurrency:{name:"G",symbol:"G",decimals:18},rpcUrls:{default:{http:["https://rpc.gravity.xyz"]}},blockExplorers:{default:{name:"Gravity Explorer",url:"https://explorer.gravity.xyz",apiUrl:"https://explorer.gravity.xyz/api"}},contracts:{multicall3:{address:"0xf8ac4BEB2F75d2cFFb588c63251347fdD629B92c",blockCreated:16851}}}),guruNetwork=defineChain({id:260,name:"Guru Network Mainnet",nativeCurrency:{name:"GURU Token",symbol:"GURU",decimals:18},rpcUrls:{default:{http:["https://rpc.gurunetwork.ai/archive/260"]}},blockExplorers:{default:{name:"Guruscan",url:"https://scan.gurunetwork.ai"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:271691}},testnet:!1}),guruTestnet=defineChain({id:261,name:"Guru Network Testnet",nativeCurrency:{name:"tGURU Token",symbol:"tGURU",decimals:18},rpcUrls:{default:{http:["https://rpc.gurunetwork.ai/archive/261"]}},blockExplorers:{default:{name:"Guruscan",url:"https://sepolia.gurunetwork.ai"}},testnet:!0}),ham=defineChain({id:5112,name:"Ham",nativeCurrency:{decimals:18,name:"Ham",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.ham.fun"],webSocket:["wss://rpc.ham.fun"]}},blockExplorers:{default:{name:"Ham Chain Explorer",url:"https://explorer.ham.fun",apiUrl:"https://explorer.ham.fun/api/v2"}}}),haqqMainnet=defineChain({id:11235,name:"HAQQ Mainnet",nativeCurrency:{decimals:18,name:"Islamic Coin",symbol:"ISLM"},rpcUrls:{default:{http:["https://rpc.eth.haqq.network"]}},blockExplorers:{default:{name:"HAQQ Explorer",url:"https://explorer.haqq.network",apiUrl:"https://explorer.haqq.network/api"}}}),haqqTestedge2=defineChain({id:54211,name:"HAQQ Testedge 2",nativeCurrency:{decimals:18,name:"Islamic Coin",symbol:"ISLMT"},rpcUrls:{default:{http:["https://rpc.eth.testedge2.haqq.network"]}},blockExplorers:{default:{name:"HAQQ Explorer",url:"https://explorer.testedge2.haqq.network",apiUrl:"https://explorer.testedge2.haqq.network/api"}}}),hardhat=defineChain({id:31337,name:"Hardhat",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["http://127.0.0.1:8545"]}}}),harmonyOne=defineChain({id:16666e5,name:"Harmony One",nativeCurrency:{name:"Harmony",symbol:"ONE",decimals:18},rpcUrls:{default:{http:["https://rpc.ankr.com/harmony"]}},blockExplorers:{default:{name:"Harmony Explorer",url:"https://explorer.harmony.one"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:24185753}}}),hashkeyTestnet=defineChain({id:133,name:"HashKey Chain Testnet",nativeCurrency:{decimals:18,name:"HashKey EcoPoints",symbol:"HSK"},rpcUrls:{default:{http:["https://hashkeychain-testnet.alt.technology"]}},blockExplorers:{default:{name:"HashKey Chain Explorer",url:"https://hashkeychain-testnet-explorer.alt.technology"}}}),hedera=defineChain({id:295,name:"Hedera Mainnet",network:"hedera-mainnet",nativeCurrency:{symbol:"HBAR",name:"HBAR",decimals:18},rpcUrls:{default:{http:["https://mainnet.hashio.io/api"]}},blockExplorers:{default:{name:"Hashscan",url:"https://hashscan.io/mainnet"}},testnet:!1}),hederaPreviewnet=defineChain({id:297,name:"Hedera Previewnet",network:"hedera-previewnet",nativeCurrency:{symbol:"HBAR",name:"HBAR",decimals:18},rpcUrls:{default:{http:["https://previewnet.hashio.io/api"]}},blockExplorers:{default:{name:"Hashscan",url:"https://hashscan.io/previewnet"}},testnet:!0}),hederaTestnet=defineChain({id:296,name:"Hedera Testnet",network:"hedera-testnet",nativeCurrency:{symbol:"HBAR",name:"HBAR",decimals:18},rpcUrls:{default:{http:["https://testnet.hashio.io/api"]}},blockExplorers:{default:{name:"Hashscan",url:"https://hashscan.io/testnet"}},testnet:!0}),hela=defineChain({id:8668,name:"Hela Mainnet",nativeCurrency:{name:"HLUSD",symbol:"HLUSD",decimals:18},rpcUrls:{default:{http:["https://mainnet-rpc.helachain.com"]}},blockExplorers:{default:{name:"Hela explorer",url:"https://mainnet-blockexplorer.helachain.com"}},testnet:!1}),hemiSepolia=defineChain({id:743111,name:"Hemi Sepolia",network:"Hemi Sepolia",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://testnet.rpc.hemi.network/rpc"]}},blockExplorers:{default:{name:"Hemi Sepolia explorer",url:"https://testnet.explorer.hemi.xyz"}},testnet:!0}),holesky=defineChain({id:17e3,name:"Holesky",nativeCurrency:{name:"Holesky Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://ethereum-holesky-rpc.publicnode.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://holesky.etherscan.io",apiUrl:"https://api-holesky.etherscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:77},ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",blockCreated:801613},ensUniversalResolver:{address:"0xa6AC935D4971E3CD133b950aE053bECD16fE7f3b",blockCreated:973484}},testnet:!0}),hpb=defineChain({id:269,name:"High Performance Blockchain",nativeCurrency:{name:"HPB",symbol:"HPB",decimals:18},rpcUrls:{default:{http:["https://hpbnode.com"]}},blockExplorers:{default:{name:"hpbScan",url:"https://hscan.org"}},testnet:!1}),hychain=defineChain({id:2911,name:"HYCHAIN",nativeCurrency:{name:"HYTOPIA",symbol:"TOPIA",decimals:18},rpcUrls:{default:{http:["https://rpc.hychain.com/http"]}},blockExplorers:{default:{name:"HYCHAIN Explorer",url:"https://explorer.hychain.com"}},testnet:!1}),hychainTestnet=defineChain({id:29112,name:"HYCHAIN Testnet",nativeCurrency:{name:"HYTOPIA",symbol:"TOPIA",decimals:18},rpcUrls:{default:{http:["https://rpc.hychain.com/http"]}},blockExplorers:{default:{name:"HYCHAIN Explorer",url:"https://testnet-rpc.hychain.com/http"}},testnet:!0}),idchain=defineChain({id:74,name:"IDChain Mainnet",nativeCurrency:{decimals:18,name:"EIDI",symbol:"EIDI"},rpcUrls:{default:{http:["https://idchain.one/rpc"],webSocket:["wss://idchain.one/ws"]}},blockExplorers:{default:{name:"IDChain Explorer",url:"https://explorer.idchain.one"}},testnet:!1}),immutableZkEvm=defineChain({id:13371,name:"Immutable zkEVM",nativeCurrency:{decimals:18,name:"Immutable Coin",symbol:"IMX"},rpcUrls:{default:{http:["https://rpc.immutable.com"]}},blockExplorers:{default:{name:"Immutable Explorer",url:"https://explorer.immutable.com",apiUrl:"https://explorer.immutable.com/api"}},contracts:{multicall3:{address:"0x236bdA4589e44e6850f5aC6a74BfCa398a86c6c0",blockCreated:4335972}}}),immutableZkEvmTestnet=defineChain({id:13473,name:"Immutable zkEVM Testnet",nativeCurrency:{decimals:18,name:"Immutable Coin",symbol:"IMX"},rpcUrls:{default:{http:["https://rpc.testnet.immutable.com"]}},blockExplorers:{default:{name:"Immutable Testnet Explorer",url:"https://explorer.testnet.immutable.com/"}},contracts:{multicall3:{address:"0x2CC787Ed364600B0222361C4188308Fa8E68bA60",blockCreated:5977391}},testnet:!0}),inEVM=defineChain({id:2525,name:"inEVM Mainnet",nativeCurrency:{decimals:18,name:"Injective",symbol:"INJ"},rpcUrls:{default:{http:["https://mainnet.rpc.inevm.com/http"]}},blockExplorers:{default:{name:"inEVM Explorer",url:"https://inevm.calderaexplorer.xyz",apiUrl:"https://inevm.calderaexplorer.xyz/api/v2"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:118606}}}),sourceId$r=11155111,inkSepolia=defineChain({...chainConfig$2,id:763373,name:"Ink Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc-gel-sepolia.inkonchain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer-sepolia.inkonchain.com/",apiUrl:"https://explorer-sepolia.inkonchain.com/api/v2"}},contracts:{...chainConfig$2.contracts,disputeGameFactory:{[sourceId$r]:{address:"0x860e626c700af381133d9f4af31412a2d1db3d5d"}},portal:{[sourceId$r]:{address:"0x5c1d29c6c9c8b0800692acc95d700bcb4966a1d7"}},l1StandardBridge:{[sourceId$r]:{address:"0x33f60714bbd74d62b66d79213c348614de51901c"}}},testnet:!0,sourceId:sourceId$r}),iota=defineChain({id:8822,name:"IOTA EVM",network:"iotaevm",nativeCurrency:{decimals:18,name:"IOTA",symbol:"IOTA"},rpcUrls:{default:{http:["https://json-rpc.evm.iotaledger.net"],webSocket:["wss://ws.json-rpc.evm.iotaledger.net"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.evm.iota.org",apiUrl:"https://explorer.evm.iota.org/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:25022}}}),iotaTestnet=defineChain({id:1075,name:"IOTA EVM Testnet",network:"iotaevm-testnet",nativeCurrency:{decimals:18,name:"IOTA",symbol:"IOTA"},rpcUrls:{default:{http:["https://json-rpc.evm.testnet.iotaledger.net"],webSocket:["wss://ws.json-rpc.evm.testnet.iotaledger.net"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.evm.testnet.iotaledger.net",apiUrl:"https://explorer.evm.testnet.iotaledger.net/api"}},testnet:!0}),iotex=defineChain({id:4689,name:"IoTeX",nativeCurrency:{decimals:18,name:"IoTeX",symbol:"IOTX"},rpcUrls:{default:{http:["https://babel-api.mainnet.iotex.io"],webSocket:["wss://babel-api.mainnet.iotex.io"]}},blockExplorers:{default:{name:"IoTeXScan",url:"https://iotexscan.io"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:22163670}}}),iotexTestnet=defineChain({id:4690,name:"IoTeX Testnet",nativeCurrency:{decimals:18,name:"IoTeX",symbol:"IOTX"},rpcUrls:{default:{http:["https://babel-api.testnet.iotex.io"],webSocket:["wss://babel-api.testnet.iotex.io"]}},blockExplorers:{default:{name:"IoTeXScan",url:"https://testnet.iotexscan.io"}},contracts:{multicall3:{address:"0xb5cecD6894c6f473Ec726A176f1512399A2e355d",blockCreated:24347592}},testnet:!0}),iSunCoin=defineChain({id:8017,name:"iSunCoin Mainnet",nativeCurrency:{decimals:18,name:"ISC",symbol:"ISC"},rpcUrls:{default:{http:["https://mainnet.isuncoin.com"]}},blockExplorers:{default:{name:"iSunCoin Explorer",url:"https://baifa.io/app/chains/8017"}}}),jbc=defineChain({id:8899,name:"JIBCHAIN L1",network:"jbc",nativeCurrency:{name:"JBC",symbol:"JBC",decimals:18},rpcUrls:{default:{http:["https://rpc-l1.jibchain.net"]}},blockExplorers:{default:{name:"Blockscout",url:"https://exp-l1.jibchain.net",apiUrl:"https://exp-l1.jibchain.net/api"}},contracts:{multicall3:{address:"0xc0C8C486D1466C57Efe13C2bf000d4c56F47CBdC",blockCreated:2299048}},testnet:!1}),jbcTestnet=defineChain({id:88991,name:"Jibchain Testnet",nativeCurrency:{name:"tJBC",symbol:"tJBC",decimals:18},rpcUrls:{default:{http:["https://rpc.testnet.jibchain.net"]}},blockExplorers:{default:{name:"Blockscout",url:"https://exp.testnet.jibchain.net",apiUrl:"https://exp.testnet.jibchain.net/api"}},contracts:{multicall3:{address:"0xa1a858ad9041B4741e620355a3F96B3c78e70ecE",blockCreated:32848}},testnet:!0}),karura=defineChain({id:686,name:"Karura",network:"karura",nativeCurrency:{name:"Karura",symbol:"KAR",decimals:18},rpcUrls:{default:{http:["https://eth-rpc-karura.aca-api.network"],webSocket:["wss://eth-rpc-karura.aca-api.network"]}},blockExplorers:{default:{name:"Karura Blockscout",url:"https://blockscout.karura.network",apiUrl:"https://blockscout.karura.network/api"}},testnet:!1}),kakarotSepolia=defineChain({id:1802203764,name:"Kakarot Sepolia",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia-rpc.kakarot.org"]}},blockExplorers:{default:{name:"Kakarot Scan",url:"https://sepolia.kakarotscan.org"}},testnet:!0}),kakarotStarknetSepolia=defineChain({id:920637907288165,name:"Kakarot Starknet Sepolia",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia-rpc.kakarot.org"]}},blockExplorers:{default:{name:"Kakarot Scan",url:"https://sepolia.kakarotscan.org"}},testnet:!0}),kardiaChain=defineChain({id:24,name:"KardiaChain Mainnet",nativeCurrency:{name:"KAI",symbol:"KAI",decimals:18},rpcUrls:{default:{http:["https://rpc.kardiachain.io"]}},blockExplorers:{default:{name:"KardiaChain Explorer",url:"https://explorer.kardiachain.io"}},testnet:!1}),kava=defineChain({id:2222,name:"Kava EVM",network:"kava-mainnet",nativeCurrency:{name:"Kava",symbol:"KAVA",decimals:18},rpcUrls:{default:{http:["https://evm.kava.io"]}},blockExplorers:{default:{name:"Kava EVM Explorer",url:"https://kavascan.com",apiUrl:"https://kavascan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:3661165}},testnet:!1}),kavaTestnet=defineChain({id:2221,name:"Kava EVM Testnet",network:"kava-testnet",nativeCurrency:{name:"Kava",symbol:"KAVA",decimals:18},rpcUrls:{default:{http:["https://evm.testnet.kava.io"]}},blockExplorers:{default:{name:"Kava EVM Testnet Explorer",url:"https://testnet.kavascan.com/",apiUrl:"https://testnet.kavascan.com/api"}},contracts:{multicall3:{address:"0xDf1D724A7166261eEB015418fe8c7679BBEa7fd6",blockCreated:7242179}},testnet:!0}),kcc=defineChain({id:321,name:"KCC Mainnet",network:"KCC Mainnet",nativeCurrency:{decimals:18,name:"KCS",symbol:"KCS"},rpcUrls:{default:{http:["https://kcc-rpc.com"]}},blockExplorers:{default:{name:"KCC Explorer",url:"https://explorer.kcc.io"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:11760430}},testnet:!1}),kinto=defineChain({id:7887,name:"Kinto Mainnet",network:"Kinto Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.kinto.xyz/http"]}},blockExplorers:{default:{name:"Kinto Explorer",url:"https://explorer.kinto.xyz"}},testnet:!1}),klaytn=defineChain({id:8217,name:"Klaytn",nativeCurrency:{decimals:18,name:"Klaytn",symbol:"KLAY"},rpcUrls:{default:{http:["https://public-en-cypress.klaytn.net"]}},blockExplorers:{default:{name:"KlaytnScope",url:"https://scope.klaytn.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:96002415}}}),kaia=defineChain({id:8217,name:"Kaia",nativeCurrency:{decimals:18,name:"Kaia",symbol:"KAIA"},rpcUrls:{default:{http:["https://public-en.node.kaia.io"]}},blockExplorers:{default:{name:"KaiaScan",url:"https://kaiascan.io",apiUrl:"https://api-cypress.klaytnscope.com/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:96002415}}}),kairos=defineChain({id:1001,name:"Kairos Testnet",network:"kairos",nativeCurrency:{decimals:18,name:"Kairos KAIA",symbol:"KAIA"},rpcUrls:{default:{http:["https://public-en-kairos.node.kaia.io"]}},blockExplorers:{default:{name:"KaiaScan",url:"https://kairos.kaiascan.io"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:123390593}},testnet:!0}),klaytnBaobab=defineChain({id:1001,name:"Klaytn Baobab Testnet",network:"klaytn-baobab",nativeCurrency:{decimals:18,name:"Baobab Klaytn",symbol:"KLAY"},rpcUrls:{default:{http:["https://public-en-baobab.klaytn.net"]}},blockExplorers:{default:{name:"KlaytnScope",url:"https://baobab.klaytnscope.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:123390593}},testnet:!0}),koi=defineChain({id:701,name:"Koi Network",nativeCurrency:{decimals:18,name:"Koi Network Native Token",symbol:"KRING"},rpcUrls:{default:{http:["https://koi-rpc.darwinia.network"],webSocket:["wss://koi-rpc.darwinia.network"]}},blockExplorers:{default:{name:"Blockscout",url:"https://koi-scan.darwinia.network"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:180001}},testnet:!0}),kroma=defineChain({id:255,name:"Kroma",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://api.kroma.network"]}},blockExplorers:{default:{name:"Kroma Explorer",url:"https://blockscout.kroma.network",apiUrl:"https://blockscout.kroma.network/api"}},testnet:!1}),kromaSepolia=defineChain({id:2358,name:"Kroma Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://api.sepolia.kroma.network"]}},blockExplorers:{default:{name:"Kroma Sepolia Explorer",url:"https://blockscout.sepolia.kroma.network",apiUrl:"https://blockscout.sepolia.kroma.network/api"}},testnet:!0}),l3x=defineChain({id:12324,name:"L3X Protocol",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc-mainnet.l3x.com"],webSocket:["wss://rpc-mainnet.l3x.com"]}},blockExplorers:{default:{name:"L3X Mainnet Explorer",url:"https://explorer.l3x.com",apiUrl:"https://explorer.l3x.com/api/v2"}},testnet:!1}),l3xTestnet=defineChain({id:12325,name:"L3X Protocol Testnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc-testnet.l3x.com"],webSocket:["wss://rpc-testnet.l3x.com"]}},blockExplorers:{default:{name:"L3X Testnet Explorer",url:"https://explorer-testnet.l3x.com",apiUrl:"https://explorer-testnet.l3x.com/api/v2"}},testnet:!0}),lavita=defineChain({id:360890,name:"LAVITA Mainnet",nativeCurrency:{name:"vTFUEL",symbol:"vTFUEL",decimals:18},rpcUrls:{default:{http:["https://tsub360890-eth-rpc.thetatoken.org/rpc"]}},blockExplorers:{default:{name:"LAVITA Explorer",url:"https://tsub360890-explorer.thetatoken.org"}},testnet:!1}),lightlinkPegasus=defineChain({id:1891,name:"LightLink Pegasus Testnet",network:"lightlink-pegasus",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://replicator.pegasus.lightlink.io/rpc/v1"]}},blockExplorers:{default:{name:"LightLink Pegasus Explorer",url:"https://pegasus.lightlink.io"}},testnet:!0}),lightlinkPhoenix=defineChain({id:1890,name:"LightLink Phoenix Mainnet",network:"lightlink-phoenix",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://replicator.phoenix.lightlink.io/rpc/v1"]}},blockExplorers:{default:{name:"LightLink Phoenix Explorer",url:"https://phoenix.lightlink.io"}},testnet:!1});async function estimateGas(fr,br){var kr,jr,Br;const{account:wr=fr.account}=br;if(!wr)throw new AccountNotFoundError;const Er=parseAccount(wr);try{const{accessList:Wr,blockNumber:qr,blockTag:Hr,data:Vr,gas:Zr,gasPrice:Jr,maxFeePerGas:Qr,maxPriorityFeePerGas:_n,nonce:En,to:Cn,value:In,...An}=br,eo=(qr?numberToHex(qr):void 0)||Hr;assertRequest(br);const ro=(Br=(jr=(kr=fr.chain)==null?void 0:kr.formatters)==null?void 0:jr.transactionRequest)==null?void 0:Br.format,_i=(ro||formatTransactionRequest)({...extract(An,{format:ro}),from:Er==null?void 0:Er.address,accessList:Wr,data:Vr,gas:Zr,gasPrice:Jr,maxFeePerGas:Qr,maxPriorityFeePerGas:_n,nonce:En,to:Cn,value:In}),{baseFeePerGas:oo,gasLimit:io,priorityFeePerGas:co}=await fr.request({method:"linea_estimateGas",params:eo?[_i,eo]:[_i]});return{baseFeePerGas:BigInt(oo),gasLimit:BigInt(io),priorityFeePerGas:BigInt(co)}}catch(Wr){throw getCallError(Wr,{...br,account:Er,chain:fr.chain})}}const chainConfig={fees:{estimateFeesPerGas,async maxPriorityFeePerGas({block:fr,client:br,request:wr}){const Er=await estimateFeesPerGas({block:fr,client:br,multiply:kr=>kr,request:wr,type:"eip1559"});return Er!=null&&Er.maxPriorityFeePerGas?Er.maxPriorityFeePerGas:null}}};async function estimateFeesPerGas({client:fr,multiply:br,request:wr,type:Er}){try{const kr=await estimateGas(fr,{...wr,account:wr==null?void 0:wr.account}),{priorityFeePerGas:jr}=kr,Wr=br(BigInt(kr.baseFeePerGas))+jr;return Er==="legacy"?{gasPrice:Wr}:{maxFeePerGas:Wr,maxPriorityFeePerGas:jr}}catch{return null}}const linea=defineChain({...chainConfig,id:59144,name:"Linea Mainnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://lineascan.build",apiUrl:"https://api.lineascan.build/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:42}},testnet:!1}),lineaGoerli=defineChain({id:59140,name:"Linea Goerli Testnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.lineascan.build",apiUrl:"https://api-goerli.lineascan.build/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:498623}},testnet:!0}),lineaSepolia=defineChain({...chainConfig,id:59141,name:"Linea Sepolia Testnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.sepolia.linea.build"],webSocket:["wss://rpc.sepolia.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.lineascan.build",apiUrl:"https://api-sepolia.lineascan.build/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:227427}},testnet:!0}),lineaTestnet=defineChain({id:59140,name:"Linea Goerli Testnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.lineascan.build",apiUrl:"https://goerli.lineascan.build/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:498623}},testnet:!0}),sourceId$q=1,lisk=defineChain({...chainConfig$2,id:1135,name:"Lisk",network:"lisk",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.api.lisk.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://blockscout.lisk.com",apiUrl:"https://blockscout.lisk.com/api"}},contracts:{...chainConfig$2.contracts,multicall3:{address:"0xA9d71E1dd7ca26F26e656E66d6AA81ed7f745bf0"},l2OutputOracle:{[sourceId$q]:{address:"0x113cB99283AF242Da0A0C54347667edF531Aa7d6"}},portal:{[sourceId$q]:{address:"0x26dB93F8b8b4f7016240af62F7730979d353f9A7"}},l1StandardBridge:{[sourceId$q]:{address:"0x2658723Bf70c7667De6B25F99fcce13A16D25d08"}}},sourceId:sourceId$q}),sourceId$p=11155111,liskSepolia=defineChain({...chainConfig$2,id:4202,network:"lisk-sepolia",name:"Lisk Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.sepolia-api.lisk.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-blockscout.lisk.com",apiUrl:"https://sepolia-blockscout.lisk.com/api"}},contracts:{...chainConfig$2.contracts,l2OutputOracle:{[sourceId$p]:{address:"0xA0E35F56C318DE1bD5D9ca6A94Fe7e37C5663348"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11"},portal:{[sourceId$p]:{address:"0xe3d90F21490686Ec7eF37BE788E02dfC12787264"}},l1StandardBridge:{[sourceId$p]:{address:"0x1Fb30e446eA791cd1f011675E5F3f5311b70faF5"}}},testnet:!0,sourceId:sourceId$p}),localhost=defineChain({id:1337,name:"Localhost",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["http://127.0.0.1:8545"]}}}),loop=defineChain({id:15551,name:"LoopNetwork Mainnet",nativeCurrency:{name:"LOOP",symbol:"LOOP",decimals:18},rpcUrls:{default:{http:["https://api.mainnetloop.com"]}},blockExplorers:{default:{name:"LoopNetwork Blockchain Explorer",url:"https://explorer.mainnetloop.com/"}},testnet:!1}),lukso=defineChain({id:42,network:"lukso",name:"LUKSO",nativeCurrency:{name:"LUKSO",symbol:"LYX",decimals:18},rpcUrls:{default:{http:["https://rpc.mainnet.lukso.network"],webSocket:["wss://ws-rpc.mainnet.lukso.network"]}},blockExplorers:{default:{name:"LUKSO Mainnet Explorer",url:"https://explorer.execution.mainnet.lukso.network",apiUrl:"https://api.explorer.execution.mainnet.lukso.network/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:468183}}}),luksoTestnet=defineChain({id:4201,name:"LUKSO Testnet",nativeCurrency:{decimals:18,name:"LUKSO Testnet",symbol:"LYXt"},rpcUrls:{default:{http:["https://rpc.testnet.lukso.network"],webSocket:["wss://ws-rpc.testnet.lukso.network"]}},blockExplorers:{default:{name:"LUKSO Testnet Explorer",url:"https://explorer.execution.testnet.lukso.network",apiUrl:"https://api.explorer.execution.testnet.lukso.network/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:605348}},testnet:!0}),lycan=defineChain({id:721,name:"Lycan",nativeCurrency:{decimals:18,name:"Lycan",symbol:"LYC"},rpcUrls:{default:{http:["https://rpc.lycanchain.com","https://us-east.lycanchain.com","https://us-west.lycanchain.com","https://eu-north.lycanchain.com","https://eu-west.lycanchain.com","https://asia-southeast.lycanchain.com"],webSocket:["wss://rpc.lycanchain.com","wss://us-east.lycanchain.com","wss://us-west.lycanchain.com","wss://eu-north.lycanchain.com","wss://eu-west.lycanchain.com","wss://asia-southeast.lycanchain.com"]}},blockExplorers:{default:{name:"Lycan Explorer",url:"https://explorer.lycanchain.com"}}}),lyra=defineChain({id:957,name:"Lyra Chain",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.lyra.finance"]}},blockExplorers:{default:{name:"Lyra Explorer",url:"https://explorer.lyra.finance",apiUrl:"https://explorer.lyra.finance/api/v2"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1935198}}}),mainnet=defineChain({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://cloudflare-eth.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xce01f8eee7E479C928F8919abD53E553a36CeF67",blockCreated:19258213},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),mandala=defineChain({id:595,name:"Mandala TC9",network:"mandala",nativeCurrency:{name:"Mandala",symbol:"mACA",decimals:18},rpcUrls:{default:{http:["https://eth-rpc-tc9.aca-staging.network"],webSocket:["wss://eth-rpc-tc9.aca-staging.network"]}},blockExplorers:{default:{name:"Mandala Blockscout",url:"https://blockscout.mandala.aca-staging.network",apiUrl:"https://blockscout.mandala.aca-staging.network/api"}},testnet:!0}),manta=defineChain({id:169,name:"Manta Pacific Mainnet",network:"manta",nativeCurrency:{decimals:18,name:"ETH",symbol:"ETH"},rpcUrls:{default:{http:["https://pacific-rpc.manta.network/http"]}},blockExplorers:{default:{name:"Manta Explorer",url:"https://pacific-explorer.manta.network",apiUrl:"https://pacific-explorer.manta.network/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:332890}}}),mantaSepoliaTestnet=defineChain({id:3441006,name:"Manta Pacific Sepolia Testnet",network:"manta-sepolia",nativeCurrency:{decimals:18,name:"ETH",symbol:"ETH"},rpcUrls:{default:{http:["https://pacific-rpc.sepolia-testnet.manta.network/http"]}},blockExplorers:{default:{name:"Manta Sepolia Testnet Explorer",url:"https://pacific-explorer.sepolia-testnet.manta.network",apiUrl:"https://pacific-explorer.sepolia-testnet.manta.network/api"}},contracts:{multicall3:{address:"0xca54918f7B525C8df894668846506767412b53E3",blockCreated:479584}},testnet:!0}),mantaTestnet=defineChain({id:3441005,name:"Manta Pacific Testnet",network:"manta-testnet",nativeCurrency:{decimals:18,name:"ETH",symbol:"ETH"},rpcUrls:{default:{http:["https://manta-testnet.calderachain.xyz/http"]}},blockExplorers:{default:{name:"Manta Testnet Explorer",url:"https://pacific-explorer.testnet.manta.network",apiUrl:"https://pacific-explorer.testnet.manta.network/api"}},contracts:{multicall3:{address:"0x211B1643b95Fe76f11eD8880EE810ABD9A4cf56C",blockCreated:419915}},testnet:!0}),mantle=defineChain({id:5e3,name:"Mantle",nativeCurrency:{decimals:18,name:"MNT",symbol:"MNT"},rpcUrls:{default:{http:["https://rpc.mantle.xyz"]}},blockExplorers:{default:{name:"Mantle Explorer",url:"https://mantlescan.xyz/",apiUrl:"https://api.mantlescan.xyz/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:304717}}}),mantleSepoliaTestnet=defineChain({id:5003,name:"Mantle Sepolia Testnet",nativeCurrency:{decimals:18,name:"MNT",symbol:"MNT"},rpcUrls:{default:{http:["https://rpc.sepolia.mantle.xyz"]}},blockExplorers:{default:{name:"Mantle Testnet Explorer",url:"https://explorer.sepolia.mantle.xyz/",apiUrl:"https://explorer.sepolia.mantle.xyz/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:4584012}},testnet:!0}),mantleTestnet=defineChain({id:5001,name:"Mantle Testnet",nativeCurrency:{decimals:18,name:"MNT",symbol:"MNT"},rpcUrls:{default:{http:["https://rpc.testnet.mantle.xyz"]}},blockExplorers:{default:{name:"Mantle Testnet Explorer",url:"https://explorer.testnet.mantle.xyz",apiUrl:"https://explorer.testnet.mantle.xyz/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:561333}},testnet:!0}),mapProtocol=defineChain({id:22776,name:"MAP Protocol",nativeCurrency:{decimals:18,name:"MAPO",symbol:"MAPO"},rpcUrls:{default:{http:["https://rpc.maplabs.io"]}},blockExplorers:{default:{name:"MAPO Scan",url:"https://maposcan.io"}},testnet:!1}),matchain=defineChain({id:698,name:"Matchain",nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18},rpcUrls:{default:{http:["https://rpc.matchain.io"]}},blockExplorers:{default:{name:"Matchain Scan",url:"https://matchscan.io"}}}),matchainTestnet=defineChain({id:699,name:"Matchain Testnet",nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18},rpcUrls:{default:{http:["https://testnet-rpc.matchain.io"]}},blockExplorers:{default:{name:"Matchain Scan",url:"https://testnet.matchscan.io"}},testnet:!0}),mchVerse=defineChain({id:29548,name:"MCH Verse",nativeCurrency:{name:"Oasys",symbol:"OAS",decimals:18},rpcUrls:{default:{http:["https://rpc.oasys.mycryptoheroes.net"]}},blockExplorers:{default:{name:"MCH Verse Explorer",url:"https://explorer.oasys.mycryptoheroes.net",apiUrl:"https://explorer.oasys.mycryptoheroes.net/api"}},testnet:!1}),mekong=defineChain({id:7078815900,name:"Mekong Pectra Devnet",nativeCurrency:{name:"eth",symbol:"eth",decimals:18},rpcUrls:{default:{http:["https://rpc.mekong.ethpandaops.io"]}},blockExplorers:{default:{name:"Block Explorer",url:"https://explorer.mekong.ethpandaops.io"}},testnet:!0}),meld=defineChain({id:333000333,name:"Meld",nativeCurrency:{decimals:18,name:"Meld",symbol:"MELD"},rpcUrls:{default:{http:["https://rpc-1.meld.com"]}},blockExplorers:{default:{name:"MELDscan",url:"https://meldscan.io"}},contracts:{multicall3:{address:"0x769ee5a8e82c15c1b6e358f62ac8eb6e3abe8dc5",blockCreated:360069}}}),merlin=defineChain({id:4200,name:"Merlin",nativeCurrency:{name:"BTC",symbol:"BTC",decimals:18},rpcUrls:{default:{http:["https://rpc.merlinchain.io"]}},blockExplorers:{default:{name:"blockscout",url:"https://scan.merlinchain.io",apiUrl:"https://scan.merlinchain.io/api"}}}),metachain=defineChain({id:571,name:"MetaChain Mainnet",nativeCurrency:{name:"Metatime Coin",symbol:"MTC",decimals:18},rpcUrls:{default:{http:["https://rpc.metatime.com"]}},blockExplorers:{default:{name:"MetaExplorer",url:"https://explorer.metatime.com"}},contracts:{multicall3:{address:"0x0000000000000000000000000000000000003001",blockCreated:0}}}),metachainIstanbul=defineChain({id:1453,name:"MetaChain Istanbul",nativeCurrency:{name:"Metatime Coin",symbol:"MTC",decimals:18},rpcUrls:{default:{http:["https://istanbul-rpc.metachain.dev"]}},blockExplorers:{default:{name:"MetaExplorer",url:"https://istanbul-explorer.metachain.dev"}},contracts:{multicall3:{address:"0x0000000000000000000000000000000000003001",blockCreated:0}},testnet:!0}),metadium=defineChain({id:11,name:"Metadium Network",nativeCurrency:{decimals:18,name:"META",symbol:"META"},rpcUrls:{default:{http:["https://api.metadium.com/prod"]}},blockExplorers:{default:{name:"Metadium Explorer",url:"https://explorer.metadium.com"}},testnet:!1}),sourceId$o=1,metalL2=defineChain({...chainConfig$2,id:1750,name:"Metal L2",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.metall2.com"],webSocket:["wss://rpc.metall2.com"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.metall2.com",apiUrl:"https://explorer.metall2.com/api"}},contracts:{...chainConfig$2.contracts,l2OutputOracle:{[sourceId$o]:{address:"0x3B1F7aDa0Fcc26B13515af752Dd07fB1CAc11426"}},multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:0},portal:{[sourceId$o]:{address:"0x3F37aBdE2C6b5B2ed6F8045787Df1ED1E3753956"}},l1StandardBridge:{[sourceId$o]:{address:"0x6d0f65D59b55B0FEC5d2d15365154DcADC140BF3"}}},sourceId:sourceId$o}),meter=defineChain({id:82,name:"Meter",nativeCurrency:{decimals:18,name:"MTR",symbol:"MTR"},rpcUrls:{default:{http:["https://rpc.meter.io"]}},blockExplorers:{default:{name:"MeterScan",url:"https://scan.meter.io"}}}),meterTestnet=defineChain({id:83,name:"Meter Testnet",nativeCurrency:{decimals:18,name:"MTR",symbol:"MTR"},rpcUrls:{default:{http:["https://rpctest.meter.io"]}},blockExplorers:{default:{name:"MeterTestnetScan",url:"https://scan-warringstakes.meter.io"}}}),metis=defineChain({id:1088,name:"Metis",nativeCurrency:{decimals:18,name:"Metis",symbol:"METIS"},rpcUrls:{default:{http:["https://andromeda.metis.io/?owner=1088"]}},blockExplorers:{default:{name:"Metis Explorer",url:"https://explorer.metis.io",apiUrl:"https://api.routescan.io/v2/network/mainnet/evm/1088/etherscan/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:2338552}}}),metisGoerli=defineChain({id:599,name:"Metis Goerli",nativeCurrency:{decimals:18,name:"Metis Goerli",symbol:"METIS"},rpcUrls:{default:{http:["https://goerli.gateway.metisdevops.link"]}},blockExplorers:{default:{name:"Metis Goerli Explorer",url:"https://goerli.explorer.metisdevops.link",apiUrl:"https://goerli.explorer.metisdevops.link/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1006207}}}),mev=defineChain({id:7518,name:"MEVerse Chain Mainnet",nativeCurrency:{decimals:18,name:"MEVerse",symbol:"MEV"},rpcUrls:{default:{http:["https://rpc.meversemainnet.io"]}},blockExplorers:{default:{name:"Explorer",url:"https://www.meversescan.io"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:86881340}}}),mevTestnet=defineChain({id:4759,name:"MEVerse Chain Testnet",nativeCurrency:{decimals:18,name:"MEVerse",symbol:"MEV"},rpcUrls:{default:{http:["https://rpc.meversetestnet.io"]}},blockExplorers:{default:{name:"Explorer",url:"https://testnet.meversescan.io/"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:64371115}},testnet:!0}),mint=defineChain({id:185,name:"Mint Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.mintchain.io"]}},blockExplorers:{default:{name:"Mintchain explorer",url:"https://explorer.mintchain.io"}},testnet:!1}),mintSepoliaTestnet=defineChain({id:1686,name:"Mint Sepolia Testnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://testnet-rpc.mintchain.io"]}},blockExplorers:{default:{name:"Mintchain Testnet explorer",url:"https://testnet-explorer.mintchain.io"}},testnet:!0}),sourceId$n=1,mode=defineChain({...chainConfig$2,id:34443,name:"Mode Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.mode.network"]}},blockExplorers:{default:{name:"Modescan",url:"https://modescan.io"}},contracts:{...chainConfig$2.contracts,multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:2465882},l2OutputOracle:{[sourceId$n]:{address:"0x4317ba146D4933D889518a3e5E11Fe7a53199b04"}},portal:{[sourceId$n]:{address:"0x8B34b14c7c7123459Cf3076b8Cb929BE097d0C07"}},l1StandardBridge:{[sourceId$n]:{address:"0x735aDBbE72226BD52e818E7181953f42E3b0FF21"}}},sourceId:sourceId$n}),sourceId$m=11155111,modeTestnet=defineChain({...chainConfig$2,id:919,name:"Mode Testnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.mode.network"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia.explorer.mode.network",apiUrl:"https://sepolia.explorer.mode.network/api"}},contracts:{...chainConfig$2.contracts,l2OutputOracle:{[sourceId$m]:{address:"0x2634BD65ba27AB63811c74A63118ACb312701Bfa",blockCreated:3778393}},portal:{[sourceId$m]:{address:"0x320e1580effF37E008F1C92700d1eBa47c1B23fD",blockCreated:3778395}},l1StandardBridge:{[sourceId$m]:{address:"0xbC5C679879B2965296756CD959C3C739769995E2",blockCreated:3778392}},multicall3:{address:"0xBAba8373113Fb7a68f195deF18732e01aF8eDfCF",blockCreated:3019007}},testnet:!0,sourceId:sourceId$m}),moonbaseAlpha=defineChain({id:1287,name:"Moonbase Alpha",nativeCurrency:{decimals:18,name:"DEV",symbol:"DEV"},rpcUrls:{default:{http:["https://rpc.api.moonbase.moonbeam.network"],webSocket:["wss://wss.api.moonbase.moonbeam.network"]}},blockExplorers:{default:{name:"Moonscan",url:"https://moonbase.moonscan.io",apiUrl:"https://moonbase.moonscan.io/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:1850686}},testnet:!0}),moonbeam=defineChain({id:1284,name:"Moonbeam",nativeCurrency:{decimals:18,name:"GLMR",symbol:"GLMR"},rpcUrls:{default:{http:["https://moonbeam.public.blastapi.io"],webSocket:["wss://moonbeam.public.blastapi.io"]}},blockExplorers:{default:{name:"Moonscan",url:"https://moonscan.io",apiUrl:"https://api-moonbeam.moonscan.io/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:609002}},testnet:!1}),moonbeamDev=defineChain({id:1281,name:"Moonbeam Development Node",nativeCurrency:{decimals:18,name:"DEV",symbol:"DEV"},rpcUrls:{default:{http:["http://127.0.0.1:9944"],webSocket:["wss://127.0.0.1:9944"]}}}),moonriver=defineChain({id:1285,name:"Moonriver",nativeCurrency:{decimals:18,name:"MOVR",symbol:"MOVR"},rpcUrls:{default:{http:["https://moonriver.public.blastapi.io"],webSocket:["wss://moonriver.public.blastapi.io"]}},blockExplorers:{default:{name:"Moonscan",url:"https://moonriver.moonscan.io",apiUrl:"https://api-moonriver.moonscan.io/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:1597904}},testnet:!1}),morph=defineChain({id:2818,name:"Morph",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.morphl2.io"],webSocket:["wss://rpc.morphl2.io:8443"]}},blockExplorers:{default:{name:"Morph Explorer",url:"https://explorer.morphl2.io"}},testnet:!1}),morphHolesky=defineChain({id:2810,name:"Morph Holesky",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc-quicknode-holesky.morphl2.io"],webSocket:["wss://rpc-quicknode-holesky.morphl2.io"]}},blockExplorers:{default:{name:"Morph Holesky Explorer",url:"https://explorer-holesky.morphl2.io",apiUrl:"https://explorer-api-holesky.morphl2.io/api?"}},testnet:!0}),morphSepolia=defineChain({id:2710,name:"Morph Sepolia",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc-testnet.morphl2.io"]}},blockExplorers:{default:{name:"Morph Testnet Explorer",url:"https://explorer-testnet.morphl2.io",apiUrl:"https://explorer-api-testnet.morphl2.io/api"}},testnet:!0}),nahmii=defineChain({id:5551,name:"Nahmii 2 Mainnet",nativeCurrency:{decimals:18,name:"ETH",symbol:"ETH"},rpcUrls:{default:{http:["https://l2.nahmii.io"]}},blockExplorers:{default:{name:"Nahmii 2 Explorer",url:"https://explorer.n2.nahmii.io"}},testnet:!1}),nautilus=defineChain({id:22222,name:"Nautilus Mainnet",nativeCurrency:{name:"ZBC",symbol:"ZBC",decimals:9},rpcUrls:{default:{http:["https://api.nautilus.nautchain.xyz"]}},blockExplorers:{default:{name:"NautScan",url:"https://nautscan.com"}}}),neonDevnet=defineChain({id:245022926,name:"Neon EVM DevNet",nativeCurrency:{name:"NEON",symbol:"NEON",decimals:18},rpcUrls:{default:{http:["https://devnet.neonevm.org"]}},blockExplorers:{default:{name:"Neonscan",url:"https://devnet.neonscan.org"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:205206112}},testnet:!0}),neonMainnet=defineChain({id:245022934,network:"neonMainnet",name:"Neon EVM MainNet",nativeCurrency:{name:"NEON",symbol:"NEON",decimals:18},rpcUrls:{default:{http:["https://neon-proxy-mainnet.solana.p2p.org"]}},blockExplorers:{default:{name:"Neonscan",url:"https://neonscan.org"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:206545524}},testnet:!1}),nexi=defineChain({id:4242,name:"Nexi",nativeCurrency:{name:"Nexi",symbol:"NEXI",decimals:18},rpcUrls:{default:{http:["https://rpc.chain.nexi.technology"]}},blockExplorers:{default:{name:"NexiScan",url:"https://www.nexiscan.com",apiUrl:"https://www.nexiscan.com/api"}},contracts:{multicall3:{address:"0x0277A46Cc69A57eE3A6C8c158bA874832F718B8E",blockCreated:25770160}}}),nexilix=defineChain({id:240,name:"Nexilix Smart Chain",nativeCurrency:{decimals:18,name:"Nexilix",symbol:"NEXILIX"},rpcUrls:{default:{http:["https://rpcurl.pos.nexilix.com"]}},blockExplorers:{default:{name:"NexilixScan",url:"https://scan.nexilix.com"}},contracts:{multicall3:{address:"0x58381c8e2BF9d0C2C4259cA14BdA9Afe02831244",blockCreated:74448}}}),oasisTestnet=defineChain({id:4090,network:"oasis-testnet",name:"Oasis Testnet",nativeCurrency:{name:"Fasttoken",symbol:"FTN",decimals:18},rpcUrls:{default:{http:["https://rpc1.oasis.bahamutchain.com"]}},blockExplorers:{default:{name:"Ftnscan",url:"https://oasis.ftnscan.com",apiUrl:"https://oasis.ftnscan.com/api"}},testnet:!0}),oasys=defineChain({id:248,name:"Oasys",nativeCurrency:{name:"Oasys",symbol:"OAS",decimals:18},rpcUrls:{default:{http:["https://rpc.mainnet.oasys.games"]}},blockExplorers:{default:{name:"OasysScan",url:"https://scan.oasys.games",apiUrl:"https://scan.oasys.games/api"}}}),odysseyTestnet=defineChain({id:911867,name:"Odyssey Testnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://odyssey.ithaca.xyz"]}},blockExplorers:{default:{name:"Odyssey Explorer",url:"https://odyssey-explorer.ithaca.xyz",apiUrl:"https://odyssey-explorer.ithaca.xyz/api"}},testnet:!0}),okc=defineChain({id:66,name:"OKC",nativeCurrency:{decimals:18,name:"OKT",symbol:"OKT"},rpcUrls:{default:{http:["https://exchainrpc.okex.org"]}},blockExplorers:{default:{name:"oklink",url:"https://www.oklink.com/okc"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:10364792}}}),omax=defineChain({id:311,name:"Omax Mainnet",nativeCurrency:{decimals:18,name:"OMAX",symbol:"OMAX"},rpcUrls:{default:{http:["https://mainapi.omaxray.com"]}},blockExplorers:{default:{name:"Omax Explorer",url:"https://omaxscan.com"}},testnet:!1}),oneWorld=defineChain({id:309075,name:"One World Chain Mainnet",nativeCurrency:{decimals:18,name:"OWCT",symbol:"OWCT"},rpcUrls:{default:{http:["https://mainnet-rpc.oneworldchain.org"]}},blockExplorers:{default:{name:"One World Explorer",url:"https://mainnet.oneworldchain.org"}},testnet:!1}),oortMainnetDev=defineChain({id:9700,name:"OORT MainnetDev",nativeCurrency:{decimals:18,name:"OORT",symbol:"OORT"},rpcUrls:{default:{http:["https://dev-rpc.oortech.com"]}},blockExplorers:{default:{name:"OORT MainnetDev Explorer",url:"https://dev-scan.oortech.com"}}}),sourceId$l=56,opBNB=defineChain({id:204,name:"opBNB",nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18},rpcUrls:{default:{http:["https://opbnb-mainnet-rpc.bnbchain.org"]}},blockExplorers:{default:{name:"opBNB (BSCScan)",url:"https://opbnb.bscscan.com",apiUrl:"https://api-opbnb.bscscan.com/api"}},contracts:{...chainConfig$2.contracts,multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:512881},l2OutputOracle:{[sourceId$l]:{address:"0x153CAB79f4767E2ff862C94aa49573294B13D169"}},portal:{[sourceId$l]:{address:"0x1876EA7702C0ad0C6A2ae6036DE7733edfBca519"}},l1StandardBridge:{[sourceId$l]:{address:"0xF05F0e4362859c3331Cb9395CBC201E3Fa6757Ea"}}},sourceId:sourceId$l}),sourceId$k=97,opBNBTestnet=defineChain({id:5611,name:"opBNB Testnet",nativeCurrency:{decimals:18,name:"tBNB",symbol:"tBNB"},rpcUrls:{default:{http:["https://opbnb-testnet-rpc.bnbchain.org"]}},blockExplorers:{default:{name:"opbnbscan",url:"https://testnet.opbnbscan.com"}},contracts:{...chainConfig$2.contracts,multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:3705108},l2OutputOracle:{[sourceId$k]:{address:"0xFf2394Bb843012562f4349C6632a0EcB92fC8810"}},portal:{[sourceId$k]:{address:"0x4386C8ABf2009aC0c263462Da568DD9d46e52a31"}},l1StandardBridge:{[sourceId$k]:{address:"0x677311Fd2cCc511Bbc0f581E8d9a07B033D5E840"}}},testnet:!0,sourceId:sourceId$k}),sourceId$j=1,optimism=defineChain({...chainConfig$2,id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimism Explorer",url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io/api"}},contracts:{...chainConfig$2.contracts,disputeGameFactory:{[sourceId$j]:{address:"0xe5965Ab5962eDc7477C8520243A95517CD252fA9"}},l2OutputOracle:{[sourceId$j]:{address:"0xdfe97868233d1aa22e815a266982f2cf17685a27"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:4286263},portal:{[sourceId$j]:{address:"0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"}},l1StandardBridge:{[sourceId$j]:{address:"0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"}}},sourceId:sourceId$j}),sourceId$i=5,optimismGoerli=defineChain({...chainConfig$2,id:420,name:"Optimism Goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://goerli.optimism.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io",apiUrl:"https://goerli-optimism.etherscan.io/api"}},contracts:{...chainConfig$2.contracts,l2OutputOracle:{[sourceId$i]:{address:"0xE6Dfba0953616Bacab0c9A8ecb3a9BBa77FC15c0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:49461},portal:{[sourceId$i]:{address:"0x5b47E1A08Ea6d985D6649300584e6722Ec4B1383"}},l1StandardBridge:{[sourceId$i]:{address:"0x636Af16bf2f682dD3109e60102b8E1A089FedAa8"}}},testnet:!0,sourceId:sourceId$i}),sourceId$h=11155111,optimismSepolia=defineChain({...chainConfig$2,id:11155420,name:"OP Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.optimism.io"]}},blockExplorers:{default:{name:"Blockscout",url:"https://optimism-sepolia.blockscout.com",apiUrl:"https://optimism-sepolia.blockscout.com/api"}},contracts:{...chainConfig$2.contracts,disputeGameFactory:{[sourceId$h]:{address:"0x05F9613aDB30026FFd634f38e5C4dFd30a197Fa1"}},l2OutputOracle:{[sourceId$h]:{address:"0x90E9c4f8a994a250F6aEfd61CAFb4F2e895D458F"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1620204},portal:{[sourceId$h]:{address:"0x16Fc5058F25648194471939df75CF27A2fdC48BC"}},l1StandardBridge:{[sourceId$h]:{address:"0xFBb0621E0B23b5478B630BD55a5f21f67730B0F1"}}},testnet:!0,sourceId:sourceId$h}),optopia=defineChain({id:62050,name:"Optopia",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc-mainnet.optopia.ai"]}},blockExplorers:{default:{name:"Optopia Explorer",url:"https://scan.optopia.ai"}},testnet:!1}),optopiaTestnet=defineChain({id:62049,name:"Optopia Testnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc-testnet.optopia.ai"]}},blockExplorers:{default:{name:"Optopia Explorer",url:"https://scan-testnet.optopia.ai"}},testnet:!0}),orderly=defineChain({id:291,name:"Orderly",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.orderly.network"]}},blockExplorers:{default:{name:"Orderly Explorer",url:"https://explorer.orderly.network"}},testnet:!1}),orderlySepolia=defineChain({id:4460,name:"Orderly Sepolia",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://l2-orderly-l2-4460-sepolia-8tc3sd7dvy.t.conduit.xyz"]}},blockExplorers:{default:{name:"Orderly Explorer",url:"https://explorerl2new-orderly-l2-4460-sepolia-8tc3sd7dvy.t.conduit.xyz"}},testnet:!0}),otimDevnet=defineChain({id:41144114,name:"Otim Devnet",nativeCurrency:{decimals:18,name:"ETH",symbol:"ETH"},rpcUrls:{default:{http:["http://devnet.otim.xyz"]}},contracts:{batchInvoker:{address:"0x5FbDB2315678afecb367f032d93F642f64180aa3"}}}),palm=defineChain({id:11297108109,name:"Palm",nativeCurrency:{decimals:18,name:"PALM",symbol:"PALM"},rpcUrls:{default:{http:["https://palm-mainnet.public.blastapi.io"],webSocket:["wss://palm-mainnet.public.blastapi.io"]}},blockExplorers:{default:{name:"Chainlens",url:"https://palm.chainlens.com"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:15429248}}}),palmTestnet=defineChain({id:11297108099,name:"Palm Testnet",nativeCurrency:{decimals:18,name:"PALM",symbol:"PALM"},rpcUrls:{default:{http:["https://palm-mainnet.public.blastapi.io"],webSocket:["wss://palm-mainnet.public.blastapi.io"]}},blockExplorers:{default:{name:"Chainlens",url:"https://palm.chainlens.com"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:15429248}},testnet:!0}),sourceId$g=1,pgn=defineChain({id:424,network:"pgn",name:"PGN",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.publicgoods.network"]}},blockExplorers:{default:{name:"PGN Explorer",url:"https://explorer.publicgoods.network",apiUrl:"https://explorer.publicgoods.network/api"}},contracts:{l2OutputOracle:{[sourceId$g]:{address:"0x9E6204F750cD866b299594e2aC9eA824E2e5f95c"}},multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:3380209},portal:{[sourceId$g]:{address:"0xb26Fd985c5959bBB382BAFdD0b879E149e48116c"}},l1StandardBridge:{[sourceId$g]:{address:"0xD0204B9527C1bA7bD765Fa5CCD9355d38338272b"}}},formatters:formatters$1,sourceId:sourceId$g}),sourceId$f=11155111,pgnTestnet=defineChain({id:58008,network:"pgn-testnet",name:"PGN ",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.publicgoods.network"]}},blockExplorers:{default:{name:"PGN Testnet Explorer",url:"https://explorer.sepolia.publicgoods.network",apiUrl:"https://explorer.sepolia.publicgoods.network/api"}},contracts:{l2OutputOracle:{[sourceId$f]:{address:"0xD5bAc3152ffC25318F848B3DD5dA6C85171BaEEe"}},portal:{[sourceId$f]:{address:"0xF04BdD5353Bb0EFF6CA60CfcC78594278eBfE179"}},l1StandardBridge:{[sourceId$f]:{address:"0xFaE6abCAF30D23e233AC7faF747F2fC3a5a6Bfa3"}},multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:3754925}},formatters:formatters$1,sourceId:sourceId$f,testnet:!0}),phoenix=defineChain({id:13381,name:"Phoenix Blockchain",nativeCurrency:{name:"Phoenix",symbol:"PHX",decimals:18},rpcUrls:{default:{http:["https://rpc.phoenixplorer.com"]}},blockExplorers:{default:{name:"Phoenixplorer",url:"https://phoenixplorer.com",apiUrl:"https://phoenixplorer.com/api"}},contracts:{multicall3:{address:"0x498cF757a575cFF2c2Ed9f532f56Efa797f86442",blockCreated:5620192}}}),planq=defineChain({id:7070,name:"Planq Mainnet",nativeCurrency:{decimals:18,name:"PLQ",symbol:"PLQ"},rpcUrls:{default:{http:["https://evm-rpc.planq.network"]}},blockExplorers:{default:{name:"Planq Explorer",url:"https://evm.planq.network"}},testnet:!1}),playfiAlbireo=defineChain({...chainConfig$3,id:1612127,name:"PlayFi Albireo Testnet",network:"albireo",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://albireo-rpc.playfi.ai"],webSocket:["wss://albireo-rpc-ws.playfi.ai/ws"]}},blockExplorers:{default:{name:"PlayFi Albireo Explorer",url:"https://albireo-explorer.playfi.ai"}},contracts:{multicall3:{address:"0xF9cda624FBC7e059355ce98a31693d299FACd963"}},testnet:!0}),plinga=defineChain({id:242,name:"Plinga",nativeCurrency:{name:"Plinga",symbol:"PLINGA",decimals:18},rpcUrls:{default:{http:["https://rpcurl.mainnet.plgchain.com"]}},blockExplorers:{default:{name:"Plgscan",url:"https://www.plgscan.com"}},contracts:{multicall3:{address:"0x0989576160f2e7092908BB9479631b901060b6e4",blockCreated:204489}}}),sourceId$e=11155111,plumeTestnet=defineChain({id:161221135,name:"Plume Testnet",nativeCurrency:{name:"Plume Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://testnet-rpc.plumenetwork.xyz/http"],webSocket:["wss://testnet-rpc.plumenetwork.xyz/ws"]}},blockExplorers:{default:{name:"Blockscout",url:"https://testnet-explorer.plumenetwork.xyz",apiUrl:"https://testnet-explorer.plumenetwork.xyz/api"}},testnet:!0,sourceId:sourceId$e}),polterTestnet=defineChain({id:631571,name:"Polter Testnet",nativeCurrency:{decimals:18,name:"Polter GHST",symbol:"GHST"},rpcUrls:{default:{http:["https://geist-polter.g.alchemy.com/public"]}},blockExplorers:{default:{name:"Blockscout",url:"https://polter-testnet.explorer.alchemy.com"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:11245}},testnet:!0}),polygon=defineChain({id:137,name:"Polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:25770160}}}),polygonAmoy=defineChain({id:80002,name:"Polygon Amoy",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://amoy.polygonscan.com",apiUrl:"https://api-amoy.polygonscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:3127388}},testnet:!0}),polygonMumbai=defineChain({id:80001,name:"Polygon Mumbai",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{default:{http:["https://rpc.ankr.com/polygon_mumbai"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://mumbai.polygonscan.com",apiUrl:"https://api-testnet.polygonscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:25770160}},testnet:!0}),polygonZkEvm=defineChain({id:1101,name:"Polygon zkEVM",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://zkevm-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://zkevm.polygonscan.com",apiUrl:"https://api-zkevm.polygonscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:57746}}}),polygonZkEvmCardona=defineChain({id:2442,name:"Polygon zkEVM Cardona",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.cardona.zkevm-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://cardona-zkevm.polygonscan.com",apiUrl:"https://cardona-zkevm.polygonscan.com/api"}},testnet:!0,contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:114091}}}),polygonZkEvmTestnet=defineChain({id:1442,name:"Polygon zkEVM Testnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.public.zkevm-test.net"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://testnet-zkevm.polygonscan.com",apiUrl:"https://testnet-zkevm.polygonscan.com/api"}},testnet:!0,contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:525686}}}),pulsechain=defineChain({id:369,name:"PulseChain",nativeCurrency:{name:"Pulse",symbol:"PLS",decimals:18},testnet:!1,rpcUrls:{default:{http:["https://rpc.pulsechain.com"],webSocket:["wss://ws.pulsechain.com"]}},blockExplorers:{default:{name:"PulseScan",url:"https://scan.pulsechain.com",apiUrl:"https://api.scan.pulsechain.com/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),pulsechainV4=defineChain({id:943,name:"PulseChain V4",testnet:!0,nativeCurrency:{name:"V4 Pulse",symbol:"v4PLS",decimals:18},rpcUrls:{default:{http:["https://rpc.v4.testnet.pulsechain.com"],webSocket:["wss://ws.v4.testnet.pulsechain.com"]}},blockExplorers:{default:{name:"PulseScan",url:"https://scan.v4.testnet.pulsechain.com",apiUrl:"https://scan.v4.testnet.pulsechain.com/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),ql1=defineChain({id:766,name:"QL1",nativeCurrency:{decimals:18,name:"QOM",symbol:"QOM"},rpcUrls:{default:{http:["https://rpc.qom.one"]}},blockExplorers:{default:{name:"Ql1 Explorer",url:"https://scan.qom.one"}},contracts:{multicall3:{address:"0x7A52370716ea730585884F5BDB0f6E60C39b8C64"}},testnet:!1}),qMainnet=defineChain({id:35441,name:"Q Mainnet",nativeCurrency:{decimals:18,name:"Q",symbol:"Q"},rpcUrls:{default:{http:["https://rpc.q.org"]}},blockExplorers:{default:{name:"Q Mainnet Explorer",url:"https://explorer.q.org",apiUrl:"https://explorer.q.org/api"}}}),qTestnet=defineChain({id:35443,name:"Q Testnet",nativeCurrency:{decimals:18,name:"Q",symbol:"Q"},rpcUrls:{default:{http:["https://rpc.qtestnet.org"]}},blockExplorers:{default:{name:"Q Testnet Explorer",url:"https://explorer.qtestnet.org",apiUrl:"https://explorer.qtestnet.org/api"}},testnet:!0}),real=defineChain({id:111188,name:"re.al",nativeCurrency:{name:"reETH",decimals:18,symbol:"reETH"},rpcUrls:{default:{http:["https://real.drpc.org"]}},blockExplorers:{default:{name:"re.al Explorer",url:"https://explorer.re.al",apiUrl:"https://explorer.re.al/api/v2"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:695}}}),redbellyTestnet=defineChain({id:153,name:"Redbelly Network Testnet",nativeCurrency:{name:"Redbelly Native Coin",symbol:"RBNT",decimals:18},rpcUrls:{default:{http:["https://governors.testnet.redbelly.network"]}},blockExplorers:{default:{name:"Ethernal",url:"https://explorer.testnet.redbelly.network",apiUrl:"https://ethernal.fly.dev/api"}},testnet:!0}),sourceId$d=1,redstone=defineChain({...chainConfig$2,name:"Redstone",id:690,sourceId:sourceId$d,nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.redstonechain.com"],webSocket:["wss://rpc.redstonechain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.redstone.xyz"}},contracts:{...chainConfig$2.contracts,multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11"},portal:{[sourceId$d]:{address:"0xC7bCb0e8839a28A1cFadd1CF716de9016CdA51ae",blockCreated:19578329}},l2OutputOracle:{[sourceId$d]:{address:"0xa426A052f657AEEefc298b3B5c35a470e4739d69",blockCreated:19578337}},l1StandardBridge:{[sourceId$d]:{address:"0xc473ca7E02af24c129c2eEf51F2aDf0411c1Df69",blockCreated:19578331}}}}),rei=defineChain({id:47805,name:"REI Mainnet",nativeCurrency:{decimals:18,name:"REI",symbol:"REI"},rpcUrls:{default:{http:["https://rpc.rei.network"],webSocket:["wss://rpc.rei.network"]}},blockExplorers:{default:{name:"REI Scan",url:"https://scan.rei.network"}},testnet:!1}),reyaNetwork=defineChain({id:1729,name:"Reya Network",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.reya.network"],webSocket:["wss://ws.reya.network"]}},blockExplorers:{default:{name:"Reya Network Explorer",url:"https://explorer.reya.network"}},testnet:!1}),rollux=defineChain({id:570,name:"Rollux Mainnet",nativeCurrency:{decimals:18,name:"Syscoin",symbol:"SYS"},rpcUrls:{default:{http:["https://rpc.rollux.com"],webSocket:["wss://rpc.rollux.com/wss"]}},blockExplorers:{default:{name:"RolluxExplorer",url:"https://explorer.rollux.com",apiUrl:"https://explorer.rollux.com/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:119222}}}),rolluxTestnet=defineChain({id:57e3,name:"Rollux Testnet",nativeCurrency:{decimals:18,name:"Syscoin",symbol:"SYS"},rpcUrls:{default:{http:["https://rpc-tanenbaum.rollux.com/"],webSocket:["wss://rpc-tanenbaum.rollux.com/wss"]}},blockExplorers:{default:{name:"RolluxTestnetExplorer",url:"https://rollux.tanenbaum.io",apiUrl:"https://rollux.tanenbaum.io/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:1813675}}}),ronin=defineChain({id:2020,name:"Ronin",nativeCurrency:{name:"RON",symbol:"RON",decimals:18},rpcUrls:{default:{http:["https://api.roninchain.com/rpc"]}},blockExplorers:{default:{name:"Ronin Explorer",url:"https://app.roninchain.com"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:26023535}}}),root=defineChain({id:7668,name:"The Root Network",nativeCurrency:{decimals:18,name:"XRP",symbol:"XRP"},rpcUrls:{default:{http:["https://root.rootnet.live/archive"],webSocket:["wss://root.rootnet.live/archive/ws"]}},blockExplorers:{default:{name:"Rootscan",url:"https://rootscan.io"}},contracts:{multicall3:{address:"0xc9C2E2429AeC354916c476B30d729deDdC94988d",blockCreated:9218338}}}),rootPorcini=defineChain({id:7672,name:"The Root Network - Porcini",nativeCurrency:{decimals:18,name:"XRP",symbol:"XRP"},rpcUrls:{default:{http:["https://porcini.rootnet.app/archive"],webSocket:["wss://porcini.rootnet.app/archive/ws"]}},blockExplorers:{default:{name:"Rootscan",url:"https://porcini.rootscan.io"}},contracts:{multicall3:{address:"0xc9C2E2429AeC354916c476B30d729deDdC94988d",blockCreated:10555692}},testnet:!0}),rootstock=defineChain({id:30,name:"Rootstock Mainnet",network:"rootstock",nativeCurrency:{decimals:18,name:"Rootstock Bitcoin",symbol:"RBTC"},rpcUrls:{default:{http:["https://public-node.rsk.co"]}},blockExplorers:{default:{name:"RSK Explorer",url:"https://explorer.rsk.co"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:4249540}}}),rootstockTestnet=defineChain({id:31,name:"Rootstock Testnet",network:"rootstock",nativeCurrency:{decimals:18,name:"Rootstock Bitcoin",symbol:"tRBTC"},rpcUrls:{default:{http:["https://public-node.testnet.rsk.co"]}},blockExplorers:{default:{name:"RSK Explorer",url:"https://explorer.testnet.rootstock.io"}},testnet:!0}),sourceId$c=1,rss3=defineChain({...chainConfig$2,id:12553,name:"RSS3 VSL Mainnet",nativeCurrency:{name:"RSS3",symbol:"RSS3",decimals:18},rpcUrls:{default:{http:["https://rpc.rss3.io"]}},blockExplorers:{default:{name:"RSS3 VSL Mainnet Scan",url:"https://scan.rss3.io",apiUrl:"https://scan.rss3.io/api"}},contracts:{...chainConfig$2.contracts,l2OutputOracle:{[sourceId$c]:{address:"0xE6f24d2C32B3109B18ed33cF08eFb490b1e09C10"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14193},portal:{[sourceId$c]:{address:"0x6A12432491bbbE8d3babf75F759766774C778Db4",blockCreated:19387057}},l1StandardBridge:{[sourceId$c]:{address:"0x4cbab69108Aa72151EDa5A3c164eA86845f18438"}}},sourceId:sourceId$c}),sourceId$b=11155111,rss3Sepolia=defineChain({...chainConfig$2,id:2331,name:"RSS3 VSL Sepolia Testnet",nativeCurrency:{name:"RSS3",symbol:"RSS3",decimals:18},rpcUrls:{default:{http:["https://rpc.testnet.rss3.io"]}},blockExplorers:{default:{name:"RSS3 VSL Sepolia Testnet Scan",url:"https://scan.testnet.rss3.io",apiUrl:"https://scan.testnet.rss3.io/api"}},contracts:{...chainConfig$2.contracts,l2OutputOracle:{[sourceId$b]:{address:"0xDb5c46C3Eaa6Ed6aE8b2379785DF7dd029C0dC81"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:55697},portal:{[sourceId$b]:{address:"0xcBD77E8E1E7F06B25baDe67142cdE82652Da7b57",blockCreated:5345035}},l1StandardBridge:{[sourceId$b]:{address:"0xdDD29bb63B0839FB1cE0eE439Ff027738595D07B"}}},testnet:!0,sourceId:sourceId$b}),saakuru=defineChain({id:7225878,name:"Saakuru Mainnet",nativeCurrency:{name:"OAS",symbol:"OAS",decimals:18},rpcUrls:{default:{http:["https://rpc.saakuru.network"]}},blockExplorers:{default:{name:"Saakuru Explorer",url:"https://explorer.saakuru.network"}},testnet:!1}),saigon=defineChain({id:2021,name:"Saigon Testnet",nativeCurrency:{name:"RON",symbol:"RON",decimals:18},rpcUrls:{default:{http:["https://saigon-testnet.roninchain.com/rpc"]}},blockExplorers:{default:{name:"Saigon Explorer",url:"https://saigon-app.roninchain.com"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:18736871}},testnet:!0}),sanko=defineChain({id:1996,name:"Sanko",nativeCurrency:{name:"DMT",symbol:"DMT",decimals:18},rpcUrls:{default:{http:["https://mainnet.sanko.xyz"]}},blockExplorers:{default:{name:"Sanko Explorer",url:"https://explorer.sanko.xyz"}},testnet:!1}),sapphire=defineChain({id:23294,name:"Oasis Sapphire",network:"sapphire",nativeCurrency:{name:"Sapphire Rose",symbol:"ROSE",decimals:18},rpcUrls:{default:{http:["https://sapphire.oasis.io"],webSocket:["wss://sapphire.oasis.io/ws"]}},blockExplorers:{default:{name:"Oasis Explorer",url:"https://explorer.oasis.io/mainnet/sapphire"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:734531}}}),sapphireTestnet=defineChain({id:23295,name:"Oasis Sapphire Testnet",network:"sapphire-testnet",nativeCurrency:{name:"Sapphire Test Rose",symbol:"TEST",decimals:18},rpcUrls:{default:{http:["https://testnet.sapphire.oasis.dev"],webSocket:["wss://testnet.sapphire.oasis.dev/ws"]}},blockExplorers:{default:{name:"Oasis Explorer",url:"https://explorer.oasis.io/testnet/sapphire"}},testnet:!0}),satoshiVM=defineChain({id:3109,name:"SatoshiVM Alpha Mainnet",nativeCurrency:{name:"BTC",symbol:"BTC",decimals:18},rpcUrls:{default:{http:["https://alpha-rpc-node-http.svmscan.io"]}},blockExplorers:{default:{name:"blockscout",url:"https://svmscan.io",apiUrl:"https://svmscan.io/api"}}}),satoshiVMTestnet=defineChain({id:3110,name:"SatoshiVM Testnet",nativeCurrency:{name:"BTC",symbol:"BTC",decimals:18},rpcUrls:{default:{http:["https://test-rpc-node-http.svmscan.io"]}},blockExplorers:{default:{name:"blockscout",url:"https://testnet.svmscan.io",apiUrl:"https://testnet.svmscan.io/api"}},testnet:!0}),scroll=defineChain({id:534352,name:"Scroll",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.scroll.io"],webSocket:["wss://wss-rpc.scroll.io/ws"]}},blockExplorers:{default:{name:"Scrollscan",url:"https://scrollscan.com",apiUrl:"https://api.scrollscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14}},testnet:!1}),scrollSepolia=defineChain({id:534351,name:"Scroll Sepolia",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia-rpc.scroll.io"]}},blockExplorers:{default:{name:"Scrollscan",url:"https://sepolia.scrollscan.com",apiUrl:"https://api-sepolia.scrollscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:9473}},testnet:!0}),sei=defineChain({id:1329,name:"Sei Network",nativeCurrency:{name:"Sei",symbol:"SEI",decimals:18},rpcUrls:{default:{http:["https://evm-rpc.sei-apis.com/"],webSocket:["wss://evm-ws.sei-apis.com/"]}},blockExplorers:{default:{name:"Seitrace",url:"https://seitrace.com",apiUrl:"https://seitrace.com/pacific-1/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11"}}}),seiDevnet=defineChain({id:713715,name:"Sei Devnet",nativeCurrency:{name:"Sei",symbol:"SEI",decimals:18},rpcUrls:{default:{http:["https://evm-rpc-arctic-1.sei-apis.com"]}},blockExplorers:{default:{name:"Seitrace",url:"https://seitrace.com"}},testnet:!0}),seiTestnet=defineChain({id:1328,name:"Sei Testnet",nativeCurrency:{name:"Sei",symbol:"SEI",decimals:18},rpcUrls:{default:{http:["https://evm-rpc-testnet.sei-apis.com"],webSocket:["wss://evm-ws-testnet.sei-apis.com"]}},blockExplorers:{default:{name:"Seitrace",url:"https://seitrace.com"}},testnet:!0}),sepolia=defineChain({id:11155111,name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.drpc.org"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io",apiUrl:"https://api-sepolia.etherscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:751532},ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",blockCreated:5317080}},testnet:!0}),sourceId$a=1,shape=defineChain({...chainConfig$2,id:360,name:"Shape",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.shape.network"]}},blockExplorers:{default:{name:"shapescan",url:"https://shapescan.xyz",apiUrl:"https://shapescan.xyz/api"}},contracts:{...chainConfig$2.contracts,l2OutputOracle:{[sourceId$a]:{address:"0x6Ef8c69CfE4635d866e3E02732068022c06e724D",blockCreated:20369940}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1},portal:{[sourceId$a]:{address:"0xEB06fFa16011B5628BaB98E29776361c83741dd3",blockCreated:20369933}},l1StandardBridge:{[sourceId$a]:{address:"0x62Edd5f4930Ea92dCa3fB81689bDD9b9d076b57B",blockCreated:20369935}}},sourceId:sourceId$a}),sourceId$9=11155111,shapeSepolia=defineChain({...chainConfig$2,id:11011,name:"Shape Sepolia Testnet",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.shape.network"]}},blockExplorers:{default:{name:"blockscout",url:"https://explorer-sepolia.shape.network/",apiUrl:"https://explorer-sepolia.shape.network/api/v2"}},contracts:{...chainConfig$2.contracts,multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1}},testnet:!0,sourceId:sourceId$9}),shardeumSphinx=defineChain({id:8082,name:"Shardeum Sphinx",nativeCurrency:{name:"SHARDEUM",symbol:"SHM",decimals:18},rpcUrls:{default:{http:["https://sphinx.shardeum.org"]}},blockExplorers:{default:{name:"Shardeum Explorer",url:"https://explorer-sphinx.shardeum.org"}},testnet:!0}),shibarium=defineChain({id:109,name:"Shibarium",network:"shibarium",nativeCurrency:{name:"Bone",symbol:"BONE",decimals:18},rpcUrls:{default:{http:["https://rpc.shibrpc.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://shibariumscan.io"}},contracts:{multicall3:{address:"0x864Bf681ADD6052395188A89101A1B37d3B4C961",blockCreated:265900}}}),shibariumTestnet=defineChain({id:157,name:"Puppynet Shibarium",nativeCurrency:{decimals:18,name:"Bone",symbol:"BONE"},rpcUrls:{default:{http:["https://puppynet.shibrpc.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://puppyscan.shib.io",apiUrl:"https://puppyscan.shib.io/api"}},contracts:{multicall3:{address:"0xA4029b74FBA366c926eDFA7Dd10B21C621170a4c",blockCreated:3035769}},testnet:!0}),shiden=defineChain({id:336,name:"Shiden",nativeCurrency:{decimals:18,name:"SDN",symbol:"SDN"},rpcUrls:{default:{http:["https://shiden.public.blastapi.io"],webSocket:["wss://shiden-rpc.dwellir.com"]}},blockExplorers:{default:{name:"Shiden Scan",url:"https://shiden.subscan.io"}},testnet:!1}),shimmer=defineChain({id:148,name:"Shimmer",network:"shimmer",nativeCurrency:{decimals:18,name:"Shimmer",symbol:"SMR"},rpcUrls:{default:{http:["https://json-rpc.evm.shimmer.network"]}},blockExplorers:{default:{name:"Shimmer Network Explorer",url:"https://explorer.evm.shimmer.network",apiUrl:"https://explorer.evm.shimmer.network/api"}}}),shimmerTestnet=defineChain({id:1073,name:"Shimmer Testnet",network:"shimmer-testnet",nativeCurrency:{decimals:18,name:"Shimmer",symbol:"SMR"},rpcUrls:{default:{http:["https://json-rpc.evm.testnet.shimmer.network"]}},blockExplorers:{default:{name:"Shimmer Network Explorer",url:"https://explorer.evm.testnet.shimmer.network",apiUrl:"https://explorer.evm.testnet.shimmer.network/api"}},testnet:!0}),silicon=defineChain({id:2355,name:"Silicon zkEVM",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.silicon.network","https://silicon-mainnet.nodeinfra.com"]}},blockExplorers:{default:{name:"SiliconScope",url:"https://scope.silicon.network"}}}),siliconSepolia=defineChain({id:1722641160,name:"Silicon Sepolia zkEVM",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc-sepolia.silicon.network","https://silicon-testnet.nodeinfra.com"]}},blockExplorers:{default:{name:"SiliconSepoliaScope",url:"https://scope-sepolia.silicon.network"}},testnet:!0}),sixProtocol=defineChain({id:98,name:"Six Protocol",nativeCurrency:{decimals:18,name:"SIX",symbol:"SIX"},rpcUrls:{default:{http:["https://sixnet-rpc-evm.sixprotocol.net"]}},blockExplorers:{default:{name:"Six Protocol Scan",url:"https://sixscan.io/sixnet"}},testnet:!1}),skaleBlockBrawlers=defineChain({id:391845894,name:"SKALE | Block Brawlers",nativeCurrency:{name:"BRAWL",symbol:"BRAWL",decimals:18},rpcUrls:{default:{http:["https://mainnet.skalenodes.com/v1/frayed-decent-antares"],webSocket:["wss://mainnet.skalenodes.com/v1/ws/frayed-decent-antares"]}},blockExplorers:{default:{name:"SKALE Explorer",url:"https://frayed-decent-antares.explorer.mainnet.skalenodes.com"}},contracts:{}}),skaleCalypso=defineChain({id:1564830818,name:"SKALE | Calypso NFT Hub",nativeCurrency:{name:"sFUEL",symbol:"sFUEL",decimals:18},rpcUrls:{default:{http:["https://mainnet.skalenodes.com/v1/honorable-steel-rasalhague"],webSocket:["wss://mainnet.skalenodes.com/v1/ws/honorable-steel-rasalhague"]}},blockExplorers:{default:{name:"SKALE Explorer",url:"https://honorable-steel-rasalhague.explorer.mainnet.skalenodes.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:3107626}}}),skaleCalypsoTestnet=defineChain({id:974399131,name:"SKALE Calypso Testnet",nativeCurrency:{name:"sFUEL",symbol:"sFUEL",decimals:18},rpcUrls:{default:{http:["https://testnet.skalenodes.com/v1/giant-half-dual-testnet"],webSocket:["wss://testnet.skalenodes.com/v1/ws/giant-half-dual-testnet"]}},blockExplorers:{default:{name:"SKALE Explorer",url:"https://giant-half-dual-testnet.explorer.testnet.skalenodes.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:103220}},testnet:!0}),skaleCryptoBlades=defineChain({id:1026062157,name:"SKALE | CryptoBlades",nativeCurrency:{name:"sFUEL",symbol:"sFUEL",decimals:18},rpcUrls:{default:{http:["https://mainnet.skalenodes.com/v1/affectionate-immediate-pollux"],webSocket:["wss://mainnet.skalenodes.com/v1/ws/affectionate-immediate-pollux"]}},blockExplorers:{default:{name:"SKALE Explorer",url:"https://affectionate-immediate-pollux.explorer.mainnet.skalenodes.com"}},contracts:{}}),skaleCryptoColosseum=defineChain({id:1032942172,name:"SKALE | Crypto Colosseum",nativeCurrency:{name:"sFUEL",symbol:"sFUEL",decimals:18},rpcUrls:{default:{http:["https://mainnet.skalenodes.com/v1/haunting-devoted-deneb"],webSocket:["wss://mainnet.skalenodes.com/v1/ws/haunting-devoted-deneb"]}},blockExplorers:{default:{name:"SKALE Explorer",url:"https://haunting-devoted-deneb.explorer.mainnet.skalenodes.com"}},contracts:{}}),skaleEuropa=defineChain({id:2046399126,name:"SKALE | Europa Liquidity Hub",nativeCurrency:{name:"sFUEL",symbol:"sFUEL",decimals:18},rpcUrls:{default:{http:["https://mainnet.skalenodes.com/v1/elated-tan-skat"],webSocket:["wss://mainnet.skalenodes.com/v1/ws/elated-tan-skat"]}},blockExplorers:{default:{name:"SKALE Explorer",url:"https://elated-tan-skat.explorer.mainnet.skalenodes.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:3113495}}}),skaleEuropaTestnet=defineChain({id:1444673419,name:"SKALE Europa Testnet",nativeCurrency:{name:"sFUEL",symbol:"sFUEL",decimals:18},rpcUrls:{default:{http:["https://testnet.skalenodes.com/v1/juicy-low-small-testnet"],webSocket:["wss://testnet.skalenodes.com/v1/ws/juicy-low-small-testnet"]}},blockExplorers:{default:{name:"SKALE Explorer",url:"https://juicy-low-small-testnet.explorer.testnet.skalenodes.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:110858}},testnet:!0}),skaleExorde=defineChain({id:2139927552,name:"SKALE | Exorde",nativeCurrency:{name:"sFUEL",symbol:"sFUEL",decimals:18},rpcUrls:{default:{http:["https://mainnet.skalenodes.com/v1/light-vast-diphda"],webSocket:["wss://mainnet.skalenodes.com/v1/ws/light-vast-diphda"]}},blockExplorers:{default:{name:"SKALE Explorer",url:"https://light-vast-diphda.explorer.mainnet.skalenodes.com"}},contracts:{}}),skaleHumanProtocol=defineChain({id:1273227453,name:"SKALE | Human Protocol",nativeCurrency:{name:"sFUEL",symbol:"sFUEL",decimals:18},rpcUrls:{default:{http:["https://mainnet.skalenodes.com/v1/wan-red-ain"],webSocket:["wss://mainnet.skalenodes.com/v1/ws/wan-red-ain"]}},blockExplorers:{default:{name:"SKALE Explorer",url:"https://wan-red-ain.explorer.mainnet.skalenodes.com"}},contracts:{}}),skaleNebula=defineChain({id:1482601649,name:"SKALE | Nebula Gaming Hub",nativeCurrency:{name:"sFUEL",symbol:"sFUEL",decimals:18},rpcUrls:{default:{http:["https://mainnet.skalenodes.com/v1/green-giddy-denebola"],webSocket:["wss://mainnet.skalenodes.com/v1/ws/green-giddy-denebola"]}},blockExplorers:{default:{name:"SKALE Explorer",url:"https://green-giddy-denebola.explorer.mainnet.skalenodes.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:2372986}}}),skaleNebulaTestnet=defineChain({id:37084624,name:"SKALE Nebula Testnet",nativeCurrency:{name:"sFUEL",symbol:"sFUEL",decimals:18},rpcUrls:{default:{http:["https://testnet.skalenodes.com/v1/lanky-ill-funny-testnet"],webSocket:["wss://testnet.skalenodes.com/v1/ws/lanky-ill-funny-testnet"]}},blockExplorers:{default:{name:"SKALE Explorer",url:"https://lanky-ill-funny-testnet.explorer.testnet.skalenodes.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:105141}},testnet:!0}),skaleRazor=defineChain({id:278611351,name:"SKALE | Razor Network",nativeCurrency:{name:"sFUEL",symbol:"sFUEL",decimals:18},rpcUrls:{default:{http:["https://mainnet.skalenodes.com/v1/turbulent-unique-scheat"],webSocket:["wss://mainnet.skalenodes.com/v1/ws/turbulent-unique-scheat"]}},blockExplorers:{default:{name:"SKALE Explorer",url:"https://turbulent-unique-scheat.explorer.mainnet.skalenodes.com"}},contracts:{}}),skaleTitan=defineChain({id:1350216234,name:"SKALE | Titan Community Hub",nativeCurrency:{name:"sFUEL",symbol:"sFUEL",decimals:18},rpcUrls:{default:{http:["https://mainnet.skalenodes.com/v1/parallel-stormy-spica"],webSocket:["wss://mainnet.skalenodes.com/v1/ws/parallel-stormy-spica"]}},blockExplorers:{default:{name:"SKALE Explorer",url:"https://parallel-stormy-spica.explorer.mainnet.skalenodes.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:2076458}}}),skaleTitanTestnet=defineChain({id:1020352220,name:"SKALE Titan Hub",nativeCurrency:{name:"sFUEL",symbol:"sFUEL",decimals:18},rpcUrls:{default:{http:["https://testnet.skalenodes.com/v1/aware-fake-trim-testnet"],webSocket:["wss://testnet.skalenodes.com/v1/ws/aware-fake-trim-testnet"]}},blockExplorers:{default:{name:"SKALE Explorer",url:"https://aware-fake-trim-testnet.explorer.testnet.skalenodes.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:104072}},testnet:!0}),sketchpad=defineChain({id:984123,name:"Forma Sketchpad",network:"sketchpad",nativeCurrency:{symbol:"TIA",name:"TIA",decimals:18},rpcUrls:{default:{http:["https://rpc.sketchpad-1.forma.art"],webSocket:["wss://ws.sketchpad-1.forma.art"]}},blockExplorers:{default:{name:"Sketchpad Explorer",url:"https://explorer.sketchpad-1.forma.art"}},testnet:!0}),sourceId$8=1,snax=defineChain({...chainConfig$2,id:2192,network:"snaxchain-mainnet",name:"SnaxChain",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.snaxchain.io"]}},blockExplorers:{default:{name:"Snax Explorer",url:"https://explorer.snaxchain.io",apiUrl:"https://explorer.snaxchain.io/api"}},contracts:{...chainConfig$2.contracts,disputeGameFactory:{[sourceId$8]:{address:"0x472562Fcf26D6b2793f8E0b0fB660ba0E5e08A46"}},l2OutputOracle:{[sourceId$8]:{address:"0x2172e492Fc807F5d5645D0E3543f139ECF539294"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11"},portal:{[sourceId$8]:{address:"0x79f446D024d74D0Bb6E699C131c703463c5D65E9"}},l1StandardBridge:{[sourceId$8]:{address:"0x6534Bdb6b5c060d3e6aa833433333135eFE8E0aA"}}},sourceId:sourceId$8}),sourceId$7=11155111,snaxTestnet=defineChain({...chainConfig$2,id:13001,network:"snaxchain-testnet",name:"SnaxChain Testnet",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://testnet.snaxchain.io"]}},blockExplorers:{default:{name:"Snax Explorer",url:"https://testnet-explorer.snaxchain.io",apiUrl:"https://testnet-explorer.snaxchain.io/api"}},contracts:{...chainConfig$2.contracts,disputeGameFactory:{[sourceId$7]:{address:"0x206a75d89d45F146C54020F132FF93bEDD09f55E"}},l2OutputOracle:{[sourceId$7]:{address:"0x60e3A368a4cdCEf85ffB964e372726F56A46221e"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11"},portal:{[sourceId$7]:{address:"0xb5afdd0E8dDF081Ef90e8A3e0c7b5798e66E954E"}},l1StandardBridge:{[sourceId$7]:{address:"0xbd37E1a59D4C00C9A46F75018dffd84061bC5f74"}}},testnet:!0,sourceId:sourceId$7}),sourceId$6=11155111,soneiumMinato=defineChain({...chainConfig$2,id:1946,name:"Soneium Minato Testnet",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.minato.soneium.org"]}},blockExplorers:{default:{name:"Blockscout",url:"https://soneium-minato.blockscout.com",apiUrl:"https://soneium-minato.blockscout.com/api"}},contracts:{...chainConfig$2.contracts,disputeGameFactory:{[sourceId$6]:{address:"0xB3Ad2c38E6e0640d7ce6aA952AB3A60E81bf7a01"}},l2OutputOracle:{[sourceId$6]:{address:"0x710e5286C746eC38beeB7538d0146f60D27be343"}},portal:{[sourceId$6]:{address:"0x65ea1489741A5D72fFdD8e6485B216bBdcC15Af3",blockCreated:6466136}},l1StandardBridge:{[sourceId$6]:{address:"0x5f5a404A5edabcDD80DB05E8e54A78c9EBF000C2",blockCreated:6466136}},multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:1}},testnet:!0,sourceId:sourceId$6}),sonicTestnet=defineChain({id:64165,name:"Sonic Testnet",nativeCurrency:{decimals:18,name:"Sonic",symbol:"S"},rpcUrls:{default:{http:["https://rpc.testnet.soniclabs.com"]}},blockExplorers:{default:{name:"Sonic Testnet Explorer",url:"https://testnet.soniclabs.com/"}},testnet:!0}),songbird=defineChain({id:19,name:"Songbird Canary-Network",nativeCurrency:{decimals:18,name:"Songbird",symbol:"SGB"},rpcUrls:{default:{http:["https://songbird-api.flare.network/ext/C/rpc"]}},blockExplorers:{default:{name:"Songbird Explorer",url:"https://songbird-explorer.flare.network",apiUrl:"https://songbird-explorer.flare.network/api"}}}),songbirdTestnet=defineChain({id:16,name:"Songbird Testnet Coston",nativeCurrency:{decimals:18,name:"Coston Flare",symbol:"CFLR"},rpcUrls:{default:{http:["https://coston-api.flare.network/ext/C/rpc"]}},blockExplorers:{default:{name:"Coston Explorer",url:"https://coston-explorer.flare.network",apiUrl:"https://coston-explorer.flare.network/api"}},testnet:!0}),sophon=defineChain({...chainConfig$3,id:50104,name:"Sophon",nativeCurrency:{decimals:18,name:"Sophon",symbol:"SOPH"},rpcUrls:{default:{http:["https://rpc.sophon.xyz"],webSocket:["wss://rpc.sophon.xyz/ws"]}},blockExplorers:{default:{name:"Sophon Block Explorer",url:"https://explorer.sophon.xyz"}},contracts:{multicall3:{address:"0x5f4867441d2416cA88B1b3fd38f21811680CD2C8",blockCreated:116}},testnet:!1}),sophonTestnet=defineChain({...chainConfig$3,id:531050104,name:"Sophon Testnet",nativeCurrency:{decimals:18,name:"Sophon",symbol:"SOPH"},rpcUrls:{default:{http:["https://rpc.testnet.sophon.xyz"],webSocket:["wss://rpc.testnet.sophon.xyz/ws"]}},blockExplorers:{default:{name:"Sophon Block Explorer",url:"https://explorer.testnet.sophon.xyz"}},contracts:{multicall3:{address:"0x83c04d112adedA2C6D9037bb6ecb42E7f0b108Af",blockCreated:15642}},testnet:!0}),spicy=defineChain({id:88882,name:"Chiliz Spicy Testnet",network:"chiliz-spicy-Testnet",nativeCurrency:{decimals:18,name:"CHZ",symbol:"CHZ"},rpcUrls:{default:{http:["https://spicy-rpc.chiliz.com","https://chiliz-spicy-rpc.publicnode.com"],webSocket:["wss://spicy-rpc-ws.chiliz.com","wss://chiliz-spicy-rpc.publicnode.com"]}},blockExplorers:{default:{name:"Chiliz Explorer",url:"http://spicy-explorer.chiliz.com",apiUrl:"http://spicy-explorer.chiliz.com/api"}},testnet:!0}),step=defineChain({id:1234,name:"Step Network",nativeCurrency:{name:"FITFI",symbol:"FITFI",decimals:18},rpcUrls:{default:{http:["https://rpc.step.network"]}},blockExplorers:{default:{name:"Step Scan",url:"https://stepscan.io"}},testnet:!1}),storyTestnet=defineChain({id:1513,name:"Story Testnet",nativeCurrency:{decimals:18,name:"IP",symbol:"IP"},rpcUrls:{default:{http:["https://testnet.storyrpc.io"]}},blockExplorers:{default:{name:"Story Testnet Explorer",url:"https://testnet.storyscan.xyz"}},testnet:!0}),stratis=defineChain({id:105105,name:"Stratis Mainnet",network:"stratis",nativeCurrency:{name:"Stratis",symbol:"STRAX",decimals:18},rpcUrls:{default:{http:["https://rpc.stratisevm.com"]}},blockExplorers:{default:{name:"Stratis Explorer",url:"https://explorer.stratisevm.com"}}}),superlumio=defineChain({id:8866,name:"SuperLumio",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.lumio.io"]}},blockExplorers:{default:{name:"Lumio explorer",url:"https://explorer.lumio.io"}},testnet:!1}),superposition=defineChain({id:55244,name:"Superposition",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.superposition.so"]}},blockExplorers:{default:{name:"Superposition Explorer",url:"https://explorer.superposition.so"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:39}},testnet:!1}),swan=defineChain({id:254,name:"Swan Chain Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet-rpc.swanchain.org"]}},blockExplorers:{default:{name:"Swan Explorer",url:"https://swanscan.io"}},testnet:!1}),swanProximaTestnet=defineChain({id:20241133,name:"Swan Proxima Testnet",nativeCurrency:{name:"Swan Ether",symbol:"sETH",decimals:18},rpcUrls:{default:{http:["https://rpc-proxima.swanchain.io "]}},blockExplorers:{default:{name:"Swan Explorer",url:"https://proxima-explorer.swanchain.io"}},testnet:!0}),swanSaturnTestnet=defineChain({id:2024,name:"Swan Saturn Testnet",nativeCurrency:{name:"Swan Ether",symbol:"sETH",decimals:18},rpcUrls:{default:{http:["https://saturn-rpc.swanchain.io"]}},blockExplorers:{default:{name:"Swan Explorer",url:"https://saturn-explorer.swanchain.io"}},testnet:!0}),swissdlt=defineChain({id:94,name:"SwissDLT Mainnet",nativeCurrency:{decimals:18,name:"BCTS",symbol:"BCTS"},rpcUrls:{default:{http:["https://rpc.swissdlt.ch"]}},blockExplorers:{default:{name:"SwissDLT Explorer",url:"https://explorer.swissdlt.ch"}},testnet:!1}),syscoin=defineChain({id:57,name:"Syscoin Mainnet",nativeCurrency:{decimals:18,name:"Syscoin",symbol:"SYS"},rpcUrls:{default:{http:["https://rpc.syscoin.org"],webSocket:["wss://rpc.syscoin.org/wss"]}},blockExplorers:{default:{name:"SyscoinExplorer",url:"https://explorer.syscoin.org",apiUrl:"https://explorer.syscoin.org/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:287139}}}),syscoinTestnet=defineChain({id:5700,name:"Syscoin Tanenbaum Testnet",nativeCurrency:{decimals:18,name:"Syscoin",symbol:"SYS"},rpcUrls:{default:{http:["https://rpc.tanenbaum.io"],webSocket:["wss://rpc.tanenbaum.io/wss"]}},blockExplorers:{default:{name:"SyscoinTestnetExplorer",url:"https://tanenbaum.io"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:271288}}}),taiko=defineChain({id:167e3,name:"Taiko Mainnet",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.mainnet.taiko.xyz"],webSocket:["wss://ws.mainnet.taiko.xyz"]}},blockExplorers:{default:{name:"Taikoscan",url:"https://taikoscan.io",apiUrl:"https://api.taikoscan.io/api"}},contracts:{multicall3:{address:"0xcb2436774C3e191c85056d248EF4260ce5f27A9D"}}}),taikoHekla=defineChain({id:167009,name:"Taiko Hekla L2",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.hekla.taiko.xyz"]}},blockExplorers:{default:{name:"Taikoscan",url:"https://hekla.taikoscan.network"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:59757}},testnet:!0}),taikoJolnir=defineChain({id:167007,name:"Taiko Jolnir (Alpha-5 Testnet)",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.jolnir.taiko.xyz"]}},blockExplorers:{default:{name:"blockscout",url:"https://explorer.jolnir.taiko.xyz"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:732706}},testnet:!0}),taikoKatla=defineChain({id:167008,name:"Taiko Katla (Alpha-6 Testnet)",network:"tko-katla",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.katla.taiko.xyz"]}},blockExplorers:{default:{name:"blockscout",url:"https://explorer.katla.taiko.xyz"}}}),taikoTestnetSepolia=defineChain({id:167005,name:"Taiko (Alpha-3 Testnet)",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.test.taiko.xyz"]}},blockExplorers:{default:{name:"blockscout",url:"https://explorer.test.taiko.xyz"}}}),taraxa=defineChain({id:841,name:"Taraxa Mainnet",nativeCurrency:{name:"Tara",symbol:"TARA",decimals:18},rpcUrls:{default:{http:["https://rpc.mainnet.taraxa.io"]}},blockExplorers:{default:{name:"Taraxa Explorer",url:"https://explorer.mainnet.taraxa.io"}}}),taraxaTestnet=defineChain({id:842,name:"Taraxa Testnet",nativeCurrency:{name:"Tara",symbol:"TARA",decimals:18},rpcUrls:{default:{http:["https://rpc.testnet.taraxa.io"]}},blockExplorers:{default:{name:"Taraxa Explorer",url:"https://explorer.testnet.taraxa.io"}},testnet:!0}),telcoinTestnet=defineChain({id:2017,name:"Telcoin Adiri Testnet",nativeCurrency:{name:"Telcoin",symbol:"TEL",decimals:18},rpcUrls:{default:{http:["https://rpc.telcoin.network"]}},blockExplorers:{default:{name:"telscan",url:"https://telscan.io"}},testnet:!0}),telos=defineChain({id:40,name:"Telos",nativeCurrency:{decimals:18,name:"Telos",symbol:"TLOS"},rpcUrls:{default:{http:["https://mainnet.telos.net/evm"]}},blockExplorers:{default:{name:"Teloscan",url:"https://www.teloscan.io/"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:246530709}}}),telosTestnet=defineChain({id:41,name:"Telos",nativeCurrency:{decimals:18,name:"Telos",symbol:"TLOS"},rpcUrls:{default:{http:["https://testnet.telos.net/evm"]}},blockExplorers:{default:{name:"Teloscan (testnet)",url:"https://testnet.teloscan.io/"}},testnet:!0}),tenet=defineChain({id:1559,name:"Tenet",network:"tenet-mainnet",nativeCurrency:{name:"TENET",symbol:"TENET",decimals:18},rpcUrls:{default:{http:["https://rpc.tenet.org"]}},blockExplorers:{default:{name:"TenetScan Mainnet",url:"https://tenetscan.io",apiUrl:"https://tenetscan.io/api"}},testnet:!1}),thaiChain=defineChain({id:7,name:"ThaiChain",nativeCurrency:{name:"TCH",symbol:"TCH",decimals:18},rpcUrls:{default:{http:["https://rpc.thaichain.org"]}},blockExplorers:{default:{name:"Blockscout",url:"https://exp.thaichain.org",apiUrl:"https://exp.thaichain.org/api"}},contracts:{multicall3:{address:"0x0DaD6130e832c21719C5CE3bae93454E16A84826",blockCreated:4806386}},testnet:!1}),that=defineChain({id:8428,name:"THAT Mainnet",nativeCurrency:{name:"THAT",symbol:"THAT",decimals:18},rpcUrls:{default:{http:["https://api.thatchain.io/mainnet"]}},blockExplorers:{default:{name:"Blockscout",url:"https://that.blockscout.com"}},testnet:!1}),theta=defineChain({id:361,name:"Theta Mainnet",nativeCurrency:{name:"TFUEL",symbol:"TFUEL",decimals:18},rpcUrls:{default:{http:["https://eth-rpc-api.thetatoken.org/rpc"]}},blockExplorers:{default:{name:"Theta Explorer",url:"https://explorer.thetatoken.org"}},testnet:!1}),thetaTestnet=defineChain({id:365,name:"Theta Testnet",nativeCurrency:{name:"TFUEL",symbol:"TFUEL",decimals:18},rpcUrls:{default:{http:["https://eth-rpc-api-testnet.thetatoken.org/rpc"]}},blockExplorers:{default:{name:"Theta Explorer",url:"https://testnet-explorer.thetatoken.org"}},testnet:!0}),thunderCore=defineChain({id:108,name:"ThunderCore Mainnet",nativeCurrency:{name:"TT",symbol:"TT",decimals:18},rpcUrls:{default:{http:["https://mainnet-rpc.thundercore.com"]}},blockExplorers:{default:{name:"ThunderCore Explorer",url:"https://viewblock.io/thundercore"}},testnet:!1}),thunderTestnet=defineChain({id:997,name:"5ireChain Thunder Testnet",nativeCurrency:{name:"5ire Token",symbol:"5IRE",decimals:18},rpcUrls:{default:{http:["https://rpc.testnet.5ire.network"]}},blockExplorers:{default:{name:"5ireChain Thunder Explorer",url:"https://testnet.5irescan.io/"}},testnet:!0}),tiktrixTestnet=defineChain({id:62092,name:"TikTrix Testnet",nativeCurrency:{name:"tTTX",symbol:"tTTX",decimals:18},rpcUrls:{default:{http:["https://tiktrix-rpc.xyz"]}},blockExplorers:{default:{name:"TikTrix Testnet Explorer",url:"https://tiktrix.xyz"}},testnet:!0}),tomb=defineChain({id:6969,name:"Tomb Mainnet",nativeCurrency:{name:"TOMB",symbol:"TOMB",decimals:18},rpcUrls:{default:{http:["https://rpc.tombchain.com"]}},blockExplorers:{default:{name:"Tomb Explorer",url:"https://tombscout.com"}},testnet:!1}),tron=defineChain({id:728126428,name:"Tron",nativeCurrency:{name:"TRON",symbol:"TRX",decimals:6},rpcUrls:{default:{http:["https://api.trongrid.io/jsonrpc"]}},blockExplorers:{default:{name:"Tronscan",url:"https://tronscan.org",apiUrl:"https://apilist.tronscanapi.com/api"}}}),ubiq=defineChain({id:8,name:"Ubiq Mainnet",nativeCurrency:{name:"UBQ",symbol:"UBQ",decimals:18},rpcUrls:{default:{http:["https://pyrus2.ubiqscan.io"]}},blockExplorers:{default:{name:"Ubiq Scan",url:"https://ubiqscan.io"}},testnet:!1}),ultron=defineChain({id:1231,name:"Ultron Mainnet",nativeCurrency:{name:"ULX",symbol:"ULX",decimals:18},rpcUrls:{default:{http:["https://ultron-rpc.net"]}},blockExplorers:{default:{name:"Ultron Scan",url:"https://ulxscan.com"}},testnet:!1}),ultronTestnet=defineChain({id:1230,name:"Ultron Testnet",nativeCurrency:{name:"ULX",symbol:"ULX",decimals:18},rpcUrls:{default:{http:["https://ultron-dev.io"]}},blockExplorers:{default:{name:"Ultron Scan",url:"https://explorer.ultron-dev.io"}},testnet:!0}),sourceId$5=11155111,unichainSepolia=defineChain({...chainConfig$2,id:1301,name:"Unichain Sepolia",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.unichain.org"]}},blockExplorers:{default:{name:"Uniscan",url:"https://sepolia.uniscan.xyz",apiUrl:"https://api-sepolia.uniscan.xyz/api"}},contracts:{...chainConfig$2.contracts,multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:0},portal:{[sourceId$5]:{address:"0x0d83dab629f0e0F9d36c0Cbc89B69a489f0751bD"}},l1StandardBridge:{[sourceId$5]:{address:"0xea58fcA6849d79EAd1f26608855c2D6407d54Ce2"}},disputeGameFactory:{[sourceId$5]:{address:"0xeff73e5aa3B9AEC32c659Aa3E00444d20a84394b"}}},testnet:!0,sourceId:sourceId$5}),unique=defineChain({id:8880,name:"Unique Mainnet",nativeCurrency:{decimals:18,name:"UNQ",symbol:"UNQ"},rpcUrls:{default:{http:["https://rpc.unique.network"]}},blockExplorers:{default:{name:"Unique Subscan",url:"https://unique.subscan.io/"}}}),uniqueOpal=defineChain({id:8882,name:"Opal Testnet",nativeCurrency:{decimals:18,name:"OPL",symbol:"OPL"},rpcUrls:{default:{http:["https://rpc-opal.unique.network"]}},blockExplorers:{default:{name:"Opal Subscan",url:"https://opal.subscan.io/"}},testnet:!0}),uniqueQuartz=defineChain({id:8881,name:"Quartz Mainnet",nativeCurrency:{decimals:18,name:"QTZ",symbol:"QTZ"},rpcUrls:{default:{http:["https://rpc-quartz.unique.network"]}},blockExplorers:{default:{name:"Quartz Subscan",url:"https://quartz.subscan.io/"}}}),unreal=defineChain({id:18233,name:"Unreal",nativeCurrency:{name:"reETH",decimals:18,symbol:"reETH"},rpcUrls:{default:{http:["https://rpc.unreal-orbit.gelato.digital"]}},blockExplorers:{default:{name:"Unreal Explorer",url:"https://unreal.blockscout.com",apiUrl:"https://unreal.blockscout.com/api/v2"}},testnet:!0,contracts:{multicall3:{address:"0x8b6B0e60D8CD84898Ea8b981065A12F876eA5677",blockCreated:1745}}}),vanar=defineChain({id:2040,name:"Vanar Mainnet",nativeCurrency:{name:"VANRY",symbol:"VANRY",decimals:18},rpcUrls:{default:{http:["https://rpc.vanarchain.com"]}},blockExplorers:{default:{name:"Vanar Mainnet Explorer",url:"https://explorer.vanarchain.com/"}},testnet:!1}),vechain=defineChain({id:100009,name:"Vechain",nativeCurrency:{name:"VeChain",symbol:"VET",decimals:18},rpcUrls:{default:{http:["https://mainnet.vechain.org"]}},blockExplorers:{default:{name:"Vechain Explorer",url:"https://explore.vechain.org"},vechainStats:{name:"Vechain Stats",url:"https://vechainstats.com"}}}),velas=defineChain({id:106,name:"Velas EVM Mainnet",nativeCurrency:{name:"VLX",symbol:"VLX",decimals:18},rpcUrls:{default:{http:["https://evmexplorer.velas.com/rpc"]}},blockExplorers:{default:{name:"Velas Explorer",url:"https://evmexplorer.velas.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:55883577}},testnet:!1}),viction=defineChain({id:88,name:"Viction",nativeCurrency:{name:"Viction",symbol:"VIC",decimals:18},rpcUrls:{default:{http:["https://rpc.viction.xyz"]}},blockExplorers:{default:{name:"VIC Scan",url:"https://vicscan.xyz"}},testnet:!1}),victionTestnet=defineChain({id:89,name:"Viction Testnet",nativeCurrency:{name:"Viction",symbol:"VIC",decimals:18},rpcUrls:{default:{http:["https://rpc-testnet.viction.xyz"]}},blockExplorers:{default:{name:"VIC Scan",url:"https://testnet.vicscan.xyz"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:12170179}},testnet:!0}),vision=defineChain({id:888888,name:"Vision",nativeCurrency:{name:"VISION",symbol:"VS",decimals:18},rpcUrls:{default:{http:["https://infragrid.v.network/ethereum/compatible"]}},blockExplorers:{default:{name:"Vision Scan",url:"https://visionscan.org"}},testnet:!1}),visionTestnet=defineChain({id:666666,name:"Vision Testnet",nativeCurrency:{name:"VISION",symbol:"VS",decimals:18},rpcUrls:{default:{http:["https://vpioneer.infragrid.v.network/ethereum/compatible"]}},blockExplorers:{default:{name:"Vision Scan",url:"https://visionscan.org/?chain=vpioneer"}},testnet:!0}),wanchain=defineChain({id:888,name:"Wanchain",nativeCurrency:{name:"WANCHAIN",symbol:"WAN",decimals:18},rpcUrls:{default:{http:["https://gwan-ssl.wandevs.org:56891","https://gwan2-ssl.wandevs.org"]}},blockExplorers:{default:{name:"WanScan",url:"https://wanscan.org"}},contracts:{multicall3:{address:"0xcDF6A1566e78EB4594c86Fe73Fcdc82429e97fbB",blockCreated:25312390}}}),wanchainTestnet=defineChain({id:999,name:"Wanchain Testnet",nativeCurrency:{name:"WANCHAIN",symbol:"WANt",decimals:18},rpcUrls:{default:{http:["https://gwan-ssl.wandevs.org:46891"]}},blockExplorers:{default:{name:"WanScanTest",url:"https://wanscan.org"}},contracts:{multicall3:{address:"0x11c89bF4496c39FB80535Ffb4c92715839CC5324",blockCreated:24743448}},testnet:!0}),weaveVMAlphanet=defineChain({id:9496,name:"WeaveVM Alphanet",nativeCurrency:{name:"Testnet WeaveVM",symbol:"tWVM",decimals:18},rpcUrls:{default:{http:["https://testnet-rpc.wvm.dev"]}},blockExplorers:{default:{name:"WeaveVM Alphanet Explorer",url:"https://explorer.wvm.dev"}},testnet:!0}),wemix=defineChain({id:1111,name:"WEMIX",network:"wemix-mainnet",nativeCurrency:{name:"WEMIX",symbol:"WEMIX",decimals:18},rpcUrls:{default:{http:["https://api.wemix.com"]}},blockExplorers:{default:{name:"wemixExplorer",url:"https://explorer.wemix.com"}}}),wemixTestnet=defineChain({id:1112,name:"WEMIX Testnet",network:"wemix-testnet",nativeCurrency:{name:"WEMIX",symbol:"tWEMIX",decimals:18},rpcUrls:{default:{http:["https://api.test.wemix.com"]}},blockExplorers:{default:{name:"wemixExplorer",url:"https://testnet.wemixscan.com",apiUrl:"https://testnet.wemixscan.com/api"}},testnet:!0}),sourceId$4=1,worldchain=defineChain({...chainConfig$2,id:480,name:"World Chain",network:"worldchain",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://worldchain-mainnet.g.alchemy.com/public"]}},blockExplorers:{default:{name:"Worldscan",url:"https://worldscan.org",apiUrl:"https://api.worldscan.org/api"},blockscout:{name:"Blockscout",url:"https://worldchain-mainnet.explorer.alchemy.com",apiUrl:"https://worldchain-mainnet.explorer.alchemy.com/api"}},contracts:{...chainConfig$2.contracts,multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:0},disputeGameFactory:{[sourceId$4]:{address:"0x0E90dCAFBC242D2C861A20Bb20EC8E7182965a52"}},l2OutputOracle:{[sourceId$4]:{address:"0x19A6d1E9034596196295CF148509796978343c5D"}},portal:{[sourceId$4]:{address:"0xd5ec14a83B7d95BE1E2Ac12523e2dEE12Cbeea6C"}},l1StandardBridge:{[sourceId$4]:{address:"0x470458C91978D2d929704489Ad730DC3E3001113"}}},testnet:!1,sourceId:sourceId$4}),sourceId$3=11155111,worldchainSepolia=defineChain({...chainConfig$2,id:4801,name:"World Chain Sepolia",network:"worldchain-sepolia",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://worldchain-sepolia.g.alchemy.com/public"]},public:{http:["https://worldchain-sepolia.g.alchemy.com/public"]}},blockExplorers:{default:{name:"Worldscan Sepolia",url:"https://sepolia.worldscan.org"},blockscout:{name:"Blockscout",url:"https://worldchain-sepolia.explorer.alchemy.com",apiUrl:"https://worldchain-sepolia.explorer.alchemy.com/api"}},contracts:{...chainConfig$2.contracts,multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:0},disputeGameFactory:{[sourceId$3]:{address:"0x8cF97Ee616C986a070F5020d973b456D0120C253"}},l2OutputOracle:{[sourceId$3]:{address:"0xc8886f8BAb6Eaeb215aDB5f1c686BF699248300e"}},portal:{[sourceId$3]:{address:"0xFf6EBa109271fe6d4237EeeD4bAb1dD9A77dD1A4"}},l1StandardBridge:{[sourceId$3]:{address:"0xd7DF54b3989855eb66497301a4aAEc33Dbb3F8DE"}}},testnet:!0,sourceId:sourceId$3}),worldLand=defineChain({id:103,name:"WorldLand Mainnet",nativeCurrency:{decimals:18,name:"WLC",symbol:"WLC"},rpcUrls:{default:{http:["https://seoul.worldland.foundation"]}},blockExplorers:{default:{name:"WorldLand Scan",url:"https://scan.worldland.foundation"}},testnet:!1}),xai=defineChain({id:660279,name:"Xai Mainnet",nativeCurrency:{name:"Xai",symbol:"XAI",decimals:18},rpcUrls:{default:{http:["https://xai-chain.net/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.xai-chain.net"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:222549}},testnet:!1}),xaiTestnet=defineChain({id:37714555429,name:"Xai Testnet",nativeCurrency:{name:"sXai",symbol:"sXAI",decimals:18},rpcUrls:{default:{http:["https://testnet-v2.xai-chain.net/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://testnet-explorer-v2.xai-chain.net"}},testnet:!0}),xdc=defineChain({id:50,name:"XinFin Network",nativeCurrency:{decimals:18,name:"XDC",symbol:"XDC"},rpcUrls:{default:{http:["https://rpc.xdcrpc.com"]}},blockExplorers:{default:{name:"XDCScan",url:"https://xdcscan.com"}},contracts:{multicall3:{address:"0x0B1795ccA8E4eC4df02346a082df54D437F8D9aF",blockCreated:75884020}}}),xdcTestnet=defineChain({id:51,name:"Apothem Network",nativeCurrency:{decimals:18,name:"TXDC",symbol:"TXDC"},rpcUrls:{default:{http:["https://erpc.apothem.network"]}},blockExplorers:{default:{name:"XDCScan",url:"https://testnet.xdcscan.com"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:59765389}}}),xLayer=defineChain({id:196,name:"X Layer Mainnet",nativeCurrency:{decimals:18,name:"OKB",symbol:"OKB"},rpcUrls:{default:{http:["https://rpc.xlayer.tech"]}},blockExplorers:{default:{name:"OKLink",url:"https://www.oklink.com/xlayer",apiUrl:"https://www.oklink.com/api/v5/explorer/xlayer/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:47416}}}),xLayerTestnet=defineChain({id:195,name:"X1 Testnet",nativeCurrency:{decimals:18,name:"OKB",symbol:"OKB"},rpcUrls:{default:{http:["https://xlayertestrpc.okx.com"]}},blockExplorers:{default:{name:"OKLink",url:"https://www.oklink.com/xlayer-test"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:624344}},testnet:!0}),xrSepolia=defineChain({id:2730,name:"XR Sepolia",nativeCurrency:{decimals:18,name:"tXR",symbol:"tXR"},rpcUrls:{default:{http:["https://xr-sepolia-testnet.rpc.caldera.xyz/http"]}},blockExplorers:{default:{name:"Blockscout",url:"https://xr-sepolia-testnet.explorer.caldera.xyz"}},testnet:!0}),yooldoVerse=defineChain({id:50005,name:"Yooldo Verse",nativeCurrency:{name:"OAS",symbol:"OAS",decimals:18},rpcUrls:{default:{http:["https://rpc.yooldo-verse.xyz"]}},blockExplorers:{default:{name:"Yooldo Verse Explorer",url:"https://explorer.yooldo-verse.xyz"}}}),yooldoVerseTestnet=defineChain({id:50006,name:"Yooldo Verse Testnet",nativeCurrency:{name:"OAS",symbol:"OAS",decimals:18},rpcUrls:{default:{http:["https://rpc.testnet.yooldo-verse.xyz"]}},blockExplorers:{default:{name:"Yooldo Verse Testnet Explorer",url:"https://explorer.testnet.yooldo-verse.xyz"}},testnet:!0}),zenchainTestnet=defineChain({id:8408,name:"Zenchain Testnet",nativeCurrency:{decimals:18,name:"ZCX",symbol:"ZCX"},rpcUrls:{default:{http:["https://zenchain-testnet.api.onfinality.io/public"],webSocket:["wss://zenchain-testnet.api.onfinality.io/public-ws"]}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:230019}},blockExplorers:{default:{name:"Zentrace",url:"https://zentrace.io"}},testnet:!0}),zeniq=defineChain({id:383414847825,name:"Zeniq Mainnet",nativeCurrency:{name:"ZENIQ",symbol:"ZENIQ",decimals:18},rpcUrls:{default:{http:["https://api.zeniq.network"]}},blockExplorers:{default:{name:"Zeniq Explorer",url:"https://zeniqscan.com"}},testnet:!1}),zetachain=defineChain({id:7e3,name:"ZetaChain",nativeCurrency:{decimals:18,name:"Zeta",symbol:"ZETA"},rpcUrls:{default:{http:["https://zetachain-evm.blockpi.network/v1/rpc/public"]}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:1632781}},blockExplorers:{default:{name:"ZetaScan",url:"https://explorer.zetachain.com"}},testnet:!1}),zetachainAthensTestnet=defineChain({id:7001,name:"ZetaChain Athens Testnet",nativeCurrency:{decimals:18,name:"Zeta",symbol:"aZETA"},rpcUrls:{default:{http:["https://zetachain-athens-evm.blockpi.network/v1/rpc/public"]}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:2715217}},blockExplorers:{default:{name:"ZetaScan",url:"https://athens.explorer.zetachain.com"}},testnet:!0}),zhejiang=defineChain({id:1337803,name:"Zhejiang",nativeCurrency:{name:"Zhejiang Ether",symbol:"ZhejETH",decimals:18},rpcUrls:{default:{http:["https://rpc.zhejiang.ethpandaops.io"]}},blockExplorers:{default:{name:"Beaconchain",url:"https://zhejiang.beaconcha.in"}},testnet:!0}),zilliqa=defineChain({id:32769,name:"Zilliqa",network:"zilliqa",nativeCurrency:{name:"Zilliqa",symbol:"ZIL",decimals:18},rpcUrls:{default:{http:["https://api.zilliqa.com"]}},blockExplorers:{default:{name:"Ethernal",url:"https://evmx.zilliqa.com"}},testnet:!1}),zilliqaTestnet=defineChain({id:33101,name:"Zilliqa Testnet",network:"zilliqa-testnet",nativeCurrency:{name:"Zilliqa",symbol:"ZIL",decimals:18},rpcUrls:{default:{http:["https://dev-api.zilliqa.com"]}},blockExplorers:{default:{name:"Ethernal",url:"https://evmx.testnet.zilliqa.com"}},testnet:!0}),zircuit=defineChain({id:48900,name:"Zircuit Mainnet",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://zircuit1-mainnet.p2pify.com","https://zircuit1-mainnet.liquify.com","https://zircuit-mainnet.drpc.org"]}},blockExplorers:{default:{name:"Zircuit Explorer",url:"https://explorer.zircuit.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11"}},testnet:!1}),zircuitTestnet=defineChain({id:48899,name:"Zircuit Testnet",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://zircuit1-testnet.p2pify.com","https://zircuit1-testnet.liquify.com"]}},blockExplorers:{default:{name:"Zircuit Testnet Explorer",url:"https://explorer.testnet.zircuit.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:6040287}},testnet:!0}),zkFair=defineChain({id:42766,name:"ZKFair Mainnet",network:"zkfair-mainnet",nativeCurrency:{decimals:18,name:"USD Coin",symbol:"USDC"},rpcUrls:{default:{http:["https://rpc.zkfair.io"]}},blockExplorers:{default:{name:"zkFair Explorer",url:"https://scan.zkfair.io",apiUrl:"https://scan.zkfair.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:6090959}},testnet:!1}),zkFairTestnet=defineChain({id:43851,name:"ZKFair Testnet",network:"zkfair-testnet",nativeCurrency:{decimals:18,name:"USD Coin",symbol:"USDC"},rpcUrls:{default:{http:["https://testnet-rpc.zkfair.io"]}},blockExplorers:{default:{name:"zkFair Explorer",url:"https://testnet-scan.zkfair.io"}},testnet:!0}),zkLinkNova=defineChain({id:810180,name:"zkLink Nova",nativeCurrency:{decimals:18,name:"ETH",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.zklink.io"]}},blockExplorers:{default:{name:"zkLink Nova Block Explorer",url:"https://explorer.zklink.io"}}}),zkLinkNovaSepoliaTestnet=defineChain({id:810181,name:"zkLink Nova Sepolia Testnet",nativeCurrency:{decimals:18,name:"ETH",symbol:"ETH"},rpcUrls:{default:{http:["https://sepolia.rpc.zklink.io"]}},blockExplorers:{default:{name:"zkLink Nova Block Explorer",url:"https://sepolia.explorer.zklink.io"}}}),zksync=defineChain({...chainConfig$3,id:324,name:"ZKsync Era",network:"zksync-era",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://mainnet.era.zksync.io"],webSocket:["wss://mainnet.era.zksync.io/ws"]}},blockExplorers:{default:{name:"Etherscan",url:"https://era.zksync.network/",apiUrl:"https://api-era.zksync.network/api"},native:{name:"ZKsync Explorer",url:"https://explorer.zksync.io/",apiUrl:"https://block-explorer-api.mainnet.zksync.io/api"}},contracts:{multicall3:{address:"0xF9cda624FBC7e059355ce98a31693d299FACd963"},universalSignatureVerifier:{address:"0xfB688330379976DA81eB64Fe4BF50d7401763B9C",blockCreated:45659388}}}),zksyncInMemoryNode=defineChain({...chainConfig$3,id:260,name:"ZKsync InMemory Node",network:"zksync-in-memory-node",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["http://localhost:8011"]}},testnet:!0}),zksyncLocalNode=defineChain({...chainConfig$3,id:270,name:"ZKsync CLI Local Node",network:"zksync-cli-local-node",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["http://localhost:3050"]}},testnet:!0}),zksyncSepoliaTestnet=defineChain({...chainConfig$3,id:300,name:"ZKsync Sepolia Testnet",network:"zksync-sepolia-testnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.era.zksync.dev"],webSocket:["wss://sepolia.era.zksync.dev/ws"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia-era.zksync.network/",apiUrl:"https://api-sepolia-era.zksync.network/api"},native:{name:"ZKsync Explorer",url:"https://sepolia.explorer.zksync.io/",blockExplorerApi:"https://block-explorer-api.sepolia.zksync.dev/api"}},contracts:{multicall3:{address:"0xF9cda624FBC7e059355ce98a31693d299FACd963"},universalSignatureVerifier:{address:"0xfB688330379976DA81eB64Fe4BF50d7401763B9C",blockCreated:3855712}},testnet:!0}),sourceId$2=1,zora=defineChain({...chainConfig$2,id:7777777,name:"Zora",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.zora.energy",apiUrl:"https://explorer.zora.energy/api"}},contracts:{...chainConfig$2.contracts,l2OutputOracle:{[sourceId$2]:{address:"0x9E6204F750cD866b299594e2aC9eA824E2e5f95c"}},multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:5882},portal:{[sourceId$2]:{address:"0x1a0ad011913A150f69f6A19DF447A0CfD9551054"}},l1StandardBridge:{[sourceId$2]:{address:"0x3e2Ea9B92B7E48A52296fD261dc26fd995284631"}}},sourceId:sourceId$2}),sourceId$1=11155111,zoraSepolia=defineChain({...chainConfig$2,id:999999999,name:"Zora Sepolia",network:"zora-sepolia",nativeCurrency:{decimals:18,name:"Zora Sepolia",symbol:"ETH"},rpcUrls:{default:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]}},blockExplorers:{default:{name:"Zora Sepolia Explorer",url:"https://sepolia.explorer.zora.energy/",apiUrl:"https://sepolia.explorer.zora.energy/api"}},contracts:{...chainConfig$2.contracts,l2OutputOracle:{[sourceId$1]:{address:"0x2615B481Bd3E5A1C0C7Ca3Da1bdc663E8615Ade9"}},multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:83160},portal:{[sourceId$1]:{address:"0xeffE2C6cA9Ab797D418f0D91eA60807713f3536f"}},l1StandardBridge:{[sourceId$1]:{address:"0x5376f1D543dcbB5BD416c56C189e4cB7399fCcCB"}}},sourceId:sourceId$1,testnet:!0}),sourceId=5,zoraTestnet=defineChain({...chainConfig$2,id:999,name:"Zora Goerli Testnet",nativeCurrency:{decimals:18,name:"Zora Goerli",symbol:"ETH"},rpcUrls:{default:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://testnet.explorer.zora.energy",apiUrl:"https://testnet.explorer.zora.energy/api"}},contracts:{...chainConfig$2.contracts,multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:189123},portal:{[sourceId]:{address:"0xDb9F51790365e7dc196e7D072728df39Be958ACe"}}},sourceId,testnet:!0}),viemChains=Object.freeze(Object.defineProperty({__proto__:null,abey,abstractTestnet,acala,acria,aioz,alienx,alienxHalTestnet,ancient8,ancient8Sepolia,anvil,apeChain,apexTestnet,arbitrum,arbitrumGoerli,arbitrumNova,arbitrumSepolia,areonNetwork,areonNetworkTestnet,artelaTestnet,assetChain,assetChainTestnet,astar,astarZkEVM,astarZkyoto,atletaOlympia,aurora,auroraTestnet,auroria,avalanche,avalancheFuji,b3,b3Sepolia,bahamut,base:base$7,baseGoerli,baseSepolia:baseSepolia$1,beam,beamTestnet,bearNetworkChainMainnet,bearNetworkChainTestnet,berachainTestnet,berachainTestnetbArtio,bevmMainnet,bifrost,bitTorrent,bitTorrentTestnet,bitgert,bitkub,bitkubTestnet,bitlayer,bitlayerTestnet,bitrock,blast,blastSepolia,bob,bobSepolia,boba,bobaSepolia,boolBetaMainnet,botanixTestnet,bounceBit,bounceBitTestnet,bronos,bronosTestnet,bsc,bscGreenfield,bscTestnet,bsquared,bsquaredTestnet,btr,btrTestnet,bxn,bxnTestnet,cannon,canto,celo,celoAlfajores,chang,chiliz,chips,classic,coinbit,coinex,confluxESpace,confluxESpaceTestnet,coreDao,crab,cronos,cronosTestnet,cronoszkEVM,cronoszkEVMTestnet,crossbell,curtis,cyber,cyberTestnet,darwinia,dchain,dchainTestnet,defichainEvm,defichainEvmTestnet,degen,dfk,diode,disChain,dodochainTestnet,dogechain,dosChain,dosChainTestnet,dreyerxMainnet,dreyerxTestnet,dustboyIoT,dymension,edgeless,edgelessTestnet,edgeware,edgewareTestnet,ekta,ektaTestnet,elastos,elastosTestnet,electroneum,electroneumTestnet,elysiumTestnet,energy,enuls,eon,eos,eosTestnet,etherlink,etherlinkTestnet,evmos,evmosTestnet,excelonMainnet,expanse,fantom,fantomSonicTestnet,fantomTestnet,fibo,filecoin,filecoinCalibration,filecoinHyperspace,fireChain,flare,flareTestnet,flowMainnet,flowPreviewnet,flowTestnet,fluence,fluenceStage,fluenceTestnet,forma,foundry,fraxtal,fraxtalTestnet,funkiMainnet,funkiSepolia,fuse,fuseSparknet,fusion,fusionTestnet,garnet,geist,genesys,glideL1Protocol,glideL2Protocol,gnosis,gnosisChiado,goChain,gobi,godwoken,goerli,gravity,guruNetwork,guruTestnet,ham,haqqMainnet,haqqTestedge2,hardhat,harmonyOne,hashkeyTestnet,hedera,hederaPreviewnet,hederaTestnet,hela,hemiSepolia,holesky,hpb,hychain,hychainTestnet,iSunCoin,idchain,immutableZkEvm,immutableZkEvmTestnet,inEVM,inkSepolia,iota,iotaTestnet,iotex,iotexTestnet,jbc,jbcTestnet,kaia,kairos,kakarotSepolia,kakarotStarknetSepolia,kardiaChain,karura,kava,kavaTestnet,kcc,kinto,klaytn,klaytnBaobab,koi,kroma,kromaSepolia,l3x,l3xTestnet,lavita,lightlinkPegasus,lightlinkPhoenix,linea,lineaGoerli,lineaSepolia,lineaTestnet,lisk,liskSepolia,localhost,loop,lukso,luksoTestnet,lycan,lyra,mainnet,mandala,manta,mantaSepoliaTestnet,mantaTestnet,mantle,mantleSepoliaTestnet,mantleTestnet,mapProtocol,matchain,matchainTestnet,mchVerse,mekong,meld,merlin,metachain,metachainIstanbul,metadium,metalL2,meter,meterTestnet,metis,metisGoerli,mev,mevTestnet,mint,mintSepoliaTestnet,mode,modeTestnet,moonbaseAlpha,moonbeam,moonbeamDev,moonriver,morph,morphHolesky,morphSepolia,nahmii,nautilus,neonDevnet,neonMainnet,nexi,nexilix,oasisTestnet,oasys,odysseyTestnet,okc,omax,oneWorld,oortMainnetDev,opBNB,opBNBTestnet,optimism,optimismGoerli,optimismSepolia,optopia,optopiaTestnet,orderly,orderlySepolia,otimDevnet,palm,palmTestnet,pgn,pgnTestnet,phoenix,planq,playfiAlbireo,plinga,plumeTestnet,polterTestnet,polygon,polygonAmoy,polygonMumbai,polygonZkEvm,polygonZkEvmCardona,polygonZkEvmTestnet,pulsechain,pulsechainV4,qMainnet,qTestnet,ql1,real,redbellyTestnet,redstone,rei,reyaNetwork,rollux,rolluxTestnet,ronin,root,rootPorcini,rootstock,rootstockTestnet,rss3,rss3Sepolia,saakuru,saigon,sanko,sapphire,sapphireTestnet,satoshiVM,satoshiVMTestnet,scroll,scrollSepolia,sei,seiDevnet,seiTestnet,sepolia,shape,shapeSepolia,shardeumSphinx,shibarium,shibariumTestnet,shiden,shimmer,shimmerTestnet,silicon,siliconSepolia,sixProtocol,skaleBlockBrawlers,skaleCalypso,skaleCalypsoTestnet,skaleCryptoBlades,skaleCryptoColosseum,skaleEuropa,skaleEuropaTestnet,skaleExorde,skaleHumanProtocol,skaleNebula,skaleNebulaTestnet,skaleRazor,skaleTitan,skaleTitanTestnet,sketchpad,snax,snaxTestnet,soneiumMinato,songbird,songbirdTestnet,sonicTestnet,sophon,sophonTestnet,spicy,step,storyTestnet,stratis,superlumio,superposition,swan,swanProximaTestnet,swanSaturnTestnet,swissdlt,syscoin,syscoinTestnet,taiko,taikoHekla,taikoJolnir,taikoKatla,taikoTestnetSepolia,taraxa,taraxaTestnet,telcoinTestnet,telos,telosTestnet,tenet,thaiChain,that,theta,thetaTestnet,thunderCore,thunderTestnet,tiktrixTestnet,tomb,tron,ubiq,ultron,ultronTestnet,unichainSepolia,unique,uniqueOpal,uniqueQuartz,unreal,vanar,vechain,velas,viction,victionTestnet,vision,visionTestnet,wanchain,wanchainTestnet,weaveVMAlphanet,wemix,wemixTestnet,worldLand,worldchain,worldchainSepolia,x1Testnet:xLayerTestnet,xLayer,xLayerTestnet,xai,xaiTestnet,xdc,xdcTestnet,xrSepolia,yooldoVerse,yooldoVerseTestnet,zenchainTestnet,zeniq,zetachain,zetachainAthensTestnet,zhejiang,zilliqa,zilliqaTestnet,zircuit,zircuitTestnet,zkFair,zkFairTestnet,zkLinkNova,zkLinkNovaSepoliaTestnet,zkSync:zksync,zkSyncInMemoryNode:zksyncInMemoryNode,zkSyncLocalNode:zksyncLocalNode,zkSyncSepoliaTestnet:zksyncSepoliaTestnet,zksync,zksyncInMemoryNode,zksyncLocalNode,zksyncSepoliaTestnet,zora,zoraSepolia,zoraTestnet},Symbol.toStringTag,{value:"Module"})),require$$1$3=getAugmentedNamespace(viemChains);var validator={},hasRequiredValidator$1;function requireValidator$1(){return hasRequiredValidator$1||(hasRequiredValidator$1=1,Object.defineProperty(validator,"__esModule",{value:!0}),validator.validatorABI=void 0,validator.validatorABI=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"previousAdmin",type:"address"},{indexed:!1,internalType:"address",name:"newAdmin",type:"address"}],name:"AdminChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"beacon",type:"address"}],name:"BeaconUpgraded",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint16",name:"valPerBlock",type:"uint16"},{indexed:!1,internalType:"uint16",name:"valPerBlockTarget",type:"uint16"}],name:"BlockParamsUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint8",name:"version",type:"uint8"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"ownerWallet",type:"address"},{indexed:!0,internalType:"address",name:"nodeWallet",type:"address"},{indexed:!1,internalType:"enum ValidatorV1.NodeType",name:"nodeType",type:"uint8"},{indexed:!1,internalType:"uint256",name:"nodeTokens",type:"uint256"},{indexed:!1,internalType:"string",name:"nodeApiBaseUrl",type:"string"}],name:"NodeAdded",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"nodeWallet",type:"address"},{indexed:!1,internalType:"address",name:"reporterWallet",type:"address"},{indexed:!1,internalType:"address[]",name:"voters",type:"address[]"},{indexed:!1,internalType:"enum ValidatorV1.VoteAction",name:"voteAction",type:"uint8"}],name:"NodeReported",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"nodeWallet",type:"address"},{indexed:!1,internalType:"enum ValidatorV1.NodeStatus",name:"nodeStatus",type:"uint8"},{indexed:!1,internalType:"uint256",name:"nodeTokens",type:"uint256"}],name:"NodeStatusChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferStarted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint16",name:"nodeRandomMinCount",type:"uint16"},{indexed:!1,internalType:"uint16",name:"nodeRandomPingCount",type:"uint16"}],name:"RandomParamsUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{inputs:[],name:"BAN_PERCENT",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[],name:"REPORTS_BEFORE_SLASH_S",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[],name:"REPORTS_BEFORE_SLASH_V",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[],name:"REPORT_THRESHOLD_PER_BLOCK",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[],name:"SLASHES_BEFORE_BAN_S",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[],name:"SLASHES_BEFORE_BAN_V",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[],name:"SLASH_PERCENT",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[],name:"VERSION",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"acceptOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"dnodes",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getActiveVNodes",outputs:[{components:[{internalType:"address",name:"nodeWallet",type:"address"},{internalType:"string",name:"nodeApiBaseUrl",type:"string"}],internalType:"struct ValidatorV1.ActiveValidator[]",name:"",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDNodes",outputs:[{internalType:"address[]",name:"",type:"address[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDNodesLength",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"_nodeWallet",type:"address"}],name:"getNodeInfo",outputs:[{components:[{internalType:"address",name:"ownerWallet",type:"address"},{internalType:"address",name:"nodeWallet",type:"address"},{internalType:"enum ValidatorV1.NodeType",name:"nodeType",type:"uint8"},{internalType:"uint256",name:"nodeTokens",type:"uint256"},{internalType:"string",name:"nodeApiBaseUrl",type:"string"},{components:[{internalType:"uint16",name:"reportCounter",type:"uint16"},{internalType:"uint16",name:"slashCounter",type:"uint16"},{internalType:"uint128[]",name:"reportedInBlocks",type:"uint128[]"},{internalType:"address[]",name:"reportedBy",type:"address[]"},{internalType:"uint128[]",name:"reportedKeys",type:"uint128[]"}],internalType:"struct ValidatorV1.NodeCounters",name:"counters",type:"tuple"},{internalType:"enum ValidatorV1.NodeStatus",name:"status",type:"uint8"}],internalType:"struct ValidatorV1.NodeInfo",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getSNodes",outputs:[{internalType:"address[]",name:"",type:"address[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getSNodesLength",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVNodes",outputs:[{internalType:"address[]",name:"",type:"address[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVNodesLength",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint16",name:"protocolVersion_",type:"uint16"},{internalType:"address",name:"pushToken_",type:"address"},{internalType:"uint16",name:"valPerBlockTarget_",type:"uint16"},{internalType:"uint16",name:"nodeRandomMinCount_",type:"uint16"},{internalType:"uint16",name:"nodeRandomPingCount_",type:"uint16"},{internalType:"uint16",name:"REPORTS_BEFORE_SLASH_V_",type:"uint16"},{internalType:"uint16",name:"REPORTS_BEFORE_SLASH_S_",type:"uint16"},{internalType:"uint16",name:"SLASHES_BEFORE_BAN_V_",type:"uint16"},{internalType:"uint16",name:"SLASHES_BEFORE_BAN_S_",type:"uint16"},{internalType:"uint16",name:"SLASH_PERCENT_",type:"uint16"},{internalType:"uint16",name:"BAN_PERCENT_",type:"uint16"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"minStakeD",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"minStakeS",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"minStakeV",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"nodeMap",outputs:[{internalType:"address",name:"ownerWallet",type:"address"},{internalType:"address",name:"nodeWallet",type:"address"},{internalType:"enum ValidatorV1.NodeType",name:"nodeType",type:"uint8"},{internalType:"uint256",name:"nodeTokens",type:"uint256"},{internalType:"string",name:"nodeApiBaseUrl",type:"string"},{components:[{internalType:"uint16",name:"reportCounter",type:"uint16"},{internalType:"uint16",name:"slashCounter",type:"uint16"},{internalType:"uint128[]",name:"reportedInBlocks",type:"uint128[]"},{internalType:"address[]",name:"reportedBy",type:"address[]"},{internalType:"uint128[]",name:"reportedKeys",type:"uint128[]"}],internalType:"struct ValidatorV1.NodeCounters",name:"counters",type:"tuple"},{internalType:"enum ValidatorV1.NodeStatus",name:"status",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"nodeRandomMinCount",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[],name:"nodeRandomPingCount",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pendingOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"protocolVersion",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[],name:"proxiableUUID",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from_",type:"address"},{internalType:"address",name:"to_",type:"address"},{internalType:"uint256",name:"amount_",type:"uint256"}],name:"redistributeStaked",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"nodeTokens_",type:"uint256"},{internalType:"enum ValidatorV1.NodeType",name:"nodeType_",type:"uint8"},{internalType:"string",name:"nodeApiBaseUrl_",type:"string"},{internalType:"address",name:"nodeWallet_",type:"address"}],name:"registerNodeAndStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"enum ValidatorV1.NodeType",name:"targetNodeType_",type:"uint8"},{internalType:"bytes",name:"voteBlob_",type:"bytes"},{internalType:"bytes[]",name:"signatures_",type:"bytes[]"}],name:"reportNode",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"addr_",type:"address"}],name:"setStorageContract",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"snodes",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"storageContract",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalFees",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalStaked",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to_",type:"address"},{internalType:"uint256",name:"amount_",type:"uint256"}],name:"unstakeFees",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"nodeWallet_",type:"address"}],name:"unstakeNode",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint16",name:"valPerBlockTarget_",type:"uint16"}],name:"updateBlockParams",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint16",name:"nodeRandomMinCount_",type:"uint16"},{internalType:"uint16",name:"nodeRandomPingCount_",type:"uint16"}],name:"updateRandomParams",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newImplementation",type:"address"}],name:"upgradeTo",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newImplementation",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"upgradeToAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"valPerBlock",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[],name:"valPerBlockTarget",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"vnodes",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"vnodesActive",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"}]),validator}var hasRequiredConfig;function requireConfig(){if(hasRequiredConfig)return config$6;hasRequiredConfig=1,Object.defineProperty(config$6,"__esModule",{value:!0});const fr=requireConstants$3(),br=require$$1$3,Er={ABIS:{VALIDATOR:requireValidator$1().validatorABI},VALIDATOR:{[fr.ENV.PROD]:{NETWORK:br.mainnet,VALIDATOR_CONTRACT:"TODO"},[fr.ENV.STAGING]:{NETWORK:br.sepolia,VALIDATOR_CONTRACT:"TODO"},[fr.ENV.DEV]:{NETWORK:br.sepolia,VALIDATOR_CONTRACT:"0x98dBfb001cB2623cF7BfE2A17755592E151f0779"},[fr.ENV.LOCAL]:{NETWORK:br.localhost,VALIDATOR_CONTRACT:"0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9"}},WALLET_URL:{[fr.ENV.PROD]:"TODO",[fr.ENV.STAGING]:"TODO",[fr.ENV.DEV]:"https://push-protocol.github.io/push-wallet/",[fr.ENV.LOCAL]:"http://localhost:5174/"}};return config$6.default=Er,config$6}var hasRequiredValidator;function requireValidator(){if(hasRequiredValidator)return validator$1;hasRequiredValidator=1;var fr;Object.defineProperty(validator$1,"__esModule",{value:!0}),validator$1.Validator=void 0;const br=require$$0$b,wr=requireUtils$5(),Er=require$$2$3,kr=require$$1$4,jr=requireConfig(),Br=requireConstants$3();class Wr{constructor(Hr,Vr,Zr){this.activeValidatorURL=Hr,this.env=Vr,this.validatorContractClient=Zr,this.ReqModifier=(Jr,Qr)=>{let _n=fr.vNodeUrlModifier(Jr),En=Qr;return(Qr==="push_getBlocks"||Qr==="push_getBlockByHash"||Qr==="push_getTransactions"||Qr==="push_getTransactionByHash"||Qr==="push_getTransactionsByUser"||Qr==="push_getTransactionsBySender"||Qr==="push_getTransactionsByRecipient")&&(this.env===Br.ENV.LOCAL&&(_n="http://localhost:5001/rpc"),this.env===Br.ENV.DEV&&(_n="https://aa1.dev.push.org/rpc"),En=`RpcService.${Qr.replace("push_","")}`,Qr==="push_getTransactions"&&(En="RpcService.getTxs"),Qr==="push_getTransactionsByUser"&&(En="RpcService.getTransactionsByUser"),Qr==="push_getTransactionsBySender"&&(En="RpcService.getTxsBySender"),Qr==="push_getTransactionsByRecipient"&&(En="RpcService.getTxsByRecipient"),Qr==="push_getTransactionByHash"&&(En="RpcService.getTxByHash")),{url:_n,fnName:En}},this.call=(Jr,...Qr)=>br.__awaiter(this,[Jr,...Qr],void 0,function*(_n,En=[],Cn=this.activeValidatorURL){return yield fr.sendJsonRpcRequest(this.ReqModifier(Cn,_n).url,this.ReqModifier(Cn,_n).fnName,En)}),(this.env===Br.ENV.DEV||this.env===Br.ENV.LOCAL)&&(fr.printTraces=!0)}callVNode(Hr){return br.__awaiter(this,arguments,void 0,function*(Vr,Zr=[],Jr=this.activeValidatorURL){const Qr=fr.fixVNodeUrl(Jr);return yield fr.sendJsonRpcRequest(Qr,Vr,Zr)})}static fixVNodeUrl(Hr){if(Hr==null||Hr.length==0)return Hr;const Vr=new URL(Hr);return Vr.hostname.endsWith(".local")?(Vr.hostname="localhost",Vr.protocol="http:"):Vr.protocol="https:",(Vr.pathname.trim().length==0||Vr.pathname.trim()==="/")&&(Vr.pathname="/api/v1/rpc"),Vr.pathname.endsWith("/")&&(Vr.pathname=Vr.pathname.slice(0,-1)),Vr.toString()}}return validator$1.Validator=Wr,fr=Wr,Wr.idCounter=0,Wr.printTraces=!1,Wr.initalize=qr=>br.__awaiter(void 0,void 0,void 0,function*(){const Hr={env:(qr==null?void 0:qr.env)||Br.ENV.STAGING};if(!fr.instance||fr.instance.env!==Hr.env){const Vr=fr.createValidatorContractClient(Hr.env),Zr=yield fr.getActiveValidator(Vr);fr.instance=new fr(Zr.nodeApiBaseUrl,Hr.env,Vr)}return fr.instance}),Wr.createValidatorContractClient=qr=>{const Hr=(0,kr.createPublicClient)({chain:jr.default.VALIDATOR[qr].NETWORK,transport:(0,kr.http)("https://proportionate-multi-sanctuary.ethereum-sepolia.quiknode.pro/fe3638bd884a34c0aa6c85ce2cd62ef54b0d8442/")});return(0,kr.getContract)({abi:jr.default.ABIS.VALIDATOR,address:jr.default.VALIDATOR[qr].VALIDATOR_CONTRACT,client:{public:Hr}})},Wr.sendJsonRpcRequest=(qr,Hr,...Vr)=>br.__awaiter(void 0,[qr,Hr,...Vr],void 0,function*(Zr,Jr,Qr=[]){const _n={jsonrpc:"2.0",method:Jr,params:Qr,id:fr.idCounter++};try{fr.printTraces&&console.log(`>> Calling RPC POST ${Zr} (req${_n.id}) with body %o`,_n);const En=yield Er.default.post(Zr,_n,{headers:{"Content-Type":"application/json"}});if(En.data.error)throw console.error("JSON-RPC Error:",En.data.error),Error(En.data.error.message);return fr.printTraces&&console.log(`<< RPC Reply POST ${Zr} (req${_n.id}) code: ${En.status} with body: %o`,En==null?void 0:En.data),En.data.result}catch(En){throw console.error("Error sending JSON-RPC request:",En),En}}),Wr.ping=qr=>br.__awaiter(void 0,void 0,void 0,function*(){return yield fr.sendJsonRpcRequest(fr.vNodeUrlModifier(qr),"push_listening")}),Wr.getActiveValidator=qr=>br.__awaiter(void 0,void 0,void 0,function*(){const Hr=yield qr.read.getActiveVNodes(),Vr=(0,wr.getRandomElement)(Hr);return(yield fr.ping(Vr.nodeApiBaseUrl))?Vr:yield fr.getActiveValidator(qr)}),Wr.vNodeUrlModifier=qr=>{let Hr=qr;return qr.includes(".local")&&(Hr=qr.replace(".local",".localh")),`${Hr}/api/v1/rpc`},validator$1}var block={},wire={},binaryEncoding={},varint={},hasRequiredVarint;function requireVarint(){if(hasRequiredVarint)return varint;hasRequiredVarint=1,Object.defineProperty(varint,"__esModule",{value:!0}),varint.varint64read=fr,varint.varint64write=br,varint.int64FromString=Er,varint.int64ToString=kr,varint.uInt64ToString=jr,varint.varint32write=Vr,varint.varint32read=Zr;function fr(){let Jr=0,Qr=0;for(let En=0;En<28;En+=7){let Cn=this.buf[this.pos++];if(Jr|=(Cn&127)<>4,!(_n&128))return this.assertBounds(),[Jr,Qr];for(let En=3;En<=31;En+=7){let Cn=this.buf[this.pos++];if(Qr|=(Cn&127)<>>In,jn=!(!(An>>>7)&&Qr==0),eo=(jn?An|128:An)&255;if(_n.push(eo),!jn)return}const En=Jr>>>28&15|(Qr&7)<<4,Cn=!!(Qr>>3);if(_n.push((Cn?En|128:En)&255),!!Cn){for(let In=3;In<31;In=In+7){const An=Qr>>>In,jn=!!(An>>>7),eo=(jn?An|128:An)&255;if(_n.push(eo),!jn)return}_n.push(Qr>>>31&1)}}const wr=4294967296;function Er(Jr){const Qr=Jr[0]==="-";Qr&&(Jr=Jr.slice(1));const _n=1e6;let En=0,Cn=0;function In(An,jn){const eo=Number(Jr.slice(An,jn));Cn*=_n,En=En*_n+eo,En>=wr&&(Cn=Cn+(En/wr|0),En=En%wr)}return In(-24,-18),In(-18,-12),In(-12,-6),In(-6),Qr?qr(En,Cn):Wr(En,Cn)}function kr(Jr,Qr){let _n=Wr(Jr,Qr);const En=_n.hi&2147483648;En&&(_n=qr(_n.lo,_n.hi));const Cn=jr(_n.lo,_n.hi);return En?"-"+Cn:Cn}function jr(Jr,Qr){if({lo:Jr,hi:Qr}=Br(Jr,Qr),Qr<=2097151)return String(wr*Qr+Jr);const _n=Jr&16777215,En=(Jr>>>24|Qr<<8)&16777215,Cn=Qr>>16&65535;let In=_n+En*6777216+Cn*6710656,An=En+Cn*8147497,jn=Cn*2;const eo=1e7;return In>=eo&&(An+=Math.floor(In/eo),In%=eo),An>=eo&&(jn+=Math.floor(An/eo),An%=eo),jn.toString()+Hr(An)+Hr(In)}function Br(Jr,Qr){return{lo:Jr>>>0,hi:Qr>>>0}}function Wr(Jr,Qr){return{lo:Jr|0,hi:Qr|0}}function qr(Jr,Qr){return Qr=~Qr,Jr?Jr=~Jr+1:Qr+=1,Wr(Jr,Qr)}const Hr=Jr=>{const Qr=String(Jr);return"0000000".slice(Qr.length)+Qr};function Vr(Jr,Qr){if(Jr>=0){for(;Jr>127;)Qr.push(Jr&127|128),Jr=Jr>>>7;Qr.push(Jr)}else{for(let _n=0;_n<9;_n++)Qr.push(Jr&127|128),Jr=Jr>>7;Qr.push(1)}}function Zr(){let Jr=this.buf[this.pos++],Qr=Jr&127;if(!(Jr&128))return this.assertBounds(),Qr;if(Jr=this.buf[this.pos++],Qr|=(Jr&127)<<7,!(Jr&128))return this.assertBounds(),Qr;if(Jr=this.buf[this.pos++],Qr|=(Jr&127)<<14,!(Jr&128))return this.assertBounds(),Qr;if(Jr=this.buf[this.pos++],Qr|=(Jr&127)<<21,!(Jr&128))return this.assertBounds(),Qr;Jr=this.buf[this.pos++],Qr|=(Jr&15)<<28;for(let _n=5;Jr&128&&_n<10;_n++)Jr=this.buf[this.pos++];if(Jr&128)throw new Error("invalid varint");return this.assertBounds(),Qr>>>0}return varint}var protoInt64={},hasRequiredProtoInt64;function requireProtoInt64(){if(hasRequiredProtoInt64)return protoInt64;hasRequiredProtoInt64=1;var fr={};Object.defineProperty(protoInt64,"__esModule",{value:!0}),protoInt64.protoInt64=void 0;const br=requireVarint();protoInt64.protoInt64=wr();function wr(){const jr=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof jr.getBigInt64=="function"&&typeof jr.getBigUint64=="function"&&typeof jr.setBigInt64=="function"&&typeof jr.setBigUint64=="function"&&(typeof process$1$1!="object"||typeof fr!="object"||fr.BUF_BIGINT_DISABLE!=="1")){const Wr=BigInt("-9223372036854775808"),qr=BigInt("9223372036854775807"),Hr=BigInt("0"),Vr=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(Zr){const Jr=typeof Zr=="bigint"?Zr:BigInt(Zr);if(Jr>qr||JrVr||Jr>>0)}raw(Zr){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(Zr),this}uint32(Zr){for(qr(Zr);Zr>127;)this.buf.push(Zr&127|128),Zr=Zr>>>7;return this.buf.push(Zr),this}int32(Zr){return Wr(Zr),(0,br.varint32write)(Zr,this.buf),this}bool(Zr){return this.buf.push(Zr?1:0),this}bytes(Zr){return this.uint32(Zr.byteLength),this.raw(Zr)}string(Zr){let Jr=this.encodeUtf8(Zr);return this.uint32(Jr.byteLength),this.raw(Jr)}float(Zr){Hr(Zr);let Jr=new Uint8Array(4);return new DataView(Jr.buffer).setFloat32(0,Zr,!0),this.raw(Jr)}double(Zr){let Jr=new Uint8Array(8);return new DataView(Jr.buffer).setFloat64(0,Zr,!0),this.raw(Jr)}fixed32(Zr){qr(Zr);let Jr=new Uint8Array(4);return new DataView(Jr.buffer).setUint32(0,Zr,!0),this.raw(Jr)}sfixed32(Zr){Wr(Zr);let Jr=new Uint8Array(4);return new DataView(Jr.buffer).setInt32(0,Zr,!0),this.raw(Jr)}sint32(Zr){return Wr(Zr),Zr=(Zr<<1^Zr>>31)>>>0,(0,br.varint32write)(Zr,this.buf),this}sfixed64(Zr){let Jr=new Uint8Array(8),Qr=new DataView(Jr.buffer),_n=wr.protoInt64.enc(Zr);return Qr.setInt32(0,_n.lo,!0),Qr.setInt32(4,_n.hi,!0),this.raw(Jr)}fixed64(Zr){let Jr=new Uint8Array(8),Qr=new DataView(Jr.buffer),_n=wr.protoInt64.uEnc(Zr);return Qr.setInt32(0,_n.lo,!0),Qr.setInt32(4,_n.hi,!0),this.raw(Jr)}int64(Zr){let Jr=wr.protoInt64.enc(Zr);return(0,br.varint64write)(Jr.lo,Jr.hi,this.buf),this}sint64(Zr){let Jr=wr.protoInt64.enc(Zr),Qr=Jr.hi>>31,_n=Jr.lo<<1^Qr,En=(Jr.hi<<1|Jr.lo>>>31)^Qr;return(0,br.varint64write)(_n,En,this.buf),this}uint64(Zr){let Jr=wr.protoInt64.uEnc(Zr);return(0,br.varint64write)(Jr.lo,Jr.hi,this.buf),this}}fr.BinaryWriter=jr;class Br{constructor(Zr,Jr=(0,Er.getTextEncoding)().decodeUtf8){this.decodeUtf8=Jr,this.varint64=br.varint64read,this.uint32=br.varint32read,this.buf=Zr,this.len=Zr.length,this.pos=0,this.view=new DataView(Zr.buffer,Zr.byteOffset,Zr.byteLength)}tag(){let Zr=this.uint32(),Jr=Zr>>>3,Qr=Zr&7;if(Jr<=0||Qr<0||Qr>5)throw new Error("illegal tag: field no "+Jr+" wire type "+Qr);return[Jr,Qr]}skip(Zr,Jr){let Qr=this.pos;switch(Zr){case kr.Varint:for(;this.buf[this.pos++]&128;);break;case kr.Bit64:this.pos+=4;case kr.Bit32:this.pos+=4;break;case kr.LengthDelimited:let _n=this.uint32();this.pos+=_n;break;case kr.StartGroup:for(;;){const[En,Cn]=this.tag();if(Cn===kr.EndGroup){if(Jr!==void 0&&En!==Jr)throw new Error("invalid end group tag");break}this.skip(Cn,En)}break;default:throw new Error("cant skip wire type "+Zr)}return this.assertBounds(),this.buf.subarray(Qr,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let Zr=this.uint32();return Zr>>>1^-(Zr&1)}int64(){return wr.protoInt64.dec(...this.varint64())}uint64(){return wr.protoInt64.uDec(...this.varint64())}sint64(){let[Zr,Jr]=this.varint64(),Qr=-(Zr&1);return Zr=(Zr>>>1|(Jr&1)<<31)^Qr,Jr=Jr>>>1^Qr,wr.protoInt64.dec(Zr,Jr)}bool(){let[Zr,Jr]=this.varint64();return Zr!==0||Jr!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return wr.protoInt64.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return wr.protoInt64.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let Zr=this.uint32(),Jr=this.pos;return this.pos+=Zr,this.assertBounds(),this.buf.subarray(Jr,Jr+Zr)}string(){return this.decodeUtf8(this.bytes())}}fr.BinaryReader=Br;function Wr(Vr){if(typeof Vr=="string")Vr=Number(Vr);else if(typeof Vr!="number")throw new Error("invalid int32: "+typeof Vr);if(!Number.isInteger(Vr)||Vr>fr.INT32_MAX||Vrfr.UINT32_MAX||Vr<0)throw new Error("invalid uint32: "+Vr)}function Hr(Vr){if(typeof Vr=="string"){const Zr=Vr;if(Vr=Number(Vr),isNaN(Vr)&&Zr!=="NaN")throw new Error("invalid float32: "+Zr)}else if(typeof Vr!="number")throw new Error("invalid float32: "+typeof Vr);if(Number.isFinite(Vr)&&(Vr>fr.FLOAT32_MAX||Vrkr+String.fromCharCode(jr),""))}function base64StringToBase64UrlEncodedString(fr){return fr.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function uint8ArrayToHexString(fr){return fr.reduce((br,wr)=>br+wr.toString(16).padStart(2,"0"),"")}const uint8ArrayFromHexString=(fr,br)=>{const wr=/^[0-9A-Fa-f]+$/;if(!fr||fr.length%2!=0||!wr.test(fr))throw new Error(`cannot create uint8array from invalid hex string: "${fr}"`);const Er=new Uint8Array(fr.match(/../g).map(jr=>parseInt(jr,16)));if(!br)return Er;if(fr.length/2>br)throw new Error("hex value cannot fit in a buffer of "+br+" byte(s)");let kr=new Uint8Array(br);return kr.set(Er,br-Er.length),kr};function btoa$1(fr){if(arguments.length===0)throw new TypeError("1 argument required, but only 0 present.");let br;for(fr=`${fr}`,br=0;br255)throw new Error(`InvalidCharacterError: found code point greater than 255:${fr.charCodeAt(br)} at position ${br}`);let wr="";for(br=0;br>2,Er[1]=(fr.charCodeAt(br)&3)<<4,fr.length>br+1&&(Er[1]|=fr.charCodeAt(br+1)>>4,Er[2]=(fr.charCodeAt(br+1)&15)<<2),fr.length>br+2&&(Er[2]|=fr.charCodeAt(br+2)>>6,Er[3]=fr.charCodeAt(br+2)&63);for(let kr=0;kr"u"?wr+="=":wr+=btoaLookup(Er[kr])}return wr}function btoaLookup(fr){const br="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";if(fr>=0&&fr<64)return br[fr]}const stampHeaderName$2="X-Stamp",isCryptoEnabledBrowser=typeof window<"u"&&typeof window.document<"u"&&typeof crypto<"u"&&typeof crypto.subtle<"u",isNode=typeof process$1$1<"u"&&process$1$1.versions!=null&&process$1$1.versions.node!=null,signWithApiKey=async fr=>isCryptoEnabledBrowser?(await __vitePreload(()=>import("./webcrypto-BG4hfxBn.js"),__vite__mapDeps([0,1])).then(wr=>wr.signWithApiKey))(fr):isNode?(await __vitePreload(()=>import("./nodecrypto-DBt_cM49.js"),__vite__mapDeps([2,1])).then(wr=>wr.signWithApiKey))(fr):(await __vitePreload(()=>import("./purejs-D68kuBYn.js"),[]).then(wr=>wr.signWithApiKey))(fr);class ApiKeyStamper{constructor(br){this.apiPublicKey=br.apiPublicKey,this.apiPrivateKey=br.apiPrivateKey}async stamp(br){const wr=await signWithApiKey({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:br}),Er={publicKey:this.apiPublicKey,scheme:"SIGNATURE_SCHEME_TK_API_P256",signature:wr};return{stampHeaderName:stampHeaderName$2,stampHeaderValue:stringToBase64urlString(JSON.stringify(Er))}}}const base64UrlEncode=fr=>Buffer$2.from(fr).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,""),generateRandomBuffer=()=>{const fr=new Uint8Array(32);return crypto.getRandomValues(fr),fr.buffer},transportMap={AUTHENTICATOR_TRANSPORT_BLE:AuthenticatorTransportProtocol.Ble,AUTHENTICATOR_TRANSPORT_HYBRID:AuthenticatorTransportProtocol.Hybrid,AUTHENTICATOR_TRANSPORT_INTERNAL:AuthenticatorTransportProtocol.Internal,AUTHENTICATOR_TRANSPORT_NFC:AuthenticatorTransportProtocol.Nfc,AUTHENTICATOR_TRANSPORT_USB:AuthenticatorTransportProtocol.Usb},convertAttestationTransports=fr=>fr.map(br=>transportMap[br]),TURNKEY_API_BASE_URL="https://api.turnkey.com",TURNKEY_API_KEY_EXPIRY_MESSAGE="Turnkey error 16: expired api key",TURNKEY_API_KEY_NOT_FOUND_MESSAGE="Turnkey error 16: could not find public key",WEBAUTHN_NOT_SUPPORTED_OR_CANCELLED_ERROR_MESSAGE="The operation either timed out or was not allowed",WEBAUTHN_NOT_SUPPORTED_OR_DISABLED_ERROR_MESSAGE="The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.",INVALID_PASSKEY_SELECTED_ERROR_MESSAGE="Turnkey error 5: webauthn authenticator not found in organization or parent organization",USER_CANCELLED_REQUEST_ERROR_MESSAGE="The user cancelled the request",TURNKEY_SDK_SESSION_KEY_RETRYABLE_ERRORS=[TURNKEY_API_KEY_EXPIRY_MESSAGE,TURNKEY_API_KEY_NOT_FOUND_MESSAGE],TURNKEY_SDK_BENIGN_ERRORS=[WEBAUTHN_NOT_SUPPORTED_OR_CANCELLED_ERROR_MESSAGE,WEBAUTHN_NOT_SUPPORTED_OR_DISABLED_ERROR_MESSAGE,INVALID_PASSKEY_SELECTED_ERROR_MESSAGE,USER_CANCELLED_REQUEST_ERROR_MESSAGE];class DynamicEmbeddedWalletsLogger extends Logger$1{constructor(br,wr){super(br,wr)}error(br,...wr){const[Er]=wr;!(Er!=null&&Er.message)||!TURNKEY_SDK_BENIGN_ERRORS.some(kr=>Er.message.includes(kr))?(Logger$1.events.emit("error",br),this.log(LogLevel.ERROR,br,...wr)):this.warn(br,...wr)}}const logger$4=new DynamicEmbeddedWalletsLogger("Dynamic embedded wallets",LogLevel.INFO),stampHeaderName$1="X-Stamp";var IframeEventType;(function(fr){fr.PublicKeyReady="PUBLIC_KEY_READY",fr.InjectCredentialBundle="INJECT_CREDENTIAL_BUNDLE",fr.InjectKeyExportBundle="INJECT_KEY_EXPORT_BUNDLE",fr.InjectWalletExportBundle="INJECT_WALLET_EXPORT_BUNDLE",fr.InjectImportBundle="INJECT_IMPORT_BUNDLE",fr.ExtractWalletEncryptedBundle="EXTRACT_WALLET_ENCRYPTED_BUNDLE",fr.ExtractKeyEncryptedBundle="EXTRACT_KEY_ENCRYPTED_BUNDLE",fr.ApplySettings="APPLY_SETTINGS",fr.BundleInjected="BUNDLE_INJECTED",fr.EncryptedBundleExtracted="ENCRYPTED_BUNDLE_EXTRACTED",fr.SettingsApplied="SETTINGS_APPLIED",fr.StampRequest="STAMP_REQUEST",fr.Stamp="STAMP",fr.Error="ERROR"})(IframeEventType||(IframeEventType={}));var KeyFormat;(function(fr){fr.Hexadecimal="HEXADECIMAL",fr.Solana="SOLANA"})(KeyFormat||(KeyFormat={}));class IframeStamper{constructor(br){if(typeof window>"u")throw new Error("Cannot initialize iframe in non-browser environment");if(!br.iframeContainer)throw new Error("Iframe container cannot be found");if(this.container=br.iframeContainer,this.container.querySelector(`#${br.iframeElementId}`))throw new Error(`Iframe element with ID ${br.iframeElementId} already exists`);let wr=window.document.createElement("iframe");wr.setAttribute("sandbox","allow-scripts allow-same-origin"),wr.id=br.iframeElementId,wr.src=br.iframeUrl,this.iframe=wr;const Er=new URL(br.iframeUrl);this.iframeOrigin=Er.origin,this.iframePublicKey=null}async init(){return this.container.appendChild(this.iframe),new Promise((br,wr)=>{window.addEventListener("message",Er=>{var kr;Er.origin===this.iframeOrigin&&((kr=Er.data)==null?void 0:kr.type)===IframeEventType.PublicKeyReady&&(this.iframePublicKey=Er.data.value,br(Er.data.value))},!1)})}clear(){this.iframe.remove()}publicKey(){return this.iframePublicKey}async injectCredentialBundle(br){return new Promise((wr,Er)=>{var kr;(kr=this.iframe.contentWindow)==null||kr.postMessage({type:IframeEventType.InjectCredentialBundle,value:br},"*"),window.addEventListener("message",jr=>{var Br,Wr;jr.origin===this.iframeOrigin&&(((Br=jr.data)==null?void 0:Br.type)===IframeEventType.BundleInjected&&wr(jr.data.value),((Wr=jr.data)==null?void 0:Wr.type)===IframeEventType.Error&&Er(jr.data.value))},!1)})}async injectKeyExportBundle(br,wr,Er){var kr;return(kr=this.iframe.contentWindow)==null||kr.postMessage({type:IframeEventType.InjectKeyExportBundle,value:br,keyFormat:Er,organizationId:wr},"*"),new Promise((jr,Br)=>{window.addEventListener("message",Wr=>{var qr,Hr;Wr.origin===this.iframeOrigin&&(((qr=Wr.data)==null?void 0:qr.type)===IframeEventType.BundleInjected&&jr(Wr.data.value),((Hr=Wr.data)==null?void 0:Hr.type)===IframeEventType.Error&&Br(Wr.data.value))},!1)})}async injectWalletExportBundle(br,wr){var Er;return(Er=this.iframe.contentWindow)==null||Er.postMessage({type:IframeEventType.InjectWalletExportBundle,value:br,organizationId:wr},"*"),new Promise((kr,jr)=>{window.addEventListener("message",Br=>{var Wr,qr;Br.origin===this.iframeOrigin&&(((Wr=Br.data)==null?void 0:Wr.type)===IframeEventType.BundleInjected&&kr(Br.data.value),((qr=Br.data)==null?void 0:qr.type)===IframeEventType.Error&&jr(Br.data.value))},!1)})}async injectImportBundle(br,wr,Er){var kr;return(kr=this.iframe.contentWindow)==null||kr.postMessage({type:IframeEventType.InjectImportBundle,value:br,organizationId:wr,userId:Er},"*"),new Promise((jr,Br)=>{window.addEventListener("message",Wr=>{var qr,Hr;Wr.origin===this.iframeOrigin&&(((qr=Wr.data)==null?void 0:qr.type)===IframeEventType.BundleInjected&&jr(Wr.data.value),((Hr=Wr.data)==null?void 0:Hr.type)===IframeEventType.Error&&Br(Wr.data.value))},!1)})}async extractWalletEncryptedBundle(){var br;return(br=this.iframe.contentWindow)==null||br.postMessage({type:IframeEventType.ExtractWalletEncryptedBundle},"*"),new Promise((wr,Er)=>{window.addEventListener("message",kr=>{var jr,Br;kr.origin===this.iframeOrigin&&(((jr=kr.data)==null?void 0:jr.type)===IframeEventType.EncryptedBundleExtracted&&wr(kr.data.value),((Br=kr.data)==null?void 0:Br.type)===IframeEventType.Error&&Er(kr.data.value))},!1)})}async extractKeyEncryptedBundle(br){var wr;return(wr=this.iframe.contentWindow)==null||wr.postMessage({type:IframeEventType.ExtractKeyEncryptedBundle,keyFormat:br},"*"),new Promise((Er,kr)=>{window.addEventListener("message",jr=>{var Br,Wr;jr.origin===this.iframeOrigin&&(((Br=jr.data)==null?void 0:Br.type)===IframeEventType.EncryptedBundleExtracted&&Er(jr.data.value),((Wr=jr.data)==null?void 0:Wr.type)===IframeEventType.Error&&kr(jr.data.value))},!1)})}async applySettings(br){var Er;const wr=JSON.stringify(br);return(Er=this.iframe.contentWindow)==null||Er.postMessage({type:IframeEventType.ApplySettings,value:wr},"*"),new Promise((kr,jr)=>{window.addEventListener("message",Br=>{var Wr,qr;Br.origin===this.iframeOrigin&&(((Wr=Br.data)==null?void 0:Wr.type)===IframeEventType.SettingsApplied&&kr(Br.data.value),((qr=Br.data)==null?void 0:qr.type)===IframeEventType.Error&&jr(Br.data.value))},!1)})}async stamp(br){var Er;if(this.iframePublicKey===null)throw new Error("null iframe public key. Have you called/awaited .init()?");const wr=this.iframeOrigin;return(Er=this.iframe.contentWindow)==null||Er.postMessage({type:IframeEventType.StampRequest,value:br},"*"),new Promise(function(kr,jr){window.addEventListener("message",Br=>{var Wr,qr;Br.origin===wr&&(((Wr=Br.data)==null?void 0:Wr.type)===IframeEventType.Stamp&&kr({stampHeaderName:stampHeaderName$1,stampHeaderValue:Br.data.value}),((qr=Br.data)==null?void 0:qr.type)===IframeEventType.Error&&jr(Br.data.value))},!1)})}}var browserPonyfill={exports:{}};(function(fr,br){var wr=typeof self<"u"?self:commonjsGlobal,Er=function(){function jr(){this.fetch=!1,this.DOMException=wr.DOMException}return jr.prototype=wr,new jr}();(function(jr){(function(Br){var Wr={searchParams:"URLSearchParams"in jr,iterable:"Symbol"in jr&&"iterator"in Symbol,blob:"FileReader"in jr&&"Blob"in jr&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in jr,arrayBuffer:"ArrayBuffer"in jr};function qr(Gr){return Gr&&DataView.prototype.isPrototypeOf(Gr)}if(Wr.arrayBuffer)var Hr=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],Vr=ArrayBuffer.isView||function(Gr){return Gr&&Hr.indexOf(Object.prototype.toString.call(Gr))>-1};function Zr(Gr){if(typeof Gr!="string"&&(Gr=String(Gr)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(Gr))throw new TypeError("Invalid character in header field name");return Gr.toLowerCase()}function Jr(Gr){return typeof Gr!="string"&&(Gr=String(Gr)),Gr}function Qr(Gr){var Xr={next:function(){var Sn=Gr.shift();return{done:Sn===void 0,value:Sn}}};return Wr.iterable&&(Xr[Symbol.iterator]=function(){return Xr}),Xr}function _n(Gr){this.map={},Gr instanceof _n?Gr.forEach(function(Xr,Sn){this.append(Sn,Xr)},this):Array.isArray(Gr)?Gr.forEach(function(Xr){this.append(Xr[0],Xr[1])},this):Gr&&Object.getOwnPropertyNames(Gr).forEach(function(Xr){this.append(Xr,Gr[Xr])},this)}_n.prototype.append=function(Gr,Xr){Gr=Zr(Gr),Xr=Jr(Xr);var Sn=this.map[Gr];this.map[Gr]=Sn?Sn+", "+Xr:Xr},_n.prototype.delete=function(Gr){delete this.map[Zr(Gr)]},_n.prototype.get=function(Gr){return Gr=Zr(Gr),this.has(Gr)?this.map[Gr]:null},_n.prototype.has=function(Gr){return this.map.hasOwnProperty(Zr(Gr))},_n.prototype.set=function(Gr,Xr){this.map[Zr(Gr)]=Jr(Xr)},_n.prototype.forEach=function(Gr,Xr){for(var Sn in this.map)this.map.hasOwnProperty(Sn)&&Gr.call(Xr,this.map[Sn],Sn,this)},_n.prototype.keys=function(){var Gr=[];return this.forEach(function(Xr,Sn){Gr.push(Sn)}),Qr(Gr)},_n.prototype.values=function(){var Gr=[];return this.forEach(function(Xr){Gr.push(Xr)}),Qr(Gr)},_n.prototype.entries=function(){var Gr=[];return this.forEach(function(Xr,Sn){Gr.push([Sn,Xr])}),Qr(Gr)},Wr.iterable&&(_n.prototype[Symbol.iterator]=_n.prototype.entries);function En(Gr){if(Gr.bodyUsed)return Promise.reject(new TypeError("Already read"));Gr.bodyUsed=!0}function Cn(Gr){return new Promise(function(Xr,Sn){Gr.onload=function(){Xr(Gr.result)},Gr.onerror=function(){Sn(Gr.error)}})}function In(Gr){var Xr=new FileReader,Sn=Cn(Xr);return Xr.readAsArrayBuffer(Gr),Sn}function An(Gr){var Xr=new FileReader,Sn=Cn(Xr);return Xr.readAsText(Gr),Sn}function jn(Gr){for(var Xr=new Uint8Array(Gr),Sn=new Array(Xr.length),Rn=0;Rn-1?Xr:Gr}function oo(Gr,Xr){Xr=Xr||{};var Sn=Xr.body;if(Gr instanceof oo){if(Gr.bodyUsed)throw new TypeError("Already read");this.url=Gr.url,this.credentials=Gr.credentials,Xr.headers||(this.headers=new _n(Gr.headers)),this.method=Gr.method,this.mode=Gr.mode,this.signal=Gr.signal,!Sn&&Gr._bodyInit!=null&&(Sn=Gr._bodyInit,Gr.bodyUsed=!0)}else this.url=String(Gr);if(this.credentials=Xr.credentials||this.credentials||"same-origin",(Xr.headers||!this.headers)&&(this.headers=new _n(Xr.headers)),this.method=_i(Xr.method||this.method||"GET"),this.mode=Xr.mode||this.mode||null,this.signal=Xr.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&Sn)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(Sn)}oo.prototype.clone=function(){return new oo(this,{body:this._bodyInit})};function io(Gr){var Xr=new FormData;return Gr.trim().split("&").forEach(function(Sn){if(Sn){var Rn=Sn.split("="),Pn=Rn.shift().replace(/\+/g," "),On=Rn.join("=").replace(/\+/g," ");Xr.append(decodeURIComponent(Pn),decodeURIComponent(On))}}),Xr}function co(Gr){var Xr=new _n,Sn=Gr.replace(/\r?\n[\t ]+/g," ");return Sn.split(/\r?\n/).forEach(function(Rn){var Pn=Rn.split(":"),On=Pn.shift().trim();if(On){var Zn=Pn.join(":").trim();Xr.append(On,Zn)}}),Xr}ro.call(oo.prototype);function so(Gr,Xr){Xr||(Xr={}),this.type="default",this.status=Xr.status===void 0?200:Xr.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in Xr?Xr.statusText:"OK",this.headers=new _n(Xr.headers),this.url=Xr.url||"",this._initBody(Gr)}ro.call(so.prototype),so.prototype.clone=function(){return new so(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new _n(this.headers),url:this.url})},so.error=function(){var Gr=new so(null,{status:0,statusText:""});return Gr.type="error",Gr};var no=[301,302,303,307,308];so.redirect=function(Gr,Xr){if(no.indexOf(Xr)===-1)throw new RangeError("Invalid status code");return new so(null,{status:Xr,headers:{location:Gr}})},Br.DOMException=jr.DOMException;try{new Br.DOMException}catch{Br.DOMException=function(Xr,Sn){this.message=Xr,this.name=Sn;var Rn=Error(Xr);this.stack=Rn.stack},Br.DOMException.prototype=Object.create(Error.prototype),Br.DOMException.prototype.constructor=Br.DOMException}function Tn(Gr,Xr){return new Promise(function(Sn,Rn){var Pn=new oo(Gr,Xr);if(Pn.signal&&Pn.signal.aborted)return Rn(new Br.DOMException("Aborted","AbortError"));var On=new XMLHttpRequest;function Zn(){On.abort()}On.onload=function(){var Nn={status:On.status,statusText:On.statusText,headers:co(On.getAllResponseHeaders()||"")};Nn.url="responseURL"in On?On.responseURL:Nn.headers.get("X-Request-URL");var wn="response"in On?On.response:On.responseText;Sn(new so(wn,Nn))},On.onerror=function(){Rn(new TypeError("Network request failed"))},On.ontimeout=function(){Rn(new TypeError("Network request failed"))},On.onabort=function(){Rn(new Br.DOMException("Aborted","AbortError"))},On.open(Pn.method,Pn.url,!0),Pn.credentials==="include"?On.withCredentials=!0:Pn.credentials==="omit"&&(On.withCredentials=!1),"responseType"in On&&Wr.blob&&(On.responseType="blob"),Pn.headers.forEach(function(Nn,wn){On.setRequestHeader(wn,Nn)}),Pn.signal&&(Pn.signal.addEventListener("abort",Zn),On.onreadystatechange=function(){On.readyState===4&&Pn.signal.removeEventListener("abort",Zn)}),On.send(typeof Pn._bodyInit>"u"?null:Pn._bodyInit)})}return Tn.polyfill=!0,jr.fetch||(jr.fetch=Tn,jr.Headers=_n,jr.Request=oo,jr.Response=so),Br.Headers=_n,Br.Request=oo,Br.Response=so,Br.fetch=Tn,Object.defineProperty(Br,"__esModule",{value:!0}),Br})({})})(Er),Er.fetch.ponyfill=!0,delete Er.fetch.polyfill;var kr=Er;br=kr.fetch,br.default=kr.fetch,br.fetch=kr.fetch,br.Headers=kr.Headers,br.Request=kr.Request,br.Response=kr.Response,fr.exports=br})(browserPonyfill,browserPonyfill.exports);var browserPonyfillExports=browserPonyfill.exports;const o$2=getDefaultExportFromCjs$2(browserPonyfillExports),fetch$1=browserPonyfillExports.fetch;class TurnkeyRequestError extends Error{constructor(br){let wr=`Turnkey error ${br.code}: ${br.message}`;br.details!=null&&(wr+=` (Details: ${JSON.stringify(br.details)})`),super(wr),this.name="TurnkeyRequestError",this.details=br.details??null,this.code=br.code}}const VERSION$1="@turnkey/http@2.12.2";class TurnkeyClient{constructor(br,wr){if(this.getActivity=async Er=>this.request("/public/v1/query/get_activity",Er),this.stampGetActivity=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_activity",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getApiKey=async Er=>this.request("/public/v1/query/get_api_key",Er),this.stampGetApiKey=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_api_key",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getApiKeys=async Er=>this.request("/public/v1/query/get_api_keys",Er),this.stampGetApiKeys=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_api_keys",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getAttestationDocument=async Er=>this.request("/public/v1/query/get_attestation",Er),this.stampGetAttestationDocument=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_attestation",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getAuthenticator=async Er=>this.request("/public/v1/query/get_authenticator",Er),this.stampGetAuthenticator=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_authenticator",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getAuthenticators=async Er=>this.request("/public/v1/query/get_authenticators",Er),this.stampGetAuthenticators=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_authenticators",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getOauthProviders=async Er=>this.request("/public/v1/query/get_oauth_providers",Er),this.stampGetOauthProviders=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_oauth_providers",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getOrganization=async Er=>this.request("/public/v1/query/get_organization",Er),this.stampGetOrganization=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_organization",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getOrganizationConfigs=async Er=>this.request("/public/v1/query/get_organization_configs",Er),this.stampGetOrganizationConfigs=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_organization_configs",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getPolicy=async Er=>this.request("/public/v1/query/get_policy",Er),this.stampGetPolicy=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_policy",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getPrivateKey=async Er=>this.request("/public/v1/query/get_private_key",Er),this.stampGetPrivateKey=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_private_key",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getUser=async Er=>this.request("/public/v1/query/get_user",Er),this.stampGetUser=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_user",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getWallet=async Er=>this.request("/public/v1/query/get_wallet",Er),this.stampGetWallet=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_wallet",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getActivities=async Er=>this.request("/public/v1/query/list_activities",Er),this.stampGetActivities=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_activities",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getPolicies=async Er=>this.request("/public/v1/query/list_policies",Er),this.stampGetPolicies=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_policies",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.listPrivateKeyTags=async Er=>this.request("/public/v1/query/list_private_key_tags",Er),this.stampListPrivateKeyTags=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_private_key_tags",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getPrivateKeys=async Er=>this.request("/public/v1/query/list_private_keys",Er),this.stampGetPrivateKeys=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_private_keys",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getSubOrgIds=async Er=>this.request("/public/v1/query/list_suborgs",Er),this.stampGetSubOrgIds=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_suborgs",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.listUserTags=async Er=>this.request("/public/v1/query/list_user_tags",Er),this.stampListUserTags=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_user_tags",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getUsers=async Er=>this.request("/public/v1/query/list_users",Er),this.stampGetUsers=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_users",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getWalletAccounts=async Er=>this.request("/public/v1/query/list_wallet_accounts",Er),this.stampGetWalletAccounts=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_wallet_accounts",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getWallets=async Er=>this.request("/public/v1/query/list_wallets",Er),this.stampGetWallets=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_wallets",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getWhoami=async Er=>this.request("/public/v1/query/whoami",Er),this.stampGetWhoami=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/whoami",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.approveActivity=async Er=>this.request("/public/v1/submit/approve_activity",Er),this.stampApproveActivity=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/approve_activity",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createApiKeys=async Er=>this.request("/public/v1/submit/create_api_keys",Er),this.stampCreateApiKeys=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_api_keys",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createApiOnlyUsers=async Er=>this.request("/public/v1/submit/create_api_only_users",Er),this.stampCreateApiOnlyUsers=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_api_only_users",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createAuthenticators=async Er=>this.request("/public/v1/submit/create_authenticators",Er),this.stampCreateAuthenticators=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_authenticators",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createInvitations=async Er=>this.request("/public/v1/submit/create_invitations",Er),this.stampCreateInvitations=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_invitations",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createOauthProviders=async Er=>this.request("/public/v1/submit/create_oauth_providers",Er),this.stampCreateOauthProviders=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_oauth_providers",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createPolicies=async Er=>this.request("/public/v1/submit/create_policies",Er),this.stampCreatePolicies=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_policies",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createPolicy=async Er=>this.request("/public/v1/submit/create_policy",Er),this.stampCreatePolicy=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_policy",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createPrivateKeyTag=async Er=>this.request("/public/v1/submit/create_private_key_tag",Er),this.stampCreatePrivateKeyTag=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_private_key_tag",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createPrivateKeys=async Er=>this.request("/public/v1/submit/create_private_keys",Er),this.stampCreatePrivateKeys=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_private_keys",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createReadOnlySession=async Er=>this.request("/public/v1/submit/create_read_only_session",Er),this.stampCreateReadOnlySession=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_read_only_session",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createReadWriteSession=async Er=>this.request("/public/v1/submit/create_read_write_session",Er),this.stampCreateReadWriteSession=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_read_write_session",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createSubOrganization=async Er=>this.request("/public/v1/submit/create_sub_organization",Er),this.stampCreateSubOrganization=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_sub_organization",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createUserTag=async Er=>this.request("/public/v1/submit/create_user_tag",Er),this.stampCreateUserTag=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_user_tag",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createUsers=async Er=>this.request("/public/v1/submit/create_users",Er),this.stampCreateUsers=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_users",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createWallet=async Er=>this.request("/public/v1/submit/create_wallet",Er),this.stampCreateWallet=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_wallet",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createWalletAccounts=async Er=>this.request("/public/v1/submit/create_wallet_accounts",Er),this.stampCreateWalletAccounts=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_wallet_accounts",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deleteApiKeys=async Er=>this.request("/public/v1/submit/delete_api_keys",Er),this.stampDeleteApiKeys=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_api_keys",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deleteAuthenticators=async Er=>this.request("/public/v1/submit/delete_authenticators",Er),this.stampDeleteAuthenticators=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_authenticators",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deleteInvitation=async Er=>this.request("/public/v1/submit/delete_invitation",Er),this.stampDeleteInvitation=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_invitation",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deleteOauthProviders=async Er=>this.request("/public/v1/submit/delete_oauth_providers",Er),this.stampDeleteOauthProviders=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_oauth_providers",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deletePolicy=async Er=>this.request("/public/v1/submit/delete_policy",Er),this.stampDeletePolicy=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_policy",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deletePrivateKeyTags=async Er=>this.request("/public/v1/submit/delete_private_key_tags",Er),this.stampDeletePrivateKeyTags=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_private_key_tags",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deleteUserTags=async Er=>this.request("/public/v1/submit/delete_user_tags",Er),this.stampDeleteUserTags=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_user_tags",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deleteUsers=async Er=>this.request("/public/v1/submit/delete_users",Er),this.stampDeleteUsers=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_users",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.emailAuth=async Er=>this.request("/public/v1/submit/email_auth",Er),this.stampEmailAuth=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/email_auth",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.exportPrivateKey=async Er=>this.request("/public/v1/submit/export_private_key",Er),this.stampExportPrivateKey=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/export_private_key",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.exportWallet=async Er=>this.request("/public/v1/submit/export_wallet",Er),this.stampExportWallet=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/export_wallet",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.exportWalletAccount=async Er=>this.request("/public/v1/submit/export_wallet_account",Er),this.stampExportWalletAccount=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/export_wallet_account",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.importPrivateKey=async Er=>this.request("/public/v1/submit/import_private_key",Er),this.stampImportPrivateKey=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/import_private_key",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.importWallet=async Er=>this.request("/public/v1/submit/import_wallet",Er),this.stampImportWallet=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/import_wallet",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.initImportPrivateKey=async Er=>this.request("/public/v1/submit/init_import_private_key",Er),this.stampInitImportPrivateKey=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/init_import_private_key",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.initImportWallet=async Er=>this.request("/public/v1/submit/init_import_wallet",Er),this.stampInitImportWallet=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/init_import_wallet",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.initUserEmailRecovery=async Er=>this.request("/public/v1/submit/init_user_email_recovery",Er),this.stampInitUserEmailRecovery=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/init_user_email_recovery",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.oauth=async Er=>this.request("/public/v1/submit/oauth",Er),this.stampOauth=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/oauth",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.recoverUser=async Er=>this.request("/public/v1/submit/recover_user",Er),this.stampRecoverUser=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/recover_user",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.rejectActivity=async Er=>this.request("/public/v1/submit/reject_activity",Er),this.stampRejectActivity=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/reject_activity",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.removeOrganizationFeature=async Er=>this.request("/public/v1/submit/remove_organization_feature",Er),this.stampRemoveOrganizationFeature=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/remove_organization_feature",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.setOrganizationFeature=async Er=>this.request("/public/v1/submit/set_organization_feature",Er),this.stampSetOrganizationFeature=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/set_organization_feature",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.signRawPayload=async Er=>this.request("/public/v1/submit/sign_raw_payload",Er),this.stampSignRawPayload=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/sign_raw_payload",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.signRawPayloads=async Er=>this.request("/public/v1/submit/sign_raw_payloads",Er),this.stampSignRawPayloads=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/sign_raw_payloads",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.signTransaction=async Er=>this.request("/public/v1/submit/sign_transaction",Er),this.stampSignTransaction=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/sign_transaction",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.updatePolicy=async Er=>this.request("/public/v1/submit/update_policy",Er),this.stampUpdatePolicy=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/update_policy",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.updatePrivateKeyTag=async Er=>this.request("/public/v1/submit/update_private_key_tag",Er),this.stampUpdatePrivateKeyTag=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/update_private_key_tag",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.updateRootQuorum=async Er=>this.request("/public/v1/submit/update_root_quorum",Er),this.stampUpdateRootQuorum=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/update_root_quorum",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.updateUser=async Er=>this.request("/public/v1/submit/update_user",Er),this.stampUpdateUser=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/update_user",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.updateUserTag=async Er=>this.request("/public/v1/submit/update_user_tag",Er),this.stampUpdateUserTag=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/update_user_tag",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},!br.baseUrl)throw new Error("Missing base URL. Please verify env vars.");this.config=br,this.stamper=wr}async request(br,wr){const Er=this.config.baseUrl+br,kr=JSON.stringify(wr),jr=await this.stamper.stamp(kr),Br=await fetch$1(Er,{method:"POST",headers:{[jr.stampHeaderName]:jr.stampHeaderValue,"X-Client-Version":VERSION$1},body:kr,redirect:"follow"});if(!Br.ok){let qr;try{qr=await Br.json()}catch{throw new Error(`${Br.status} ${Br.statusText}`)}throw new TurnkeyRequestError(qr)}return await Br.json()}}class TurnkeyActivityError extends Error{constructor(br){const{message:wr,cause:Er,activityId:kr,activityStatus:jr,activityType:Br}=br;super(wr),this.name="TurnkeyActivityError",this.activityId=kr??null,this.activityStatus=jr??null,this.activityType=Br??null,this.cause=Er??null}}function bufferToBase64url(fr){const br=new Uint8Array(fr);let wr="";for(const jr of br)wr+=String.fromCharCode(jr);return btoa(wr).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}const copyValue="copy",convertValue="convert";function convert$1(fr,br,wr){if(br===copyValue)return wr;if(br===convertValue)return fr(wr);if(br instanceof Array)return wr.map(Er=>convert$1(fr,br[0],Er));if(br instanceof Object){const Er={};for(const[kr,jr]of Object.entries(br)){if(jr.derive){const Br=jr.derive(wr);Br!==void 0&&(wr[kr]=Br)}if(!(kr in wr)){if(jr.required)throw new Error(`Missing key: ${kr}`);continue}if(wr[kr]==null){Er[kr]=null;continue}Er[kr]=convert$1(fr,jr.schema,wr[kr])}return Er}}function derived(fr,br){return{required:!0,schema:fr,derive:br}}function required(fr){return{required:!0,schema:fr}}function optional$3(fr){return{required:!1,schema:fr}}const simplifiedClientExtensionResultsSchema={appid:optional$3(copyValue),appidExclude:optional$3(copyValue),credProps:optional$3(copyValue)},publicKeyCredentialWithAssertion={type:required(copyValue),id:required(copyValue),rawId:required(convertValue),authenticatorAttachment:optional$3(copyValue),response:required({clientDataJSON:required(convertValue),authenticatorData:required(convertValue),signature:required(convertValue),userHandle:required(convertValue)}),clientExtensionResults:derived(simplifiedClientExtensionResultsSchema,fr=>fr.getClientExtensionResults())};function getResponseToJSON(fr){return convert$1(bufferToBase64url,publicKeyCredentialWithAssertion,fr)}async function get$2(fr){const br=await navigator.credentials.get(fr);return br.toJSON=()=>getResponseToJSON(br),br}const K$2=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998];function createHash(fr){return new Hash}class Hash{constructor(){this.A=1779033703,this.B=-1150833019,this.C=1013904242,this.D=-1521486534,this.E=1359893119,this.F=-1694144372,this.G=528734635,this.H=1541459225,this._size=0,this._sp=0,(!sharedBuffer||sharedOffset>=8e3)&&(sharedBuffer=new ArrayBuffer(8e3),sharedOffset=0),this._byte=new Uint8Array(sharedBuffer,sharedOffset,80),this._word=new Int32Array(sharedBuffer,sharedOffset,20),sharedOffset+=80}update(br){if(typeof br=="string")return this._utf8(br);if(br==null)throw new TypeError("Invalid type: "+typeof br);const wr=br.byteOffset,Er=br.byteLength;let kr=Er/64|0,jr=0;if(kr&&!(wr&3)&&!(this._size%64)){const Wr=new Int32Array(br.buffer,wr,kr*16);for(;kr--;)this._int32(Wr,jr>>2),jr+=64;this._size+=jr}if(br.BYTES_PER_ELEMENT!==1&&br.buffer){const Wr=new Uint8Array(br.buffer,wr+jr,Er-jr);return this._uint8(Wr)}return jr===Er?this:this._uint8(br,jr)}_uint8(br,wr){const{_byte:Er,_word:kr}=this,jr=br.length;for(wr=wr|0;wr=64&&this._int32(kr),this._size+=Wr-Br}return this}_utf8(br){const{_byte:wr,_word:Er}=this,kr=br.length;let jr=this._sp;for(let Br=0;Br>>6,wr[qr++]=128|Hr&63):Hr<55296||Hr>57343?(wr[qr++]=224|Hr>>>12,wr[qr++]=128|Hr>>>6&63,wr[qr++]=128|Hr&63):jr?(Hr=((jr&1023)<<10)+(Hr&1023)+65536,wr[qr++]=240|Hr>>>18,wr[qr++]=128|Hr>>>12&63,wr[qr++]=128|Hr>>>6&63,wr[qr++]=128|Hr&63,jr=0):jr=Hr}qr>=64&&(this._int32(Er),Er[0]=Er[16]),this._size+=qr-Wr}return this._sp=jr,this}_int32(br,wr){let{A:Er,B:kr,C:jr,D:Br,E:Wr,F:qr,G:Hr,H:Vr}=this,Zr=0;for(wr=wr|0;Zr<16;)W$1[Zr++]=swap32(br[wr++]);for(Zr=16;Zr<64;Zr++)W$1[Zr]=gamma1(W$1[Zr-2])+W$1[Zr-7]+gamma0(W$1[Zr-15])+W$1[Zr-16]|0;for(Zr=0;Zr<64;Zr++){const Jr=Vr+sigma1(Wr)+ch(Wr,qr,Hr)+K$2[Zr]+W$1[Zr]|0,Qr=sigma0(Er)+maj(Er,kr,jr)|0;Vr=Hr,Hr=qr,qr=Wr,Wr=Br+Jr|0,Br=jr,jr=kr,kr=Er,Er=Jr+Qr|0}this.A=Er+this.A|0,this.B=kr+this.B|0,this.C=jr+this.C|0,this.D=Br+this.D|0,this.E=Wr+this.E|0,this.F=qr+this.F|0,this.G=Hr+this.G|0,this.H=Vr+this.H|0}digest(br){const{_byte:wr,_word:Er}=this;let kr=this._size%64|0;for(wr[kr++]=128;kr&3;)wr[kr++]=0;if(kr>>=2,kr>14){for(;kr<16;)Er[kr++]=0;kr=0,this._int32(Er)}for(;kr<16;)Er[kr++]=0;const jr=this._size*8,Br=(jr&4294967295)>>>0,Wr=(jr-Br)/4294967296;return Wr&&(Er[14]=swap32(Wr)),Br&&(Er[15]=swap32(Br)),this._int32(Er),br==="hex"?this._hex():this._bin()}_hex(){const{A:br,B:wr,C:Er,D:kr,E:jr,F:Br,G:Wr,H:qr}=this;return hex32(br)+hex32(wr)+hex32(Er)+hex32(kr)+hex32(jr)+hex32(Br)+hex32(Wr)+hex32(qr)}_bin(){const{A:br,B:wr,C:Er,D:kr,E:jr,F:Br,G:Wr,H:qr,_byte:Hr,_word:Vr}=this;return Vr[0]=swap32(br),Vr[1]=swap32(wr),Vr[2]=swap32(Er),Vr[3]=swap32(kr),Vr[4]=swap32(jr),Vr[5]=swap32(Br),Vr[6]=swap32(Wr),Vr[7]=swap32(qr),Hr.slice(0,32)}}const W$1=new Int32Array(64);let sharedBuffer,sharedOffset=0;const hex32=fr=>(fr+4294967296).toString(16).substr(-8),swapLE=fr=>fr<<24&4278190080|fr<<8&16711680|fr>>8&65280|fr>>24&255,swapBE=fr=>fr,swap32=isBE()?swapBE:swapLE,ch=(fr,br,wr)=>wr^fr&(br^wr),maj=(fr,br,wr)=>fr&br|wr&(fr|br),sigma0=fr=>(fr>>>2|fr<<30)^(fr>>>13|fr<<19)^(fr>>>22|fr<<10),sigma1=fr=>(fr>>>6|fr<<26)^(fr>>>11|fr<<21)^(fr>>>25|fr<<7),gamma0=fr=>(fr>>>7|fr<<25)^(fr>>>18|fr<<14)^fr>>>3,gamma1=fr=>(fr>>>17|fr<<15)^(fr>>>19|fr<<13)^fr>>>10;function isBE(){return new Uint8Array(new Uint16Array([65279]).buffer)[0]===254}const stampHeaderName="X-Stamp-Webauthn",defaultTimeout=5*60*1e3,defaultUserVerification="preferred";class WebauthnStamper{constructor(br){this.rpId=br.rpId,this.timeout=br.timeout||defaultTimeout,this.userVerification=br.userVerification||defaultUserVerification,this.allowCredentials=br.allowCredentials||[]}async stamp(br){const wr=getChallengeFromPayload(br),Er={publicKey:{rpId:this.rpId,challenge:wr,allowCredentials:this.allowCredentials,timeout:this.timeout,userVerification:this.userVerification}},jr=(await get$2(Er)).toJSON(),Br={authenticatorData:jr.response.authenticatorData,clientDataJson:jr.response.clientDataJSON,credentialId:jr.id,signature:jr.response.signature};return{stampHeaderName,stampHeaderValue:JSON.stringify(Br)}}}function getChallengeFromPayload(fr){const br=createHash().update(fr).digest("hex");return new TextEncoder().encode(br)}var version$b="3.8.2";class WebauthnNotSupportedError extends Error{constructor(){super("Webauthn is not supported on this device")}}function __awaiter$b(fr,br,wr,Er){function kr(jr){return jr instanceof wr?jr:new wr(function(Br){Br(jr)})}return new(wr||(wr=Promise))(function(jr,Br){function Wr(Vr){try{Hr(Er.next(Vr))}catch(Zr){Br(Zr)}}function qr(Vr){try{Hr(Er.throw(Vr))}catch(Zr){Br(Zr)}}function Hr(Vr){Vr.done?jr(Vr.value):kr(Vr.value).then(Wr,qr)}Hr((Er=Er.apply(fr,[])).next())})}typeof SuppressedError=="function"&&SuppressedError;function utf8StringToBuffer(fr){return new TextEncoder().encode(fr)}function bufferToBase64URLString(fr){const br=new Uint8Array(fr);let wr="";for(const kr of br)wr+=String.fromCharCode(kr);return btoa(wr).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function base64URLStringToBuffer(fr){const br=fr.replace(/-/g,"+").replace(/_/g,"/"),wr=(4-br.length%4)%4,Er=br.padEnd(br.length+wr,"="),kr=atob(Er),jr=new ArrayBuffer(kr.length),Br=new Uint8Array(jr);for(let Wr=0;WrBr.type==="public-key").length===0?new WebAuthnError({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:fr}):new WebAuthnError({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:fr});if(fr.name==="SecurityError"){const jr=window.location.hostname;if(isValidDomain(jr)){if(wr.rp.id!==jr)return new WebAuthnError({message:`The RP ID "${wr.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:fr})}else return new WebAuthnError({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:fr})}else if(fr.name==="TypeError"){if(wr.user.id.byteLength<1||wr.user.id.byteLength>64)return new WebAuthnError({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:fr})}else if(fr.name==="UnknownError")return new WebAuthnError({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:fr})}return fr}class BaseWebAuthnAbortService{createNewAbortSignal(){if(this.controller){const wr=new Error("Cancelling existing WebAuthn API call for new one");wr.name="AbortError",this.controller.abort(wr)}const br=new AbortController;return this.controller=br,br.signal}cancelCeremony(){if(this.controller){const br=new Error("Manually cancelling existing WebAuthn API call");br.name="AbortError",this.controller.abort(br),this.controller=void 0}}}const WebAuthnAbortService=new BaseWebAuthnAbortService,attachments=["cross-platform","platform"];function toAuthenticatorAttachment(fr){if(fr&&!(attachments.indexOf(fr)<0))return fr}async function startRegistration(fr){var Jr;if(!browserSupportsWebAuthn())throw new Error("WebAuthn is not supported in this browser");const wr={publicKey:{...fr,challenge:base64URLStringToBuffer(fr.challenge),user:{...fr.user,id:utf8StringToBuffer(fr.user.id)},excludeCredentials:(Jr=fr.excludeCredentials)==null?void 0:Jr.map(toPublicKeyCredentialDescriptor)}};wr.signal=WebAuthnAbortService.createNewAbortSignal();let Er;try{Er=await navigator.credentials.create(wr)}catch(Qr){throw identifyRegistrationError({error:Qr,options:wr})}if(!Er)throw new Error("Registration was not completed");const{id:kr,rawId:jr,response:Br,type:Wr}=Er;let qr;typeof Br.getTransports=="function"&&(qr=Br.getTransports());let Hr;if(typeof Br.getPublicKeyAlgorithm=="function")try{Hr=Br.getPublicKeyAlgorithm()}catch(Qr){warnOnBrokenImplementation("getPublicKeyAlgorithm()",Qr)}let Vr;if(typeof Br.getPublicKey=="function")try{const Qr=Br.getPublicKey();Qr!==null&&(Vr=bufferToBase64URLString(Qr))}catch(Qr){warnOnBrokenImplementation("getPublicKey()",Qr)}let Zr;if(typeof Br.getAuthenticatorData=="function")try{Zr=bufferToBase64URLString(Br.getAuthenticatorData())}catch(Qr){warnOnBrokenImplementation("getAuthenticatorData()",Qr)}return{id:kr,rawId:bufferToBase64URLString(jr),response:{attestationObject:bufferToBase64URLString(Br.attestationObject),clientDataJSON:bufferToBase64URLString(Br.clientDataJSON),transports:qr,publicKeyAlgorithm:Hr,publicKey:Vr,authenticatorData:Zr},type:Wr,clientExtensionResults:Er.getClientExtensionResults(),authenticatorAttachment:toAuthenticatorAttachment(Er.authenticatorAttachment)}}function warnOnBrokenImplementation(fr,br){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${fr}. You should report this error to them. +`,themeConfig={dark:{blocksTheme:blocksTheme.dark,scheme:"dark"},light:{blocksTheme:blocksTheme.light,scheme:"light"}};function App(){const{isDarkMode:fr}=useDarkMode();return jsxRuntimeExports.jsxs(Le$2,{theme:fr?themeConfig.dark:themeConfig.light,children:[jsxRuntimeExports.jsx(GlobalStyle,{}),jsxRuntimeExports.jsx(GlobalProvider,{children:jsxRuntimeExports.jsx(BrowserRouter,{basename:getAppBasePath(),children:jsxRuntimeExports.jsx(RouterContainer,{})})})]})}typeof window<"u"&&(window.global=globalThis,Object.assign(window,{Buffer:Buffer$1$1}));var version$d="3.8.2",version$c="3.8.2";function __awaiter$c(fr,br,wr,Er){function kr(jr){return jr instanceof wr?jr:new wr(function(Br){Br(jr)})}return new(wr||(wr=Promise))(function(jr,Br){function Wr(Vr){try{Hr(Er.next(Vr))}catch(Zr){Br(Zr)}}function qr(Vr){try{Hr(Er.throw(Vr))}catch(Zr){Br(Zr)}}function Hr(Vr){Vr.done?jr(Vr.value):kr(Vr.value).then(Wr,qr)}Hr((Er=Er.apply(fr,br||[])).next())})}function __classPrivateFieldGet$4(fr,br,wr,Er){if(wr==="a"&&!Er)throw new TypeError("Private accessor was defined without a getter");if(typeof br=="function"?fr!==br||!Er:!br.has(fr))throw new TypeError("Cannot read private member from an object whose class did not declare it");return wr==="m"?Er:wr==="a"?Er.call(fr):Er?Er.value:br.get(fr)}function __classPrivateFieldSet$4(fr,br,wr,Er,kr){if(typeof br=="function"?fr!==br||!kr:!br.has(fr))throw new TypeError("Cannot write private member to an object whose class did not declare it");return kr?kr.value=wr:br.set(fr,wr),wr}typeof SuppressedError=="function"&&SuppressedError;const DEFAULT_JWK_MEMBER_BYTE_LENGTH=32;function stringToBase64urlString(fr){const br=btoa$1(fr);return base64StringToBase64UrlEncodedString(br)}function hexStringToBase64url(fr,br){const wr=fr.padStart(Math.ceil(fr.length/2)*2,"0"),Er=uint8ArrayFromHexString(wr,br);return stringToBase64urlString(Er.reduce((kr,jr)=>kr+String.fromCharCode(jr),""))}function base64StringToBase64UrlEncodedString(fr){return fr.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function uint8ArrayToHexString(fr){return fr.reduce((br,wr)=>br+wr.toString(16).padStart(2,"0"),"")}const uint8ArrayFromHexString=(fr,br)=>{const wr=/^[0-9A-Fa-f]+$/;if(!fr||fr.length%2!=0||!wr.test(fr))throw new Error(`cannot create uint8array from invalid hex string: "${fr}"`);const Er=new Uint8Array(fr.match(/../g).map(jr=>parseInt(jr,16)));if(!br)return Er;if(fr.length/2>br)throw new Error("hex value cannot fit in a buffer of "+br+" byte(s)");let kr=new Uint8Array(br);return kr.set(Er,br-Er.length),kr};function btoa$1(fr){if(arguments.length===0)throw new TypeError("1 argument required, but only 0 present.");let br;for(fr=`${fr}`,br=0;br255)throw new Error(`InvalidCharacterError: found code point greater than 255:${fr.charCodeAt(br)} at position ${br}`);let wr="";for(br=0;br>2,Er[1]=(fr.charCodeAt(br)&3)<<4,fr.length>br+1&&(Er[1]|=fr.charCodeAt(br+1)>>4,Er[2]=(fr.charCodeAt(br+1)&15)<<2),fr.length>br+2&&(Er[2]|=fr.charCodeAt(br+2)>>6,Er[3]=fr.charCodeAt(br+2)&63);for(let kr=0;kr"u"?wr+="=":wr+=btoaLookup(Er[kr])}return wr}function btoaLookup(fr){const br="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";if(fr>=0&&fr<64)return br[fr]}const stampHeaderName$2="X-Stamp",isCryptoEnabledBrowser=typeof window<"u"&&typeof window.document<"u"&&typeof crypto<"u"&&typeof crypto.subtle<"u",isNode=typeof process$1$1<"u"&&process$1$1.versions!=null&&process$1$1.versions.node!=null,signWithApiKey=async fr=>isCryptoEnabledBrowser?(await __vitePreload(()=>import("./webcrypto-D3OqlkPG.js"),__vite__mapDeps([0,1])).then(wr=>wr.signWithApiKey))(fr):isNode?(await __vitePreload(()=>import("./nodecrypto-D6j4PjE1.js"),__vite__mapDeps([2,1])).then(wr=>wr.signWithApiKey))(fr):(await __vitePreload(()=>import("./purejs-DbBnR00B.js"),[]).then(wr=>wr.signWithApiKey))(fr);class ApiKeyStamper{constructor(br){this.apiPublicKey=br.apiPublicKey,this.apiPrivateKey=br.apiPrivateKey}async stamp(br){const wr=await signWithApiKey({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:br}),Er={publicKey:this.apiPublicKey,scheme:"SIGNATURE_SCHEME_TK_API_P256",signature:wr};return{stampHeaderName:stampHeaderName$2,stampHeaderValue:stringToBase64urlString(JSON.stringify(Er))}}}const base64UrlEncode=fr=>Buffer$2.from(fr).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,""),generateRandomBuffer=()=>{const fr=new Uint8Array(32);return crypto.getRandomValues(fr),fr.buffer},transportMap={AUTHENTICATOR_TRANSPORT_BLE:AuthenticatorTransportProtocol.Ble,AUTHENTICATOR_TRANSPORT_HYBRID:AuthenticatorTransportProtocol.Hybrid,AUTHENTICATOR_TRANSPORT_INTERNAL:AuthenticatorTransportProtocol.Internal,AUTHENTICATOR_TRANSPORT_NFC:AuthenticatorTransportProtocol.Nfc,AUTHENTICATOR_TRANSPORT_USB:AuthenticatorTransportProtocol.Usb},convertAttestationTransports=fr=>fr.map(br=>transportMap[br]),TURNKEY_API_BASE_URL="https://api.turnkey.com",TURNKEY_API_KEY_EXPIRY_MESSAGE="Turnkey error 16: expired api key",TURNKEY_API_KEY_NOT_FOUND_MESSAGE="Turnkey error 16: could not find public key",WEBAUTHN_NOT_SUPPORTED_OR_CANCELLED_ERROR_MESSAGE="The operation either timed out or was not allowed",WEBAUTHN_NOT_SUPPORTED_OR_DISABLED_ERROR_MESSAGE="The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.",INVALID_PASSKEY_SELECTED_ERROR_MESSAGE="Turnkey error 5: webauthn authenticator not found in organization or parent organization",USER_CANCELLED_REQUEST_ERROR_MESSAGE="The user cancelled the request",TURNKEY_SDK_SESSION_KEY_RETRYABLE_ERRORS=[TURNKEY_API_KEY_EXPIRY_MESSAGE,TURNKEY_API_KEY_NOT_FOUND_MESSAGE],TURNKEY_SDK_BENIGN_ERRORS=[WEBAUTHN_NOT_SUPPORTED_OR_CANCELLED_ERROR_MESSAGE,WEBAUTHN_NOT_SUPPORTED_OR_DISABLED_ERROR_MESSAGE,INVALID_PASSKEY_SELECTED_ERROR_MESSAGE,USER_CANCELLED_REQUEST_ERROR_MESSAGE];class DynamicEmbeddedWalletsLogger extends Logger$1{constructor(br,wr){super(br,wr)}error(br,...wr){const[Er]=wr;!(Er!=null&&Er.message)||!TURNKEY_SDK_BENIGN_ERRORS.some(kr=>Er.message.includes(kr))?(Logger$1.events.emit("error",br),this.log(LogLevel.ERROR,br,...wr)):this.warn(br,...wr)}}const logger$4=new DynamicEmbeddedWalletsLogger("Dynamic embedded wallets",LogLevel.INFO),stampHeaderName$1="X-Stamp";var IframeEventType;(function(fr){fr.PublicKeyReady="PUBLIC_KEY_READY",fr.InjectCredentialBundle="INJECT_CREDENTIAL_BUNDLE",fr.InjectKeyExportBundle="INJECT_KEY_EXPORT_BUNDLE",fr.InjectWalletExportBundle="INJECT_WALLET_EXPORT_BUNDLE",fr.InjectImportBundle="INJECT_IMPORT_BUNDLE",fr.ExtractWalletEncryptedBundle="EXTRACT_WALLET_ENCRYPTED_BUNDLE",fr.ExtractKeyEncryptedBundle="EXTRACT_KEY_ENCRYPTED_BUNDLE",fr.ApplySettings="APPLY_SETTINGS",fr.BundleInjected="BUNDLE_INJECTED",fr.EncryptedBundleExtracted="ENCRYPTED_BUNDLE_EXTRACTED",fr.SettingsApplied="SETTINGS_APPLIED",fr.StampRequest="STAMP_REQUEST",fr.Stamp="STAMP",fr.Error="ERROR"})(IframeEventType||(IframeEventType={}));var KeyFormat;(function(fr){fr.Hexadecimal="HEXADECIMAL",fr.Solana="SOLANA"})(KeyFormat||(KeyFormat={}));class IframeStamper{constructor(br){if(typeof window>"u")throw new Error("Cannot initialize iframe in non-browser environment");if(!br.iframeContainer)throw new Error("Iframe container cannot be found");if(this.container=br.iframeContainer,this.container.querySelector(`#${br.iframeElementId}`))throw new Error(`Iframe element with ID ${br.iframeElementId} already exists`);let wr=window.document.createElement("iframe");wr.setAttribute("sandbox","allow-scripts allow-same-origin"),wr.id=br.iframeElementId,wr.src=br.iframeUrl,this.iframe=wr;const Er=new URL(br.iframeUrl);this.iframeOrigin=Er.origin,this.iframePublicKey=null}async init(){return this.container.appendChild(this.iframe),new Promise((br,wr)=>{window.addEventListener("message",Er=>{var kr;Er.origin===this.iframeOrigin&&((kr=Er.data)==null?void 0:kr.type)===IframeEventType.PublicKeyReady&&(this.iframePublicKey=Er.data.value,br(Er.data.value))},!1)})}clear(){this.iframe.remove()}publicKey(){return this.iframePublicKey}async injectCredentialBundle(br){return new Promise((wr,Er)=>{var kr;(kr=this.iframe.contentWindow)==null||kr.postMessage({type:IframeEventType.InjectCredentialBundle,value:br},"*"),window.addEventListener("message",jr=>{var Br,Wr;jr.origin===this.iframeOrigin&&(((Br=jr.data)==null?void 0:Br.type)===IframeEventType.BundleInjected&&wr(jr.data.value),((Wr=jr.data)==null?void 0:Wr.type)===IframeEventType.Error&&Er(jr.data.value))},!1)})}async injectKeyExportBundle(br,wr,Er){var kr;return(kr=this.iframe.contentWindow)==null||kr.postMessage({type:IframeEventType.InjectKeyExportBundle,value:br,keyFormat:Er,organizationId:wr},"*"),new Promise((jr,Br)=>{window.addEventListener("message",Wr=>{var qr,Hr;Wr.origin===this.iframeOrigin&&(((qr=Wr.data)==null?void 0:qr.type)===IframeEventType.BundleInjected&&jr(Wr.data.value),((Hr=Wr.data)==null?void 0:Hr.type)===IframeEventType.Error&&Br(Wr.data.value))},!1)})}async injectWalletExportBundle(br,wr){var Er;return(Er=this.iframe.contentWindow)==null||Er.postMessage({type:IframeEventType.InjectWalletExportBundle,value:br,organizationId:wr},"*"),new Promise((kr,jr)=>{window.addEventListener("message",Br=>{var Wr,qr;Br.origin===this.iframeOrigin&&(((Wr=Br.data)==null?void 0:Wr.type)===IframeEventType.BundleInjected&&kr(Br.data.value),((qr=Br.data)==null?void 0:qr.type)===IframeEventType.Error&&jr(Br.data.value))},!1)})}async injectImportBundle(br,wr,Er){var kr;return(kr=this.iframe.contentWindow)==null||kr.postMessage({type:IframeEventType.InjectImportBundle,value:br,organizationId:wr,userId:Er},"*"),new Promise((jr,Br)=>{window.addEventListener("message",Wr=>{var qr,Hr;Wr.origin===this.iframeOrigin&&(((qr=Wr.data)==null?void 0:qr.type)===IframeEventType.BundleInjected&&jr(Wr.data.value),((Hr=Wr.data)==null?void 0:Hr.type)===IframeEventType.Error&&Br(Wr.data.value))},!1)})}async extractWalletEncryptedBundle(){var br;return(br=this.iframe.contentWindow)==null||br.postMessage({type:IframeEventType.ExtractWalletEncryptedBundle},"*"),new Promise((wr,Er)=>{window.addEventListener("message",kr=>{var jr,Br;kr.origin===this.iframeOrigin&&(((jr=kr.data)==null?void 0:jr.type)===IframeEventType.EncryptedBundleExtracted&&wr(kr.data.value),((Br=kr.data)==null?void 0:Br.type)===IframeEventType.Error&&Er(kr.data.value))},!1)})}async extractKeyEncryptedBundle(br){var wr;return(wr=this.iframe.contentWindow)==null||wr.postMessage({type:IframeEventType.ExtractKeyEncryptedBundle,keyFormat:br},"*"),new Promise((Er,kr)=>{window.addEventListener("message",jr=>{var Br,Wr;jr.origin===this.iframeOrigin&&(((Br=jr.data)==null?void 0:Br.type)===IframeEventType.EncryptedBundleExtracted&&Er(jr.data.value),((Wr=jr.data)==null?void 0:Wr.type)===IframeEventType.Error&&kr(jr.data.value))},!1)})}async applySettings(br){var Er;const wr=JSON.stringify(br);return(Er=this.iframe.contentWindow)==null||Er.postMessage({type:IframeEventType.ApplySettings,value:wr},"*"),new Promise((kr,jr)=>{window.addEventListener("message",Br=>{var Wr,qr;Br.origin===this.iframeOrigin&&(((Wr=Br.data)==null?void 0:Wr.type)===IframeEventType.SettingsApplied&&kr(Br.data.value),((qr=Br.data)==null?void 0:qr.type)===IframeEventType.Error&&jr(Br.data.value))},!1)})}async stamp(br){var Er;if(this.iframePublicKey===null)throw new Error("null iframe public key. Have you called/awaited .init()?");const wr=this.iframeOrigin;return(Er=this.iframe.contentWindow)==null||Er.postMessage({type:IframeEventType.StampRequest,value:br},"*"),new Promise(function(kr,jr){window.addEventListener("message",Br=>{var Wr,qr;Br.origin===wr&&(((Wr=Br.data)==null?void 0:Wr.type)===IframeEventType.Stamp&&kr({stampHeaderName:stampHeaderName$1,stampHeaderValue:Br.data.value}),((qr=Br.data)==null?void 0:qr.type)===IframeEventType.Error&&jr(Br.data.value))},!1)})}}var browserPonyfill={exports:{}};(function(fr,br){var wr=typeof self<"u"?self:commonjsGlobal,Er=function(){function jr(){this.fetch=!1,this.DOMException=wr.DOMException}return jr.prototype=wr,new jr}();(function(jr){(function(Br){var Wr={searchParams:"URLSearchParams"in jr,iterable:"Symbol"in jr&&"iterator"in Symbol,blob:"FileReader"in jr&&"Blob"in jr&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in jr,arrayBuffer:"ArrayBuffer"in jr};function qr(Gr){return Gr&&DataView.prototype.isPrototypeOf(Gr)}if(Wr.arrayBuffer)var Hr=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],Vr=ArrayBuffer.isView||function(Gr){return Gr&&Hr.indexOf(Object.prototype.toString.call(Gr))>-1};function Zr(Gr){if(typeof Gr!="string"&&(Gr=String(Gr)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(Gr))throw new TypeError("Invalid character in header field name");return Gr.toLowerCase()}function Jr(Gr){return typeof Gr!="string"&&(Gr=String(Gr)),Gr}function Qr(Gr){var Xr={next:function(){var Sn=Gr.shift();return{done:Sn===void 0,value:Sn}}};return Wr.iterable&&(Xr[Symbol.iterator]=function(){return Xr}),Xr}function _n(Gr){this.map={},Gr instanceof _n?Gr.forEach(function(Xr,Sn){this.append(Sn,Xr)},this):Array.isArray(Gr)?Gr.forEach(function(Xr){this.append(Xr[0],Xr[1])},this):Gr&&Object.getOwnPropertyNames(Gr).forEach(function(Xr){this.append(Xr,Gr[Xr])},this)}_n.prototype.append=function(Gr,Xr){Gr=Zr(Gr),Xr=Jr(Xr);var Sn=this.map[Gr];this.map[Gr]=Sn?Sn+", "+Xr:Xr},_n.prototype.delete=function(Gr){delete this.map[Zr(Gr)]},_n.prototype.get=function(Gr){return Gr=Zr(Gr),this.has(Gr)?this.map[Gr]:null},_n.prototype.has=function(Gr){return this.map.hasOwnProperty(Zr(Gr))},_n.prototype.set=function(Gr,Xr){this.map[Zr(Gr)]=Jr(Xr)},_n.prototype.forEach=function(Gr,Xr){for(var Sn in this.map)this.map.hasOwnProperty(Sn)&&Gr.call(Xr,this.map[Sn],Sn,this)},_n.prototype.keys=function(){var Gr=[];return this.forEach(function(Xr,Sn){Gr.push(Sn)}),Qr(Gr)},_n.prototype.values=function(){var Gr=[];return this.forEach(function(Xr){Gr.push(Xr)}),Qr(Gr)},_n.prototype.entries=function(){var Gr=[];return this.forEach(function(Xr,Sn){Gr.push([Sn,Xr])}),Qr(Gr)},Wr.iterable&&(_n.prototype[Symbol.iterator]=_n.prototype.entries);function En(Gr){if(Gr.bodyUsed)return Promise.reject(new TypeError("Already read"));Gr.bodyUsed=!0}function Cn(Gr){return new Promise(function(Xr,Sn){Gr.onload=function(){Xr(Gr.result)},Gr.onerror=function(){Sn(Gr.error)}})}function In(Gr){var Xr=new FileReader,Sn=Cn(Xr);return Xr.readAsArrayBuffer(Gr),Sn}function An(Gr){var Xr=new FileReader,Sn=Cn(Xr);return Xr.readAsText(Gr),Sn}function jn(Gr){for(var Xr=new Uint8Array(Gr),Sn=new Array(Xr.length),Rn=0;Rn-1?Xr:Gr}function oo(Gr,Xr){Xr=Xr||{};var Sn=Xr.body;if(Gr instanceof oo){if(Gr.bodyUsed)throw new TypeError("Already read");this.url=Gr.url,this.credentials=Gr.credentials,Xr.headers||(this.headers=new _n(Gr.headers)),this.method=Gr.method,this.mode=Gr.mode,this.signal=Gr.signal,!Sn&&Gr._bodyInit!=null&&(Sn=Gr._bodyInit,Gr.bodyUsed=!0)}else this.url=String(Gr);if(this.credentials=Xr.credentials||this.credentials||"same-origin",(Xr.headers||!this.headers)&&(this.headers=new _n(Xr.headers)),this.method=_i(Xr.method||this.method||"GET"),this.mode=Xr.mode||this.mode||null,this.signal=Xr.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&Sn)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(Sn)}oo.prototype.clone=function(){return new oo(this,{body:this._bodyInit})};function io(Gr){var Xr=new FormData;return Gr.trim().split("&").forEach(function(Sn){if(Sn){var Rn=Sn.split("="),Pn=Rn.shift().replace(/\+/g," "),On=Rn.join("=").replace(/\+/g," ");Xr.append(decodeURIComponent(Pn),decodeURIComponent(On))}}),Xr}function co(Gr){var Xr=new _n,Sn=Gr.replace(/\r?\n[\t ]+/g," ");return Sn.split(/\r?\n/).forEach(function(Rn){var Pn=Rn.split(":"),On=Pn.shift().trim();if(On){var Zn=Pn.join(":").trim();Xr.append(On,Zn)}}),Xr}ro.call(oo.prototype);function so(Gr,Xr){Xr||(Xr={}),this.type="default",this.status=Xr.status===void 0?200:Xr.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in Xr?Xr.statusText:"OK",this.headers=new _n(Xr.headers),this.url=Xr.url||"",this._initBody(Gr)}ro.call(so.prototype),so.prototype.clone=function(){return new so(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new _n(this.headers),url:this.url})},so.error=function(){var Gr=new so(null,{status:0,statusText:""});return Gr.type="error",Gr};var no=[301,302,303,307,308];so.redirect=function(Gr,Xr){if(no.indexOf(Xr)===-1)throw new RangeError("Invalid status code");return new so(null,{status:Xr,headers:{location:Gr}})},Br.DOMException=jr.DOMException;try{new Br.DOMException}catch{Br.DOMException=function(Xr,Sn){this.message=Xr,this.name=Sn;var Rn=Error(Xr);this.stack=Rn.stack},Br.DOMException.prototype=Object.create(Error.prototype),Br.DOMException.prototype.constructor=Br.DOMException}function Tn(Gr,Xr){return new Promise(function(Sn,Rn){var Pn=new oo(Gr,Xr);if(Pn.signal&&Pn.signal.aborted)return Rn(new Br.DOMException("Aborted","AbortError"));var On=new XMLHttpRequest;function Zn(){On.abort()}On.onload=function(){var Nn={status:On.status,statusText:On.statusText,headers:co(On.getAllResponseHeaders()||"")};Nn.url="responseURL"in On?On.responseURL:Nn.headers.get("X-Request-URL");var wn="response"in On?On.response:On.responseText;Sn(new so(wn,Nn))},On.onerror=function(){Rn(new TypeError("Network request failed"))},On.ontimeout=function(){Rn(new TypeError("Network request failed"))},On.onabort=function(){Rn(new Br.DOMException("Aborted","AbortError"))},On.open(Pn.method,Pn.url,!0),Pn.credentials==="include"?On.withCredentials=!0:Pn.credentials==="omit"&&(On.withCredentials=!1),"responseType"in On&&Wr.blob&&(On.responseType="blob"),Pn.headers.forEach(function(Nn,wn){On.setRequestHeader(wn,Nn)}),Pn.signal&&(Pn.signal.addEventListener("abort",Zn),On.onreadystatechange=function(){On.readyState===4&&Pn.signal.removeEventListener("abort",Zn)}),On.send(typeof Pn._bodyInit>"u"?null:Pn._bodyInit)})}return Tn.polyfill=!0,jr.fetch||(jr.fetch=Tn,jr.Headers=_n,jr.Request=oo,jr.Response=so),Br.Headers=_n,Br.Request=oo,Br.Response=so,Br.fetch=Tn,Object.defineProperty(Br,"__esModule",{value:!0}),Br})({})})(Er),Er.fetch.ponyfill=!0,delete Er.fetch.polyfill;var kr=Er;br=kr.fetch,br.default=kr.fetch,br.fetch=kr.fetch,br.Headers=kr.Headers,br.Request=kr.Request,br.Response=kr.Response,fr.exports=br})(browserPonyfill,browserPonyfill.exports);var browserPonyfillExports=browserPonyfill.exports;const o$2=getDefaultExportFromCjs$2(browserPonyfillExports),fetch$1=browserPonyfillExports.fetch;class TurnkeyRequestError extends Error{constructor(br){let wr=`Turnkey error ${br.code}: ${br.message}`;br.details!=null&&(wr+=` (Details: ${JSON.stringify(br.details)})`),super(wr),this.name="TurnkeyRequestError",this.details=br.details??null,this.code=br.code}}const VERSION$1="@turnkey/http@2.12.2";class TurnkeyClient{constructor(br,wr){if(this.getActivity=async Er=>this.request("/public/v1/query/get_activity",Er),this.stampGetActivity=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_activity",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getApiKey=async Er=>this.request("/public/v1/query/get_api_key",Er),this.stampGetApiKey=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_api_key",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getApiKeys=async Er=>this.request("/public/v1/query/get_api_keys",Er),this.stampGetApiKeys=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_api_keys",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getAttestationDocument=async Er=>this.request("/public/v1/query/get_attestation",Er),this.stampGetAttestationDocument=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_attestation",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getAuthenticator=async Er=>this.request("/public/v1/query/get_authenticator",Er),this.stampGetAuthenticator=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_authenticator",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getAuthenticators=async Er=>this.request("/public/v1/query/get_authenticators",Er),this.stampGetAuthenticators=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_authenticators",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getOauthProviders=async Er=>this.request("/public/v1/query/get_oauth_providers",Er),this.stampGetOauthProviders=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_oauth_providers",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getOrganization=async Er=>this.request("/public/v1/query/get_organization",Er),this.stampGetOrganization=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_organization",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getOrganizationConfigs=async Er=>this.request("/public/v1/query/get_organization_configs",Er),this.stampGetOrganizationConfigs=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_organization_configs",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getPolicy=async Er=>this.request("/public/v1/query/get_policy",Er),this.stampGetPolicy=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_policy",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getPrivateKey=async Er=>this.request("/public/v1/query/get_private_key",Er),this.stampGetPrivateKey=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_private_key",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getUser=async Er=>this.request("/public/v1/query/get_user",Er),this.stampGetUser=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_user",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getWallet=async Er=>this.request("/public/v1/query/get_wallet",Er),this.stampGetWallet=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/get_wallet",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getActivities=async Er=>this.request("/public/v1/query/list_activities",Er),this.stampGetActivities=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_activities",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getPolicies=async Er=>this.request("/public/v1/query/list_policies",Er),this.stampGetPolicies=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_policies",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.listPrivateKeyTags=async Er=>this.request("/public/v1/query/list_private_key_tags",Er),this.stampListPrivateKeyTags=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_private_key_tags",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getPrivateKeys=async Er=>this.request("/public/v1/query/list_private_keys",Er),this.stampGetPrivateKeys=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_private_keys",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getSubOrgIds=async Er=>this.request("/public/v1/query/list_suborgs",Er),this.stampGetSubOrgIds=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_suborgs",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.listUserTags=async Er=>this.request("/public/v1/query/list_user_tags",Er),this.stampListUserTags=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_user_tags",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getUsers=async Er=>this.request("/public/v1/query/list_users",Er),this.stampGetUsers=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_users",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getWalletAccounts=async Er=>this.request("/public/v1/query/list_wallet_accounts",Er),this.stampGetWalletAccounts=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_wallet_accounts",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getWallets=async Er=>this.request("/public/v1/query/list_wallets",Er),this.stampGetWallets=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/list_wallets",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.getWhoami=async Er=>this.request("/public/v1/query/whoami",Er),this.stampGetWhoami=async Er=>{const kr=this.config.baseUrl+"/public/v1/query/whoami",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.approveActivity=async Er=>this.request("/public/v1/submit/approve_activity",Er),this.stampApproveActivity=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/approve_activity",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createApiKeys=async Er=>this.request("/public/v1/submit/create_api_keys",Er),this.stampCreateApiKeys=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_api_keys",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createApiOnlyUsers=async Er=>this.request("/public/v1/submit/create_api_only_users",Er),this.stampCreateApiOnlyUsers=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_api_only_users",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createAuthenticators=async Er=>this.request("/public/v1/submit/create_authenticators",Er),this.stampCreateAuthenticators=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_authenticators",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createInvitations=async Er=>this.request("/public/v1/submit/create_invitations",Er),this.stampCreateInvitations=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_invitations",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createOauthProviders=async Er=>this.request("/public/v1/submit/create_oauth_providers",Er),this.stampCreateOauthProviders=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_oauth_providers",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createPolicies=async Er=>this.request("/public/v1/submit/create_policies",Er),this.stampCreatePolicies=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_policies",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createPolicy=async Er=>this.request("/public/v1/submit/create_policy",Er),this.stampCreatePolicy=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_policy",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createPrivateKeyTag=async Er=>this.request("/public/v1/submit/create_private_key_tag",Er),this.stampCreatePrivateKeyTag=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_private_key_tag",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createPrivateKeys=async Er=>this.request("/public/v1/submit/create_private_keys",Er),this.stampCreatePrivateKeys=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_private_keys",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createReadOnlySession=async Er=>this.request("/public/v1/submit/create_read_only_session",Er),this.stampCreateReadOnlySession=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_read_only_session",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createReadWriteSession=async Er=>this.request("/public/v1/submit/create_read_write_session",Er),this.stampCreateReadWriteSession=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_read_write_session",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createSubOrganization=async Er=>this.request("/public/v1/submit/create_sub_organization",Er),this.stampCreateSubOrganization=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_sub_organization",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createUserTag=async Er=>this.request("/public/v1/submit/create_user_tag",Er),this.stampCreateUserTag=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_user_tag",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createUsers=async Er=>this.request("/public/v1/submit/create_users",Er),this.stampCreateUsers=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_users",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createWallet=async Er=>this.request("/public/v1/submit/create_wallet",Er),this.stampCreateWallet=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_wallet",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.createWalletAccounts=async Er=>this.request("/public/v1/submit/create_wallet_accounts",Er),this.stampCreateWalletAccounts=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/create_wallet_accounts",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deleteApiKeys=async Er=>this.request("/public/v1/submit/delete_api_keys",Er),this.stampDeleteApiKeys=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_api_keys",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deleteAuthenticators=async Er=>this.request("/public/v1/submit/delete_authenticators",Er),this.stampDeleteAuthenticators=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_authenticators",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deleteInvitation=async Er=>this.request("/public/v1/submit/delete_invitation",Er),this.stampDeleteInvitation=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_invitation",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deleteOauthProviders=async Er=>this.request("/public/v1/submit/delete_oauth_providers",Er),this.stampDeleteOauthProviders=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_oauth_providers",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deletePolicy=async Er=>this.request("/public/v1/submit/delete_policy",Er),this.stampDeletePolicy=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_policy",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deletePrivateKeyTags=async Er=>this.request("/public/v1/submit/delete_private_key_tags",Er),this.stampDeletePrivateKeyTags=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_private_key_tags",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deleteUserTags=async Er=>this.request("/public/v1/submit/delete_user_tags",Er),this.stampDeleteUserTags=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_user_tags",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.deleteUsers=async Er=>this.request("/public/v1/submit/delete_users",Er),this.stampDeleteUsers=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/delete_users",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.emailAuth=async Er=>this.request("/public/v1/submit/email_auth",Er),this.stampEmailAuth=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/email_auth",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.exportPrivateKey=async Er=>this.request("/public/v1/submit/export_private_key",Er),this.stampExportPrivateKey=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/export_private_key",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.exportWallet=async Er=>this.request("/public/v1/submit/export_wallet",Er),this.stampExportWallet=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/export_wallet",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.exportWalletAccount=async Er=>this.request("/public/v1/submit/export_wallet_account",Er),this.stampExportWalletAccount=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/export_wallet_account",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.importPrivateKey=async Er=>this.request("/public/v1/submit/import_private_key",Er),this.stampImportPrivateKey=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/import_private_key",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.importWallet=async Er=>this.request("/public/v1/submit/import_wallet",Er),this.stampImportWallet=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/import_wallet",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.initImportPrivateKey=async Er=>this.request("/public/v1/submit/init_import_private_key",Er),this.stampInitImportPrivateKey=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/init_import_private_key",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.initImportWallet=async Er=>this.request("/public/v1/submit/init_import_wallet",Er),this.stampInitImportWallet=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/init_import_wallet",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.initUserEmailRecovery=async Er=>this.request("/public/v1/submit/init_user_email_recovery",Er),this.stampInitUserEmailRecovery=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/init_user_email_recovery",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.oauth=async Er=>this.request("/public/v1/submit/oauth",Er),this.stampOauth=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/oauth",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.recoverUser=async Er=>this.request("/public/v1/submit/recover_user",Er),this.stampRecoverUser=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/recover_user",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.rejectActivity=async Er=>this.request("/public/v1/submit/reject_activity",Er),this.stampRejectActivity=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/reject_activity",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.removeOrganizationFeature=async Er=>this.request("/public/v1/submit/remove_organization_feature",Er),this.stampRemoveOrganizationFeature=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/remove_organization_feature",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.setOrganizationFeature=async Er=>this.request("/public/v1/submit/set_organization_feature",Er),this.stampSetOrganizationFeature=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/set_organization_feature",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.signRawPayload=async Er=>this.request("/public/v1/submit/sign_raw_payload",Er),this.stampSignRawPayload=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/sign_raw_payload",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.signRawPayloads=async Er=>this.request("/public/v1/submit/sign_raw_payloads",Er),this.stampSignRawPayloads=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/sign_raw_payloads",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.signTransaction=async Er=>this.request("/public/v1/submit/sign_transaction",Er),this.stampSignTransaction=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/sign_transaction",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.updatePolicy=async Er=>this.request("/public/v1/submit/update_policy",Er),this.stampUpdatePolicy=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/update_policy",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.updatePrivateKeyTag=async Er=>this.request("/public/v1/submit/update_private_key_tag",Er),this.stampUpdatePrivateKeyTag=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/update_private_key_tag",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.updateRootQuorum=async Er=>this.request("/public/v1/submit/update_root_quorum",Er),this.stampUpdateRootQuorum=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/update_root_quorum",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.updateUser=async Er=>this.request("/public/v1/submit/update_user",Er),this.stampUpdateUser=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/update_user",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},this.updateUserTag=async Er=>this.request("/public/v1/submit/update_user_tag",Er),this.stampUpdateUserTag=async Er=>{const kr=this.config.baseUrl+"/public/v1/submit/update_user_tag",jr=JSON.stringify(Er),Br=await this.stamper.stamp(jr);return{body:jr,stamp:Br,url:kr}},!br.baseUrl)throw new Error("Missing base URL. Please verify env vars.");this.config=br,this.stamper=wr}async request(br,wr){const Er=this.config.baseUrl+br,kr=JSON.stringify(wr),jr=await this.stamper.stamp(kr),Br=await fetch$1(Er,{method:"POST",headers:{[jr.stampHeaderName]:jr.stampHeaderValue,"X-Client-Version":VERSION$1},body:kr,redirect:"follow"});if(!Br.ok){let qr;try{qr=await Br.json()}catch{throw new Error(`${Br.status} ${Br.statusText}`)}throw new TurnkeyRequestError(qr)}return await Br.json()}}class TurnkeyActivityError extends Error{constructor(br){const{message:wr,cause:Er,activityId:kr,activityStatus:jr,activityType:Br}=br;super(wr),this.name="TurnkeyActivityError",this.activityId=kr??null,this.activityStatus=jr??null,this.activityType=Br??null,this.cause=Er??null}}function bufferToBase64url(fr){const br=new Uint8Array(fr);let wr="";for(const jr of br)wr+=String.fromCharCode(jr);return btoa(wr).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}const copyValue="copy",convertValue="convert";function convert$1(fr,br,wr){if(br===copyValue)return wr;if(br===convertValue)return fr(wr);if(br instanceof Array)return wr.map(Er=>convert$1(fr,br[0],Er));if(br instanceof Object){const Er={};for(const[kr,jr]of Object.entries(br)){if(jr.derive){const Br=jr.derive(wr);Br!==void 0&&(wr[kr]=Br)}if(!(kr in wr)){if(jr.required)throw new Error(`Missing key: ${kr}`);continue}if(wr[kr]==null){Er[kr]=null;continue}Er[kr]=convert$1(fr,jr.schema,wr[kr])}return Er}}function derived(fr,br){return{required:!0,schema:fr,derive:br}}function required(fr){return{required:!0,schema:fr}}function optional$3(fr){return{required:!1,schema:fr}}const simplifiedClientExtensionResultsSchema={appid:optional$3(copyValue),appidExclude:optional$3(copyValue),credProps:optional$3(copyValue)},publicKeyCredentialWithAssertion={type:required(copyValue),id:required(copyValue),rawId:required(convertValue),authenticatorAttachment:optional$3(copyValue),response:required({clientDataJSON:required(convertValue),authenticatorData:required(convertValue),signature:required(convertValue),userHandle:required(convertValue)}),clientExtensionResults:derived(simplifiedClientExtensionResultsSchema,fr=>fr.getClientExtensionResults())};function getResponseToJSON(fr){return convert$1(bufferToBase64url,publicKeyCredentialWithAssertion,fr)}async function get$2(fr){const br=await navigator.credentials.get(fr);return br.toJSON=()=>getResponseToJSON(br),br}const K$2=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998];function createHash(fr){return new Hash}class Hash{constructor(){this.A=1779033703,this.B=-1150833019,this.C=1013904242,this.D=-1521486534,this.E=1359893119,this.F=-1694144372,this.G=528734635,this.H=1541459225,this._size=0,this._sp=0,(!sharedBuffer||sharedOffset>=8e3)&&(sharedBuffer=new ArrayBuffer(8e3),sharedOffset=0),this._byte=new Uint8Array(sharedBuffer,sharedOffset,80),this._word=new Int32Array(sharedBuffer,sharedOffset,20),sharedOffset+=80}update(br){if(typeof br=="string")return this._utf8(br);if(br==null)throw new TypeError("Invalid type: "+typeof br);const wr=br.byteOffset,Er=br.byteLength;let kr=Er/64|0,jr=0;if(kr&&!(wr&3)&&!(this._size%64)){const Wr=new Int32Array(br.buffer,wr,kr*16);for(;kr--;)this._int32(Wr,jr>>2),jr+=64;this._size+=jr}if(br.BYTES_PER_ELEMENT!==1&&br.buffer){const Wr=new Uint8Array(br.buffer,wr+jr,Er-jr);return this._uint8(Wr)}return jr===Er?this:this._uint8(br,jr)}_uint8(br,wr){const{_byte:Er,_word:kr}=this,jr=br.length;for(wr=wr|0;wr=64&&this._int32(kr),this._size+=Wr-Br}return this}_utf8(br){const{_byte:wr,_word:Er}=this,kr=br.length;let jr=this._sp;for(let Br=0;Br>>6,wr[qr++]=128|Hr&63):Hr<55296||Hr>57343?(wr[qr++]=224|Hr>>>12,wr[qr++]=128|Hr>>>6&63,wr[qr++]=128|Hr&63):jr?(Hr=((jr&1023)<<10)+(Hr&1023)+65536,wr[qr++]=240|Hr>>>18,wr[qr++]=128|Hr>>>12&63,wr[qr++]=128|Hr>>>6&63,wr[qr++]=128|Hr&63,jr=0):jr=Hr}qr>=64&&(this._int32(Er),Er[0]=Er[16]),this._size+=qr-Wr}return this._sp=jr,this}_int32(br,wr){let{A:Er,B:kr,C:jr,D:Br,E:Wr,F:qr,G:Hr,H:Vr}=this,Zr=0;for(wr=wr|0;Zr<16;)W$1[Zr++]=swap32(br[wr++]);for(Zr=16;Zr<64;Zr++)W$1[Zr]=gamma1(W$1[Zr-2])+W$1[Zr-7]+gamma0(W$1[Zr-15])+W$1[Zr-16]|0;for(Zr=0;Zr<64;Zr++){const Jr=Vr+sigma1(Wr)+ch(Wr,qr,Hr)+K$2[Zr]+W$1[Zr]|0,Qr=sigma0(Er)+maj(Er,kr,jr)|0;Vr=Hr,Hr=qr,qr=Wr,Wr=Br+Jr|0,Br=jr,jr=kr,kr=Er,Er=Jr+Qr|0}this.A=Er+this.A|0,this.B=kr+this.B|0,this.C=jr+this.C|0,this.D=Br+this.D|0,this.E=Wr+this.E|0,this.F=qr+this.F|0,this.G=Hr+this.G|0,this.H=Vr+this.H|0}digest(br){const{_byte:wr,_word:Er}=this;let kr=this._size%64|0;for(wr[kr++]=128;kr&3;)wr[kr++]=0;if(kr>>=2,kr>14){for(;kr<16;)Er[kr++]=0;kr=0,this._int32(Er)}for(;kr<16;)Er[kr++]=0;const jr=this._size*8,Br=(jr&4294967295)>>>0,Wr=(jr-Br)/4294967296;return Wr&&(Er[14]=swap32(Wr)),Br&&(Er[15]=swap32(Br)),this._int32(Er),br==="hex"?this._hex():this._bin()}_hex(){const{A:br,B:wr,C:Er,D:kr,E:jr,F:Br,G:Wr,H:qr}=this;return hex32(br)+hex32(wr)+hex32(Er)+hex32(kr)+hex32(jr)+hex32(Br)+hex32(Wr)+hex32(qr)}_bin(){const{A:br,B:wr,C:Er,D:kr,E:jr,F:Br,G:Wr,H:qr,_byte:Hr,_word:Vr}=this;return Vr[0]=swap32(br),Vr[1]=swap32(wr),Vr[2]=swap32(Er),Vr[3]=swap32(kr),Vr[4]=swap32(jr),Vr[5]=swap32(Br),Vr[6]=swap32(Wr),Vr[7]=swap32(qr),Hr.slice(0,32)}}const W$1=new Int32Array(64);let sharedBuffer,sharedOffset=0;const hex32=fr=>(fr+4294967296).toString(16).substr(-8),swapLE=fr=>fr<<24&4278190080|fr<<8&16711680|fr>>8&65280|fr>>24&255,swapBE=fr=>fr,swap32=isBE()?swapBE:swapLE,ch=(fr,br,wr)=>wr^fr&(br^wr),maj=(fr,br,wr)=>fr&br|wr&(fr|br),sigma0=fr=>(fr>>>2|fr<<30)^(fr>>>13|fr<<19)^(fr>>>22|fr<<10),sigma1=fr=>(fr>>>6|fr<<26)^(fr>>>11|fr<<21)^(fr>>>25|fr<<7),gamma0=fr=>(fr>>>7|fr<<25)^(fr>>>18|fr<<14)^fr>>>3,gamma1=fr=>(fr>>>17|fr<<15)^(fr>>>19|fr<<13)^fr>>>10;function isBE(){return new Uint8Array(new Uint16Array([65279]).buffer)[0]===254}const stampHeaderName="X-Stamp-Webauthn",defaultTimeout=5*60*1e3,defaultUserVerification="preferred";class WebauthnStamper{constructor(br){this.rpId=br.rpId,this.timeout=br.timeout||defaultTimeout,this.userVerification=br.userVerification||defaultUserVerification,this.allowCredentials=br.allowCredentials||[]}async stamp(br){const wr=getChallengeFromPayload(br),Er={publicKey:{rpId:this.rpId,challenge:wr,allowCredentials:this.allowCredentials,timeout:this.timeout,userVerification:this.userVerification}},jr=(await get$2(Er)).toJSON(),Br={authenticatorData:jr.response.authenticatorData,clientDataJson:jr.response.clientDataJSON,credentialId:jr.id,signature:jr.response.signature};return{stampHeaderName,stampHeaderValue:JSON.stringify(Br)}}}function getChallengeFromPayload(fr){const br=createHash().update(fr).digest("hex");return new TextEncoder().encode(br)}var version$b="3.8.2";class WebauthnNotSupportedError extends Error{constructor(){super("Webauthn is not supported on this device")}}function __awaiter$b(fr,br,wr,Er){function kr(jr){return jr instanceof wr?jr:new wr(function(Br){Br(jr)})}return new(wr||(wr=Promise))(function(jr,Br){function Wr(Vr){try{Hr(Er.next(Vr))}catch(Zr){Br(Zr)}}function qr(Vr){try{Hr(Er.throw(Vr))}catch(Zr){Br(Zr)}}function Hr(Vr){Vr.done?jr(Vr.value):kr(Vr.value).then(Wr,qr)}Hr((Er=Er.apply(fr,[])).next())})}typeof SuppressedError=="function"&&SuppressedError;function utf8StringToBuffer(fr){return new TextEncoder().encode(fr)}function bufferToBase64URLString(fr){const br=new Uint8Array(fr);let wr="";for(const kr of br)wr+=String.fromCharCode(kr);return btoa(wr).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function base64URLStringToBuffer(fr){const br=fr.replace(/-/g,"+").replace(/_/g,"/"),wr=(4-br.length%4)%4,Er=br.padEnd(br.length+wr,"="),kr=atob(Er),jr=new ArrayBuffer(kr.length),Br=new Uint8Array(jr);for(let Wr=0;WrBr.type==="public-key").length===0?new WebAuthnError({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:fr}):new WebAuthnError({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:fr});if(fr.name==="SecurityError"){const jr=window.location.hostname;if(isValidDomain(jr)){if(wr.rp.id!==jr)return new WebAuthnError({message:`The RP ID "${wr.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:fr})}else return new WebAuthnError({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:fr})}else if(fr.name==="TypeError"){if(wr.user.id.byteLength<1||wr.user.id.byteLength>64)return new WebAuthnError({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:fr})}else if(fr.name==="UnknownError")return new WebAuthnError({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:fr})}return fr}class BaseWebAuthnAbortService{createNewAbortSignal(){if(this.controller){const wr=new Error("Cancelling existing WebAuthn API call for new one");wr.name="AbortError",this.controller.abort(wr)}const br=new AbortController;return this.controller=br,br.signal}cancelCeremony(){if(this.controller){const br=new Error("Manually cancelling existing WebAuthn API call");br.name="AbortError",this.controller.abort(br),this.controller=void 0}}}const WebAuthnAbortService=new BaseWebAuthnAbortService,attachments=["cross-platform","platform"];function toAuthenticatorAttachment(fr){if(fr&&!(attachments.indexOf(fr)<0))return fr}async function startRegistration(fr){var Jr;if(!browserSupportsWebAuthn())throw new Error("WebAuthn is not supported in this browser");const wr={publicKey:{...fr,challenge:base64URLStringToBuffer(fr.challenge),user:{...fr.user,id:utf8StringToBuffer(fr.user.id)},excludeCredentials:(Jr=fr.excludeCredentials)==null?void 0:Jr.map(toPublicKeyCredentialDescriptor)}};wr.signal=WebAuthnAbortService.createNewAbortSignal();let Er;try{Er=await navigator.credentials.create(wr)}catch(Qr){throw identifyRegistrationError({error:Qr,options:wr})}if(!Er)throw new Error("Registration was not completed");const{id:kr,rawId:jr,response:Br,type:Wr}=Er;let qr;typeof Br.getTransports=="function"&&(qr=Br.getTransports());let Hr;if(typeof Br.getPublicKeyAlgorithm=="function")try{Hr=Br.getPublicKeyAlgorithm()}catch(Qr){warnOnBrokenImplementation("getPublicKeyAlgorithm()",Qr)}let Vr;if(typeof Br.getPublicKey=="function")try{const Qr=Br.getPublicKey();Qr!==null&&(Vr=bufferToBase64URLString(Qr))}catch(Qr){warnOnBrokenImplementation("getPublicKey()",Qr)}let Zr;if(typeof Br.getAuthenticatorData=="function")try{Zr=bufferToBase64URLString(Br.getAuthenticatorData())}catch(Qr){warnOnBrokenImplementation("getAuthenticatorData()",Qr)}return{id:kr,rawId:bufferToBase64URLString(jr),response:{attestationObject:bufferToBase64URLString(Br.attestationObject),clientDataJSON:bufferToBase64URLString(Br.clientDataJSON),transports:qr,publicKeyAlgorithm:Hr,publicKey:Vr,authenticatorData:Zr},type:Wr,clientExtensionResults:Er.getClientExtensionResults(),authenticatorAttachment:toAuthenticatorAttachment(Er.authenticatorAttachment)}}function warnOnBrokenImplementation(fr,br){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${fr}. You should report this error to them. `,br)}const logger$3=new Logger$1("Webauthn"),createWebauthnCredential=fr=>__awaiter$b(void 0,void 0,void 0,function*(){if(!browserSupportsWebAuthn())throw new WebauthnNotSupportedError;let br;try{br=yield startRegistration(fr)}catch(wr){throw logger$3.debug("Failed to create webauthn credential",wr),wr}return br}),convertTransportEnumToTurnkeyEnum=fr=>{switch(fr){case"internal":return"AUTHENTICATOR_TRANSPORT_INTERNAL";case"usb":return"AUTHENTICATOR_TRANSPORT_USB";case"nfc":return"AUTHENTICATOR_TRANSPORT_NFC";case"ble":return"AUTHENTICATOR_TRANSPORT_BLE";case"hybrid":return"AUTHENTICATOR_TRANSPORT_HYBRID";default:throw new Error("unsupported transport format "+fr)}},getWebAuthnAttestationTurnkeyAdapter=fr=>__awaiter$b(void 0,void 0,void 0,function*(){var br,wr;if(!fr.publicKey)throw new Error("Invalid options. Public key attribute must be defined");const Er=Object.assign(Object.assign({},fr.publicKey),{challenge:bufferSourceToString(fr.publicKey.challenge),excludeCredentials:(br=fr.publicKey.excludeCredentials)===null||br===void 0?void 0:br.map(jr=>Object.assign(Object.assign({},jr),{id:bufferSourceToString(jr.id)})),user:Object.assign(Object.assign({},fr.publicKey.user),{id:bufferSourceToString(fr.publicKey.user.id)})}),kr=yield createWebauthnCredential(Er);return{attestationObject:kr.response.attestationObject,clientDataJson:kr.response.clientDataJSON,credentialId:kr.rawId,transports:((wr=kr.response.transports)===null||wr===void 0?void 0:wr.map(convertTransportEnumToTurnkeyEnum))||[]}}),bufferSourceToString=fr=>{if(fr instanceof ArrayBuffer)return bufferToBase64URLString(fr);{const br=new Uint8Array(fr.buffer,fr.byteOffset,fr.byteLength);return bufferToBase64URLString(br)}};assertPackageVersion("@dynamic-labs/webauthn",version$b);const createTurnkeyPasskeyService=()=>({createWebauthnStamper:fr=>new WebauthnStamper(fr),getWebAuthnAttestation:getWebAuthnAttestationTurnkeyAdapter});var _a,_PasskeyService_implementation;class PasskeyService{static get implementation(){return __classPrivateFieldGet$4(_a,_a,"f",_PasskeyService_implementation)?__classPrivateFieldGet$4(_a,_a,"f",_PasskeyService_implementation):createTurnkeyPasskeyService()}static set implementation(br){__classPrivateFieldSet$4(_a,_a,br,"f",_PasskeyService_implementation)}static get getWebAuthnAttestation(){return _a.implementation.getWebAuthnAttestation}static get createWebauthnStamper(){return _a.implementation.createWebauthnStamper}}_a=PasskeyService;_PasskeyService_implementation={value:void 0};const turnkeyBaseUrl$1="https://api.turnkey.com",turnkeyPasskeyRecoveryUrl="https://recovery.turnkey.com",turnkeyEmailRecoveryUrl="https://auth.turnkey.com",TURNKEY_RECOVERY_CREDENTIAL_EXPIRATION_SECONDS=900,TURNKEY_SESSION_EXPIRATION_SECONDS=1800,EMAIL_AUTH_CREDENTIAL_TYPE="CREDENTIAL_TYPE_API_KEY_P256",PASSKEY_RECOVERY_CREDENTIAL_TYPE="CREDENTIAL_TYPE_RECOVER_USER_KEY_P256";class TurnkeyAuthenticatorRecoveryHandler{constructor(){this.isSessionActive=()=>!this.__createdAt||this.__recoveryType!=="email"?!1:this.isExpired(this.__createdAt,this.__sessionExpiration||TURNKEY_SESSION_EXPIRATION_SECONDS)?(this.clear(),!1):!0,this.isValidCode=br=>__awaiter$c(this,void 0,void 0,function*(){var wr,Er,kr,jr;if(!br||!this.__turnkeyRecoveryUserId)throw new DynamicError("Cannot proceed with your request");const Br=yield(wr=this.__client)===null||wr===void 0?void 0:wr.getUser({organizationId:br,userId:this.__turnkeyRecoveryUserId}),Wr={email:EMAIL_AUTH_CREDENTIAL_TYPE,passkey:PASSKEY_RECOVERY_CREDENTIAL_TYPE},qr=(jr=(kr=(Er=Br==null?void 0:Br.user)===null||Er===void 0?void 0:Er.apiKeys)===null||kr===void 0?void 0:kr.filter(Vr=>Vr.credential.type===Wr[this.__recoveryType]))===null||jr===void 0?void 0:jr.pop();return!qr||this.isExpired(parseInt(qr.createdAt.seconds,10),TURNKEY_RECOVERY_CREDENTIAL_EXPIRATION_SECONDS)?!1:(this.__createdAt=parseInt(qr.createdAt.seconds,10),!0)}),this.isExpired=(br,wr)=>{const Er=br+wr,kr=new Date(Er*1e3);return new Date>=kr}}get publicKey(){return this.__publicKey}get client(){return this.__client}get recoveryType(){return this.__recoveryType}get recoveryUserId(){return this.__turnkeyRecoveryUserId||""}set recoveryUserId(br){this.__turnkeyRecoveryUserId=br}clear(){var br;(br=this.__iframeStamper)===null||br===void 0||br.clear(),this.__recoveryType=void 0,this.__iframeStamper=void 0,this.__publicKey=void 0,this.__client=void 0,this.__turnkeyRecoveryUserId=void 0,this.__createdAt=void 0}initRecovery(br,wr,Er,kr){return __awaiter$c(this,void 0,void 0,function*(){this.__recoveryType&&this.clear(),this.__sessionExpiration=kr,this.__recoveryType=br;const jr=br==="passkey"?turnkeyPasskeyRecoveryUrl:turnkeyEmailRecoveryUrl;return this.__iframeStamper=new IframeStamper({iframeContainer:wr,iframeElementId:Er,iframeUrl:jr}),yield this.__iframeStamper.init(),this.__publicKey=this.__iframeStamper.publicKey(),this.__publicKey})}verifyRecoveryCode(br,wr){return __awaiter$c(this,void 0,void 0,function*(){if(!this.__iframeStamper)throw new DynamicError("Cannot proceed with your request");try{if(yield this.__iframeStamper.injectCredentialBundle(br),this.__client=new TurnkeyClient({baseUrl:turnkeyBaseUrl$1},this.__iframeStamper),!wr||!this.__turnkeyRecoveryUserId)throw new DynamicError("Cannot proceed with your request");if(!(yield this.isValidCode(wr)))throw new DynamicError("The code is invalid or expired.")}catch(Er){throw logger$4.error("Error while verifying recovery code",Er),Er instanceof DynamicError?Er:new DynamicError("The code is invalid or expired.")}})}completeRecovery(br){return __awaiter$c(this,arguments,void 0,function*({attestation:wr,challenge:Er,turnkeySubOrganizationId:kr}){if(!this.__client||!this.__turnkeyRecoveryUserId)throw new DynamicError("Cannot proceed with your request");try{return this.__client.recoverUser({organizationId:kr,parameters:{authenticator:{attestation:wr,authenticatorName:"Passkey",challenge:Er},userId:this.__turnkeyRecoveryUserId},timestampMs:String(Date.now()),type:"ACTIVITY_TYPE_RECOVER_USER"})}catch(jr){throw logger$4.error("[TK] Error while completing recovery process",jr),jr}})}addPasskeyAuthenticator(br){return __awaiter$c(this,arguments,void 0,function*({attestation:wr,challenge:Er,turnkeySubOrganizationId:kr}){if(!this.__client||!this.__turnkeyRecoveryUserId)throw new DynamicError("Cannot proceed with your request");try{return this.__client.createAuthenticators({organizationId:kr,parameters:{authenticators:[{attestation:wr,authenticatorName:"Passkey",challenge:Er}],userId:this.__turnkeyRecoveryUserId},timestampMs:String(Date.now()),type:"ACTIVITY_TYPE_CREATE_AUTHENTICATORS_V2"})}catch(jr){throw logger$4.error("[TK] Error while creating new authenticator",jr),jr}})}addEmailRecovery(br){return __awaiter$c(this,arguments,void 0,function*({organizationId:wr,email:Er,turnkeyUserId:kr}){let jr=getTLD();jr||(jr=PlatformService.getHostname());const Br=PasskeyService.createWebauthnStamper({rpId:jr}),Wr=new TurnkeyClient({baseUrl:turnkeyBaseUrl$1},Br);try{return{signedRequest:yield Wr.stampUpdateUser({organizationId:wr,parameters:{userEmail:Er,userId:kr,userTagIds:[]},timestampMs:String(Date.now()),type:"ACTIVITY_TYPE_UPDATE_USER"}),userId:kr}}catch(qr){throw logger$4.error("Error while adding email recovery",qr),qr}})}}const turnkeyAuthenticatorRecoveryHandler=new TurnkeyAuthenticatorRecoveryHandler,turnkeyBaseUrl="https://api.turnkey.com",turnkeyExportUrl="https://export.turnkey.com";class ExportHandler{get publicKey(){return this.__publicKey}clear(){var br;(br=this.__iframeStamper)===null||br===void 0||br.clear(),this.__iframeStamper=void 0,this.__publicKey=void 0,this.__turnkeyClient=void 0}initExport(br,wr){return __awaiter$c(this,void 0,void 0,function*(){if(this.__iframeStamper=new IframeStamper({iframeContainer:br,iframeElementId:wr,iframeUrl:turnkeyExportUrl}),yield this.__iframeStamper.init(),this.__publicKey=this.__iframeStamper.publicKey(),turnkeyAuthenticatorRecoveryHandler.isSessionActive())this.__turnkeyClient=turnkeyAuthenticatorRecoveryHandler.client;else{let Er=getTLD();Er||(Er=PlatformService.getHostname());const kr=PasskeyService.createWebauthnStamper({rpId:Er}),jr=ExportHandler==null?void 0:ExportHandler.apiKeyStamper,Br=jr??kr;this.__turnkeyClient=new TurnkeyClient({baseUrl:turnkeyBaseUrl},Br)}return this.__publicKey})}verifyExportWallet(br){return __awaiter$c(this,arguments,void 0,function*({exportBundle:wr,organizationId:Er}){if(!this.__iframeStamper)throw new DynamicError("Cannot proceed with your request");try{return yield this.__iframeStamper.injectWalletExportBundle(wr,Er)}catch(kr){throw logger$4.error("Error while verifying export wallet",kr),kr}})}verifyExportPrivateKey(br){return __awaiter$c(this,arguments,void 0,function*({exportBundle:wr,organizationId:Er,chain:kr}){if(!this.__iframeStamper)throw new DynamicError("Cannot proceed with your request");const jr=kr==="solana"||kr==="SOL"?KeyFormat.Solana:KeyFormat.Hexadecimal;try{return yield this.__iframeStamper.injectKeyExportBundle(wr,Er,jr)}catch(Br){throw logger$4.error("Error while verifying export private key",Br),Br}})}exportPrivateKey(br){return __awaiter$c(this,arguments,void 0,function*({privateKeyId:wr,organizationId:Er}){const kr=ExportHandler==null?void 0:ExportHandler.apiKeyStamper;if(kr&&(this.__turnkeyClient=new TurnkeyClient({baseUrl:turnkeyBaseUrl},kr)),!this.__iframeStamper||!this.__publicKey||!this.__turnkeyClient||!wr)throw new DynamicError("Cannot proceed with your request");try{return(yield this.__turnkeyClient.exportPrivateKey({organizationId:Er,parameters:{privateKeyId:wr,targetPublicKey:this.__publicKey},timestampMs:String(Date.now()),type:"ACTIVITY_TYPE_EXPORT_PRIVATE_KEY"})).activity}catch(jr){throw logger$4.error("[TK] Error while completing export private key process",jr),jr}})}exportWallet(br){return __awaiter$c(this,arguments,void 0,function*({walletId:wr,organizationId:Er,address:kr}){const jr=ExportHandler==null?void 0:ExportHandler.apiKeyStamper;if(jr&&(this.__turnkeyClient=new TurnkeyClient({baseUrl:turnkeyBaseUrl},jr)),!this.__iframeStamper||!this.__publicKey||!this.__turnkeyClient||!wr)throw new DynamicError("Cannot proceed with your request");try{return kr?(yield this.__turnkeyClient.exportWalletAccount({organizationId:Er,parameters:{address:kr,targetPublicKey:this.__publicKey},timestampMs:String(Date.now()),type:"ACTIVITY_TYPE_EXPORT_WALLET_ACCOUNT"})).activity:(yield this.__turnkeyClient.exportWallet({organizationId:Er,parameters:{targetPublicKey:this.__publicKey,walletId:wr},timestampMs:String(Date.now()),type:"ACTIVITY_TYPE_EXPORT_WALLET"})).activity}catch(Br){throw logger$4.error("[TK] Error while completing export wallet process",Br),Br}})}}class TurnkeyWalletConnectorBase extends WalletConnectorBase{constructor(br,wr){if(super(wr),this.requiresNonDynamicEmailOtp=!1,this.isEmbeddedWallet=!0,this.removeSessionKeys=()=>__awaiter$c(this,void 0,void 0,function*(){TurnkeyWalletConnectorBase.sessionKeys=void 0,TurnkeyWalletConnectorBase.apiKeyStamper=void 0,ExportHandler.apiKeyStamper=void 0,typeof(this===null||this===void 0?void 0:this.removeSessionKeysFunction)=="function"&&this.removeSessionKeysFunction()}),!wr.appName)throw new Error("appName not set");this.name=br.name,this.overrideKey=br.key,this.appName=wr.appName,this.__authenticatorMethodHandler=turnkeyAuthenticatorRecoveryHandler,this.__exportHandler=new ExportHandler}getWebAuthnAttestation(){return __awaiter$c(this,void 0,void 0,function*(){const br=generateRandomBuffer(),wr=generateRandomBuffer(),{email:Er,passkeyIdentifier:kr}=this;if(!Er&&!kr)throw new Error("Email or passkeyIdentifier must be set to register a webauthn credential.");const jr=Er||`${this.appName} - ${kr}`,Br={publicKey:{authenticatorSelection:{authenticatorAttachment:void 0,requireResidentKey:!1,residentKey:"preferred",userVerification:"discouraged"},challenge:br,pubKeyCredParams:[{alg:-7,type:"public-key"}],rp:{id:getTLD(),name:this.appName},user:{displayName:jr,id:wr,name:Er||`${this.appName} - ${kr}`}}};let Wr;try{Wr=yield PasskeyService.getWebAuthnAttestation(Br)}catch(qr){logger$4.warn(`Unable to register webauthn credential on the current page's TLD ${getTLD()}. Falling back to using hostname. ${PlatformService.getHostname()}`,qr),Br.publicKey.rp.id=PlatformService.getHostname(),Wr=yield PasskeyService.getWebAuthnAttestation(Br)}return{attestation:{attestationObject:Wr.attestationObject,clientDataJson:Wr.clientDataJson,credentialId:Wr.credentialId,transports:convertAttestationTransports(Wr.transports)},challenge:base64UrlEncode(br),displayName:jr}})}getAuthenticatorHandler(){return this.__authenticatorMethodHandler}getExportHandler(){return this.__exportHandler}get email(){return this._email}setEmail(br){this._email=br}get phone(){return this._phone}setPhone(br){this._phone=br}get passkeyIdentifier(){return this._passkeyIdentifier}setPasskeyIdentifier(br){this._passkeyIdentifier=br}clearEmail(){this._email=null}getAddress(){return __awaiter$c(this,void 0,void 0,function*(){var br;return(br=this.verifiedCredential)===null||br===void 0?void 0:br.address})}getConnectedAccounts(){return __awaiter$c(this,void 0,void 0,function*(){return(this.verifiedCredentials||[]).map(Er=>Er==null?void 0:Er.address).filter(Er=>typeof Er=="string")})}get turnkeyAddress(){var br;const{address:wr}=(br=this.verifiedCredential)!==null&&br!==void 0?br:{};return wr}get walletProperties(){const{walletProperties:br}=this.verifiedCredential||{};return br}set verifiedCredentials(br){this._verifiedCredentials=br}get verifiedCredentials(){return this._verifiedCredentials}set verifiedCredential(br){this._verifiedCredential=br}get verifiedCredential(){return this._verifiedCredential}setSessionKeyFetcher(br){this.createOrRestoreSessionFetcherFunction=br}setSessionKeyRemoveFunction(br){this.removeSessionKeysFunction=br}createOrRestoreSession(){return __awaiter$c(this,arguments,void 0,function*({ignoreRestore:br}={}){if(!this.isSessionKeyCompatible()||TurnkeyWalletConnectorBase.isLoadingSession)return;if(!this.createOrRestoreSessionFetcherFunction)throw new DynamicError("Cannot register session key to init provider");const{sessionKeys:wr}=TurnkeyWalletConnectorBase;if(wr!=null&&wr.publicKey&&!(new Date>=new Date(wr.expirationDate)))return wr.publicKey;try{TurnkeyWalletConnectorBase.isLoadingSession=!0;const Er=yield this.createOrRestoreSessionFetcherFunction({ignoreRestore:br});return TurnkeyWalletConnectorBase.sessionKeys=Er,TurnkeyWalletConnectorBase.apiKeyStamper=new ApiKeyStamper({apiPrivateKey:Er.privateKey,apiPublicKey:Er.publicKey}),ExportHandler.apiKeyStamper=TurnkeyWalletConnectorBase.apiKeyStamper,logger$4.setMetaData("sessionApiPublicKey",Er.publicKey),Er.publicKey}catch{throw new DynamicError("Failed to create or restore session")}finally{TurnkeyWalletConnectorBase.isLoadingSession=!1}})}isSessionKeyCompatible(){var br;const wr=(br=this.verifiedCredential)===null||br===void 0?void 0:br.walletProperties;return!!(wr==null?void 0:wr.isSessionKeyCompatible)}isSessionActive(){return __awaiter$c(this,void 0,void 0,function*(){return!!((yield this.getAddress())&&TurnkeyWalletConnectorBase.sessionKeys&&TurnkeyWalletConnectorBase.apiKeyStamper)})}get sessionKeys(){return TurnkeyWalletConnectorBase.sessionKeys}setLoggerMetadata(){var br,wr,Er;logger$4.setMetaData("turnkeySubOrganizationId",(wr=(br=this._verifiedCredential)===null||br===void 0?void 0:br.walletProperties)===null||wr===void 0?void 0:wr.turnkeySubOrganizationId),logger$4.setMetaData("walletId",(Er=this._verifiedCredential)===null||Er===void 0?void 0:Er.id);let kr="Unknown";this.isSessionKeyCompatible()?kr="SessionKeys":this.__authenticatorMethodHandler.recoveryType==="passkey"?kr="Passkey":this.__authenticatorMethodHandler.recoveryType==="email"&&(kr="EmailAuth"),logger$4.setMetaData("authMethod",kr)}}TurnkeyWalletConnectorBase.isLoadingSession=!1;const TurnkeyWalletConnectorInfo={Turnkey:{key:"turnkey",name:"Turnkey"},TurnkeyHD:{key:"turnkeyhd",name:"Turnkey HD"}},findTurnkeyVerifiedCredentials=(fr,br)=>fr==null?void 0:fr.filter(({walletName:wr,chain:Er})=>(wr==null?void 0:wr.startsWith("turnkey"))&&br===Er),findTurnkeyVerifiedCredentialsWithSmartWalletRef=(fr,br)=>fr==null?void 0:fr.reduce((wr,Er)=>{var kr;if(!((kr=Er.walletName)===null||kr===void 0)&&kr.startsWith("turnkey")&&br===Er.chain){const jr=fr.find(qr=>qr.signerRefId===Er.id),Br=jr==null?void 0:jr.id,Wr=jr==null?void 0:jr.address;wr.push(Object.assign(Object.assign({},Er),{smartWalletRefAddress:Wr,smartWalletRefId:Br}))}return wr},[]);assertPackageVersion("@dynamic-labs/embedded-wallet",version$c);function __awaiter$a(fr,br,wr,Er){function kr(jr){return jr instanceof wr?jr:new wr(function(Br){Br(jr)})}return new(wr||(wr=Promise))(function(jr,Br){function Wr(Vr){try{Hr(Er.next(Vr))}catch(Zr){Br(Zr)}}function qr(Vr){try{Hr(Er.throw(Vr))}catch(Zr){Br(Zr)}}function Hr(Vr){Vr.done?jr(Vr.value):kr(Vr.value).then(Wr,qr)}Hr((Er=Er.apply(fr,br||[])).next())})}typeof SuppressedError=="function"&&SuppressedError;async function createAccount(fr){var jr;const{client:br,organizationId:wr,signWith:Er}=fr;let{ethereumAddress:kr}=fr;if(!Er)throw new TurnkeyActivityError({message:"Missing signWith parameter"});if(isAddress(Er))kr=Er;else if(!kr&&(kr=(jr=(await br.getPrivateKey({privateKeyId:Er,organizationId:wr})).privateKey.addresses.find(Wr=>Wr.format==="ADDRESS_FORMAT_ETHEREUM"))==null?void 0:jr.address,typeof kr!="string"||!kr))throw new TurnkeyActivityError({message:`Unable to find Ethereum address for key ${Er} under organization ${wr}`});return toAccount({address:kr,signMessage:function({message:Br}){return signMessage(br,Br,wr,Er)},signTransaction:function(Br,Wr){const qr=Wr!=null&&Wr.serializer?Wr.serializer:serializeTransaction$4;return signTransaction(br,Br,qr,wr,Er)},signTypedData:function(Br){return signTypedData(br,Br,wr,Er)}})}async function signMessage(fr,br,wr,Er){const kr=hashMessage(br);return`${await signMessageWithErrorWrapping(fr,kr,wr,Er)}`}async function signTransaction(fr,br,wr,Er,kr){const Br=wr(br).replace(/^0x/,"");return await signTransactionWithErrorWrapping(fr,Br,Er,kr)}async function signTypedData(fr,br,wr,Er){const kr=hashTypedData(br);return await signMessageWithErrorWrapping(fr,kr,wr,Er)}async function signTransactionWithErrorWrapping(fr,br,wr,Er){let kr;try{kr=await signTransactionImpl(fr,br,wr,Er)}catch(jr){throw jr instanceof TurnkeyActivityError?jr:new TurnkeyActivityError({message:`Failed to sign transaction: ${jr.message}`,cause:jr})}return`0x${kr}`}async function signTransactionImpl(fr,br,wr,Er){var kr,jr;if(fr instanceof TurnkeyClient){const{activity:Br}=await fr.signTransaction({type:"ACTIVITY_TYPE_SIGN_TRANSACTION_V2",organizationId:wr,parameters:{signWith:Er,type:"TRANSACTION_TYPE_ETHEREUM",unsignedTransaction:br},timestampMs:String(Date.now())}),{id:Wr,status:qr,type:Hr}=Br;if(Br.status!=="ACTIVITY_STATUS_COMPLETED")throw new TurnkeyActivityError({message:`Invalid activity status: ${Br.status}`,activityId:Wr,activityStatus:qr,activityType:Hr});return assertNonNull((jr=(kr=Br==null?void 0:Br.result)==null?void 0:kr.signTransactionResult)==null?void 0:jr.signedTransaction)}else{const Br=await fr.signTransaction({signWith:Er,type:"TRANSACTION_TYPE_ETHEREUM",unsignedTransaction:br});return assertNonNull(Br==null?void 0:Br.signedTransaction)}}async function signMessageWithErrorWrapping(fr,br,wr,Er){let kr;try{kr=await signMessageImpl(fr,br,wr,Er)}catch(jr){throw jr instanceof TurnkeyActivityError?jr:new TurnkeyActivityError({message:`Failed to sign: ${jr.message}`,cause:jr})}return kr}async function signMessageImpl(fr,br,wr,Er){var Br;let kr;if(fr instanceof TurnkeyClient){const{activity:Wr}=await fr.signRawPayload({type:"ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2",organizationId:wr,parameters:{signWith:Er,payload:br,encoding:"PAYLOAD_ENCODING_HEXADECIMAL",hashFunction:"HASH_FUNCTION_NO_OP"},timestampMs:String(Date.now())}),{id:qr,status:Hr,type:Vr}=Wr;if(Hr!=="ACTIVITY_STATUS_COMPLETED")throw new TurnkeyActivityError({message:`Invalid activity status: ${Wr.status}`,activityId:qr,activityStatus:Hr,activityType:Vr});kr=assertNonNull((Br=Wr==null?void 0:Wr.result)==null?void 0:Br.signRawPayloadResult)}else kr=await fr.signRawPayload({signWith:Er,payload:br,encoding:"PAYLOAD_ENCODING_HEXADECIMAL",hashFunction:"HASH_FUNCTION_NO_OP"});let jr=serializeSignature({r:`0x${kr.r}`,s:`0x${kr.s}`,v:kr.v==="00"?27n:28n});return assertNonNull(jr)}function assertNonNull(fr){if(fr==null)throw new Error(`Got unexpected ${JSON.stringify(fr)}`);return fr}var version$a="3.8.2";function __awaiter$9(fr,br,wr,Er){function kr(jr){return jr instanceof wr?jr:new wr(function(Br){Br(jr)})}return new(wr||(wr=Promise))(function(jr,Br){function Wr(Vr){try{Hr(Er.next(Vr))}catch(Zr){Br(Zr)}}function qr(Vr){try{Hr(Er.throw(Vr))}catch(Zr){Br(Zr)}}function Hr(Vr){Vr.done?jr(Vr.value):kr(Vr.value).then(Wr,qr)}Hr((Er=Er.apply(fr,br||[])).next())})}typeof SuppressedError=="function"&&SuppressedError;const logger$2=new Logger$1("ethereum-core"),gasPriceOracleAbiAddress="0x420000000000000000000000000000000000000F",gasPriceOracleAbi=[{inputs:[{internalType:"bytes",name:"_data",type:"bytes"}],name:"getL1Fee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}],estimateL1Fee$1=(fr,br)=>__awaiter$9(void 0,void 0,void 0,function*(){const wr=serializeTransaction$4(Object.assign(Object.assign({chainId:fr.chain.id},br),{type:br.type?br.type:"eip1559"}));return fr.readContract({abi:gasPriceOracleAbi,address:gasPriceOracleAbiAddress,args:[wr],functionName:"getL1Fee"})}),opStackSupportedChains=[optimism.id,optimismGoerli.id,optimismSepolia.id,base$7.id,baseGoerli.id,baseSepolia$1.id],chainsMap=Object.values(viemChains).reduce((fr,br)=>Object.assign(Object.assign({},fr),{[br.id]:br}),{}),erc20Abi=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}];class Eip1559FeeFeed{constructor({publicClient:br,initialGasLimit:wr,initialMaxFeePerGas:Er}){this.fee={gas:BigInt(0)},this.publicClient=br,this.initialGasLimit=wr,this.initialMaxFeePerGas=Er}fetchFee(){return __awaiter$9(this,void 0,void 0,function*(){try{const br=yield this.estimateL1Fee();if(this.initialGasLimit&&this.initialMaxFeePerGas){this.fee.gas=this.initialGasLimit*this.initialMaxFeePerGas+br;return}const wr=yield this.estimateGas();if(this.initialMaxFeePerGas){this.fee.gas=wr*this.initialMaxFeePerGas+br;return}const Er=yield this.publicClient.estimateFeesPerGas();if(!Er||!Er.maxFeePerGas)return;this.fee.gas=wr*Er.maxFeePerGas+br,this.maxFeePerGas=Er.maxFeePerGas,this.maxPriorityFeePerGas=Er.maxPriorityFeePerGas}catch(br){logger$2.debug(br);return}})}}const estimateL1Fee=(fr,br)=>__awaiter$9(void 0,void 0,void 0,function*(){const{chain:wr}=fr;if(!wr)throw new Error("Chain is not defined");const Er=fr;if(opStackSupportedChains.includes(wr.id))return estimateL1Fee$1(Er,br);throw new Error("Chain is not supported")}),estimateL1FeeSupportedChains=[...opStackSupportedChains],isL1FeeSupportedByChain=fr=>estimateL1FeeSupportedChains.includes(fr),validateAddressFormat=fr=>/^0x[0-9a-fA-F]{40}$/.test(fr),parseEther=fr=>parseEther$1(fr,"wei"),formatEther=(fr,{precision:br}={})=>formatNumberText(formatEther$1(fr),{precision:br});class ViemUiTransaction extends Eip1559FeeFeed{constructor({transaction:br,onSubmit:wr,publicClient:Er,account:kr}){super({initialGasLimit:br.gas,initialMaxFeePerGas:br.maxFeePerGas,publicClient:Er}),this.chain="EVM",this.validateAddressFormat=validateAddressFormat,this.parse=parseEther,this.parseNonNativeToken=(jr,Br)=>parseUnits(jr,Br),this.format=formatEther,this.formatNonNativeToken=(jr,Br)=>formatUnits(jr,Br),this.transaction=br,this.onSubmit=wr,this.publicClient=Er,this.address=kr}get to(){return this.transaction.to||void 0}set to(br){this.transaction.to=br}get from(){return this.address}get value(){return this.transaction.value}set value(br){this.transaction.value=br}get nonNativeValue(){return this.transaction.nonNativeValue}set nonNativeValue(br){this.transaction.nonNativeValue=br}get nonNativeAddress(){return this.transaction.nonNativeAddress}set nonNativeAddress(br){this.transaction.nonNativeAddress=br}get nonNativeDecimal(){return this.transaction.nonNativeDecimal}set nonNativeDecimal(br){this.transaction.nonNativeDecimal=br}get data(){return this.transaction.data}submit(){return __awaiter$9(this,void 0,void 0,function*(){return this.onSubmit(this.transaction).catch(br=>{throw br instanceof UserRejectedTransactionError?new TransactionExecutionError(new BaseError(br.message),this.transaction):br})})}getBalance(){return this.publicClient.getBalance({address:this.address})}estimateGas(){return __awaiter$9(this,void 0,void 0,function*(){const br=yield this.publicClient.transport.request({method:"eth_estimateGas",params:[{data:this.data,to:this.to,value:this.convertBigIntToHex(this.value)}]});return hexToBigInt(br)})}convertBigIntToHex(br){return br?toHex(br):void 0}estimateL1Fee(){return __awaiter$9(this,void 0,void 0,function*(){var br;return isL1FeeSupportedByChain(((br=this.publicClient.chain)===null||br===void 0?void 0:br.id)||0)?estimateL1Fee(this.publicClient,{data:this.transaction.data,to:this.transaction.to,value:this.transaction.value}):BigInt(0)})}set maxFeePerGas(br){this.transaction.maxFeePerGas=br}set maxPriorityFeePerGas(br){this.transaction.maxPriorityFeePerGas=br}}const createViemUiTransaction=fr=>__awaiter$9(void 0,[fr],void 0,function*({from:br,publicClient:wr,walletClient:Er}){return new ViemUiTransaction({account:br,onSubmit:kr=>__awaiter$9(void 0,void 0,void 0,function*(){return kr.nonNativeAddress?Er.writeContract({abi:erc20Abi,account:br,address:kr.nonNativeAddress,args:[kr.to,kr.nonNativeValue],functionName:"transfer",maxFeePerGas:kr.maxFeePerGas,maxPriorityFeePerGas:kr.maxPriorityFeePerGas}):Er.sendTransaction({account:br,maxFeePerGas:kr.maxFeePerGas,maxPriorityFeePerGas:kr.maxPriorityFeePerGas,to:kr.to,value:kr.value})}),publicClient:wr,transaction:{}})}),getChain=fr=>{for(const br of Object.values(viemChains))if("id"in br&&br.id===fr)return br;throw new Error(`Chain with id ${fr} not found`)},mapChain=fr=>{var br;return{blockExplorers:!((br=fr.blockExplorerUrls)===null||br===void 0)&&br[0]?{default:{name:fr.blockExplorerUrls[0],url:fr.blockExplorerUrls[0]}}:void 0,id:fr.chainId,name:fr.vanityName||fr.name||fr.chainName,nativeCurrency:fr.nativeCurrency,rpcUrls:{default:{http:fr.rpcUrls},public:{http:fr.rpcUrls}}}},getOrMapViemChain=fr=>{let br;try{br=getChain(fr.chainId)}catch{logger$2.debug(`Chain with id ${fr.chainId} not found in viem's chains`)}const wr=mapChain(fr);return br?Object.assign(Object.assign({},br),wr):wr},findEvmNetwork=({chainId:fr,name:br,networks:wr})=>{if(!(!fr&&!br))return fr&&br?wr.find(Er=>Er.chainId===fr&&Er.name===br):fr?wr.find(Er=>Er.chainId===fr):wr.find(Er=>Er.name===br)};var L2ResolverAbi=[{inputs:[{internalType:"contract ENS",name:"ens_",type:"address"},{internalType:"address",name:"registrarController_",type:"address"},{internalType:"address",name:"reverseRegistrar_",type:"address"},{internalType:"address",name:"owner_",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"AlreadyInitialized",type:"error"},{inputs:[],name:"CantSetSelfAsDelegate",type:"error"},{inputs:[],name:"CantSetSelfAsOperator",type:"error"},{inputs:[],name:"NewOwnerIsZeroAddress",type:"error"},{inputs:[],name:"NoHandoverRequest",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"node",type:"bytes32"},{indexed:!0,internalType:"uint256",name:"contentType",type:"uint256"}],name:"ABIChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"node",type:"bytes32"},{indexed:!1,internalType:"address",name:"a",type:"address"}],name:"AddrChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"node",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"coinType",type:"uint256"},{indexed:!1,internalType:"bytes",name:"newAddress",type:"bytes"}],name:"AddressChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"bytes32",name:"node",type:"bytes32"},{indexed:!0,internalType:"address",name:"delegate",type:"address"},{indexed:!0,internalType:"bool",name:"approved",type:"bool"}],name:"Approved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"node",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"hash",type:"bytes"}],name:"ContenthashChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"node",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"name",type:"bytes"},{indexed:!1,internalType:"uint16",name:"resource",type:"uint16"},{indexed:!1,internalType:"bytes",name:"record",type:"bytes"}],name:"DNSRecordChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"node",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"name",type:"bytes"},{indexed:!1,internalType:"uint16",name:"resource",type:"uint16"}],name:"DNSRecordDeleted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"node",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"lastzonehash",type:"bytes"},{indexed:!1,internalType:"bytes",name:"zonehash",type:"bytes"}],name:"DNSZonehashChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"node",type:"bytes32"},{indexed:!0,internalType:"bytes4",name:"interfaceID",type:"bytes4"},{indexed:!1,internalType:"address",name:"implementer",type:"address"}],name:"InterfaceChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"node",type:"bytes32"},{indexed:!1,internalType:"string",name:"name",type:"string"}],name:"NameChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"pendingOwner",type:"address"}],name:"OwnershipHandoverCanceled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"pendingOwner",type:"address"}],name:"OwnershipHandoverRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oldOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"node",type:"bytes32"},{indexed:!1,internalType:"bytes32",name:"x",type:"bytes32"},{indexed:!1,internalType:"bytes32",name:"y",type:"bytes32"}],name:"PubkeyChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newRegistrarController",type:"address"}],name:"RegistrarControllerUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newReverseRegistrar",type:"address"}],name:"ReverseRegistrarUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"node",type:"bytes32"},{indexed:!0,internalType:"string",name:"indexedKey",type:"string"},{indexed:!1,internalType:"string",name:"key",type:"string"},{indexed:!1,internalType:"string",name:"value",type:"string"}],name:"TextChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"node",type:"bytes32"},{indexed:!1,internalType:"uint64",name:"newVersion",type:"uint64"}],name:"VersionChanged",type:"event"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"uint256",name:"contentTypes",type:"uint256"}],name:"ABI",outputs:[{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"}],name:"addr",outputs:[{internalType:"address payable",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"uint256",name:"coinType",type:"uint256"}],name:"addr",outputs:[{internalType:"bytes",name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"address",name:"delegate",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"cancelOwnershipHandover",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"}],name:"clearRecords",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"pendingOwner",type:"address"}],name:"completeOwnershipHandover",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"}],name:"contenthash",outputs:[{internalType:"bytes",name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"bytes32",name:"name",type:"bytes32"},{internalType:"uint16",name:"resource",type:"uint16"}],name:"dnsRecord",outputs:[{internalType:"bytes",name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[],name:"ens",outputs:[{internalType:"contract ENS",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"bytes32",name:"name",type:"bytes32"}],name:"hasDNSRecords",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"bytes4",name:"interfaceID",type:"bytes4"}],name:"interfaceImplementer",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"address",name:"delegate",type:"address"}],name:"isApprovedFor",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"nodehash",type:"bytes32"},{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicallWithNodeCheck",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"}],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"result",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"pendingOwner",type:"address"}],name:"ownershipHandoverExpiresAt",outputs:[{internalType:"uint256",name:"result",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"}],name:"pubkey",outputs:[{internalType:"bytes32",name:"x",type:"bytes32"},{internalType:"bytes32",name:"y",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"recordVersions",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[],name:"registrarController",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"requestOwnershipHandover",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes",name:"",type:"bytes"},{internalType:"bytes",name:"data",type:"bytes"}],name:"resolve",outputs:[{internalType:"bytes",name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[],name:"reverseRegistrar",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"uint256",name:"contentType",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"setABI",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"uint256",name:"coinType",type:"uint256"},{internalType:"bytes",name:"a",type:"bytes"}],name:"setAddr",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"address",name:"a",type:"address"}],name:"setAddr",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"bytes",name:"hash",type:"bytes"}],name:"setContenthash",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"bytes",name:"data",type:"bytes"}],name:"setDNSRecords",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"bytes4",name:"interfaceID",type:"bytes4"},{internalType:"address",name:"implementer",type:"address"}],name:"setInterface",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"string",name:"newName",type:"string"}],name:"setName",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"bytes32",name:"x",type:"bytes32"},{internalType:"bytes32",name:"y",type:"bytes32"}],name:"setPubkey",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"registrarController_",type:"address"}],name:"setRegistrarController",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"reverseRegistrar_",type:"address"}],name:"setReverseRegistrar",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"string",name:"key",type:"string"},{internalType:"string",name:"value",type:"string"}],name:"setText",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"bytes",name:"hash",type:"bytes"}],name:"setZonehash",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceID",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"},{internalType:"string",name:"key",type:"string"}],name:"text",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes32",name:"node",type:"bytes32"}],name:"zonehash",outputs:[{internalType:"bytes",name:"",type:"bytes"}],stateMutability:"view",type:"function"}];const getNameservice=fr=>__awaiter$9(void 0,[fr],void 0,function*({rpcProvider:br,address:wr}){const Er={avatar:void 0,name:void 0},kr=yield br.getChainId();if(!kr)return Er;const jr=(Wr,qr)=>{const Hr=Wr.toLocaleLowerCase(),Vr=keccak256(Hr.substring(2)),Zr=Br(qr),Jr=namehash(`${Zr.toLocaleUpperCase()}.reverse`);return keccak256(encodePacked(["bytes32","bytes32"],[Jr,Vr]))},Br=Wr=>((2147483648|Wr)>>>0).toString(16).toLocaleUpperCase();if(kr===8453){const Wr=jr(wr,8453);try{const qr=yield br.readContract({abi:L2ResolverAbi,address:"0xC6d566A56A1aFf6508b41f6c90ff131615583BCD",args:[Wr],functionName:"name"});if(qr)return Er.name=qr,Er}catch{return Er}}else Er.name=yield br.getEnsName({address:wr}),Er.avatar=Er.name?yield br.getEnsAvatar({name:Er.name}):void 0;return Er}),isTransactionExecutionError=fr=>fr!=null&&typeof fr=="object"&&"walk"in fr&&typeof fr.walk=="function",interceptTransport=({getAccounts:fr,onPersonalSign:br,onSendTransaction:wr,onSignTypedData:Er,transport:kr})=>jr=>{const Br=kr(jr);return custom({request:Wr=>__awaiter$9(void 0,void 0,void 0,function*(){var qr;const{method:Hr,params:Vr}=Wr;if(fr&&Hr==="eth_accounts")return fr({provider:Br});if(br&&Hr==="personal_sign"){const[Zr]=Vr;return br({args:Wr,message:Zr,provider:Br}).catch(Jr=>{throw Jr instanceof UserRejectedRequestError$1?new UserRejectedRequestError(Jr):Jr})}if(wr&&Hr==="eth_sendTransaction"){const[Zr]=Vr;return wr({args:Wr,provider:Br,transaction:Zr}).catch(Jr=>{throw isTransactionExecutionError(Jr)&&Jr.walk()instanceof UserRejectedTransactionError?new UserRejectedRequestError(Jr.walk()):Jr instanceof UserRejectedRequestError$1?new UserRejectedRequestError(Jr):Jr})}if(Er&&Hr==="eth_signTypedData_v4"){const[,Zr]=(qr=Vr)!==null&&qr!==void 0?qr:[];return Er({args:Wr,message:Zr,provider:Br}).catch(Jr=>{throw Jr instanceof UserRejectedRequestError$1?new UserRejectedRequestError(Jr):Jr})}return Br.request(Wr)})})(jr)};class EthereumWallet extends Wallet$2{getPublicClient(){return __awaiter$9(this,void 0,void 0,function*(){const br=yield this._connector.getPublicClient();if(!br)throw new Error("Unable to retrieve PublicClient");return br})}getWalletClient(br){return __awaiter$9(this,void 0,void 0,function*(){const wr=this._connector.getWalletClient(br);if(!wr)throw new Error("Unable to retrieve WalletClient");return createWalletClient({account:this.address,chain:wr.chain,transport:interceptTransport({onPersonalSign:Er=>__awaiter$9(this,[Er],void 0,function*({provider:kr,args:jr}){return yield this.sync(),kr.request(jr)}),onSendTransaction:Er=>__awaiter$9(this,[Er],void 0,function*({provider:kr,args:jr}){return yield this.sync(),kr.request(jr)}),onSignTypedData:Er=>__awaiter$9(this,[Er],void 0,function*({provider:kr,args:jr}){return yield this.sync(),kr.request(jr)}),transport:custom(wr.transport)})})})}}class EthereumWalletConnector extends WalletConnectorBase{getPublicClient(){return __awaiter$9(this,void 0,void 0,function*(){var br,wr;const Er=(br=yield this.getNetwork())!==null&&br!==void 0?br:1;if(this.evmNetworks.length===0)return;const kr={cosmos:[],evm:this.evmNetworks,solana:[],starknet:void 0};if(!this.chainRpcProviders)return;const jr=this.chainRpcProviders.getProviders(kr);return(wr=this.chainRpcProviders.getEvmProviderByChainId(jr,Er))===null||wr===void 0?void 0:wr.provider})}constructor(br){var wr;super(br),this.ChainWallet=EthereumWallet,this.evmNetworkRpcMap=()=>this.evmNetworks.reduce((Er,kr)=>{var jr;return[Er[kr.chainId]]=!((jr=kr==null?void 0:kr.privateCustomerRpcUrls)===null||jr===void 0)&&jr.length?kr.privateCustomerRpcUrls:kr.rpcUrls,Er},{}),this.evmNetworks=parseEvmNetworks(br.evmNetworks),this.chainRpcProviders=br.chainRpcProviders,(wr=this.chainRpcProviders)===null||wr===void 0||wr.registerEvmProviders()}getNetwork(){return __awaiter$9(this,void 0,void 0,function*(){const br=this.getWalletClient();if(!this.supportsNetworkSwitching||!br)return Promise.resolve(void 0);const wr=yield retryableFn(br.getChainId,{fallbackValue:FALLBACK_UNDEFINED,timeoutMs:1e3});return this.setActiveChain(chainsMap[wr]),wr})}getNameService(br){return __awaiter$9(this,void 0,void 0,function*(){const wr=yield this.getPublicClient();if(wr)return getNameservice({address:br,rpcProvider:wr})})}isTestnet(){return __awaiter$9(this,void 0,void 0,function*(){var br,wr,Er;return(Er=(wr=(br=yield this.getPublicClient())===null||br===void 0?void 0:br.chain)===null||wr===void 0?void 0:wr.testnet)!==null&&Er!==void 0?Er:!1})}parseAddress(br){try{return getAddress(br)}catch(wr){logger$7.debug(`Failed to parse EVM address into EIP55 format: error getting checksum, returning default ${br}`,wr)}return br}getSigner(){return __awaiter$9(this,void 0,void 0,function*(){return this.getWalletClient()})}getBalance(br){return __awaiter$9(this,void 0,void 0,function*(){const wr=yield this.getPublicClient(),Er=yield wr==null?void 0:wr.getBalance({address:br});if(!(!Er&&Er!==BigInt(0)))return formatEther$1(Er)})}supportsNetworkSwitching(){return!0}switchNetwork(br){return __awaiter$9(this,arguments,void 0,function*({networkName:wr,networkChainId:Er}){const kr=findEvmNetwork({chainId:Er,name:wr,networks:this.evmNetworks});if(!kr)throw new DynamicError(`Could not find network mapping for chain ${wr||Er}`);if(!this.supportsNetworkSwitching())throw new DynamicError("Network switching is not supported");const jr=this.getWalletClient();if(!jr)throw new DynamicError("Provider not found");return this.providerSwitchNetwork({network:kr,provider:jr})})}chooseAccountsToConnect(){return __awaiter$9(this,void 0,void 0,function*(){var br,wr,Er;const kr=this.getWalletClient();if(!kr)return[];try{const jr=yield kr.requestPermissions({eth_accounts:{}});logger$7.debug("chooseAccountsToConnect - requestPermissions result",jr);const Br=(Er=(wr=(br=jr==null?void 0:jr.find(Wr=>Wr.parentCapability==="eth_accounts"))===null||br===void 0?void 0:br.caveats)===null||wr===void 0?void 0:wr[0])===null||Er===void 0?void 0:Er.value;return typeof Br=="string"?[Br]:Array.isArray(Br)?Br:[]}catch(jr){if(logger$7.debug("chooseAccountsToConnect - error",jr),jr.code===4001)throw new UserRejectedRequestError$1}return[]})}getConnectedAccounts(){return __awaiter$9(this,void 0,void 0,function*(){const br=this.getWalletClient();if(!br)return[];const wr=yield retryableFn(br.getAddresses,{fallbackValue:[],timeoutMs:500});return wr.length&&this.setActiveAccount(wr[0]),wr})}providerSwitchNetwork(br){return __awaiter$9(this,arguments,void 0,function*({network:wr,provider:Er}){var kr,jr,Br,Wr;const{chainId:qr}=wr,Hr=yield this.getNetwork();if(!(Hr&&Hr===qr))try{if(!this.supportsNetworkSwitching())throw new DynamicError("Network switching is not supported");const Vr=getOrMapViemChain(wr);if(yield Er.switchChain(Vr),this.key==="magiceden"){const Zr=yield Er.getChainId();this.emit("chainChange",{chain:Zr.toString()})}else this.setActiveChain(Vr)}catch(Vr){if(Vr.code===4902||!((kr=Vr.message)===null||kr===void 0)&&kr.includes("Unrecognized chain")||((Br=(jr=Vr.data)===null||jr===void 0?void 0:jr.orginalError)===null||Br===void 0?void 0:Br.code)===4902)return this.providerAddNetwork({network:wr,provider:Er});throw!((Wr=Vr.message)===null||Wr===void 0)&&Wr.includes("rejected")||typeof Vr=="string"&&Vr.includes("rejected")?new DynamicError("User rejected the wallet's request to switch network"):Vr}})}providerAddNetwork(br){return __awaiter$9(this,arguments,void 0,function*({network:wr,provider:Er}){var kr;try{return yield Er.addChain({chain:getOrMapViemChain(wr)})}catch(jr){throw!((kr=jr.message)===null||kr===void 0)&&kr.includes("rejected")||typeof jr=="string"&&jr.includes("rejected")?new DynamicError("User rejected the wallet's request to add network"):jr}})}setActiveAccount(br){this.activeAccount=br?toAccount(br):void 0}getActiveAccount(){return this.activeAccount}setActiveChain(br){this.activeChain=br}getActiveChain(){return this.activeChain}createUiTransaction(br){return __awaiter$9(this,void 0,void 0,function*(){yield this.validateActiveWallet(br);const wr=yield this.getWalletClient(),Er=yield this.getPublicClient();if(!Er||!wr)throw new DynamicError("No public client available");return createViemUiTransaction({from:br,publicClient:Er,walletClient:wr})})}confirmTransactionStatus(br){return __awaiter$9(this,void 0,void 0,function*(){const wr=yield this.getPublicClient();if(!wr)throw new DynamicError("No public client available");return wr.waitForTransactionReceipt({confirmations:3,hash:br})})}}ChainRpcProviders.getEvmProviderByChainId=(fr,br)=>{var wr;return(wr=fr.evm)===null||wr===void 0?void 0:wr.find(kr=>kr.chainId===br)};ChainRpcProviders.registerEvmProviders=()=>{ChainRpcProviders.registerChainProviders(ProviderChain.EVM,fr=>{const br={};return fr!=null&&fr.evm&&(br.evm=parseEvmNetworks(fr.evm).map(wr=>{var Er;const kr=((Er=wr.privateCustomerRpcUrls)===null||Er===void 0?void 0:Er[0])||wr.rpcUrls[0],jr=createPublicClient({chain:getOrMapViemChain(wr),transport:http(kr)});return{chainId:wr.chainId,chainName:wr.name,provider:jr}})),br.evm})};const unFormatTransaction=fr=>Object.assign(Object.assign({},fr),{gas:typeof fr.gas<"u"?hexToBigInt(fr.gas):void 0,gasPrice:typeof fr.gasPrice<"u"?hexToBigInt(fr.gasPrice):void 0,maxFeePerGas:typeof fr.maxFeePerGas<"u"?hexToBigInt(fr.maxFeePerGas):void 0,maxPriorityFeePerGas:typeof fr.maxPriorityFeePerGas<"u"?hexToBigInt(fr.maxPriorityFeePerGas):void 0,nonce:typeof fr.nonce<"u"?hexToBigInt(fr.nonce):void 0,value:typeof fr.value<"u"?hexToBigInt(fr.value):void 0}),createAccountWithUiConfirmation=({address:fr,account:br,provider:wr,walletConnector:Er,walletUiUtils:kr})=>toAccount({address:fr,signMessage:(...jr)=>__awaiter$9(void 0,void 0,void 0,function*(){return kr.signMessage({handler:()=>__awaiter$9(void 0,void 0,void 0,function*(){return(yield br()).signMessage(...jr)}),message:(()=>{var Br;const Wr=(Br=jr[0])===null||Br===void 0?void 0:Br.message;return Wr&&!(typeof Wr=="string"&&Array.isArray(Wr))?JSON.stringify(Wr):Wr==null?void 0:Wr.toString()})(),walletConnector:Er})}),signTransaction:(...jr)=>__awaiter$9(void 0,void 0,void 0,function*(){const Br=new ViemUiTransaction({account:fr,onSubmit:Wr=>__awaiter$9(void 0,void 0,void 0,function*(){return(yield br()).signTransaction(Wr)}),publicClient:wr,transaction:jr[0]});return kr.sendTransaction(Er,Br)}),signTypedData:(...jr)=>kr.signMessage({handler:()=>__awaiter$9(void 0,void 0,void 0,function*(){return(yield br()).signTypedData(...jr)}),message:JSON.stringify(jr[0]),walletConnector:Er})}),createWalletClientWithUiConfirmation=({address:fr,account:br,chain:wr,transport:Er,walletConnector:kr,walletUiUtils:jr})=>{let Br=null;const Wr=createPublicClient({chain:wr,transport:Er}),qr=createAccountWithUiConfirmation({account:br,address:fr,provider:Wr,walletConnector:kr,walletUiUtils:jr}),Hr=interceptTransport({getAccounts:()=>__awaiter$9(void 0,void 0,void 0,function*(){return[fr]}),onPersonalSign:Vr=>__awaiter$9(void 0,[Vr],void 0,function*({message:Zr}){if(!Br)throw new Error("Client not initialized");return Br.signMessage({message:{raw:Zr}})}),onSendTransaction:Vr=>__awaiter$9(void 0,[Vr],void 0,function*({transaction:Zr}){if(!Br)throw new Error("Client not initialized");const Jr=unFormatTransaction(Zr);return Br.sendTransaction(Jr)}),onSignTypedData:Vr=>__awaiter$9(void 0,[Vr],void 0,function*({message:Zr}){if(!Br)throw new Error("Client not initialized");return Br.signTypedData(JSON.parse(Zr))}),transport:Er});return Br=createWalletClient({account:qr,chain:wr,transport:Hr}),Br};assertPackageVersion("@dynamic-labs/ethereum-core",version$a);class TurnkeyEVMWalletConnector extends TurnkeyWalletConnectorBase{constructor(br,wr){var Er;super(br,wr),this.walletFallback={brand:{alt:"Turnkey Wallet",spriteId:"turnkey"},name:"Turnkey HD"},this.ChainWallet=EthereumWallet,this.connectedChain="EVM",this.supportedChains=["ETH","EVM"],this.verifiedCredentialChain="eip155",this.stampCreateWalletAccountRequest=kr=>__awaiter$a(this,[kr],void 0,function*({request:jr}){return yield this.createOrRestoreSession(),this.getTurnkeyClient().stampCreateWalletAccounts(jr)}),this.evmNetworks=parseEvmNetworks(wr.evmNetworks),this.walletUiUtils=wr.walletUiUtils,this._turnkeyAccount=void 0,this._selectedChainId=this.getLastUsedChainId(),this.chainRpcProviders=wr.chainRpcProviders,(Er=this.chainRpcProviders)===null||Er===void 0||Er.registerEvmProviders(),this.__turnkeyClient=this.getTurnkeyClient()}getLastUsedChainId(){var br;if(this.lastUsedChainId)return this.lastUsedChainId;if(!((br=this.evmNetworks)===null||br===void 0)&&br.length)return this.evmNetworks[0].chainId}getNetwork(){return __awaiter$a(this,void 0,void 0,function*(){var br;return(br=yield this.getSigner())===null||br===void 0?void 0:br.getChainId()})}supportsNetworkSwitching(){return!0}switchNetwork(br){return __awaiter$a(this,arguments,void 0,function*({networkChainId:wr}){wr&&(typeof wr=="string"&&(wr=parseInt(wr)),this.lastUsedChainId=wr,this._selectedChainId=wr,yield this.refreshTurnkeyAccount(),this.emit("chainChange",{chain:wr.toString()}))})}setVerifiedCredentials(br){const wr=findTurnkeyVerifiedCredentialsWithSmartWalletRef(br,"eip155"),[Er]=wr;JSON.stringify(this.verifiedCredentials)!==JSON.stringify(wr)&&(this.verifiedCredential=Er,this.verifiedCredentials=wr,this.refreshTurnkeyAccount())}validateActiveWallet(br){return __awaiter$a(this,void 0,void 0,function*(){var wr,Er;const kr=((wr=this.verifiedCredential)===null||wr===void 0?void 0:wr.address)||"";if(!isSameAddress$1(kr,br,this.connectedChain)){const Br=(Er=this.verifiedCredentials)===null||Er===void 0?void 0:Er.find(Wr=>(Wr==null?void 0:Wr.address)===br);if(!Br)throw new DynamicError("Account not found");this.verifiedCredential=Br,this.refreshTurnkeyAccount()}})}getRpcUrl(){const br=this._selectedChainId;return getRpcUrlForChain({chainId:br,networks:this.evmNetworks})}getBalance(br){return __awaiter$a(this,void 0,void 0,function*(){const wr=this.getRpcUrl();if(!wr)return;const kr=yield createPublicClient({transport:http(wr)}).getBalance({address:br});return formatEther$1(kr)})}signMessage(br){return __awaiter$a(this,void 0,void 0,function*(){const wr=yield this.getSigner();if(!wr)throw new Error("Signer not found");return wr.signMessage({message:br})})}getPublicClient(){return __awaiter$a(this,void 0,void 0,function*(){var br,wr;if(this.evmNetworks.length===0)return;const Er=(br=yield this.getNetwork())!==null&&br!==void 0?br:1,kr={cosmos:[],evm:this.evmNetworks,solana:[],starknet:void 0};if(!this.chainRpcProviders)return;const jr=this.chainRpcProviders.getProviders(kr);return(wr=this.chainRpcProviders.getEvmProviderByChainId(jr,Er))===null||wr===void 0?void 0:wr.provider})}getSigner(){return __awaiter$a(this,void 0,void 0,function*(){return yield this.getTurnkeyAccount(),this.getWalletClient()})}getTurnkeyClient(){var br;let wr=getTLD();wr||(wr=PlatformService.getHostname());const Er=PasskeyService.createWebauthnStamper({rpId:wr}),kr=TurnkeyWalletConnectorBase==null?void 0:TurnkeyWalletConnectorBase.apiKeyStamper,jr=kr??Er;return this.__turnkeyClient=(br=this.getAuthenticatorHandler().client)!==null&&br!==void 0?br:new TurnkeyClient({baseUrl:TURNKEY_API_BASE_URL},jr),this.__turnkeyClient}getAccount(){return __awaiter$a(this,void 0,void 0,function*(){var br,wr,Er;return this.isSessionKeyCompatible()&&((br=this.__turnkeyClient)===null||br===void 0?void 0:br.stamper)instanceof ApiKeyStamper?this._turnkeyAccount:((this.getAuthenticatorHandler().recoveryType==="passkey"&&((wr=this.__turnkeyClient)===null||wr===void 0?void 0:wr.stamper)instanceof IframeStamper||this.getAuthenticatorHandler().recoveryType==="email"&&((Er=this.__turnkeyClient)===null||Er===void 0?void 0:Er.stamper)instanceof WebauthnStamper||this.__turnkeyClient!==this.getAuthenticatorHandler().client)&&(yield this.refreshTurnkeyAccount()),this._turnkeyAccount)})}getWalletClient(){const br=this.networkRpcUrl,wr=this._turnkeyAccount,Er=this.currentEvmNetwork;if(!(!wr||!br||!Er))return createWalletClientWithUiConfirmation({account:this.getAccount.bind(this),address:this.turnkeyAddress,chain:getOrMapViemChain(Er),transport:http(br),walletConnector:this,walletUiUtils:this.walletUiUtils})}get currentChainId(){var br,wr,Er;return(br=this._selectedChainId)!==null&&br!==void 0?br:(Er=(wr=this.evmNetworks)===null||wr===void 0?void 0:wr[0])===null||Er===void 0?void 0:Er.chainId}get lastUsedChainId(){const br=localStorage.getItem(TurnkeyEVMWalletConnector.lastUsedChainIdStorageKey);if(br)try{const wr=parseInt(br);if(isNaN(wr))return;if(!this.evmNetworks.some(kr=>kr.chainId===wr)){const kr=this.evmNetworks[0].chainId;return this.lastUsedChainId=kr,this.lastUsedChainId}return wr}catch(wr){logger$4.error(wr);return}}set lastUsedChainId(br){br===void 0?localStorage.removeItem(TurnkeyEVMWalletConnector.lastUsedChainIdStorageKey):localStorage.setItem(TurnkeyEVMWalletConnector.lastUsedChainIdStorageKey,br.toString())}get networkRpcUrl(){const br=this.currentChainId;return this.evmNetworks.find(kr=>kr.chainId===br)?getRpcUrlForChain({chainId:br,networks:this.evmNetworks}):void 0}get currentEvmNetwork(){const br=this.currentChainId;return this.evmNetworks.find(wr=>wr.chainId===br)}internalSignTransaction(br){return __awaiter$a(this,arguments,void 0,function*({transaction:wr,args:Er,address:kr,turnkeySubOrganizationId:jr}){return this.doRetryableTurnkeyAction({action:Br=>Br.signTransaction(wr,Er),activityType:"SignTransaction",address:kr,turnkeySubOrganizationId:jr})})}internalSignTypedData(br){return __awaiter$a(this,arguments,void 0,function*({typedData:wr,address:Er,turnkeySubOrganizationId:kr}){return this.doRetryableTurnkeyAction({action:jr=>jr.signTypedData(wr),activityType:"SignTypedData",address:Er,turnkeySubOrganizationId:kr})})}internalSignMessage(br){return __awaiter$a(this,arguments,void 0,function*({message:wr,address:Er,turnkeySubOrganizationId:kr}){return this.doRetryableTurnkeyAction({action:jr=>jr.signMessage({message:wr}),activityType:"SignMessage",address:Er,turnkeySubOrganizationId:kr})})}doRetryableTurnkeyAction(br){return __awaiter$a(this,arguments,void 0,function*({action:wr,activityType:Er,address:kr,turnkeySubOrganizationId:jr}){yield this.createOrRestoreSession();let Br=yield this.createTurnkeyAccount({address:kr,turnkeySubOrganizationId:jr});try{return yield wr(Br)}catch(Wr){if(TURNKEY_SDK_SESSION_KEY_RETRYABLE_ERRORS.some(qr=>Wr.message.includes(qr)))return yield this.removeSessionKeys(),yield this.createOrRestoreSession({ignoreRestore:!0}),Br=yield this.createTurnkeyAccount({address:kr,turnkeySubOrganizationId:jr}),wr(Br);throw logger$4.error(`[TK] failed to perform ${Er} activity`,Wr),Wr}})}createTurnkeyAccount(br){return __awaiter$a(this,arguments,void 0,function*({address:wr,turnkeySubOrganizationId:Er}){return createAccount({client:this.getTurnkeyClient(),ethereumAddress:wr,organizationId:Er,signWith:wr})})}refreshTurnkeyAccount(){return __awaiter$a(this,void 0,void 0,function*(){return this._turnkeyAccount=void 0,this.getTurnkeyAccount()})}getTurnkeyAccount(){return __awaiter$a(this,void 0,void 0,function*(){var br,wr;if(this._turnkeyAccount)return this._turnkeyAccount;const{turnkeySubOrganizationId:Er}=(br=this.walletProperties)!==null&&br!==void 0?br:{},{address:kr}=(wr=this.verifiedCredential)!==null&&wr!==void 0?wr:{};if(!(!Er||!kr))return this._turnkeyAccount=toAccount({address:kr,signMessage:jr=>__awaiter$a(this,[jr],void 0,function*({message:Br}){return this.internalSignMessage({address:kr,message:Br,turnkeySubOrganizationId:Er})}),signTransaction:(jr,Br)=>__awaiter$a(this,void 0,void 0,function*(){return this.internalSignTransaction({address:kr,args:Br,transaction:jr,turnkeySubOrganizationId:Er})}),signTypedData:jr=>__awaiter$a(this,void 0,void 0,function*(){return this.internalSignTypedData({address:kr,turnkeySubOrganizationId:Er,typedData:jr})})}),this.setLoggerMetadata(),this._turnkeyAccount})}createUiTransaction(br){return __awaiter$a(this,void 0,void 0,function*(){yield this.validateActiveWallet(br);const wr=this.getWalletClient(),Er=yield this.getPublicClient();if(!Er||!wr)throw new DynamicError("No public client available");return createViemUiTransaction({from:br,publicClient:Er,walletClient:wr})})}}TurnkeyEVMWalletConnector.lastUsedChainIdStorageKey="turnkey-last-used-chain-id";const TurnkeyEVMWalletConnectors=fr=>{var br;return!((br=fr.apiProviders)===null||br===void 0)&&br.turnkey?[TurnkeyEVMWalletConnector.bind(null,TurnkeyWalletConnectorInfo.TurnkeyHD),TurnkeyEVMWalletConnector.bind(null,TurnkeyWalletConnectorInfo.Turnkey)]:[]};assertPackageVersion("@dynamic-labs/embedded-wallet-evm",version$d);var version$9="3.8.2";function __rest$6(fr,br){var wr={};for(var Er in fr)Object.prototype.hasOwnProperty.call(fr,Er)&&br.indexOf(Er)<0&&(wr[Er]=fr[Er]);if(fr!=null&&typeof Object.getOwnPropertySymbols=="function")for(var kr=0,Er=Object.getOwnPropertySymbols(fr);krwr.chain==="evm")}installedProviders(){const br=this.getInjectedConfig();if(!br)return[];const wr=[];if(br.windowLocations)for(const Er of br.windowLocations){const kr=getProvidersFromWindow(Er);kr&&kr.length&&wr.push(...kr)}return window.ethereum&&(!window.ethereum.providers||!window.ethereum.providers.length?wr.push(window.ethereum):window.ethereum.providers.forEach(Er=>wr.push(Er))),wr}installedProviderLookup(br){const wr=this.installedProviders();return ProviderLookup(wr,br)}eip6963ProviderLookup(br){var wr;const{providers:Er}=Eip6963ProviderSingleton.get();return(wr=Er.find(kr=>{var jr;return((jr=kr==null?void 0:kr.info)===null||jr===void 0?void 0:jr.rdns)===br}))===null||wr===void 0?void 0:wr.provider}isInstalledHelper(){return this.findProvider()!==void 0}findProvider(){return this.connector.findProvider()}findWalletClient(br){const wr=this.findProvider();if(wr)return createWalletClient({account:this.connector.getActiveAccount(),chain:br?chainsMap[br]:this.connector.getActiveChain(),transport:custom(wr)})}getAddress(){return __awaiter$8(this,void 0,void 0,function*(){const br=this.findWalletClient();return br?this.getAddressWithProvider(br):Promise.resolve(void 0)})}getAddressWithProvider(br){return __awaiter$8(this,void 0,void 0,function*(){try{const[wr]=yield br.requestAddresses(),Er=getAddress(wr);return this.connector.setActiveAccount(Er),Er}catch(wr){return logger$7.error(wr),Promise.reject(wr)}})}signMessage(br){return __awaiter$8(this,void 0,void 0,function*(){const wr=yield this.getAddress();if(!wr)return Promise.resolve(void 0);const Er=this.findWalletClient();return Er?yield Er.signMessage({account:wr,message:br}):Promise.resolve(void 0)})}_setupEventListeners(br){const wr=this.findProvider();if(!wr)return logger$7.warn("Provider not found",{connector:br}),{tearDownEventListeners:()=>{}};if(!wr.on)return logger$7.warn("Provider does not support event listeners",{connector:br,provider:wr}),{tearDownEventListeners:()=>{}};const{handleAccountChange:Er,handleChainChange:kr,handleDisconnect:jr}=eventListenerHandlers(br);return wr.on("accountsChanged",Er),wr.on("chainChanged",kr),wr.on("disconnect",jr),{tearDownEventListeners:()=>{const Wr=this.findProvider();Wr&&(Er&&Wr.removeListener("accountsChanged",Er),kr&&Wr.removeListener("chainChanged",kr),jr&&Wr.removeListener("disconnect",jr))}}}}var chacha20poly1305={},chacha={},binary={},int={};(function(fr){Object.defineProperty(fr,"__esModule",{value:!0});function br(Wr,qr){var Hr=Wr>>>16&65535,Vr=Wr&65535,Zr=qr>>>16&65535,Jr=qr&65535;return Vr*Jr+(Hr*Jr+Vr*Zr<<16>>>0)|0}fr.mul=Math.imul||br;function wr(Wr,qr){return Wr+qr|0}fr.add=wr;function Er(Wr,qr){return Wr-qr|0}fr.sub=Er;function kr(Wr,qr){return Wr<>>32-qr}fr.rotl=kr;function jr(Wr,qr){return Wr<<32-qr|Wr>>>qr}fr.rotr=jr;function Br(Wr){return typeof Wr=="number"&&isFinite(Wr)&&Math.floor(Wr)===Wr}fr.isInteger=Number.isInteger||Br,fr.MAX_SAFE_INTEGER=9007199254740991,fr.isSafeInteger=function(Wr){return fr.isInteger(Wr)&&Wr>=-fr.MAX_SAFE_INTEGER&&Wr<=fr.MAX_SAFE_INTEGER}})(int);Object.defineProperty(binary,"__esModule",{value:!0});var int_1=int;function readInt16BE(fr,br){return br===void 0&&(br=0),(fr[br+0]<<8|fr[br+1])<<16>>16}binary.readInt16BE=readInt16BE;function readUint16BE(fr,br){return br===void 0&&(br=0),(fr[br+0]<<8|fr[br+1])>>>0}binary.readUint16BE=readUint16BE;function readInt16LE(fr,br){return br===void 0&&(br=0),(fr[br+1]<<8|fr[br])<<16>>16}binary.readInt16LE=readInt16LE;function readUint16LE(fr,br){return br===void 0&&(br=0),(fr[br+1]<<8|fr[br])>>>0}binary.readUint16LE=readUint16LE;function writeUint16BE(fr,br,wr){return br===void 0&&(br=new Uint8Array(2)),wr===void 0&&(wr=0),br[wr+0]=fr>>>8,br[wr+1]=fr>>>0,br}binary.writeUint16BE=writeUint16BE;binary.writeInt16BE=writeUint16BE;function writeUint16LE(fr,br,wr){return br===void 0&&(br=new Uint8Array(2)),wr===void 0&&(wr=0),br[wr+0]=fr>>>0,br[wr+1]=fr>>>8,br}binary.writeUint16LE=writeUint16LE;binary.writeInt16LE=writeUint16LE;function readInt32BE(fr,br){return br===void 0&&(br=0),fr[br]<<24|fr[br+1]<<16|fr[br+2]<<8|fr[br+3]}binary.readInt32BE=readInt32BE;function readUint32BE(fr,br){return br===void 0&&(br=0),(fr[br]<<24|fr[br+1]<<16|fr[br+2]<<8|fr[br+3])>>>0}binary.readUint32BE=readUint32BE;function readInt32LE(fr,br){return br===void 0&&(br=0),fr[br+3]<<24|fr[br+2]<<16|fr[br+1]<<8|fr[br]}binary.readInt32LE=readInt32LE;function readUint32LE(fr,br){return br===void 0&&(br=0),(fr[br+3]<<24|fr[br+2]<<16|fr[br+1]<<8|fr[br])>>>0}binary.readUint32LE=readUint32LE;function writeUint32BE(fr,br,wr){return br===void 0&&(br=new Uint8Array(4)),wr===void 0&&(wr=0),br[wr+0]=fr>>>24,br[wr+1]=fr>>>16,br[wr+2]=fr>>>8,br[wr+3]=fr>>>0,br}binary.writeUint32BE=writeUint32BE;binary.writeInt32BE=writeUint32BE;function writeUint32LE(fr,br,wr){return br===void 0&&(br=new Uint8Array(4)),wr===void 0&&(wr=0),br[wr+0]=fr>>>0,br[wr+1]=fr>>>8,br[wr+2]=fr>>>16,br[wr+3]=fr>>>24,br}binary.writeUint32LE=writeUint32LE;binary.writeInt32LE=writeUint32LE;function readInt64BE(fr,br){br===void 0&&(br=0);var wr=readInt32BE(fr,br),Er=readInt32BE(fr,br+4);return wr*4294967296+Er-(Er>>31)*4294967296}binary.readInt64BE=readInt64BE;function readUint64BE(fr,br){br===void 0&&(br=0);var wr=readUint32BE(fr,br),Er=readUint32BE(fr,br+4);return wr*4294967296+Er}binary.readUint64BE=readUint64BE;function readInt64LE(fr,br){br===void 0&&(br=0);var wr=readInt32LE(fr,br),Er=readInt32LE(fr,br+4);return Er*4294967296+wr-(wr>>31)*4294967296}binary.readInt64LE=readInt64LE;function readUint64LE(fr,br){br===void 0&&(br=0);var wr=readUint32LE(fr,br),Er=readUint32LE(fr,br+4);return Er*4294967296+wr}binary.readUint64LE=readUint64LE;function writeUint64BE(fr,br,wr){return br===void 0&&(br=new Uint8Array(8)),wr===void 0&&(wr=0),writeUint32BE(fr/4294967296>>>0,br,wr),writeUint32BE(fr>>>0,br,wr+4),br}binary.writeUint64BE=writeUint64BE;binary.writeInt64BE=writeUint64BE;function writeUint64LE(fr,br,wr){return br===void 0&&(br=new Uint8Array(8)),wr===void 0&&(wr=0),writeUint32LE(fr>>>0,br,wr),writeUint32LE(fr/4294967296>>>0,br,wr+4),br}binary.writeUint64LE=writeUint64LE;binary.writeInt64LE=writeUint64LE;function readUintBE(fr,br,wr){if(wr===void 0&&(wr=0),fr%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(fr/8>br.length-wr)throw new Error("readUintBE: array is too short for the given bitLength");for(var Er=0,kr=1,jr=fr/8+wr-1;jr>=wr;jr--)Er+=br[jr]*kr,kr*=256;return Er}binary.readUintBE=readUintBE;function readUintLE(fr,br,wr){if(wr===void 0&&(wr=0),fr%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(fr/8>br.length-wr)throw new Error("readUintLE: array is too short for the given bitLength");for(var Er=0,kr=1,jr=wr;jr=Er;jr--)wr[jr]=br/kr&255,kr*=256;return wr}binary.writeUintBE=writeUintBE;function writeUintLE(fr,br,wr,Er){if(wr===void 0&&(wr=new Uint8Array(fr/8)),Er===void 0&&(Er=0),fr%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!int_1.isSafeInteger(br))throw new Error("writeUintLE value must be an integer");for(var kr=1,jr=Er;jr>>16|Xr<<16,so=so+Xr|0,_i^=so,_i=_i>>>20|_i<<12,eo=eo+oo|0,Sn^=eo,Sn=Sn>>>16|Sn<<16,no=no+Sn|0,oo^=no,oo=oo>>>20|oo<<12,ro=ro+io|0,Rn^=ro,Rn=Rn>>>16|Rn<<16,Tn=Tn+Rn|0,io^=Tn,io=io>>>20|io<<12,to=to+co|0,Pn^=to,Pn=Pn>>>16|Pn<<16,Gr=Gr+Pn|0,co^=Gr,co=co>>>20|co<<12,ro=ro+io|0,Rn^=ro,Rn=Rn>>>24|Rn<<8,Tn=Tn+Rn|0,io^=Tn,io=io>>>25|io<<7,to=to+co|0,Pn^=to,Pn=Pn>>>24|Pn<<8,Gr=Gr+Pn|0,co^=Gr,co=co>>>25|co<<7,eo=eo+oo|0,Sn^=eo,Sn=Sn>>>24|Sn<<8,no=no+Sn|0,oo^=no,oo=oo>>>25|oo<<7,jn=jn+_i|0,Xr^=jn,Xr=Xr>>>24|Xr<<8,so=so+Xr|0,_i^=so,_i=_i>>>25|_i<<7,jn=jn+oo|0,Pn^=jn,Pn=Pn>>>16|Pn<<16,Tn=Tn+Pn|0,oo^=Tn,oo=oo>>>20|oo<<12,eo=eo+io|0,Xr^=eo,Xr=Xr>>>16|Xr<<16,Gr=Gr+Xr|0,io^=Gr,io=io>>>20|io<<12,ro=ro+co|0,Sn^=ro,Sn=Sn>>>16|Sn<<16,so=so+Sn|0,co^=so,co=co>>>20|co<<12,to=to+_i|0,Rn^=to,Rn=Rn>>>16|Rn<<16,no=no+Rn|0,_i^=no,_i=_i>>>20|_i<<12,ro=ro+co|0,Sn^=ro,Sn=Sn>>>24|Sn<<8,so=so+Sn|0,co^=so,co=co>>>25|co<<7,to=to+_i|0,Rn^=to,Rn=Rn>>>24|Rn<<8,no=no+Rn|0,_i^=no,_i=_i>>>25|_i<<7,eo=eo+io|0,Xr^=eo,Xr=Xr>>>24|Xr<<8,Gr=Gr+Xr|0,io^=Gr,io=io>>>25|io<<7,jn=jn+oo|0,Pn^=jn,Pn=Pn>>>24|Pn<<8,Tn=Tn+Pn|0,oo^=Tn,oo=oo>>>25|oo<<7;binary_1.writeUint32LE(jn+Er|0,fr,0),binary_1.writeUint32LE(eo+kr|0,fr,4),binary_1.writeUint32LE(ro+jr|0,fr,8),binary_1.writeUint32LE(to+Br|0,fr,12),binary_1.writeUint32LE(_i+Wr|0,fr,16),binary_1.writeUint32LE(oo+qr|0,fr,20),binary_1.writeUint32LE(io+Hr|0,fr,24),binary_1.writeUint32LE(co+Vr|0,fr,28),binary_1.writeUint32LE(so+Zr|0,fr,32),binary_1.writeUint32LE(no+Jr|0,fr,36),binary_1.writeUint32LE(Tn+Qr|0,fr,40),binary_1.writeUint32LE(Gr+_n|0,fr,44),binary_1.writeUint32LE(Xr+En|0,fr,48),binary_1.writeUint32LE(Sn+Cn|0,fr,52),binary_1.writeUint32LE(Rn+In|0,fr,56),binary_1.writeUint32LE(Pn+An|0,fr,60)}function streamXOR(fr,br,wr,Er,kr){if(kr===void 0&&(kr=0),fr.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(Er.length>>=8,br++;if(Er>0)throw new Error("ChaCha: counter overflow")}var poly1305={},constantTime={};Object.defineProperty(constantTime,"__esModule",{value:!0});function select(fr,br,wr){return~(fr-1)&br|fr-1&wr}constantTime.select=select;function lessOrEqual(fr,br){return(fr|0)-(br|0)-1>>>31&1}constantTime.lessOrEqual=lessOrEqual;function compare(fr,br){if(fr.length!==br.length)return 0;for(var wr=0,Er=0;Er>>8}constantTime.compare=compare;function equal(fr,br){return fr.length===0||br.length===0?!1:compare(fr,br)!==0}constantTime.equal=equal;(function(fr){Object.defineProperty(fr,"__esModule",{value:!0});var br=constantTime,wr=wipe$1;fr.DIGEST_LENGTH=16;var Er=function(){function Br(Wr){this.digestLength=fr.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var qr=Wr[0]|Wr[1]<<8;this._r[0]=qr&8191;var Hr=Wr[2]|Wr[3]<<8;this._r[1]=(qr>>>13|Hr<<3)&8191;var Vr=Wr[4]|Wr[5]<<8;this._r[2]=(Hr>>>10|Vr<<6)&7939;var Zr=Wr[6]|Wr[7]<<8;this._r[3]=(Vr>>>7|Zr<<9)&8191;var Jr=Wr[8]|Wr[9]<<8;this._r[4]=(Zr>>>4|Jr<<12)&255,this._r[5]=Jr>>>1&8190;var Qr=Wr[10]|Wr[11]<<8;this._r[6]=(Jr>>>14|Qr<<2)&8191;var _n=Wr[12]|Wr[13]<<8;this._r[7]=(Qr>>>11|_n<<5)&8065;var En=Wr[14]|Wr[15]<<8;this._r[8]=(_n>>>8|En<<8)&8191,this._r[9]=En>>>5&127,this._pad[0]=Wr[16]|Wr[17]<<8,this._pad[1]=Wr[18]|Wr[19]<<8,this._pad[2]=Wr[20]|Wr[21]<<8,this._pad[3]=Wr[22]|Wr[23]<<8,this._pad[4]=Wr[24]|Wr[25]<<8,this._pad[5]=Wr[26]|Wr[27]<<8,this._pad[6]=Wr[28]|Wr[29]<<8,this._pad[7]=Wr[30]|Wr[31]<<8}return Br.prototype._blocks=function(Wr,qr,Hr){for(var Vr=this._fin?0:2048,Zr=this._h[0],Jr=this._h[1],Qr=this._h[2],_n=this._h[3],En=this._h[4],Cn=this._h[5],In=this._h[6],An=this._h[7],jn=this._h[8],eo=this._h[9],ro=this._r[0],to=this._r[1],_i=this._r[2],oo=this._r[3],io=this._r[4],co=this._r[5],so=this._r[6],no=this._r[7],Tn=this._r[8],Gr=this._r[9];Hr>=16;){var Xr=Wr[qr+0]|Wr[qr+1]<<8;Zr+=Xr&8191;var Sn=Wr[qr+2]|Wr[qr+3]<<8;Jr+=(Xr>>>13|Sn<<3)&8191;var Rn=Wr[qr+4]|Wr[qr+5]<<8;Qr+=(Sn>>>10|Rn<<6)&8191;var Pn=Wr[qr+6]|Wr[qr+7]<<8;_n+=(Rn>>>7|Pn<<9)&8191;var On=Wr[qr+8]|Wr[qr+9]<<8;En+=(Pn>>>4|On<<12)&8191,Cn+=On>>>1&8191;var Zn=Wr[qr+10]|Wr[qr+11]<<8;In+=(On>>>14|Zn<<2)&8191;var Nn=Wr[qr+12]|Wr[qr+13]<<8;An+=(Zn>>>11|Nn<<5)&8191;var wn=Wr[qr+14]|Wr[qr+15]<<8;jn+=(Nn>>>8|wn<<8)&8191,eo+=wn>>>5|Vr;var zn=0,fo=zn;fo+=Zr*ro,fo+=Jr*(5*Gr),fo+=Qr*(5*Tn),fo+=_n*(5*no),fo+=En*(5*so),zn=fo>>>13,fo&=8191,fo+=Cn*(5*co),fo+=In*(5*io),fo+=An*(5*oo),fo+=jn*(5*_i),fo+=eo*(5*to),zn+=fo>>>13,fo&=8191;var vo=zn;vo+=Zr*to,vo+=Jr*ro,vo+=Qr*(5*Gr),vo+=_n*(5*Tn),vo+=En*(5*no),zn=vo>>>13,vo&=8191,vo+=Cn*(5*so),vo+=In*(5*co),vo+=An*(5*io),vo+=jn*(5*oo),vo+=eo*(5*_i),zn+=vo>>>13,vo&=8191;var go=zn;go+=Zr*_i,go+=Jr*to,go+=Qr*ro,go+=_n*(5*Gr),go+=En*(5*Tn),zn=go>>>13,go&=8191,go+=Cn*(5*no),go+=In*(5*so),go+=An*(5*co),go+=jn*(5*io),go+=eo*(5*oo),zn+=go>>>13,go&=8191;var uo=zn;uo+=Zr*oo,uo+=Jr*_i,uo+=Qr*to,uo+=_n*ro,uo+=En*(5*Gr),zn=uo>>>13,uo&=8191,uo+=Cn*(5*Tn),uo+=In*(5*no),uo+=An*(5*so),uo+=jn*(5*co),uo+=eo*(5*io),zn+=uo>>>13,uo&=8191;var lo=zn;lo+=Zr*io,lo+=Jr*oo,lo+=Qr*_i,lo+=_n*to,lo+=En*ro,zn=lo>>>13,lo&=8191,lo+=Cn*(5*Gr),lo+=In*(5*Tn),lo+=An*(5*no),lo+=jn*(5*so),lo+=eo*(5*co),zn+=lo>>>13,lo&=8191;var Eo=zn;Eo+=Zr*co,Eo+=Jr*io,Eo+=Qr*oo,Eo+=_n*_i,Eo+=En*to,zn=Eo>>>13,Eo&=8191,Eo+=Cn*ro,Eo+=In*(5*Gr),Eo+=An*(5*Tn),Eo+=jn*(5*no),Eo+=eo*(5*so),zn+=Eo>>>13,Eo&=8191;var mo=zn;mo+=Zr*so,mo+=Jr*co,mo+=Qr*io,mo+=_n*oo,mo+=En*_i,zn=mo>>>13,mo&=8191,mo+=Cn*to,mo+=In*ro,mo+=An*(5*Gr),mo+=jn*(5*Tn),mo+=eo*(5*no),zn+=mo>>>13,mo&=8191;var yo=zn;yo+=Zr*no,yo+=Jr*so,yo+=Qr*co,yo+=_n*io,yo+=En*oo,zn=yo>>>13,yo&=8191,yo+=Cn*_i,yo+=In*to,yo+=An*ro,yo+=jn*(5*Gr),yo+=eo*(5*Tn),zn+=yo>>>13,yo&=8191;var _o=zn;_o+=Zr*Tn,_o+=Jr*no,_o+=Qr*so,_o+=_n*co,_o+=En*io,zn=_o>>>13,_o&=8191,_o+=Cn*oo,_o+=In*_i,_o+=An*to,_o+=jn*ro,_o+=eo*(5*Gr),zn+=_o>>>13,_o&=8191;var Bo=zn;Bo+=Zr*Gr,Bo+=Jr*Tn,Bo+=Qr*no,Bo+=_n*so,Bo+=En*co,zn=Bo>>>13,Bo&=8191,Bo+=Cn*io,Bo+=In*oo,Bo+=An*_i,Bo+=jn*to,Bo+=eo*ro,zn+=Bo>>>13,Bo&=8191,zn=(zn<<2)+zn|0,zn=zn+fo|0,fo=zn&8191,zn=zn>>>13,vo+=zn,Zr=fo,Jr=vo,Qr=go,_n=uo,En=lo,Cn=Eo,In=mo,An=yo,jn=_o,eo=Bo,qr+=16,Hr-=16}this._h[0]=Zr,this._h[1]=Jr,this._h[2]=Qr,this._h[3]=_n,this._h[4]=En,this._h[5]=Cn,this._h[6]=In,this._h[7]=An,this._h[8]=jn,this._h[9]=eo},Br.prototype.finish=function(Wr,qr){qr===void 0&&(qr=0);var Hr=new Uint16Array(10),Vr,Zr,Jr,Qr;if(this._leftover){for(Qr=this._leftover,this._buffer[Qr++]=1;Qr<16;Qr++)this._buffer[Qr]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(Vr=this._h[1]>>>13,this._h[1]&=8191,Qr=2;Qr<10;Qr++)this._h[Qr]+=Vr,Vr=this._h[Qr]>>>13,this._h[Qr]&=8191;for(this._h[0]+=Vr*5,Vr=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=Vr,Vr=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=Vr,Hr[0]=this._h[0]+5,Vr=Hr[0]>>>13,Hr[0]&=8191,Qr=1;Qr<10;Qr++)Hr[Qr]=this._h[Qr]+Vr,Vr=Hr[Qr]>>>13,Hr[Qr]&=8191;for(Hr[9]-=8192,Zr=(Vr^1)-1,Qr=0;Qr<10;Qr++)Hr[Qr]&=Zr;for(Zr=~Zr,Qr=0;Qr<10;Qr++)this._h[Qr]=this._h[Qr]&Zr|Hr[Qr];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,Jr=this._h[0]+this._pad[0],this._h[0]=Jr&65535,Qr=1;Qr<8;Qr++)Jr=(this._h[Qr]+this._pad[Qr]|0)+(Jr>>>16)|0,this._h[Qr]=Jr&65535;return Wr[qr+0]=this._h[0]>>>0,Wr[qr+1]=this._h[0]>>>8,Wr[qr+2]=this._h[1]>>>0,Wr[qr+3]=this._h[1]>>>8,Wr[qr+4]=this._h[2]>>>0,Wr[qr+5]=this._h[2]>>>8,Wr[qr+6]=this._h[3]>>>0,Wr[qr+7]=this._h[3]>>>8,Wr[qr+8]=this._h[4]>>>0,Wr[qr+9]=this._h[4]>>>8,Wr[qr+10]=this._h[5]>>>0,Wr[qr+11]=this._h[5]>>>8,Wr[qr+12]=this._h[6]>>>0,Wr[qr+13]=this._h[6]>>>8,Wr[qr+14]=this._h[7]>>>0,Wr[qr+15]=this._h[7]>>>8,this._finished=!0,this},Br.prototype.update=function(Wr){var qr=0,Hr=Wr.length,Vr;if(this._leftover){Vr=16-this._leftover,Vr>Hr&&(Vr=Hr);for(var Zr=0;Zr=16&&(Vr=Hr-Hr%16,this._blocks(Wr,qr,Vr),qr+=Vr,Hr-=Vr),Hr){for(var Zr=0;Zr16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var Qr=new Uint8Array(16);Qr.set(Hr,Qr.length-Hr.length);var _n=new Uint8Array(32);br.stream(this._key,Qr,_n,4);var En=Vr.length+this.tagLength,Cn;if(Jr){if(Jr.length!==En)throw new Error("ChaCha20Poly1305: incorrect destination length");Cn=Jr}else Cn=new Uint8Array(En);return br.streamXOR(this._key,Qr,Vr,Cn,4),this._authenticate(Cn.subarray(Cn.length-this.tagLength,Cn.length),_n,Cn.subarray(0,Cn.length-this.tagLength),Zr),Er.wipe(Qr),Cn},qr.prototype.open=function(Hr,Vr,Zr,Jr){if(Hr.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(Vr.length0&&Qr.update(Br.subarray(Jr.length%16))),Qr.update(Zr),Zr.length%16>0&&Qr.update(Br.subarray(Zr.length%16));var _n=new Uint8Array(8);Jr&&kr.writeUint64LE(Jr.length,_n),Qr.update(_n),kr.writeUint64LE(Zr.length,_n),Qr.update(_n);for(var En=Qr.digest(),Cn=0;Cnthis.blockSize?this._inner.update(wr).finish(Er).clean():Er.set(wr);for(var kr=0;kr1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},fr.prototype.expand=function(br){for(var wr=new Uint8Array(br),Er=0;Er256)throw new Error("randomString charset is too long");let Jr="";const Qr=Vr.length,_n=256-256%Qr;for(;Hr>0;){const En=kr(Math.ceil(Hr*256/_n),Zr);for(let Cn=0;Cn0;Cn++){const In=En[Cn];In<_n&&(Jr+=Vr.charAt(In%Qr),Hr--)}(0,Er.wipe)(En)}return Jr}fr.randomString=Wr;function qr(Hr,Vr=Br,Zr=fr.defaultRandomSource){const Jr=Math.ceil(Hr/(Math.log(Vr.length)/Math.LN2));return Wr(Jr,Vr,Zr)}fr.randomStringForEntropy=qr})(random);var sha256={};(function(fr){Object.defineProperty(fr,"__esModule",{value:!0});var br=binary,wr=wipe$1;fr.DIGEST_LENGTH=32,fr.BLOCK_SIZE=64;var Er=function(){function Wr(){this.digestLength=fr.DIGEST_LENGTH,this.blockSize=fr.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return Wr.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},Wr.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},Wr.prototype.clean=function(){wr.wipe(this._buffer),wr.wipe(this._temp),this.reset()},Wr.prototype.update=function(qr,Hr){if(Hr===void 0&&(Hr=qr.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var Vr=0;if(this._bytesHashed+=Hr,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=qr[Vr++],Hr--;this._bufferLength===this.blockSize&&(jr(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(Hr>=this.blockSize&&(Vr=jr(this._temp,this._state,qr,Vr,Hr),Hr%=this.blockSize);Hr>0;)this._buffer[this._bufferLength++]=qr[Vr++],Hr--;return this},Wr.prototype.finish=function(qr){if(!this._finished){var Hr=this._bytesHashed,Vr=this._bufferLength,Zr=Hr/536870912|0,Jr=Hr<<3,Qr=Hr%64<56?64:128;this._buffer[Vr]=128;for(var _n=Vr+1;_n0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},Wr.prototype.restoreState=function(qr){return this._state.set(qr.state),this._bufferLength=qr.bufferLength,qr.buffer&&this._buffer.set(qr.buffer),this._bytesHashed=qr.bytesHashed,this._finished=!1,this},Wr.prototype.cleanSavedState=function(qr){wr.wipe(qr.state),qr.buffer&&wr.wipe(qr.buffer),qr.bufferLength=0,qr.bytesHashed=0},Wr}();fr.SHA256=Er;var kr=new Int32Array([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]);function jr(Wr,qr,Hr,Vr,Zr){for(;Zr>=64;){for(var Jr=qr[0],Qr=qr[1],_n=qr[2],En=qr[3],Cn=qr[4],In=qr[5],An=qr[6],jn=qr[7],eo=0;eo<16;eo++){var ro=Vr+eo*4;Wr[eo]=br.readUint32BE(Hr,ro)}for(var eo=16;eo<64;eo++){var to=Wr[eo-2],_i=(to>>>17|to<<15)^(to>>>19|to<<13)^to>>>10;to=Wr[eo-15];var oo=(to>>>7|to<<25)^(to>>>18|to<<14)^to>>>3;Wr[eo]=(_i+Wr[eo-7]|0)+(oo+Wr[eo-16]|0)}for(var eo=0;eo<64;eo++){var _i=(((Cn>>>6|Cn<<26)^(Cn>>>11|Cn<<21)^(Cn>>>25|Cn<<7))+(Cn&In^~Cn&An)|0)+(jn+(kr[eo]+Wr[eo]|0)|0)|0,oo=((Jr>>>2|Jr<<30)^(Jr>>>13|Jr<<19)^(Jr>>>22|Jr<<10))+(Jr&Qr^Jr&_n^Qr&_n)|0;jn=An,An=In,In=Cn,Cn=En+_i|0,En=_n,_n=Qr,Qr=Jr,Jr=_i+oo|0}qr[0]+=Jr,qr[1]+=Qr,qr[2]+=_n,qr[3]+=En,qr[4]+=Cn,qr[5]+=In,qr[6]+=An,qr[7]+=jn,Vr+=64,Zr-=64}return Vr}function Br(Wr){var qr=new Er;qr.update(Wr);var Hr=qr.digest();return qr.clean(),Hr}fr.hash=Br})(sha256);var x25519={};(function(fr){Object.defineProperty(fr,"__esModule",{value:!0}),fr.sharedKey=fr.generateKeyPair=fr.generateKeyPairFromSeed=fr.scalarMultBase=fr.scalarMult=fr.SHARED_KEY_LENGTH=fr.SECRET_KEY_LENGTH=fr.PUBLIC_KEY_LENGTH=void 0;const br=random,wr=wipe$1;fr.PUBLIC_KEY_LENGTH=32,fr.SECRET_KEY_LENGTH=32,fr.SHARED_KEY_LENGTH=32;function Er(eo){const ro=new Float64Array(16);if(eo)for(let to=0;to>16&1),to[co-1]&=65535;to[15]=_i[15]-32767-(to[14]>>16&1);const io=to[15]>>16&1;to[14]&=65535,Wr(_i,to,1-io)}for(let oo=0;oo<16;oo++)eo[2*oo]=_i[oo]&255,eo[2*oo+1]=_i[oo]>>8}function Hr(eo,ro){for(let to=0;to<16;to++)eo[to]=ro[2*to]+(ro[2*to+1]<<8);eo[15]&=32767}function Vr(eo,ro,to){for(let _i=0;_i<16;_i++)eo[_i]=ro[_i]+to[_i]}function Zr(eo,ro,to){for(let _i=0;_i<16;_i++)eo[_i]=ro[_i]-to[_i]}function Jr(eo,ro,to){let _i,oo,io=0,co=0,so=0,no=0,Tn=0,Gr=0,Xr=0,Sn=0,Rn=0,Pn=0,On=0,Zn=0,Nn=0,wn=0,zn=0,fo=0,vo=0,go=0,uo=0,lo=0,Eo=0,mo=0,yo=0,_o=0,Bo=0,Lo=0,Wo=0,na=0,qo=0,ga=0,wl=0,No=to[0],Fo=to[1],Nl=to[2],Vo=to[3],Uo=to[4],Ol=to[5],$a=to[6],Jo=to[7],Zl=to[8],Cl=to[9],ko=to[10],wo=to[11],bo=to[12],Io=to[13],Ho=to[14],Do=to[15];_i=ro[0],io+=_i*No,co+=_i*Fo,so+=_i*Nl,no+=_i*Vo,Tn+=_i*Uo,Gr+=_i*Ol,Xr+=_i*$a,Sn+=_i*Jo,Rn+=_i*Zl,Pn+=_i*Cl,On+=_i*ko,Zn+=_i*wo,Nn+=_i*bo,wn+=_i*Io,zn+=_i*Ho,fo+=_i*Do,_i=ro[1],co+=_i*No,so+=_i*Fo,no+=_i*Nl,Tn+=_i*Vo,Gr+=_i*Uo,Xr+=_i*Ol,Sn+=_i*$a,Rn+=_i*Jo,Pn+=_i*Zl,On+=_i*Cl,Zn+=_i*ko,Nn+=_i*wo,wn+=_i*bo,zn+=_i*Io,fo+=_i*Ho,vo+=_i*Do,_i=ro[2],so+=_i*No,no+=_i*Fo,Tn+=_i*Nl,Gr+=_i*Vo,Xr+=_i*Uo,Sn+=_i*Ol,Rn+=_i*$a,Pn+=_i*Jo,On+=_i*Zl,Zn+=_i*Cl,Nn+=_i*ko,wn+=_i*wo,zn+=_i*bo,fo+=_i*Io,vo+=_i*Ho,go+=_i*Do,_i=ro[3],no+=_i*No,Tn+=_i*Fo,Gr+=_i*Nl,Xr+=_i*Vo,Sn+=_i*Uo,Rn+=_i*Ol,Pn+=_i*$a,On+=_i*Jo,Zn+=_i*Zl,Nn+=_i*Cl,wn+=_i*ko,zn+=_i*wo,fo+=_i*bo,vo+=_i*Io,go+=_i*Ho,uo+=_i*Do,_i=ro[4],Tn+=_i*No,Gr+=_i*Fo,Xr+=_i*Nl,Sn+=_i*Vo,Rn+=_i*Uo,Pn+=_i*Ol,On+=_i*$a,Zn+=_i*Jo,Nn+=_i*Zl,wn+=_i*Cl,zn+=_i*ko,fo+=_i*wo,vo+=_i*bo,go+=_i*Io,uo+=_i*Ho,lo+=_i*Do,_i=ro[5],Gr+=_i*No,Xr+=_i*Fo,Sn+=_i*Nl,Rn+=_i*Vo,Pn+=_i*Uo,On+=_i*Ol,Zn+=_i*$a,Nn+=_i*Jo,wn+=_i*Zl,zn+=_i*Cl,fo+=_i*ko,vo+=_i*wo,go+=_i*bo,uo+=_i*Io,lo+=_i*Ho,Eo+=_i*Do,_i=ro[6],Xr+=_i*No,Sn+=_i*Fo,Rn+=_i*Nl,Pn+=_i*Vo,On+=_i*Uo,Zn+=_i*Ol,Nn+=_i*$a,wn+=_i*Jo,zn+=_i*Zl,fo+=_i*Cl,vo+=_i*ko,go+=_i*wo,uo+=_i*bo,lo+=_i*Io,Eo+=_i*Ho,mo+=_i*Do,_i=ro[7],Sn+=_i*No,Rn+=_i*Fo,Pn+=_i*Nl,On+=_i*Vo,Zn+=_i*Uo,Nn+=_i*Ol,wn+=_i*$a,zn+=_i*Jo,fo+=_i*Zl,vo+=_i*Cl,go+=_i*ko,uo+=_i*wo,lo+=_i*bo,Eo+=_i*Io,mo+=_i*Ho,yo+=_i*Do,_i=ro[8],Rn+=_i*No,Pn+=_i*Fo,On+=_i*Nl,Zn+=_i*Vo,Nn+=_i*Uo,wn+=_i*Ol,zn+=_i*$a,fo+=_i*Jo,vo+=_i*Zl,go+=_i*Cl,uo+=_i*ko,lo+=_i*wo,Eo+=_i*bo,mo+=_i*Io,yo+=_i*Ho,_o+=_i*Do,_i=ro[9],Pn+=_i*No,On+=_i*Fo,Zn+=_i*Nl,Nn+=_i*Vo,wn+=_i*Uo,zn+=_i*Ol,fo+=_i*$a,vo+=_i*Jo,go+=_i*Zl,uo+=_i*Cl,lo+=_i*ko,Eo+=_i*wo,mo+=_i*bo,yo+=_i*Io,_o+=_i*Ho,Bo+=_i*Do,_i=ro[10],On+=_i*No,Zn+=_i*Fo,Nn+=_i*Nl,wn+=_i*Vo,zn+=_i*Uo,fo+=_i*Ol,vo+=_i*$a,go+=_i*Jo,uo+=_i*Zl,lo+=_i*Cl,Eo+=_i*ko,mo+=_i*wo,yo+=_i*bo,_o+=_i*Io,Bo+=_i*Ho,Lo+=_i*Do,_i=ro[11],Zn+=_i*No,Nn+=_i*Fo,wn+=_i*Nl,zn+=_i*Vo,fo+=_i*Uo,vo+=_i*Ol,go+=_i*$a,uo+=_i*Jo,lo+=_i*Zl,Eo+=_i*Cl,mo+=_i*ko,yo+=_i*wo,_o+=_i*bo,Bo+=_i*Io,Lo+=_i*Ho,Wo+=_i*Do,_i=ro[12],Nn+=_i*No,wn+=_i*Fo,zn+=_i*Nl,fo+=_i*Vo,vo+=_i*Uo,go+=_i*Ol,uo+=_i*$a,lo+=_i*Jo,Eo+=_i*Zl,mo+=_i*Cl,yo+=_i*ko,_o+=_i*wo,Bo+=_i*bo,Lo+=_i*Io,Wo+=_i*Ho,na+=_i*Do,_i=ro[13],wn+=_i*No,zn+=_i*Fo,fo+=_i*Nl,vo+=_i*Vo,go+=_i*Uo,uo+=_i*Ol,lo+=_i*$a,Eo+=_i*Jo,mo+=_i*Zl,yo+=_i*Cl,_o+=_i*ko,Bo+=_i*wo,Lo+=_i*bo,Wo+=_i*Io,na+=_i*Ho,qo+=_i*Do,_i=ro[14],zn+=_i*No,fo+=_i*Fo,vo+=_i*Nl,go+=_i*Vo,uo+=_i*Uo,lo+=_i*Ol,Eo+=_i*$a,mo+=_i*Jo,yo+=_i*Zl,_o+=_i*Cl,Bo+=_i*ko,Lo+=_i*wo,Wo+=_i*bo,na+=_i*Io,qo+=_i*Ho,ga+=_i*Do,_i=ro[15],fo+=_i*No,vo+=_i*Fo,go+=_i*Nl,uo+=_i*Vo,lo+=_i*Uo,Eo+=_i*Ol,mo+=_i*$a,yo+=_i*Jo,_o+=_i*Zl,Bo+=_i*Cl,Lo+=_i*ko,Wo+=_i*wo,na+=_i*bo,qo+=_i*Io,ga+=_i*Ho,wl+=_i*Do,io+=38*vo,co+=38*go,so+=38*uo,no+=38*lo,Tn+=38*Eo,Gr+=38*mo,Xr+=38*yo,Sn+=38*_o,Rn+=38*Bo,Pn+=38*Lo,On+=38*Wo,Zn+=38*na,Nn+=38*qo,wn+=38*ga,zn+=38*wl,oo=1,_i=io+oo+65535,oo=Math.floor(_i/65536),io=_i-oo*65536,_i=co+oo+65535,oo=Math.floor(_i/65536),co=_i-oo*65536,_i=so+oo+65535,oo=Math.floor(_i/65536),so=_i-oo*65536,_i=no+oo+65535,oo=Math.floor(_i/65536),no=_i-oo*65536,_i=Tn+oo+65535,oo=Math.floor(_i/65536),Tn=_i-oo*65536,_i=Gr+oo+65535,oo=Math.floor(_i/65536),Gr=_i-oo*65536,_i=Xr+oo+65535,oo=Math.floor(_i/65536),Xr=_i-oo*65536,_i=Sn+oo+65535,oo=Math.floor(_i/65536),Sn=_i-oo*65536,_i=Rn+oo+65535,oo=Math.floor(_i/65536),Rn=_i-oo*65536,_i=Pn+oo+65535,oo=Math.floor(_i/65536),Pn=_i-oo*65536,_i=On+oo+65535,oo=Math.floor(_i/65536),On=_i-oo*65536,_i=Zn+oo+65535,oo=Math.floor(_i/65536),Zn=_i-oo*65536,_i=Nn+oo+65535,oo=Math.floor(_i/65536),Nn=_i-oo*65536,_i=wn+oo+65535,oo=Math.floor(_i/65536),wn=_i-oo*65536,_i=zn+oo+65535,oo=Math.floor(_i/65536),zn=_i-oo*65536,_i=fo+oo+65535,oo=Math.floor(_i/65536),fo=_i-oo*65536,io+=oo-1+37*(oo-1),oo=1,_i=io+oo+65535,oo=Math.floor(_i/65536),io=_i-oo*65536,_i=co+oo+65535,oo=Math.floor(_i/65536),co=_i-oo*65536,_i=so+oo+65535,oo=Math.floor(_i/65536),so=_i-oo*65536,_i=no+oo+65535,oo=Math.floor(_i/65536),no=_i-oo*65536,_i=Tn+oo+65535,oo=Math.floor(_i/65536),Tn=_i-oo*65536,_i=Gr+oo+65535,oo=Math.floor(_i/65536),Gr=_i-oo*65536,_i=Xr+oo+65535,oo=Math.floor(_i/65536),Xr=_i-oo*65536,_i=Sn+oo+65535,oo=Math.floor(_i/65536),Sn=_i-oo*65536,_i=Rn+oo+65535,oo=Math.floor(_i/65536),Rn=_i-oo*65536,_i=Pn+oo+65535,oo=Math.floor(_i/65536),Pn=_i-oo*65536,_i=On+oo+65535,oo=Math.floor(_i/65536),On=_i-oo*65536,_i=Zn+oo+65535,oo=Math.floor(_i/65536),Zn=_i-oo*65536,_i=Nn+oo+65535,oo=Math.floor(_i/65536),Nn=_i-oo*65536,_i=wn+oo+65535,oo=Math.floor(_i/65536),wn=_i-oo*65536,_i=zn+oo+65535,oo=Math.floor(_i/65536),zn=_i-oo*65536,_i=fo+oo+65535,oo=Math.floor(_i/65536),fo=_i-oo*65536,io+=oo-1+37*(oo-1),eo[0]=io,eo[1]=co,eo[2]=so,eo[3]=no,eo[4]=Tn,eo[5]=Gr,eo[6]=Xr,eo[7]=Sn,eo[8]=Rn,eo[9]=Pn,eo[10]=On,eo[11]=Zn,eo[12]=Nn,eo[13]=wn,eo[14]=zn,eo[15]=fo}function Qr(eo,ro){Jr(eo,ro,ro)}function _n(eo,ro){const to=Er();for(let _i=0;_i<16;_i++)to[_i]=ro[_i];for(let _i=253;_i>=0;_i--)Qr(to,to),_i!==2&&_i!==4&&Jr(to,to,ro);for(let _i=0;_i<16;_i++)eo[_i]=to[_i]}function En(eo,ro){const to=new Uint8Array(32),_i=new Float64Array(80),oo=Er(),io=Er(),co=Er(),so=Er(),no=Er(),Tn=Er();for(let Rn=0;Rn<31;Rn++)to[Rn]=eo[Rn];to[31]=eo[31]&127|64,to[0]&=248,Hr(_i,ro);for(let Rn=0;Rn<16;Rn++)io[Rn]=_i[Rn];oo[0]=so[0]=1;for(let Rn=254;Rn>=0;--Rn){const Pn=to[Rn>>>3]>>>(Rn&7)&1;Wr(oo,io,Pn),Wr(co,so,Pn),Vr(no,oo,co),Zr(oo,oo,co),Vr(co,io,so),Zr(io,io,so),Qr(so,no),Qr(Tn,oo),Jr(oo,co,oo),Jr(co,io,no),Vr(no,oo,co),Zr(oo,oo,co),Qr(io,oo),Zr(co,so,Tn),Jr(oo,co,jr),Vr(oo,oo,so),Jr(co,co,oo),Jr(oo,so,Tn),Jr(so,io,_i),Qr(io,no),Wr(oo,io,Pn),Wr(co,so,Pn)}for(let Rn=0;Rn<16;Rn++)_i[Rn+16]=oo[Rn],_i[Rn+32]=co[Rn],_i[Rn+48]=io[Rn],_i[Rn+64]=so[Rn];const Gr=_i.subarray(32),Xr=_i.subarray(16);_n(Gr,Gr),Jr(Xr,Xr,Gr);const Sn=new Uint8Array(32);return qr(Sn,Xr),Sn}fr.scalarMult=En;function Cn(eo){return En(eo,kr)}fr.scalarMultBase=Cn;function In(eo){if(eo.length!==fr.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${fr.SECRET_KEY_LENGTH} bytes`);const ro=new Uint8Array(eo);return{publicKey:Cn(ro),secretKey:ro}}fr.generateKeyPairFromSeed=In;function An(eo){const ro=(0,br.randomBytes)(32,eo),to=In(ro);return(0,wr.wipe)(ro),to}fr.generateKeyPair=An;function jn(eo,ro,to=!1){if(eo.length!==fr.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(ro.length!==fr.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const _i=En(eo,ro);if(to){let oo=0;for(let io=0;io<_i.length;io++)oo|=_i[io];if(oo===0)throw new Error("X25519: invalid shared key")}return _i}fr.sharedKey=jn})(x25519);function asUint8Array(fr){return globalThis.Buffer!=null?new Uint8Array(fr.buffer,fr.byteOffset,fr.byteLength):fr}function allocUnsafe(fr=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?asUint8Array(globalThis.Buffer.allocUnsafe(fr)):new Uint8Array(fr)}function concat(fr,br){br||(br=fr.reduce((kr,jr)=>kr+jr.length,0));const wr=allocUnsafe(br);let Er=0;for(const kr of fr)wr.set(kr,Er),Er+=kr.length;return asUint8Array(wr)}function base$4(fr,br){if(fr.length>=255)throw new TypeError("Alphabet too long");for(var wr=new Uint8Array(256),Er=0;Er>>0,eo=new Uint8Array(jn);In!==An;){for(var ro=_n[In],to=0,_i=jn-1;(ro!==0||to>>0,eo[_i]=ro%Wr>>>0,ro=ro/Wr>>>0;if(ro!==0)throw new Error("Non-zero carry");Cn=to,In++}for(var oo=jn-Cn;oo!==jn&&eo[oo]===0;)oo++;for(var io=qr.repeat(En);oo>>0,jn=new Uint8Array(An);_n[En];){var eo=wr[_n.charCodeAt(En)];if(eo===255)return;for(var ro=0,to=An-1;(eo!==0||ro>>0,jn[to]=eo%256>>>0,eo=eo/256>>>0;if(eo!==0)throw new Error("Non-zero carry");In=ro,En++}if(_n[En]!==" "){for(var _i=An-In;_i!==An&&jn[_i]===0;)_i++;for(var oo=new Uint8Array(Cn+(An-_i)),io=Cn;_i!==An;)oo[io++]=jn[_i++];return oo}}}function Qr(_n){var En=Jr(_n);if(En)return En;throw new Error(`Non-${br} character`)}return{encode:Zr,decodeUnsafe:Jr,decode:Qr}}var src$4=base$4,_brrp__multiformats_scope_baseX=src$4;const coerce$3=fr=>{if(fr instanceof Uint8Array&&fr.constructor.name==="Uint8Array")return fr;if(fr instanceof ArrayBuffer)return new Uint8Array(fr);if(ArrayBuffer.isView(fr))return new Uint8Array(fr.buffer,fr.byteOffset,fr.byteLength);throw new Error("Unknown type, must be binary type")},fromString$1=fr=>new TextEncoder().encode(fr),toString$1=fr=>new TextDecoder().decode(fr);class Encoder{constructor(br,wr,Er){this.name=br,this.prefix=wr,this.baseEncode=Er}encode(br){if(br instanceof Uint8Array)return`${this.prefix}${this.baseEncode(br)}`;throw Error("Unknown type, must be binary type")}}class Decoder{constructor(br,wr,Er){if(this.name=br,this.prefix=wr,wr.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=wr.codePointAt(0),this.baseDecode=Er}decode(br){if(typeof br=="string"){if(br.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(br)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(br.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(br){return or$2(this,br)}}class ComposedDecoder{constructor(br){this.decoders=br}or(br){return or$2(this,br)}decode(br){const wr=br[0],Er=this.decoders[wr];if(Er)return Er.decode(br);throw RangeError(`Unable to decode multibase string ${JSON.stringify(br)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const or$2=(fr,br)=>new ComposedDecoder({...fr.decoders||{[fr.prefix]:fr},...br.decoders||{[br.prefix]:br}});class Codec{constructor(br,wr,Er,kr){this.name=br,this.prefix=wr,this.baseEncode=Er,this.baseDecode=kr,this.encoder=new Encoder(br,wr,Er),this.decoder=new Decoder(br,wr,kr)}encode(br){return this.encoder.encode(br)}decode(br){return this.decoder.decode(br)}}const from=({name:fr,prefix:br,encode:wr,decode:Er})=>new Codec(fr,br,wr,Er),baseX=({prefix:fr,name:br,alphabet:wr})=>{const{encode:Er,decode:kr}=_brrp__multiformats_scope_baseX(wr,br);return from({prefix:fr,name:br,encode:Er,decode:jr=>coerce$3(kr(jr))})},decode$2=(fr,br,wr,Er)=>{const kr={};for(let Vr=0;Vr=8&&(Wr-=8,Br[Hr++]=255&qr>>Wr)}if(Wr>=wr||255&qr<<8-Wr)throw new SyntaxError("Unexpected end of data");return Br},encode$1=(fr,br,wr)=>{const Er=br[br.length-1]==="=",kr=(1<wr;)Br-=wr,jr+=br[kr&Wr>>Br];if(Br&&(jr+=br[kr&Wr<from({prefix:br,name:fr,encode(kr){return encode$1(kr,Er,wr)},decode(kr){return decode$2(kr,Er,wr,fr)}}),identity=from({prefix:"\0",name:"identity",encode:fr=>toString$1(fr),decode:fr=>fromString$1(fr)}),identityBase=Object.freeze(Object.defineProperty({__proto__:null,identity},Symbol.toStringTag,{value:"Module"})),base2=rfc4648({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),base2$1=Object.freeze(Object.defineProperty({__proto__:null,base2},Symbol.toStringTag,{value:"Module"})),base8=rfc4648({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$1=Object.freeze(Object.defineProperty({__proto__:null,base8},Symbol.toStringTag,{value:"Module"})),base10=baseX({prefix:"9",name:"base10",alphabet:"0123456789"}),base10$1=Object.freeze(Object.defineProperty({__proto__:null,base10},Symbol.toStringTag,{value:"Module"})),base16=rfc4648({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper=rfc4648({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),base16$1=Object.freeze(Object.defineProperty({__proto__:null,base16,base16upper},Symbol.toStringTag,{value:"Module"})),base32=rfc4648({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper=rfc4648({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad=rfc4648({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper=rfc4648({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex=rfc4648({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper=rfc4648({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad=rfc4648({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper=rfc4648({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z=rfc4648({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$1=Object.freeze(Object.defineProperty({__proto__:null,base32,base32hex,base32hexpad,base32hexpadupper,base32hexupper,base32pad,base32padupper,base32upper,base32z},Symbol.toStringTag,{value:"Module"})),base36=baseX({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper=baseX({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$1=Object.freeze(Object.defineProperty({__proto__:null,base36,base36upper},Symbol.toStringTag,{value:"Module"})),base58btc=baseX({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr=baseX({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58=Object.freeze(Object.defineProperty({__proto__:null,base58btc,base58flickr},Symbol.toStringTag,{value:"Module"})),base64=rfc4648({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad=rfc4648({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url=rfc4648({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad=rfc4648({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$1=Object.freeze(Object.defineProperty({__proto__:null,base64,base64pad,base64url,base64urlpad},Symbol.toStringTag,{value:"Module"})),alphabet=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),alphabetBytesToChars=alphabet.reduce((fr,br,wr)=>(fr[wr]=br,fr),[]),alphabetCharsToBytes=alphabet.reduce((fr,br,wr)=>(fr[br.codePointAt(0)]=wr,fr),[]);function encode(fr){return fr.reduce((br,wr)=>(br+=alphabetBytesToChars[wr],br),"")}function decode$1(fr){const br=[];for(const wr of fr){const Er=alphabetCharsToBytes[wr.codePointAt(0)];if(Er===void 0)throw new Error(`Non-base256emoji character: ${wr}`);br.push(Er)}return new Uint8Array(br)}const base256emoji=from({prefix:"🚀",name:"base256emoji",encode,decode:decode$1}),base256emoji$1=Object.freeze(Object.defineProperty({__proto__:null,base256emoji},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases={...identityBase,...base2$1,...base8$1,...base10$1,...base16$1,...base32$1,...base36$1,...base58,...base64$1,...base256emoji$1};function createCodec(fr,br,wr,Er){return{name:fr,prefix:br,encoder:{name:fr,prefix:br,encode:wr},decoder:{decode:Er}}}const string$3=createCodec("utf8","u",fr=>"u"+new TextDecoder("utf8").decode(fr),fr=>new TextEncoder().encode(fr.substring(1))),ascii=createCodec("ascii","a",fr=>{let br="a";for(let wr=0;wr{fr=fr.substring(1);const br=allocUnsafe(fr.length);for(let wr=0;wr"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ReactNativeInfo:typeof navigator<"u"?parseUserAgent(navigator.userAgent):getNodeVersion()}function matchUserAgent(fr){return fr!==""&&userAgentRules.reduce(function(br,wr){var Er=wr[0],kr=wr[1];if(br)return br;var jr=kr.exec(fr);return!!jr&&[Er,jr]},!1)}function parseUserAgent(fr){var br=matchUserAgent(fr);if(!br)return null;var wr=br[0],Er=br[1];if(wr==="searchbot")return new BotInfo;var kr=Er[1]&&Er[1].split(".").join("_").split("_").slice(0,3);kr?kr.length=$o)return Yr;var Po=Yn-Pm(ao);if(Po<1)return ao;var Oo=To?mm(To,0,Po).join(""):Yr.slice(0,Po);if(ho===wr)return Oo+ao;if(To&&(Po+=Oo.length-Po),ey(ho)){if(Yr.slice(Po).search(ho)){var _c,yl=Oo;for(ho.global||(ho=p1(ho.source,Ou($l.exec(ho))+"g")),ho.lastIndex=0;_c=ho.exec(yl);)var Rl=_c.index;Oo=Oo.slice(0,Rl===wr?Po:Rl)}}else if(Yr.indexOf(Ip(ho),Po)!=Po){var Hl=Oo.lastIndexOf(ho);Hl>-1&&(Oo=Oo.slice(0,Hl))}return Oo+ao}function b$(Yr){return Yr=Ou(Yr),Yr&&du.test(Yr)?Yr.replace(xl,Hx):Yr}var x$=Lm(function(Yr,$n,Yn){return Yr+(Yn?" ":"")+$n.toUpperCase()}),ny=Sv("toUpperCase");function Ex(Yr,$n,Yn){return Yr=Ou(Yr),$n=Yn?wr:$n,$n===wr?Ux(Yr)?Zx(Yr):Px(Yr):Yr.match($n)||[]}var $x=ku(function(Yr,$n){try{return mp(Yr,wr,$n)}catch(Yn){return Q1(Yn)?Yn:new xu(Yn)}}),w$=tm(function(Yr,$n){return Mp($n,function(Yn){Yn=Jp(Yn),Qp(Yr,Yn,Y1(Yr[Yn],Yr))}),Yr});function _$(Yr){var $n=Yr==null?0:Yr.length,Yn=cu();return Yr=$n?Gu(Yr,function(ao){if(typeof ao[1]!="function")throw new Op(Br);return[Yn(ao[0]),ao[1]]}):[],ku(function(ao){for(var ho=-1;++ho<$n;){var $o=Yr[ho];if(mp($o[0],this,ao))return mp($o[1],this,ao)}})}function E$(Yr){return Hw(Bp(Yr,Zr))}function iy(Yr){return function(){return Yr}}function $$(Yr,$n){return Yr==null||Yr!==Yr?$n:Yr}var S$=Cv(),k$=Cv(!0);function kp(Yr){return Yr}function oy(Yr){return Vy(typeof Yr=="function"?Yr:Bp(Yr,Zr))}function C$(Yr){return Ky(Bp(Yr,Zr))}function R$(Yr,$n){return Gy(Yr,Bp($n,Zr))}var T$=ku(function(Yr,$n){return function(Yn){return Qm(Yn,Yr,$n)}}),I$=ku(function(Yr,$n){return function(Yn){return Qm(Yr,Yn,$n)}});function ay(Yr,$n,Yn){var ao=sp($n),ho=M0($n,ao);Yn==null&&!(_f($n)&&(ho.length||!ao.length))&&(Yn=$n,$n=Yr,Yr=this,ho=M0($n,sp($n)));var $o=!(_f(Yn)&&"chain"in Yn)||!!Yn.chain,To=nm(Yr);return Mp(ho,function(Po){var Oo=$n[Po];Yr[Po]=Oo,To&&(Yr.prototype[Po]=function(){var _c=this.__chain__;if($o||_c){var yl=Yr(this.__wrapped__),Rl=yl.__actions__=Ep(this.__actions__);return Rl.push({func:Oo,args:arguments,thisArg:Yr}),yl.__chain__=_c,yl}return Oo.apply(Yr,lm([this.value()],arguments))})}),Yr}function A$(){return Hu._===this&&(Hu._=tw),this}function sy(){}function P$(Yr){return Yr=$u(Yr),ku(function($n){return Zy($n,Yr)})}var N$=D1(Gu),M$=D1(gy),O$=D1(s1);function Sx(Yr){return V1(Yr)?c1(Jp(Yr)):l_(Yr)}function j$(Yr){return function($n){return Yr==null?wr:Em(Yr,$n)}}var B$=Tv(),D$=Tv(!0);function cy(){return[]}function ly(){return!1}function L$(){return{}}function F$(){return""}function U$(){return!0}function W$(Yr,$n){if(Yr=$u(Yr),Yr<1||Yr>Pn)return[];var Yn=Nn,ao=hp(Yr,Nn);$n=cu($n),Yr-=Nn;for(var ho=d1(ao,$n);++Yn0||$n<0)?new Iu(Yn):(Yr<0?Yn=Yn.takeRight(-Yr):Yr&&(Yn=Yn.drop(Yr)),$n!==wr&&($n=$u($n),Yn=$n<0?Yn.dropRight(-$n):Yn.take($n-Yr)),Yn)},Iu.prototype.takeRightWhile=function(Yr){return this.reverse().takeWhile(Yr).reverse()},Iu.prototype.toArray=function(){return this.take(Nn)},Gp(Iu.prototype,function(Yr,$n){var Yn=/^(?:filter|find|map|reject)|While$/.test($n),ao=/^(?:head|last)$/.test($n),ho=xo[ao?"take"+($n=="last"?"Right":""):$n],$o=ao||/^find/.test($n);ho&&(xo.prototype[$n]=function(){var To=this.__wrapped__,Po=ao?[1]:arguments,Oo=To instanceof Iu,_c=Po[0],yl=Oo||wu(To),Rl=function(Ru){var Pu=ho.apply(xo,lm([Ru],Po));return ao&&Hl?Pu[0]:Pu};yl&&Yn&&typeof _c=="function"&&_c.length!=1&&(Oo=yl=!1);var Hl=this.__chain__,eu=!!this.__actions__.length,lu=$o&&!Hl,Su=Oo&&!eu;if(!$o&&yl){To=Su?To:new Iu(this);var uu=Yr.apply(To,Po);return uu.__actions__.push({func:H0,args:[Rl],thisArg:wr}),new jp(uu,Hl)}return lu&&Su?Yr.apply(this,Po):(uu=this.thru(Rl),lu?ao?uu.value()[0]:uu.value():uu)})}),Mp(["pop","push","shift","sort","splice","unshift"],function(Yr){var $n=v0[Yr],Yn=/^(?:push|sort|unshift)$/.test(Yr)?"tap":"thru",ao=/^(?:pop|shift)$/.test(Yr);xo.prototype[Yr]=function(){var ho=arguments;if(ao&&!this.__chain__){var $o=this.value();return $n.apply(wu($o)?$o:[],ho)}return this[Yn](function(To){return $n.apply(wu(To)?To:[],ho)})}}),Gp(Iu.prototype,function(Yr,$n){var Yn=xo[$n];if(Yn){var ao=Yn.name+"";ju.call(jm,ao)||(jm[ao]=[]),jm[ao].push({name:$n,func:Yn})}}),jm[L0(wr,In).name]=[{name:"wrapper",func:wr}],Iu.prototype.clone=yw,Iu.prototype.reverse=vw,Iu.prototype.value=bw,xo.prototype.at=G2,xo.prototype.chain=Z2,xo.prototype.commit=J2,xo.prototype.next=Y2,xo.prototype.plant=Q2,xo.prototype.reverse=eE,xo.prototype.toJSON=xo.prototype.valueOf=xo.prototype.value=tE,xo.prototype.first=xo.prototype.head,Hm&&(xo.prototype[Hm]=X2),xo},Nm=Jx();_p?((_p.exports=Nm)._=Nm,gp._=Nm):Hu._=Nm}).call(ge)})(Ui,Ui.exports);var Gg=Object.defineProperty,zg=Object.defineProperties,Kg=Object.getOwnPropertyDescriptors,Ea=Object.getOwnPropertySymbols,Yg=Object.prototype.hasOwnProperty,Zg=Object.prototype.propertyIsEnumerable,ya=(fr,br,wr)=>br in fr?Gg(fr,br,{enumerable:!0,configurable:!0,writable:!0,value:wr}):fr[br]=wr,cr=(fr,br)=>{for(var wr in br||(br={}))Yg.call(br,wr)&&ya(fr,wr,br[wr]);if(Ea)for(var wr of Ea(br))Zg.call(br,wr)&&ya(fr,wr,br[wr]);return fr},Jg=(fr,br)=>zg(fr,Kg(br));function ft(fr,br,wr){var Er;const kr=ve(fr);return((Er=br.rpcMap)==null?void 0:Er[kr.reference])||`${Bg}?chainId=${kr.namespace}:${kr.reference}&projectId=${wr}`}function Ct(fr){return fr.includes(":")?fr.split(":")[1]:fr}function Sa(fr){return fr.map(br=>`${br.split(":")[0]}:${br.split(":")[1]}`)}function Xg(fr,br){const wr=Object.keys(br.namespaces).filter(kr=>kr.includes(fr));if(!wr.length)return[];const Er=[];return wr.forEach(kr=>{const jr=br.namespaces[kr].accounts;Er.push(...jr)}),Er}function Oa(fr={},br={}){const wr=Ra(fr),Er=Ra(br);return Ui.exports.merge(wr,Er)}function Ra(fr){var br,wr,Er,kr;const jr={};if(!B$2(fr))return jr;for(const[Br,Wr]of Object.entries(fr)){const qr=oe(Br)?[Br]:Wr.chains,Hr=Wr.methods||[],Vr=Wr.events||[],Zr=Wr.rpcMap||{},Jr=en(Br);jr[Jr]=Jg(cr(cr({},jr[Jr]),Wr),{chains:S$2(qr,(br=jr[Jr])==null?void 0:br.chains),methods:S$2(Hr,(wr=jr[Jr])==null?void 0:wr.methods),events:S$2(Vr,(Er=jr[Jr])==null?void 0:Er.events),rpcMap:cr(cr({},Zr),(kr=jr[Jr])==null?void 0:kr.rpcMap)})}return jr}function Qg(fr){return fr.includes(":")?fr.split(":")[2]:fr}function Vg(fr){const br={};for(const[wr,Er]of Object.entries(fr)){const kr=Er.methods||[],jr=Er.events||[],Br=Er.accounts||[],Wr=oe(wr)?[wr]:Er.chains?Er.chains:Sa(Er.accounts);br[wr]={chains:Wr,methods:kr,events:jr,accounts:Br}}return br}function Wi(fr){return typeof fr=="number"?fr:fr.includes("0x")?parseInt(fr,16):(fr=fr.includes(":")?fr.split(":")[1]:fr,isNaN(Number(fr))?fr:Number(fr))}const ba={},z$2=fr=>ba[fr],Fi=(fr,br)=>{ba[fr]=br};class kg{constructor(br){this.name="polkadot",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}request(br){return this.namespace.methods.includes(br.request.method)?this.client.request(br):this.getHttpProvider().request(br.request)}setDefaultChain(br,wr){this.httpProviders[br]||this.setHttpProvider(br,wr),this.chainId=br,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${br}`)}getAccounts(){const br=this.namespace.accounts;return br?br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2])||[]:[]}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{var Er;const kr=Ct(wr);br[kr]=this.createHttpProvider(kr,(Er=this.namespace.rpcMap)==null?void 0:Er[wr])}),br}getHttpProvider(){const br=`${this.name}:${this.chainId}`,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProvider(br,wr){const Er=wr||ft(br,this.namespace,this.client.core.projectId);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);return new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}}class jg{constructor(br){this.name="eip155",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(br){switch(br.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(br);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(br.request.method)?await this.client.request(br):this.getHttpProvider().request(br.request)}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}setDefaultChain(br,wr){this.httpProviders[br]||this.setHttpProvider(parseInt(br),wr),this.chainId=parseInt(br),this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${br}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}createHttpProvider(br,wr){const Er=wr||ft(`${this.name}:${br}`,this.namespace,this.client.core.projectId);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);return new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{var Er;const kr=parseInt(Ct(wr));br[kr]=this.createHttpProvider(kr,(Er=this.namespace.rpcMap)==null?void 0:Er[wr])}),br}getAccounts(){const br=this.namespace.accounts;return br?[...new Set(br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2]))]:[]}getHttpProvider(){const br=this.chainId,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}async handleSwitchChain(br){var wr,Er;let kr=br.request.params?(wr=br.request.params[0])==null?void 0:wr.chainId:"0x0";kr=kr.startsWith("0x")?kr:`0x${kr}`;const jr=parseInt(kr,16);if(this.isChainApproved(jr))this.setDefaultChain(`${jr}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:br.topic,request:{method:br.request.method,params:[{chainId:kr}]},chainId:(Er=this.namespace.chains)==null?void 0:Er[0]}),this.setDefaultChain(`${jr}`);else throw new Error(`Failed to switch to chain 'eip155:${jr}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(br){return this.namespace.chains.includes(`${this.name}:${br}`)}}class nv{constructor(br){this.name="solana",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}requestAccounts(){return this.getAccounts()}request(br){return this.namespace.methods.includes(br.request.method)?this.client.request(br):this.getHttpProvider().request(br.request)}setDefaultChain(br,wr){this.httpProviders[br]||this.setHttpProvider(br,wr),this.chainId=br,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${br}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}getAccounts(){const br=this.namespace.accounts;return br?[...new Set(br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2]))]:[]}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{var Er;const kr=Ct(wr);br[kr]=this.createHttpProvider(kr,(Er=this.namespace.rpcMap)==null?void 0:Er[wr])}),br}getHttpProvider(){const br=`${this.name}:${this.chainId}`,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProvider(br,wr){const Er=wr||ft(br,this.namespace,this.client.core.projectId);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);return new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}}class tv{constructor(br){this.name="cosmos",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}request(br){return this.namespace.methods.includes(br.request.method)?this.client.request(br):this.getHttpProvider().request(br.request)}setDefaultChain(br,wr){this.httpProviders[br]||this.setHttpProvider(br,wr),this.chainId=br,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const br=this.namespace.accounts;return br?[...new Set(br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2]))]:[]}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{var Er;const kr=Ct(wr);br[kr]=this.createHttpProvider(kr,(Er=this.namespace.rpcMap)==null?void 0:Er[wr])}),br}getHttpProvider(){const br=`${this.name}:${this.chainId}`,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProvider(br,wr){const Er=wr||ft(br,this.namespace,this.client.core.projectId);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);return new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}}class ev{constructor(br){this.name="cip34",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}request(br){return this.namespace.methods.includes(br.request.method)?this.client.request(br):this.getHttpProvider().request(br.request)}setDefaultChain(br,wr){this.httpProviders[br]||this.setHttpProvider(br,wr),this.chainId=br,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const br=this.namespace.accounts;return br?[...new Set(br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2]))]:[]}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{const Er=this.getCardanoRPCUrl(wr),kr=Ct(wr);br[kr]=this.createHttpProvider(kr,Er)}),br}getHttpProvider(){const br=`${this.name}:${this.chainId}`,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}getCardanoRPCUrl(br){const wr=this.namespace.rpcMap;if(wr)return wr[br]}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProvider(br,wr){const Er=wr||this.getCardanoRPCUrl(br);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);return new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}}class rv{constructor(br){this.name="elrond",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}requestAccounts(){return this.getAccounts()}request(br){return this.namespace.methods.includes(br.request.method)?this.client.request(br):this.getHttpProvider().request(br.request)}setDefaultChain(br,wr){this.httpProviders[br]||this.setHttpProvider(br,wr),this.chainId=br,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${br}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}getAccounts(){const br=this.namespace.accounts;return br?[...new Set(br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2]))]:[]}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{var Er;const kr=Ct(wr);br[kr]=this.createHttpProvider(kr,(Er=this.namespace.rpcMap)==null?void 0:Er[wr])}),br}getHttpProvider(){const br=`${this.name}:${this.chainId}`,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProvider(br,wr){const Er=wr||ft(br,this.namespace,this.client.core.projectId);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);return new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}}class iv{constructor(br){this.name="multiversx",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}requestAccounts(){return this.getAccounts()}request(br){return this.namespace.methods.includes(br.request.method)?this.client.request(br):this.getHttpProvider().request(br.request)}setDefaultChain(br,wr){this.httpProviders[br]||this.setHttpProvider(br,wr),this.chainId=br,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${br}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}getAccounts(){const br=this.namespace.accounts;return br?[...new Set(br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2]))]:[]}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{var Er;const kr=Ct(wr);br[kr]=this.createHttpProvider(kr,(Er=this.namespace.rpcMap)==null?void 0:Er[wr])}),br}getHttpProvider(){const br=`${this.name}:${this.chainId}`,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProvider(br,wr){const Er=wr||ft(br,this.namespace,this.client.core.projectId);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);return new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}}class sv{constructor(br){this.name="near",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}request(br){return this.namespace.methods.includes(br.request.method)?this.client.request(br):this.getHttpProvider().request(br.request)}setDefaultChain(br,wr){if(this.chainId=br,!this.httpProviders[br]){const Er=wr||ft(`${this.name}:${br}`,this.namespace);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);this.setHttpProvider(br,Er)}this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const br=this.namespace.accounts;return br?br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2])||[]:[]}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{var Er;br[wr]=this.createHttpProvider(wr,(Er=this.namespace.rpcMap)==null?void 0:Er[wr])}),br}getHttpProvider(){const br=`${this.name}:${this.chainId}`,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProvider(br,wr){const Er=wr||ft(br,this.namespace);return typeof Er>"u"?void 0:new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}}var uv=Object.defineProperty,av=Object.defineProperties,ov=Object.getOwnPropertyDescriptors,Ta=Object.getOwnPropertySymbols,fv=Object.prototype.hasOwnProperty,cv=Object.prototype.propertyIsEnumerable,La=(fr,br,wr)=>br in fr?uv(fr,br,{enumerable:!0,configurable:!0,writable:!0,value:wr}):fr[br]=wr,hr=(fr,br)=>{for(var wr in br||(br={}))fv.call(br,wr)&&La(fr,wr,br[wr]);if(Ta)for(var wr of Ta(br))cv.call(br,wr)&&La(fr,wr,br[wr]);return fr},Mi=(fr,br)=>av(fr,ov(br));class lr{constructor(br){this.events=new Ug,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=br,this.logger=typeof(br==null?void 0:br.logger)<"u"&&typeof(br==null?void 0:br.logger)!="string"?br.logger:Hg(k$4({level:(br==null?void 0:br.logger)||Ia})),this.disableProviderPing=(br==null?void 0:br.disableProviderPing)||!1}static async init(br){const wr=new lr(br);return await wr.initialize(),wr}async request(br,wr,Er){const[kr,jr]=this.validateChain(wr);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(kr).request({request:hr({},br),chainId:`${kr}:${jr}`,topic:this.session.topic,expiry:Er})}sendAsync(br,wr,Er,kr){const jr=new Date().getTime();this.request(br,Er,kr).then(Br=>wr(null,formatJsonRpcResult(jr,Br))).catch(Br=>wr(Br,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var br;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(br=this.session)==null?void 0:br.topic,reason:U$1("USER_DISCONNECTED")}),await this.cleanup()}async connect(br){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(br),await this.cleanupPendingPairings(),!br.skipPairing)return await this.pair(br.pairingTopic)}on(br,wr){this.events.on(br,wr)}once(br,wr){this.events.once(br,wr)}removeListener(br,wr){this.events.removeListener(br,wr)}off(br,wr){this.events.off(br,wr)}get isWalletConnect(){return!0}async pair(br){this.shouldAbortPairingAttempt=!1;let wr=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(wr>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:Er,approval:kr}=await this.client.connect({pairingTopic:br,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});Er&&(this.uri=Er,this.events.emit("display_uri",Er)),await kr().then(jr=>{this.session=jr;const Br=Vg(jr.namespaces);this.namespaces=Oa(this.namespaces,Br),this.persist("namespaces",this.namespaces)}).catch(jr=>{if(jr.message!==ae)throw jr;wr++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(br,wr){try{if(!this.session)return;const[Er,kr]=this.validateChain(br);this.getProvider(Er).setDefaultChain(kr,wr)}catch(Er){if(!/Please call connect/.test(Er.message))throw Er}}async cleanupPendingPairings(br={}){this.logger.info("Cleaning up inactive pairings...");const wr=this.client.pairing.getAll();if(k$2(wr)){for(const Er of wr)br.deletePairings?this.client.core.expirer.set(Er.topic,0):await this.client.core.relayer.subscriber.unsubscribe(Er.topic);this.logger.info(`Inactive pairings cleared: ${wr.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const br=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[br]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await Q$1.init({logger:this.providerOpts.logger||Ia,relayUrl:this.providerOpts.relayUrl||Fg,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const br=[...new Set(Object.keys(this.session.namespaces).map(wr=>en(wr)))];Fi("client",this.client),Fi("events",this.events),Fi("disableProviderPing",this.disableProviderPing),br.forEach(wr=>{if(!this.session)return;const Er=Xg(wr,this.session),kr=Sa(Er),jr=Oa(this.namespaces,this.optionalNamespaces),Br=Mi(hr({},jr[wr]),{accounts:Er,chains:kr});switch(wr){case"eip155":this.rpcProviders[wr]=new jg({namespace:Br});break;case"solana":this.rpcProviders[wr]=new nv({namespace:Br});break;case"cosmos":this.rpcProviders[wr]=new tv({namespace:Br});break;case"polkadot":this.rpcProviders[wr]=new kg({namespace:Br});break;case"cip34":this.rpcProviders[wr]=new ev({namespace:Br});break;case"elrond":this.rpcProviders[wr]=new rv({namespace:Br});break;case"multiversx":this.rpcProviders[wr]=new iv({namespace:Br});break;case"near":this.rpcProviders[wr]=new sv({namespace:Br});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",br=>{this.events.emit("session_ping",br)}),this.client.on("session_event",br=>{const{params:wr}=br,{event:Er}=wr;if(Er.name==="accountsChanged"){const kr=Er.data;kr&&k$2(kr)&&this.events.emit("accountsChanged",kr.map(Qg))}else if(Er.name==="chainChanged"){const kr=wr.chainId,jr=wr.event.data,Br=en(kr),Wr=Wi(kr)!==Wi(jr)?`${Br}:${Wi(jr)}`:kr;this.onChainChanged(Wr)}else this.events.emit(Er.name,Er.data);this.events.emit("session_event",br)}),this.client.on("session_update",({topic:br,params:wr})=>{var Er;const{namespaces:kr}=wr,jr=(Er=this.client)==null?void 0:Er.session.get(br);this.session=Mi(hr({},jr),{namespaces:kr}),this.onSessionUpdate(),this.events.emit("session_update",{topic:br,params:wr})}),this.client.on("session_delete",async br=>{await this.cleanup(),this.events.emit("session_delete",br),this.events.emit("disconnect",Mi(hr({},U$1("USER_DISCONNECTED")),{data:br.topic}))}),this.on(Vn.DEFAULT_CHAIN_CHANGED,br=>{this.onChainChanged(br,!0)})}getProvider(br){if(!this.rpcProviders[br])throw new Error(`Provider not found: ${br}`);return this.rpcProviders[br]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(br=>{var wr;this.getProvider(br).updateNamespace((wr=this.session)==null?void 0:wr.namespaces[br])})}setNamespaces(br){const{namespaces:wr,optionalNamespaces:Er,sessionProperties:kr}=br;wr&&Object.keys(wr).length&&(this.namespaces=wr),Er&&Object.keys(Er).length&&(this.optionalNamespaces=Er),this.sessionProperties=kr,this.persist("namespaces",wr),this.persist("optionalNamespaces",Er)}validateChain(br){const[wr,Er]=(br==null?void 0:br.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[wr,Er];if(wr&&!Object.keys(this.namespaces||{}).map(Br=>en(Br)).includes(wr))throw new Error(`Namespace '${wr}' is not configured. Please call connect() first with namespace config.`);if(wr&&Er)return[wr,Er];const kr=en(Object.keys(this.namespaces)[0]),jr=this.rpcProviders[kr].getDefaultChain();return[kr,jr]}async requestAccounts(){const[br]=this.validateChain();return await this.getProvider(br).requestAccounts()}onChainChanged(br,wr=!1){if(!this.namespaces)return;const[Er,kr]=this.validateChain(br);kr&&(wr||this.getProvider(Er).setDefaultChain(kr),this.namespaces[Er]?this.namespaces[Er].defaultChain=kr:this.namespaces[`${Er}:${kr}`]?this.namespaces[`${Er}:${kr}`].defaultChain=kr:this.namespaces[`${Er}:${kr}`]={defaultChain:kr},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",kr))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(br,wr){this.client.core.storage.setItem(`${xa}/${br}`,wr)}async getFromStore(br){return await this.client.core.storage.getItem(`${xa}/${br}`)}}const hv=lr,P$2="wc",S$1="ethereum_provider",$$1=`${P$2}@2:${S$1}:`,j$2="https://rpc.walletconnect.com/v1/",u$2=["eth_sendTransaction","personal_sign"],E$1=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],m$2=["chainChanged","accountsChanged"],_$2=["chainChanged","accountsChanged","message","disconnect","connect"];var N$1=Object.defineProperty,q$2=Object.defineProperties,D$2=Object.getOwnPropertyDescriptors,y$2=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,O$1=(fr,br,wr)=>br in fr?N$1(fr,br,{enumerable:!0,configurable:!0,writable:!0,value:wr}):fr[br]=wr,p$2=(fr,br)=>{for(var wr in br||(br={}))U.call(br,wr)&&O$1(fr,wr,br[wr]);if(y$2)for(var wr of y$2(br))Q.call(br,wr)&&O$1(fr,wr,br[wr]);return fr},M$1=(fr,br)=>q$2(fr,D$2(br));function g$2(fr){return Number(fr[0].split(":")[1])}function f$3(fr){return`0x${fr.toString(16)}`}function L$1(fr){const{chains:br,optionalChains:wr,methods:Er,optionalMethods:kr,events:jr,optionalEvents:Br,rpcMap:Wr}=fr;if(!k$6(br))throw new Error("Invalid chains");const qr={chains:br,methods:Er||u$2,events:jr||m$2,rpcMap:p$2({},br.length?{[g$2(br)]:Wr[g$2(br)]}:{})},Hr=jr==null?void 0:jr.filter(Qr=>!m$2.includes(Qr)),Vr=Er==null?void 0:Er.filter(Qr=>!u$2.includes(Qr));if(!wr&&!Br&&!kr&&!(Hr!=null&&Hr.length)&&!(Vr!=null&&Vr.length))return{required:br.length?qr:void 0};const Zr=(Hr==null?void 0:Hr.length)&&(Vr==null?void 0:Vr.length)||!wr,Jr={chains:[...new Set(Zr?qr.chains.concat(wr||[]):wr)],methods:[...new Set(qr.methods.concat(kr!=null&&kr.length?kr:E$1))],events:[...new Set(qr.events.concat(Br!=null&&Br.length?Br:_$2))],rpcMap:Wr};return{required:br.length?qr:void 0,optional:wr.length?Jr:void 0}}let v$2=class dS{constructor(){this.events=new eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=$$1,this.on=(br,wr)=>(this.events.on(br,wr),this),this.once=(br,wr)=>(this.events.once(br,wr),this),this.removeListener=(br,wr)=>(this.events.removeListener(br,wr),this),this.off=(br,wr)=>(this.events.off(br,wr),this),this.parseAccount=br=>this.isCompatibleChainId(br)?this.parseAccountId(br).address:br,this.signer={},this.rpc={}}static async init(br){const wr=new dS;return await wr.initialize(br),wr}async request(br,wr){return await this.signer.request(br,this.formatChainId(this.chainId),wr)}sendAsync(br,wr,Er){this.signer.sendAsync(br,wr,this.formatChainId(this.chainId),Er)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(br){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(br);const{required:wr,optional:Er}=L$1(this.rpc);try{const kr=await new Promise(async(Br,Wr)=>{var qr;this.rpc.showQrModal&&((qr=this.modal)==null||qr.subscribeModal(Hr=>{!Hr.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),Wr(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(M$1(p$2({namespaces:p$2({},wr&&{[this.namespace]:wr})},Er&&{optionalNamespaces:{[this.namespace]:Er}}),{pairingTopic:br==null?void 0:br.pairingTopic})).then(Hr=>{Br(Hr)}).catch(Hr=>{Wr(new Error(Hr.message))})});if(!kr)return;const jr=Un(kr.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:jr),this.setAccounts(jr),this.events.emit("connect",{chainId:f$3(this.chainId)})}catch(kr){throw this.signer.logger.error(kr),kr}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",br=>{const{params:wr}=br,{event:Er}=wr;Er.name==="accountsChanged"?(this.accounts=this.parseAccounts(Er.data),this.events.emit("accountsChanged",this.accounts)):Er.name==="chainChanged"?this.setChainId(this.formatChainId(Er.data)):this.events.emit(Er.name,Er.data),this.events.emit("session_event",br)}),this.signer.on("chainChanged",br=>{const wr=parseInt(br);this.chainId=wr,this.events.emit("chainChanged",f$3(this.chainId)),this.persist()}),this.signer.on("session_update",br=>{this.events.emit("session_update",br)}),this.signer.on("session_delete",br=>{this.reset(),this.events.emit("session_delete",br),this.events.emit("disconnect",M$1(p$2({},U$4("USER_DISCONNECTED")),{data:br.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",br=>{var wr,Er;this.rpc.showQrModal&&((wr=this.modal)==null||wr.closeModal(),(Er=this.modal)==null||Er.openModal({uri:br})),this.events.emit("display_uri",br)})}switchEthereumChain(br){this.request({method:"wallet_switchEthereumChain",params:[{chainId:br.toString(16)}]})}isCompatibleChainId(br){return typeof br=="string"?br.startsWith(`${this.namespace}:`):!1}formatChainId(br){return`${this.namespace}:${br}`}parseChainId(br){return Number(br.split(":")[1])}setChainIds(br){const wr=br.filter(Er=>this.isCompatibleChainId(Er)).map(Er=>this.parseChainId(Er));wr.length&&(this.chainId=wr[0],this.events.emit("chainChanged",f$3(this.chainId)),this.persist())}setChainId(br){if(this.isCompatibleChainId(br)){const wr=this.parseChainId(br);this.chainId=wr,this.switchEthereumChain(wr)}}parseAccountId(br){const[wr,Er,kr]=br.split(":");return{chainId:`${wr}:${Er}`,address:kr}}setAccounts(br){this.accounts=br.filter(wr=>this.parseChainId(this.parseAccountId(wr).chainId)===this.chainId).map(wr=>this.parseAccountId(wr).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(br){var wr,Er;const kr=(wr=br==null?void 0:br.chains)!=null?wr:[],jr=(Er=br==null?void 0:br.optionalChains)!=null?Er:[],Br=kr.concat(jr);if(!Br.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const Wr=kr.length?(br==null?void 0:br.methods)||u$2:[],qr=kr.length?(br==null?void 0:br.events)||m$2:[],Hr=(br==null?void 0:br.optionalMethods)||[],Vr=(br==null?void 0:br.optionalEvents)||[],Zr=(br==null?void 0:br.rpcMap)||this.buildRpcMap(Br,br.projectId),Jr=(br==null?void 0:br.qrModalOptions)||void 0;return{chains:kr==null?void 0:kr.map(Qr=>this.formatChainId(Qr)),optionalChains:jr.map(Qr=>this.formatChainId(Qr)),methods:Wr,events:qr,optionalMethods:Hr,optionalEvents:Vr,rpcMap:Zr,showQrModal:!!(br!=null&&br.showQrModal),qrModalOptions:Jr,projectId:br.projectId,metadata:br.metadata}}buildRpcMap(br,wr){const Er={};return br.forEach(kr=>{Er[kr]=this.getRpcUrl(kr,wr)}),Er}async initialize(br){if(this.rpc=this.getRpcConfig(br),this.chainId=this.rpc.chains.length?g$2(this.rpc.chains):g$2(this.rpc.optionalChains),this.signer=await hv.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:br.disableProviderPing,relayUrl:br.relayUrl,storageOptions:br.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let wr;try{const{WalletConnectModal:Er}=await __vitePreload(()=>import("./index-DnxKYT5P.js").then(kr=>kr.i),[]);wr=Er}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(wr)try{this.modal=new wr(p$2({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(Er){throw this.signer.logger.error(Er),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(br){if(!br)return;const{chains:wr,optionalChains:Er,rpcMap:kr}=br;wr&&k$6(wr)&&(this.rpc.chains=wr.map(jr=>this.formatChainId(jr)),wr.forEach(jr=>{this.rpc.rpcMap[jr]=(kr==null?void 0:kr[jr])||this.getRpcUrl(jr)})),Er&&k$6(Er)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=Er==null?void 0:Er.map(jr=>this.formatChainId(jr)),Er.forEach(jr=>{this.rpc.rpcMap[jr]=(kr==null?void 0:kr[jr])||this.getRpcUrl(jr)}))}getRpcUrl(br,wr){var Er;return((Er=this.rpc.rpcMap)==null?void 0:Er[br])||`${j$2}?chainId=eip155:${br}&projectId=${wr||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const br=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),wr=this.session.namespaces[`${this.namespace}:${br}`]?this.session.namespaces[`${this.namespace}:${br}`]:this.session.namespaces[this.namespace];this.setChainIds(br?[this.formatChainId(br)]:wr==null?void 0:wr.accounts),this.setAccounts(wr==null?void 0:wr.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(br){return typeof br=="string"||br instanceof String?[this.parseAccount(br)]:br.map(wr=>this.parseAccount(wr))}};const parseIntSafe=(fr,br=10)=>{try{const wr=parseInt(String(fr),br);if(isNaN(wr)){logger$7.error(`Error parsing ${fr}`);return}return wr}catch(wr){logger$7.error(`Error parsing ${fr} to int: ${wr}`)}},activeAccountKey=fr=>`dynamic-wc2-active-account-${fr}`,sessionTopicKey=fr=>`dynamic-wc2-session-topic-${fr}`,swicthedNetworkKey=fr=>`dynamic-wc2-switched-network-${fr}`,currentChainKey=fr=>`dynamic-wc2-current-chain-${fr}`,ee=new EventEmitter$2;class WalletConnect extends EthereumWalletConnector{constructor(br){var wr;super(br),this.supportedChains=["EVM","ETH"],this.connectedChain="EVM",this.isInitialized=!1,this.canConnectViaQrCode=!0,this.isWalletConnect=!0,this.preferredChains=[],this._hasSwitchedNetwork=!1,this.sessionEventHandler=()=>{},this.sessionDeleteHandler=()=>{},this.name=br.walletName,this.projectId=br.projectId,this.deepLinkPreference=br.deepLinkPreference||"native",this.preferredChains=br.walletConnectPreferredChains||[],this.hasSwitchedNetwork=(wr=!!localStorage.getItem(this.swicthedNetworkKey))!==null&&wr!==void 0?wr:!1;const Er=localStorage.getItem(this.currentChainKey);this.currentChainId=Er?parseIntSafe(Er):void 0}getMappedChains(){return this.evmNetworks.filter(br=>br.chainId!==11297108109).map(br=>`eip155:${br.chainId}`)}getMappedChainsByPreferredOrder(){const br=this.getMappedChains(),wr=this.preferredChains.filter(kr=>br.includes(kr)),Er=br.filter(kr=>!this.preferredChains.includes(kr));return[...wr,...Er].map(kr=>Number(kr.split(":")[1]))}initConnection(){return __awaiter$8(this,void 0,void 0,function*(){const{provider:br}=WalletConnect;if(!br)throw new DynamicError("No provider found (init connection)");br!=null&&br.signer.uri||br.connect().catch(wr=>{logger$7.error(wr),ee.emit("walletconnect_connection_failed",wr)})})}createProvider(){return __awaiter$8(this,void 0,void 0,function*(){return v$2.init({events:["chainChanged","accountsChanged"],methods:[],optionalChains:this.getMappedChainsByPreferredOrder(),optionalMethods:["eth_chainId","eth_signTypedData","eth_signTransaction","eth_sign","personal_sign","eth_sendTransaction","eth_signTypedData_v4","wallet_switchEthereumChain","wallet_addEthereumChain"],projectId:this.projectId,rpcMap:this.evmNetworkRpcMap(),showQrModal:!1})})}getWalletClientFromInitializedProvider(){return __awaiter$8(this,void 0,void 0,function*(){const br=this.createProvider();return createWalletClient({account:this.getActiveAccount(),transport:custom(yield br)})})}createInitProviderPromise(){return __awaiter$8(this,void 0,void 0,function*(){WalletConnect.provider=yield this.createProvider(),this.teardownEventListeners(),this.setupEventListeners()})}initProvider(){return __awaiter$8(this,void 0,void 0,function*(){const{provider:br}=WalletConnect;br||(this.initializePromise===void 0&&(this.initializePromise=this.createInitProviderPromise()),yield this.initializePromise)})}refreshSession(){var br,wr,Er,kr,jr;!((wr=(br=WalletConnect.provider)===null||br===void 0?void 0:br.session)===null||wr===void 0)&&wr.topic&&localStorage.getItem(this.sessionTopicKey)===((kr=(Er=WalletConnect.provider)===null||Er===void 0?void 0:Er.session)===null||kr===void 0?void 0:kr.topic)&&(this.session=WalletConnect.provider.session,this.setActiveAccount((jr=localStorage.getItem(this.activeAccountKey))!==null&&jr!==void 0?jr:void 0))}init(){return __awaiter$8(this,void 0,void 0,function*(){yield this.initProvider(),yield this.initConnection(),this.isInitialized=!0})}get sessionTopicKey(){return sessionTopicKey(this.key)}get activeAccountKey(){return activeAccountKey(this.key)}get swicthedNetworkKey(){return swicthedNetworkKey(this.key)}get currentChainKey(){return currentChainKey(this.key)}set currentChainId(br){this._currentChainId=br,br?localStorage.setItem(this.currentChainKey,br.toString()):localStorage.removeItem(this.currentChainKey)}get currentChainId(){return this._currentChainId}set hasSwitchedNetwork(br){this._hasSwitchedNetwork=br,br?localStorage.setItem(this.swicthedNetworkKey,br.toString()):localStorage.removeItem(this.swicthedNetworkKey)}get hasSwitchedNetwork(){return this._hasSwitchedNetwork}supportsNetworkSwitching(){return!0}setupEventListeners(){WalletConnect.provider&&(this.sessionEventHandler=({params:br})=>{if(logger$7.debug("session_event was called",{params:br}),!br||!br.event){logger$7.debug("session_event was called without params or params.event");return}const{name:wr,data:Er}=br.event;if(wr==="chainChanged"){const kr=parseIntSafe(Er);if(kr===this.currentChainId){logger$7.debug(`ignoring chainChanged event with same chain id as current chain id: ${kr}`);return}if(kr===void 0){logger$7.debug(`received unexpected data for chainChanged: ${Er} with type ${typeof Er}}`);return}this.currentChainId=kr,this.emit("chainChange",{chain:String(kr)}),this.hasSwitchedNetwork=!0,this.switchNetwork({networkChainId:kr})}else if(wr==="accountsChanged"){if(!Array.isArray(Er)){logger$7.debug(`received unexpected data for accountsChanged: ${Er} with type ${typeof Er}}`);return}const kr=Er[0].split(":")[2];this.setWCActiveAccount(kr)}},WalletConnect.provider.on("session_event",this.sessionEventHandler),this.sessionDeleteHandler=()=>__awaiter$8(this,void 0,void 0,function*(){this.endSession(),this.emit("disconnect")}),WalletConnect.provider.on("session_delete",this.sessionDeleteHandler))}teardownEventListeners(){WalletConnect.provider&&(WalletConnect.provider.off("session_event",this.sessionEventHandler),WalletConnect.provider.off("session_delete",this.sessionDeleteHandler))}getWalletClient(br){if(WalletConnect.provider)return createWalletClient({account:this.getActiveAccount(),chain:chainsMap[br??String(this.currentChainId)],transport:custom(WalletConnect.provider)})}getAddress(br){return __awaiter$8(this,void 0,void 0,function*(){var wr,Er;const kr=this.getActiveAccount();if(kr!=null&&kr.address)return kr.address;if((!WalletConnect.provider||!(!((wr=WalletConnect.provider)===null||wr===void 0)&&wr.signer.uri))&&(logger$7.debug("No WC2 provider found, re-initializing..."),yield this.endSession(),yield this.init(),yield sleep$1(1e3),!WalletConnect.provider||!(!((Er=WalletConnect.provider)===null||Er===void 0)&&Er.signer.uri)))throw logger$7.debug("No WC2 provider found, escaping and throwing error"),new DynamicError("No provider found");const jr=getWalletBookWallet(this.walletBook,this.key,this.walletFallback);return performPlatformSpecificConnectionMethod(WalletConnect.provider.signer.uri,jr,{onDesktopUri:br==null?void 0:br.onDesktopUri,onDisplayUri:br==null?void 0:br.onDisplayUri},this.deepLinkPreference),new Promise((Br,Wr)=>{if(!WalletConnect.provider){Wr(new DynamicError("No provider found"));return}const qr=()=>{const Zr=new DynamicError("Connection rejected. Please try again.");Zr.code="connection_rejected",WalletConnect.provider&&(WalletConnect.provider.signer.uri=void 0,this.init()),Wr(Zr),Vr()},Hr=()=>{var Zr;const Jr=(Zr=WalletConnect.provider)===null||Zr===void 0?void 0:Zr.session;if(!Jr){Wr(new DynamicError("No session found"));return}this.setSession(Jr),this.setWCActiveAccount(Jr.namespaces.eip155.accounts[0].split(":")[2]),this.getNetwork().then(Qr=>{var _n;this.currentChainId=Qr,Br((_n=this.getActiveAccount())===null||_n===void 0?void 0:_n.address)}),Vr()},Vr=()=>{var Zr;ee.off("walletconnect_connection_failed",qr),(Zr=WalletConnect.provider)===null||Zr===void 0||Zr.off("connect",Hr)};ee.on("walletconnect_connection_failed",qr),WalletConnect.provider.on("connect",Hr)})})}waitForSignMessage(br,wr){return __awaiter$8(this,void 0,void 0,function*(){const kr=yield new Promise((jr,Br)=>{this.on("chainChange",()=>jr({success:!1})),br(wr).then(Wr=>jr({signedMessage:Wr,success:!0})).catch(Br)});return kr.success===!1?br(wr):kr.signedMessage})}getDeepLink(){var br;if(!this.session)return;const wr=getWalletBookWallet(this.walletBook,this.key),Er=getDeepLink({metadata:wr,mode:"regular",preference:this.deepLinkPreference,uri:(br=WalletConnect.provider)===null||br===void 0?void 0:br.signer.uri});if(Er)return`${Er}?sessionTopic=${this.session.topic}`}signMessage(br){return __awaiter$8(this,void 0,void 0,function*(){if(!this.session)throw new DynamicError("no session");const wr=this.getDeepLink();isMobile()&&wr&&(window.location.href=wr);const Er=jr=>__awaiter$8(this,void 0,void 0,function*(){const Br=this.getActiveAccount();return Br?(yield this.getWalletClientFromInitializedProvider()).signMessage({account:Br,message:jr}):void 0});return yield this.waitForSignMessage(Er,br)})}clearActiveAccount(){localStorage.removeItem(this.activeAccountKey),this.setActiveAccount(void 0)}clearSession(){localStorage.removeItem(this.sessionTopicKey),this.session=void 0}setWCActiveAccount(br){localStorage.setItem(this.activeAccountKey,br),this.setActiveAccount(br),this.emit("accountChange",{accounts:[br]})}setSession(br){localStorage.setItem(this.sessionTopicKey,br.topic),this.session=br}endSession(){return __awaiter$8(this,void 0,void 0,function*(){var br;if(this.clearActiveAccount(),this.clearSession(),this.hasSwitchedNetwork=!1,this.currentChainId=void 0,!!(!((br=WalletConnect.provider)===null||br===void 0)&&br.session))try{yield WalletConnect.provider.disconnect(),WalletConnect.provider=void 0}catch(wr){logger$7.debug(wr)}})}getNetwork(){const br=Object.create(null,{getNetwork:{get:()=>super.getNetwork}});return __awaiter$8(this,void 0,void 0,function*(){return this.currentChainId?this.currentChainId:(yield this.initProvider(),br.getNetwork.call(this))})}providerSwitchNetwork(br){const wr=Object.create(null,{providerSwitchNetwork:{get:()=>super.providerSwitchNetwork}});return __awaiter$8(this,arguments,void 0,function*({network:Er}){const kr=yield this.getSupportedNetworks();if(!(kr!=null&&kr.includes(Er.chainId.toString()))){const Wr=new DynamicError("Network switching is not available at this time. The user should manually switch network in their wallet");throw Wr.code="network_switching_only_available_in_wallet",Wr}const jr=yield this.getNetwork();if(jr&&jr===Er.chainId)return;if(this.switchNetworkOnlyFromWallet)throw new DynamicError("Network switching is only supported through the wallet");if(!this.supportsNetworkSwitching())throw new DynamicError("Network switching not supported");const Br=yield this.getWalletClientFromInitializedProvider();if(this.isMetaMask()){const Wr=this.getDeepLink();Wr&&(window.location.href=Wr)}yield wr.providerSwitchNetwork.call(this,{network:Er,provider:Br}),this.currentChainId=Er.chainId,this.hasSwitchedNetwork=!0,this.emit("chainChange",{chain:String(Er.chainId)})})}getConnectedAccounts(){return __awaiter$8(this,void 0,void 0,function*(){this.isInitialized===!1&&(yield this.initProvider(),this.refreshSession(),this.isInitialized=!0);const br=this.getActiveAccount();return br!=null&&br.address?[br.address]:[]})}isMetaMask(){var br,wr,Er,kr,jr;return(jr=(kr=(Er=(wr=(br=this.session)===null||br===void 0?void 0:br.peer)===null||wr===void 0?void 0:wr.metadata)===null||Er===void 0?void 0:Er.name)===null||kr===void 0?void 0:kr.toLowerCase().startsWith("metamask"))!==null&&jr!==void 0?jr:!1}getSupportedNetworks(){return __awaiter$8(this,void 0,void 0,function*(){var br;if(yield this.initProvider(),this.refreshSession(),this.isMetaMask())return this.hasSwitchedNetwork?[String(this.currentChainId)]:this.evmNetworks.map(Er=>Er.chainId.toString());if(!this.session)return[];const wr=[];return Object.keys(this.session.namespaces).forEach(Er=>{Er.startsWith("eip155:")&&wr.push(Er.split(":")[1])}),(br=this.session.namespaces.eip155)===null||br===void 0||br.accounts.forEach(Er=>wr.push(Er.split(":")[1])),wr.length?wr:this.evmNetworks.map(Er=>Er.chainId.toString())})}}let InjectedWalletBase$1=class extends EthereumWalletConnector{constructor(){super(...arguments),this.supportedChains=["ETH","EVM"],this.connectedChain="EVM",this.walletConnectorFallback=!1}getEthProviderHelper(){return this.wallet||(this.wallet=findWalletBookWallet(this.walletBook,this.key)),this.wallet&&!this.ethProviderHelper&&(this.ethProviderHelper=new EthProviderHelper(this.wallet,this)),this.ethProviderHelper}getMobileOrInstalledWallet(){var br,wr;return this.wallet||(this.wallet=findWalletBookWallet(this.walletBook,this.key)),this.isInstalledOnBrowser()?this:!((wr=(br=this.wallet)===null||br===void 0?void 0:br.mobile)===null||wr===void 0)&&wr.inAppBrowser&&this.mobileExperience==="in-app-browser"&&isMobile()?this:this.walletConnectorFallback?new WalletConnect(Object.assign(Object.assign({},this.constructorProps),{walletName:this.name})):this}findProvider(){const br=this.getEthProviderHelper();if(br)return br.getInstalledProvider()}setupEventListeners(){if(!this.getWalletClient())return;const wr=this.getEthProviderHelper();if(!wr)return;const{tearDownEventListeners:Er}=wr._setupEventListeners(this);this.teardownEventListeners=Er}getWalletClient(br){var wr;return(wr=this.getEthProviderHelper())===null||wr===void 0?void 0:wr.findWalletClient(br)}isInstalledOnBrowser(){var br;return((br=this.getEthProviderHelper())===null||br===void 0?void 0:br.findProvider())!==void 0}getAddress(){return __awaiter$8(this,void 0,void 0,function*(){var br;return(br=this.getEthProviderHelper())===null||br===void 0?void 0:br.getAddress()})}connect(){return __awaiter$8(this,void 0,void 0,function*(){yield this.getAddress()})}signMessage(br){return __awaiter$8(this,void 0,void 0,function*(){var wr;return(wr=this.getEthProviderHelper())===null||wr===void 0?void 0:wr.signMessage(br)})}proveOwnership(br,wr){return __awaiter$8(this,void 0,void 0,function*(){return yield this.validateActiveWallet(br),this.signMessage(wr)})}endSession(){return __awaiter$8(this,void 0,void 0,function*(){})}providerSwitchNetwork(br){const wr=Object.create(null,{providerSwitchNetwork:{get:()=>super.providerSwitchNetwork}});return __awaiter$8(this,arguments,void 0,function*({network:Er,provider:kr}){return wr.providerSwitchNetwork.call(this,{network:Er,provider:kr})})}};class PhantomEvm extends InjectedWalletBase$1{constructor(br){super(br),this.name="Phantom",this.overrideKey="phantomevm",this.wallet=findWalletBookWallet(this.walletBook,this.key)}getAddress(){const br=Object.create(null,{getAddress:{get:()=>super.getAddress}});return __awaiter$8(this,void 0,void 0,function*(){if(this.isInstalledOnBrowser())return br.getAddress.call(this);isMobile()&&handleMobileWalletRedirect({nativeLink:"phantom://browse",universalLink:"https://phantom.app/ul/browse"})})}canGetChainAddress(){var br,wr;return!!(!((wr=(br=this.getEthProviderHelper())===null||br===void 0?void 0:br.findProvider())===null||wr===void 0)&&wr.selectedAddress)}}class ExodusEvm extends InjectedWalletBase$1{constructor(br){super(br),this.name="ExodusEvm",this.overrideKey="exodusevm",this.walletConnectorFallback=!0,this.wallet=findWalletBookWallet(this.walletBook,this.key)}}let UnknownInjected$1=class extends InjectedWalletBase$1{constructor(br){super(br),this.name="Unknown",this.overrideKey="unknown",this.wallet=findWalletBookWallet(this.walletBook,this.key)}isInstalledOnBrowser(){return!1}};class FallbackEvmConnector extends InjectedWalletBase$1{constructor(br){super(br),this.name="Fallback Connector",this.overrideKey="fallbackconnector",this.isAvailable=!1,this.wallet=findWalletBookWallet(this.walletBook,this.key)}isInstalledOnBrowser(){return!1}}const injectedWalletOverrides$1=[PhantomEvm,ExodusEvm],filteredInjectedWalletKeysOverrides$1=["phantomevm","coinbase","exodusevm"],fetchInjectedWalletConnector=({walletBook:fr})=>{var br;return Object.entries((br=fr==null?void 0:fr.wallets)!==null&&br!==void 0?br:{}).filter(([wr,Er])=>{var kr;return((kr=Er.injectedConfig)===null||kr===void 0?void 0:kr.find(jr=>jr.chain==="evm"))&&!filteredInjectedWalletKeysOverrides$1.includes(wr)}).map(([wr,Er])=>{const{shortName:kr}=Er,jr=kr||Er.name,Br=!!Er.walletConnect;return class extends InjectedWalletBase$1{constructor(Wr){super(Object.assign({},Wr)),this.name=jr,this.wallet=Er,this.walletConnectorFallback=Br,this.overrideKey=wr}getAddress(){const Wr=Object.create(null,{getAddress:{get:()=>super.getAddress}});return __awaiter$8(this,void 0,void 0,function*(){var qr;if(this.isInstalledOnBrowser())return Wr.getAddress.call(this);const Hr=(qr=this.wallet.mobile)===null||qr===void 0?void 0:qr.inAppBrowser;if(!Hr){const Vr=new Error(`No inAppBrowserBase found for ${this.name}.`);throw logger$7.error(Vr.message),Vr}window.location.href=`${Hr}/${window.location.href}`})}}})},fetchWalletConnectWallets=({walletBook:fr})=>{var br;return Object.entries((br=fr==null?void 0:fr.wallets)!==null&&br!==void 0?br:{}).filter(([,wr])=>wr.walletConnect&&!wr.filterFromWalletConnect).map(([wr,Er])=>{const{shortName:kr}=Er,jr=kr||Er.name;return class extends WalletConnect{constructor(Br){super(Object.assign(Object.assign({},Br),{walletName:jr})),this.overrideKey=wr}}})},getWalletConnectConnector=()=>class extends WalletConnect{constructor(fr){super(Object.assign(Object.assign({},fr),{walletName:"WalletConnect"}))}};var dist={},CoinbaseWalletSDK$1={},walletLogo$1={};Object.defineProperty(walletLogo$1,"__esModule",{value:!0});walletLogo$1.walletLogo=void 0;const walletLogo=(fr,br)=>{let wr;switch(fr){case"standard":return wr=br,`data:image/svg+xml,%3Csvg width='${br}' height='${wr}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return wr=br,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${br}' height='${wr}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return wr=(.1*br).toFixed(2),`data:image/svg+xml,%3Csvg width='${br}' height='${wr}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return wr=(.25*br).toFixed(2),`data:image/svg+xml,%3Csvg width='${br}' height='${wr}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return wr=(.1*br).toFixed(2),`data:image/svg+xml,%3Csvg width='${br}' height='${wr}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return wr=(.25*br).toFixed(2),`data:image/svg+xml,%3Csvg width='${br}' height='${wr}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return wr=br,`data:image/svg+xml,%3Csvg width='${br}' height='${wr}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};walletLogo$1.walletLogo=walletLogo;var CoinbaseWalletProvider$1={};const require$$0$2=getAugmentedNamespace(eventemitter3$1);var error={},constants$2={};Object.defineProperty(constants$2,"__esModule",{value:!0});constants$2.errorValues=constants$2.standardErrorCodes=void 0;constants$2.standardErrorCodes={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}};constants$2.errorValues={"-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."}};var errors$1={},utils$1={};(function(fr){Object.defineProperty(fr,"__esModule",{value:!0}),fr.serialize=fr.getErrorCode=fr.isValidCode=fr.getMessageFromCode=fr.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const br=constants$2,wr="Unspecified error message.";fr.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function Er(Jr,Qr=wr){if(Jr&&Number.isInteger(Jr)){const _n=Jr.toString();if(Vr(br.errorValues,_n))return br.errorValues[_n].message;if(qr(Jr))return fr.JSON_RPC_SERVER_ERROR_MESSAGE}return Qr}fr.getMessageFromCode=Er;function kr(Jr){if(!Number.isInteger(Jr))return!1;const Qr=Jr.toString();return!!(br.errorValues[Qr]||qr(Jr))}fr.isValidCode=kr;function jr(Jr){var Qr;if(typeof Jr=="number")return Jr;if(Br(Jr))return(Qr=Jr.code)!==null&&Qr!==void 0?Qr:Jr.errorCode}fr.getErrorCode=jr;function Br(Jr){return typeof Jr=="object"&&Jr!==null&&(typeof Jr.code=="number"||typeof Jr.errorCode=="number")}function Wr(Jr,{shouldIncludeStack:Qr=!1}={}){const _n={};if(Jr&&typeof Jr=="object"&&!Array.isArray(Jr)&&Vr(Jr,"code")&&kr(Jr.code)){const En=Jr;_n.code=En.code,En.message&&typeof En.message=="string"?(_n.message=En.message,Vr(En,"data")&&(_n.data=En.data)):(_n.message=Er(_n.code),_n.data={originalError:Hr(Jr)})}else _n.code=br.standardErrorCodes.rpc.internal,_n.message=Zr(Jr,"message")?Jr.message:wr,_n.data={originalError:Hr(Jr)};return Qr&&(_n.stack=Zr(Jr,"stack")?Jr.stack:void 0),_n}fr.serialize=Wr;function qr(Jr){return Jr>=-32099&&Jr<=-32e3}function Hr(Jr){return Jr&&typeof Jr=="object"&&!Array.isArray(Jr)?Object.assign({},Jr):Jr}function Vr(Jr,Qr){return Object.prototype.hasOwnProperty.call(Jr,Qr)}function Zr(Jr,Qr){return typeof Jr=="object"&&Jr!==null&&Qr in Jr&&typeof Jr[Qr]=="string"}})(utils$1);Object.defineProperty(errors$1,"__esModule",{value:!0});errors$1.standardErrors=void 0;const constants_1$6=constants$2,utils_1$1=utils$1;errors$1.standardErrors={rpc:{parse:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.parse,fr),invalidRequest:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.invalidRequest,fr),invalidParams:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.invalidParams,fr),methodNotFound:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.methodNotFound,fr),internal:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.internal,fr),server:fr=>{if(!fr||typeof fr!="object"||Array.isArray(fr))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:br}=fr;if(!Number.isInteger(br)||br>-32005||br<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return getEthJsonRpcError(br,fr)},invalidInput:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.invalidInput,fr),resourceNotFound:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.resourceNotFound,fr),resourceUnavailable:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.resourceUnavailable,fr),transactionRejected:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.transactionRejected,fr),methodNotSupported:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.methodNotSupported,fr),limitExceeded:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.limitExceeded,fr)},provider:{userRejectedRequest:fr=>getEthProviderError(constants_1$6.standardErrorCodes.provider.userRejectedRequest,fr),unauthorized:fr=>getEthProviderError(constants_1$6.standardErrorCodes.provider.unauthorized,fr),unsupportedMethod:fr=>getEthProviderError(constants_1$6.standardErrorCodes.provider.unsupportedMethod,fr),disconnected:fr=>getEthProviderError(constants_1$6.standardErrorCodes.provider.disconnected,fr),chainDisconnected:fr=>getEthProviderError(constants_1$6.standardErrorCodes.provider.chainDisconnected,fr),unsupportedChain:fr=>getEthProviderError(constants_1$6.standardErrorCodes.provider.unsupportedChain,fr),custom:fr=>{if(!fr||typeof fr!="object"||Array.isArray(fr))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:br,message:wr,data:Er}=fr;if(!wr||typeof wr!="string")throw new Error('"message" must be a nonempty string');return new EthereumProviderError(br,wr,Er)}}};function getEthJsonRpcError(fr,br){const[wr,Er]=parseOpts(br);return new EthereumRpcError(fr,wr||(0,utils_1$1.getMessageFromCode)(fr),Er)}function getEthProviderError(fr,br){const[wr,Er]=parseOpts(br);return new EthereumProviderError(fr,wr||(0,utils_1$1.getMessageFromCode)(fr),Er)}function parseOpts(fr){if(fr){if(typeof fr=="string")return[fr];if(typeof fr=="object"&&!Array.isArray(fr)){const{message:br,data:wr}=fr;if(br&&typeof br!="string")throw new Error("Must specify string message.");return[br||void 0,wr]}}return[]}class EthereumRpcError extends Error{constructor(br,wr,Er){if(!Number.isInteger(br))throw new Error('"code" must be an integer.');if(!wr||typeof wr!="string")throw new Error('"message" must be a nonempty string.');super(wr),this.code=br,Er!==void 0&&(this.data=Er)}}class EthereumProviderError extends EthereumRpcError{constructor(br,wr,Er){if(!isValidEthProviderCode(br))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(br,wr,Er)}}function isValidEthProviderCode(fr){return Number.isInteger(fr)&&fr>=1e3&&fr<=4999}(function(fr){Object.defineProperty(fr,"__esModule",{value:!0}),fr.standardErrors=fr.standardErrorCodes=void 0;var br=constants$2;Object.defineProperty(fr,"standardErrorCodes",{enumerable:!0,get:function(){return br.standardErrorCodes}});var wr=errors$1;Object.defineProperty(fr,"standardErrors",{enumerable:!0,get:function(){return wr.standardErrors}})})(error);var serialize$1={},Web3Response={};Object.defineProperty(Web3Response,"__esModule",{value:!0});Web3Response.isErrorResponse=void 0;function isErrorResponse(fr){return fr.errorMessage!==void 0}Web3Response.isErrorResponse=isErrorResponse;var version$8={};Object.defineProperty(version$8,"__esModule",{value:!0});version$8.LIB_VERSION=void 0;version$8.LIB_VERSION="4.0.4";Object.defineProperty(serialize$1,"__esModule",{value:!0});serialize$1.serializeError=void 0;const Web3Response_1$2=Web3Response,version_1$3=version$8,constants_1$5=constants$2,utils_1=utils$1;function serializeError(fr,br){const wr=(0,utils_1.serialize)(getErrorObject(fr),{shouldIncludeStack:!0}),Er=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");Er.searchParams.set("version",version_1$3.LIB_VERSION),Er.searchParams.set("code",wr.code.toString());const kr=getMethod(wr.data,br);return kr&&Er.searchParams.set("method",kr),Er.searchParams.set("message",wr.message),Object.assign(Object.assign({},wr),{docUrl:Er.href})}serialize$1.serializeError=serializeError;function getErrorObject(fr){return typeof fr=="string"?{message:fr,code:constants_1$5.standardErrorCodes.rpc.internal}:(0,Web3Response_1$2.isErrorResponse)(fr)?Object.assign(Object.assign({},fr),{message:fr.errorMessage,code:fr.errorCode,data:{method:fr.method}}):fr}function getMethod(fr,br){const wr=fr==null?void 0:fr.method;if(wr)return wr;if(br!==void 0){if(typeof br=="string")return br;if(Array.isArray(br)){if(br.length>0)return br[0].method}else return br.method}}var type$3={};Object.defineProperty(type$3,"__esModule",{value:!0});type$3.RegExpString=type$3.IntNumber=type$3.BigIntString=type$3.AddressString=type$3.HexString=type$3.OpaqueType=void 0;function OpaqueType(){return fr=>fr}type$3.OpaqueType=OpaqueType;type$3.HexString=OpaqueType();type$3.AddressString=OpaqueType();type$3.BigIntString=OpaqueType();function IntNumber(fr){return Math.floor(fr)}type$3.IntNumber=IntNumber;type$3.RegExpString=OpaqueType();var util$6={};Object.defineProperty(util$6,"__esModule",{value:!0});util$6.areAddressArraysEqual=util$6.getFavicon=util$6.range=util$6.isBigNumber=util$6.ensureParsedJSONObject=util$6.ensureBigInt=util$6.ensureRegExpString=util$6.ensureIntNumber=util$6.ensureBuffer=util$6.ensureAddressString=util$6.ensureEvenLengthHexString=util$6.ensureHexString=util$6.isHexString=util$6.prepend0x=util$6.strip0x=util$6.has0xPrefix=util$6.hexStringFromIntNumber=util$6.intNumberFromHexString=util$6.bigIntStringFromBigInt=util$6.hexStringFromBuffer=util$6.hexStringToUint8Array=util$6.uint8ArrayToHex=util$6.randomBytesHex=void 0;const error_1$8=error,_1=type$3,INT_STRING_REGEX=/^[0-9]*$/,HEXADECIMAL_STRING_REGEX=/^[a-f0-9]*$/;function randomBytesHex(fr){return uint8ArrayToHex(crypto.getRandomValues(new Uint8Array(fr)))}util$6.randomBytesHex=randomBytesHex;function uint8ArrayToHex(fr){return[...fr].map(br=>br.toString(16).padStart(2,"0")).join("")}util$6.uint8ArrayToHex=uint8ArrayToHex;function hexStringToUint8Array(fr){return new Uint8Array(fr.match(/.{1,2}/g).map(br=>parseInt(br,16)))}util$6.hexStringToUint8Array=hexStringToUint8Array;function hexStringFromBuffer(fr,br=!1){const wr=fr.toString("hex");return(0,_1.HexString)(br?`0x${wr}`:wr)}util$6.hexStringFromBuffer=hexStringFromBuffer;function bigIntStringFromBigInt(fr){return(0,_1.BigIntString)(fr.toString(10))}util$6.bigIntStringFromBigInt=bigIntStringFromBigInt;function intNumberFromHexString(fr){return(0,_1.IntNumber)(Number(BigInt(ensureEvenLengthHexString(fr,!0))))}util$6.intNumberFromHexString=intNumberFromHexString;function hexStringFromIntNumber(fr){return(0,_1.HexString)(`0x${BigInt(fr).toString(16)}`)}util$6.hexStringFromIntNumber=hexStringFromIntNumber;function has0xPrefix(fr){return fr.startsWith("0x")||fr.startsWith("0X")}util$6.has0xPrefix=has0xPrefix;function strip0x(fr){return has0xPrefix(fr)?fr.slice(2):fr}util$6.strip0x=strip0x;function prepend0x(fr){return has0xPrefix(fr)?`0x${fr.slice(2)}`:`0x${fr}`}util$6.prepend0x=prepend0x;function isHexString$1(fr){if(typeof fr!="string")return!1;const br=strip0x(fr).toLowerCase();return HEXADECIMAL_STRING_REGEX.test(br)}util$6.isHexString=isHexString$1;function ensureHexString(fr,br=!1){if(typeof fr=="string"){const wr=strip0x(fr).toLowerCase();if(HEXADECIMAL_STRING_REGEX.test(wr))return(0,_1.HexString)(br?`0x${wr}`:wr)}throw error_1$8.standardErrors.rpc.invalidParams(`"${String(fr)}" is not a hexadecimal string`)}util$6.ensureHexString=ensureHexString;function ensureEvenLengthHexString(fr,br=!1){let wr=ensureHexString(fr,!1);return wr.length%2===1&&(wr=(0,_1.HexString)(`0${wr}`)),br?(0,_1.HexString)(`0x${wr}`):wr}util$6.ensureEvenLengthHexString=ensureEvenLengthHexString;function ensureAddressString(fr){if(typeof fr=="string"){const br=strip0x(fr).toLowerCase();if(isHexString$1(br)&&br.length===40)return(0,_1.AddressString)(prepend0x(br))}throw error_1$8.standardErrors.rpc.invalidParams(`Invalid Ethereum address: ${String(fr)}`)}util$6.ensureAddressString=ensureAddressString;function ensureBuffer(fr){if(Buffer$2.isBuffer(fr))return fr;if(typeof fr=="string"){if(isHexString$1(fr)){const br=ensureEvenLengthHexString(fr,!1);return Buffer$2.from(br,"hex")}return Buffer$2.from(fr,"utf8")}throw error_1$8.standardErrors.rpc.invalidParams(`Not binary data: ${String(fr)}`)}util$6.ensureBuffer=ensureBuffer;function ensureIntNumber(fr){if(typeof fr=="number"&&Number.isInteger(fr))return(0,_1.IntNumber)(fr);if(typeof fr=="string"){if(INT_STRING_REGEX.test(fr))return(0,_1.IntNumber)(Number(fr));if(isHexString$1(fr))return(0,_1.IntNumber)(Number(BigInt(ensureEvenLengthHexString(fr,!0))))}throw error_1$8.standardErrors.rpc.invalidParams(`Not an integer: ${String(fr)}`)}util$6.ensureIntNumber=ensureIntNumber;function ensureRegExpString(fr){if(fr instanceof RegExp)return(0,_1.RegExpString)(fr.toString());throw error_1$8.standardErrors.rpc.invalidParams(`Not a RegExp: ${String(fr)}`)}util$6.ensureRegExpString=ensureRegExpString;function ensureBigInt(fr){if(fr!==null&&(typeof fr=="bigint"||isBigNumber(fr)))return BigInt(fr.toString(10));if(typeof fr=="number")return BigInt(ensureIntNumber(fr));if(typeof fr=="string"){if(INT_STRING_REGEX.test(fr))return BigInt(fr);if(isHexString$1(fr))return BigInt(ensureEvenLengthHexString(fr,!0))}throw error_1$8.standardErrors.rpc.invalidParams(`Not an integer: ${String(fr)}`)}util$6.ensureBigInt=ensureBigInt;function ensureParsedJSONObject(fr){if(typeof fr=="string")return JSON.parse(fr);if(typeof fr=="object")return fr;throw error_1$8.standardErrors.rpc.invalidParams(`Not a JSON string or an object: ${String(fr)}`)}util$6.ensureParsedJSONObject=ensureParsedJSONObject;function isBigNumber(fr){if(fr==null||typeof fr.constructor!="function")return!1;const{constructor:br}=fr;return typeof br.config=="function"&&typeof br.EUCLID=="number"}util$6.isBigNumber=isBigNumber;function range(fr,br){return Array.from({length:br-fr},(wr,Er)=>fr+Er)}util$6.range=range;function getFavicon(){const fr=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:br,host:wr}=document.location,Er=fr?fr.getAttribute("href"):null;return!Er||Er.startsWith("javascript:")||Er.startsWith("vbscript:")?null:Er.startsWith("http://")||Er.startsWith("https://")||Er.startsWith("data:")?Er:Er.startsWith("//")?br+Er:`${br}//${wr}${Er}`}util$6.getFavicon=getFavicon;function areAddressArraysEqual(fr,br){return fr.length===br.length&&fr.every((wr,Er)=>wr===br[Er])}util$6.areAddressArraysEqual=areAddressArraysEqual;var util$5={},SCWSigner$1={},SCWKeyManager$1={},cipher={};Object.defineProperty(cipher,"__esModule",{value:!0});cipher.decryptContent=cipher.encryptContent=cipher.importKeyFromHexString=cipher.exportKeyToHexString=cipher.decrypt=cipher.encrypt=cipher.deriveSharedSecret=cipher.generateKeyPair=void 0;const util_1$b=util$6;async function generateKeyPair(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}cipher.generateKeyPair=generateKeyPair;async function deriveSharedSecret(fr,br){return crypto.subtle.deriveKey({name:"ECDH",public:br},fr,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}cipher.deriveSharedSecret=deriveSharedSecret;async function encrypt(fr,br){const wr=crypto.getRandomValues(new Uint8Array(12)),Er=await crypto.subtle.encrypt({name:"AES-GCM",iv:wr},fr,new TextEncoder().encode(br));return{iv:wr,cipherText:Er}}cipher.encrypt=encrypt;async function decrypt(fr,{iv:br,cipherText:wr}){const Er=await crypto.subtle.decrypt({name:"AES-GCM",iv:br},fr,wr);return new TextDecoder().decode(Er)}cipher.decrypt=decrypt;function getFormat(fr){switch(fr){case"public":return"spki";case"private":return"pkcs8"}}async function exportKeyToHexString(fr,br){const wr=getFormat(fr),Er=await crypto.subtle.exportKey(wr,br);return(0,util_1$b.uint8ArrayToHex)(new Uint8Array(Er))}cipher.exportKeyToHexString=exportKeyToHexString;async function importKeyFromHexString(fr,br){const wr=getFormat(fr),Er=(0,util_1$b.hexStringToUint8Array)(br).buffer;return await crypto.subtle.importKey(wr,Er,{name:"ECDH",namedCurve:"P-256"},!0,fr==="private"?["deriveKey"]:[])}cipher.importKeyFromHexString=importKeyFromHexString;async function encryptContent(fr,br){const wr=JSON.stringify(fr,(Er,kr)=>{if(!(kr instanceof Error))return kr;const jr=kr;return Object.assign(Object.assign({},jr.code?{code:jr.code}:{}),{message:jr.message})});return encrypt(br,wr)}cipher.encryptContent=encryptContent;async function decryptContent(fr,br){return JSON.parse(await decrypt(br,fr))}cipher.decryptContent=decryptContent;var ScopedLocalStorage$1={};Object.defineProperty(ScopedLocalStorage$1,"__esModule",{value:!0});ScopedLocalStorage$1.ScopedLocalStorage=void 0;class ScopedLocalStorage{constructor(br,wr){this.scope=br,this.module=wr}setItem(br,wr){localStorage.setItem(this.scopedKey(br),wr)}getItem(br){return localStorage.getItem(this.scopedKey(br))}removeItem(br){localStorage.removeItem(this.scopedKey(br))}clear(){const br=this.scopedKey(""),wr=[];for(let Er=0;ErlocalStorage.removeItem(Er))}scopedKey(br){return`-${this.scope}${this.module?`:${this.module}`:""}:${br}`}static clearAll(){new ScopedLocalStorage("CBWSDK").clear(),new ScopedLocalStorage("walletlink").clear()}}ScopedLocalStorage$1.ScopedLocalStorage=ScopedLocalStorage;Object.defineProperty(SCWKeyManager$1,"__esModule",{value:!0});SCWKeyManager$1.SCWKeyManager=void 0;const cipher_1$1=cipher,ScopedLocalStorage_1$6=ScopedLocalStorage$1,OWN_PRIVATE_KEY={storageKey:"ownPrivateKey",keyType:"private"},OWN_PUBLIC_KEY={storageKey:"ownPublicKey",keyType:"public"},PEER_PUBLIC_KEY={storageKey:"peerPublicKey",keyType:"public"};class SCWKeyManager{constructor(){this.storage=new ScopedLocalStorage_1$6.ScopedLocalStorage("CBWSDK","SCWKeyManager"),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(br){this.sharedSecret=null,this.peerPublicKey=br,await this.storeKey(PEER_PUBLIC_KEY,br),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,this.storage.removeItem(OWN_PUBLIC_KEY.storageKey),this.storage.removeItem(OWN_PRIVATE_KEY.storageKey),this.storage.removeItem(PEER_PUBLIC_KEY.storageKey)}async generateKeyPair(){const br=await(0,cipher_1$1.generateKeyPair)();this.ownPrivateKey=br.privateKey,this.ownPublicKey=br.publicKey,await this.storeKey(OWN_PRIVATE_KEY,br.privateKey),await this.storeKey(OWN_PUBLIC_KEY,br.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(OWN_PRIVATE_KEY)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(OWN_PUBLIC_KEY)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey(PEER_PUBLIC_KEY)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await(0,cipher_1$1.deriveSharedSecret)(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(br){const wr=this.storage.getItem(br.storageKey);return wr?(0,cipher_1$1.importKeyFromHexString)(br.keyType,wr):null}async storeKey(br,wr){const Er=await(0,cipher_1$1.exportKeyToHexString)(br.keyType,wr);this.storage.setItem(br.storageKey,Er)}}SCWKeyManager$1.SCWKeyManager=SCWKeyManager;var SCWStateManager$1={};Object.defineProperty(SCWStateManager$1,"__esModule",{value:!0});SCWStateManager$1.SCWStateManager=void 0;const ScopedLocalStorage_1$5=ScopedLocalStorage$1,ACCOUNTS_KEY="accounts",ACTIVE_CHAIN_STORAGE_KEY="activeChain",AVAILABLE_CHAINS_STORAGE_KEY="availableChains",WALLET_CAPABILITIES_STORAGE_KEY="walletCapabilities";class SCWStateManager{get accounts(){return this._accounts}get activeChain(){return this._activeChain}get walletCapabilities(){return this._walletCapabilities}constructor(br){var wr,Er;this.storage=new ScopedLocalStorage_1$5.ScopedLocalStorage("CBWSDK","SCWStateManager"),this.updateListener=br.updateListener,this.availableChains=this.loadItemFromStorage(AVAILABLE_CHAINS_STORAGE_KEY),this._walletCapabilities=this.loadItemFromStorage(WALLET_CAPABILITIES_STORAGE_KEY);const kr=this.loadItemFromStorage(ACCOUNTS_KEY),jr=this.loadItemFromStorage(ACTIVE_CHAIN_STORAGE_KEY);kr&&this.updateListener.onAccountsUpdate({accounts:kr,source:"storage"}),jr&&this.updateListener.onChainUpdate({chain:jr,source:"storage"}),this._accounts=kr||[],this._activeChain=jr||{id:(Er=(wr=br.appChainIds)===null||wr===void 0?void 0:wr[0])!==null&&Er!==void 0?Er:1}}updateAccounts(br){this._accounts=br,this.storeItemToStorage(ACCOUNTS_KEY,br),this.updateListener.onAccountsUpdate({accounts:br,source:"wallet"})}switchChain(br){var wr;const Er=(wr=this.availableChains)===null||wr===void 0?void 0:wr.find(kr=>kr.id===br);return Er?(Er===this._activeChain||(this._activeChain=Er,this.storeItemToStorage(ACTIVE_CHAIN_STORAGE_KEY,Er),this.updateListener.onChainUpdate({chain:Er,source:"wallet"})),!0):!1}updateAvailableChains(br){if(!br||Object.keys(br).length===0)return;const wr=Object.entries(br).map(([Er,kr])=>({id:Number(Er),rpcUrl:kr}));this.availableChains=wr,this.storeItemToStorage(AVAILABLE_CHAINS_STORAGE_KEY,wr),this.switchChain(this._activeChain.id)}updateWalletCapabilities(br){this._walletCapabilities=br,this.storeItemToStorage(WALLET_CAPABILITIES_STORAGE_KEY,br)}storeItemToStorage(br,wr){this.storage.setItem(br,JSON.stringify(wr))}loadItemFromStorage(br){const wr=this.storage.getItem(br);return wr?JSON.parse(wr):void 0}clear(){this.storage.clear()}}SCWStateManager$1.SCWStateManager=SCWStateManager;Object.defineProperty(SCWSigner$1,"__esModule",{value:!0});SCWSigner$1.SCWSigner=void 0;const SCWKeyManager_1=SCWKeyManager$1,SCWStateManager_1=SCWStateManager$1,error_1$7=error,util_1$a=util$6,cipher_1=cipher;class SCWSigner{constructor(br){this.metadata=br.metadata,this.communicator=br.communicator,this.keyManager=new SCWKeyManager_1.SCWKeyManager,this.stateManager=new SCWStateManager_1.SCWStateManager({appChainIds:this.metadata.appChainIds,updateListener:br.updateListener}),this.handshake=this.handshake.bind(this),this.request=this.request.bind(this),this.createRequestMessage=this.createRequestMessage.bind(this),this.decryptResponseMessage=this.decryptResponseMessage.bind(this)}async handshake(){const br=await this.createRequestMessage({handshake:{method:"eth_requestAccounts",params:this.metadata}}),wr=await this.communicator.postRequestAndWaitForResponse(br);if("failure"in wr.content)throw wr.content.failure;const Er=await(0,cipher_1.importKeyFromHexString)("public",wr.sender);await this.keyManager.setPeerPublicKey(Er);const kr=await this.decryptResponseMessage(wr);this.updateInternalState({method:"eth_requestAccounts"},kr);const jr=kr.result;if("error"in jr)throw jr.error;return this.stateManager.accounts}async request(br){const wr=this.tryLocalHandling(br);if(wr!==void 0){if(wr instanceof Error)throw wr;return wr}await this.communicator.waitForPopupLoaded();const Er=await this.sendEncryptedRequest(br),kr=await this.decryptResponseMessage(Er);this.updateInternalState(br,kr);const jr=kr.result;if("error"in jr)throw jr.error;return jr.value}async disconnect(){this.stateManager.clear(),await this.keyManager.clear()}tryLocalHandling(br){var wr;switch(br.method){case"wallet_switchEthereumChain":{const Er=br.params;if(!Er||!(!((wr=Er[0])===null||wr===void 0)&&wr.chainId))throw error_1$7.standardErrors.rpc.invalidParams();const kr=(0,util_1$a.ensureIntNumber)(Er[0].chainId);return this.stateManager.switchChain(kr)?null:void 0}case"wallet_getCapabilities":{const Er=this.stateManager.walletCapabilities;if(!Er)throw error_1$7.standardErrors.provider.unauthorized("No wallet capabilities found, please disconnect and reconnect");return Er}default:return}}async sendEncryptedRequest(br){const wr=await this.keyManager.getSharedSecret();if(!wr)throw error_1$7.standardErrors.provider.unauthorized("No valid session found, try requestAccounts before other methods");const Er=await(0,cipher_1.encryptContent)({action:br,chainId:this.stateManager.activeChain.id},wr),kr=await this.createRequestMessage({encrypted:Er});return this.communicator.postRequestAndWaitForResponse(kr)}async createRequestMessage(br){const wr=await(0,cipher_1.exportKeyToHexString)("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),sender:wr,content:br,timestamp:new Date}}async decryptResponseMessage(br){const wr=br.content;if("failure"in wr)throw wr.failure;const Er=await this.keyManager.getSharedSecret();if(!Er)throw error_1$7.standardErrors.provider.unauthorized("Invalid session");return(0,cipher_1.decryptContent)(wr.encrypted,Er)}updateInternalState(br,wr){var Er,kr;const jr=(Er=wr.data)===null||Er===void 0?void 0:Er.chains;jr&&this.stateManager.updateAvailableChains(jr);const Br=(kr=wr.data)===null||kr===void 0?void 0:kr.capabilities;Br&&this.stateManager.updateWalletCapabilities(Br);const Wr=wr.result;if(!("error"in Wr))switch(br.method){case"eth_requestAccounts":{const qr=Wr.value;this.stateManager.updateAccounts(qr);break}case"wallet_switchEthereumChain":{if(Wr.value!==null)return;const qr=br.params,Hr=(0,util_1$a.ensureIntNumber)(qr[0].chainId);this.stateManager.switchChain(Hr);break}}}}SCWSigner$1.SCWSigner=SCWSigner;var WalletLinkSigner$1={};const{Transform:Transform$1}=requireReadableBrowser$1();var keccak$2=fr=>class fS extends Transform$1{constructor(wr,Er,kr,jr,Br){super(Br),this._rate=wr,this._capacity=Er,this._delimitedSuffix=kr,this._hashBitLength=jr,this._options=Br,this._state=new fr,this._state.initialize(wr,Er),this._finalized=!1}_transform(wr,Er,kr){let jr=null;try{this.update(wr,Er)}catch(Br){jr=Br}kr(jr)}_flush(wr){let Er=null;try{this.push(this.digest())}catch(kr){Er=kr}wr(Er)}update(wr,Er){if(!Buffer$2.isBuffer(wr)&&typeof wr!="string")throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return Buffer$2.isBuffer(wr)||(wr=Buffer$2.from(wr,Er)),this._state.absorb(wr),this}digest(wr){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);let Er=this._state.squeeze(this._hashBitLength/8);return wr!==void 0&&(Er=Er.toString(wr)),this._resetState(),Er}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const wr=new fS(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(wr._state),wr._finalized=this._finalized,wr}};const{Transform}=requireReadableBrowser$1();var shake=fr=>class hS extends Transform{constructor(wr,Er,kr,jr){super(jr),this._rate=wr,this._capacity=Er,this._delimitedSuffix=kr,this._options=jr,this._state=new fr,this._state.initialize(wr,Er),this._finalized=!1}_transform(wr,Er,kr){let jr=null;try{this.update(wr,Er)}catch(Br){jr=Br}kr(jr)}_flush(){}_read(wr){this.push(this.squeeze(wr))}update(wr,Er){if(!Buffer$2.isBuffer(wr)&&typeof wr!="string")throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return Buffer$2.isBuffer(wr)||(wr=Buffer$2.from(wr,Er)),this._state.absorb(wr),this}squeeze(wr,Er){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));let kr=this._state.squeeze(wr);return Er!==void 0&&(kr=kr.toString(Er)),kr}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const wr=new hS(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(wr._state),wr._finalized=this._finalized,wr}};const createKeccak=keccak$2,createShake=shake;var api=function(fr){const br=createKeccak(fr),wr=createShake(fr);return function(Er,kr){switch(typeof Er=="string"?Er.toLowerCase():Er){case"keccak224":return new br(1152,448,null,224,kr);case"keccak256":return new br(1088,512,null,256,kr);case"keccak384":return new br(832,768,null,384,kr);case"keccak512":return new br(576,1024,null,512,kr);case"sha3-224":return new br(1152,448,6,224,kr);case"sha3-256":return new br(1088,512,6,256,kr);case"sha3-384":return new br(832,768,6,384,kr);case"sha3-512":return new br(576,1024,6,512,kr);case"shake128":return new wr(1344,256,31,kr);case"shake256":return new wr(1088,512,31,kr);default:throw new Error("Invald algorithm: "+Er)}}},keccakStateUnroll={};const P1600_ROUND_CONSTANTS=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648];keccakStateUnroll.p1600=function(fr){for(let br=0;br<24;++br){const wr=fr[0]^fr[10]^fr[20]^fr[30]^fr[40],Er=fr[1]^fr[11]^fr[21]^fr[31]^fr[41],kr=fr[2]^fr[12]^fr[22]^fr[32]^fr[42],jr=fr[3]^fr[13]^fr[23]^fr[33]^fr[43],Br=fr[4]^fr[14]^fr[24]^fr[34]^fr[44],Wr=fr[5]^fr[15]^fr[25]^fr[35]^fr[45],qr=fr[6]^fr[16]^fr[26]^fr[36]^fr[46],Hr=fr[7]^fr[17]^fr[27]^fr[37]^fr[47],Vr=fr[8]^fr[18]^fr[28]^fr[38]^fr[48],Zr=fr[9]^fr[19]^fr[29]^fr[39]^fr[49];let Jr=Vr^(kr<<1|jr>>>31),Qr=Zr^(jr<<1|kr>>>31);const _n=fr[0]^Jr,En=fr[1]^Qr,Cn=fr[10]^Jr,In=fr[11]^Qr,An=fr[20]^Jr,jn=fr[21]^Qr,eo=fr[30]^Jr,ro=fr[31]^Qr,to=fr[40]^Jr,_i=fr[41]^Qr;Jr=wr^(Br<<1|Wr>>>31),Qr=Er^(Wr<<1|Br>>>31);const oo=fr[2]^Jr,io=fr[3]^Qr,co=fr[12]^Jr,so=fr[13]^Qr,no=fr[22]^Jr,Tn=fr[23]^Qr,Gr=fr[32]^Jr,Xr=fr[33]^Qr,Sn=fr[42]^Jr,Rn=fr[43]^Qr;Jr=kr^(qr<<1|Hr>>>31),Qr=jr^(Hr<<1|qr>>>31);const Pn=fr[4]^Jr,On=fr[5]^Qr,Zn=fr[14]^Jr,Nn=fr[15]^Qr,wn=fr[24]^Jr,zn=fr[25]^Qr,fo=fr[34]^Jr,vo=fr[35]^Qr,go=fr[44]^Jr,uo=fr[45]^Qr;Jr=Br^(Vr<<1|Zr>>>31),Qr=Wr^(Zr<<1|Vr>>>31);const lo=fr[6]^Jr,Eo=fr[7]^Qr,mo=fr[16]^Jr,yo=fr[17]^Qr,_o=fr[26]^Jr,Bo=fr[27]^Qr,Lo=fr[36]^Jr,Wo=fr[37]^Qr,na=fr[46]^Jr,qo=fr[47]^Qr;Jr=qr^(wr<<1|Er>>>31),Qr=Hr^(Er<<1|wr>>>31);const ga=fr[8]^Jr,wl=fr[9]^Qr,No=fr[18]^Jr,Fo=fr[19]^Qr,Nl=fr[28]^Jr,Vo=fr[29]^Qr,Uo=fr[38]^Jr,Ol=fr[39]^Qr,$a=fr[48]^Jr,Jo=fr[49]^Qr,Zl=_n,Cl=En,ko=In<<4|Cn>>>28,wo=Cn<<4|In>>>28,bo=An<<3|jn>>>29,Io=jn<<3|An>>>29,Ho=ro<<9|eo>>>23,Do=eo<<9|ro>>>23,zo=to<<18|_i>>>14,nu=_i<<18|to>>>14,Ll=oo<<1|io>>>31,_l=io<<1|oo>>>31,bu=so<<12|co>>>20,xl=co<<12|so>>>20,Tl=no<<10|Tn>>>22,du=Tn<<10|no>>>22,Bl=Xr<<13|Gr>>>19,Il=Gr<<13|Xr>>>19,Eu=Sn<<2|Rn>>>30,Al=Rn<<2|Sn>>>30,Ml=On<<30|Pn>>>2,Tu=Pn<<30|On>>>2,Ul=Zn<<6|Nn>>>26,Sl=Nn<<6|Zn>>>26,_u=zn<<11|wn>>>21,So=wn<<11|zn>>>21,Co=fo<<15|vo>>>17,Ao=vo<<15|fo>>>17,po=uo<<29|go>>>3,Ro=go<<29|uo>>>3,Xo=lo<<28|Eo>>>4,jo=Eo<<28|lo>>>4,Ko=yo<<23|mo>>>9,Wl=mo<<23|yo>>>9,$l=_o<<25|Bo>>>7,El=Bo<<25|_o>>>7,Cu=Lo<<21|Wo>>>11,iu=Wo<<21|Lo>>>11,pu=qo<<24|na>>>8,yu=na<<24|qo>>>8,hu=ga<<27|wl>>>5,mu=wl<<27|ga>>>5,vu=No<<20|Fo>>>12,fu=Fo<<20|No>>>12,gu=Vo<<7|Nl>>>25,ou=Nl<<7|Vo>>>25,su=Uo<<8|Ol>>>24,tu=Ol<<8|Uo>>>24,zl=$a<<14|Jo>>>18,Gl=Jo<<14|$a>>>18;fr[0]=Zl^~bu&_u,fr[1]=Cl^~xl&So,fr[10]=Xo^~vu&bo,fr[11]=jo^~fu&Io,fr[20]=Ll^~Ul&$l,fr[21]=_l^~Sl&El,fr[30]=hu^~ko&Tl,fr[31]=mu^~wo&du,fr[40]=Ml^~Ko&gu,fr[41]=Tu^~Wl&ou,fr[2]=bu^~_u&Cu,fr[3]=xl^~So&iu,fr[12]=vu^~bo&Bl,fr[13]=fu^~Io&Il,fr[22]=Ul^~$l&su,fr[23]=Sl^~El&tu,fr[32]=ko^~Tl&Co,fr[33]=wo^~du&Ao,fr[42]=Ko^~gu&Ho,fr[43]=Wl^~ou&Do,fr[4]=_u^~Cu&zl,fr[5]=So^~iu&Gl,fr[14]=bo^~Bl&po,fr[15]=Io^~Il&Ro,fr[24]=$l^~su&zo,fr[25]=El^~tu&nu,fr[34]=Tl^~Co&pu,fr[35]=du^~Ao&yu,fr[44]=gu^~Ho&Eu,fr[45]=ou^~Do&Al,fr[6]=Cu^~zl&Zl,fr[7]=iu^~Gl&Cl,fr[16]=Bl^~po&Xo,fr[17]=Il^~Ro&jo,fr[26]=su^~zo&Ll,fr[27]=tu^~nu&_l,fr[36]=Co^~pu&hu,fr[37]=Ao^~yu&mu,fr[46]=Ho^~Eu&Ml,fr[47]=Do^~Al&Tu,fr[8]=zl^~Zl&bu,fr[9]=Gl^~Cl&xl,fr[18]=po^~Xo&vu,fr[19]=Ro^~jo&fu,fr[28]=zo^~Ll&Ul,fr[29]=nu^~_l&Sl,fr[38]=pu^~hu&ko,fr[39]=yu^~mu&wo,fr[48]=Eu^~Ml&Ko,fr[49]=Al^~Tu&Wl,fr[0]^=P1600_ROUND_CONSTANTS[br*2],fr[1]^=P1600_ROUND_CONSTANTS[br*2+1]}};const keccakState=keccakStateUnroll;function Keccak(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}Keccak.prototype.initialize=function(fr,br){for(let wr=0;wr<50;++wr)this.state[wr]=0;this.blockSize=fr/8,this.count=0,this.squeezing=!1};Keccak.prototype.absorb=function(fr){for(let br=0;br>>8*(this.count%4)&255,this.count+=1,this.count===this.blockSize&&(keccakState.p1600(this.state),this.count=0);return br};Keccak.prototype.copy=function(fr){for(let br=0;br<50;++br)fr.state[br]=this.state[br];fr.blockSize=this.blockSize,fr.count=this.count,fr.squeezing=this.squeezing};var keccak$1=Keccak,js=api(keccak$1);const createKeccakHash=js;function zeros(fr){return Buffer$2.allocUnsafe(fr).fill(0)}function bitLengthFromBigInt(fr){return fr.toString(2).length}function bufferBEFromBigInt(fr,br){let wr=fr.toString(16);wr.length%2!==0&&(wr="0"+wr);const Er=wr.match(/.{1,2}/g).map(kr=>parseInt(kr,16));for(;Er.length"u")throw new Error("Not an array?");if(wr=parseTypeArray(fr),wr!=="dynamic"&&wr!==0&&br.length>wr)throw new Error("Elements exceed array size: "+wr);kr=[],fr=fr.slice(0,fr.lastIndexOf("[")),typeof br=="string"&&(br=JSON.parse(br));for(jr in br)kr.push(encodeSingle(fr,br[jr]));if(wr==="dynamic"){var Br=encodeSingle("uint256",br.length);kr.unshift(Br)}return Buffer$2.concat(kr)}else{if(fr==="bytes")return br=new Buffer$2(br),kr=Buffer$2.concat([encodeSingle("uint256",br.length),br]),br.length%32!==0&&(kr=Buffer$2.concat([kr,util$3.zeros(32-br.length%32)])),kr;if(fr.startsWith("bytes")){if(wr=parseTypeN(fr),wr<1||wr>32)throw new Error("Invalid bytes width: "+wr);return util$3.setLengthRight(br,32)}else if(fr.startsWith("uint")){if(wr=parseTypeN(fr),wr%8||wr<8||wr>256)throw new Error("Invalid uint width: "+wr);Er=parseNumber(br);const Wr=util$3.bitLengthFromBigInt(Er);if(Wr>wr)throw new Error("Supplied uint exceeds width: "+wr+" vs "+Wr);if(Er<0)throw new Error("Supplied uint is negative");return util$3.bufferBEFromBigInt(Er,32)}else if(fr.startsWith("int")){if(wr=parseTypeN(fr),wr%8||wr<8||wr>256)throw new Error("Invalid int width: "+wr);Er=parseNumber(br);const Wr=util$3.bitLengthFromBigInt(Er);if(Wr>wr)throw new Error("Supplied int exceeds width: "+wr+" vs "+Wr);const qr=util$3.twosFromBigInt(Er,256);return util$3.bufferBEFromBigInt(qr,32)}else if(fr.startsWith("ufixed")){if(wr=parseTypeNxM(fr),Er=parseNumber(br),Er<0)throw new Error("Supplied ufixed is negative");return encodeSingle("uint256",Er*BigInt(2)**BigInt(wr[1]))}else if(fr.startsWith("fixed"))return wr=parseTypeNxM(fr),encodeSingle("int256",parseNumber(br)*BigInt(2)**BigInt(wr[1]))}throw new Error("Unsupported or invalid type: "+fr)}function isDynamic(fr){return fr==="string"||fr==="bytes"||parseTypeArray(fr)==="dynamic"}function isArray(fr){return fr.lastIndexOf("]")===fr.length-1}function rawEncode(fr,br){var wr=[],Er=[],kr=32*fr.length;for(var jr in fr){var Br=elementaryName(fr[jr]),Wr=br[jr],qr=encodeSingle(Br,Wr);isDynamic(Br)?(wr.push(encodeSingle("uint256",kr)),Er.push(qr),kr+=qr.length):wr.push(qr)}return Buffer$2.concat(wr.concat(Er))}function solidityPack(fr,br){if(fr.length!==br.length)throw new Error("Number of types are not matching the values");for(var wr,Er,kr=[],jr=0;jr32)throw new Error("Invalid bytes width: "+wr);kr.push(util$3.setLengthRight(Wr,wr))}else if(Br.startsWith("uint")){if(wr=parseTypeN(Br),wr%8||wr<8||wr>256)throw new Error("Invalid uint width: "+wr);Er=parseNumber(Wr);const qr=util$3.bitLengthFromBigInt(Er);if(qr>wr)throw new Error("Supplied uint exceeds width: "+wr+" vs "+qr);kr.push(util$3.bufferBEFromBigInt(Er,wr/8))}else if(Br.startsWith("int")){if(wr=parseTypeN(Br),wr%8||wr<8||wr>256)throw new Error("Invalid int width: "+wr);Er=parseNumber(Wr);const qr=util$3.bitLengthFromBigInt(Er);if(qr>wr)throw new Error("Supplied int exceeds width: "+wr+" vs "+qr);const Hr=util$3.twosFromBigInt(Er,wr);kr.push(util$3.bufferBEFromBigInt(Hr,wr/8))}else throw new Error("Unsupported or invalid type: "+Br)}return Buffer$2.concat(kr)}function soliditySHA3(fr,br){return util$3.keccak(solidityPack(fr,br))}var abi$1={rawEncode,solidityPack,soliditySHA3};const util$2=util$4,abi=abi$1,TYPED_MESSAGE_SCHEMA={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"]},TypedDataUtils={encodeData(fr,br,wr,Er=!0){const kr=["bytes32"],jr=[this.hashType(fr,wr)];if(Er){const Br=(Wr,qr,Hr)=>{if(wr[qr]!==void 0)return["bytes32",Hr==null?"0x0000000000000000000000000000000000000000000000000000000000000000":util$2.keccak(this.encodeData(qr,Hr,wr,Er))];if(Hr===void 0)throw new Error(`missing value for field ${Wr} of type ${qr}`);if(qr==="bytes")return["bytes32",util$2.keccak(Hr)];if(qr==="string")return typeof Hr=="string"&&(Hr=Buffer$2.from(Hr,"utf8")),["bytes32",util$2.keccak(Hr)];if(qr.lastIndexOf("]")===qr.length-1){const Vr=qr.slice(0,qr.lastIndexOf("[")),Zr=Hr.map(Jr=>Br(Wr,Vr,Jr));return["bytes32",util$2.keccak(abi.rawEncode(Zr.map(([Jr])=>Jr),Zr.map(([,Jr])=>Jr)))]}return[qr,Hr]};for(const Wr of wr[fr]){const[qr,Hr]=Br(Wr.name,Wr.type,br[Wr.name]);kr.push(qr),jr.push(Hr)}}else for(const Br of wr[fr]){let Wr=br[Br.name];if(Wr!==void 0)if(Br.type==="bytes")kr.push("bytes32"),Wr=util$2.keccak(Wr),jr.push(Wr);else if(Br.type==="string")kr.push("bytes32"),typeof Wr=="string"&&(Wr=Buffer$2.from(Wr,"utf8")),Wr=util$2.keccak(Wr),jr.push(Wr);else if(wr[Br.type]!==void 0)kr.push("bytes32"),Wr=util$2.keccak(this.encodeData(Br.type,Wr,wr,Er)),jr.push(Wr);else{if(Br.type.lastIndexOf("]")===Br.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");kr.push(Br.type),jr.push(Wr)}}return abi.rawEncode(kr,jr)},encodeType(fr,br){let wr="",Er=this.findTypeDependencies(fr,br).filter(kr=>kr!==fr);Er=[fr].concat(Er.sort());for(const kr of Er){if(!br[kr])throw new Error("No type definition specified: "+kr);wr+=kr+"("+br[kr].map(({name:Br,type:Wr})=>Wr+" "+Br).join(",")+")"}return wr},findTypeDependencies(fr,br,wr=[]){if(fr=fr.match(/^\w*/)[0],wr.includes(fr)||br[fr]===void 0)return wr;wr.push(fr);for(const Er of br[fr])for(const kr of this.findTypeDependencies(Er.type,br,wr))!wr.includes(kr)&&wr.push(kr);return wr},hashStruct(fr,br,wr,Er=!0){return util$2.keccak(this.encodeData(fr,br,wr,Er))},hashType(fr,br){return util$2.keccak(this.encodeType(fr,br))},sanitizeData(fr){const br={};for(const wr in TYPED_MESSAGE_SCHEMA.properties)fr[wr]&&(br[wr]=fr[wr]);return br.types&&(br.types=Object.assign({EIP712Domain:[]},br.types)),br},hash(fr,br=!0){const wr=this.sanitizeData(fr),Er=[Buffer$2.from("1901","hex")];return Er.push(this.hashStruct("EIP712Domain",wr.domain,wr.types,br)),wr.primaryType!=="EIP712Domain"&&Er.push(this.hashStruct(wr.primaryType,wr.message,wr.types,br)),util$2.keccak(Buffer$2.concat(Er))}};var ethEip712Util={TYPED_MESSAGE_SCHEMA,TypedDataUtils,hashForSignTypedDataLegacy:function(fr){return typedSignatureHashLegacy(fr.data)},hashForSignTypedData_v3:function(fr){return TypedDataUtils.hash(fr.data,!1)},hashForSignTypedData_v4:function(fr){return TypedDataUtils.hash(fr.data)}};function typedSignatureHashLegacy(fr){const br=new Error("Expect argument to be non-empty array");if(typeof fr!="object"||!fr.length)throw br;const wr=fr.map(function(jr){return jr.type==="bytes"?util$2.toBuffer(jr.value):jr.value}),Er=fr.map(function(jr){return jr.type}),kr=fr.map(function(jr){if(!jr.name)throw br;return jr.type+" "+jr.name});return abi.soliditySHA3(["bytes32","bytes32"],[abi.soliditySHA3(new Array(fr.length).fill("string"),kr),abi.soliditySHA3(Er,wr)])}var constants$1={};Object.defineProperty(constants$1,"__esModule",{value:!0});constants$1.APP_VERSION_KEY=constants$1.LOCAL_STORAGE_ADDRESSES_KEY=constants$1.WALLET_USER_NAME_KEY=void 0;constants$1.WALLET_USER_NAME_KEY="walletUsername";constants$1.LOCAL_STORAGE_ADDRESSES_KEY="Addresses";constants$1.APP_VERSION_KEY="AppVersion";var RelayEventManager$1={};Object.defineProperty(RelayEventManager$1,"__esModule",{value:!0});RelayEventManager$1.RelayEventManager=void 0;const util_1$9=util$6;class RelayEventManager{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const br=this._nextRequestId,wr=(0,util_1$9.prepend0x)(br.toString(16));return this.callbacks.get(wr)&&this.callbacks.delete(wr),br}}RelayEventManager$1.RelayEventManager=RelayEventManager;var WalletLinkRelay$1={},WalletLinkConnection$1={},WalletLinkCipher$1={};Object.defineProperty(WalletLinkCipher$1,"__esModule",{value:!0});WalletLinkCipher$1.WalletLinkCipher=void 0;const util_1$8=util$6;class WalletLinkCipher{constructor(br){this.secret=br}async encrypt(br){const wr=this.secret;if(wr.length!==64)throw Error("secret must be 256 bits");const Er=crypto.getRandomValues(new Uint8Array(12)),kr=await crypto.subtle.importKey("raw",(0,util_1$8.hexStringToUint8Array)(wr),{name:"aes-gcm"},!1,["encrypt","decrypt"]),jr=new TextEncoder,Br=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:Er},kr,jr.encode(br)),Wr=16,qr=Br.slice(Br.byteLength-Wr),Hr=Br.slice(0,Br.byteLength-Wr),Vr=new Uint8Array(qr),Zr=new Uint8Array(Hr),Jr=new Uint8Array([...Er,...Vr,...Zr]);return(0,util_1$8.uint8ArrayToHex)(Jr)}async decrypt(br){const wr=this.secret;if(wr.length!==64)throw Error("secret must be 256 bits");return new Promise((Er,kr)=>{(async function(){const jr=await crypto.subtle.importKey("raw",(0,util_1$8.hexStringToUint8Array)(wr),{name:"aes-gcm"},!1,["encrypt","decrypt"]),Br=(0,util_1$8.hexStringToUint8Array)(br),Wr=Br.slice(0,12),qr=Br.slice(12,28),Hr=Br.slice(28),Vr=new Uint8Array([...Hr,...qr]),Zr={name:"AES-GCM",iv:new Uint8Array(Wr)};try{const Jr=await window.crypto.subtle.decrypt(Zr,jr,Vr),Qr=new TextDecoder;Er(Qr.decode(Jr))}catch(Jr){kr(Jr)}})()})}}WalletLinkCipher$1.WalletLinkCipher=WalletLinkCipher;var WalletLinkHTTP$1={};Object.defineProperty(WalletLinkHTTP$1,"__esModule",{value:!0});WalletLinkHTTP$1.WalletLinkHTTP=void 0;class WalletLinkHTTP{constructor(br,wr,Er){this.linkAPIUrl=br,this.sessionId=wr;const kr=`${wr}:${Er}`;this.auth=`Basic ${btoa(kr)}`}async markUnseenEventsAsSeen(br){return Promise.all(br.map(wr=>fetch(`${this.linkAPIUrl}/events/${wr.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(wr=>console.error("Unabled to mark event as failed:",wr))}async fetchUnseenEvents(){var br;const wr=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(wr.ok){const{events:Er,error:kr}=await wr.json();if(kr)throw new Error(`Check unseen events failed: ${kr}`);const jr=(br=Er==null?void 0:Er.filter(Br=>Br.event==="Web3Response").map(Br=>({type:"Event",sessionId:this.sessionId,eventId:Br.id,event:Br.event,data:Br.data})))!==null&&br!==void 0?br:[];return this.markUnseenEventsAsSeen(jr),jr}throw new Error(`Check unseen events failed: ${wr.status}`)}}WalletLinkHTTP$1.WalletLinkHTTP=WalletLinkHTTP;var WalletLinkWebSocket$1={};Object.defineProperty(WalletLinkWebSocket$1,"__esModule",{value:!0});WalletLinkWebSocket$1.WalletLinkWebSocket=WalletLinkWebSocket$1.ConnectionState=void 0;var ConnectionState;(function(fr){fr[fr.DISCONNECTED=0]="DISCONNECTED",fr[fr.CONNECTING=1]="CONNECTING",fr[fr.CONNECTED=2]="CONNECTED"})(ConnectionState||(WalletLinkWebSocket$1.ConnectionState=ConnectionState={}));class WalletLinkWebSocket{setConnectionStateListener(br){this.connectionStateListener=br}setIncomingDataListener(br){this.incomingDataListener=br}constructor(br,wr=WebSocket){this.WebSocketClass=wr,this.webSocket=null,this.pendingData=[],this.url=br.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((br,wr)=>{var Er;let kr;try{this.webSocket=kr=new this.WebSocketClass(this.url)}catch(jr){wr(jr);return}(Er=this.connectionStateListener)===null||Er===void 0||Er.call(this,ConnectionState.CONNECTING),kr.onclose=jr=>{var Br;this.clearWebSocket(),wr(new Error(`websocket error ${jr.code}: ${jr.reason}`)),(Br=this.connectionStateListener)===null||Br===void 0||Br.call(this,ConnectionState.DISCONNECTED)},kr.onopen=jr=>{var Br;br(),(Br=this.connectionStateListener)===null||Br===void 0||Br.call(this,ConnectionState.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(qr=>this.sendData(qr)),this.pendingData=[])},kr.onmessage=jr=>{var Br,Wr;if(jr.data==="h")(Br=this.incomingDataListener)===null||Br===void 0||Br.call(this,{type:"Heartbeat"});else try{const qr=JSON.parse(jr.data);(Wr=this.incomingDataListener)===null||Wr===void 0||Wr.call(this,qr)}catch{}}})}disconnect(){var br;const{webSocket:wr}=this;if(wr){this.clearWebSocket(),(br=this.connectionStateListener)===null||br===void 0||br.call(this,ConnectionState.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{wr.close()}catch{}}}sendData(br){const{webSocket:wr}=this;if(!wr){this.pendingData.push(br),this.connect();return}wr.send(br)}clearWebSocket(){const{webSocket:br}=this;br&&(this.webSocket=null,br.onclose=null,br.onerror=null,br.onmessage=null,br.onopen=null)}}WalletLinkWebSocket$1.WalletLinkWebSocket=WalletLinkWebSocket;Object.defineProperty(WalletLinkConnection$1,"__esModule",{value:!0});WalletLinkConnection$1.WalletLinkConnection=void 0;const constants_1$4=constants$1,WalletLinkCipher_1=WalletLinkCipher$1,WalletLinkHTTP_1=WalletLinkHTTP$1,WalletLinkWebSocket_1=WalletLinkWebSocket$1,type_1$1=type$3,HEARTBEAT_INTERVAL=1e4,REQUEST_TIMEOUT=6e4;class WalletLinkConnection{constructor({session:br,linkAPIUrl:wr,listener:Er,WebSocketClass:kr=WebSocket}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=(0,type_1$1.IntNumber)(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=Br=>{if(!Br)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",qr=>Br.JsonRpcUrl&&this.handleChainUpdated(qr,Br.JsonRpcUrl)]]).forEach((qr,Hr)=>{const Vr=Br[Hr];Vr!==void 0&&qr(Vr)})},this.handleDestroyed=Br=>{var Wr;Br==="1"&&((Wr=this.listener)===null||Wr===void 0||Wr.resetAndReload())},this.handleAccountUpdated=async Br=>{var Wr;{const qr=await this.cipher.decrypt(Br);(Wr=this.listener)===null||Wr===void 0||Wr.accountUpdated(qr)}},this.handleMetadataUpdated=async(Br,Wr)=>{var qr;{const Hr=await this.cipher.decrypt(Wr);(qr=this.listener)===null||qr===void 0||qr.metadataUpdated(Br,Hr)}},this.handleWalletUsernameUpdated=async Br=>{this.handleMetadataUpdated(constants_1$4.WALLET_USER_NAME_KEY,Br)},this.handleAppVersionUpdated=async Br=>{this.handleMetadataUpdated(constants_1$4.APP_VERSION_KEY,Br)},this.handleChainUpdated=async(Br,Wr)=>{var qr;{const Hr=await this.cipher.decrypt(Br),Vr=await this.cipher.decrypt(Wr);(qr=this.listener)===null||qr===void 0||qr.chainUpdated(Hr,Vr)}},this.session=br,this.cipher=new WalletLinkCipher_1.WalletLinkCipher(br.secret),this.listener=Er;const jr=new WalletLinkWebSocket_1.WalletLinkWebSocket(`${wr}/rpc`,kr);jr.setConnectionStateListener(async Br=>{let Wr=!1;switch(Br){case WalletLinkWebSocket_1.ConnectionState.DISCONNECTED:if(!this.destroyed){const qr=async()=>{await new Promise(Hr=>setTimeout(Hr,5e3)),this.destroyed||jr.connect().catch(()=>{qr()})};qr()}break;case WalletLinkWebSocket_1.ConnectionState.CONNECTED:try{await this.authenticate(),this.sendIsLinked(),this.sendGetSessionConfig(),Wr=!0}catch{}this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},HEARTBEAT_INTERVAL),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case WalletLinkWebSocket_1.ConnectionState.CONNECTING:break}this.connected!==Wr&&(this.connected=Wr)}),jr.setIncomingDataListener(Br=>{var Wr;switch(Br.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const qr=Br.type==="IsLinkedOK"?Br.linked:void 0;this.linked=qr||Br.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(Br.metadata);break}case"Event":{this.handleIncomingEvent(Br);break}}Br.id!==void 0&&((Wr=this.requestResolutions.get(Br.id))===null||Wr===void 0||Wr(Br))}),this.ws=jr,this.http=new WalletLinkHTTP_1.WalletLinkHTTP(wr,br.id,br.key)}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}destroy(){this.destroyed=!0,this.ws.disconnect(),this.listener=void 0}get isDestroyed(){return this.destroyed}get connected(){return this._connected}set connected(br){var wr;this._connected=br,br&&((wr=this.onceConnected)===null||wr===void 0||wr.call(this))}setOnceConnected(br){return new Promise(wr=>{this.connected?br().then(wr):this.onceConnected=()=>{br().then(wr),this.onceConnected=void 0}})}get linked(){return this._linked}set linked(br){var wr,Er;this._linked=br,br&&((wr=this.onceLinked)===null||wr===void 0||wr.call(this)),(Er=this.listener)===null||Er===void 0||Er.linkedUpdated(br)}setOnceLinked(br){return new Promise(wr=>{this.linked?br().then(wr):this.onceLinked=()=>{br().then(wr),this.onceLinked=void 0}})}async handleIncomingEvent(br){var wr;if(!(br.type!=="Event"||br.event!=="Web3Response")){const Er=await this.cipher.decrypt(br.data),kr=JSON.parse(Er);if(kr.type!=="WEB3_RESPONSE")return;(wr=this.listener)===null||wr===void 0||wr.handleWeb3ResponseMessage(kr)}}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(br=>setTimeout(br,250));try{await this.fetchUnseenEventsAPI()}catch(br){console.error("Unable to check for unseen events",br)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(wr=>this.handleIncomingEvent(wr))}async setSessionMetadata(br,wr){const Er={type:"SetSessionConfig",id:(0,type_1$1.IntNumber)(this.nextReqId++),sessionId:this.session.id,metadata:{[br]:wr}};return this.setOnceConnected(async()=>{const kr=await this.makeRequest(Er);if(kr.type==="Fail")throw new Error(kr.error||"failed to set session metadata")})}async publishEvent(br,wr,Er=!1){const kr=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},wr),{origin:location.origin,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),jr={type:"PublishEvent",id:(0,type_1$1.IntNumber)(this.nextReqId++),sessionId:this.session.id,event:br,data:kr,callWebhook:Er};return this.setOnceLinked(async()=>{const Br=await this.makeRequest(jr);if(Br.type==="Fail")throw new Error(Br.error||"failed to publish event");return Br.eventId})}sendData(br){this.ws.sendData(JSON.stringify(br))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>HEARTBEAT_INTERVAL*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(br,wr=REQUEST_TIMEOUT){const Er=br.id;this.sendData(br);let kr;return Promise.race([new Promise((jr,Br)=>{kr=window.setTimeout(()=>{Br(new Error(`request ${Er} timed out`))},wr)}),new Promise(jr=>{this.requestResolutions.set(Er,Br=>{clearTimeout(kr),jr(Br),this.requestResolutions.delete(Er)})})])}async authenticate(){const br={type:"HostSession",id:(0,type_1$1.IntNumber)(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key},wr=await this.makeRequest(br);if(wr.type==="Fail")throw new Error(wr.error||"failed to authenticate")}sendIsLinked(){const br={type:"IsLinked",id:(0,type_1$1.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(br)}sendGetSessionConfig(){const br={type:"GetSessionConfig",id:(0,type_1$1.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(br)}}WalletLinkConnection$1.WalletLinkConnection=WalletLinkConnection;var WalletLinkSession$1={};Object.defineProperty(WalletLinkSession$1,"__esModule",{value:!0});WalletLinkSession$1.WalletLinkSession=void 0;const sha_js_1=requireSha_js(),util_1$7=util$6,STORAGE_KEY_SESSION_ID="session:id",STORAGE_KEY_SESSION_SECRET="session:secret",STORAGE_KEY_SESSION_LINKED="session:linked";class WalletLinkSession{constructor(br,wr,Er,kr){this._storage=br,this._id=wr||(0,util_1$7.randomBytesHex)(16),this._secret=Er||(0,util_1$7.randomBytesHex)(32),this._key=new sha_js_1.sha256().update(`${this._id}, ${this._secret} WalletLink`).digest("hex"),this._linked=!!kr}static load(br){const wr=br.getItem(STORAGE_KEY_SESSION_ID),Er=br.getItem(STORAGE_KEY_SESSION_LINKED),kr=br.getItem(STORAGE_KEY_SESSION_SECRET);return wr&&kr?new WalletLinkSession(br,wr,kr,Er==="1"):null}get id(){return this._id}get secret(){return this._secret}get key(){return this._key}get linked(){return this._linked}set linked(br){this._linked=br,this.persistLinked()}save(){return this._storage.setItem(STORAGE_KEY_SESSION_ID,this._id),this._storage.setItem(STORAGE_KEY_SESSION_SECRET,this._secret),this.persistLinked(),this}persistLinked(){this._storage.setItem(STORAGE_KEY_SESSION_LINKED,this._linked?"1":"0")}}WalletLinkSession$1.WalletLinkSession=WalletLinkSession;var util$1={};Object.defineProperty(util$1,"__esModule",{value:!0});util$1.isDarkMode=util$1.isMobileWeb=util$1.getLocation=util$1.createQrUrl=void 0;function createQrUrl(fr,br,wr,Er,kr,jr){const Br=Er?"parent-id":"id",Wr=new URLSearchParams({[Br]:fr,secret:br,server:wr,v:kr,chainId:jr.toString()}).toString();return`${wr}/#/link?${Wr}`}util$1.createQrUrl=createQrUrl;function isInIFrame(){try{return window.frameElement!==null}catch{return!1}}function getLocation(){try{return isInIFrame()&&window.top?window.top.location:window.location}catch{return window.location}}util$1.getLocation=getLocation;function isMobileWeb(){var fr;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((fr=window==null?void 0:window.navigator)===null||fr===void 0?void 0:fr.userAgent)}util$1.isMobileWeb=isMobileWeb;function isDarkMode(){var fr,br;return(br=(fr=window==null?void 0:window.matchMedia)===null||fr===void 0?void 0:fr.call(window,"(prefers-color-scheme: dark)").matches)!==null&&br!==void 0?br:!1}util$1.isDarkMode=isDarkMode;var WalletLinkRelayUI$1={},cssReset={},cssResetCss={};Object.defineProperty(cssResetCss,"__esModule",{value:!0});cssResetCss.default='@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}';var __importDefault$4=commonjsGlobal&&commonjsGlobal.__importDefault||function(fr){return fr&&fr.__esModule?fr:{default:fr}};Object.defineProperty(cssReset,"__esModule",{value:!0});cssReset.injectCssReset=void 0;const cssReset_css_1=__importDefault$4(cssResetCss);function injectCssReset(){const fr=document.createElement("style");fr.type="text/css",fr.appendChild(document.createTextNode(cssReset_css_1.default)),document.documentElement.appendChild(fr)}cssReset.injectCssReset=injectCssReset;var Snackbar={};function r$2(fr){var br,wr,Er="";if(typeof fr=="string"||typeof fr=="number")Er+=fr;else if(typeof fr=="object")if(Array.isArray(fr))for(br=0;br2&&(Br.children=arguments.length>3?n.call(arguments,2):wr),typeof fr=="function"&&fr.defaultProps!=null)for(jr in fr.defaultProps)Br[jr]===void 0&&(Br[jr]=fr.defaultProps[jr]);return g$1(fr,Br,Er,kr,null)}function g$1(fr,br,wr,Er,kr){var jr={type:fr,props:br,key:wr,ref:Er,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:kr??++u$1,__i:-1,__u:0};return kr==null&&l$1.vnode!=null&&l$1.vnode(jr),jr}function m$1(){return{current:null}}function b$1(fr){return fr.children}function k$1(fr,br){this.props=fr,this.context=br}function x$1(fr,br){if(br==null)return fr.__?x$1(fr.__,fr.__i+1):null;for(var wr;brbr&&i$2.sort(f$2));M.__r=0}function P$1(fr,br,wr,Er,kr,jr,Br,Wr,qr,Hr,Vr){var Zr,Jr,Qr,_n,En,Cn=Er&&Er.__k||v$1,In=br.length;for(wr.__d=qr,$(wr,br,Cn),qr=wr.__d,Zr=0;Zr0?g$1(kr.type,kr.props,kr.key,kr.ref?kr.ref:null,kr.__v):kr).__=fr,kr.__b=fr.__b+1,jr=null,(Wr=kr.__i=L(kr,wr,Br,Vr))!==-1&&(Vr--,(jr=wr[Wr])&&(jr.__u|=131072)),jr==null||jr.__v===null?(Wr==-1&&Zr--,typeof kr.type!="function"&&(kr.__u|=65536)):Wr!==Br&&(Wr==Br-1?Zr--:Wr==Br+1?Zr++:(Wr>Br?Zr--:Zr++,kr.__u|=65536))):kr=fr.__k[Er]=null;if(Vr)for(Er=0;Er(qr!=null&&!(131072&qr.__u)?1:0))for(;Br>=0||Wr=0){if((qr=br[Br])&&!(131072&qr.__u)&&kr==qr.key&&jr===qr.type)return Br;Br--}if(Wr2&&(Wr.children=arguments.length>3?n.call(arguments,2):wr),g$1(fr.type,Wr,Er||fr.key,kr||fr.ref,null)}function G(fr,br){var wr={__c:br="__cC"+a$1++,__:fr,Consumer:function(Er,kr){return Er.children(kr)},Provider:function(Er){var kr,jr;return this.getChildContext||(kr=new Set,(jr={})[br]=this,this.getChildContext=function(){return jr},this.componentWillUnmount=function(){kr=null},this.shouldComponentUpdate=function(Br){this.props.value!==Br.value&&kr.forEach(function(Wr){Wr.__e=!0,S(Wr)})},this.sub=function(Br){kr.add(Br);var Wr=Br.componentWillUnmount;Br.componentWillUnmount=function(){kr&&kr.delete(Br),Wr&&Wr.call(Br)}}),Er.children}};return wr.Provider.__=wr.Consumer.contextType=wr}n=v$1.slice,l$1={__e:function(fr,br,wr,Er){for(var kr,jr,Br;br=br.__;)if((kr=br.__c)&&!kr.__)try{if((jr=kr.constructor)&&jr.getDerivedStateFromError!=null&&(kr.setState(jr.getDerivedStateFromError(fr)),Br=kr.__d),kr.componentDidCatch!=null&&(kr.componentDidCatch(fr,Er||{}),Br=kr.__d),Br)return kr.__E=kr}catch(Wr){fr=Wr}throw fr}},u$1=0,t$1=function(fr){return fr!=null&&fr.constructor==null},k$1.prototype.setState=function(fr,br){var wr;wr=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=d$1({},this.state),typeof fr=="function"&&(fr=fr(d$1({},wr),this.props)),fr&&d$1(wr,fr),fr!=null&&this.__v&&(br&&this._sb.push(br),S(this))},k$1.prototype.forceUpdate=function(fr){this.__v&&(this.__e=!0,fr&&this.__h.push(fr),S(this))},k$1.prototype.render=b$1,i$2=[],r$1=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,f$2=function(fr,br){return fr.__v.__b-br.__v.__b},M.__r=0,e$1=0,c$1=F$1(!1),s$1=F$1(!0),a$1=0;const preact_module=Object.freeze(Object.defineProperty({__proto__:null,Component:k$1,Fragment:b$1,cloneElement:D$1,createContext:G,createElement:_$1,createRef:m$1,h:_$1,hydrate:B$1,get isValidElement(){return t$1},get options(){return l$1},render:q$1,toChildArray:H},Symbol.toStringTag,{value:"Module"})),require$$1=getAugmentedNamespace(preact_module);var t,r,u,i$1,o=0,f$1=[],c=l$1,e=c.__b,a=c.__r,v=c.diffed,l=c.__c,m=c.unmount,s=c.__;function d(fr,br){c.__h&&c.__h(r,fr,o||br),o=0;var wr=r.__H||(r.__H={__:[],__h:[]});return fr>=wr.__.length&&wr.__.push({}),wr.__[fr]}function h(fr){return o=1,p(D,fr)}function p(fr,br,wr){var Er=d(t++,2);if(Er.t=fr,!Er.__c&&(Er.__=[wr?wr(br):D(void 0,br),function(Wr){var qr=Er.__N?Er.__N[0]:Er.__[0],Hr=Er.t(qr,Wr);qr!==Hr&&(Er.__N=[Hr,Er.__[1]],Er.__c.setState({}))}],Er.__c=r,!r.u)){var kr=function(Wr,qr,Hr){if(!Er.__c.__H)return!0;var Vr=Er.__c.__H.__.filter(function(Jr){return!!Jr.__c});if(Vr.every(function(Jr){return!Jr.__N}))return!jr||jr.call(this,Wr,qr,Hr);var Zr=Er.__c.props!==Wr;return Vr.forEach(function(Jr){if(Jr.__N){var Qr=Jr.__[0];Jr.__=Jr.__N,Jr.__N=void 0,Qr!==Jr.__[0]&&(Zr=!0)}}),jr&&jr.call(this,Wr,qr,Hr)||Zr};r.u=!0;var jr=r.shouldComponentUpdate,Br=r.componentWillUpdate;r.componentWillUpdate=function(Wr,qr,Hr){if(this.__e){var Vr=jr;jr=void 0,kr(Wr,qr,Hr),jr=Vr}Br&&Br.call(this,Wr,qr,Hr)},r.shouldComponentUpdate=kr}return Er.__N||Er.__}function y(fr,br){var wr=d(t++,3);!c.__s&&C(wr.__H,br)&&(wr.__=fr,wr.i=br,r.__H.__h.push(wr))}function _(fr,br){var wr=d(t++,4);!c.__s&&C(wr.__H,br)&&(wr.__=fr,wr.i=br,r.__h.push(wr))}function A(fr){return o=5,T(function(){return{current:fr}},[])}function F(fr,br,wr){o=6,_(function(){return typeof fr=="function"?(fr(br()),function(){return fr(null)}):fr?(fr.current=br(),function(){return fr.current=null}):void 0},wr==null?wr:wr.concat(fr))}function T(fr,br){var wr=d(t++,7);return C(wr.__H,br)&&(wr.__=fr(),wr.__H=br,wr.__h=fr),wr.__}function q(fr,br){return o=8,T(function(){return fr},br)}function x(fr){var br=r.context[fr.__c],wr=d(t++,9);return wr.c=fr,br?(wr.__==null&&(wr.__=!0,br.sub(r)),br.props.value):fr.__}function P(fr,br){c.useDebugValue&&c.useDebugValue(br?br(fr):fr)}function b(fr){var br=d(t++,10),wr=h();return br.__=fr,r.componentDidCatch||(r.componentDidCatch=function(Er,kr){br.__&&br.__(Er,kr),wr[1](Er)}),[wr[0],function(){wr[1](void 0)}]}function g(){var fr=d(t++,11);if(!fr.__){for(var br=r.__v;br!==null&&!br.__m&&br.__!==null;)br=br.__;var wr=br.__m||(br.__m=[0,0]);fr.__="P"+wr[0]+"-"+wr[1]++}return fr.__}function j(){for(var fr;fr=f$1.shift();)if(fr.__P&&fr.__H)try{fr.__H.__h.forEach(z),fr.__H.__h.forEach(B),fr.__H.__h=[]}catch(br){fr.__H.__h=[],c.__e(br,fr.__v)}}c.__b=function(fr){r=null,e&&e(fr)},c.__=function(fr,br){fr&&br.__k&&br.__k.__m&&(fr.__m=br.__k.__m),s&&s(fr,br)},c.__r=function(fr){a&&a(fr),t=0;var br=(r=fr.__c).__H;br&&(u===r?(br.__h=[],r.__h=[],br.__.forEach(function(wr){wr.__N&&(wr.__=wr.__N),wr.i=wr.__N=void 0})):(br.__h.forEach(z),br.__h.forEach(B),br.__h=[],t=0)),u=r},c.diffed=function(fr){v&&v(fr);var br=fr.__c;br&&br.__H&&(br.__H.__h.length&&(f$1.push(br)!==1&&i$1===c.requestAnimationFrame||((i$1=c.requestAnimationFrame)||w)(j)),br.__H.__.forEach(function(wr){wr.i&&(wr.__H=wr.i),wr.i=void 0})),u=r=null},c.__c=function(fr,br){br.some(function(wr){try{wr.__h.forEach(z),wr.__h=wr.__h.filter(function(Er){return!Er.__||B(Er)})}catch(Er){br.some(function(kr){kr.__h&&(kr.__h=[])}),br=[],c.__e(Er,wr.__v)}}),l&&l(fr,br)},c.unmount=function(fr){m&&m(fr);var br,wr=fr.__c;wr&&wr.__H&&(wr.__H.__.forEach(function(Er){try{z(Er)}catch(kr){br=kr}}),wr.__H=void 0,br&&c.__e(br,wr.__v))};var k=typeof requestAnimationFrame=="function";function w(fr){var br,wr=function(){clearTimeout(Er),k&&cancelAnimationFrame(br),setTimeout(fr)},Er=setTimeout(wr,100);k&&(br=requestAnimationFrame(wr))}function z(fr){var br=r,wr=fr.__c;typeof wr=="function"&&(fr.__c=void 0,wr()),r=br}function B(fr){var br=r;fr.__c=fr.__(),r=br}function C(fr,br){return!fr||fr.length!==br.length||br.some(function(wr,Er){return wr!==fr[Er]})}function D(fr,br){return typeof br=="function"?br(fr):br}const hooks_module=Object.freeze(Object.defineProperty({__proto__:null,useCallback:q,useContext:x,useDebugValue:P,useEffect:y,useErrorBoundary:b,useId:g,useImperativeHandle:F,useLayoutEffect:_,useMemo:T,useReducer:p,useRef:A,useState:h},Symbol.toStringTag,{value:"Module"})),require$$2$1=getAugmentedNamespace(hooks_module);var SnackbarCss={};Object.defineProperty(SnackbarCss,"__esModule",{value:!0});SnackbarCss.default=".-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}";(function(fr){var br=commonjsGlobal&&commonjsGlobal.__importDefault||function(Jr){return Jr&&Jr.__esModule?Jr:{default:Jr}};Object.defineProperty(fr,"__esModule",{value:!0}),fr.SnackbarInstance=fr.SnackbarContainer=fr.Snackbar=void 0;const wr=br(require$$0$1),Er=require$$1,kr=require$$2$1,jr=util$1,Br=br(SnackbarCss),Wr="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",qr="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class Hr{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=(0,jr.isDarkMode)()}attach(Qr){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",Qr.appendChild(this.root),this.render()}presentItem(Qr){const _n=this.nextItemKey++;return this.items.set(_n,Qr),this.render(),()=>{this.items.delete(_n),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&(0,Er.render)((0,Er.h)("div",null,(0,Er.h)(fr.SnackbarContainer,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([Qr,_n])=>(0,Er.h)(fr.SnackbarInstance,Object.assign({},_n,{key:Qr}))))),this.root)}}fr.Snackbar=Hr;const Vr=Jr=>(0,Er.h)("div",{class:(0,wr.default)("-cbwsdk-snackbar-container")},(0,Er.h)("style",null,Br.default),(0,Er.h)("div",{class:"-cbwsdk-snackbar"},Jr.children));fr.SnackbarContainer=Vr;const Zr=({autoExpand:Jr,message:Qr,menuItems:_n})=>{const[En,Cn]=(0,kr.useState)(!0),[In,An]=(0,kr.useState)(Jr??!1);(0,kr.useEffect)(()=>{const eo=[window.setTimeout(()=>{Cn(!1)},1),window.setTimeout(()=>{An(!0)},1e4)];return()=>{eo.forEach(window.clearTimeout)}});const jn=()=>{An(!In)};return(0,Er.h)("div",{class:(0,wr.default)("-cbwsdk-snackbar-instance",En&&"-cbwsdk-snackbar-instance-hidden",In&&"-cbwsdk-snackbar-instance-expanded")},(0,Er.h)("div",{class:"-cbwsdk-snackbar-instance-header",onClick:jn},(0,Er.h)("img",{src:Wr,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",(0,Er.h)("div",{class:"-cbwsdk-snackbar-instance-header-message"},Qr),(0,Er.h)("div",{class:"-gear-container"},!In&&(0,Er.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,Er.h)("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),(0,Er.h)("img",{src:qr,class:"-gear-icon",title:"Expand"}))),_n&&_n.length>0&&(0,Er.h)("div",{class:"-cbwsdk-snackbar-instance-menu"},_n.map((eo,ro)=>(0,Er.h)("div",{class:(0,wr.default)("-cbwsdk-snackbar-instance-menu-item",eo.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:eo.onClick,key:ro},(0,Er.h)("svg",{width:eo.svgWidth,height:eo.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,Er.h)("path",{"fill-rule":eo.defaultFillRule,"clip-rule":eo.defaultClipRule,d:eo.path,fill:"#AAAAAA"})),(0,Er.h)("span",{class:(0,wr.default)("-cbwsdk-snackbar-instance-menu-item-info",eo.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},eo.info)))))};fr.SnackbarInstance=Zr})(Snackbar);Object.defineProperty(WalletLinkRelayUI$1,"__esModule",{value:!0});WalletLinkRelayUI$1.WalletLinkRelayUI=void 0;const cssReset_1$1=cssReset,Snackbar_1$1=Snackbar;class WalletLinkRelayUI{constructor(){this.attached=!1,this.snackbar=new Snackbar_1$1.Snackbar}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const br=document.documentElement,wr=document.createElement("div");wr.className="-cbwsdk-css-reset",br.appendChild(wr),this.snackbar.attach(wr),this.attached=!0,(0,cssReset_1$1.injectCssReset)()}showConnecting(br){let wr;return br.isUnlinkedErrorState?wr={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:br.onResetConnection}]}:wr={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:br.onCancel},{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:br.onResetConnection}]},this.snackbar.presentItem(wr)}}WalletLinkRelayUI$1.WalletLinkRelayUI=WalletLinkRelayUI;var WLMobileRelayUI$1={},RedirectDialog$1={},RedirectDialogCss={};Object.defineProperty(RedirectDialogCss,"__esModule",{value:!0});RedirectDialogCss.default=".-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}";var __importDefault$3=commonjsGlobal&&commonjsGlobal.__importDefault||function(fr){return fr&&fr.__esModule?fr:{default:fr}};Object.defineProperty(RedirectDialog$1,"__esModule",{value:!0});RedirectDialog$1.RedirectDialog=void 0;const clsx_1=__importDefault$3(require$$0$1),preact_1=require$$1,cssReset_1=cssReset,Snackbar_1=Snackbar,util_1$6=util$1,RedirectDialog_css_1=__importDefault$3(RedirectDialogCss);class RedirectDialog{constructor(){this.root=null,this.darkMode=(0,util_1$6.isDarkMode)()}attach(){const br=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",br.appendChild(this.root),(0,cssReset_1.injectCssReset)()}present(br){this.render(br)}clear(){this.render(null)}render(br){this.root&&((0,preact_1.render)(null,this.root),br&&(0,preact_1.render)((0,preact_1.h)(RedirectDialogContent,Object.assign({},br,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}RedirectDialog$1.RedirectDialog=RedirectDialog;const RedirectDialogContent=({title:fr,buttonText:br,darkMode:wr,onButtonClick:Er,onDismiss:kr})=>{const jr=wr?"dark":"light";return(0,preact_1.h)(Snackbar_1.SnackbarContainer,{darkMode:wr},(0,preact_1.h)("div",{class:"-cbwsdk-redirect-dialog"},(0,preact_1.h)("style",null,RedirectDialog_css_1.default),(0,preact_1.h)("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:kr}),(0,preact_1.h)("div",{class:(0,clsx_1.default)("-cbwsdk-redirect-dialog-box",jr)},(0,preact_1.h)("p",null,fr),(0,preact_1.h)("button",{onClick:Er},br))))};var constants={};Object.defineProperty(constants,"__esModule",{value:!0});constants.CBW_MOBILE_DEEPLINK_URL=constants.WALLETLINK_URL=constants.CB_KEYS_URL=void 0;constants.CB_KEYS_URL="https://keys.coinbase.com/connect";constants.WALLETLINK_URL="https://www.walletlink.org";constants.CBW_MOBILE_DEEPLINK_URL="https://go.cb-w.com/walletlink";Object.defineProperty(WLMobileRelayUI$1,"__esModule",{value:!0});WLMobileRelayUI$1.WLMobileRelayUI=void 0;const RedirectDialog_1=RedirectDialog$1,util_1$5=util$1,constants_1$3=constants;class WLMobileRelayUI{constructor(){this.attached=!1,this.redirectDialog=new RedirectDialog_1.RedirectDialog}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(br){const wr=new URL(constants_1$3.CBW_MOBILE_DEEPLINK_URL);wr.searchParams.append("redirect_url",(0,util_1$5.getLocation)().href),br&&wr.searchParams.append("wl_url",br);const Er=document.createElement("a");Er.target="cbw-opener",Er.href=wr.href,Er.rel="noreferrer noopener",Er.click()}openCoinbaseWalletDeeplink(br){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(br)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(br)},99)}showConnecting(br){return()=>{this.redirectDialog.clear()}}}WLMobileRelayUI$1.WLMobileRelayUI=WLMobileRelayUI;Object.defineProperty(WalletLinkRelay$1,"__esModule",{value:!0});WalletLinkRelay$1.WalletLinkRelay=void 0;const WalletLinkConnection_1=WalletLinkConnection$1,constants_1$2=constants$1,RelayEventManager_1$1=RelayEventManager$1,WalletLinkSession_1=WalletLinkSession$1,Web3Response_1$1=Web3Response,util_1$4=util$1,WalletLinkRelayUI_1=WalletLinkRelayUI$1,WLMobileRelayUI_1=WLMobileRelayUI$1,error_1$6=error,util_2$1=util$6,ScopedLocalStorage_1$4=ScopedLocalStorage$1;class WalletLinkRelay{constructor(br){this.accountsCallback=null,this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.chainCallback=null,this.dappDefaultChain=1,this.isMobileWeb=(0,util_1$4.isMobileWeb)(),this.appName="",this.appLogoUrl=null,this.linkedUpdated=jr=>{this.isLinked=jr;const Br=this.storage.getItem(constants_1$2.LOCAL_STORAGE_ADDRESSES_KEY);if(jr&&(this._session.linked=jr),this.isUnlinkedErrorState=!1,Br){const Wr=Br.split(" "),qr=this.storage.getItem("IsStandaloneSigning")==="true";Wr[0]!==""&&!jr&&this._session.linked&&!qr&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(jr,Br)=>{this.storage.setItem(jr,Br)},this.chainUpdated=(jr,Br)=>{this.chainCallbackParams.chainId===jr&&this.chainCallbackParams.jsonRpcUrl===Br||(this.chainCallbackParams={chainId:jr,jsonRpcUrl:Br},this.chainCallback&&this.chainCallback(jr,Br))},this.accountUpdated=jr=>{this.accountsCallback&&this.accountsCallback([jr]),WalletLinkRelay.accountRequestCallbackIds.size>0&&(Array.from(WalletLinkRelay.accountRequestCallbackIds.values()).forEach(Br=>{const Wr={type:"WEB3_RESPONSE",id:Br,response:{method:"requestEthereumAccounts",result:[jr]}};this.invokeCallback(Object.assign(Object.assign({},Wr),{id:Br}))}),WalletLinkRelay.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=br.linkAPIUrl,this.storage=br.storage;const{session:wr,ui:Er,connection:kr}=this.subscribe();this._session=wr,this.connection=kr,this.relayEventManager=new RelayEventManager_1$1.RelayEventManager,this.ui=Er}subscribe(){const br=WalletLinkSession_1.WalletLinkSession.load(this.storage)||new WalletLinkSession_1.WalletLinkSession(this.storage).save(),{linkAPIUrl:wr}=this,Er=new WalletLinkConnection_1.WalletLinkConnection({session:br,linkAPIUrl:wr,listener:this}),kr=this.isMobileWeb?new WLMobileRelayUI_1.WLMobileRelayUI:new WalletLinkRelayUI_1.WalletLinkRelayUI;return Er.connect(),{session:br,ui:kr,connection:Er}}attachUI(){this.ui.attach()}resetAndReload(){Promise.race([this.connection.setSessionMetadata("__destroyed","1"),new Promise(br=>setTimeout(()=>br(null),1e3))]).then(()=>{this.connection.destroy();const br=WalletLinkSession_1.WalletLinkSession.load(this.storage);(br==null?void 0:br.id)===this._session.id&&ScopedLocalStorage_1$4.ScopedLocalStorage.clearAll(),document.location.reload()}).catch(br=>{})}setAppInfo(br,wr){this.appName=br,this.appLogoUrl=wr}getStorageItem(br){return this.storage.getItem(br)}setStorageItem(br,wr){this.storage.setItem(br,wr)}signEthereumMessage(br,wr,Er,kr){return this.sendRequest({method:"signEthereumMessage",params:{message:(0,util_2$1.hexStringFromBuffer)(br,!0),address:wr,addPrefix:Er,typedDataJson:kr||null}})}ethereumAddressFromSignedMessage(br,wr,Er){return this.sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:(0,util_2$1.hexStringFromBuffer)(br,!0),signature:(0,util_2$1.hexStringFromBuffer)(wr,!0),addPrefix:Er}})}signEthereumTransaction(br){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:br.fromAddress,toAddress:br.toAddress,weiValue:(0,util_2$1.bigIntStringFromBigInt)(br.weiValue),data:(0,util_2$1.hexStringFromBuffer)(br.data,!0),nonce:br.nonce,gasPriceInWei:br.gasPriceInWei?(0,util_2$1.bigIntStringFromBigInt)(br.gasPriceInWei):null,maxFeePerGas:br.gasPriceInWei?(0,util_2$1.bigIntStringFromBigInt)(br.gasPriceInWei):null,maxPriorityFeePerGas:br.gasPriceInWei?(0,util_2$1.bigIntStringFromBigInt)(br.gasPriceInWei):null,gasLimit:br.gasLimit?(0,util_2$1.bigIntStringFromBigInt)(br.gasLimit):null,chainId:br.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(br){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:br.fromAddress,toAddress:br.toAddress,weiValue:(0,util_2$1.bigIntStringFromBigInt)(br.weiValue),data:(0,util_2$1.hexStringFromBuffer)(br.data,!0),nonce:br.nonce,gasPriceInWei:br.gasPriceInWei?(0,util_2$1.bigIntStringFromBigInt)(br.gasPriceInWei):null,maxFeePerGas:br.maxFeePerGas?(0,util_2$1.bigIntStringFromBigInt)(br.maxFeePerGas):null,maxPriorityFeePerGas:br.maxPriorityFeePerGas?(0,util_2$1.bigIntStringFromBigInt)(br.maxPriorityFeePerGas):null,gasLimit:br.gasLimit?(0,util_2$1.bigIntStringFromBigInt)(br.gasLimit):null,chainId:br.chainId,shouldSubmit:!0}})}submitEthereumTransaction(br,wr){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:(0,util_2$1.hexStringFromBuffer)(br,!0),chainId:wr}})}scanQRCode(br){return this.sendRequest({method:"scanQRCode",params:{regExp:br}})}getWalletLinkSession(){return this._session}genericRequest(br,wr){return this.sendRequest({method:"generic",params:{action:wr,data:br}})}sendGenericMessage(br){return this.sendRequest(br)}sendRequest(br){let wr=null;const Er=(0,util_2$1.randomBytesHex)(8),kr=jr=>{this.publishWeb3RequestCanceledEvent(Er),this.handleErrorResponse(Er,br.method,jr),wr==null||wr()};return new Promise((jr,Br)=>{wr=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:kr,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(Er,Wr=>{if(wr==null||wr(),(0,Web3Response_1$1.isErrorResponse)(Wr))return Br(new Error(Wr.errorMessage));jr(Wr)}),this.publishWeb3RequestEvent(Er,br)})}setAccountsCallback(br){this.accountsCallback=br}setChainCallback(br){this.chainCallback=br}setDappDefaultChainCallback(br){this.dappDefaultChain=br}publishWeb3RequestEvent(br,wr){const Er={type:"WEB3_REQUEST",id:br,request:wr};this.publishEvent("Web3Request",Er,!0).then(kr=>{}).catch(kr=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:Er.id,response:{method:wr.method,errorMessage:kr.message}})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(wr.method)}openCoinbaseWalletDeeplink(br){if(this.ui instanceof WLMobileRelayUI_1.WLMobileRelayUI)switch(br){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink();break}}publishWeb3RequestCanceledEvent(br){const wr={type:"WEB3_REQUEST_CANCELED",id:br};this.publishEvent("Web3RequestCanceled",wr,!1).then()}publishEvent(br,wr,Er){return this.connection.publishEvent(br,wr,Er)}handleWeb3ResponseMessage(br){const{response:wr}=br;if(wr.method==="requestEthereumAccounts"){WalletLinkRelay.accountRequestCallbackIds.forEach(Er=>this.invokeCallback(Object.assign(Object.assign({},br),{id:Er}))),WalletLinkRelay.accountRequestCallbackIds.clear();return}this.invokeCallback(br)}handleErrorResponse(br,wr,Er){var kr;const jr=(kr=Er==null?void 0:Er.message)!==null&&kr!==void 0?kr:"Unspecified error message.";this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:br,response:{method:wr,errorMessage:jr}})}invokeCallback(br){const wr=this.relayEventManager.callbacks.get(br.id);wr&&(wr(br.response),this.relayEventManager.callbacks.delete(br.id))}requestEthereumAccounts(){const br={method:"requestEthereumAccounts",params:{appName:this.appName,appLogoUrl:this.appLogoUrl||null}},wr=(0,util_2$1.randomBytesHex)(8);return new Promise((Er,kr)=>{this.relayEventManager.callbacks.set(wr,jr=>{if((0,Web3Response_1$1.isErrorResponse)(jr))return kr(new Error(jr.errorMessage));Er(jr)}),WalletLinkRelay.accountRequestCallbackIds.add(wr),this.publishWeb3RequestEvent(wr,br)})}watchAsset(br,wr,Er,kr,jr,Br){const Wr={method:"watchAsset",params:{type:br,options:{address:wr,symbol:Er,decimals:kr,image:jr},chainId:Br}};let qr=null;const Hr=(0,util_2$1.randomBytesHex)(8),Vr=Zr=>{this.publishWeb3RequestCanceledEvent(Hr),this.handleErrorResponse(Hr,Wr.method,Zr),qr==null||qr()};return qr=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:Vr,onResetConnection:this.resetAndReload}),new Promise((Zr,Jr)=>{this.relayEventManager.callbacks.set(Hr,Qr=>{if(qr==null||qr(),(0,Web3Response_1$1.isErrorResponse)(Qr))return Jr(new Error(Qr.errorMessage));Zr(Qr)}),this.publishWeb3RequestEvent(Hr,Wr)})}addEthereumChain(br,wr,Er,kr,jr,Br){const Wr={method:"addEthereumChain",params:{chainId:br,rpcUrls:wr,blockExplorerUrls:kr,chainName:jr,iconUrls:Er,nativeCurrency:Br}};let qr=null;const Hr=(0,util_2$1.randomBytesHex)(8),Vr=Zr=>{this.publishWeb3RequestCanceledEvent(Hr),this.handleErrorResponse(Hr,Wr.method,Zr),qr==null||qr()};return qr=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:Vr,onResetConnection:this.resetAndReload}),new Promise((Zr,Jr)=>{this.relayEventManager.callbacks.set(Hr,Qr=>{if(qr==null||qr(),(0,Web3Response_1$1.isErrorResponse)(Qr))return Jr(new Error(Qr.errorMessage));Zr(Qr)}),this.publishWeb3RequestEvent(Hr,Wr)})}switchEthereumChain(br,wr){const Er={method:"switchEthereumChain",params:Object.assign({chainId:br},{address:wr})},kr=(0,util_2$1.randomBytesHex)(8);return new Promise((jr,Br)=>{this.relayEventManager.callbacks.set(kr,Wr=>{if((0,Web3Response_1$1.isErrorResponse)(Wr)&&Wr.errorCode)return Br(error_1$6.standardErrors.provider.custom({code:Wr.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if((0,Web3Response_1$1.isErrorResponse)(Wr))return Br(new Error(Wr.errorMessage));jr(Wr)}),this.publishWeb3RequestEvent(kr,Er)})}}WalletLinkRelay$1.WalletLinkRelay=WalletLinkRelay;WalletLinkRelay.accountRequestCallbackIds=new Set;var __importDefault$2=commonjsGlobal&&commonjsGlobal.__importDefault||function(fr){return fr&&fr.__esModule?fr:{default:fr}};Object.defineProperty(WalletLinkSigner$1,"__esModule",{value:!0});WalletLinkSigner$1.WalletLinkSigner=void 0;const eth_eip712_util_1=__importDefault$2(ethEip712Util),constants_1$1=constants$1,RelayEventManager_1=RelayEventManager$1,Web3Response_1=Web3Response,WalletLinkRelay_1=WalletLinkRelay$1,constants_2=constants,error_1$5=error,util_1$3=util$6,ScopedLocalStorage_1$3=ScopedLocalStorage$1,DEFAULT_CHAIN_ID_KEY="DefaultChainId",DEFAULT_JSON_RPC_URL="DefaultJsonRpcUrl";class WalletLinkSigner{constructor(br){var wr,Er;this._relay=null,this._addresses=[],this.hasMadeFirstChainChangedEmission=!1;const{appName:kr,appLogoUrl:jr}=br.metadata;this._appName=kr,this._appLogoUrl=jr,this._storage=new ScopedLocalStorage_1$3.ScopedLocalStorage("walletlink",constants_2.WALLETLINK_URL),this.updateListener=br.updateListener,this._relayEventManager=new RelayEventManager_1.RelayEventManager,this._jsonRpcUrlFromOpts="";const Br=this._storage.getItem(constants_1$1.LOCAL_STORAGE_ADDRESSES_KEY);if(Br){const qr=Br.split(" ");qr[0]!==""&&(this._addresses=qr.map(Hr=>(0,util_1$3.ensureAddressString)(Hr)),(wr=this.updateListener)===null||wr===void 0||wr.onAccountsUpdate({accounts:this._addresses,source:"storage"}))}this._storage.getItem(DEFAULT_CHAIN_ID_KEY)&&((Er=this.updateListener)===null||Er===void 0||Er.onChainUpdate({chain:{id:this.getChainId(),rpcUrl:this.jsonRpcUrl},source:"storage"}),this.hasMadeFirstChainChangedEmission=!0),this.initializeRelay()}getSession(){const br=this.initializeRelay(),{id:wr,secret:Er}=br.getWalletLinkSession();return{id:wr,secret:Er}}async handshake(){return await this.request({method:"eth_requestAccounts"})}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var br;return(br=this._storage.getItem(DEFAULT_JSON_RPC_URL))!==null&&br!==void 0?br:this._jsonRpcUrlFromOpts}set jsonRpcUrl(br){this._storage.setItem(DEFAULT_JSON_RPC_URL,br)}updateProviderInfo(br,wr){var Er;this.jsonRpcUrl=br;const kr=this.getChainId();this._storage.setItem(DEFAULT_CHAIN_ID_KEY,wr.toString(10)),((0,util_1$3.ensureIntNumber)(wr)!==kr||!this.hasMadeFirstChainChangedEmission)&&((Er=this.updateListener)===null||Er===void 0||Er.onChainUpdate({chain:{id:wr,rpcUrl:br},source:"wallet"}),this.hasMadeFirstChainChangedEmission=!0)}async watchAsset(br,wr,Er,kr,jr,Br){const qr=await this.initializeRelay().watchAsset(br,wr,Er,kr,jr,Br==null?void 0:Br.toString());return(0,Web3Response_1.isErrorResponse)(qr)?!1:!!qr.result}async addEthereumChain(br,wr,Er,kr,jr,Br){var Wr,qr;if((0,util_1$3.ensureIntNumber)(br)===this.getChainId())return!1;const Hr=this.initializeRelay();this._isAuthorized()||await Hr.requestEthereumAccounts();const Vr=await Hr.addEthereumChain(br.toString(),wr,jr,Er,kr,Br);return(0,Web3Response_1.isErrorResponse)(Vr)?!1:(((Wr=Vr.result)===null||Wr===void 0?void 0:Wr.isApproved)===!0&&this.updateProviderInfo(wr[0],br),((qr=Vr.result)===null||qr===void 0?void 0:qr.isApproved)===!0)}async switchEthereumChain(br){const Er=await this.initializeRelay().switchEthereumChain(br.toString(10),this.selectedAddress||void 0);if((0,Web3Response_1.isErrorResponse)(Er)){if(!Er.errorCode)return;throw Er.errorCode===error_1$5.standardErrorCodes.provider.unsupportedChain?error_1$5.standardErrors.provider.unsupportedChain():error_1$5.standardErrors.provider.custom({message:Er.errorMessage,code:Er.errorCode})}const kr=Er.result;kr.isApproved&&kr.rpcUrl.length>0&&this.updateProviderInfo(kr.rpcUrl,br)}async disconnect(){this._relay&&this._relay.resetAndReload(),this._storage.clear()}async request(br){try{return this._request(br).catch(wr=>{throw wr})}catch(wr){return Promise.reject(wr)}}async _request(br){if(!br||typeof br!="object"||Array.isArray(br))throw error_1$5.standardErrors.rpc.invalidRequest({message:"Expected a single, non-array, object argument.",data:br});const{method:wr,params:Er}=br;if(typeof wr!="string"||wr.length===0)throw error_1$5.standardErrors.rpc.invalidRequest({message:"'args.method' must be a non-empty string.",data:br});if(Er!==void 0&&!Array.isArray(Er)&&(typeof Er!="object"||Er===null))throw error_1$5.standardErrors.rpc.invalidRequest({message:"'args.params' must be an object or array if provided.",data:br});const kr=Er===void 0?[]:Er,jr=this._relayEventManager.makeRequestId();return(await this._sendRequestAsync({method:wr,params:kr,jsonrpc:"2.0",id:jr})).result}_setAddresses(br,wr){var Er;if(!Array.isArray(br))throw new Error("addresses is not an array");const kr=br.map(jr=>(0,util_1$3.ensureAddressString)(jr));JSON.stringify(kr)!==JSON.stringify(this._addresses)&&(this._addresses=kr,(Er=this.updateListener)===null||Er===void 0||Er.onAccountsUpdate({accounts:kr,source:"wallet"}),this._storage.setItem(constants_1$1.LOCAL_STORAGE_ADDRESSES_KEY,kr.join(" ")))}_sendRequestAsync(br){return new Promise((wr,Er)=>{try{const kr=this._handleSynchronousMethods(br);if(kr!==void 0)return wr({jsonrpc:"2.0",id:br.id,result:kr})}catch(kr){return Er(kr)}this._handleAsynchronousMethods(br).then(kr=>kr&&wr(Object.assign(Object.assign({},kr),{id:br.id}))).catch(kr=>Er(kr))})}_handleSynchronousMethods(br){const{method:wr}=br;switch(wr){case"eth_accounts":return this._eth_accounts();case"eth_coinbase":return this._eth_coinbase();case"net_version":return this._net_version();case"eth_chainId":return this._eth_chainId();default:return}}async _handleAsynchronousMethods(br){const{method:wr}=br,Er=br.params||[];switch(wr){case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_sign":return this._eth_sign(Er);case"eth_ecRecover":return this._eth_ecRecover(Er);case"personal_sign":return this._personal_sign(Er);case"personal_ecRecover":return this._personal_ecRecover(Er);case"eth_signTransaction":return this._eth_signTransaction(Er);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(Er);case"eth_sendTransaction":return this._eth_sendTransaction(Er);case"eth_signTypedData_v1":return this._eth_signTypedData_v1(Er);case"eth_signTypedData_v2":return this._throwUnsupportedMethodError();case"eth_signTypedData_v3":return this._eth_signTypedData_v3(Er);case"eth_signTypedData_v4":case"eth_signTypedData":return this._eth_signTypedData_v4(Er);case"wallet_addEthereumChain":return this._wallet_addEthereumChain(Er);case"wallet_switchEthereumChain":return this._wallet_switchEthereumChain(Er);case"wallet_watchAsset":return this._wallet_watchAsset(Er);default:return this._throwUnsupportedMethodError()}}_isKnownAddress(br){try{const wr=(0,util_1$3.ensureAddressString)(br);return this._addresses.map(kr=>(0,util_1$3.ensureAddressString)(kr)).includes(wr)}catch{}return!1}_ensureKnownAddress(br){if(!this._isKnownAddress(br))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(br){const wr=br.from?(0,util_1$3.ensureAddressString)(br.from):this.selectedAddress;if(!wr)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(wr);const Er=br.to?(0,util_1$3.ensureAddressString)(br.to):null,kr=br.value!=null?(0,util_1$3.ensureBigInt)(br.value):BigInt(0),jr=br.data?(0,util_1$3.ensureBuffer)(br.data):Buffer$2.alloc(0),Br=br.nonce!=null?(0,util_1$3.ensureIntNumber)(br.nonce):null,Wr=br.gasPrice!=null?(0,util_1$3.ensureBigInt)(br.gasPrice):null,qr=br.maxFeePerGas!=null?(0,util_1$3.ensureBigInt)(br.maxFeePerGas):null,Hr=br.maxPriorityFeePerGas!=null?(0,util_1$3.ensureBigInt)(br.maxPriorityFeePerGas):null,Vr=br.gas!=null?(0,util_1$3.ensureBigInt)(br.gas):null,Zr=br.chainId?(0,util_1$3.ensureIntNumber)(br.chainId):this.getChainId();return{fromAddress:wr,toAddress:Er,weiValue:kr,data:jr,nonce:Br,gasPriceInWei:Wr,maxFeePerGas:qr,maxPriorityFeePerGas:Hr,gasLimit:Vr,chainId:Zr}}_isAuthorized(){return this._addresses.length>0}_requireAuthorization(){if(!this._isAuthorized())throw error_1$5.standardErrors.provider.unauthorized({})}_throwUnsupportedMethodError(){throw error_1$5.standardErrors.provider.unsupportedMethod({})}async _signEthereumMessage(br,wr,Er,kr){this._ensureKnownAddress(wr);try{const Br=await this.initializeRelay().signEthereumMessage(br,wr,Er,kr);if((0,Web3Response_1.isErrorResponse)(Br))throw new Error(Br.errorMessage);return{jsonrpc:"2.0",id:0,result:Br.result}}catch(jr){throw typeof jr.message=="string"&&jr.message.match(/(denied|rejected)/i)?error_1$5.standardErrors.provider.userRejectedRequest("User denied message signature"):jr}}async _ethereumAddressFromSignedMessage(br,wr,Er){const jr=await this.initializeRelay().ethereumAddressFromSignedMessage(br,wr,Er);if((0,Web3Response_1.isErrorResponse)(jr))throw new Error(jr.errorMessage);return{jsonrpc:"2.0",id:0,result:jr.result}}_eth_accounts(){return[...this._addresses]}_eth_coinbase(){return this.selectedAddress||null}_net_version(){return this.getChainId().toString(10)}_eth_chainId(){return(0,util_1$3.hexStringFromIntNumber)(this.getChainId())}getChainId(){const br=this._storage.getItem(DEFAULT_CHAIN_ID_KEY);if(!br)return(0,util_1$3.ensureIntNumber)(1);const wr=parseInt(br,10);return(0,util_1$3.ensureIntNumber)(wr)}async _eth_requestAccounts(){if(this._isAuthorized())return Promise.resolve({jsonrpc:"2.0",id:0,result:this._addresses});let br;try{if(br=await this.initializeRelay().requestEthereumAccounts(),(0,Web3Response_1.isErrorResponse)(br))throw new Error(br.errorMessage)}catch(wr){throw typeof wr.message=="string"&&wr.message.match(/(denied|rejected)/i)?error_1$5.standardErrors.provider.userRejectedRequest("User denied account authorization"):wr}if(!br.result)throw new Error("accounts received is empty");return this._setAddresses(br.result),{jsonrpc:"2.0",id:0,result:this._addresses}}_eth_sign(br){this._requireAuthorization();const wr=(0,util_1$3.ensureAddressString)(br[0]),Er=(0,util_1$3.ensureBuffer)(br[1]);return this._signEthereumMessage(Er,wr,!1)}_eth_ecRecover(br){const wr=(0,util_1$3.ensureBuffer)(br[0]),Er=(0,util_1$3.ensureBuffer)(br[1]);return this._ethereumAddressFromSignedMessage(wr,Er,!1)}_personal_sign(br){this._requireAuthorization();const wr=(0,util_1$3.ensureBuffer)(br[0]),Er=(0,util_1$3.ensureAddressString)(br[1]);return this._signEthereumMessage(wr,Er,!0)}_personal_ecRecover(br){const wr=(0,util_1$3.ensureBuffer)(br[0]),Er=(0,util_1$3.ensureBuffer)(br[1]);return this._ethereumAddressFromSignedMessage(wr,Er,!0)}async _eth_signTransaction(br){this._requireAuthorization();const wr=this._prepareTransactionParams(br[0]||{});try{const kr=await this.initializeRelay().signEthereumTransaction(wr);if((0,Web3Response_1.isErrorResponse)(kr))throw new Error(kr.errorMessage);return{jsonrpc:"2.0",id:0,result:kr.result}}catch(Er){throw typeof Er.message=="string"&&Er.message.match(/(denied|rejected)/i)?error_1$5.standardErrors.provider.userRejectedRequest("User denied transaction signature"):Er}}async _eth_sendRawTransaction(br){const wr=(0,util_1$3.ensureBuffer)(br[0]),kr=await this.initializeRelay().submitEthereumTransaction(wr,this.getChainId());if((0,Web3Response_1.isErrorResponse)(kr))throw new Error(kr.errorMessage);return{jsonrpc:"2.0",id:0,result:kr.result}}async _eth_sendTransaction(br){this._requireAuthorization();const wr=this._prepareTransactionParams(br[0]||{});try{const kr=await this.initializeRelay().signAndSubmitEthereumTransaction(wr);if((0,Web3Response_1.isErrorResponse)(kr))throw new Error(kr.errorMessage);return{jsonrpc:"2.0",id:0,result:kr.result}}catch(Er){throw typeof Er.message=="string"&&Er.message.match(/(denied|rejected)/i)?error_1$5.standardErrors.provider.userRejectedRequest("User denied transaction signature"):Er}}async _eth_signTypedData_v1(br){this._requireAuthorization();const wr=(0,util_1$3.ensureParsedJSONObject)(br[0]),Er=(0,util_1$3.ensureAddressString)(br[1]);this._ensureKnownAddress(Er);const kr=eth_eip712_util_1.default.hashForSignTypedDataLegacy({data:wr}),jr=JSON.stringify(wr,null,2);return this._signEthereumMessage(kr,Er,!1,jr)}async _eth_signTypedData_v3(br){this._requireAuthorization();const wr=(0,util_1$3.ensureAddressString)(br[0]),Er=(0,util_1$3.ensureParsedJSONObject)(br[1]);this._ensureKnownAddress(wr);const kr=eth_eip712_util_1.default.hashForSignTypedData_v3({data:Er}),jr=JSON.stringify(Er,null,2);return this._signEthereumMessage(kr,wr,!1,jr)}async _eth_signTypedData_v4(br){this._requireAuthorization();const wr=(0,util_1$3.ensureAddressString)(br[0]),Er=(0,util_1$3.ensureParsedJSONObject)(br[1]);this._ensureKnownAddress(wr);const kr=eth_eip712_util_1.default.hashForSignTypedData_v4({data:Er}),jr=JSON.stringify(Er,null,2);return this._signEthereumMessage(kr,wr,!1,jr)}async _wallet_addEthereumChain(br){var wr,Er,kr,jr;const Br=br[0];if(((wr=Br.rpcUrls)===null||wr===void 0?void 0:wr.length)===0)return{jsonrpc:"2.0",id:0,error:{code:2,message:"please pass in at least 1 rpcUrl"}};if(!Br.chainName||Br.chainName.trim()==="")throw error_1$5.standardErrors.rpc.invalidParams("chainName is a required field");if(!Br.nativeCurrency)throw error_1$5.standardErrors.rpc.invalidParams("nativeCurrency is a required field");const Wr=parseInt(Br.chainId,16);return await this.addEthereumChain(Wr,(Er=Br.rpcUrls)!==null&&Er!==void 0?Er:[],(kr=Br.blockExplorerUrls)!==null&&kr!==void 0?kr:[],Br.chainName,(jr=Br.iconUrls)!==null&&jr!==void 0?jr:[],Br.nativeCurrency)?{jsonrpc:"2.0",id:0,result:null}:{jsonrpc:"2.0",id:0,error:{code:2,message:"unable to add ethereum chain"}}}async _wallet_switchEthereumChain(br){const wr=br[0];return await this.switchEthereumChain(parseInt(wr.chainId,16)),{jsonrpc:"2.0",id:0,result:null}}async _wallet_watchAsset(br){const wr=Array.isArray(br)?br[0]:br;if(!wr.type)throw error_1$5.standardErrors.rpc.invalidParams("Type is required");if((wr==null?void 0:wr.type)!=="ERC20")throw error_1$5.standardErrors.rpc.invalidParams(`Asset of type '${wr.type}' is not supported`);if(!(wr!=null&&wr.options))throw error_1$5.standardErrors.rpc.invalidParams("Options are required");if(!(wr!=null&&wr.options.address))throw error_1$5.standardErrors.rpc.invalidParams("Address is required");const Er=this.getChainId(),{address:kr,symbol:jr,image:Br,decimals:Wr}=wr.options;return{jsonrpc:"2.0",id:0,result:await this.watchAsset(wr.type,kr,jr,Wr,Br,Er)}}initializeRelay(){if(!this._relay){const br=new WalletLinkRelay_1.WalletLinkRelay({linkAPIUrl:constants_2.WALLETLINK_URL,storage:this._storage});br.setAppInfo(this._appName,this._appLogoUrl),br.attachUI(),br.setAccountsCallback((wr,Er)=>this._setAddresses(wr,Er)),br.setChainCallback((wr,Er)=>{this.updateProviderInfo(Er,parseInt(wr,10))}),this._relay=br}return this._relay}}WalletLinkSigner$1.WalletLinkSigner=WalletLinkSigner;var provider={};Object.defineProperty(provider,"__esModule",{value:!0});provider.checkErrorForInvalidRequestArgs=provider.getCoinbaseInjectedProvider=provider.getCoinbaseInjectedSigner=provider.fetchRPCRequest=void 0;const version_1$2=version$8,error_1$4=error;async function fetchRPCRequest(fr,br){if(!br.rpcUrl)throw error_1$4.standardErrors.rpc.internal("No RPC URL set for chain");const wr=Object.assign(Object.assign({},fr),{jsonrpc:"2.0",id:crypto.randomUUID()});return(await(await window.fetch(br.rpcUrl,{method:"POST",body:JSON.stringify(wr),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":version_1$2.LIB_VERSION}})).json()).result}provider.fetchRPCRequest=fetchRPCRequest;function getCoinbaseInjectedSigner(){return globalThis.coinbaseWalletSigner}provider.getCoinbaseInjectedSigner=getCoinbaseInjectedSigner;function getCoinbaseInjectedLegacyProvider(){return globalThis.coinbaseWalletExtension}function getInjectedEthereum(){var fr,br;try{const wr=globalThis;return(fr=wr.ethereum)!==null&&fr!==void 0?fr:(br=wr.top)===null||br===void 0?void 0:br.ethereum}catch{return}}function getCoinbaseInjectedProvider({metadata:fr,preference:br}){var wr;if(br.options!=="smartWalletOnly"){if(getCoinbaseInjectedSigner())return;const jr=getCoinbaseInjectedLegacyProvider();if(jr){const{appName:Br,appLogoUrl:Wr,appChainIds:qr}=fr;return(wr=jr.setAppInfo)===null||wr===void 0||wr.call(jr,Br,Wr,qr),jr}}const Er=getInjectedEthereum();if(Er!=null&&Er.isCoinbaseBrowser)return Er}provider.getCoinbaseInjectedProvider=getCoinbaseInjectedProvider;function checkErrorForInvalidRequestArgs(fr){if(!fr||typeof fr!="object"||Array.isArray(fr))return error_1$4.standardErrors.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:fr});const{method:br,params:wr}=fr;if(typeof br!="string"||br.length===0)return error_1$4.standardErrors.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:fr});if(wr!==void 0&&!Array.isArray(wr)&&(typeof wr!="object"||wr===null))return error_1$4.standardErrors.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:fr})}provider.checkErrorForInvalidRequestArgs=checkErrorForInvalidRequestArgs;Object.defineProperty(util$5,"__esModule",{value:!0});util$5.createSigner=util$5.fetchSignerType=util$5.storeSignerType=util$5.loadSignerType=void 0;const SCWSigner_1=SCWSigner$1,WalletLinkSigner_1=WalletLinkSigner$1,error_1$3=error,provider_1$2=provider,ScopedLocalStorage_1$2=ScopedLocalStorage$1,SIGNER_TYPE_KEY="SignerType",storage$1=new ScopedLocalStorage_1$2.ScopedLocalStorage("CBWSDK","SignerConfigurator");function loadSignerType(){return storage$1.getItem(SIGNER_TYPE_KEY)}util$5.loadSignerType=loadSignerType;function storeSignerType(fr){storage$1.setItem(SIGNER_TYPE_KEY,fr)}util$5.storeSignerType=storeSignerType;async function fetchSignerType(fr){const{communicator:br,metadata:wr}=fr;listenForWalletLinkSessionRequest(br,wr).catch(()=>{});const Er={id:crypto.randomUUID(),event:"selectSignerType",data:fr.preference},{data:kr}=await br.postRequestAndWaitForResponse(Er);return kr}util$5.fetchSignerType=fetchSignerType;function createSigner(fr){const{signerType:br,metadata:wr,communicator:Er,updateListener:kr}=fr;switch(br){case"scw":return new SCWSigner_1.SCWSigner({metadata:wr,updateListener:kr,communicator:Er});case"walletlink":return new WalletLinkSigner_1.WalletLinkSigner({metadata:wr,updateListener:kr});case"extension":{const jr=(0,provider_1$2.getCoinbaseInjectedSigner)();if(!jr)throw error_1$3.standardErrors.rpc.internal("injected signer not found");return jr}}}util$5.createSigner=createSigner;async function listenForWalletLinkSessionRequest(fr,br){await fr.onMessage(({event:Er})=>Er==="WalletLinkSessionRequest");const wr=new WalletLinkSigner_1.WalletLinkSigner({metadata:br});fr.postMessage({event:"WalletLinkUpdate",data:{session:wr.getSession()}}),await wr.handshake(),fr.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}var Communicator$1={},util={};Object.defineProperty(util,"__esModule",{value:!0});util.closePopup=util.openPopup=void 0;const error_1$2=error,POPUP_WIDTH=420,POPUP_HEIGHT=540;function openPopup(fr){const br=(window.innerWidth-POPUP_WIDTH)/2+window.screenX,wr=(window.innerHeight-POPUP_HEIGHT)/2+window.screenY,Er=window.open(fr,"Smart Wallet",`width=${POPUP_WIDTH}, height=${POPUP_HEIGHT}, left=${br}, top=${wr}`);if(Er==null||Er.focus(),!Er)throw error_1$2.standardErrors.rpc.internal("Pop up window failed to open");return Er}util.openPopup=openPopup;function closePopup(fr){fr&&!fr.closed&&fr.close()}util.closePopup=closePopup;Object.defineProperty(Communicator$1,"__esModule",{value:!0});Communicator$1.Communicator=void 0;const version_1$1=version$8,util_1$2=util,constants_1=constants,error_1$1=error;class Communicator{constructor(br=constants_1.CB_KEYS_URL){this.popup=null,this.listeners=new Map,this.postMessage=async wr=>{(await this.waitForPopupLoaded()).postMessage(wr,this.url.origin)},this.postRequestAndWaitForResponse=async wr=>{const Er=this.onMessage(({requestId:kr})=>kr===wr.id);return this.postMessage(wr),await Er},this.onMessage=async wr=>new Promise((Er,kr)=>{const jr=Br=>{if(Br.origin!==this.url.origin)return;const Wr=Br.data;wr(Wr)&&(Er(Wr),window.removeEventListener("message",jr),this.listeners.delete(jr))};window.addEventListener("message",jr),this.listeners.set(jr,{reject:kr})}),this.disconnect=()=>{(0,util_1$2.closePopup)(this.popup),this.popup=null,this.listeners.forEach(({reject:wr},Er)=>{wr(error_1$1.standardErrors.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",Er)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(this.popup=(0,util_1$2.openPopup)(this.url),this.onMessage(({event:wr})=>wr==="PopupUnload").then(this.disconnect).catch(()=>{}),this.onMessage(({event:wr})=>wr==="PopupLoaded").then(wr=>{this.postMessage({requestId:wr.id,data:{version:version_1$1.LIB_VERSION}})}).then(()=>{if(!this.popup)throw error_1$1.standardErrors.rpc.internal();return this.popup})),this.url=new URL(br)}}Communicator$1.Communicator=Communicator;var method={};Object.defineProperty(method,"__esModule",{value:!0});method.determineMethodCategory=void 0;const mapping={handshake:["eth_requestAccounts"],sign:["eth_ecRecover","personal_sign","personal_ecRecover","eth_signTransaction","eth_sendTransaction","eth_signTypedData_v1","eth_signTypedData_v3","eth_signTypedData_v4","eth_signTypedData","wallet_addEthereumChain","wallet_switchEthereumChain","wallet_watchAsset","wallet_getCapabilities","wallet_sendCalls","wallet_showCallsStatus"],state:["eth_chainId","eth_accounts","eth_coinbase","net_version"],deprecated:["eth_sign","eth_signTypedData_v2"],unsupported:["eth_subscribe","eth_unsubscribe"],fetch:[]};function determineMethodCategory(fr){for(const br in mapping){const wr=br;if(mapping[wr].includes(fr))return wr}}method.determineMethodCategory=determineMethodCategory;var __rest$2=commonjsGlobal&&commonjsGlobal.__rest||function(fr,br){var wr={};for(var Er in fr)Object.prototype.hasOwnProperty.call(fr,Er)&&br.indexOf(Er)<0&&(wr[Er]=fr[Er]);if(fr!=null&&typeof Object.getOwnPropertySymbols=="function")for(var kr=0,Er=Object.getOwnPropertySymbols(fr);kr{try{if(this.connected)return this.emit("connect",{chainId:(0,util_1$1.hexStringFromIntNumber)((0,type_1.IntNumber)(this.chain.id))}),this.accounts;const Vr=await this.requestSignerSelection(),Zr=this.initSigner(Vr),Jr=await Zr.handshake();return this.signer=Zr,(0,util_2.storeSignerType)(Vr),this.emit("connect",{chainId:(0,util_1$1.hexStringFromIntNumber)((0,type_1.IntNumber)(this.chain.id))}),Jr}catch(Vr){throw this.handleUnauthorizedError(Vr),Vr}},sign:async Hr=>{if(!this.connected||!this.signer)throw error_1.standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods");try{return await this.signer.request(Hr)}catch(Vr){throw this.handleUnauthorizedError(Vr),Vr}},fetch:Hr=>(0,provider_1$1.fetchRPCRequest)(Hr,this.chain),state:Hr=>{const Vr=()=>{if(this.connected)return this.accounts;throw error_1.standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods")};switch(Hr.method){case"eth_chainId":return(0,util_1$1.hexStringFromIntNumber)((0,type_1.IntNumber)(this.chain.id));case"net_version":return this.chain.id;case"eth_accounts":return Vr();case"eth_coinbase":return Vr()[0];default:return this.handlers.unsupported(Hr)}},deprecated:({method:Hr})=>{throw error_1.standardErrors.rpc.methodNotSupported(`Method ${Hr} is deprecated.`)},unsupported:({method:Hr})=>{throw error_1.standardErrors.rpc.methodNotSupported(`Method ${Hr} is not supported.`)}},this.isCoinbaseWallet=!0,this.updateListener={onAccountsUpdate:({accounts:Hr,source:Vr})=>{(0,util_1$1.areAddressArraysEqual)(this.accounts,Hr)||(this.accounts=Hr,Vr!=="storage"&&this.emit("accountsChanged",this.accounts))},onChainUpdate:({chain:Hr,source:Vr})=>{Hr.id===this.chain.id&&Hr.rpcUrl===this.chain.rpcUrl||(this.chain=Hr,Vr!=="storage"&&this.emit("chainChanged",(0,util_1$1.hexStringFromIntNumber)((0,type_1.IntNumber)(Hr.id))))}},this.metadata=kr,this.preference=Wr,this.communicator=new Communicator_1.Communicator(Br),this.chain={id:(Er=(wr=kr.appChainIds)===null||wr===void 0?void 0:wr[0])!==null&&Er!==void 0?Er:1};const qr=(0,util_2.loadSignerType)();this.signer=qr?this.initSigner(qr):null}get connected(){return this.accounts.length>0}async request(br){var wr;try{const Er=(0,provider_1$1.checkErrorForInvalidRequestArgs)(br);if(Er)throw Er;const kr=(wr=(0,method_1.determineMethodCategory)(br.method))!==null&&wr!==void 0?wr:"fetch";return this.handlers[kr](br)}catch(Er){return Promise.reject((0,serialize_1$1.serializeError)(Er,br.method))}}handleUnauthorizedError(br){br.code===error_1.standardErrorCodes.provider.unauthorized&&this.disconnect()}async enable(){return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'),await this.request({method:"eth_requestAccounts"})}async disconnect(){this.accounts=[],this.chain={id:1},ScopedLocalStorage_1$1.ScopedLocalStorage.clearAll(),this.emit("disconnect",error_1.standardErrors.provider.disconnected("User initiated disconnection"))}requestSignerSelection(){return(0,util_2.fetchSignerType)({communicator:this.communicator,preference:this.preference,metadata:this.metadata})}initSigner(br){return(0,util_2.createSigner)({signerType:br,metadata:this.metadata,communicator:this.communicator,updateListener:this.updateListener})}}CoinbaseWalletProvider$1.CoinbaseWalletProvider=CoinbaseWalletProvider;Object.defineProperty(CoinbaseWalletSDK$1,"__esModule",{value:!0});CoinbaseWalletSDK$1.CoinbaseWalletSDK=void 0;const wallet_logo_1=walletLogo$1,CoinbaseWalletProvider_1=CoinbaseWalletProvider$1,ScopedLocalStorage_1=ScopedLocalStorage$1,version_1=version$8,util_1=util$6,provider_1=provider;class CoinbaseWalletSDK{constructor(br){this.metadata={appName:br.appName||"Dapp",appLogoUrl:br.appLogoUrl||(0,util_1.getFavicon)(),appChainIds:br.appChainIds||[]},this.storeLatestVersion()}makeWeb3Provider(br={options:"all"}){var wr;const Er={metadata:this.metadata,preference:br};return(wr=(0,provider_1.getCoinbaseInjectedProvider)(Er))!==null&&wr!==void 0?wr:new CoinbaseWalletProvider_1.CoinbaseWalletProvider(Er)}getCoinbaseWalletLogo(br,wr=240){return(0,wallet_logo_1.walletLogo)(br,wr)}storeLatestVersion(){new ScopedLocalStorage_1.ScopedLocalStorage("CBWSDK").setItem("VERSION",version_1.LIB_VERSION)}}CoinbaseWalletSDK$1.CoinbaseWalletSDK=CoinbaseWalletSDK;(function(fr){Object.defineProperty(fr,"__esModule",{value:!0}),fr.CoinbaseWalletSDK=void 0;const br=CoinbaseWalletSDK$1;fr.default=br.CoinbaseWalletSDK;var wr=CoinbaseWalletSDK$1;Object.defineProperty(fr,"CoinbaseWalletSDK",{enumerable:!0,get:function(){return wr.CoinbaseWalletSDK}})})(dist);let coinbaseProvider;const baseSepolia=84532,baseMainnet=8453,getCoinbaseProvider=({appLogoUrl:fr,appName:br,evmNetworks:wr,walletPreference:Er}={})=>{const kr=wr==null?void 0:wr.map(Wr=>Number(Wr.chainId));return(wr==null?void 0:wr.some(Wr=>Wr.chainId===baseSepolia))&&(kr==null||kr.sort((Wr,qr)=>Wr===baseSepolia?-1:qr===baseSepolia?1:0)),(wr==null?void 0:wr.some(Wr=>Wr.chainId===baseMainnet))&&(kr==null||kr.sort((Wr,qr)=>Wr===baseMainnet?-1:qr===baseMainnet?1:0)),coinbaseProvider||(coinbaseProvider=new dist.CoinbaseWalletSDK({appChainIds:kr,appLogoUrl:fr,appName:br}).makeWeb3Provider({options:Er??"all"})),coinbaseProvider};class Coinbase extends EthereumWalletConnector{constructor(br){var{appName:wr,appLogoUrl:Er,evmNetworks:kr,coinbaseWalletPreference:jr}=br,Br=__rest$6(br,["appName","appLogoUrl","evmNetworks","coinbaseWalletPreference"]);super(Object.assign({evmNetworks:kr},Br)),this.name="Coinbase",this.overrideKey="coinbase",this.supportedChains=["EVM","ETH"],this.connectedChain="EVM",this.canConnectViaQrCode=!1,this.canConnectViaCustodialService=!this.isInstalledOnBrowser(),this.coinbaseProviderOpts={appLogoUrl:Er,appName:wr,evmNetworks:kr,walletPreference:jr}}get coinbaseProvider(){return getCoinbaseProvider(this.coinbaseProviderOpts)}getConnectedAccounts(){return __awaiter$8(this,void 0,void 0,function*(){try{const br=yield this.coinbaseProvider.request({method:"eth_accounts"});return br[0]&&this.setActiveAccount(br[0]),br}catch{return[]}})}isInstalledOnBrowser(){var br;return!!(!((br=window==null?void 0:window.coinbaseWalletExtension)===null||br===void 0)&&br.isCoinbaseWallet)}getAddress(){return __awaiter$8(this,void 0,void 0,function*(){const[br]=yield this.coinbaseProvider.request({method:"eth_requestAccounts"});return this.setActiveAccount(br),br})}signMessage(br){return __awaiter$8(this,void 0,void 0,function*(){const[wr]=yield this.coinbaseProvider.request({method:"eth_requestAccounts"});try{return yield this.coinbaseProvider.request({method:"personal_sign",params:[toHex(toBytes$3(br)),wr.toLowerCase()]})}catch{return}})}setupEventListeners(){const{handleAccountChange:br,handleChainChange:wr,handleDisconnect:Er}=eventListenerHandlers(this);this.coinbaseProvider.on("accountsChanged",br),this.coinbaseProvider.on("chainChanged",wr),this.coinbaseProvider.on("disconnect",Er),this.teardownEventListeners=()=>{this.coinbaseProvider.removeListener("accountsChanged",br),this.coinbaseProvider.removeListener("chainChanged",wr),this.coinbaseProvider.removeListener("disconnect",Er)}}getWalletClient(br){return createWalletClient({account:this.getActiveAccount(),chain:br?chainsMap[br]:void 0,transport:custom(this.coinbaseProvider)})}}assertPackageVersion("@dynamic-labs/ethereum",version$9);const EthereumWalletConnectors=fr=>[...injectedWalletOverrides$1,...fetchInjectedWalletConnector(fr),...fetchWalletConnectWallets(fr),...TurnkeyEVMWalletConnectors(fr),Coinbase,UnknownInjected$1,FallbackEvmConnector,getWalletConnectConnector()];var version$7="3.8.2",version$6="3.8.2";function __awaiter$4(fr,br,wr,Er){function kr(jr){return jr instanceof wr?jr:new wr(function(Br){Br(jr)})}return new(wr||(wr=Promise))(function(jr,Br){function Wr(Vr){try{Hr(Er.next(Vr))}catch(Zr){Br(Zr)}}function qr(Vr){try{Hr(Er.throw(Vr))}catch(Zr){Br(Zr)}}function Hr(Vr){Vr.done?jr(Vr.value):kr(Vr.value).then(Wr,qr)}Hr((Er=Er.apply(fr,[])).next())})}typeof SuppressedError=="function"&&SuppressedError;const U32_MASK64=BigInt(2**32-1),_32n=BigInt(32);function fromBig(fr,br=!1){return br?{h:Number(fr&U32_MASK64),l:Number(fr>>_32n&U32_MASK64)}:{h:Number(fr>>_32n&U32_MASK64)|0,l:Number(fr&U32_MASK64)|0}}function split(fr,br=!1){let wr=new Uint32Array(fr.length),Er=new Uint32Array(fr.length);for(let kr=0;krBigInt(fr>>>0)<<_32n|BigInt(br>>>0),shrSH=(fr,br,wr)=>fr>>>wr,shrSL=(fr,br,wr)=>fr<<32-wr|br>>>wr,rotrSH=(fr,br,wr)=>fr>>>wr|br<<32-wr,rotrSL=(fr,br,wr)=>fr<<32-wr|br>>>wr,rotrBH=(fr,br,wr)=>fr<<64-wr|br>>>wr-32,rotrBL=(fr,br,wr)=>fr>>>wr-32|br<<64-wr,rotr32H=(fr,br)=>br,rotr32L=(fr,br)=>fr,rotlSH=(fr,br,wr)=>fr<>>32-wr,rotlSL=(fr,br,wr)=>br<>>32-wr,rotlBH=(fr,br,wr)=>br<>>64-wr,rotlBL=(fr,br,wr)=>fr<>>64-wr;function add(fr,br,wr,Er){const kr=(br>>>0)+(Er>>>0);return{h:fr+wr+(kr/2**32|0)|0,l:kr|0}}const add3L=(fr,br,wr)=>(fr>>>0)+(br>>>0)+(wr>>>0),add3H=(fr,br,wr,Er)=>br+wr+Er+(fr/2**32|0)|0,add4L=(fr,br,wr,Er)=>(fr>>>0)+(br>>>0)+(wr>>>0)+(Er>>>0),add4H=(fr,br,wr,Er,kr)=>br+wr+Er+kr+(fr/2**32|0)|0,add5L=(fr,br,wr,Er,kr)=>(fr>>>0)+(br>>>0)+(wr>>>0)+(Er>>>0)+(kr>>>0),add5H=(fr,br,wr,Er,kr,jr)=>br+wr+Er+kr+jr+(fr/2**32|0)|0,u64$4={fromBig,split,toBig,shrSH,shrSL,rotrSH,rotrSL,rotrBH,rotrBL,rotr32H,rotr32L,rotlSH,rotlSL,rotlBH,rotlBL,add,add3L,add3H,add4L,add4H,add5H,add5L},[SHA512_Kh,SHA512_Kl]=u64$4.split(["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(fr=>BigInt(fr))),SHA512_W_H=new Uint32Array(80),SHA512_W_L=new Uint32Array(80);class SHA512 extends HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:br,Al:wr,Bh:Er,Bl:kr,Ch:jr,Cl:Br,Dh:Wr,Dl:qr,Eh:Hr,El:Vr,Fh:Zr,Fl:Jr,Gh:Qr,Gl:_n,Hh:En,Hl:Cn}=this;return[br,wr,Er,kr,jr,Br,Wr,qr,Hr,Vr,Zr,Jr,Qr,_n,En,Cn]}set(br,wr,Er,kr,jr,Br,Wr,qr,Hr,Vr,Zr,Jr,Qr,_n,En,Cn){this.Ah=br|0,this.Al=wr|0,this.Bh=Er|0,this.Bl=kr|0,this.Ch=jr|0,this.Cl=Br|0,this.Dh=Wr|0,this.Dl=qr|0,this.Eh=Hr|0,this.El=Vr|0,this.Fh=Zr|0,this.Fl=Jr|0,this.Gh=Qr|0,this.Gl=_n|0,this.Hh=En|0,this.Hl=Cn|0}process(br,wr){for(let jn=0;jn<16;jn++,wr+=4)SHA512_W_H[jn]=br.getUint32(wr),SHA512_W_L[jn]=br.getUint32(wr+=4);for(let jn=16;jn<80;jn++){const eo=SHA512_W_H[jn-15]|0,ro=SHA512_W_L[jn-15]|0,to=u64$4.rotrSH(eo,ro,1)^u64$4.rotrSH(eo,ro,8)^u64$4.shrSH(eo,ro,7),_i=u64$4.rotrSL(eo,ro,1)^u64$4.rotrSL(eo,ro,8)^u64$4.shrSL(eo,ro,7),oo=SHA512_W_H[jn-2]|0,io=SHA512_W_L[jn-2]|0,co=u64$4.rotrSH(oo,io,19)^u64$4.rotrBH(oo,io,61)^u64$4.shrSH(oo,io,6),so=u64$4.rotrSL(oo,io,19)^u64$4.rotrBL(oo,io,61)^u64$4.shrSL(oo,io,6),no=u64$4.add4L(_i,so,SHA512_W_L[jn-7],SHA512_W_L[jn-16]),Tn=u64$4.add4H(no,to,co,SHA512_W_H[jn-7],SHA512_W_H[jn-16]);SHA512_W_H[jn]=Tn|0,SHA512_W_L[jn]=no|0}let{Ah:Er,Al:kr,Bh:jr,Bl:Br,Ch:Wr,Cl:qr,Dh:Hr,Dl:Vr,Eh:Zr,El:Jr,Fh:Qr,Fl:_n,Gh:En,Gl:Cn,Hh:In,Hl:An}=this;for(let jn=0;jn<80;jn++){const eo=u64$4.rotrSH(Zr,Jr,14)^u64$4.rotrSH(Zr,Jr,18)^u64$4.rotrBH(Zr,Jr,41),ro=u64$4.rotrSL(Zr,Jr,14)^u64$4.rotrSL(Zr,Jr,18)^u64$4.rotrBL(Zr,Jr,41),to=Zr&Qr^~Zr&En,_i=Jr&_n^~Jr&Cn,oo=u64$4.add5L(An,ro,_i,SHA512_Kl[jn],SHA512_W_L[jn]),io=u64$4.add5H(oo,In,eo,to,SHA512_Kh[jn],SHA512_W_H[jn]),co=oo|0,so=u64$4.rotrSH(Er,kr,28)^u64$4.rotrBH(Er,kr,34)^u64$4.rotrBH(Er,kr,39),no=u64$4.rotrSL(Er,kr,28)^u64$4.rotrBL(Er,kr,34)^u64$4.rotrBL(Er,kr,39),Tn=Er&jr^Er&Wr^jr&Wr,Gr=kr&Br^kr&qr^Br&qr;In=En|0,An=Cn|0,En=Qr|0,Cn=_n|0,Qr=Zr|0,_n=Jr|0,{h:Zr,l:Jr}=u64$4.add(Hr|0,Vr|0,io|0,co|0),Hr=Wr|0,Vr=qr|0,Wr=jr|0,qr=Br|0,jr=Er|0,Br=kr|0;const Xr=u64$4.add3L(co,no,Gr);Er=u64$4.add3H(Xr,io,so,Tn),kr=Xr|0}({h:Er,l:kr}=u64$4.add(this.Ah|0,this.Al|0,Er|0,kr|0)),{h:jr,l:Br}=u64$4.add(this.Bh|0,this.Bl|0,jr|0,Br|0),{h:Wr,l:qr}=u64$4.add(this.Ch|0,this.Cl|0,Wr|0,qr|0),{h:Hr,l:Vr}=u64$4.add(this.Dh|0,this.Dl|0,Hr|0,Vr|0),{h:Zr,l:Jr}=u64$4.add(this.Eh|0,this.El|0,Zr|0,Jr|0),{h:Qr,l:_n}=u64$4.add(this.Fh|0,this.Fl|0,Qr|0,_n|0),{h:En,l:Cn}=u64$4.add(this.Gh|0,this.Gl|0,En|0,Cn|0),{h:In,l:An}=u64$4.add(this.Hh|0,this.Hl|0,In|0,An|0),this.set(Er,kr,jr,Br,Wr,qr,Hr,Vr,Zr,Jr,Qr,_n,En,Cn,In,An)}roundClean(){SHA512_W_H.fill(0),SHA512_W_L.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const sha512=wrapConstructor(()=>new SHA512);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n=BigInt(0),_1n$1=BigInt(1),_2n$1=BigInt(2),_8n$1=BigInt(8),VERIFY_DEFAULT={zip215:!0};function validateOpts(fr){const br=validateBasic(fr);return validateObject(fr,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...br})}function twistedEdwards(fr){const br=validateOpts(fr),{Fp:wr,n:Er,prehash:kr,hash:jr,randomBytes:Br,nByteLength:Wr,h:qr}=br,Hr=_2n$1<{try{return{isValid:!0,value:wr.sqrt(Sn*wr.inv(Rn))}}catch{return{isValid:!1,value:_0n}}}),Qr=br.adjustScalarBytes||(Sn=>Sn),_n=br.domain||((Sn,Rn,Pn)=>{if(abool("phflag",Pn),Rn.length||Pn)throw new Error("Contexts/pre-hash are not supported");return Sn});function En(Sn,Rn){aInRange("coordinate "+Sn,Rn,_0n,Hr)}function Cn(Sn){if(!(Sn instanceof jn))throw new Error("ExtendedPoint expected")}const In=memoized((Sn,Rn)=>{const{ex:Pn,ey:On,ez:Zn}=Sn,Nn=Sn.is0();Rn==null&&(Rn=Nn?_8n$1:wr.inv(Zn));const wn=Vr(Pn*Rn),zn=Vr(On*Rn),fo=Vr(Zn*Rn);if(Nn)return{x:_0n,y:_1n$1};if(fo!==_1n$1)throw new Error("invZ was invalid");return{x:wn,y:zn}}),An=memoized(Sn=>{const{a:Rn,d:Pn}=br;if(Sn.is0())throw new Error("bad point: ZERO");const{ex:On,ey:Zn,ez:Nn,et:wn}=Sn,zn=Vr(On*On),fo=Vr(Zn*Zn),vo=Vr(Nn*Nn),go=Vr(vo*vo),uo=Vr(zn*Rn),lo=Vr(vo*Vr(uo+fo)),Eo=Vr(go+Vr(Pn*Vr(zn*fo)));if(lo!==Eo)throw new Error("bad point: equation left != right (1)");const mo=Vr(On*Zn),yo=Vr(Nn*wn);if(mo!==yo)throw new Error("bad point: equation left != right (2)");return!0});class jn{constructor(Rn,Pn,On,Zn){this.ex=Rn,this.ey=Pn,this.ez=On,this.et=Zn,En("x",Rn),En("y",Pn),En("z",On),En("t",Zn),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(Rn){if(Rn instanceof jn)throw new Error("extended point not allowed");const{x:Pn,y:On}=Rn||{};return En("x",Pn),En("y",On),new jn(Pn,On,_1n$1,Vr(Pn*On))}static normalizeZ(Rn){const Pn=wr.invertBatch(Rn.map(On=>On.ez));return Rn.map((On,Zn)=>On.toAffine(Pn[Zn])).map(jn.fromAffine)}static msm(Rn,Pn){return pippenger(jn,Zr,Rn,Pn)}_setWindowSize(Rn){to.setWindowSize(this,Rn)}assertValidity(){An(this)}equals(Rn){Cn(Rn);const{ex:Pn,ey:On,ez:Zn}=this,{ex:Nn,ey:wn,ez:zn}=Rn,fo=Vr(Pn*zn),vo=Vr(Nn*Zn),go=Vr(On*zn),uo=Vr(wn*Zn);return fo===vo&&go===uo}is0(){return this.equals(jn.ZERO)}negate(){return new jn(Vr(-this.ex),this.ey,this.ez,Vr(-this.et))}double(){const{a:Rn}=br,{ex:Pn,ey:On,ez:Zn}=this,Nn=Vr(Pn*Pn),wn=Vr(On*On),zn=Vr(_2n$1*Vr(Zn*Zn)),fo=Vr(Rn*Nn),vo=Pn+On,go=Vr(Vr(vo*vo)-Nn-wn),uo=fo+wn,lo=uo-zn,Eo=fo-wn,mo=Vr(go*lo),yo=Vr(uo*Eo),_o=Vr(go*Eo),Bo=Vr(lo*uo);return new jn(mo,yo,Bo,_o)}add(Rn){Cn(Rn);const{a:Pn,d:On}=br,{ex:Zn,ey:Nn,ez:wn,et:zn}=this,{ex:fo,ey:vo,ez:go,et:uo}=Rn;if(Pn===BigInt(-1)){const No=Vr((Nn-Zn)*(vo+fo)),Fo=Vr((Nn+Zn)*(vo-fo)),Nl=Vr(Fo-No);if(Nl===_0n)return this.double();const Vo=Vr(wn*_2n$1*uo),Uo=Vr(zn*_2n$1*go),Ol=Uo+Vo,$a=Fo+No,Jo=Uo-Vo,Zl=Vr(Ol*Nl),Cl=Vr($a*Jo),ko=Vr(Ol*Jo),wo=Vr(Nl*$a);return new jn(Zl,Cl,wo,ko)}const lo=Vr(Zn*fo),Eo=Vr(Nn*vo),mo=Vr(zn*On*uo),yo=Vr(wn*go),_o=Vr((Zn+Nn)*(fo+vo)-lo-Eo),Bo=yo-mo,Lo=yo+mo,Wo=Vr(Eo-Pn*lo),na=Vr(_o*Bo),qo=Vr(Lo*Wo),ga=Vr(_o*Wo),wl=Vr(Bo*Lo);return new jn(na,qo,wl,ga)}subtract(Rn){return this.add(Rn.negate())}wNAF(Rn){return to.wNAFCached(this,Rn,jn.normalizeZ)}multiply(Rn){const Pn=Rn;aInRange("scalar",Pn,_1n$1,Er);const{p:On,f:Zn}=this.wNAF(Pn);return jn.normalizeZ([On,Zn])[0]}multiplyUnsafe(Rn,Pn=jn.ZERO){const On=Rn;return aInRange("scalar",On,_0n,Er),On===_0n?ro:this.is0()||On===_1n$1?this:to.wNAFCachedUnsafe(this,On,jn.normalizeZ,Pn)}isSmallOrder(){return this.multiplyUnsafe(qr).is0()}isTorsionFree(){return to.unsafeLadder(this,Er).is0()}toAffine(Rn){return In(this,Rn)}clearCofactor(){const{h:Rn}=br;return Rn===_1n$1?this:this.multiplyUnsafe(Rn)}static fromHex(Rn,Pn=!1){const{d:On,a:Zn}=br,Nn=wr.BYTES;Rn=ensureBytes("pointHex",Rn,Nn),abool("zip215",Pn);const wn=Rn.slice(),zn=Rn[Nn-1];wn[Nn-1]=zn&-129;const fo=bytesToNumberLE(wn),vo=Pn?Hr:wr.ORDER;aInRange("pointHex.y",fo,_0n,vo);const go=Vr(fo*fo),uo=Vr(go-_1n$1),lo=Vr(On*go-Zn);let{isValid:Eo,value:mo}=Jr(uo,lo);if(!Eo)throw new Error("Point.fromHex: invalid y coordinate");const yo=(mo&_1n$1)===_1n$1,_o=(zn&128)!==0;if(!Pn&&mo===_0n&&_o)throw new Error("Point.fromHex: x=0 and x_0=1");return _o!==yo&&(mo=Vr(-mo)),jn.fromAffine({x:mo,y:fo})}static fromPrivateKey(Rn){return io(Rn).point}toRawBytes(){const{x:Rn,y:Pn}=this.toAffine(),On=numberToBytesLE(Pn,wr.BYTES);return On[On.length-1]|=Rn&_1n$1?128:0,On}toHex(){return bytesToHex(this.toRawBytes())}}jn.BASE=new jn(br.Gx,br.Gy,_1n$1,Vr(br.Gx*br.Gy)),jn.ZERO=new jn(_0n,_1n$1,_1n$1,_0n);const{BASE:eo,ZERO:ro}=jn,to=wNAF(jn,Wr*8);function _i(Sn){return mod(Sn,Er)}function oo(Sn){return _i(bytesToNumberLE(Sn))}function io(Sn){const Rn=wr.BYTES;Sn=ensureBytes("private key",Sn,Rn);const Pn=ensureBytes("hashed private key",jr(Sn),2*Rn),On=Qr(Pn.slice(0,Rn)),Zn=Pn.slice(Rn,2*Rn),Nn=oo(On),wn=eo.multiply(Nn),zn=wn.toRawBytes();return{head:On,prefix:Zn,scalar:Nn,point:wn,pointBytes:zn}}function co(Sn){return io(Sn).pointBytes}function so(Sn=new Uint8Array,...Rn){const Pn=concatBytes(...Rn);return oo(jr(_n(Pn,ensureBytes("context",Sn),!!kr)))}function no(Sn,Rn,Pn={}){Sn=ensureBytes("message",Sn),kr&&(Sn=kr(Sn));const{prefix:On,scalar:Zn,pointBytes:Nn}=io(Rn),wn=so(Pn.context,On,Sn),zn=eo.multiply(wn).toRawBytes(),fo=so(Pn.context,zn,Nn,Sn),vo=_i(wn+fo*Zn);aInRange("signature.s",vo,_0n,Er);const go=concatBytes(zn,numberToBytesLE(vo,wr.BYTES));return ensureBytes("result",go,wr.BYTES*2)}const Tn=VERIFY_DEFAULT;function Gr(Sn,Rn,Pn,On=Tn){const{context:Zn,zip215:Nn}=On,wn=wr.BYTES;Sn=ensureBytes("signature",Sn,2*wn),Rn=ensureBytes("message",Rn),Pn=ensureBytes("publicKey",Pn,wn),Nn!==void 0&&abool("zip215",Nn),kr&&(Rn=kr(Rn));const zn=bytesToNumberLE(Sn.slice(wn,2*wn));let fo,vo,go;try{fo=jn.fromHex(Pn,Nn),vo=jn.fromHex(Sn.slice(0,wn),Nn),go=eo.multiplyUnsafe(zn)}catch{return!1}if(!Nn&&fo.isSmallOrder())return!1;const uo=so(Zn,vo.toRawBytes(),fo.toRawBytes(),Rn);return vo.add(fo.multiplyUnsafe(uo)).subtract(go).clearCofactor().equals(jn.ZERO)}return eo._setWindowSize(8),{CURVE:br,getPublicKey:co,sign:no,verify:Gr,ExtendedPoint:jn,utils:{getExtendedPublicKey:io,randomPrivateKey:()=>Br(wr.BYTES),precompute(Sn=8,Rn=jn.BASE){return Rn._setWindowSize(Sn),Rn.multiply(BigInt(3)),Rn}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ED25519_P=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ED25519_SQRT_M1=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const _1n=BigInt(1),_2n=BigInt(2);BigInt(3);const _5n=BigInt(5),_8n=BigInt(8);function ed25519_pow_2_252_3(fr){const br=BigInt(10),wr=BigInt(20),Er=BigInt(40),kr=BigInt(80),jr=ED25519_P,Wr=fr*fr%jr*fr%jr,qr=pow2(Wr,_2n,jr)*Wr%jr,Hr=pow2(qr,_1n,jr)*fr%jr,Vr=pow2(Hr,_5n,jr)*Hr%jr,Zr=pow2(Vr,br,jr)*Vr%jr,Jr=pow2(Zr,wr,jr)*Zr%jr,Qr=pow2(Jr,Er,jr)*Jr%jr,_n=pow2(Qr,kr,jr)*Qr%jr,En=pow2(_n,kr,jr)*Qr%jr,Cn=pow2(En,br,jr)*Vr%jr;return{pow_p_5_8:pow2(Cn,_2n,jr)*fr%jr,b2:Wr}}function adjustScalarBytes(fr){return fr[0]&=248,fr[31]&=127,fr[31]|=64,fr}function uvRatio(fr,br){const wr=ED25519_P,Er=mod(br*br*br,wr),kr=mod(Er*Er*br,wr),jr=ed25519_pow_2_252_3(fr*kr).pow_p_5_8;let Br=mod(fr*Er*jr,wr);const Wr=mod(br*Br*Br,wr),qr=Br,Hr=mod(Br*ED25519_SQRT_M1,wr),Vr=Wr===fr,Zr=Wr===mod(-fr,wr),Jr=Wr===mod(-fr*ED25519_SQRT_M1,wr);return Vr&&(Br=qr),(Zr||Jr)&&(Br=Hr),isNegativeLE(Br,wr)&&(Br=mod(-Br,wr)),{isValid:Vr||Zr,value:Br}}const Fp=Field(ED25519_P,void 0,!0),ed25519Defaults={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:_8n,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:sha512,randomBytes,adjustScalarBytes,uvRatio},ed25519=twistedEdwards(ed25519Defaults);var bn$3={exports:{}};bn$3.exports;(function(fr){(function(br,wr){function Er(Tn,Gr){if(!Tn)throw new Error(Gr||"Assertion failed")}function kr(Tn,Gr){Tn.super_=Gr;var Xr=function(){};Xr.prototype=Gr.prototype,Tn.prototype=new Xr,Tn.prototype.constructor=Tn}function jr(Tn,Gr,Xr){if(jr.isBN(Tn))return Tn;this.negative=0,this.words=null,this.length=0,this.red=null,Tn!==null&&((Gr==="le"||Gr==="be")&&(Xr=Gr,Gr=10),this._init(Tn||0,Gr||10,Xr||"be"))}typeof br=="object"?br.exports=jr:wr.BN=jr,jr.BN=jr,jr.wordSize=26;var Br;try{typeof window<"u"&&typeof window.Buffer<"u"?Br=window.Buffer:Br=require$$0$9.Buffer}catch{}jr.isBN=function(Gr){return Gr instanceof jr?!0:Gr!==null&&typeof Gr=="object"&&Gr.constructor.wordSize===jr.wordSize&&Array.isArray(Gr.words)},jr.max=function(Gr,Xr){return Gr.cmp(Xr)>0?Gr:Xr},jr.min=function(Gr,Xr){return Gr.cmp(Xr)<0?Gr:Xr},jr.prototype._init=function(Gr,Xr,Sn){if(typeof Gr=="number")return this._initNumber(Gr,Xr,Sn);if(typeof Gr=="object")return this._initArray(Gr,Xr,Sn);Xr==="hex"&&(Xr=16),Er(Xr===(Xr|0)&&Xr>=2&&Xr<=36),Gr=Gr.toString().replace(/\s+/g,"");var Rn=0;Gr[0]==="-"&&(Rn++,this.negative=1),Rn=0;Rn-=3)On=Gr[Rn]|Gr[Rn-1]<<8|Gr[Rn-2]<<16,this.words[Pn]|=On<>>26-Zn&67108863,Zn+=24,Zn>=26&&(Zn-=26,Pn++);else if(Sn==="le")for(Rn=0,Pn=0;Rn>>26-Zn&67108863,Zn+=24,Zn>=26&&(Zn-=26,Pn++);return this._strip()};function Wr(Tn,Gr){var Xr=Tn.charCodeAt(Gr);if(Xr>=48&&Xr<=57)return Xr-48;if(Xr>=65&&Xr<=70)return Xr-55;if(Xr>=97&&Xr<=102)return Xr-87;Er(!1,"Invalid character in "+Tn)}function qr(Tn,Gr,Xr){var Sn=Wr(Tn,Xr);return Xr-1>=Gr&&(Sn|=Wr(Tn,Xr-1)<<4),Sn}jr.prototype._parseHex=function(Gr,Xr,Sn){this.length=Math.ceil((Gr.length-Xr)/6),this.words=new Array(this.length);for(var Rn=0;Rn=Xr;Rn-=2)Zn=qr(Gr,Xr,Rn)<=18?(Pn-=18,On+=1,this.words[On]|=Zn>>>26):Pn+=8;else{var Nn=Gr.length-Xr;for(Rn=Nn%2===0?Xr+1:Xr;Rn=18?(Pn-=18,On+=1,this.words[On]|=Zn>>>26):Pn+=8}this._strip()};function Hr(Tn,Gr,Xr,Sn){for(var Rn=0,Pn=0,On=Math.min(Tn.length,Xr),Zn=Gr;Zn=49?Pn=Nn-49+10:Nn>=17?Pn=Nn-17+10:Pn=Nn,Er(Nn>=0&&Pn1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},jr.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{jr.prototype[Symbol.for("nodejs.util.inspect.custom")]=Zr}catch{jr.prototype.inspect=Zr}else jr.prototype.inspect=Zr;function Zr(){return(this.red?""}var Jr=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],Qr=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],_n=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];jr.prototype.toString=function(Gr,Xr){Gr=Gr||10,Xr=Xr|0||1;var Sn;if(Gr===16||Gr==="hex"){Sn="";for(var Rn=0,Pn=0,On=0;On>>24-Rn&16777215,Rn+=2,Rn>=26&&(Rn-=26,On--),Pn!==0||On!==this.length-1?Sn=Jr[6-Nn.length]+Nn+Sn:Sn=Nn+Sn}for(Pn!==0&&(Sn=Pn.toString(16)+Sn);Sn.length%Xr!==0;)Sn="0"+Sn;return this.negative!==0&&(Sn="-"+Sn),Sn}if(Gr===(Gr|0)&&Gr>=2&&Gr<=36){var wn=Qr[Gr],zn=_n[Gr];Sn="";var fo=this.clone();for(fo.negative=0;!fo.isZero();){var vo=fo.modrn(zn).toString(Gr);fo=fo.idivn(zn),fo.isZero()?Sn=vo+Sn:Sn=Jr[wn-vo.length]+vo+Sn}for(this.isZero()&&(Sn="0"+Sn);Sn.length%Xr!==0;)Sn="0"+Sn;return this.negative!==0&&(Sn="-"+Sn),Sn}Er(!1,"Base should be between 2 and 36")},jr.prototype.toNumber=function(){var Gr=this.words[0];return this.length===2?Gr+=this.words[1]*67108864:this.length===3&&this.words[2]===1?Gr+=4503599627370496+this.words[1]*67108864:this.length>2&&Er(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-Gr:Gr},jr.prototype.toJSON=function(){return this.toString(16,2)},Br&&(jr.prototype.toBuffer=function(Gr,Xr){return this.toArrayLike(Br,Gr,Xr)}),jr.prototype.toArray=function(Gr,Xr){return this.toArrayLike(Array,Gr,Xr)};var En=function(Gr,Xr){return Gr.allocUnsafe?Gr.allocUnsafe(Xr):new Gr(Xr)};jr.prototype.toArrayLike=function(Gr,Xr,Sn){this._strip();var Rn=this.byteLength(),Pn=Sn||Math.max(1,Rn);Er(Rn<=Pn,"byte array longer than desired length"),Er(Pn>0,"Requested array length <= 0");var On=En(Gr,Pn),Zn=Xr==="le"?"LE":"BE";return this["_toArrayLike"+Zn](On,Rn),On},jr.prototype._toArrayLikeLE=function(Gr,Xr){for(var Sn=0,Rn=0,Pn=0,On=0;Pn>8&255),Sn>16&255),On===6?(Sn>24&255),Rn=0,On=0):(Rn=Zn>>>24,On+=2)}if(Sn=0&&(Gr[Sn--]=Zn>>8&255),Sn>=0&&(Gr[Sn--]=Zn>>16&255),On===6?(Sn>=0&&(Gr[Sn--]=Zn>>24&255),Rn=0,On=0):(Rn=Zn>>>24,On+=2)}if(Sn>=0)for(Gr[Sn--]=Rn;Sn>=0;)Gr[Sn--]=0},Math.clz32?jr.prototype._countBits=function(Gr){return 32-Math.clz32(Gr)}:jr.prototype._countBits=function(Gr){var Xr=Gr,Sn=0;return Xr>=4096&&(Sn+=13,Xr>>>=13),Xr>=64&&(Sn+=7,Xr>>>=7),Xr>=8&&(Sn+=4,Xr>>>=4),Xr>=2&&(Sn+=2,Xr>>>=2),Sn+Xr},jr.prototype._zeroBits=function(Gr){if(Gr===0)return 26;var Xr=Gr,Sn=0;return Xr&8191||(Sn+=13,Xr>>>=13),Xr&127||(Sn+=7,Xr>>>=7),Xr&15||(Sn+=4,Xr>>>=4),Xr&3||(Sn+=2,Xr>>>=2),Xr&1||Sn++,Sn},jr.prototype.bitLength=function(){var Gr=this.words[this.length-1],Xr=this._countBits(Gr);return(this.length-1)*26+Xr};function Cn(Tn){for(var Gr=new Array(Tn.bitLength()),Xr=0;Xr>>Rn&1}return Gr}jr.prototype.zeroBits=function(){if(this.isZero())return 0;for(var Gr=0,Xr=0;XrGr.length?this.clone().ior(Gr):Gr.clone().ior(this)},jr.prototype.uor=function(Gr){return this.length>Gr.length?this.clone().iuor(Gr):Gr.clone().iuor(this)},jr.prototype.iuand=function(Gr){var Xr;this.length>Gr.length?Xr=Gr:Xr=this;for(var Sn=0;SnGr.length?this.clone().iand(Gr):Gr.clone().iand(this)},jr.prototype.uand=function(Gr){return this.length>Gr.length?this.clone().iuand(Gr):Gr.clone().iuand(this)},jr.prototype.iuxor=function(Gr){var Xr,Sn;this.length>Gr.length?(Xr=this,Sn=Gr):(Xr=Gr,Sn=this);for(var Rn=0;RnGr.length?this.clone().ixor(Gr):Gr.clone().ixor(this)},jr.prototype.uxor=function(Gr){return this.length>Gr.length?this.clone().iuxor(Gr):Gr.clone().iuxor(this)},jr.prototype.inotn=function(Gr){Er(typeof Gr=="number"&&Gr>=0);var Xr=Math.ceil(Gr/26)|0,Sn=Gr%26;this._expand(Xr),Sn>0&&Xr--;for(var Rn=0;Rn0&&(this.words[Rn]=~this.words[Rn]&67108863>>26-Sn),this._strip()},jr.prototype.notn=function(Gr){return this.clone().inotn(Gr)},jr.prototype.setn=function(Gr,Xr){Er(typeof Gr=="number"&&Gr>=0);var Sn=Gr/26|0,Rn=Gr%26;return this._expand(Sn+1),Xr?this.words[Sn]=this.words[Sn]|1<Gr.length?(Sn=this,Rn=Gr):(Sn=Gr,Rn=this);for(var Pn=0,On=0;On>>26;for(;Pn!==0&&On>>26;if(this.length=Sn.length,Pn!==0)this.words[this.length]=Pn,this.length++;else if(Sn!==this)for(;OnGr.length?this.clone().iadd(Gr):Gr.clone().iadd(this)},jr.prototype.isub=function(Gr){if(Gr.negative!==0){Gr.negative=0;var Xr=this.iadd(Gr);return Gr.negative=1,Xr._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(Gr),this.negative=1,this._normSign();var Sn=this.cmp(Gr);if(Sn===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Rn,Pn;Sn>0?(Rn=this,Pn=Gr):(Rn=Gr,Pn=this);for(var On=0,Zn=0;Zn>26,this.words[Zn]=Xr&67108863;for(;On!==0&&Zn>26,this.words[Zn]=Xr&67108863;if(On===0&&Zn>>26,fo=Nn&67108863,vo=Math.min(wn,Gr.length-1),go=Math.max(0,wn-Tn.length+1);go<=vo;go++){var uo=wn-go|0;Rn=Tn.words[uo]|0,Pn=Gr.words[go]|0,On=Rn*Pn+fo,zn+=On/67108864|0,fo=On&67108863}Xr.words[wn]=fo|0,Nn=zn|0}return Nn!==0?Xr.words[wn]=Nn|0:Xr.length--,Xr._strip()}var An=function(Gr,Xr,Sn){var Rn=Gr.words,Pn=Xr.words,On=Sn.words,Zn=0,Nn,wn,zn,fo=Rn[0]|0,vo=fo&8191,go=fo>>>13,uo=Rn[1]|0,lo=uo&8191,Eo=uo>>>13,mo=Rn[2]|0,yo=mo&8191,_o=mo>>>13,Bo=Rn[3]|0,Lo=Bo&8191,Wo=Bo>>>13,na=Rn[4]|0,qo=na&8191,ga=na>>>13,wl=Rn[5]|0,No=wl&8191,Fo=wl>>>13,Nl=Rn[6]|0,Vo=Nl&8191,Uo=Nl>>>13,Ol=Rn[7]|0,$a=Ol&8191,Jo=Ol>>>13,Zl=Rn[8]|0,Cl=Zl&8191,ko=Zl>>>13,wo=Rn[9]|0,bo=wo&8191,Io=wo>>>13,Ho=Pn[0]|0,Do=Ho&8191,zo=Ho>>>13,nu=Pn[1]|0,Ll=nu&8191,_l=nu>>>13,bu=Pn[2]|0,xl=bu&8191,Tl=bu>>>13,du=Pn[3]|0,Bl=du&8191,Il=du>>>13,Eu=Pn[4]|0,Al=Eu&8191,Ml=Eu>>>13,Tu=Pn[5]|0,Ul=Tu&8191,Sl=Tu>>>13,_u=Pn[6]|0,So=_u&8191,Co=_u>>>13,Ao=Pn[7]|0,po=Ao&8191,Ro=Ao>>>13,Xo=Pn[8]|0,jo=Xo&8191,Ko=Xo>>>13,Wl=Pn[9]|0,$l=Wl&8191,El=Wl>>>13;Sn.negative=Gr.negative^Xr.negative,Sn.length=19,Nn=Math.imul(vo,Do),wn=Math.imul(vo,zo),wn=wn+Math.imul(go,Do)|0,zn=Math.imul(go,zo);var Cu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Cu>>>26)|0,Cu&=67108863,Nn=Math.imul(lo,Do),wn=Math.imul(lo,zo),wn=wn+Math.imul(Eo,Do)|0,zn=Math.imul(Eo,zo),Nn=Nn+Math.imul(vo,Ll)|0,wn=wn+Math.imul(vo,_l)|0,wn=wn+Math.imul(go,Ll)|0,zn=zn+Math.imul(go,_l)|0;var iu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(iu>>>26)|0,iu&=67108863,Nn=Math.imul(yo,Do),wn=Math.imul(yo,zo),wn=wn+Math.imul(_o,Do)|0,zn=Math.imul(_o,zo),Nn=Nn+Math.imul(lo,Ll)|0,wn=wn+Math.imul(lo,_l)|0,wn=wn+Math.imul(Eo,Ll)|0,zn=zn+Math.imul(Eo,_l)|0,Nn=Nn+Math.imul(vo,xl)|0,wn=wn+Math.imul(vo,Tl)|0,wn=wn+Math.imul(go,xl)|0,zn=zn+Math.imul(go,Tl)|0;var pu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(pu>>>26)|0,pu&=67108863,Nn=Math.imul(Lo,Do),wn=Math.imul(Lo,zo),wn=wn+Math.imul(Wo,Do)|0,zn=Math.imul(Wo,zo),Nn=Nn+Math.imul(yo,Ll)|0,wn=wn+Math.imul(yo,_l)|0,wn=wn+Math.imul(_o,Ll)|0,zn=zn+Math.imul(_o,_l)|0,Nn=Nn+Math.imul(lo,xl)|0,wn=wn+Math.imul(lo,Tl)|0,wn=wn+Math.imul(Eo,xl)|0,zn=zn+Math.imul(Eo,Tl)|0,Nn=Nn+Math.imul(vo,Bl)|0,wn=wn+Math.imul(vo,Il)|0,wn=wn+Math.imul(go,Bl)|0,zn=zn+Math.imul(go,Il)|0;var yu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(yu>>>26)|0,yu&=67108863,Nn=Math.imul(qo,Do),wn=Math.imul(qo,zo),wn=wn+Math.imul(ga,Do)|0,zn=Math.imul(ga,zo),Nn=Nn+Math.imul(Lo,Ll)|0,wn=wn+Math.imul(Lo,_l)|0,wn=wn+Math.imul(Wo,Ll)|0,zn=zn+Math.imul(Wo,_l)|0,Nn=Nn+Math.imul(yo,xl)|0,wn=wn+Math.imul(yo,Tl)|0,wn=wn+Math.imul(_o,xl)|0,zn=zn+Math.imul(_o,Tl)|0,Nn=Nn+Math.imul(lo,Bl)|0,wn=wn+Math.imul(lo,Il)|0,wn=wn+Math.imul(Eo,Bl)|0,zn=zn+Math.imul(Eo,Il)|0,Nn=Nn+Math.imul(vo,Al)|0,wn=wn+Math.imul(vo,Ml)|0,wn=wn+Math.imul(go,Al)|0,zn=zn+Math.imul(go,Ml)|0;var hu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(hu>>>26)|0,hu&=67108863,Nn=Math.imul(No,Do),wn=Math.imul(No,zo),wn=wn+Math.imul(Fo,Do)|0,zn=Math.imul(Fo,zo),Nn=Nn+Math.imul(qo,Ll)|0,wn=wn+Math.imul(qo,_l)|0,wn=wn+Math.imul(ga,Ll)|0,zn=zn+Math.imul(ga,_l)|0,Nn=Nn+Math.imul(Lo,xl)|0,wn=wn+Math.imul(Lo,Tl)|0,wn=wn+Math.imul(Wo,xl)|0,zn=zn+Math.imul(Wo,Tl)|0,Nn=Nn+Math.imul(yo,Bl)|0,wn=wn+Math.imul(yo,Il)|0,wn=wn+Math.imul(_o,Bl)|0,zn=zn+Math.imul(_o,Il)|0,Nn=Nn+Math.imul(lo,Al)|0,wn=wn+Math.imul(lo,Ml)|0,wn=wn+Math.imul(Eo,Al)|0,zn=zn+Math.imul(Eo,Ml)|0,Nn=Nn+Math.imul(vo,Ul)|0,wn=wn+Math.imul(vo,Sl)|0,wn=wn+Math.imul(go,Ul)|0,zn=zn+Math.imul(go,Sl)|0;var mu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(mu>>>26)|0,mu&=67108863,Nn=Math.imul(Vo,Do),wn=Math.imul(Vo,zo),wn=wn+Math.imul(Uo,Do)|0,zn=Math.imul(Uo,zo),Nn=Nn+Math.imul(No,Ll)|0,wn=wn+Math.imul(No,_l)|0,wn=wn+Math.imul(Fo,Ll)|0,zn=zn+Math.imul(Fo,_l)|0,Nn=Nn+Math.imul(qo,xl)|0,wn=wn+Math.imul(qo,Tl)|0,wn=wn+Math.imul(ga,xl)|0,zn=zn+Math.imul(ga,Tl)|0,Nn=Nn+Math.imul(Lo,Bl)|0,wn=wn+Math.imul(Lo,Il)|0,wn=wn+Math.imul(Wo,Bl)|0,zn=zn+Math.imul(Wo,Il)|0,Nn=Nn+Math.imul(yo,Al)|0,wn=wn+Math.imul(yo,Ml)|0,wn=wn+Math.imul(_o,Al)|0,zn=zn+Math.imul(_o,Ml)|0,Nn=Nn+Math.imul(lo,Ul)|0,wn=wn+Math.imul(lo,Sl)|0,wn=wn+Math.imul(Eo,Ul)|0,zn=zn+Math.imul(Eo,Sl)|0,Nn=Nn+Math.imul(vo,So)|0,wn=wn+Math.imul(vo,Co)|0,wn=wn+Math.imul(go,So)|0,zn=zn+Math.imul(go,Co)|0;var vu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(vu>>>26)|0,vu&=67108863,Nn=Math.imul($a,Do),wn=Math.imul($a,zo),wn=wn+Math.imul(Jo,Do)|0,zn=Math.imul(Jo,zo),Nn=Nn+Math.imul(Vo,Ll)|0,wn=wn+Math.imul(Vo,_l)|0,wn=wn+Math.imul(Uo,Ll)|0,zn=zn+Math.imul(Uo,_l)|0,Nn=Nn+Math.imul(No,xl)|0,wn=wn+Math.imul(No,Tl)|0,wn=wn+Math.imul(Fo,xl)|0,zn=zn+Math.imul(Fo,Tl)|0,Nn=Nn+Math.imul(qo,Bl)|0,wn=wn+Math.imul(qo,Il)|0,wn=wn+Math.imul(ga,Bl)|0,zn=zn+Math.imul(ga,Il)|0,Nn=Nn+Math.imul(Lo,Al)|0,wn=wn+Math.imul(Lo,Ml)|0,wn=wn+Math.imul(Wo,Al)|0,zn=zn+Math.imul(Wo,Ml)|0,Nn=Nn+Math.imul(yo,Ul)|0,wn=wn+Math.imul(yo,Sl)|0,wn=wn+Math.imul(_o,Ul)|0,zn=zn+Math.imul(_o,Sl)|0,Nn=Nn+Math.imul(lo,So)|0,wn=wn+Math.imul(lo,Co)|0,wn=wn+Math.imul(Eo,So)|0,zn=zn+Math.imul(Eo,Co)|0,Nn=Nn+Math.imul(vo,po)|0,wn=wn+Math.imul(vo,Ro)|0,wn=wn+Math.imul(go,po)|0,zn=zn+Math.imul(go,Ro)|0;var fu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(fu>>>26)|0,fu&=67108863,Nn=Math.imul(Cl,Do),wn=Math.imul(Cl,zo),wn=wn+Math.imul(ko,Do)|0,zn=Math.imul(ko,zo),Nn=Nn+Math.imul($a,Ll)|0,wn=wn+Math.imul($a,_l)|0,wn=wn+Math.imul(Jo,Ll)|0,zn=zn+Math.imul(Jo,_l)|0,Nn=Nn+Math.imul(Vo,xl)|0,wn=wn+Math.imul(Vo,Tl)|0,wn=wn+Math.imul(Uo,xl)|0,zn=zn+Math.imul(Uo,Tl)|0,Nn=Nn+Math.imul(No,Bl)|0,wn=wn+Math.imul(No,Il)|0,wn=wn+Math.imul(Fo,Bl)|0,zn=zn+Math.imul(Fo,Il)|0,Nn=Nn+Math.imul(qo,Al)|0,wn=wn+Math.imul(qo,Ml)|0,wn=wn+Math.imul(ga,Al)|0,zn=zn+Math.imul(ga,Ml)|0,Nn=Nn+Math.imul(Lo,Ul)|0,wn=wn+Math.imul(Lo,Sl)|0,wn=wn+Math.imul(Wo,Ul)|0,zn=zn+Math.imul(Wo,Sl)|0,Nn=Nn+Math.imul(yo,So)|0,wn=wn+Math.imul(yo,Co)|0,wn=wn+Math.imul(_o,So)|0,zn=zn+Math.imul(_o,Co)|0,Nn=Nn+Math.imul(lo,po)|0,wn=wn+Math.imul(lo,Ro)|0,wn=wn+Math.imul(Eo,po)|0,zn=zn+Math.imul(Eo,Ro)|0,Nn=Nn+Math.imul(vo,jo)|0,wn=wn+Math.imul(vo,Ko)|0,wn=wn+Math.imul(go,jo)|0,zn=zn+Math.imul(go,Ko)|0;var gu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(gu>>>26)|0,gu&=67108863,Nn=Math.imul(bo,Do),wn=Math.imul(bo,zo),wn=wn+Math.imul(Io,Do)|0,zn=Math.imul(Io,zo),Nn=Nn+Math.imul(Cl,Ll)|0,wn=wn+Math.imul(Cl,_l)|0,wn=wn+Math.imul(ko,Ll)|0,zn=zn+Math.imul(ko,_l)|0,Nn=Nn+Math.imul($a,xl)|0,wn=wn+Math.imul($a,Tl)|0,wn=wn+Math.imul(Jo,xl)|0,zn=zn+Math.imul(Jo,Tl)|0,Nn=Nn+Math.imul(Vo,Bl)|0,wn=wn+Math.imul(Vo,Il)|0,wn=wn+Math.imul(Uo,Bl)|0,zn=zn+Math.imul(Uo,Il)|0,Nn=Nn+Math.imul(No,Al)|0,wn=wn+Math.imul(No,Ml)|0,wn=wn+Math.imul(Fo,Al)|0,zn=zn+Math.imul(Fo,Ml)|0,Nn=Nn+Math.imul(qo,Ul)|0,wn=wn+Math.imul(qo,Sl)|0,wn=wn+Math.imul(ga,Ul)|0,zn=zn+Math.imul(ga,Sl)|0,Nn=Nn+Math.imul(Lo,So)|0,wn=wn+Math.imul(Lo,Co)|0,wn=wn+Math.imul(Wo,So)|0,zn=zn+Math.imul(Wo,Co)|0,Nn=Nn+Math.imul(yo,po)|0,wn=wn+Math.imul(yo,Ro)|0,wn=wn+Math.imul(_o,po)|0,zn=zn+Math.imul(_o,Ro)|0,Nn=Nn+Math.imul(lo,jo)|0,wn=wn+Math.imul(lo,Ko)|0,wn=wn+Math.imul(Eo,jo)|0,zn=zn+Math.imul(Eo,Ko)|0,Nn=Nn+Math.imul(vo,$l)|0,wn=wn+Math.imul(vo,El)|0,wn=wn+Math.imul(go,$l)|0,zn=zn+Math.imul(go,El)|0;var ou=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(ou>>>26)|0,ou&=67108863,Nn=Math.imul(bo,Ll),wn=Math.imul(bo,_l),wn=wn+Math.imul(Io,Ll)|0,zn=Math.imul(Io,_l),Nn=Nn+Math.imul(Cl,xl)|0,wn=wn+Math.imul(Cl,Tl)|0,wn=wn+Math.imul(ko,xl)|0,zn=zn+Math.imul(ko,Tl)|0,Nn=Nn+Math.imul($a,Bl)|0,wn=wn+Math.imul($a,Il)|0,wn=wn+Math.imul(Jo,Bl)|0,zn=zn+Math.imul(Jo,Il)|0,Nn=Nn+Math.imul(Vo,Al)|0,wn=wn+Math.imul(Vo,Ml)|0,wn=wn+Math.imul(Uo,Al)|0,zn=zn+Math.imul(Uo,Ml)|0,Nn=Nn+Math.imul(No,Ul)|0,wn=wn+Math.imul(No,Sl)|0,wn=wn+Math.imul(Fo,Ul)|0,zn=zn+Math.imul(Fo,Sl)|0,Nn=Nn+Math.imul(qo,So)|0,wn=wn+Math.imul(qo,Co)|0,wn=wn+Math.imul(ga,So)|0,zn=zn+Math.imul(ga,Co)|0,Nn=Nn+Math.imul(Lo,po)|0,wn=wn+Math.imul(Lo,Ro)|0,wn=wn+Math.imul(Wo,po)|0,zn=zn+Math.imul(Wo,Ro)|0,Nn=Nn+Math.imul(yo,jo)|0,wn=wn+Math.imul(yo,Ko)|0,wn=wn+Math.imul(_o,jo)|0,zn=zn+Math.imul(_o,Ko)|0,Nn=Nn+Math.imul(lo,$l)|0,wn=wn+Math.imul(lo,El)|0,wn=wn+Math.imul(Eo,$l)|0,zn=zn+Math.imul(Eo,El)|0;var su=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(su>>>26)|0,su&=67108863,Nn=Math.imul(bo,xl),wn=Math.imul(bo,Tl),wn=wn+Math.imul(Io,xl)|0,zn=Math.imul(Io,Tl),Nn=Nn+Math.imul(Cl,Bl)|0,wn=wn+Math.imul(Cl,Il)|0,wn=wn+Math.imul(ko,Bl)|0,zn=zn+Math.imul(ko,Il)|0,Nn=Nn+Math.imul($a,Al)|0,wn=wn+Math.imul($a,Ml)|0,wn=wn+Math.imul(Jo,Al)|0,zn=zn+Math.imul(Jo,Ml)|0,Nn=Nn+Math.imul(Vo,Ul)|0,wn=wn+Math.imul(Vo,Sl)|0,wn=wn+Math.imul(Uo,Ul)|0,zn=zn+Math.imul(Uo,Sl)|0,Nn=Nn+Math.imul(No,So)|0,wn=wn+Math.imul(No,Co)|0,wn=wn+Math.imul(Fo,So)|0,zn=zn+Math.imul(Fo,Co)|0,Nn=Nn+Math.imul(qo,po)|0,wn=wn+Math.imul(qo,Ro)|0,wn=wn+Math.imul(ga,po)|0,zn=zn+Math.imul(ga,Ro)|0,Nn=Nn+Math.imul(Lo,jo)|0,wn=wn+Math.imul(Lo,Ko)|0,wn=wn+Math.imul(Wo,jo)|0,zn=zn+Math.imul(Wo,Ko)|0,Nn=Nn+Math.imul(yo,$l)|0,wn=wn+Math.imul(yo,El)|0,wn=wn+Math.imul(_o,$l)|0,zn=zn+Math.imul(_o,El)|0;var tu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(tu>>>26)|0,tu&=67108863,Nn=Math.imul(bo,Bl),wn=Math.imul(bo,Il),wn=wn+Math.imul(Io,Bl)|0,zn=Math.imul(Io,Il),Nn=Nn+Math.imul(Cl,Al)|0,wn=wn+Math.imul(Cl,Ml)|0,wn=wn+Math.imul(ko,Al)|0,zn=zn+Math.imul(ko,Ml)|0,Nn=Nn+Math.imul($a,Ul)|0,wn=wn+Math.imul($a,Sl)|0,wn=wn+Math.imul(Jo,Ul)|0,zn=zn+Math.imul(Jo,Sl)|0,Nn=Nn+Math.imul(Vo,So)|0,wn=wn+Math.imul(Vo,Co)|0,wn=wn+Math.imul(Uo,So)|0,zn=zn+Math.imul(Uo,Co)|0,Nn=Nn+Math.imul(No,po)|0,wn=wn+Math.imul(No,Ro)|0,wn=wn+Math.imul(Fo,po)|0,zn=zn+Math.imul(Fo,Ro)|0,Nn=Nn+Math.imul(qo,jo)|0,wn=wn+Math.imul(qo,Ko)|0,wn=wn+Math.imul(ga,jo)|0,zn=zn+Math.imul(ga,Ko)|0,Nn=Nn+Math.imul(Lo,$l)|0,wn=wn+Math.imul(Lo,El)|0,wn=wn+Math.imul(Wo,$l)|0,zn=zn+Math.imul(Wo,El)|0;var zl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(zl>>>26)|0,zl&=67108863,Nn=Math.imul(bo,Al),wn=Math.imul(bo,Ml),wn=wn+Math.imul(Io,Al)|0,zn=Math.imul(Io,Ml),Nn=Nn+Math.imul(Cl,Ul)|0,wn=wn+Math.imul(Cl,Sl)|0,wn=wn+Math.imul(ko,Ul)|0,zn=zn+Math.imul(ko,Sl)|0,Nn=Nn+Math.imul($a,So)|0,wn=wn+Math.imul($a,Co)|0,wn=wn+Math.imul(Jo,So)|0,zn=zn+Math.imul(Jo,Co)|0,Nn=Nn+Math.imul(Vo,po)|0,wn=wn+Math.imul(Vo,Ro)|0,wn=wn+Math.imul(Uo,po)|0,zn=zn+Math.imul(Uo,Ro)|0,Nn=Nn+Math.imul(No,jo)|0,wn=wn+Math.imul(No,Ko)|0,wn=wn+Math.imul(Fo,jo)|0,zn=zn+Math.imul(Fo,Ko)|0,Nn=Nn+Math.imul(qo,$l)|0,wn=wn+Math.imul(qo,El)|0,wn=wn+Math.imul(ga,$l)|0,zn=zn+Math.imul(ga,El)|0;var Gl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Gl>>>26)|0,Gl&=67108863,Nn=Math.imul(bo,Ul),wn=Math.imul(bo,Sl),wn=wn+Math.imul(Io,Ul)|0,zn=Math.imul(Io,Sl),Nn=Nn+Math.imul(Cl,So)|0,wn=wn+Math.imul(Cl,Co)|0,wn=wn+Math.imul(ko,So)|0,zn=zn+Math.imul(ko,Co)|0,Nn=Nn+Math.imul($a,po)|0,wn=wn+Math.imul($a,Ro)|0,wn=wn+Math.imul(Jo,po)|0,zn=zn+Math.imul(Jo,Ro)|0,Nn=Nn+Math.imul(Vo,jo)|0,wn=wn+Math.imul(Vo,Ko)|0,wn=wn+Math.imul(Uo,jo)|0,zn=zn+Math.imul(Uo,Ko)|0,Nn=Nn+Math.imul(No,$l)|0,wn=wn+Math.imul(No,El)|0,wn=wn+Math.imul(Fo,$l)|0,zn=zn+Math.imul(Fo,El)|0;var Jl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Jl>>>26)|0,Jl&=67108863,Nn=Math.imul(bo,So),wn=Math.imul(bo,Co),wn=wn+Math.imul(Io,So)|0,zn=Math.imul(Io,Co),Nn=Nn+Math.imul(Cl,po)|0,wn=wn+Math.imul(Cl,Ro)|0,wn=wn+Math.imul(ko,po)|0,zn=zn+Math.imul(ko,Ro)|0,Nn=Nn+Math.imul($a,jo)|0,wn=wn+Math.imul($a,Ko)|0,wn=wn+Math.imul(Jo,jo)|0,zn=zn+Math.imul(Jo,Ko)|0,Nn=Nn+Math.imul(Vo,$l)|0,wn=wn+Math.imul(Vo,El)|0,wn=wn+Math.imul(Uo,$l)|0,zn=zn+Math.imul(Uo,El)|0;var Pl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Pl>>>26)|0,Pl&=67108863,Nn=Math.imul(bo,po),wn=Math.imul(bo,Ro),wn=wn+Math.imul(Io,po)|0,zn=Math.imul(Io,Ro),Nn=Nn+Math.imul(Cl,jo)|0,wn=wn+Math.imul(Cl,Ko)|0,wn=wn+Math.imul(ko,jo)|0,zn=zn+Math.imul(ko,Ko)|0,Nn=Nn+Math.imul($a,$l)|0,wn=wn+Math.imul($a,El)|0,wn=wn+Math.imul(Jo,$l)|0,zn=zn+Math.imul(Jo,El)|0;var Fl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Fl>>>26)|0,Fl&=67108863,Nn=Math.imul(bo,jo),wn=Math.imul(bo,Ko),wn=wn+Math.imul(Io,jo)|0,zn=Math.imul(Io,Ko),Nn=Nn+Math.imul(Cl,$l)|0,wn=wn+Math.imul(Cl,El)|0,wn=wn+Math.imul(ko,$l)|0,zn=zn+Math.imul(ko,El)|0;var Yl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Yl>>>26)|0,Yl&=67108863,Nn=Math.imul(bo,$l),wn=Math.imul(bo,El),wn=wn+Math.imul(Io,$l)|0,zn=Math.imul(Io,El);var Vl=(Zn+Nn|0)+((wn&8191)<<13)|0;return Zn=(zn+(wn>>>13)|0)+(Vl>>>26)|0,Vl&=67108863,On[0]=Cu,On[1]=iu,On[2]=pu,On[3]=yu,On[4]=hu,On[5]=mu,On[6]=vu,On[7]=fu,On[8]=gu,On[9]=ou,On[10]=su,On[11]=tu,On[12]=zl,On[13]=Gl,On[14]=Jl,On[15]=Pl,On[16]=Fl,On[17]=Yl,On[18]=Vl,Zn!==0&&(On[19]=Zn,Sn.length++),Sn};Math.imul||(An=In);function jn(Tn,Gr,Xr){Xr.negative=Gr.negative^Tn.negative,Xr.length=Tn.length+Gr.length;for(var Sn=0,Rn=0,Pn=0;Pn>>26)|0,Rn+=On>>>26,On&=67108863}Xr.words[Pn]=Zn,Sn=On,On=Rn}return Sn!==0?Xr.words[Pn]=Sn:Xr.length--,Xr._strip()}function eo(Tn,Gr,Xr){return jn(Tn,Gr,Xr)}jr.prototype.mulTo=function(Gr,Xr){var Sn,Rn=this.length+Gr.length;return this.length===10&&Gr.length===10?Sn=An(this,Gr,Xr):Rn<63?Sn=In(this,Gr,Xr):Rn<1024?Sn=jn(this,Gr,Xr):Sn=eo(this,Gr,Xr),Sn},jr.prototype.mul=function(Gr){var Xr=new jr(null);return Xr.words=new Array(this.length+Gr.length),this.mulTo(Gr,Xr)},jr.prototype.mulf=function(Gr){var Xr=new jr(null);return Xr.words=new Array(this.length+Gr.length),eo(this,Gr,Xr)},jr.prototype.imul=function(Gr){return this.clone().mulTo(Gr,this)},jr.prototype.imuln=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(typeof Gr=="number"),Er(Gr<67108864);for(var Sn=0,Rn=0;Rn>=26,Sn+=Pn/67108864|0,Sn+=On>>>26,this.words[Rn]=On&67108863}return Sn!==0&&(this.words[Rn]=Sn,this.length++),Xr?this.ineg():this},jr.prototype.muln=function(Gr){return this.clone().imuln(Gr)},jr.prototype.sqr=function(){return this.mul(this)},jr.prototype.isqr=function(){return this.imul(this.clone())},jr.prototype.pow=function(Gr){var Xr=Cn(Gr);if(Xr.length===0)return new jr(1);for(var Sn=this,Rn=0;Rn=0);var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=67108863>>>26-Xr<<26-Xr,Pn;if(Xr!==0){var On=0;for(Pn=0;Pn>>26-Xr}On&&(this.words[Pn]=On,this.length++)}if(Sn!==0){for(Pn=this.length-1;Pn>=0;Pn--)this.words[Pn+Sn]=this.words[Pn];for(Pn=0;Pn=0);var Rn;Xr?Rn=(Xr-Xr%26)/26:Rn=0;var Pn=Gr%26,On=Math.min((Gr-Pn)/26,this.length),Zn=67108863^67108863>>>Pn<On)for(this.length-=On,wn=0;wn=0&&(zn!==0||wn>=Rn);wn--){var fo=this.words[wn]|0;this.words[wn]=zn<<26-Pn|fo>>>Pn,zn=fo&Zn}return Nn&&zn!==0&&(Nn.words[Nn.length++]=zn),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},jr.prototype.ishrn=function(Gr,Xr,Sn){return Er(this.negative===0),this.iushrn(Gr,Xr,Sn)},jr.prototype.shln=function(Gr){return this.clone().ishln(Gr)},jr.prototype.ushln=function(Gr){return this.clone().iushln(Gr)},jr.prototype.shrn=function(Gr){return this.clone().ishrn(Gr)},jr.prototype.ushrn=function(Gr){return this.clone().iushrn(Gr)},jr.prototype.testn=function(Gr){Er(typeof Gr=="number"&&Gr>=0);var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=1<=0);var Xr=Gr%26,Sn=(Gr-Xr)/26;if(Er(this.negative===0,"imaskn works only with positive numbers"),this.length<=Sn)return this;if(Xr!==0&&Sn++,this.length=Math.min(Sn,this.length),Xr!==0){var Rn=67108863^67108863>>>Xr<=67108864;Xr++)this.words[Xr]-=67108864,Xr===this.length-1?this.words[Xr+1]=1:this.words[Xr+1]++;return this.length=Math.max(this.length,Xr+1),this},jr.prototype.isubn=function(Gr){if(Er(typeof Gr=="number"),Er(Gr<67108864),Gr<0)return this.iaddn(-Gr);if(this.negative!==0)return this.negative=0,this.iaddn(Gr),this.negative=1,this;if(this.words[0]-=Gr,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var Xr=0;Xr>26)-(Nn/67108864|0),this.words[Pn+Sn]=On&67108863}for(;Pn>26,this.words[Pn+Sn]=On&67108863;if(Zn===0)return this._strip();for(Er(Zn===-1),Zn=0,Pn=0;Pn>26,this.words[Pn]=On&67108863;return this.negative=1,this._strip()},jr.prototype._wordDiv=function(Gr,Xr){var Sn=this.length-Gr.length,Rn=this.clone(),Pn=Gr,On=Pn.words[Pn.length-1]|0,Zn=this._countBits(On);Sn=26-Zn,Sn!==0&&(Pn=Pn.ushln(Sn),Rn.iushln(Sn),On=Pn.words[Pn.length-1]|0);var Nn=Rn.length-Pn.length,wn;if(Xr!=="mod"){wn=new jr(null),wn.length=Nn+1,wn.words=new Array(wn.length);for(var zn=0;zn=0;vo--){var go=(Rn.words[Pn.length+vo]|0)*67108864+(Rn.words[Pn.length+vo-1]|0);for(go=Math.min(go/On|0,67108863),Rn._ishlnsubmul(Pn,go,vo);Rn.negative!==0;)go--,Rn.negative=0,Rn._ishlnsubmul(Pn,1,vo),Rn.isZero()||(Rn.negative^=1);wn&&(wn.words[vo]=go)}return wn&&wn._strip(),Rn._strip(),Xr!=="div"&&Sn!==0&&Rn.iushrn(Sn),{div:wn||null,mod:Rn}},jr.prototype.divmod=function(Gr,Xr,Sn){if(Er(!Gr.isZero()),this.isZero())return{div:new jr(0),mod:new jr(0)};var Rn,Pn,On;return this.negative!==0&&Gr.negative===0?(On=this.neg().divmod(Gr,Xr),Xr!=="mod"&&(Rn=On.div.neg()),Xr!=="div"&&(Pn=On.mod.neg(),Sn&&Pn.negative!==0&&Pn.iadd(Gr)),{div:Rn,mod:Pn}):this.negative===0&&Gr.negative!==0?(On=this.divmod(Gr.neg(),Xr),Xr!=="mod"&&(Rn=On.div.neg()),{div:Rn,mod:On.mod}):this.negative&Gr.negative?(On=this.neg().divmod(Gr.neg(),Xr),Xr!=="div"&&(Pn=On.mod.neg(),Sn&&Pn.negative!==0&&Pn.isub(Gr)),{div:On.div,mod:Pn}):Gr.length>this.length||this.cmp(Gr)<0?{div:new jr(0),mod:this}:Gr.length===1?Xr==="div"?{div:this.divn(Gr.words[0]),mod:null}:Xr==="mod"?{div:null,mod:new jr(this.modrn(Gr.words[0]))}:{div:this.divn(Gr.words[0]),mod:new jr(this.modrn(Gr.words[0]))}:this._wordDiv(Gr,Xr)},jr.prototype.div=function(Gr){return this.divmod(Gr,"div",!1).div},jr.prototype.mod=function(Gr){return this.divmod(Gr,"mod",!1).mod},jr.prototype.umod=function(Gr){return this.divmod(Gr,"mod",!0).mod},jr.prototype.divRound=function(Gr){var Xr=this.divmod(Gr);if(Xr.mod.isZero())return Xr.div;var Sn=Xr.div.negative!==0?Xr.mod.isub(Gr):Xr.mod,Rn=Gr.ushrn(1),Pn=Gr.andln(1),On=Sn.cmp(Rn);return On<0||Pn===1&&On===0?Xr.div:Xr.div.negative!==0?Xr.div.isubn(1):Xr.div.iaddn(1)},jr.prototype.modrn=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(Gr<=67108863);for(var Sn=(1<<26)%Gr,Rn=0,Pn=this.length-1;Pn>=0;Pn--)Rn=(Sn*Rn+(this.words[Pn]|0))%Gr;return Xr?-Rn:Rn},jr.prototype.modn=function(Gr){return this.modrn(Gr)},jr.prototype.idivn=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(Gr<=67108863);for(var Sn=0,Rn=this.length-1;Rn>=0;Rn--){var Pn=(this.words[Rn]|0)+Sn*67108864;this.words[Rn]=Pn/Gr|0,Sn=Pn%Gr}return this._strip(),Xr?this.ineg():this},jr.prototype.divn=function(Gr){return this.clone().idivn(Gr)},jr.prototype.egcd=function(Gr){Er(Gr.negative===0),Er(!Gr.isZero());var Xr=this,Sn=Gr.clone();Xr.negative!==0?Xr=Xr.umod(Gr):Xr=Xr.clone();for(var Rn=new jr(1),Pn=new jr(0),On=new jr(0),Zn=new jr(1),Nn=0;Xr.isEven()&&Sn.isEven();)Xr.iushrn(1),Sn.iushrn(1),++Nn;for(var wn=Sn.clone(),zn=Xr.clone();!Xr.isZero();){for(var fo=0,vo=1;!(Xr.words[0]&vo)&&fo<26;++fo,vo<<=1);if(fo>0)for(Xr.iushrn(fo);fo-- >0;)(Rn.isOdd()||Pn.isOdd())&&(Rn.iadd(wn),Pn.isub(zn)),Rn.iushrn(1),Pn.iushrn(1);for(var go=0,uo=1;!(Sn.words[0]&uo)&&go<26;++go,uo<<=1);if(go>0)for(Sn.iushrn(go);go-- >0;)(On.isOdd()||Zn.isOdd())&&(On.iadd(wn),Zn.isub(zn)),On.iushrn(1),Zn.iushrn(1);Xr.cmp(Sn)>=0?(Xr.isub(Sn),Rn.isub(On),Pn.isub(Zn)):(Sn.isub(Xr),On.isub(Rn),Zn.isub(Pn))}return{a:On,b:Zn,gcd:Sn.iushln(Nn)}},jr.prototype._invmp=function(Gr){Er(Gr.negative===0),Er(!Gr.isZero());var Xr=this,Sn=Gr.clone();Xr.negative!==0?Xr=Xr.umod(Gr):Xr=Xr.clone();for(var Rn=new jr(1),Pn=new jr(0),On=Sn.clone();Xr.cmpn(1)>0&&Sn.cmpn(1)>0;){for(var Zn=0,Nn=1;!(Xr.words[0]&Nn)&&Zn<26;++Zn,Nn<<=1);if(Zn>0)for(Xr.iushrn(Zn);Zn-- >0;)Rn.isOdd()&&Rn.iadd(On),Rn.iushrn(1);for(var wn=0,zn=1;!(Sn.words[0]&zn)&&wn<26;++wn,zn<<=1);if(wn>0)for(Sn.iushrn(wn);wn-- >0;)Pn.isOdd()&&Pn.iadd(On),Pn.iushrn(1);Xr.cmp(Sn)>=0?(Xr.isub(Sn),Rn.isub(Pn)):(Sn.isub(Xr),Pn.isub(Rn))}var fo;return Xr.cmpn(1)===0?fo=Rn:fo=Pn,fo.cmpn(0)<0&&fo.iadd(Gr),fo},jr.prototype.gcd=function(Gr){if(this.isZero())return Gr.abs();if(Gr.isZero())return this.abs();var Xr=this.clone(),Sn=Gr.clone();Xr.negative=0,Sn.negative=0;for(var Rn=0;Xr.isEven()&&Sn.isEven();Rn++)Xr.iushrn(1),Sn.iushrn(1);do{for(;Xr.isEven();)Xr.iushrn(1);for(;Sn.isEven();)Sn.iushrn(1);var Pn=Xr.cmp(Sn);if(Pn<0){var On=Xr;Xr=Sn,Sn=On}else if(Pn===0||Sn.cmpn(1)===0)break;Xr.isub(Sn)}while(!0);return Sn.iushln(Rn)},jr.prototype.invm=function(Gr){return this.egcd(Gr).a.umod(Gr)},jr.prototype.isEven=function(){return(this.words[0]&1)===0},jr.prototype.isOdd=function(){return(this.words[0]&1)===1},jr.prototype.andln=function(Gr){return this.words[0]&Gr},jr.prototype.bincn=function(Gr){Er(typeof Gr=="number");var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=1<>>26,Zn&=67108863,this.words[On]=Zn}return Pn!==0&&(this.words[On]=Pn,this.length++),this},jr.prototype.isZero=function(){return this.length===1&&this.words[0]===0},jr.prototype.cmpn=function(Gr){var Xr=Gr<0;if(this.negative!==0&&!Xr)return-1;if(this.negative===0&&Xr)return 1;this._strip();var Sn;if(this.length>1)Sn=1;else{Xr&&(Gr=-Gr),Er(Gr<=67108863,"Number is too big");var Rn=this.words[0]|0;Sn=Rn===Gr?0:RnGr.length)return 1;if(this.length=0;Sn--){var Rn=this.words[Sn]|0,Pn=Gr.words[Sn]|0;if(Rn!==Pn){RnPn&&(Xr=1);break}}return Xr},jr.prototype.gtn=function(Gr){return this.cmpn(Gr)===1},jr.prototype.gt=function(Gr){return this.cmp(Gr)===1},jr.prototype.gten=function(Gr){return this.cmpn(Gr)>=0},jr.prototype.gte=function(Gr){return this.cmp(Gr)>=0},jr.prototype.ltn=function(Gr){return this.cmpn(Gr)===-1},jr.prototype.lt=function(Gr){return this.cmp(Gr)===-1},jr.prototype.lten=function(Gr){return this.cmpn(Gr)<=0},jr.prototype.lte=function(Gr){return this.cmp(Gr)<=0},jr.prototype.eqn=function(Gr){return this.cmpn(Gr)===0},jr.prototype.eq=function(Gr){return this.cmp(Gr)===0},jr.red=function(Gr){return new so(Gr)},jr.prototype.toRed=function(Gr){return Er(!this.red,"Already a number in reduction context"),Er(this.negative===0,"red works only with positives"),Gr.convertTo(this)._forceRed(Gr)},jr.prototype.fromRed=function(){return Er(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},jr.prototype._forceRed=function(Gr){return this.red=Gr,this},jr.prototype.forceRed=function(Gr){return Er(!this.red,"Already a number in reduction context"),this._forceRed(Gr)},jr.prototype.redAdd=function(Gr){return Er(this.red,"redAdd works only with red numbers"),this.red.add(this,Gr)},jr.prototype.redIAdd=function(Gr){return Er(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,Gr)},jr.prototype.redSub=function(Gr){return Er(this.red,"redSub works only with red numbers"),this.red.sub(this,Gr)},jr.prototype.redISub=function(Gr){return Er(this.red,"redISub works only with red numbers"),this.red.isub(this,Gr)},jr.prototype.redShl=function(Gr){return Er(this.red,"redShl works only with red numbers"),this.red.shl(this,Gr)},jr.prototype.redMul=function(Gr){return Er(this.red,"redMul works only with red numbers"),this.red._verify2(this,Gr),this.red.mul(this,Gr)},jr.prototype.redIMul=function(Gr){return Er(this.red,"redMul works only with red numbers"),this.red._verify2(this,Gr),this.red.imul(this,Gr)},jr.prototype.redSqr=function(){return Er(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},jr.prototype.redISqr=function(){return Er(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},jr.prototype.redSqrt=function(){return Er(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},jr.prototype.redInvm=function(){return Er(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},jr.prototype.redNeg=function(){return Er(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},jr.prototype.redPow=function(Gr){return Er(this.red&&!Gr.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,Gr)};var ro={k256:null,p224:null,p192:null,p25519:null};function to(Tn,Gr){this.name=Tn,this.p=new jr(Gr,16),this.n=this.p.bitLength(),this.k=new jr(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}to.prototype._tmp=function(){var Gr=new jr(null);return Gr.words=new Array(Math.ceil(this.n/13)),Gr},to.prototype.ireduce=function(Gr){var Xr=Gr,Sn;do this.split(Xr,this.tmp),Xr=this.imulK(Xr),Xr=Xr.iadd(this.tmp),Sn=Xr.bitLength();while(Sn>this.n);var Rn=Sn0?Xr.isub(this.p):Xr.strip!==void 0?Xr.strip():Xr._strip(),Xr},to.prototype.split=function(Gr,Xr){Gr.iushrn(this.n,0,Xr)},to.prototype.imulK=function(Gr){return Gr.imul(this.k)};function _i(){to.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}kr(_i,to),_i.prototype.split=function(Gr,Xr){for(var Sn=4194303,Rn=Math.min(Gr.length,9),Pn=0;Pn>>22,On=Zn}On>>>=22,Gr.words[Pn-10]=On,On===0&&Gr.length>10?Gr.length-=10:Gr.length-=9},_i.prototype.imulK=function(Gr){Gr.words[Gr.length]=0,Gr.words[Gr.length+1]=0,Gr.length+=2;for(var Xr=0,Sn=0;Sn>>=26,Gr.words[Sn]=Pn,Xr=Rn}return Xr!==0&&(Gr.words[Gr.length++]=Xr),Gr},jr._prime=function(Gr){if(ro[Gr])return ro[Gr];var Xr;if(Gr==="k256")Xr=new _i;else if(Gr==="p224")Xr=new oo;else if(Gr==="p192")Xr=new io;else if(Gr==="p25519")Xr=new co;else throw new Error("Unknown prime "+Gr);return ro[Gr]=Xr,Xr};function so(Tn){if(typeof Tn=="string"){var Gr=jr._prime(Tn);this.m=Gr.p,this.prime=Gr}else Er(Tn.gtn(1),"modulus must be greater than 1"),this.m=Tn,this.prime=null}so.prototype._verify1=function(Gr){Er(Gr.negative===0,"red works only with positives"),Er(Gr.red,"red works only with red numbers")},so.prototype._verify2=function(Gr,Xr){Er((Gr.negative|Xr.negative)===0,"red works only with positives"),Er(Gr.red&&Gr.red===Xr.red,"red works only with red numbers")},so.prototype.imod=function(Gr){return this.prime?this.prime.ireduce(Gr)._forceRed(this):(Vr(Gr,Gr.umod(this.m)._forceRed(this)),Gr)},so.prototype.neg=function(Gr){return Gr.isZero()?Gr.clone():this.m.sub(Gr)._forceRed(this)},so.prototype.add=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.add(Xr);return Sn.cmp(this.m)>=0&&Sn.isub(this.m),Sn._forceRed(this)},so.prototype.iadd=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.iadd(Xr);return Sn.cmp(this.m)>=0&&Sn.isub(this.m),Sn},so.prototype.sub=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.sub(Xr);return Sn.cmpn(0)<0&&Sn.iadd(this.m),Sn._forceRed(this)},so.prototype.isub=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.isub(Xr);return Sn.cmpn(0)<0&&Sn.iadd(this.m),Sn},so.prototype.shl=function(Gr,Xr){return this._verify1(Gr),this.imod(Gr.ushln(Xr))},so.prototype.imul=function(Gr,Xr){return this._verify2(Gr,Xr),this.imod(Gr.imul(Xr))},so.prototype.mul=function(Gr,Xr){return this._verify2(Gr,Xr),this.imod(Gr.mul(Xr))},so.prototype.isqr=function(Gr){return this.imul(Gr,Gr.clone())},so.prototype.sqr=function(Gr){return this.mul(Gr,Gr)},so.prototype.sqrt=function(Gr){if(Gr.isZero())return Gr.clone();var Xr=this.m.andln(3);if(Er(Xr%2===1),Xr===3){var Sn=this.m.add(new jr(1)).iushrn(2);return this.pow(Gr,Sn)}for(var Rn=this.m.subn(1),Pn=0;!Rn.isZero()&&Rn.andln(1)===0;)Pn++,Rn.iushrn(1);Er(!Rn.isZero());var On=new jr(1).toRed(this),Zn=On.redNeg(),Nn=this.m.subn(1).iushrn(1),wn=this.m.bitLength();for(wn=new jr(2*wn*wn).toRed(this);this.pow(wn,Nn).cmp(Zn)!==0;)wn.redIAdd(Zn);for(var zn=this.pow(wn,Rn),fo=this.pow(Gr,Rn.addn(1).iushrn(1)),vo=this.pow(Gr,Rn),go=Pn;vo.cmp(On)!==0;){for(var uo=vo,lo=0;uo.cmp(On)!==0;lo++)uo=uo.redSqr();Er(lo=0;Pn--){for(var zn=Xr.words[Pn],fo=wn-1;fo>=0;fo--){var vo=zn>>fo&1;if(On!==Rn[0]&&(On=this.sqr(On)),vo===0&&Zn===0){Nn=0;continue}Zn<<=1,Zn|=vo,Nn++,!(Nn!==Sn&&(Pn!==0||fo!==0))&&(On=this.mul(On,Rn[Zn]),Nn=0,Zn=0)}wn=26}return On},so.prototype.convertTo=function(Gr){var Xr=Gr.umod(this.m);return Xr===Gr?Xr.clone():Xr},so.prototype.convertFrom=function(Gr){var Xr=Gr.clone();return Xr.red=null,Xr},jr.mont=function(Gr){return new no(Gr)};function no(Tn){so.call(this,Tn),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new jr(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}kr(no,so),no.prototype.convertTo=function(Gr){return this.imod(Gr.ushln(this.shift))},no.prototype.convertFrom=function(Gr){var Xr=this.imod(Gr.mul(this.rinv));return Xr.red=null,Xr},no.prototype.imul=function(Gr,Xr){if(Gr.isZero()||Xr.isZero())return Gr.words[0]=0,Gr.length=1,Gr;var Sn=Gr.imul(Xr),Rn=Sn.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Pn=Sn.isub(Rn).iushrn(this.shift),On=Pn;return Pn.cmp(this.m)>=0?On=Pn.isub(this.m):Pn.cmpn(0)<0&&(On=Pn.iadd(this.m)),On._forceRed(this)},no.prototype.mul=function(Gr,Xr){if(Gr.isZero()||Xr.isZero())return new jr(0)._forceRed(this);var Sn=Gr.mul(Xr),Rn=Sn.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Pn=Sn.isub(Rn).iushrn(this.shift),On=Pn;return Pn.cmp(this.m)>=0?On=Pn.isub(this.m):Pn.cmpn(0)<0&&(On=Pn.iadd(this.m)),On._forceRed(this)},no.prototype.invm=function(Gr){var Xr=this.imod(Gr._invmp(this.m).mul(this.r2));return Xr._forceRed(this)}})(fr,commonjsGlobal)})(bn$3);var bnExports$3=bn$3.exports;const BN$2=getDefaultExportFromCjs$2(bnExports$3);var _Buffer$3=safeBufferExports.Buffer;function base$3(fr){if(fr.length>=255)throw new TypeError("Alphabet too long");for(var br=new Uint8Array(256),wr=0;wr>>0,jn=new Uint8Array(An);Cn!==In;){for(var eo=Qr[Cn],ro=0,to=An-1;(eo!==0||ro>>0,jn[to]=eo%Br>>>0,eo=eo/Br>>>0;if(eo!==0)throw new Error("Non-zero carry");En=ro,Cn++}for(var _i=An-En;_i!==An&&jn[_i]===0;)_i++;for(var oo=Wr.repeat(_n);_i>>0,An=new Uint8Array(In);_n>>0,An[ro]=jn%256>>>0,jn=jn/256>>>0;if(jn!==0)throw new Error("Non-zero carry");Cn=eo,_n++}for(var to=In-Cn;to!==In&&An[to]===0;)to++;var _i=_Buffer$3.allocUnsafe(En+(In-to));_i.fill(0,0,En);for(var oo=En;to!==In;)_i[oo++]=An[to++];return _i}function Jr(Qr){var _n=Zr(Qr);if(_n)return _n;throw new Error("Non-base"+Br+" character")}return{encode:Vr,decodeUnsafe:Zr,decode:Jr}}var src$3=base$3,basex$3=src$3,ALPHABET$3="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",bs58$5=basex$3(ALPHABET$3);const bs58$6=getDefaultExportFromCjs$2(bs58$5);var lib={},bn$2={exports:{}};bn$2.exports;(function(fr){(function(br,wr){function Er(Tn,Gr){if(!Tn)throw new Error(Gr||"Assertion failed")}function kr(Tn,Gr){Tn.super_=Gr;var Xr=function(){};Xr.prototype=Gr.prototype,Tn.prototype=new Xr,Tn.prototype.constructor=Tn}function jr(Tn,Gr,Xr){if(jr.isBN(Tn))return Tn;this.negative=0,this.words=null,this.length=0,this.red=null,Tn!==null&&((Gr==="le"||Gr==="be")&&(Xr=Gr,Gr=10),this._init(Tn||0,Gr||10,Xr||"be"))}typeof br=="object"?br.exports=jr:wr.BN=jr,jr.BN=jr,jr.wordSize=26;var Br;try{typeof window<"u"&&typeof window.Buffer<"u"?Br=window.Buffer:Br=require$$0$9.Buffer}catch{}jr.isBN=function(Gr){return Gr instanceof jr?!0:Gr!==null&&typeof Gr=="object"&&Gr.constructor.wordSize===jr.wordSize&&Array.isArray(Gr.words)},jr.max=function(Gr,Xr){return Gr.cmp(Xr)>0?Gr:Xr},jr.min=function(Gr,Xr){return Gr.cmp(Xr)<0?Gr:Xr},jr.prototype._init=function(Gr,Xr,Sn){if(typeof Gr=="number")return this._initNumber(Gr,Xr,Sn);if(typeof Gr=="object")return this._initArray(Gr,Xr,Sn);Xr==="hex"&&(Xr=16),Er(Xr===(Xr|0)&&Xr>=2&&Xr<=36),Gr=Gr.toString().replace(/\s+/g,"");var Rn=0;Gr[0]==="-"&&(Rn++,this.negative=1),Rn=0;Rn-=3)On=Gr[Rn]|Gr[Rn-1]<<8|Gr[Rn-2]<<16,this.words[Pn]|=On<>>26-Zn&67108863,Zn+=24,Zn>=26&&(Zn-=26,Pn++);else if(Sn==="le")for(Rn=0,Pn=0;Rn>>26-Zn&67108863,Zn+=24,Zn>=26&&(Zn-=26,Pn++);return this._strip()};function Wr(Tn,Gr){var Xr=Tn.charCodeAt(Gr);if(Xr>=48&&Xr<=57)return Xr-48;if(Xr>=65&&Xr<=70)return Xr-55;if(Xr>=97&&Xr<=102)return Xr-87;Er(!1,"Invalid character in "+Tn)}function qr(Tn,Gr,Xr){var Sn=Wr(Tn,Xr);return Xr-1>=Gr&&(Sn|=Wr(Tn,Xr-1)<<4),Sn}jr.prototype._parseHex=function(Gr,Xr,Sn){this.length=Math.ceil((Gr.length-Xr)/6),this.words=new Array(this.length);for(var Rn=0;Rn=Xr;Rn-=2)Zn=qr(Gr,Xr,Rn)<=18?(Pn-=18,On+=1,this.words[On]|=Zn>>>26):Pn+=8;else{var Nn=Gr.length-Xr;for(Rn=Nn%2===0?Xr+1:Xr;Rn=18?(Pn-=18,On+=1,this.words[On]|=Zn>>>26):Pn+=8}this._strip()};function Hr(Tn,Gr,Xr,Sn){for(var Rn=0,Pn=0,On=Math.min(Tn.length,Xr),Zn=Gr;Zn=49?Pn=Nn-49+10:Nn>=17?Pn=Nn-17+10:Pn=Nn,Er(Nn>=0&&Pn1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},jr.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{jr.prototype[Symbol.for("nodejs.util.inspect.custom")]=Zr}catch{jr.prototype.inspect=Zr}else jr.prototype.inspect=Zr;function Zr(){return(this.red?""}var Jr=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],Qr=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],_n=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];jr.prototype.toString=function(Gr,Xr){Gr=Gr||10,Xr=Xr|0||1;var Sn;if(Gr===16||Gr==="hex"){Sn="";for(var Rn=0,Pn=0,On=0;On>>24-Rn&16777215,Rn+=2,Rn>=26&&(Rn-=26,On--),Pn!==0||On!==this.length-1?Sn=Jr[6-Nn.length]+Nn+Sn:Sn=Nn+Sn}for(Pn!==0&&(Sn=Pn.toString(16)+Sn);Sn.length%Xr!==0;)Sn="0"+Sn;return this.negative!==0&&(Sn="-"+Sn),Sn}if(Gr===(Gr|0)&&Gr>=2&&Gr<=36){var wn=Qr[Gr],zn=_n[Gr];Sn="";var fo=this.clone();for(fo.negative=0;!fo.isZero();){var vo=fo.modrn(zn).toString(Gr);fo=fo.idivn(zn),fo.isZero()?Sn=vo+Sn:Sn=Jr[wn-vo.length]+vo+Sn}for(this.isZero()&&(Sn="0"+Sn);Sn.length%Xr!==0;)Sn="0"+Sn;return this.negative!==0&&(Sn="-"+Sn),Sn}Er(!1,"Base should be between 2 and 36")},jr.prototype.toNumber=function(){var Gr=this.words[0];return this.length===2?Gr+=this.words[1]*67108864:this.length===3&&this.words[2]===1?Gr+=4503599627370496+this.words[1]*67108864:this.length>2&&Er(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-Gr:Gr},jr.prototype.toJSON=function(){return this.toString(16,2)},Br&&(jr.prototype.toBuffer=function(Gr,Xr){return this.toArrayLike(Br,Gr,Xr)}),jr.prototype.toArray=function(Gr,Xr){return this.toArrayLike(Array,Gr,Xr)};var En=function(Gr,Xr){return Gr.allocUnsafe?Gr.allocUnsafe(Xr):new Gr(Xr)};jr.prototype.toArrayLike=function(Gr,Xr,Sn){this._strip();var Rn=this.byteLength(),Pn=Sn||Math.max(1,Rn);Er(Rn<=Pn,"byte array longer than desired length"),Er(Pn>0,"Requested array length <= 0");var On=En(Gr,Pn),Zn=Xr==="le"?"LE":"BE";return this["_toArrayLike"+Zn](On,Rn),On},jr.prototype._toArrayLikeLE=function(Gr,Xr){for(var Sn=0,Rn=0,Pn=0,On=0;Pn>8&255),Sn>16&255),On===6?(Sn>24&255),Rn=0,On=0):(Rn=Zn>>>24,On+=2)}if(Sn=0&&(Gr[Sn--]=Zn>>8&255),Sn>=0&&(Gr[Sn--]=Zn>>16&255),On===6?(Sn>=0&&(Gr[Sn--]=Zn>>24&255),Rn=0,On=0):(Rn=Zn>>>24,On+=2)}if(Sn>=0)for(Gr[Sn--]=Rn;Sn>=0;)Gr[Sn--]=0},Math.clz32?jr.prototype._countBits=function(Gr){return 32-Math.clz32(Gr)}:jr.prototype._countBits=function(Gr){var Xr=Gr,Sn=0;return Xr>=4096&&(Sn+=13,Xr>>>=13),Xr>=64&&(Sn+=7,Xr>>>=7),Xr>=8&&(Sn+=4,Xr>>>=4),Xr>=2&&(Sn+=2,Xr>>>=2),Sn+Xr},jr.prototype._zeroBits=function(Gr){if(Gr===0)return 26;var Xr=Gr,Sn=0;return Xr&8191||(Sn+=13,Xr>>>=13),Xr&127||(Sn+=7,Xr>>>=7),Xr&15||(Sn+=4,Xr>>>=4),Xr&3||(Sn+=2,Xr>>>=2),Xr&1||Sn++,Sn},jr.prototype.bitLength=function(){var Gr=this.words[this.length-1],Xr=this._countBits(Gr);return(this.length-1)*26+Xr};function Cn(Tn){for(var Gr=new Array(Tn.bitLength()),Xr=0;Xr>>Rn&1}return Gr}jr.prototype.zeroBits=function(){if(this.isZero())return 0;for(var Gr=0,Xr=0;XrGr.length?this.clone().ior(Gr):Gr.clone().ior(this)},jr.prototype.uor=function(Gr){return this.length>Gr.length?this.clone().iuor(Gr):Gr.clone().iuor(this)},jr.prototype.iuand=function(Gr){var Xr;this.length>Gr.length?Xr=Gr:Xr=this;for(var Sn=0;SnGr.length?this.clone().iand(Gr):Gr.clone().iand(this)},jr.prototype.uand=function(Gr){return this.length>Gr.length?this.clone().iuand(Gr):Gr.clone().iuand(this)},jr.prototype.iuxor=function(Gr){var Xr,Sn;this.length>Gr.length?(Xr=this,Sn=Gr):(Xr=Gr,Sn=this);for(var Rn=0;RnGr.length?this.clone().ixor(Gr):Gr.clone().ixor(this)},jr.prototype.uxor=function(Gr){return this.length>Gr.length?this.clone().iuxor(Gr):Gr.clone().iuxor(this)},jr.prototype.inotn=function(Gr){Er(typeof Gr=="number"&&Gr>=0);var Xr=Math.ceil(Gr/26)|0,Sn=Gr%26;this._expand(Xr),Sn>0&&Xr--;for(var Rn=0;Rn0&&(this.words[Rn]=~this.words[Rn]&67108863>>26-Sn),this._strip()},jr.prototype.notn=function(Gr){return this.clone().inotn(Gr)},jr.prototype.setn=function(Gr,Xr){Er(typeof Gr=="number"&&Gr>=0);var Sn=Gr/26|0,Rn=Gr%26;return this._expand(Sn+1),Xr?this.words[Sn]=this.words[Sn]|1<Gr.length?(Sn=this,Rn=Gr):(Sn=Gr,Rn=this);for(var Pn=0,On=0;On>>26;for(;Pn!==0&&On>>26;if(this.length=Sn.length,Pn!==0)this.words[this.length]=Pn,this.length++;else if(Sn!==this)for(;OnGr.length?this.clone().iadd(Gr):Gr.clone().iadd(this)},jr.prototype.isub=function(Gr){if(Gr.negative!==0){Gr.negative=0;var Xr=this.iadd(Gr);return Gr.negative=1,Xr._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(Gr),this.negative=1,this._normSign();var Sn=this.cmp(Gr);if(Sn===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Rn,Pn;Sn>0?(Rn=this,Pn=Gr):(Rn=Gr,Pn=this);for(var On=0,Zn=0;Zn>26,this.words[Zn]=Xr&67108863;for(;On!==0&&Zn>26,this.words[Zn]=Xr&67108863;if(On===0&&Zn>>26,fo=Nn&67108863,vo=Math.min(wn,Gr.length-1),go=Math.max(0,wn-Tn.length+1);go<=vo;go++){var uo=wn-go|0;Rn=Tn.words[uo]|0,Pn=Gr.words[go]|0,On=Rn*Pn+fo,zn+=On/67108864|0,fo=On&67108863}Xr.words[wn]=fo|0,Nn=zn|0}return Nn!==0?Xr.words[wn]=Nn|0:Xr.length--,Xr._strip()}var An=function(Gr,Xr,Sn){var Rn=Gr.words,Pn=Xr.words,On=Sn.words,Zn=0,Nn,wn,zn,fo=Rn[0]|0,vo=fo&8191,go=fo>>>13,uo=Rn[1]|0,lo=uo&8191,Eo=uo>>>13,mo=Rn[2]|0,yo=mo&8191,_o=mo>>>13,Bo=Rn[3]|0,Lo=Bo&8191,Wo=Bo>>>13,na=Rn[4]|0,qo=na&8191,ga=na>>>13,wl=Rn[5]|0,No=wl&8191,Fo=wl>>>13,Nl=Rn[6]|0,Vo=Nl&8191,Uo=Nl>>>13,Ol=Rn[7]|0,$a=Ol&8191,Jo=Ol>>>13,Zl=Rn[8]|0,Cl=Zl&8191,ko=Zl>>>13,wo=Rn[9]|0,bo=wo&8191,Io=wo>>>13,Ho=Pn[0]|0,Do=Ho&8191,zo=Ho>>>13,nu=Pn[1]|0,Ll=nu&8191,_l=nu>>>13,bu=Pn[2]|0,xl=bu&8191,Tl=bu>>>13,du=Pn[3]|0,Bl=du&8191,Il=du>>>13,Eu=Pn[4]|0,Al=Eu&8191,Ml=Eu>>>13,Tu=Pn[5]|0,Ul=Tu&8191,Sl=Tu>>>13,_u=Pn[6]|0,So=_u&8191,Co=_u>>>13,Ao=Pn[7]|0,po=Ao&8191,Ro=Ao>>>13,Xo=Pn[8]|0,jo=Xo&8191,Ko=Xo>>>13,Wl=Pn[9]|0,$l=Wl&8191,El=Wl>>>13;Sn.negative=Gr.negative^Xr.negative,Sn.length=19,Nn=Math.imul(vo,Do),wn=Math.imul(vo,zo),wn=wn+Math.imul(go,Do)|0,zn=Math.imul(go,zo);var Cu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Cu>>>26)|0,Cu&=67108863,Nn=Math.imul(lo,Do),wn=Math.imul(lo,zo),wn=wn+Math.imul(Eo,Do)|0,zn=Math.imul(Eo,zo),Nn=Nn+Math.imul(vo,Ll)|0,wn=wn+Math.imul(vo,_l)|0,wn=wn+Math.imul(go,Ll)|0,zn=zn+Math.imul(go,_l)|0;var iu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(iu>>>26)|0,iu&=67108863,Nn=Math.imul(yo,Do),wn=Math.imul(yo,zo),wn=wn+Math.imul(_o,Do)|0,zn=Math.imul(_o,zo),Nn=Nn+Math.imul(lo,Ll)|0,wn=wn+Math.imul(lo,_l)|0,wn=wn+Math.imul(Eo,Ll)|0,zn=zn+Math.imul(Eo,_l)|0,Nn=Nn+Math.imul(vo,xl)|0,wn=wn+Math.imul(vo,Tl)|0,wn=wn+Math.imul(go,xl)|0,zn=zn+Math.imul(go,Tl)|0;var pu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(pu>>>26)|0,pu&=67108863,Nn=Math.imul(Lo,Do),wn=Math.imul(Lo,zo),wn=wn+Math.imul(Wo,Do)|0,zn=Math.imul(Wo,zo),Nn=Nn+Math.imul(yo,Ll)|0,wn=wn+Math.imul(yo,_l)|0,wn=wn+Math.imul(_o,Ll)|0,zn=zn+Math.imul(_o,_l)|0,Nn=Nn+Math.imul(lo,xl)|0,wn=wn+Math.imul(lo,Tl)|0,wn=wn+Math.imul(Eo,xl)|0,zn=zn+Math.imul(Eo,Tl)|0,Nn=Nn+Math.imul(vo,Bl)|0,wn=wn+Math.imul(vo,Il)|0,wn=wn+Math.imul(go,Bl)|0,zn=zn+Math.imul(go,Il)|0;var yu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(yu>>>26)|0,yu&=67108863,Nn=Math.imul(qo,Do),wn=Math.imul(qo,zo),wn=wn+Math.imul(ga,Do)|0,zn=Math.imul(ga,zo),Nn=Nn+Math.imul(Lo,Ll)|0,wn=wn+Math.imul(Lo,_l)|0,wn=wn+Math.imul(Wo,Ll)|0,zn=zn+Math.imul(Wo,_l)|0,Nn=Nn+Math.imul(yo,xl)|0,wn=wn+Math.imul(yo,Tl)|0,wn=wn+Math.imul(_o,xl)|0,zn=zn+Math.imul(_o,Tl)|0,Nn=Nn+Math.imul(lo,Bl)|0,wn=wn+Math.imul(lo,Il)|0,wn=wn+Math.imul(Eo,Bl)|0,zn=zn+Math.imul(Eo,Il)|0,Nn=Nn+Math.imul(vo,Al)|0,wn=wn+Math.imul(vo,Ml)|0,wn=wn+Math.imul(go,Al)|0,zn=zn+Math.imul(go,Ml)|0;var hu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(hu>>>26)|0,hu&=67108863,Nn=Math.imul(No,Do),wn=Math.imul(No,zo),wn=wn+Math.imul(Fo,Do)|0,zn=Math.imul(Fo,zo),Nn=Nn+Math.imul(qo,Ll)|0,wn=wn+Math.imul(qo,_l)|0,wn=wn+Math.imul(ga,Ll)|0,zn=zn+Math.imul(ga,_l)|0,Nn=Nn+Math.imul(Lo,xl)|0,wn=wn+Math.imul(Lo,Tl)|0,wn=wn+Math.imul(Wo,xl)|0,zn=zn+Math.imul(Wo,Tl)|0,Nn=Nn+Math.imul(yo,Bl)|0,wn=wn+Math.imul(yo,Il)|0,wn=wn+Math.imul(_o,Bl)|0,zn=zn+Math.imul(_o,Il)|0,Nn=Nn+Math.imul(lo,Al)|0,wn=wn+Math.imul(lo,Ml)|0,wn=wn+Math.imul(Eo,Al)|0,zn=zn+Math.imul(Eo,Ml)|0,Nn=Nn+Math.imul(vo,Ul)|0,wn=wn+Math.imul(vo,Sl)|0,wn=wn+Math.imul(go,Ul)|0,zn=zn+Math.imul(go,Sl)|0;var mu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(mu>>>26)|0,mu&=67108863,Nn=Math.imul(Vo,Do),wn=Math.imul(Vo,zo),wn=wn+Math.imul(Uo,Do)|0,zn=Math.imul(Uo,zo),Nn=Nn+Math.imul(No,Ll)|0,wn=wn+Math.imul(No,_l)|0,wn=wn+Math.imul(Fo,Ll)|0,zn=zn+Math.imul(Fo,_l)|0,Nn=Nn+Math.imul(qo,xl)|0,wn=wn+Math.imul(qo,Tl)|0,wn=wn+Math.imul(ga,xl)|0,zn=zn+Math.imul(ga,Tl)|0,Nn=Nn+Math.imul(Lo,Bl)|0,wn=wn+Math.imul(Lo,Il)|0,wn=wn+Math.imul(Wo,Bl)|0,zn=zn+Math.imul(Wo,Il)|0,Nn=Nn+Math.imul(yo,Al)|0,wn=wn+Math.imul(yo,Ml)|0,wn=wn+Math.imul(_o,Al)|0,zn=zn+Math.imul(_o,Ml)|0,Nn=Nn+Math.imul(lo,Ul)|0,wn=wn+Math.imul(lo,Sl)|0,wn=wn+Math.imul(Eo,Ul)|0,zn=zn+Math.imul(Eo,Sl)|0,Nn=Nn+Math.imul(vo,So)|0,wn=wn+Math.imul(vo,Co)|0,wn=wn+Math.imul(go,So)|0,zn=zn+Math.imul(go,Co)|0;var vu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(vu>>>26)|0,vu&=67108863,Nn=Math.imul($a,Do),wn=Math.imul($a,zo),wn=wn+Math.imul(Jo,Do)|0,zn=Math.imul(Jo,zo),Nn=Nn+Math.imul(Vo,Ll)|0,wn=wn+Math.imul(Vo,_l)|0,wn=wn+Math.imul(Uo,Ll)|0,zn=zn+Math.imul(Uo,_l)|0,Nn=Nn+Math.imul(No,xl)|0,wn=wn+Math.imul(No,Tl)|0,wn=wn+Math.imul(Fo,xl)|0,zn=zn+Math.imul(Fo,Tl)|0,Nn=Nn+Math.imul(qo,Bl)|0,wn=wn+Math.imul(qo,Il)|0,wn=wn+Math.imul(ga,Bl)|0,zn=zn+Math.imul(ga,Il)|0,Nn=Nn+Math.imul(Lo,Al)|0,wn=wn+Math.imul(Lo,Ml)|0,wn=wn+Math.imul(Wo,Al)|0,zn=zn+Math.imul(Wo,Ml)|0,Nn=Nn+Math.imul(yo,Ul)|0,wn=wn+Math.imul(yo,Sl)|0,wn=wn+Math.imul(_o,Ul)|0,zn=zn+Math.imul(_o,Sl)|0,Nn=Nn+Math.imul(lo,So)|0,wn=wn+Math.imul(lo,Co)|0,wn=wn+Math.imul(Eo,So)|0,zn=zn+Math.imul(Eo,Co)|0,Nn=Nn+Math.imul(vo,po)|0,wn=wn+Math.imul(vo,Ro)|0,wn=wn+Math.imul(go,po)|0,zn=zn+Math.imul(go,Ro)|0;var fu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(fu>>>26)|0,fu&=67108863,Nn=Math.imul(Cl,Do),wn=Math.imul(Cl,zo),wn=wn+Math.imul(ko,Do)|0,zn=Math.imul(ko,zo),Nn=Nn+Math.imul($a,Ll)|0,wn=wn+Math.imul($a,_l)|0,wn=wn+Math.imul(Jo,Ll)|0,zn=zn+Math.imul(Jo,_l)|0,Nn=Nn+Math.imul(Vo,xl)|0,wn=wn+Math.imul(Vo,Tl)|0,wn=wn+Math.imul(Uo,xl)|0,zn=zn+Math.imul(Uo,Tl)|0,Nn=Nn+Math.imul(No,Bl)|0,wn=wn+Math.imul(No,Il)|0,wn=wn+Math.imul(Fo,Bl)|0,zn=zn+Math.imul(Fo,Il)|0,Nn=Nn+Math.imul(qo,Al)|0,wn=wn+Math.imul(qo,Ml)|0,wn=wn+Math.imul(ga,Al)|0,zn=zn+Math.imul(ga,Ml)|0,Nn=Nn+Math.imul(Lo,Ul)|0,wn=wn+Math.imul(Lo,Sl)|0,wn=wn+Math.imul(Wo,Ul)|0,zn=zn+Math.imul(Wo,Sl)|0,Nn=Nn+Math.imul(yo,So)|0,wn=wn+Math.imul(yo,Co)|0,wn=wn+Math.imul(_o,So)|0,zn=zn+Math.imul(_o,Co)|0,Nn=Nn+Math.imul(lo,po)|0,wn=wn+Math.imul(lo,Ro)|0,wn=wn+Math.imul(Eo,po)|0,zn=zn+Math.imul(Eo,Ro)|0,Nn=Nn+Math.imul(vo,jo)|0,wn=wn+Math.imul(vo,Ko)|0,wn=wn+Math.imul(go,jo)|0,zn=zn+Math.imul(go,Ko)|0;var gu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(gu>>>26)|0,gu&=67108863,Nn=Math.imul(bo,Do),wn=Math.imul(bo,zo),wn=wn+Math.imul(Io,Do)|0,zn=Math.imul(Io,zo),Nn=Nn+Math.imul(Cl,Ll)|0,wn=wn+Math.imul(Cl,_l)|0,wn=wn+Math.imul(ko,Ll)|0,zn=zn+Math.imul(ko,_l)|0,Nn=Nn+Math.imul($a,xl)|0,wn=wn+Math.imul($a,Tl)|0,wn=wn+Math.imul(Jo,xl)|0,zn=zn+Math.imul(Jo,Tl)|0,Nn=Nn+Math.imul(Vo,Bl)|0,wn=wn+Math.imul(Vo,Il)|0,wn=wn+Math.imul(Uo,Bl)|0,zn=zn+Math.imul(Uo,Il)|0,Nn=Nn+Math.imul(No,Al)|0,wn=wn+Math.imul(No,Ml)|0,wn=wn+Math.imul(Fo,Al)|0,zn=zn+Math.imul(Fo,Ml)|0,Nn=Nn+Math.imul(qo,Ul)|0,wn=wn+Math.imul(qo,Sl)|0,wn=wn+Math.imul(ga,Ul)|0,zn=zn+Math.imul(ga,Sl)|0,Nn=Nn+Math.imul(Lo,So)|0,wn=wn+Math.imul(Lo,Co)|0,wn=wn+Math.imul(Wo,So)|0,zn=zn+Math.imul(Wo,Co)|0,Nn=Nn+Math.imul(yo,po)|0,wn=wn+Math.imul(yo,Ro)|0,wn=wn+Math.imul(_o,po)|0,zn=zn+Math.imul(_o,Ro)|0,Nn=Nn+Math.imul(lo,jo)|0,wn=wn+Math.imul(lo,Ko)|0,wn=wn+Math.imul(Eo,jo)|0,zn=zn+Math.imul(Eo,Ko)|0,Nn=Nn+Math.imul(vo,$l)|0,wn=wn+Math.imul(vo,El)|0,wn=wn+Math.imul(go,$l)|0,zn=zn+Math.imul(go,El)|0;var ou=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(ou>>>26)|0,ou&=67108863,Nn=Math.imul(bo,Ll),wn=Math.imul(bo,_l),wn=wn+Math.imul(Io,Ll)|0,zn=Math.imul(Io,_l),Nn=Nn+Math.imul(Cl,xl)|0,wn=wn+Math.imul(Cl,Tl)|0,wn=wn+Math.imul(ko,xl)|0,zn=zn+Math.imul(ko,Tl)|0,Nn=Nn+Math.imul($a,Bl)|0,wn=wn+Math.imul($a,Il)|0,wn=wn+Math.imul(Jo,Bl)|0,zn=zn+Math.imul(Jo,Il)|0,Nn=Nn+Math.imul(Vo,Al)|0,wn=wn+Math.imul(Vo,Ml)|0,wn=wn+Math.imul(Uo,Al)|0,zn=zn+Math.imul(Uo,Ml)|0,Nn=Nn+Math.imul(No,Ul)|0,wn=wn+Math.imul(No,Sl)|0,wn=wn+Math.imul(Fo,Ul)|0,zn=zn+Math.imul(Fo,Sl)|0,Nn=Nn+Math.imul(qo,So)|0,wn=wn+Math.imul(qo,Co)|0,wn=wn+Math.imul(ga,So)|0,zn=zn+Math.imul(ga,Co)|0,Nn=Nn+Math.imul(Lo,po)|0,wn=wn+Math.imul(Lo,Ro)|0,wn=wn+Math.imul(Wo,po)|0,zn=zn+Math.imul(Wo,Ro)|0,Nn=Nn+Math.imul(yo,jo)|0,wn=wn+Math.imul(yo,Ko)|0,wn=wn+Math.imul(_o,jo)|0,zn=zn+Math.imul(_o,Ko)|0,Nn=Nn+Math.imul(lo,$l)|0,wn=wn+Math.imul(lo,El)|0,wn=wn+Math.imul(Eo,$l)|0,zn=zn+Math.imul(Eo,El)|0;var su=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(su>>>26)|0,su&=67108863,Nn=Math.imul(bo,xl),wn=Math.imul(bo,Tl),wn=wn+Math.imul(Io,xl)|0,zn=Math.imul(Io,Tl),Nn=Nn+Math.imul(Cl,Bl)|0,wn=wn+Math.imul(Cl,Il)|0,wn=wn+Math.imul(ko,Bl)|0,zn=zn+Math.imul(ko,Il)|0,Nn=Nn+Math.imul($a,Al)|0,wn=wn+Math.imul($a,Ml)|0,wn=wn+Math.imul(Jo,Al)|0,zn=zn+Math.imul(Jo,Ml)|0,Nn=Nn+Math.imul(Vo,Ul)|0,wn=wn+Math.imul(Vo,Sl)|0,wn=wn+Math.imul(Uo,Ul)|0,zn=zn+Math.imul(Uo,Sl)|0,Nn=Nn+Math.imul(No,So)|0,wn=wn+Math.imul(No,Co)|0,wn=wn+Math.imul(Fo,So)|0,zn=zn+Math.imul(Fo,Co)|0,Nn=Nn+Math.imul(qo,po)|0,wn=wn+Math.imul(qo,Ro)|0,wn=wn+Math.imul(ga,po)|0,zn=zn+Math.imul(ga,Ro)|0,Nn=Nn+Math.imul(Lo,jo)|0,wn=wn+Math.imul(Lo,Ko)|0,wn=wn+Math.imul(Wo,jo)|0,zn=zn+Math.imul(Wo,Ko)|0,Nn=Nn+Math.imul(yo,$l)|0,wn=wn+Math.imul(yo,El)|0,wn=wn+Math.imul(_o,$l)|0,zn=zn+Math.imul(_o,El)|0;var tu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(tu>>>26)|0,tu&=67108863,Nn=Math.imul(bo,Bl),wn=Math.imul(bo,Il),wn=wn+Math.imul(Io,Bl)|0,zn=Math.imul(Io,Il),Nn=Nn+Math.imul(Cl,Al)|0,wn=wn+Math.imul(Cl,Ml)|0,wn=wn+Math.imul(ko,Al)|0,zn=zn+Math.imul(ko,Ml)|0,Nn=Nn+Math.imul($a,Ul)|0,wn=wn+Math.imul($a,Sl)|0,wn=wn+Math.imul(Jo,Ul)|0,zn=zn+Math.imul(Jo,Sl)|0,Nn=Nn+Math.imul(Vo,So)|0,wn=wn+Math.imul(Vo,Co)|0,wn=wn+Math.imul(Uo,So)|0,zn=zn+Math.imul(Uo,Co)|0,Nn=Nn+Math.imul(No,po)|0,wn=wn+Math.imul(No,Ro)|0,wn=wn+Math.imul(Fo,po)|0,zn=zn+Math.imul(Fo,Ro)|0,Nn=Nn+Math.imul(qo,jo)|0,wn=wn+Math.imul(qo,Ko)|0,wn=wn+Math.imul(ga,jo)|0,zn=zn+Math.imul(ga,Ko)|0,Nn=Nn+Math.imul(Lo,$l)|0,wn=wn+Math.imul(Lo,El)|0,wn=wn+Math.imul(Wo,$l)|0,zn=zn+Math.imul(Wo,El)|0;var zl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(zl>>>26)|0,zl&=67108863,Nn=Math.imul(bo,Al),wn=Math.imul(bo,Ml),wn=wn+Math.imul(Io,Al)|0,zn=Math.imul(Io,Ml),Nn=Nn+Math.imul(Cl,Ul)|0,wn=wn+Math.imul(Cl,Sl)|0,wn=wn+Math.imul(ko,Ul)|0,zn=zn+Math.imul(ko,Sl)|0,Nn=Nn+Math.imul($a,So)|0,wn=wn+Math.imul($a,Co)|0,wn=wn+Math.imul(Jo,So)|0,zn=zn+Math.imul(Jo,Co)|0,Nn=Nn+Math.imul(Vo,po)|0,wn=wn+Math.imul(Vo,Ro)|0,wn=wn+Math.imul(Uo,po)|0,zn=zn+Math.imul(Uo,Ro)|0,Nn=Nn+Math.imul(No,jo)|0,wn=wn+Math.imul(No,Ko)|0,wn=wn+Math.imul(Fo,jo)|0,zn=zn+Math.imul(Fo,Ko)|0,Nn=Nn+Math.imul(qo,$l)|0,wn=wn+Math.imul(qo,El)|0,wn=wn+Math.imul(ga,$l)|0,zn=zn+Math.imul(ga,El)|0;var Gl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Gl>>>26)|0,Gl&=67108863,Nn=Math.imul(bo,Ul),wn=Math.imul(bo,Sl),wn=wn+Math.imul(Io,Ul)|0,zn=Math.imul(Io,Sl),Nn=Nn+Math.imul(Cl,So)|0,wn=wn+Math.imul(Cl,Co)|0,wn=wn+Math.imul(ko,So)|0,zn=zn+Math.imul(ko,Co)|0,Nn=Nn+Math.imul($a,po)|0,wn=wn+Math.imul($a,Ro)|0,wn=wn+Math.imul(Jo,po)|0,zn=zn+Math.imul(Jo,Ro)|0,Nn=Nn+Math.imul(Vo,jo)|0,wn=wn+Math.imul(Vo,Ko)|0,wn=wn+Math.imul(Uo,jo)|0,zn=zn+Math.imul(Uo,Ko)|0,Nn=Nn+Math.imul(No,$l)|0,wn=wn+Math.imul(No,El)|0,wn=wn+Math.imul(Fo,$l)|0,zn=zn+Math.imul(Fo,El)|0;var Jl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Jl>>>26)|0,Jl&=67108863,Nn=Math.imul(bo,So),wn=Math.imul(bo,Co),wn=wn+Math.imul(Io,So)|0,zn=Math.imul(Io,Co),Nn=Nn+Math.imul(Cl,po)|0,wn=wn+Math.imul(Cl,Ro)|0,wn=wn+Math.imul(ko,po)|0,zn=zn+Math.imul(ko,Ro)|0,Nn=Nn+Math.imul($a,jo)|0,wn=wn+Math.imul($a,Ko)|0,wn=wn+Math.imul(Jo,jo)|0,zn=zn+Math.imul(Jo,Ko)|0,Nn=Nn+Math.imul(Vo,$l)|0,wn=wn+Math.imul(Vo,El)|0,wn=wn+Math.imul(Uo,$l)|0,zn=zn+Math.imul(Uo,El)|0;var Pl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Pl>>>26)|0,Pl&=67108863,Nn=Math.imul(bo,po),wn=Math.imul(bo,Ro),wn=wn+Math.imul(Io,po)|0,zn=Math.imul(Io,Ro),Nn=Nn+Math.imul(Cl,jo)|0,wn=wn+Math.imul(Cl,Ko)|0,wn=wn+Math.imul(ko,jo)|0,zn=zn+Math.imul(ko,Ko)|0,Nn=Nn+Math.imul($a,$l)|0,wn=wn+Math.imul($a,El)|0,wn=wn+Math.imul(Jo,$l)|0,zn=zn+Math.imul(Jo,El)|0;var Fl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Fl>>>26)|0,Fl&=67108863,Nn=Math.imul(bo,jo),wn=Math.imul(bo,Ko),wn=wn+Math.imul(Io,jo)|0,zn=Math.imul(Io,Ko),Nn=Nn+Math.imul(Cl,$l)|0,wn=wn+Math.imul(Cl,El)|0,wn=wn+Math.imul(ko,$l)|0,zn=zn+Math.imul(ko,El)|0;var Yl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Yl>>>26)|0,Yl&=67108863,Nn=Math.imul(bo,$l),wn=Math.imul(bo,El),wn=wn+Math.imul(Io,$l)|0,zn=Math.imul(Io,El);var Vl=(Zn+Nn|0)+((wn&8191)<<13)|0;return Zn=(zn+(wn>>>13)|0)+(Vl>>>26)|0,Vl&=67108863,On[0]=Cu,On[1]=iu,On[2]=pu,On[3]=yu,On[4]=hu,On[5]=mu,On[6]=vu,On[7]=fu,On[8]=gu,On[9]=ou,On[10]=su,On[11]=tu,On[12]=zl,On[13]=Gl,On[14]=Jl,On[15]=Pl,On[16]=Fl,On[17]=Yl,On[18]=Vl,Zn!==0&&(On[19]=Zn,Sn.length++),Sn};Math.imul||(An=In);function jn(Tn,Gr,Xr){Xr.negative=Gr.negative^Tn.negative,Xr.length=Tn.length+Gr.length;for(var Sn=0,Rn=0,Pn=0;Pn>>26)|0,Rn+=On>>>26,On&=67108863}Xr.words[Pn]=Zn,Sn=On,On=Rn}return Sn!==0?Xr.words[Pn]=Sn:Xr.length--,Xr._strip()}function eo(Tn,Gr,Xr){return jn(Tn,Gr,Xr)}jr.prototype.mulTo=function(Gr,Xr){var Sn,Rn=this.length+Gr.length;return this.length===10&&Gr.length===10?Sn=An(this,Gr,Xr):Rn<63?Sn=In(this,Gr,Xr):Rn<1024?Sn=jn(this,Gr,Xr):Sn=eo(this,Gr,Xr),Sn},jr.prototype.mul=function(Gr){var Xr=new jr(null);return Xr.words=new Array(this.length+Gr.length),this.mulTo(Gr,Xr)},jr.prototype.mulf=function(Gr){var Xr=new jr(null);return Xr.words=new Array(this.length+Gr.length),eo(this,Gr,Xr)},jr.prototype.imul=function(Gr){return this.clone().mulTo(Gr,this)},jr.prototype.imuln=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(typeof Gr=="number"),Er(Gr<67108864);for(var Sn=0,Rn=0;Rn>=26,Sn+=Pn/67108864|0,Sn+=On>>>26,this.words[Rn]=On&67108863}return Sn!==0&&(this.words[Rn]=Sn,this.length++),Xr?this.ineg():this},jr.prototype.muln=function(Gr){return this.clone().imuln(Gr)},jr.prototype.sqr=function(){return this.mul(this)},jr.prototype.isqr=function(){return this.imul(this.clone())},jr.prototype.pow=function(Gr){var Xr=Cn(Gr);if(Xr.length===0)return new jr(1);for(var Sn=this,Rn=0;Rn=0);var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=67108863>>>26-Xr<<26-Xr,Pn;if(Xr!==0){var On=0;for(Pn=0;Pn>>26-Xr}On&&(this.words[Pn]=On,this.length++)}if(Sn!==0){for(Pn=this.length-1;Pn>=0;Pn--)this.words[Pn+Sn]=this.words[Pn];for(Pn=0;Pn=0);var Rn;Xr?Rn=(Xr-Xr%26)/26:Rn=0;var Pn=Gr%26,On=Math.min((Gr-Pn)/26,this.length),Zn=67108863^67108863>>>Pn<On)for(this.length-=On,wn=0;wn=0&&(zn!==0||wn>=Rn);wn--){var fo=this.words[wn]|0;this.words[wn]=zn<<26-Pn|fo>>>Pn,zn=fo&Zn}return Nn&&zn!==0&&(Nn.words[Nn.length++]=zn),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},jr.prototype.ishrn=function(Gr,Xr,Sn){return Er(this.negative===0),this.iushrn(Gr,Xr,Sn)},jr.prototype.shln=function(Gr){return this.clone().ishln(Gr)},jr.prototype.ushln=function(Gr){return this.clone().iushln(Gr)},jr.prototype.shrn=function(Gr){return this.clone().ishrn(Gr)},jr.prototype.ushrn=function(Gr){return this.clone().iushrn(Gr)},jr.prototype.testn=function(Gr){Er(typeof Gr=="number"&&Gr>=0);var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=1<=0);var Xr=Gr%26,Sn=(Gr-Xr)/26;if(Er(this.negative===0,"imaskn works only with positive numbers"),this.length<=Sn)return this;if(Xr!==0&&Sn++,this.length=Math.min(Sn,this.length),Xr!==0){var Rn=67108863^67108863>>>Xr<=67108864;Xr++)this.words[Xr]-=67108864,Xr===this.length-1?this.words[Xr+1]=1:this.words[Xr+1]++;return this.length=Math.max(this.length,Xr+1),this},jr.prototype.isubn=function(Gr){if(Er(typeof Gr=="number"),Er(Gr<67108864),Gr<0)return this.iaddn(-Gr);if(this.negative!==0)return this.negative=0,this.iaddn(Gr),this.negative=1,this;if(this.words[0]-=Gr,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var Xr=0;Xr>26)-(Nn/67108864|0),this.words[Pn+Sn]=On&67108863}for(;Pn>26,this.words[Pn+Sn]=On&67108863;if(Zn===0)return this._strip();for(Er(Zn===-1),Zn=0,Pn=0;Pn>26,this.words[Pn]=On&67108863;return this.negative=1,this._strip()},jr.prototype._wordDiv=function(Gr,Xr){var Sn=this.length-Gr.length,Rn=this.clone(),Pn=Gr,On=Pn.words[Pn.length-1]|0,Zn=this._countBits(On);Sn=26-Zn,Sn!==0&&(Pn=Pn.ushln(Sn),Rn.iushln(Sn),On=Pn.words[Pn.length-1]|0);var Nn=Rn.length-Pn.length,wn;if(Xr!=="mod"){wn=new jr(null),wn.length=Nn+1,wn.words=new Array(wn.length);for(var zn=0;zn=0;vo--){var go=(Rn.words[Pn.length+vo]|0)*67108864+(Rn.words[Pn.length+vo-1]|0);for(go=Math.min(go/On|0,67108863),Rn._ishlnsubmul(Pn,go,vo);Rn.negative!==0;)go--,Rn.negative=0,Rn._ishlnsubmul(Pn,1,vo),Rn.isZero()||(Rn.negative^=1);wn&&(wn.words[vo]=go)}return wn&&wn._strip(),Rn._strip(),Xr!=="div"&&Sn!==0&&Rn.iushrn(Sn),{div:wn||null,mod:Rn}},jr.prototype.divmod=function(Gr,Xr,Sn){if(Er(!Gr.isZero()),this.isZero())return{div:new jr(0),mod:new jr(0)};var Rn,Pn,On;return this.negative!==0&&Gr.negative===0?(On=this.neg().divmod(Gr,Xr),Xr!=="mod"&&(Rn=On.div.neg()),Xr!=="div"&&(Pn=On.mod.neg(),Sn&&Pn.negative!==0&&Pn.iadd(Gr)),{div:Rn,mod:Pn}):this.negative===0&&Gr.negative!==0?(On=this.divmod(Gr.neg(),Xr),Xr!=="mod"&&(Rn=On.div.neg()),{div:Rn,mod:On.mod}):this.negative&Gr.negative?(On=this.neg().divmod(Gr.neg(),Xr),Xr!=="div"&&(Pn=On.mod.neg(),Sn&&Pn.negative!==0&&Pn.isub(Gr)),{div:On.div,mod:Pn}):Gr.length>this.length||this.cmp(Gr)<0?{div:new jr(0),mod:this}:Gr.length===1?Xr==="div"?{div:this.divn(Gr.words[0]),mod:null}:Xr==="mod"?{div:null,mod:new jr(this.modrn(Gr.words[0]))}:{div:this.divn(Gr.words[0]),mod:new jr(this.modrn(Gr.words[0]))}:this._wordDiv(Gr,Xr)},jr.prototype.div=function(Gr){return this.divmod(Gr,"div",!1).div},jr.prototype.mod=function(Gr){return this.divmod(Gr,"mod",!1).mod},jr.prototype.umod=function(Gr){return this.divmod(Gr,"mod",!0).mod},jr.prototype.divRound=function(Gr){var Xr=this.divmod(Gr);if(Xr.mod.isZero())return Xr.div;var Sn=Xr.div.negative!==0?Xr.mod.isub(Gr):Xr.mod,Rn=Gr.ushrn(1),Pn=Gr.andln(1),On=Sn.cmp(Rn);return On<0||Pn===1&&On===0?Xr.div:Xr.div.negative!==0?Xr.div.isubn(1):Xr.div.iaddn(1)},jr.prototype.modrn=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(Gr<=67108863);for(var Sn=(1<<26)%Gr,Rn=0,Pn=this.length-1;Pn>=0;Pn--)Rn=(Sn*Rn+(this.words[Pn]|0))%Gr;return Xr?-Rn:Rn},jr.prototype.modn=function(Gr){return this.modrn(Gr)},jr.prototype.idivn=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(Gr<=67108863);for(var Sn=0,Rn=this.length-1;Rn>=0;Rn--){var Pn=(this.words[Rn]|0)+Sn*67108864;this.words[Rn]=Pn/Gr|0,Sn=Pn%Gr}return this._strip(),Xr?this.ineg():this},jr.prototype.divn=function(Gr){return this.clone().idivn(Gr)},jr.prototype.egcd=function(Gr){Er(Gr.negative===0),Er(!Gr.isZero());var Xr=this,Sn=Gr.clone();Xr.negative!==0?Xr=Xr.umod(Gr):Xr=Xr.clone();for(var Rn=new jr(1),Pn=new jr(0),On=new jr(0),Zn=new jr(1),Nn=0;Xr.isEven()&&Sn.isEven();)Xr.iushrn(1),Sn.iushrn(1),++Nn;for(var wn=Sn.clone(),zn=Xr.clone();!Xr.isZero();){for(var fo=0,vo=1;!(Xr.words[0]&vo)&&fo<26;++fo,vo<<=1);if(fo>0)for(Xr.iushrn(fo);fo-- >0;)(Rn.isOdd()||Pn.isOdd())&&(Rn.iadd(wn),Pn.isub(zn)),Rn.iushrn(1),Pn.iushrn(1);for(var go=0,uo=1;!(Sn.words[0]&uo)&&go<26;++go,uo<<=1);if(go>0)for(Sn.iushrn(go);go-- >0;)(On.isOdd()||Zn.isOdd())&&(On.iadd(wn),Zn.isub(zn)),On.iushrn(1),Zn.iushrn(1);Xr.cmp(Sn)>=0?(Xr.isub(Sn),Rn.isub(On),Pn.isub(Zn)):(Sn.isub(Xr),On.isub(Rn),Zn.isub(Pn))}return{a:On,b:Zn,gcd:Sn.iushln(Nn)}},jr.prototype._invmp=function(Gr){Er(Gr.negative===0),Er(!Gr.isZero());var Xr=this,Sn=Gr.clone();Xr.negative!==0?Xr=Xr.umod(Gr):Xr=Xr.clone();for(var Rn=new jr(1),Pn=new jr(0),On=Sn.clone();Xr.cmpn(1)>0&&Sn.cmpn(1)>0;){for(var Zn=0,Nn=1;!(Xr.words[0]&Nn)&&Zn<26;++Zn,Nn<<=1);if(Zn>0)for(Xr.iushrn(Zn);Zn-- >0;)Rn.isOdd()&&Rn.iadd(On),Rn.iushrn(1);for(var wn=0,zn=1;!(Sn.words[0]&zn)&&wn<26;++wn,zn<<=1);if(wn>0)for(Sn.iushrn(wn);wn-- >0;)Pn.isOdd()&&Pn.iadd(On),Pn.iushrn(1);Xr.cmp(Sn)>=0?(Xr.isub(Sn),Rn.isub(Pn)):(Sn.isub(Xr),Pn.isub(Rn))}var fo;return Xr.cmpn(1)===0?fo=Rn:fo=Pn,fo.cmpn(0)<0&&fo.iadd(Gr),fo},jr.prototype.gcd=function(Gr){if(this.isZero())return Gr.abs();if(Gr.isZero())return this.abs();var Xr=this.clone(),Sn=Gr.clone();Xr.negative=0,Sn.negative=0;for(var Rn=0;Xr.isEven()&&Sn.isEven();Rn++)Xr.iushrn(1),Sn.iushrn(1);do{for(;Xr.isEven();)Xr.iushrn(1);for(;Sn.isEven();)Sn.iushrn(1);var Pn=Xr.cmp(Sn);if(Pn<0){var On=Xr;Xr=Sn,Sn=On}else if(Pn===0||Sn.cmpn(1)===0)break;Xr.isub(Sn)}while(!0);return Sn.iushln(Rn)},jr.prototype.invm=function(Gr){return this.egcd(Gr).a.umod(Gr)},jr.prototype.isEven=function(){return(this.words[0]&1)===0},jr.prototype.isOdd=function(){return(this.words[0]&1)===1},jr.prototype.andln=function(Gr){return this.words[0]&Gr},jr.prototype.bincn=function(Gr){Er(typeof Gr=="number");var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=1<>>26,Zn&=67108863,this.words[On]=Zn}return Pn!==0&&(this.words[On]=Pn,this.length++),this},jr.prototype.isZero=function(){return this.length===1&&this.words[0]===0},jr.prototype.cmpn=function(Gr){var Xr=Gr<0;if(this.negative!==0&&!Xr)return-1;if(this.negative===0&&Xr)return 1;this._strip();var Sn;if(this.length>1)Sn=1;else{Xr&&(Gr=-Gr),Er(Gr<=67108863,"Number is too big");var Rn=this.words[0]|0;Sn=Rn===Gr?0:RnGr.length)return 1;if(this.length=0;Sn--){var Rn=this.words[Sn]|0,Pn=Gr.words[Sn]|0;if(Rn!==Pn){RnPn&&(Xr=1);break}}return Xr},jr.prototype.gtn=function(Gr){return this.cmpn(Gr)===1},jr.prototype.gt=function(Gr){return this.cmp(Gr)===1},jr.prototype.gten=function(Gr){return this.cmpn(Gr)>=0},jr.prototype.gte=function(Gr){return this.cmp(Gr)>=0},jr.prototype.ltn=function(Gr){return this.cmpn(Gr)===-1},jr.prototype.lt=function(Gr){return this.cmp(Gr)===-1},jr.prototype.lten=function(Gr){return this.cmpn(Gr)<=0},jr.prototype.lte=function(Gr){return this.cmp(Gr)<=0},jr.prototype.eqn=function(Gr){return this.cmpn(Gr)===0},jr.prototype.eq=function(Gr){return this.cmp(Gr)===0},jr.red=function(Gr){return new so(Gr)},jr.prototype.toRed=function(Gr){return Er(!this.red,"Already a number in reduction context"),Er(this.negative===0,"red works only with positives"),Gr.convertTo(this)._forceRed(Gr)},jr.prototype.fromRed=function(){return Er(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},jr.prototype._forceRed=function(Gr){return this.red=Gr,this},jr.prototype.forceRed=function(Gr){return Er(!this.red,"Already a number in reduction context"),this._forceRed(Gr)},jr.prototype.redAdd=function(Gr){return Er(this.red,"redAdd works only with red numbers"),this.red.add(this,Gr)},jr.prototype.redIAdd=function(Gr){return Er(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,Gr)},jr.prototype.redSub=function(Gr){return Er(this.red,"redSub works only with red numbers"),this.red.sub(this,Gr)},jr.prototype.redISub=function(Gr){return Er(this.red,"redISub works only with red numbers"),this.red.isub(this,Gr)},jr.prototype.redShl=function(Gr){return Er(this.red,"redShl works only with red numbers"),this.red.shl(this,Gr)},jr.prototype.redMul=function(Gr){return Er(this.red,"redMul works only with red numbers"),this.red._verify2(this,Gr),this.red.mul(this,Gr)},jr.prototype.redIMul=function(Gr){return Er(this.red,"redMul works only with red numbers"),this.red._verify2(this,Gr),this.red.imul(this,Gr)},jr.prototype.redSqr=function(){return Er(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},jr.prototype.redISqr=function(){return Er(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},jr.prototype.redSqrt=function(){return Er(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},jr.prototype.redInvm=function(){return Er(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},jr.prototype.redNeg=function(){return Er(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},jr.prototype.redPow=function(Gr){return Er(this.red&&!Gr.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,Gr)};var ro={k256:null,p224:null,p192:null,p25519:null};function to(Tn,Gr){this.name=Tn,this.p=new jr(Gr,16),this.n=this.p.bitLength(),this.k=new jr(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}to.prototype._tmp=function(){var Gr=new jr(null);return Gr.words=new Array(Math.ceil(this.n/13)),Gr},to.prototype.ireduce=function(Gr){var Xr=Gr,Sn;do this.split(Xr,this.tmp),Xr=this.imulK(Xr),Xr=Xr.iadd(this.tmp),Sn=Xr.bitLength();while(Sn>this.n);var Rn=Sn0?Xr.isub(this.p):Xr.strip!==void 0?Xr.strip():Xr._strip(),Xr},to.prototype.split=function(Gr,Xr){Gr.iushrn(this.n,0,Xr)},to.prototype.imulK=function(Gr){return Gr.imul(this.k)};function _i(){to.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}kr(_i,to),_i.prototype.split=function(Gr,Xr){for(var Sn=4194303,Rn=Math.min(Gr.length,9),Pn=0;Pn>>22,On=Zn}On>>>=22,Gr.words[Pn-10]=On,On===0&&Gr.length>10?Gr.length-=10:Gr.length-=9},_i.prototype.imulK=function(Gr){Gr.words[Gr.length]=0,Gr.words[Gr.length+1]=0,Gr.length+=2;for(var Xr=0,Sn=0;Sn>>=26,Gr.words[Sn]=Pn,Xr=Rn}return Xr!==0&&(Gr.words[Gr.length++]=Xr),Gr},jr._prime=function(Gr){if(ro[Gr])return ro[Gr];var Xr;if(Gr==="k256")Xr=new _i;else if(Gr==="p224")Xr=new oo;else if(Gr==="p192")Xr=new io;else if(Gr==="p25519")Xr=new co;else throw new Error("Unknown prime "+Gr);return ro[Gr]=Xr,Xr};function so(Tn){if(typeof Tn=="string"){var Gr=jr._prime(Tn);this.m=Gr.p,this.prime=Gr}else Er(Tn.gtn(1),"modulus must be greater than 1"),this.m=Tn,this.prime=null}so.prototype._verify1=function(Gr){Er(Gr.negative===0,"red works only with positives"),Er(Gr.red,"red works only with red numbers")},so.prototype._verify2=function(Gr,Xr){Er((Gr.negative|Xr.negative)===0,"red works only with positives"),Er(Gr.red&&Gr.red===Xr.red,"red works only with red numbers")},so.prototype.imod=function(Gr){return this.prime?this.prime.ireduce(Gr)._forceRed(this):(Vr(Gr,Gr.umod(this.m)._forceRed(this)),Gr)},so.prototype.neg=function(Gr){return Gr.isZero()?Gr.clone():this.m.sub(Gr)._forceRed(this)},so.prototype.add=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.add(Xr);return Sn.cmp(this.m)>=0&&Sn.isub(this.m),Sn._forceRed(this)},so.prototype.iadd=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.iadd(Xr);return Sn.cmp(this.m)>=0&&Sn.isub(this.m),Sn},so.prototype.sub=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.sub(Xr);return Sn.cmpn(0)<0&&Sn.iadd(this.m),Sn._forceRed(this)},so.prototype.isub=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.isub(Xr);return Sn.cmpn(0)<0&&Sn.iadd(this.m),Sn},so.prototype.shl=function(Gr,Xr){return this._verify1(Gr),this.imod(Gr.ushln(Xr))},so.prototype.imul=function(Gr,Xr){return this._verify2(Gr,Xr),this.imod(Gr.imul(Xr))},so.prototype.mul=function(Gr,Xr){return this._verify2(Gr,Xr),this.imod(Gr.mul(Xr))},so.prototype.isqr=function(Gr){return this.imul(Gr,Gr.clone())},so.prototype.sqr=function(Gr){return this.mul(Gr,Gr)},so.prototype.sqrt=function(Gr){if(Gr.isZero())return Gr.clone();var Xr=this.m.andln(3);if(Er(Xr%2===1),Xr===3){var Sn=this.m.add(new jr(1)).iushrn(2);return this.pow(Gr,Sn)}for(var Rn=this.m.subn(1),Pn=0;!Rn.isZero()&&Rn.andln(1)===0;)Pn++,Rn.iushrn(1);Er(!Rn.isZero());var On=new jr(1).toRed(this),Zn=On.redNeg(),Nn=this.m.subn(1).iushrn(1),wn=this.m.bitLength();for(wn=new jr(2*wn*wn).toRed(this);this.pow(wn,Nn).cmp(Zn)!==0;)wn.redIAdd(Zn);for(var zn=this.pow(wn,Rn),fo=this.pow(Gr,Rn.addn(1).iushrn(1)),vo=this.pow(Gr,Rn),go=Pn;vo.cmp(On)!==0;){for(var uo=vo,lo=0;uo.cmp(On)!==0;lo++)uo=uo.redSqr();Er(lo=0;Pn--){for(var zn=Xr.words[Pn],fo=wn-1;fo>=0;fo--){var vo=zn>>fo&1;if(On!==Rn[0]&&(On=this.sqr(On)),vo===0&&Zn===0){Nn=0;continue}Zn<<=1,Zn|=vo,Nn++,!(Nn!==Sn&&(Pn!==0||fo!==0))&&(On=this.mul(On,Rn[Zn]),Nn=0,Zn=0)}wn=26}return On},so.prototype.convertTo=function(Gr){var Xr=Gr.umod(this.m);return Xr===Gr?Xr.clone():Xr},so.prototype.convertFrom=function(Gr){var Xr=Gr.clone();return Xr.red=null,Xr},jr.mont=function(Gr){return new no(Gr)};function no(Tn){so.call(this,Tn),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new jr(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}kr(no,so),no.prototype.convertTo=function(Gr){return this.imod(Gr.ushln(this.shift))},no.prototype.convertFrom=function(Gr){var Xr=this.imod(Gr.mul(this.rinv));return Xr.red=null,Xr},no.prototype.imul=function(Gr,Xr){if(Gr.isZero()||Xr.isZero())return Gr.words[0]=0,Gr.length=1,Gr;var Sn=Gr.imul(Xr),Rn=Sn.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Pn=Sn.isub(Rn).iushrn(this.shift),On=Pn;return Pn.cmp(this.m)>=0?On=Pn.isub(this.m):Pn.cmpn(0)<0&&(On=Pn.iadd(this.m)),On._forceRed(this)},no.prototype.mul=function(Gr,Xr){if(Gr.isZero()||Xr.isZero())return new jr(0)._forceRed(this);var Sn=Gr.mul(Xr),Rn=Sn.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Pn=Sn.isub(Rn).iushrn(this.shift),On=Pn;return Pn.cmp(this.m)>=0?On=Pn.isub(this.m):Pn.cmpn(0)<0&&(On=Pn.iadd(this.m)),On._forceRed(this)},no.prototype.invm=function(Gr){var Xr=this.imod(Gr._invmp(this.m).mul(this.r2));return Xr._forceRed(this)}})(fr,commonjsGlobal)})(bn$2);var bnExports$2=bn$2.exports,_Buffer$2=safeBufferExports.Buffer;function base$2(fr){if(fr.length>=255)throw new TypeError("Alphabet too long");for(var br=new Uint8Array(256),wr=0;wr>>0,jn=new Uint8Array(An);Cn!==In;){for(var eo=Qr[Cn],ro=0,to=An-1;(eo!==0||ro>>0,jn[to]=eo%Br>>>0,eo=eo/Br>>>0;if(eo!==0)throw new Error("Non-zero carry");En=ro,Cn++}for(var _i=An-En;_i!==An&&jn[_i]===0;)_i++;for(var oo=Wr.repeat(_n);_i>>0,An=new Uint8Array(In);_n>>0,An[ro]=jn%256>>>0,jn=jn/256>>>0;if(jn!==0)throw new Error("Non-zero carry");Cn=eo,_n++}for(var to=In-Cn;to!==In&&An[to]===0;)to++;var _i=_Buffer$2.allocUnsafe(En+(In-to));_i.fill(0,0,En);for(var oo=En;to!==In;)_i[oo++]=An[to++];return _i}function Jr(Qr){var _n=Zr(Qr);if(_n)return _n;throw new Error("Non-base"+Br+" character")}return{encode:Vr,decodeUnsafe:Zr,decode:Jr}}var src$2=base$2,basex$2=src$2,ALPHABET$2="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",bs58$4=basex$2(ALPHABET$2);function inRange(fr,br,wr){return br<=fr&&fr<=wr}function ToDictionary(fr){if(fr===void 0)return{};if(fr===Object(fr))return fr;throw TypeError("Could not convert argument to dictionary")}function stringToCodePoints(fr){for(var br=String(fr),wr=br.length,Er=0,kr=[];Er57343)kr.push(jr);else if(56320<=jr&&jr<=57343)kr.push(65533);else if(55296<=jr&&jr<=56319)if(Er===wr-1)kr.push(65533);else{var Br=fr.charCodeAt(Er+1);if(56320<=Br&&Br<=57343){var Wr=jr&1023,qr=Br&1023;kr.push(65536+(Wr<<10)+qr),Er+=1}else kr.push(65533)}Er+=1}return kr}function codePointsToString(fr){for(var br="",wr=0;wr>10)+55296,(Er&1023)+56320))}return br}var end_of_stream=-1;function Stream(fr){this.tokens=[].slice.call(fr)}Stream.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():end_of_stream},prepend:function(fr){if(Array.isArray(fr))for(var br=fr;br.length;)this.tokens.unshift(br.pop());else this.tokens.unshift(fr)},push:function(fr){if(Array.isArray(fr))for(var br=fr;br.length;)this.tokens.push(br.shift());else this.tokens.push(fr)}};var finished=-1;function decoderError(fr,br){if(fr)throw TypeError("Decoder error");return br||65533}var DEFAULT_ENCODING="utf-8";function TextDecoder$1(fr,br){if(!(this instanceof TextDecoder$1))return new TextDecoder$1(fr,br);if(fr=fr!==void 0?String(fr).toLowerCase():DEFAULT_ENCODING,fr!==DEFAULT_ENCODING)throw new Error("Encoding not supported. Only utf-8 is supported");br=ToDictionary(br),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!br.fatal,this._ignoreBOM=!!br.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}TextDecoder$1.prototype={decode:function fr(br,wr){var Er;typeof br=="object"&&br instanceof ArrayBuffer?Er=new Uint8Array(br):typeof br=="object"&&"buffer"in br&&br.buffer instanceof ArrayBuffer?Er=new Uint8Array(br.buffer,br.byteOffset,br.byteLength):Er=new Uint8Array(0),wr=ToDictionary(wr),this._streaming||(this._decoder=new UTF8Decoder({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!wr.stream;for(var kr=new Stream(Er),jr=[],Br;!kr.endOfStream()&&(Br=this._decoder.handler(kr,kr.read()),Br!==finished);)Br!==null&&(Array.isArray(Br)?jr.push.apply(jr,Br):jr.push(Br));if(!this._streaming){do{if(Br=this._decoder.handler(kr,kr.read()),Br===finished)break;Br!==null&&(Array.isArray(Br)?jr.push.apply(jr,Br):jr.push(Br))}while(!kr.endOfStream());this._decoder=null}return jr.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(jr[0]===65279?(this._BOMseen=!0,jr.shift()):this._BOMseen=!0),codePointsToString(jr)}};function TextEncoder$1(fr,br){if(!(this instanceof TextEncoder$1))return new TextEncoder$1(fr,br);if(fr=fr!==void 0?String(fr).toLowerCase():DEFAULT_ENCODING,fr!==DEFAULT_ENCODING)throw new Error("Encoding not supported. Only utf-8 is supported");br=ToDictionary(br),this._streaming=!1,this._encoder=null,this._options={fatal:!!br.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}TextEncoder$1.prototype={encode:function fr(br,wr){br=br?String(br):"",wr=ToDictionary(wr),this._streaming||(this._encoder=new UTF8Encoder(this._options)),this._streaming=!!wr.stream;for(var Er=[],kr=new Stream(stringToCodePoints(br)),jr;!kr.endOfStream()&&(jr=this._encoder.handler(kr,kr.read()),jr!==finished);)Array.isArray(jr)?Er.push.apply(Er,jr):Er.push(jr);if(!this._streaming){for(;jr=this._encoder.handler(kr,kr.read()),jr!==finished;)Array.isArray(jr)?Er.push.apply(Er,jr):Er.push(jr);this._encoder=null}return new Uint8Array(Er)}};function UTF8Decoder(fr){var br=fr.fatal,wr=0,Er=0,kr=0,jr=128,Br=191;this.handler=function(Wr,qr){if(qr===end_of_stream&&kr!==0)return kr=0,decoderError(br);if(qr===end_of_stream)return finished;if(kr===0){if(inRange(qr,0,127))return qr;if(inRange(qr,194,223))kr=1,wr=qr-192;else if(inRange(qr,224,239))qr===224&&(jr=160),qr===237&&(Br=159),kr=2,wr=qr-224;else if(inRange(qr,240,244))qr===240&&(jr=144),qr===244&&(Br=143),kr=3,wr=qr-240;else return decoderError(br);return wr=wr<<6*kr,null}if(!inRange(qr,jr,Br))return wr=kr=Er=0,jr=128,Br=191,Wr.prepend(qr),decoderError(br);if(jr=128,Br=191,Er+=1,wr+=qr-128<<6*(kr-Er),Er!==kr)return null;var Hr=wr;return wr=kr=Er=0,Hr}}function UTF8Encoder(fr){fr.fatal,this.handler=function(br,wr){if(wr===end_of_stream)return finished;if(inRange(wr,0,127))return wr;var Er,kr;inRange(wr,128,2047)?(Er=1,kr=192):inRange(wr,2048,65535)?(Er=2,kr=224):inRange(wr,65536,1114111)&&(Er=3,kr=240);for(var jr=[(wr>>6*Er)+kr];Er>0;){var Br=wr>>6*(Er-1);jr.push(128|Br&63),Er-=1}return jr}}const encoding$1=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:TextDecoder$1,TextEncoder:TextEncoder$1},Symbol.toStringTag,{value:"Module"})),require$$2=getAugmentedNamespace(encoding$1);var __createBinding=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(fr,br,wr,Er){Er===void 0&&(Er=wr),Object.defineProperty(fr,Er,{enumerable:!0,get:function(){return br[wr]}})}:function(fr,br,wr,Er){Er===void 0&&(Er=wr),fr[Er]=br[wr]}),__setModuleDefault=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(fr,br){Object.defineProperty(fr,"default",{enumerable:!0,value:br})}:function(fr,br){fr.default=br}),__decorate=commonjsGlobal&&commonjsGlobal.__decorate||function(fr,br,wr,Er){var kr=arguments.length,jr=kr<3?br:Er===null?Er=Object.getOwnPropertyDescriptor(br,wr):Er,Br;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")jr=Reflect.decorate(fr,br,wr,Er);else for(var Wr=fr.length-1;Wr>=0;Wr--)(Br=fr[Wr])&&(jr=(kr<3?Br(jr):kr>3?Br(br,wr,jr):Br(br,wr))||jr);return kr>3&&jr&&Object.defineProperty(br,wr,jr),jr},__importStar=commonjsGlobal&&commonjsGlobal.__importStar||function(fr){if(fr&&fr.__esModule)return fr;var br={};if(fr!=null)for(var wr in fr)wr!=="default"&&Object.hasOwnProperty.call(fr,wr)&&__createBinding(br,fr,wr);return __setModuleDefault(br,fr),br},__importDefault=commonjsGlobal&&commonjsGlobal.__importDefault||function(fr){return fr&&fr.__esModule?fr:{default:fr}};Object.defineProperty(lib,"__esModule",{value:!0});var deserializeUnchecked_1=lib.deserializeUnchecked=deserialize_1=lib.deserialize=serialize_1=lib.serialize=lib.BinaryReader=lib.BinaryWriter=lib.BorshError=lib.baseDecode=lib.baseEncode=void 0;const bn_js_1=__importDefault(bnExports$2),bs58_1=__importDefault(bs58$4),encoding=__importStar(require$$2),ResolvedTextDecoder=typeof TextDecoder!="function"?encoding.TextDecoder:TextDecoder,textDecoder=new ResolvedTextDecoder("utf-8",{fatal:!0});function baseEncode(fr){return typeof fr=="string"&&(fr=Buffer$2.from(fr,"utf8")),bs58_1.default.encode(Buffer$2.from(fr))}lib.baseEncode=baseEncode;function baseDecode(fr){return Buffer$2.from(bs58_1.default.decode(fr))}lib.baseDecode=baseDecode;const INITIAL_LENGTH=1024;class BorshError extends Error{constructor(br){super(br),this.fieldPath=[],this.originalMessage=br}addToFieldPath(br){this.fieldPath.splice(0,0,br),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}lib.BorshError=BorshError;class BinaryWriter{constructor(){this.buf=Buffer$2.alloc(INITIAL_LENGTH),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer$2.concat([this.buf,Buffer$2.alloc(INITIAL_LENGTH)]))}writeU8(br){this.maybeResize(),this.buf.writeUInt8(br,this.length),this.length+=1}writeU16(br){this.maybeResize(),this.buf.writeUInt16LE(br,this.length),this.length+=2}writeU32(br){this.maybeResize(),this.buf.writeUInt32LE(br,this.length),this.length+=4}writeU64(br){this.maybeResize(),this.writeBuffer(Buffer$2.from(new bn_js_1.default(br).toArray("le",8)))}writeU128(br){this.maybeResize(),this.writeBuffer(Buffer$2.from(new bn_js_1.default(br).toArray("le",16)))}writeU256(br){this.maybeResize(),this.writeBuffer(Buffer$2.from(new bn_js_1.default(br).toArray("le",32)))}writeU512(br){this.maybeResize(),this.writeBuffer(Buffer$2.from(new bn_js_1.default(br).toArray("le",64)))}writeBuffer(br){this.buf=Buffer$2.concat([Buffer$2.from(this.buf.subarray(0,this.length)),br,Buffer$2.alloc(INITIAL_LENGTH)]),this.length+=br.length}writeString(br){this.maybeResize();const wr=Buffer$2.from(br,"utf8");this.writeU32(wr.length),this.writeBuffer(wr)}writeFixedArray(br){this.writeBuffer(Buffer$2.from(br))}writeArray(br,wr){this.maybeResize(),this.writeU32(br.length);for(const Er of br)this.maybeResize(),wr(Er)}toArray(){return this.buf.subarray(0,this.length)}}lib.BinaryWriter=BinaryWriter;function handlingRangeError(fr,br,wr){const Er=wr.value;wr.value=function(...kr){try{return Er.apply(this,kr)}catch(jr){if(jr instanceof RangeError){const Br=jr.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(Br)>=0)throw new BorshError("Reached the end of buffer when deserializing")}throw jr}}}class BinaryReader{constructor(br){this.buf=br,this.offset=0}readU8(){const br=this.buf.readUInt8(this.offset);return this.offset+=1,br}readU16(){const br=this.buf.readUInt16LE(this.offset);return this.offset+=2,br}readU32(){const br=this.buf.readUInt32LE(this.offset);return this.offset+=4,br}readU64(){const br=this.readBuffer(8);return new bn_js_1.default(br,"le")}readU128(){const br=this.readBuffer(16);return new bn_js_1.default(br,"le")}readU256(){const br=this.readBuffer(32);return new bn_js_1.default(br,"le")}readU512(){const br=this.readBuffer(64);return new bn_js_1.default(br,"le")}readBuffer(br){if(this.offset+br>this.buf.length)throw new BorshError(`Expected buffer length ${br} isn't within bounds`);const wr=this.buf.slice(this.offset,this.offset+br);return this.offset+=br,wr}readString(){const br=this.readU32(),wr=this.readBuffer(br);try{return textDecoder.decode(wr)}catch(Er){throw new BorshError(`Error decoding UTF-8 string: ${Er}`)}}readFixedArray(br){return new Uint8Array(this.readBuffer(br))}readArray(br){const wr=this.readU32(),Er=Array();for(let kr=0;kr{serializeField(fr,br,jr,Er[0],kr)});else if(Er.kind!==void 0)switch(Er.kind){case"option":{wr==null?kr.writeU8(0):(kr.writeU8(1),serializeField(fr,br,wr,Er.type,kr));break}case"map":{kr.writeU32(wr.size),wr.forEach((jr,Br)=>{serializeField(fr,br,Br,Er.key,kr),serializeField(fr,br,jr,Er.value,kr)});break}default:throw new BorshError(`FieldType ${Er} unrecognized`)}else serializeStruct(fr,wr,kr)}catch(jr){throw jr instanceof BorshError&&jr.addToFieldPath(br),jr}}function serializeStruct(fr,br,wr){if(typeof br.borshSerialize=="function"){br.borshSerialize(wr);return}const Er=fr.get(br.constructor);if(!Er)throw new BorshError(`Class ${br.constructor.name} is missing in schema`);if(Er.kind==="struct")Er.fields.map(([kr,jr])=>{serializeField(fr,kr,br[kr],jr,wr)});else if(Er.kind==="enum"){const kr=br[Er.field];for(let jr=0;jrdeserializeField(fr,br,wr[0],Er))}if(wr.kind==="option")return Er.readU8()?deserializeField(fr,br,wr.type,Er):void 0;if(wr.kind==="map"){let kr=new Map;const jr=Er.readU32();for(let Br=0;Br=Er.values.length)throw new BorshError(`Enum index: ${kr} is out of range`);const[jr,Br]=Er.values[kr],Wr=deserializeField(fr,jr,Br,wr);return new br({[jr]:Wr})}throw new BorshError(`Unexpected schema kind: ${Er.kind} for ${br.constructor.name}`)}function deserialize(fr,br,wr,Er=BinaryReader){const kr=new Er(wr),jr=deserializeStruct(fr,br,kr);if(kr.offsetthis.span)throw new RangeError("indeterminate span");return this.span}replicate(br){const wr=Object.create(this.constructor.prototype);return Object.assign(wr,this),wr.property=br,wr}fromArray(br){}}Layout$1.Layout=Layout;function nameWithProperty(fr,br){return br.property?fr+"["+br.property+"]":fr}Layout$1.nameWithProperty=nameWithProperty;function bindConstructorLayout(fr,br){if(typeof fr!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(fr,"layout_"))throw new Error("Class is already bound to a layout");if(!(br&&br instanceof Layout))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(br,"boundConstructor_"))throw new Error("layout is already bound to a constructor");fr.layout_=br,br.boundConstructor_=fr,br.makeDestinationObject=()=>new fr,Object.defineProperty(fr.prototype,"encode",{value(wr,Er){return br.encode(this,wr,Er)},writable:!0}),Object.defineProperty(fr,"decode",{value(wr,Er){return br.decode(wr,Er)},writable:!0})}Layout$1.bindConstructorLayout=bindConstructorLayout;class ExternalLayout extends Layout{isCount(){throw new Error("ExternalLayout is abstract")}}Layout$1.ExternalLayout=ExternalLayout;class GreedyCount extends ExternalLayout{constructor(br=1,wr){if(!Number.isInteger(br)||0>=br)throw new TypeError("elementSpan must be a (positive) integer");super(-1,wr),this.elementSpan=br}isCount(){return!0}decode(br,wr=0){checkUint8Array(br);const Er=br.length-wr;return Math.floor(Er/this.elementSpan)}encode(br,wr,Er){return 0}}Layout$1.GreedyCount=GreedyCount;class OffsetLayout extends ExternalLayout{constructor(br,wr=0,Er){if(!(br instanceof Layout))throw new TypeError("layout must be a Layout");if(!Number.isInteger(wr))throw new TypeError("offset must be integer or undefined");super(br.span,Er||br.property),this.layout=br,this.offset=wr}isCount(){return this.layout instanceof UInt||this.layout instanceof UIntBE}decode(br,wr=0){return this.layout.decode(br,wr+this.offset)}encode(br,wr,Er=0){return this.layout.encode(br,wr,Er+this.offset)}}Layout$1.OffsetLayout=OffsetLayout;class UInt extends Layout{constructor(br,wr){if(super(br,wr),6Br+kr.encode(Wr,wr,Er+Br),0);return this.count instanceof ExternalLayout&&this.count.encode(br.length,wr,Er),jr}}Layout$1.Sequence=Sequence;class Structure extends Layout{constructor(br,wr,Er){if(!(Array.isArray(br)&&br.reduce((jr,Br)=>jr&&Br instanceof Layout,!0)))throw new TypeError("fields must be array of Layout instances");typeof wr=="boolean"&&Er===void 0&&(Er=wr,wr=void 0);for(const jr of br)if(0>jr.span&&jr.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let kr=-1;try{kr=br.reduce((jr,Br)=>jr+Br.getSpan(),0)}catch{}super(kr,wr),this.fields=br,this.decodePrefixes=!!Er}getSpan(br,wr=0){if(0<=this.span)return this.span;let Er=0;try{Er=this.fields.reduce((kr,jr)=>{const Br=jr.getSpan(br,wr);return wr+=Br,kr+Br},0)}catch{throw new RangeError("indeterminate span")}return Er}decode(br,wr=0){checkUint8Array(br);const Er=this.makeDestinationObject();for(const kr of this.fields)if(kr.property!==void 0&&(Er[kr.property]=kr.decode(br,wr)),wr+=kr.getSpan(br,wr),this.decodePrefixes&&br.length===wr)break;return Er}encode(br,wr,Er=0){const kr=Er;let jr=0,Br=0;for(const Wr of this.fields){let qr=Wr.span;if(Br=0qr&&(qr=Wr.getSpan(wr,Er)))}jr=Er,Er+=qr}return jr+Br-kr}fromArray(br){const wr=this.makeDestinationObject();for(const Er of this.fields)Er.property!==void 0&&0Er.span?wr=-1:0<=wr&&(wr+=Er.span)}}}Layout$1.Structure=Structure;class UnionDiscriminator{constructor(br){this.property=br}decode(br,wr){throw new Error("UnionDiscriminator is abstract")}encode(br,wr,Er){throw new Error("UnionDiscriminator is abstract")}}Layout$1.UnionDiscriminator=UnionDiscriminator;class UnionLayoutDiscriminator extends UnionDiscriminator{constructor(br,wr){if(!(br instanceof ExternalLayout&&br.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(wr||br.property||"variant"),this.layout=br}decode(br,wr){return this.layout.decode(br,wr)}encode(br,wr,Er){return this.layout.encode(br,wr,Er)}}Layout$1.UnionLayoutDiscriminator=UnionLayoutDiscriminator;class Union extends Layout{constructor(br,wr,Er){let kr;if(br instanceof UInt||br instanceof UIntBE)kr=new UnionLayoutDiscriminator(new OffsetLayout(br));else if(br instanceof ExternalLayout&&br.isCount())kr=new UnionLayoutDiscriminator(br);else if(br instanceof UnionDiscriminator)kr=br;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(wr===void 0&&(wr=null),!(wr===null||wr instanceof Layout))throw new TypeError("defaultLayout must be null or a Layout");if(wr!==null){if(0>wr.span)throw new Error("defaultLayout must have constant span");wr.property===void 0&&(wr=wr.replicate("content"))}let jr=-1;wr&&(jr=wr.span,0<=jr&&(br instanceof UInt||br instanceof UIntBE)&&(jr+=kr.layout.span)),super(jr,Er),this.discriminator=kr,this.usesPrefixDiscriminator=br instanceof UInt||br instanceof UIntBE,this.defaultLayout=wr,this.registry={};let Br=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(Wr){return Br(Wr)},this.configGetSourceVariant=function(Wr){Br=Wr.bind(this)}}getSpan(br,wr=0){if(0<=this.span)return this.span;const Er=this.getVariant(br,wr);if(!Er)throw new Error("unable to determine span for unrecognized variant");return Er.getSpan(br,wr)}defaultGetSourceVariant(br){if(Object.prototype.hasOwnProperty.call(br,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(br,this.defaultLayout.property))return;const wr=this.registry[br[this.discriminator.property]];if(wr&&(!wr.layout||wr.property&&Object.prototype.hasOwnProperty.call(br,wr.property)))return wr}else for(const wr in this.registry){const Er=this.registry[wr];if(Er.property&&Object.prototype.hasOwnProperty.call(br,Er.property))return Er}throw new Error("unable to infer src variant")}decode(br,wr=0){let Er;const kr=this.discriminator,jr=kr.decode(br,wr),Br=this.registry[jr];if(Br===void 0){const Wr=this.defaultLayout;let qr=0;this.usesPrefixDiscriminator&&(qr=kr.layout.span),Er=this.makeDestinationObject(),Er[kr.property]=jr,Er[Wr.property]=Wr.decode(br,wr+qr)}else Er=Br.decode(br,wr);return Er}encode(br,wr,Er=0){const kr=this.getSourceVariant(br);if(kr===void 0){const jr=this.discriminator,Br=this.defaultLayout;let Wr=0;return this.usesPrefixDiscriminator&&(Wr=jr.layout.span),jr.encode(br[jr.property],wr,Er),Wr+Br.encode(br[Br.property],wr,Er+Wr)}return kr.encode(br,wr,Er)}addVariant(br,wr,Er){const kr=new VariantLayout(this,br,wr,Er);return this.registry[br]=kr,kr}getVariant(br,wr=0){let Er;return br instanceof Uint8Array?Er=this.discriminator.decode(br,wr):Er=br,this.registry[Er]}}Layout$1.Union=Union;class VariantLayout extends Layout{constructor(br,wr,Er,kr){if(!(br instanceof Union))throw new TypeError("union must be a Union");if(!Number.isInteger(wr)||0>wr)throw new TypeError("variant must be a (non-negative) integer");if(typeof Er=="string"&&kr===void 0&&(kr=Er,Er=null),Er){if(!(Er instanceof Layout))throw new TypeError("layout must be a Layout");if(br.defaultLayout!==null&&0<=Er.span&&Er.span>br.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof kr!="string")throw new TypeError("variant must have a String property")}let jr=br.span;0>br.span&&(jr=Er?Er.span:0,0<=jr&&br.usesPrefixDiscriminator&&(jr+=br.discriminator.layout.span)),super(jr,kr),this.union=br,this.variant=wr,this.layout=Er||null}getSpan(br,wr=0){if(0<=this.span)return this.span;let Er=0;this.union.usesPrefixDiscriminator&&(Er=this.union.discriminator.layout.span);let kr=0;return this.layout&&(kr=this.layout.getSpan(br,wr+Er)),Er+kr}decode(br,wr=0){const Er=this.makeDestinationObject();if(this!==this.union.getVariant(br,wr))throw new Error("variant mismatch");let kr=0;return this.union.usesPrefixDiscriminator&&(kr=this.union.discriminator.layout.span),this.layout?Er[this.property]=this.layout.decode(br,wr+kr):this.property?Er[this.property]=!0:this.union.usesPrefixDiscriminator&&(Er[this.union.discriminator.property]=this.variant),Er}encode(br,wr,Er=0){let kr=0;if(this.union.usesPrefixDiscriminator&&(kr=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(br,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,wr,Er);let jr=kr;if(this.layout&&(this.layout.encode(br[this.property],wr,Er+kr),jr+=this.layout.getSpan(wr,Er+kr),0<=this.union.span&&jr>this.union.span))throw new Error("encoded variant overruns containing union");return jr}fromArray(br){if(this.layout)return this.layout.fromArray(br)}}Layout$1.VariantLayout=VariantLayout;function fixBitwiseResult(fr){return 0>fr&&(fr+=4294967296),fr}class BitStructure extends Layout{constructor(br,wr,Er){if(!(br instanceof UInt||br instanceof UIntBE))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof wr=="string"&&Er===void 0&&(Er=wr,wr=!1),4=wr)throw new TypeError("bits must be positive integer");const kr=8*br.span,jr=br.fields.reduce((Br,Wr)=>Br+Wr.bits,0);if(wr+jr>kr)throw new Error("bits too long for span remainder ("+(kr-jr)+" of "+kr+" remain)");this.container=br,this.bits=wr,this.valueMask=(1<>>this.start}encode(br){if(typeof br!="number"||!Number.isInteger(br)||br!==fixBitwiseResult(br&this.valueMask))throw new TypeError(nameWithProperty("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const wr=this.container._packedGetValue(),Er=fixBitwiseResult(br<Er&&(Er=this.length.decode(br,wr)),Er}decode(br,wr=0){let Er=this.span;return 0>Er&&(Er=this.length.decode(br,wr)),uint8ArrayToBuffer(br).slice(wr,wr+Er)}encode(br,wr,Er){let kr=this.length;if(this.length instanceof ExternalLayout&&(kr=br.length),!(br instanceof Uint8Array&&kr===br.length))throw new TypeError(nameWithProperty("Blob.encode",this)+" requires (length "+kr+") Uint8Array as src");if(Er+kr>wr.length)throw new RangeError("encoding overruns Uint8Array");const jr=uint8ArrayToBuffer(br);return uint8ArrayToBuffer(wr).write(jr.toString("hex"),Er,kr,"hex"),this.length instanceof ExternalLayout&&this.length.encode(kr,wr,Er),kr}};Layout$1.Blob=Blob$1;class CString extends Layout{constructor(br){super(-1,br)}getSpan(br,wr=0){checkUint8Array(br);let Er=wr;for(;Erwr.length)throw new RangeError("encoding overruns Buffer");const Br=uint8ArrayToBuffer(wr);return kr.copy(Br,Er),Br[Er+jr]=0,jr+1}}Layout$1.CString=CString;class UTF8 extends Layout{constructor(br,wr){if(typeof br=="string"&&wr===void 0&&(wr=br,br=void 0),br===void 0)br=-1;else if(!Number.isInteger(br))throw new TypeError("maxSpan must be an integer");super(-1,wr),this.maxSpan=br}getSpan(br,wr=0){return checkUint8Array(br),br.length-wr}decode(br,wr=0){const Er=this.getSpan(br,wr);if(0<=this.maxSpan&&this.maxSpanwr.length)throw new RangeError("encoding overruns Buffer");return kr.copy(uint8ArrayToBuffer(wr),Er),jr}}Layout$1.UTF8=UTF8;class Constant extends Layout{constructor(br,wr){super(0,wr),this.value=br}decode(br,wr){return this.value}encode(br,wr,Er){return 0}}Layout$1.Constant=Constant;Layout$1.greedy=(fr,br)=>new GreedyCount(fr,br);var offset=Layout$1.offset=(fr,br,wr)=>new OffsetLayout(fr,br,wr),u8=Layout$1.u8=fr=>new UInt(1,fr),u16=Layout$1.u16=fr=>new UInt(2,fr);Layout$1.u24=fr=>new UInt(3,fr);var u32=Layout$1.u32=fr=>new UInt(4,fr);Layout$1.u40=fr=>new UInt(5,fr);Layout$1.u48=fr=>new UInt(6,fr);var nu64=Layout$1.nu64=fr=>new NearUInt64(fr);Layout$1.u16be=fr=>new UIntBE(2,fr);Layout$1.u24be=fr=>new UIntBE(3,fr);Layout$1.u32be=fr=>new UIntBE(4,fr);Layout$1.u40be=fr=>new UIntBE(5,fr);Layout$1.u48be=fr=>new UIntBE(6,fr);Layout$1.nu64be=fr=>new NearUInt64BE(fr);Layout$1.s8=fr=>new Int(1,fr);Layout$1.s16=fr=>new Int(2,fr);Layout$1.s24=fr=>new Int(3,fr);Layout$1.s32=fr=>new Int(4,fr);Layout$1.s40=fr=>new Int(5,fr);Layout$1.s48=fr=>new Int(6,fr);var ns64=Layout$1.ns64=fr=>new NearInt64(fr);Layout$1.s16be=fr=>new IntBE(2,fr);Layout$1.s24be=fr=>new IntBE(3,fr);Layout$1.s32be=fr=>new IntBE(4,fr);Layout$1.s40be=fr=>new IntBE(5,fr);Layout$1.s48be=fr=>new IntBE(6,fr);Layout$1.ns64be=fr=>new NearInt64BE(fr);Layout$1.f32=fr=>new Float(fr);Layout$1.f32be=fr=>new FloatBE(fr);Layout$1.f64=fr=>new Double(fr);Layout$1.f64be=fr=>new DoubleBE(fr);var struct=Layout$1.struct=(fr,br,wr)=>new Structure(fr,br,wr);Layout$1.bits=(fr,br,wr)=>new BitStructure(fr,br,wr);var seq=Layout$1.seq=(fr,br,wr)=>new Sequence(fr,br,wr);Layout$1.union=(fr,br,wr)=>new Union(fr,br,wr);Layout$1.unionLayoutDiscriminator=(fr,br)=>new UnionLayoutDiscriminator(fr,br);var blob=Layout$1.blob=(fr,br)=>new Blob$1(fr,br);Layout$1.cstr=fr=>new CString(fr);Layout$1.utf8=(fr,br)=>new UTF8(fr,br);Layout$1.constant=(fr,br)=>new Constant(fr,br);var browser$1={};Object.defineProperty(browser$1,"__esModule",{value:!0});function toBigIntLE(fr){{const br=Buffer$2.from(fr);br.reverse();const wr=br.toString("hex");return wr.length===0?BigInt(0):BigInt(`0x${wr}`)}}var toBigIntLE_1=browser$1.toBigIntLE=toBigIntLE;function toBigIntBE(fr){{const br=fr.toString("hex");return br.length===0?BigInt(0):BigInt(`0x${br}`)}}browser$1.toBigIntBE=toBigIntBE;function toBufferLE(fr,br){{const wr=fr.toString(16),Er=Buffer$2.from(wr.padStart(br*2,"0").slice(0,br*2),"hex");return Er.reverse(),Er}}var toBufferLE_1=browser$1.toBufferLE=toBufferLE;function toBufferBE(fr,br){{const wr=fr.toString(16);return Buffer$2.from(wr.padStart(br*2,"0").slice(0,br*2),"hex")}}browser$1.toBufferBE=toBufferBE;let StructError$2=class extends TypeError{constructor(br,wr){let Er;const{message:kr,explanation:jr,...Br}=br,{path:Wr}=br,qr=Wr.length===0?kr:`At path: ${Wr.join(".")} -- ${kr}`;super(jr??qr),jr!=null&&(this.cause=qr),Object.assign(this,Br),this.name=this.constructor.name,this.failures=()=>Er??(Er=[br,...wr()])}};function isIterable$2(fr){return isObject$2(fr)&&typeof fr[Symbol.iterator]=="function"}function isObject$2(fr){return typeof fr=="object"&&fr!=null}function print$2(fr){return typeof fr=="symbol"?fr.toString():typeof fr=="string"?JSON.stringify(fr):`${fr}`}function shiftIterator$2(fr){const{done:br,value:wr}=fr.next();return br?void 0:wr}function toFailure$2(fr,br,wr,Er){if(fr===!0)return;fr===!1?fr={}:typeof fr=="string"&&(fr={message:fr});const{path:kr,branch:jr}=br,{type:Br}=wr,{refinement:Wr,message:qr=`Expected a value of type \`${Br}\`${Wr?` with refinement \`${Wr}\``:""}, but received: \`${print$2(Er)}\``}=fr;return{value:Er,type:Br,refinement:Wr,key:kr[kr.length-1],path:kr,branch:jr,...fr,message:qr}}function*toFailures$2(fr,br,wr,Er){isIterable$2(fr)||(fr=[fr]);for(const kr of fr){const jr=toFailure$2(kr,br,wr,Er);jr&&(yield jr)}}function*run$2(fr,br,wr={}){const{path:Er=[],branch:kr=[fr],coerce:jr=!1,mask:Br=!1}=wr,Wr={path:Er,branch:kr};if(jr&&(fr=br.coercer(fr,Wr),Br&&br.type!=="type"&&isObject$2(br.schema)&&isObject$2(fr)&&!Array.isArray(fr)))for(const Hr in fr)br.schema[Hr]===void 0&&delete fr[Hr];let qr="valid";for(const Hr of br.validator(fr,Wr))Hr.explanation=wr.message,qr="not_valid",yield[Hr,void 0];for(let[Hr,Vr,Zr]of br.entries(fr,Wr)){const Jr=run$2(Vr,Zr,{path:Hr===void 0?Er:[...Er,Hr],branch:Hr===void 0?kr:[...kr,Vr],coerce:jr,mask:Br,message:wr.message});for(const Qr of Jr)Qr[0]?(qr=Qr[0].refinement!=null?"not_refined":"not_valid",yield[Qr[0],void 0]):jr&&(Vr=Qr[1],Hr===void 0?fr=Vr:fr instanceof Map?fr.set(Hr,Vr):fr instanceof Set?fr.add(Vr):isObject$2(fr)&&(Vr!==void 0||Hr in fr)&&(fr[Hr]=Vr))}if(qr!=="not_valid")for(const Hr of br.refiner(fr,Wr))Hr.explanation=wr.message,qr="not_refined",yield[Hr,void 0];qr==="valid"&&(yield[void 0,fr])}let Struct$5=class{constructor(br){const{type:wr,schema:Er,validator:kr,refiner:jr,coercer:Br=qr=>qr,entries:Wr=function*(){}}=br;this.type=wr,this.schema=Er,this.entries=Wr,this.coercer=Br,kr?this.validator=(qr,Hr)=>{const Vr=kr(qr,Hr);return toFailures$2(Vr,Hr,this,qr)}:this.validator=()=>[],jr?this.refiner=(qr,Hr)=>{const Vr=jr(qr,Hr);return toFailures$2(Vr,Hr,this,qr)}:this.refiner=()=>[]}assert(br,wr){return assert$3(br,this,wr)}create(br,wr){return create$2(br,this,wr)}is(br){return is$2(br,this)}mask(br,wr){return mask$2(br,this,wr)}validate(br,wr={}){return validate$3(br,this,wr)}};function assert$3(fr,br,wr){const Er=validate$3(fr,br,{message:wr});if(Er[0])throw Er[0]}function create$2(fr,br,wr){const Er=validate$3(fr,br,{coerce:!0,message:wr});if(Er[0])throw Er[0];return Er[1]}function mask$2(fr,br,wr){const Er=validate$3(fr,br,{coerce:!0,mask:!0,message:wr});if(Er[0])throw Er[0];return Er[1]}function is$2(fr,br){return!validate$3(fr,br)[0]}function validate$3(fr,br,wr={}){const Er=run$2(fr,br,wr),kr=shiftIterator$2(Er);return kr[0]?[new StructError$2(kr[0],function*(){for(const Br of Er)Br[0]&&(yield Br[0])}),void 0]:[void 0,kr[1]]}function define$2(fr,br){return new Struct$5({type:fr,schema:null,validator:br})}function any$2(){return define$2("any",()=>!0)}function array$2(fr){return new Struct$5({type:"array",schema:fr,*entries(br){if(fr&&Array.isArray(br))for(const[wr,Er]of br.entries())yield[wr,Er,fr]},coercer(br){return Array.isArray(br)?br.slice():br},validator(br){return Array.isArray(br)||`Expected an array value, but received: ${print$2(br)}`}})}function boolean$2(){return define$2("boolean",fr=>typeof fr=="boolean")}function instance$2(fr){return define$2("instance",br=>br instanceof fr||`Expected a \`${fr.name}\` instance, but received: ${print$2(br)}`)}function literal$2(fr){const br=print$2(fr),wr=typeof fr;return new Struct$5({type:"literal",schema:wr==="string"||wr==="number"||wr==="boolean"?fr:null,validator(Er){return Er===fr||`Expected the literal \`${br}\`, but received: ${print$2(Er)}`}})}function never$2(){return define$2("never",()=>!1)}function nullable$2(fr){return new Struct$5({...fr,validator:(br,wr)=>br===null||fr.validator(br,wr),refiner:(br,wr)=>br===null||fr.refiner(br,wr)})}function number$2(){return define$2("number",fr=>typeof fr=="number"&&!isNaN(fr)||`Expected a number, but received: ${print$2(fr)}`)}function optional$2(fr){return new Struct$5({...fr,validator:(br,wr)=>br===void 0||fr.validator(br,wr),refiner:(br,wr)=>br===void 0||fr.refiner(br,wr)})}function record$2(fr,br){return new Struct$5({type:"record",schema:null,*entries(wr){if(isObject$2(wr))for(const Er in wr){const kr=wr[Er];yield[Er,Er,fr],yield[Er,kr,br]}},validator(wr){return isObject$2(wr)||`Expected an object, but received: ${print$2(wr)}`}})}function string$2(){return define$2("string",fr=>typeof fr=="string"||`Expected a string, but received: ${print$2(fr)}`)}function tuple$2(fr){const br=never$2();return new Struct$5({type:"tuple",schema:null,*entries(wr){if(Array.isArray(wr)){const Er=Math.max(fr.length,wr.length);for(let kr=0;krwr.type).join(" | ");return new Struct$5({type:"union",schema:null,coercer(wr){for(const Er of fr){const[kr,jr]=Er.validate(wr,{coerce:!0});if(!kr)return jr}return wr},validator(wr,Er){const kr=[];for(const jr of fr){const[...Br]=run$2(wr,jr,Er),[Wr]=Br;if(Wr[0])for(const[qr]of Br)qr&&kr.push(qr);else return[]}return[`Expected the value to satisfy a union of \`${br}\`, but received: ${print$2(wr)}`,...kr]}})}function unknown$2(){return define$2("unknown",()=>!0)}function coerce$2(fr,br,wr){return new Struct$5({...fr,coercer:(Er,kr)=>is$2(Er,br)?fr.coercer(wr(Er,kr),kr):fr.coercer(Er,kr)})}var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&(getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!getRandomValues))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}const REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate$2(fr){return typeof fr=="string"&®EX.test(fr)}var byteToHex=[];for(var i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify$1(fr){var br=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,wr=(byteToHex[fr[br+0]]+byteToHex[fr[br+1]]+byteToHex[fr[br+2]]+byteToHex[fr[br+3]]+"-"+byteToHex[fr[br+4]]+byteToHex[fr[br+5]]+"-"+byteToHex[fr[br+6]]+byteToHex[fr[br+7]]+"-"+byteToHex[fr[br+8]]+byteToHex[fr[br+9]]+"-"+byteToHex[fr[br+10]]+byteToHex[fr[br+11]]+byteToHex[fr[br+12]]+byteToHex[fr[br+13]]+byteToHex[fr[br+14]]+byteToHex[fr[br+15]]).toLowerCase();if(!validate$2(wr))throw TypeError("Stringified UUID is invalid");return wr}var _nodeId,_clockseq,_lastMSecs=0,_lastNSecs=0;function v1(fr,br,wr){var Er=br&&wr||0,kr=br||new Array(16);fr=fr||{};var jr=fr.node||_nodeId,Br=fr.clockseq!==void 0?fr.clockseq:_clockseq;if(jr==null||Br==null){var Wr=fr.random||(fr.rng||rng)();jr==null&&(jr=_nodeId=[Wr[0]|1,Wr[1],Wr[2],Wr[3],Wr[4],Wr[5]]),Br==null&&(Br=_clockseq=(Wr[6]<<8|Wr[7])&16383)}var qr=fr.msecs!==void 0?fr.msecs:Date.now(),Hr=fr.nsecs!==void 0?fr.nsecs:_lastNSecs+1,Vr=qr-_lastMSecs+(Hr-_lastNSecs)/1e4;if(Vr<0&&fr.clockseq===void 0&&(Br=Br+1&16383),(Vr<0||qr>_lastMSecs)&&fr.nsecs===void 0&&(Hr=0),Hr>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=qr,_lastNSecs=Hr,_clockseq=Br,qr+=122192928e5;var Zr=((qr&268435455)*1e4+Hr)%4294967296;kr[Er++]=Zr>>>24&255,kr[Er++]=Zr>>>16&255,kr[Er++]=Zr>>>8&255,kr[Er++]=Zr&255;var Jr=qr/4294967296*1e4&268435455;kr[Er++]=Jr>>>8&255,kr[Er++]=Jr&255,kr[Er++]=Jr>>>24&15|16,kr[Er++]=Jr>>>16&255,kr[Er++]=Br>>>8|128,kr[Er++]=Br&255;for(var Qr=0;Qr<6;++Qr)kr[Er+Qr]=jr[Qr];return br||stringify$1(kr)}function parse(fr){if(!validate$2(fr))throw TypeError("Invalid UUID");var br,wr=new Uint8Array(16);return wr[0]=(br=parseInt(fr.slice(0,8),16))>>>24,wr[1]=br>>>16&255,wr[2]=br>>>8&255,wr[3]=br&255,wr[4]=(br=parseInt(fr.slice(9,13),16))>>>8,wr[5]=br&255,wr[6]=(br=parseInt(fr.slice(14,18),16))>>>8,wr[7]=br&255,wr[8]=(br=parseInt(fr.slice(19,23),16))>>>8,wr[9]=br&255,wr[10]=(br=parseInt(fr.slice(24,36),16))/1099511627776&255,wr[11]=br/4294967296&255,wr[12]=br>>>24&255,wr[13]=br>>>16&255,wr[14]=br>>>8&255,wr[15]=br&255,wr}function stringToBytes(fr){fr=unescape(encodeURIComponent(fr));for(var br=[],wr=0;wr>5]>>>kr%32&255,Br=parseInt(Er.charAt(jr>>>4&15)+Er.charAt(jr&15),16);br.push(Br)}return br}function getOutputLength(fr){return(fr+64>>>9<<4)+14+1}function wordsToMd5(fr,br){fr[br>>5]|=128<>5]|=(fr[Er/8]&255)<>16)+(br>>16)+(wr>>16);return Er<<16|wr&65535}function bitRotateLeft(fr,br){return fr<>>32-br}function md5cmn(fr,br,wr,Er,kr,jr){return safeAdd(bitRotateLeft(safeAdd(safeAdd(br,fr),safeAdd(Er,jr)),kr),wr)}function md5ff(fr,br,wr,Er,kr,jr,Br){return md5cmn(br&wr|~br&Er,fr,br,kr,jr,Br)}function md5gg(fr,br,wr,Er,kr,jr,Br){return md5cmn(br&Er|wr&~Er,fr,br,kr,jr,Br)}function md5hh(fr,br,wr,Er,kr,jr,Br){return md5cmn(br^wr^Er,fr,br,kr,jr,Br)}function md5ii(fr,br,wr,Er,kr,jr,Br){return md5cmn(wr^(br|~Er),fr,br,kr,jr,Br)}var v3=v35("v3",48,md5);function v4(fr,br,wr){fr=fr||{};var Er=fr.random||(fr.rng||rng)();if(Er[6]=Er[6]&15|64,Er[8]=Er[8]&63|128,br){wr=wr||0;for(var kr=0;kr<16;++kr)br[wr+kr]=Er[kr];return br}return stringify$1(Er)}function f(fr,br,wr,Er){switch(fr){case 0:return br&wr^~br&Er;case 1:return br^wr^Er;case 2:return br&wr^br&Er^wr&Er;case 3:return br^wr^Er}}function ROTL(fr,br){return fr<>>32-br}function sha1(fr){var br=[1518500249,1859775393,2400959708,3395469782],wr=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof fr=="string"){var Er=unescape(encodeURIComponent(fr));fr=[];for(var kr=0;kr>>0;jn=An,An=In,In=ROTL(Cn,30)>>>0,Cn=En,En=to}wr[0]=wr[0]+En>>>0,wr[1]=wr[1]+Cn>>>0,wr[2]=wr[2]+In>>>0,wr[3]=wr[3]+An>>>0,wr[4]=wr[4]+jn>>>0}return[wr[0]>>24&255,wr[0]>>16&255,wr[0]>>8&255,wr[0]&255,wr[1]>>24&255,wr[1]>>16&255,wr[1]>>8&255,wr[1]&255,wr[2]>>24&255,wr[2]>>16&255,wr[2]>>8&255,wr[2]&255,wr[3]>>24&255,wr[3]>>16&255,wr[3]>>8&255,wr[3]&255,wr[4]>>24&255,wr[4]>>16&255,wr[4]>>8&255,wr[4]&255]}var v5=v35("v5",80,sha1);const nil="00000000-0000-0000-0000-000000000000";function version$5(fr){if(!validate$2(fr))throw TypeError("Invalid UUID");return parseInt(fr.substr(14,1),16)}const esmBrowser=Object.freeze(Object.defineProperty({__proto__:null,NIL:nil,parse,stringify:stringify$1,v1,v3,v4,v5,validate:validate$2,version:version$5},Symbol.toStringTag,{value:"Module"})),require$$0=getAugmentedNamespace(esmBrowser),uuid$1=require$$0.v4,generateRequest$1=function(fr,br,wr,Er){if(typeof fr!="string")throw new TypeError(fr+" must be a string");Er=Er||{};const kr=typeof Er.version=="number"?Er.version:2;if(kr!==1&&kr!==2)throw new TypeError(kr+" must be 1 or 2");const jr={method:fr};if(kr===2&&(jr.jsonrpc="2.0"),br){if(typeof br!="object"&&!Array.isArray(br))throw new TypeError(br+" must be an object, array or omitted");jr.params=br}if(typeof wr>"u"){const Br=typeof Er.generator=="function"?Er.generator:function(){return uuid$1()};jr.id=Br(jr,Er)}else kr===2&&wr===null?Er.notificationIdNull&&(jr.id=null):jr.id=wr;return jr};var generateRequest_1=generateRequest$1;const uuid=require$$0.v4,generateRequest=generateRequest_1,ClientBrowser=function(fr,br){if(!(this instanceof ClientBrowser))return new ClientBrowser(fr,br);br||(br={}),this.options={reviver:typeof br.reviver<"u"?br.reviver:null,replacer:typeof br.replacer<"u"?br.replacer:null,generator:typeof br.generator<"u"?br.generator:function(){return uuid()},version:typeof br.version<"u"?br.version:2,notificationIdNull:typeof br.notificationIdNull=="boolean"?br.notificationIdNull:!1},this.callServer=fr};var browser=ClientBrowser;ClientBrowser.prototype.request=function(fr,br,wr,Er){const kr=this;let jr=null;const Br=Array.isArray(fr)&&typeof br=="function";if(this.options.version===1&&Br)throw new TypeError("JSON-RPC 1.0 does not support batching");if(Br||!Br&&fr&&typeof fr=="object"&&typeof br=="function")Er=br,jr=fr;else{typeof wr=="function"&&(Er=wr,wr=void 0);const Hr=typeof Er=="function";try{jr=generateRequest(fr,br,wr,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(Vr){if(Hr)return Er(Vr);throw Vr}if(!Hr)return jr}let qr;try{qr=JSON.stringify(jr,this.options.replacer)}catch(Hr){return Er(Hr)}return this.callServer(qr,function(Hr,Vr){kr._parseResponse(Hr,Vr,Er)}),jr};ClientBrowser.prototype._parseResponse=function(fr,br,wr){if(fr){wr(fr);return}if(!br)return wr();let Er;try{Er=JSON.parse(br,this.options.reviver)}catch(kr){return wr(kr)}if(wr.length===3)if(Array.isArray(Er)){const kr=function(Br){return typeof Br.error<"u"},jr=function(Br){return!kr(Br)};return wr(null,Er.filter(kr),Er.filter(jr))}else return wr(null,Er.error,Er.result);wr(null,Er)};const RpcClient=getDefaultExportFromCjs$2(browser);var client={},eventemitter3={exports:{}};(function(fr){var br=Object.prototype.hasOwnProperty,wr="~";function Er(){}Object.create&&(Er.prototype=Object.create(null),new Er().__proto__||(wr=!1));function kr(qr,Hr,Vr){this.fn=qr,this.context=Hr,this.once=Vr||!1}function jr(qr,Hr,Vr,Zr,Jr){if(typeof Vr!="function")throw new TypeError("The listener must be a function");var Qr=new kr(Vr,Zr||qr,Jr),_n=wr?wr+Hr:Hr;return qr._events[_n]?qr._events[_n].fn?qr._events[_n]=[qr._events[_n],Qr]:qr._events[_n].push(Qr):(qr._events[_n]=Qr,qr._eventsCount++),qr}function Br(qr,Hr){--qr._eventsCount===0?qr._events=new Er:delete qr._events[Hr]}function Wr(){this._events=new Er,this._eventsCount=0}Wr.prototype.eventNames=function(){var Hr=[],Vr,Zr;if(this._eventsCount===0)return Hr;for(Zr in Vr=this._events)br.call(Vr,Zr)&&Hr.push(wr?Zr.slice(1):Zr);return Object.getOwnPropertySymbols?Hr.concat(Object.getOwnPropertySymbols(Vr)):Hr},Wr.prototype.listeners=function(Hr){var Vr=wr?wr+Hr:Hr,Zr=this._events[Vr];if(!Zr)return[];if(Zr.fn)return[Zr.fn];for(var Jr=0,Qr=Zr.length,_n=new Array(Qr);Jr++this.rpc_id),Vr?this.dataPack=Vr:this.dataPack=new utils_cjs_1.DefaultDataPack,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(wr,Er,kr,jr){return!jr&&typeof kr=="object"&&(jr=kr,kr=null),new Promise((Br,Wr)=>{if(!this.ready)return Wr(new Error("socket not ready"));const qr=this.generate_request_id(wr,Er),Hr={jsonrpc:"2.0",method:wr,params:Er||void 0,id:qr};this.socket.send(this.dataPack.encode(Hr),jr,Vr=>{if(Vr)return Wr(Vr);this.queue[qr]={promise:[Br,Wr]},kr&&(this.queue[qr].timeout=setTimeout(()=>{delete this.queue[qr],Wr(new Error("reply timeout"))},kr))})})}async login(wr){const Er=await this.call("rpc.login",wr);if(!Er)throw new Error("authentication failed");return Er}async listMethods(){return await this.call("__listMethods")}notify(wr,Er){return new Promise((kr,jr)=>{if(!this.ready)return jr(new Error("socket not ready"));const Br={jsonrpc:"2.0",method:wr,params:Er};this.socket.send(this.dataPack.encode(Br),Wr=>{if(Wr)return jr(Wr);kr()})})}async subscribe(wr){typeof wr=="string"&&(wr=[wr]);const Er=await this.call("rpc.on",wr);if(typeof wr=="string"&&Er[wr]!=="ok")throw new Error("Failed subscribing to an event '"+wr+"' with: "+Er[wr]);return Er}async unsubscribe(wr){typeof wr=="string"&&(wr=[wr]);const Er=await this.call("rpc.off",wr);if(typeof wr=="string"&&Er[wr]!=="ok")throw new Error("Failed unsubscribing from an event with: "+Er);return Er}close(wr,Er){this.socket.close(wr||1e3,Er)}setAutoReconnect(wr){this.reconnect=wr}setReconnectInterval(wr){this.reconnect_interval=wr}setMaxReconnects(wr){this.max_reconnects=wr}_connect(wr,Er){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(wr,Er),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:kr})=>{kr instanceof ArrayBuffer&&(kr=Buffer$2.from(kr).toString());try{kr=this.dataPack.decode(kr)}catch{return}if(kr.notification&&this.listeners(kr.notification).length){if(!Object.keys(kr.params).length)return this.emit(kr.notification);const jr=[kr.notification];if(kr.params.constructor===Object)jr.push(kr.params);else for(let Br=0;Br{this.emit.apply(this,jr)})}if(!this.queue[kr.id])return kr.method?Promise.resolve().then(()=>{this.emit(kr.method,kr==null?void 0:kr.params)}):void 0;"error"in kr=="result"in kr&&this.queue[kr.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[kr.id].timeout&&clearTimeout(this.queue[kr.id].timeout),kr.error?this.queue[kr.id].promise[1](kr.error):this.queue[kr.id].promise[0](kr.result),delete this.queue[kr.id]}),this.socket.addEventListener("error",kr=>this.emit("error",kr)),this.socket.addEventListener("close",({code:kr,reason:jr})=>{this.ready&&setTimeout(()=>this.emit("close",kr,jr),0),this.ready=!1,this.socket=void 0,kr!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(wr,Er),this.reconnect_interval)))})}}var _default$1=client.default=CommonClient,websocket_browser={};Object.defineProperty(websocket_browser,"__esModule",{value:!0});const eventemitter3_1=eventemitter3Exports;class WebSocketBrowserImpl extends eventemitter3_1.EventEmitter{constructor(wr,Er,kr){super();Uu(this,"socket");this.socket=new window.WebSocket(wr,kr),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=jr=>this.emit("message",jr.data),this.socket.onerror=jr=>this.emit("error",jr),this.socket.onclose=jr=>{this.emit("close",jr.code,jr.reason)}}send(wr,Er,kr){const jr=kr||Er;try{this.socket.send(wr),jr()}catch(Br){jr(Br)}}close(wr,Er){this.socket.close(wr,Er)}addEventListener(wr,Er,kr){this.socket.addEventListener(wr,Er,kr)}}function default_1(fr,br){return new WebSocketBrowserImpl(fr,br)}var _default=websocket_browser.default=default_1;function isOnCurve$2(fr){try{return ed25519.ExtendedPoint.fromHex(fr),!0}catch{return!1}}const sign=(fr,br)=>ed25519.sign(fr,br.slice(0,32)),verify=ed25519.verify,toBuffer$2=fr=>Buffer$1$1.isBuffer(fr)?fr:fr instanceof Uint8Array?Buffer$1$1.from(fr.buffer,fr.byteOffset,fr.byteLength):Buffer$1$1.from(fr);let Struct$4=class{constructor(br){Object.assign(this,br)}encode(){return Buffer$1$1.from(serialize_1(SOLANA_SCHEMA$2,this))}static decode(br){return deserialize_1(SOLANA_SCHEMA$2,this,br)}static decodeUnchecked(br){return deserializeUnchecked_1(SOLANA_SCHEMA$2,this,br)}};const SOLANA_SCHEMA$2=new Map;var _PublicKey$2;const MAX_SEED_LENGTH$2=32,PUBLIC_KEY_LENGTH$2=32;function isPublicKeyData$2(fr){return fr._bn!==void 0}let uniquePublicKeyCounter$2=1,PublicKey$2=class hy extends Struct$4{constructor(br){if(super({}),this._bn=void 0,isPublicKeyData$2(br))this._bn=br._bn;else{if(typeof br=="string"){const wr=bs58$6.decode(br);if(wr.length!=PUBLIC_KEY_LENGTH$2)throw new Error("Invalid public key input");this._bn=new BN$2(wr)}else this._bn=new BN$2(br);if(this._bn.byteLength()>PUBLIC_KEY_LENGTH$2)throw new Error("Invalid public key input")}}static unique(){const br=new hy(uniquePublicKeyCounter$2);return uniquePublicKeyCounter$2+=1,new hy(br.toBuffer())}equals(br){return this._bn.eq(br._bn)}toBase58(){return bs58$6.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const br=this.toBuffer();return new Uint8Array(br.buffer,br.byteOffset,br.byteLength)}toBuffer(){const br=this._bn.toArrayLike(Buffer$1$1);if(br.length===PUBLIC_KEY_LENGTH$2)return br;const wr=Buffer$1$1.alloc(32);return br.copy(wr,32-br.length),wr}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(br,wr,Er){const kr=Buffer$1$1.concat([br.toBuffer(),Buffer$1$1.from(wr),Er.toBuffer()]),jr=sha256$4(kr);return new hy(jr)}static createProgramAddressSync(br,wr){let Er=Buffer$1$1.alloc(0);br.forEach(function(jr){if(jr.length>MAX_SEED_LENGTH$2)throw new TypeError("Max seed length exceeded");Er=Buffer$1$1.concat([Er,toBuffer$2(jr)])}),Er=Buffer$1$1.concat([Er,wr.toBuffer(),Buffer$1$1.from("ProgramDerivedAddress")]);const kr=sha256$4(Er);if(isOnCurve$2(kr))throw new Error("Invalid seeds, address must fall off the curve");return new hy(kr)}static async createProgramAddress(br,wr){return this.createProgramAddressSync(br,wr)}static findProgramAddressSync(br,wr){let Er=255,kr;for(;Er!=0;){try{const jr=br.concat(Buffer$1$1.from([Er]));kr=this.createProgramAddressSync(jr,wr)}catch(jr){if(jr instanceof TypeError)throw jr;Er--;continue}return[kr,Er]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(br,wr){return this.findProgramAddressSync(br,wr)}static isOnCurve(br){const wr=new hy(br);return isOnCurve$2(wr.toBytes())}};_PublicKey$2=PublicKey$2;PublicKey$2.default=new _PublicKey$2("11111111111111111111111111111111");SOLANA_SCHEMA$2.set(PublicKey$2,{kind:"struct",fields:[["_bn","u256"]]});new PublicKey$2("BPFLoader1111111111111111111111111111111111");const PACKET_DATA_SIZE=1232,VERSION_PREFIX_MASK=127,SIGNATURE_LENGTH_IN_BYTES$2=64;class TransactionExpiredBlockheightExceededError extends Error{constructor(br){super(`Signature ${br} has expired: block height exceeded.`),this.signature=void 0,this.signature=br}}Object.defineProperty(TransactionExpiredBlockheightExceededError.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class TransactionExpiredTimeoutError extends Error{constructor(br,wr){super(`Transaction was not confirmed in ${wr.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${br} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=br}}Object.defineProperty(TransactionExpiredTimeoutError.prototype,"name",{value:"TransactionExpiredTimeoutError"});class TransactionExpiredNonceInvalidError extends Error{constructor(br){super(`Signature ${br} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=br}}Object.defineProperty(TransactionExpiredNonceInvalidError.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class MessageAccountKeys{constructor(br,wr){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=br,this.accountKeysFromLookups=wr}keySegments(){const br=[this.staticAccountKeys];return this.accountKeysFromLookups&&(br.push(this.accountKeysFromLookups.writable),br.push(this.accountKeysFromLookups.readonly)),br}get(br){for(const wr of this.keySegments()){if(br256)throw new Error("Account index overflow encountered during compilation");const Er=new Map;this.keySegments().flat().forEach((jr,Br)=>{Er.set(jr.toBase58(),Br)});const kr=jr=>{const Br=Er.get(jr.toBase58());if(Br===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return Br};return br.map(jr=>({programIdIndex:kr(jr.programId),accountKeyIndexes:jr.keys.map(Br=>kr(Br.pubkey)),data:jr.data}))}}const publicKey$3=(fr="publicKey")=>blob(32,fr),signature=(fr="signature")=>blob(64,fr),rustString$2=(fr="string")=>{const br=struct([u32("length"),u32("lengthPadding"),blob(offset(u32(),-8),"chars")],fr),wr=br.decode.bind(br),Er=br.encode.bind(br),kr=br;return kr.decode=(jr,Br)=>wr(jr,Br).chars.toString(),kr.encode=(jr,Br,Wr)=>{const qr={chars:Buffer$1$1.from(jr,"utf8")};return Er(qr,Br,Wr)},kr.alloc=jr=>u32().span+u32().span+Buffer$1$1.from(jr,"utf8").length,kr},authorized$2=(fr="authorized")=>struct([publicKey$3("staker"),publicKey$3("withdrawer")],fr),lockup$2=(fr="lockup")=>struct([ns64("unixTimestamp"),ns64("epoch"),publicKey$3("custodian")],fr),voteInit$2=(fr="voteInit")=>struct([publicKey$3("nodePubkey"),publicKey$3("authorizedVoter"),publicKey$3("authorizedWithdrawer"),u8("commission")],fr),voteAuthorizeWithSeedArgs$2=(fr="voteAuthorizeWithSeedArgs")=>struct([u32("voteAuthorizationType"),publicKey$3("currentAuthorityDerivedKeyOwnerPubkey"),rustString$2("currentAuthorityDerivedKeySeed"),publicKey$3("newAuthorized")],fr);function getAlloc(fr,br){const wr=kr=>{if(kr.span>=0)return kr.span;if(typeof kr.alloc=="function")return kr.alloc(br[kr.property]);if("count"in kr&&"elementLayout"in kr){const jr=br[kr.property];if(Array.isArray(jr))return jr.length*wr(kr.elementLayout)}else if("fields"in kr)return getAlloc({layout:kr},br[kr.property]);return 0};let Er=0;return fr.layout.fields.forEach(kr=>{Er+=wr(kr)}),Er}function decodeLength(fr){let br=0,wr=0;for(;;){let Er=fr.shift();if(br|=(Er&127)<>=7,wr==0){fr.push(Er);break}else Er|=128,fr.push(Er)}}function assert$2(fr,br){if(!fr)throw new Error(br||"Assertion failed")}class CompiledKeys{constructor(br,wr){this.payer=void 0,this.keyMetaMap=void 0,this.payer=br,this.keyMetaMap=wr}static compile(br,wr){const Er=new Map,kr=Br=>{const Wr=Br.toBase58();let qr=Er.get(Wr);return qr===void 0&&(qr={isSigner:!1,isWritable:!1,isInvoked:!1},Er.set(Wr,qr)),qr},jr=kr(wr);jr.isSigner=!0,jr.isWritable=!0;for(const Br of br){kr(Br.programId).isInvoked=!0;for(const Wr of Br.keys){const qr=kr(Wr.pubkey);qr.isSigner||(qr.isSigner=Wr.isSigner),qr.isWritable||(qr.isWritable=Wr.isWritable)}}return new CompiledKeys(wr,Er)}getMessageComponents(){const br=[...this.keyMetaMap.entries()];assert$2(br.length<=256,"Max static account keys length exceeded");const wr=br.filter(([,qr])=>qr.isSigner&&qr.isWritable),Er=br.filter(([,qr])=>qr.isSigner&&!qr.isWritable),kr=br.filter(([,qr])=>!qr.isSigner&&qr.isWritable),jr=br.filter(([,qr])=>!qr.isSigner&&!qr.isWritable),Br={numRequiredSignatures:wr.length+Er.length,numReadonlySignedAccounts:Er.length,numReadonlyUnsignedAccounts:jr.length};{assert$2(wr.length>0,"Expected at least one writable signer key");const[qr]=wr[0];assert$2(qr===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const Wr=[...wr.map(([qr])=>new PublicKey$2(qr)),...Er.map(([qr])=>new PublicKey$2(qr)),...kr.map(([qr])=>new PublicKey$2(qr)),...jr.map(([qr])=>new PublicKey$2(qr))];return[Br,Wr]}extractTableLookup(br){const[wr,Er]=this.drainKeysFoundInLookupTable(br.state.addresses,Br=>!Br.isSigner&&!Br.isInvoked&&Br.isWritable),[kr,jr]=this.drainKeysFoundInLookupTable(br.state.addresses,Br=>!Br.isSigner&&!Br.isInvoked&&!Br.isWritable);if(!(wr.length===0&&kr.length===0))return[{accountKey:br.key,writableIndexes:wr,readonlyIndexes:kr},{writable:Er,readonly:jr}]}drainKeysFoundInLookupTable(br,wr){const Er=new Array,kr=new Array;for(const[jr,Br]of this.keyMetaMap.entries())if(wr(Br)){const Wr=new PublicKey$2(jr),qr=br.findIndex(Hr=>Hr.equals(Wr));qr>=0&&(assert$2(qr<256,"Max lookup table index exceeded"),Er.push(qr),kr.push(Wr),this.keyMetaMap.delete(jr))}return[Er,kr]}}const END_OF_BUFFER_ERROR_MESSAGE="Reached end of buffer unexpectedly";function guardedShift(fr){if(fr.length===0)throw new Error(END_OF_BUFFER_ERROR_MESSAGE);return fr.shift()}function guardedSplice(fr,...br){const[wr]=br;if(br.length===2?wr+(br[1]??0)>fr.length:wr>=fr.length)throw new Error(END_OF_BUFFER_ERROR_MESSAGE);return fr.splice(...br)}class Message{constructor(br){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=br.header,this.accountKeys=br.accountKeys.map(wr=>new PublicKey$2(wr)),this.recentBlockhash=br.recentBlockhash,this.instructions=br.instructions,this.instructions.forEach(wr=>this.indexToProgramIds.set(wr.programIdIndex,this.accountKeys[wr.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(br=>({programIdIndex:br.programIdIndex,accountKeyIndexes:br.accounts,data:bs58$6.decode(br.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new MessageAccountKeys(this.staticAccountKeys)}static compile(br){const wr=CompiledKeys.compile(br.instructions,br.payerKey),[Er,kr]=wr.getMessageComponents(),Br=new MessageAccountKeys(kr).compileInstructions(br.instructions).map(Wr=>({programIdIndex:Wr.programIdIndex,accounts:Wr.accountKeyIndexes,data:bs58$6.encode(Wr.data)}));return new Message({header:Er,accountKeys:kr,recentBlockhash:br.recentBlockhash,instructions:Br})}isAccountSigner(br){return br=this.header.numRequiredSignatures){const Er=br-wr,jr=this.accountKeys.length-wr-this.header.numReadonlyUnsignedAccounts;return Er!this.isProgramId(wr))}serialize(){const br=this.accountKeys.length;let wr=[];encodeLength(wr,br);const Er=this.instructions.map(Zr=>{const{accounts:Jr,programIdIndex:Qr}=Zr,_n=Array.from(bs58$6.decode(Zr.data));let En=[];encodeLength(En,Jr.length);let Cn=[];return encodeLength(Cn,_n.length),{programIdIndex:Qr,keyIndicesCount:Buffer$1$1.from(En),keyIndices:Jr,dataLength:Buffer$1$1.from(Cn),data:_n}});let kr=[];encodeLength(kr,Er.length);let jr=Buffer$1$1.alloc(PACKET_DATA_SIZE);Buffer$1$1.from(kr).copy(jr);let Br=kr.length;Er.forEach(Zr=>{const Qr=struct([u8("programIdIndex"),blob(Zr.keyIndicesCount.length,"keyIndicesCount"),seq(u8("keyIndex"),Zr.keyIndices.length,"keyIndices"),blob(Zr.dataLength.length,"dataLength"),seq(u8("userdatum"),Zr.data.length,"data")]).encode(Zr,jr,Br);Br+=Qr}),jr=jr.slice(0,Br);const Wr=struct([blob(1,"numRequiredSignatures"),blob(1,"numReadonlySignedAccounts"),blob(1,"numReadonlyUnsignedAccounts"),blob(wr.length,"keyCount"),seq(publicKey$3("key"),br,"keys"),publicKey$3("recentBlockhash")]),qr={numRequiredSignatures:Buffer$1$1.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Buffer$1$1.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Buffer$1$1.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Buffer$1$1.from(wr),keys:this.accountKeys.map(Zr=>toBuffer$2(Zr.toBytes())),recentBlockhash:bs58$6.decode(this.recentBlockhash)};let Hr=Buffer$1$1.alloc(2048);const Vr=Wr.encode(qr,Hr);return jr.copy(Hr,Vr),Hr.slice(0,Vr+jr.length)}static from(br){let wr=[...br];const Er=guardedShift(wr);if(Er!==(Er&VERSION_PREFIX_MASK))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const kr=guardedShift(wr),jr=guardedShift(wr),Br=decodeLength(wr);let Wr=[];for(let Jr=0;Jr0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new MessageAccountKeys(this.staticAccountKeys,wr)}isAccountSigner(br){return br=Er){const kr=br-Er,jr=this.addressTableLookups.reduce((Br,Wr)=>Br+Wr.writableIndexes.length,0);return kr=this.header.numRequiredSignatures){const kr=br-wr,Br=Er-wr-this.header.numReadonlyUnsignedAccounts;return krjr.key.equals(Er.accountKey));if(!kr)throw new Error(`Failed to find address lookup table account for table key ${Er.accountKey.toBase58()}`);for(const jr of Er.writableIndexes)if(jrVr.toBytes()),recentBlockhash:bs58$6.decode(this.recentBlockhash),instructionsLength:new Uint8Array(Er),serializedInstructions:wr,addressTableLookupsLength:new Uint8Array(jr),serializedAddressTableLookups:kr},Wr);return Wr.slice(0,Hr)}serializeInstructions(){let br=0;const wr=new Uint8Array(PACKET_DATA_SIZE);for(const Er of this.compiledInstructions){const kr=Array();encodeLength(kr,Er.accountKeyIndexes.length);const jr=Array();encodeLength(jr,Er.data.length);const Br=struct([u8("programIdIndex"),blob(kr.length,"encodedAccountKeyIndexesLength"),seq(u8(),Er.accountKeyIndexes.length,"accountKeyIndexes"),blob(jr.length,"encodedDataLength"),blob(Er.data.length,"data")]);br+=Br.encode({programIdIndex:Er.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(kr),accountKeyIndexes:Er.accountKeyIndexes,encodedDataLength:new Uint8Array(jr),data:Er.data},wr,br)}return wr.slice(0,br)}serializeAddressTableLookups(){let br=0;const wr=new Uint8Array(PACKET_DATA_SIZE);for(const Er of this.addressTableLookups){const kr=Array();encodeLength(kr,Er.writableIndexes.length);const jr=Array();encodeLength(jr,Er.readonlyIndexes.length);const Br=struct([publicKey$3("accountKey"),blob(kr.length,"encodedWritableIndexesLength"),seq(u8(),Er.writableIndexes.length,"writableIndexes"),blob(jr.length,"encodedReadonlyIndexesLength"),seq(u8(),Er.readonlyIndexes.length,"readonlyIndexes")]);br+=Br.encode({accountKey:Er.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(kr),writableIndexes:Er.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(jr),readonlyIndexes:Er.readonlyIndexes},wr,br)}return wr.slice(0,br)}static deserialize(br){let wr=[...br];const Er=guardedShift(wr),kr=Er&VERSION_PREFIX_MASK;assert$2(Er!==kr,"Expected versioned message but received legacy message");const jr=kr;assert$2(jr===0,`Expected versioned message with version 0 but found version ${jr}`);const Br={numRequiredSignatures:guardedShift(wr),numReadonlySignedAccounts:guardedShift(wr),numReadonlyUnsignedAccounts:guardedShift(wr)},Wr=[],qr=decodeLength(wr);for(let _n=0;_n{const br=VersionedMessage.deserializeMessageVersion(fr);if(br==="legacy")return Message.from(fr);if(br===0)return MessageV0.deserialize(fr);throw new Error(`Transaction message version ${br} deserialization is not supported`)}};let TransactionStatus=function(fr){return fr[fr.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",fr[fr.PROCESSED=1]="PROCESSED",fr[fr.TIMED_OUT=2]="TIMED_OUT",fr[fr.NONCE_INVALID=3]="NONCE_INVALID",fr}({});const DEFAULT_SIGNATURE=Buffer$1$1.alloc(SIGNATURE_LENGTH_IN_BYTES$2).fill(0);class TransactionInstruction{constructor(br){this.keys=void 0,this.programId=void 0,this.data=Buffer$1$1.alloc(0),this.programId=br.programId,this.keys=br.keys,br.data&&(this.data=br.data)}toJSON(){return{keys:this.keys.map(({pubkey:br,isSigner:wr,isWritable:Er})=>({pubkey:br.toJSON(),isSigner:wr,isWritable:Er})),programId:this.programId.toJSON(),data:[...this.data]}}}class Transaction{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(br){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!br)if(br.feePayer&&(this.feePayer=br.feePayer),br.signatures&&(this.signatures=br.signatures),Object.prototype.hasOwnProperty.call(br,"nonceInfo")){const{minContextSlot:wr,nonceInfo:Er}=br;this.minNonceContextSlot=wr,this.nonceInfo=Er}else if(Object.prototype.hasOwnProperty.call(br,"lastValidBlockHeight")){const{blockhash:wr,lastValidBlockHeight:Er}=br;this.recentBlockhash=wr,this.lastValidBlockHeight=Er}else{const{recentBlockhash:wr,nonceInfo:Er}=br;Er&&(this.nonceInfo=Er),this.recentBlockhash=wr}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(br=>br.toJSON()),signers:this.signatures.map(({publicKey:br})=>br.toJSON())}}add(...br){if(br.length===0)throw new Error("No instructions");return br.forEach(wr=>{"instructions"in wr?this.instructions=this.instructions.concat(wr.instructions):"data"in wr&&"programId"in wr&&"keys"in wr?this.instructions.push(wr):this.instructions.push(new TransactionInstruction(wr))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let br,wr;if(this.nonceInfo?(br=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?wr=[this.nonceInfo.nonceInstruction,...this.instructions]:wr=this.instructions):(br=this.recentBlockhash,wr=this.instructions),!br)throw new Error("Transaction recentBlockhash required");wr.length<1&&console.warn("No instructions provided");let Er;if(this.feePayer)Er=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)Er=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let En=0;En{En.keys.forEach(In=>{jr.push({...In})});const Cn=En.programId.toString();kr.includes(Cn)||kr.push(Cn)}),kr.forEach(En=>{jr.push({pubkey:new PublicKey$2(En),isSigner:!1,isWritable:!1})});const Br=[];jr.forEach(En=>{const Cn=En.pubkey.toString(),In=Br.findIndex(An=>An.pubkey.toString()===Cn);In>-1?(Br[In].isWritable=Br[In].isWritable||En.isWritable,Br[In].isSigner=Br[In].isSigner||En.isSigner):Br.push(En)}),Br.sort(function(En,Cn){if(En.isSigner!==Cn.isSigner)return En.isSigner?-1:1;if(En.isWritable!==Cn.isWritable)return En.isWritable?-1:1;const In={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return En.pubkey.toBase58().localeCompare(Cn.pubkey.toBase58(),"en",In)});const Wr=Br.findIndex(En=>En.pubkey.equals(Er));if(Wr>-1){const[En]=Br.splice(Wr,1);En.isSigner=!0,En.isWritable=!0,Br.unshift(En)}else Br.unshift({pubkey:Er,isSigner:!0,isWritable:!0});for(const En of this.signatures){const Cn=Br.findIndex(In=>In.pubkey.equals(En.publicKey));if(Cn>-1)Br[Cn].isSigner||(Br[Cn].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${En.publicKey.toString()}`)}let qr=0,Hr=0,Vr=0;const Zr=[],Jr=[];Br.forEach(({pubkey:En,isSigner:Cn,isWritable:In})=>{Cn?(Zr.push(En.toString()),qr+=1,In||(Hr+=1)):(Jr.push(En.toString()),In||(Vr+=1))});const Qr=Zr.concat(Jr),_n=wr.map(En=>{const{data:Cn,programId:In}=En;return{programIdIndex:Qr.indexOf(In.toString()),accounts:En.keys.map(An=>Qr.indexOf(An.pubkey.toString())),data:bs58$6.encode(Cn)}});return _n.forEach(En=>{assert$2(En.programIdIndex>=0),En.accounts.forEach(Cn=>assert$2(Cn>=0))}),new Message({header:{numRequiredSignatures:qr,numReadonlySignedAccounts:Hr,numReadonlyUnsignedAccounts:Vr},accountKeys:Qr,recentBlockhash:br,instructions:_n})}_compile(){const br=this.compileMessage(),wr=br.accountKeys.slice(0,br.header.numRequiredSignatures);return this.signatures.length===wr.length&&this.signatures.every((kr,jr)=>wr[jr].equals(kr.publicKey))||(this.signatures=wr.map(Er=>({signature:null,publicKey:Er}))),br}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(br){return(await br.getFeeForMessage(this.compileMessage())).value}setSigners(...br){if(br.length===0)throw new Error("No signers");const wr=new Set;this.signatures=br.filter(Er=>{const kr=Er.toString();return wr.has(kr)?!1:(wr.add(kr),!0)}).map(Er=>({signature:null,publicKey:Er}))}sign(...br){if(br.length===0)throw new Error("No signers");const wr=new Set,Er=[];for(const jr of br){const Br=jr.publicKey.toString();wr.has(Br)||(wr.add(Br),Er.push(jr))}this.signatures=Er.map(jr=>({signature:null,publicKey:jr.publicKey}));const kr=this._compile();this._partialSign(kr,...Er)}partialSign(...br){if(br.length===0)throw new Error("No signers");const wr=new Set,Er=[];for(const jr of br){const Br=jr.publicKey.toString();wr.has(Br)||(wr.add(Br),Er.push(jr))}const kr=this._compile();this._partialSign(kr,...Er)}_partialSign(br,...wr){const Er=br.serialize();wr.forEach(kr=>{const jr=sign(Er,kr.secretKey);this._addSignature(kr.publicKey,toBuffer$2(jr))})}addSignature(br,wr){this._compile(),this._addSignature(br,wr)}_addSignature(br,wr){assert$2(wr.length===64);const Er=this.signatures.findIndex(kr=>br.equals(kr.publicKey));if(Er<0)throw new Error(`unknown signer: ${br.toString()}`);this.signatures[Er].signature=Buffer$1$1.from(wr)}verifySignatures(br=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),br)}_getMessageSignednessErrors(br,wr){const Er={};for(const{signature:kr,publicKey:jr}of this.signatures)kr===null?wr&&(Er.missing||(Er.missing=[])).push(jr):verify(kr,br,jr.toBytes())||(Er.invalid||(Er.invalid=[])).push(jr);return Er.invalid||Er.missing?Er:void 0}serialize(br){const{requireAllSignatures:wr,verifySignatures:Er}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},br),kr=this.serializeMessage();if(Er){const jr=this._getMessageSignednessErrors(kr,wr);if(jr){let Br="Signature verification failed.";throw jr.invalid&&(Br+=` +}`;var Su=$x(function(){return Mu($o,eu+"return "+Rl).apply(wr,To)});if(Su.source=Rl,Q1(Su))throw Su;return Su}function h$(Yr){return Ou(Yr).toLowerCase()}function p$(Yr){return Ou(Yr).toUpperCase()}function m$(Yr,$n,Yn){if(Yr=Ou(Yr),Yr&&(Yn||$n===wr))return wy(Yr);if(!Yr||!($n=Ip($n)))return Yr;var ao=qp(Yr),ho=qp($n),$o=_y(ao,ho),To=Ey(ao,ho)+1;return mm(ao,$o,To).join("")}function g$(Yr,$n,Yn){if(Yr=Ou(Yr),Yr&&(Yn||$n===wr))return Yr.slice(0,Sy(Yr)+1);if(!Yr||!($n=Ip($n)))return Yr;var ao=qp(Yr),ho=Ey(ao,qp($n))+1;return mm(ao,0,ho).join("")}function y$(Yr,$n,Yn){if(Yr=Ou(Yr),Yr&&(Yn||$n===wr))return Yr.replace(So,"");if(!Yr||!($n=Ip($n)))return Yr;var ao=qp(Yr),ho=_y(ao,qp($n));return mm(ao,ho).join("")}function v$(Yr,$n){var Yn=co,ao=so;if(_f($n)){var ho="separator"in $n?$n.separator:ho;Yn="length"in $n?$u($n.length):Yn,ao="omission"in $n?Ip($n.omission):ao}Yr=Ou(Yr);var $o=Yr.length;if(Am(Yr)){var To=qp(Yr);$o=To.length}if(Yn>=$o)return Yr;var Po=Yn-Pm(ao);if(Po<1)return ao;var Oo=To?mm(To,0,Po).join(""):Yr.slice(0,Po);if(ho===wr)return Oo+ao;if(To&&(Po+=Oo.length-Po),ey(ho)){if(Yr.slice(Po).search(ho)){var _c,yl=Oo;for(ho.global||(ho=p1(ho.source,Ou($l.exec(ho))+"g")),ho.lastIndex=0;_c=ho.exec(yl);)var Rl=_c.index;Oo=Oo.slice(0,Rl===wr?Po:Rl)}}else if(Yr.indexOf(Ip(ho),Po)!=Po){var Hl=Oo.lastIndexOf(ho);Hl>-1&&(Oo=Oo.slice(0,Hl))}return Oo+ao}function b$(Yr){return Yr=Ou(Yr),Yr&&du.test(Yr)?Yr.replace(xl,Hx):Yr}var x$=Lm(function(Yr,$n,Yn){return Yr+(Yn?" ":"")+$n.toUpperCase()}),ny=Sv("toUpperCase");function Ex(Yr,$n,Yn){return Yr=Ou(Yr),$n=Yn?wr:$n,$n===wr?Ux(Yr)?Zx(Yr):Px(Yr):Yr.match($n)||[]}var $x=ku(function(Yr,$n){try{return mp(Yr,wr,$n)}catch(Yn){return Q1(Yn)?Yn:new xu(Yn)}}),w$=tm(function(Yr,$n){return Mp($n,function(Yn){Yn=Jp(Yn),Qp(Yr,Yn,Y1(Yr[Yn],Yr))}),Yr});function _$(Yr){var $n=Yr==null?0:Yr.length,Yn=cu();return Yr=$n?Gu(Yr,function(ao){if(typeof ao[1]!="function")throw new Op(Br);return[Yn(ao[0]),ao[1]]}):[],ku(function(ao){for(var ho=-1;++ho<$n;){var $o=Yr[ho];if(mp($o[0],this,ao))return mp($o[1],this,ao)}})}function E$(Yr){return Hw(Bp(Yr,Zr))}function iy(Yr){return function(){return Yr}}function $$(Yr,$n){return Yr==null||Yr!==Yr?$n:Yr}var S$=Cv(),k$=Cv(!0);function kp(Yr){return Yr}function oy(Yr){return Vy(typeof Yr=="function"?Yr:Bp(Yr,Zr))}function C$(Yr){return Ky(Bp(Yr,Zr))}function R$(Yr,$n){return Gy(Yr,Bp($n,Zr))}var T$=ku(function(Yr,$n){return function(Yn){return Qm(Yn,Yr,$n)}}),I$=ku(function(Yr,$n){return function(Yn){return Qm(Yr,Yn,$n)}});function ay(Yr,$n,Yn){var ao=sp($n),ho=M0($n,ao);Yn==null&&!(_f($n)&&(ho.length||!ao.length))&&(Yn=$n,$n=Yr,Yr=this,ho=M0($n,sp($n)));var $o=!(_f(Yn)&&"chain"in Yn)||!!Yn.chain,To=nm(Yr);return Mp(ho,function(Po){var Oo=$n[Po];Yr[Po]=Oo,To&&(Yr.prototype[Po]=function(){var _c=this.__chain__;if($o||_c){var yl=Yr(this.__wrapped__),Rl=yl.__actions__=Ep(this.__actions__);return Rl.push({func:Oo,args:arguments,thisArg:Yr}),yl.__chain__=_c,yl}return Oo.apply(Yr,lm([this.value()],arguments))})}),Yr}function A$(){return Hu._===this&&(Hu._=tw),this}function sy(){}function P$(Yr){return Yr=$u(Yr),ku(function($n){return Zy($n,Yr)})}var N$=D1(Gu),M$=D1(gy),O$=D1(s1);function Sx(Yr){return V1(Yr)?c1(Jp(Yr)):l_(Yr)}function j$(Yr){return function($n){return Yr==null?wr:Em(Yr,$n)}}var B$=Tv(),D$=Tv(!0);function cy(){return[]}function ly(){return!1}function L$(){return{}}function F$(){return""}function U$(){return!0}function W$(Yr,$n){if(Yr=$u(Yr),Yr<1||Yr>Pn)return[];var Yn=Nn,ao=hp(Yr,Nn);$n=cu($n),Yr-=Nn;for(var ho=d1(ao,$n);++Yn0||$n<0)?new Iu(Yn):(Yr<0?Yn=Yn.takeRight(-Yr):Yr&&(Yn=Yn.drop(Yr)),$n!==wr&&($n=$u($n),Yn=$n<0?Yn.dropRight(-$n):Yn.take($n-Yr)),Yn)},Iu.prototype.takeRightWhile=function(Yr){return this.reverse().takeWhile(Yr).reverse()},Iu.prototype.toArray=function(){return this.take(Nn)},Gp(Iu.prototype,function(Yr,$n){var Yn=/^(?:filter|find|map|reject)|While$/.test($n),ao=/^(?:head|last)$/.test($n),ho=xo[ao?"take"+($n=="last"?"Right":""):$n],$o=ao||/^find/.test($n);ho&&(xo.prototype[$n]=function(){var To=this.__wrapped__,Po=ao?[1]:arguments,Oo=To instanceof Iu,_c=Po[0],yl=Oo||wu(To),Rl=function(Ru){var Pu=ho.apply(xo,lm([Ru],Po));return ao&&Hl?Pu[0]:Pu};yl&&Yn&&typeof _c=="function"&&_c.length!=1&&(Oo=yl=!1);var Hl=this.__chain__,eu=!!this.__actions__.length,lu=$o&&!Hl,Su=Oo&&!eu;if(!$o&&yl){To=Su?To:new Iu(this);var uu=Yr.apply(To,Po);return uu.__actions__.push({func:H0,args:[Rl],thisArg:wr}),new jp(uu,Hl)}return lu&&Su?Yr.apply(this,Po):(uu=this.thru(Rl),lu?ao?uu.value()[0]:uu.value():uu)})}),Mp(["pop","push","shift","sort","splice","unshift"],function(Yr){var $n=v0[Yr],Yn=/^(?:push|sort|unshift)$/.test(Yr)?"tap":"thru",ao=/^(?:pop|shift)$/.test(Yr);xo.prototype[Yr]=function(){var ho=arguments;if(ao&&!this.__chain__){var $o=this.value();return $n.apply(wu($o)?$o:[],ho)}return this[Yn](function(To){return $n.apply(wu(To)?To:[],ho)})}}),Gp(Iu.prototype,function(Yr,$n){var Yn=xo[$n];if(Yn){var ao=Yn.name+"";ju.call(jm,ao)||(jm[ao]=[]),jm[ao].push({name:$n,func:Yn})}}),jm[L0(wr,In).name]=[{name:"wrapper",func:wr}],Iu.prototype.clone=yw,Iu.prototype.reverse=vw,Iu.prototype.value=bw,xo.prototype.at=G2,xo.prototype.chain=Z2,xo.prototype.commit=J2,xo.prototype.next=Y2,xo.prototype.plant=Q2,xo.prototype.reverse=eE,xo.prototype.toJSON=xo.prototype.valueOf=xo.prototype.value=tE,xo.prototype.first=xo.prototype.head,Hm&&(xo.prototype[Hm]=X2),xo},Nm=Jx();_p?((_p.exports=Nm)._=Nm,gp._=Nm):Hu._=Nm}).call(ge)})(Ui,Ui.exports);var Gg=Object.defineProperty,zg=Object.defineProperties,Kg=Object.getOwnPropertyDescriptors,Ea=Object.getOwnPropertySymbols,Yg=Object.prototype.hasOwnProperty,Zg=Object.prototype.propertyIsEnumerable,ya=(fr,br,wr)=>br in fr?Gg(fr,br,{enumerable:!0,configurable:!0,writable:!0,value:wr}):fr[br]=wr,cr=(fr,br)=>{for(var wr in br||(br={}))Yg.call(br,wr)&&ya(fr,wr,br[wr]);if(Ea)for(var wr of Ea(br))Zg.call(br,wr)&&ya(fr,wr,br[wr]);return fr},Jg=(fr,br)=>zg(fr,Kg(br));function ft(fr,br,wr){var Er;const kr=ve(fr);return((Er=br.rpcMap)==null?void 0:Er[kr.reference])||`${Bg}?chainId=${kr.namespace}:${kr.reference}&projectId=${wr}`}function Ct(fr){return fr.includes(":")?fr.split(":")[1]:fr}function Sa(fr){return fr.map(br=>`${br.split(":")[0]}:${br.split(":")[1]}`)}function Xg(fr,br){const wr=Object.keys(br.namespaces).filter(kr=>kr.includes(fr));if(!wr.length)return[];const Er=[];return wr.forEach(kr=>{const jr=br.namespaces[kr].accounts;Er.push(...jr)}),Er}function Oa(fr={},br={}){const wr=Ra(fr),Er=Ra(br);return Ui.exports.merge(wr,Er)}function Ra(fr){var br,wr,Er,kr;const jr={};if(!B$2(fr))return jr;for(const[Br,Wr]of Object.entries(fr)){const qr=oe(Br)?[Br]:Wr.chains,Hr=Wr.methods||[],Vr=Wr.events||[],Zr=Wr.rpcMap||{},Jr=en(Br);jr[Jr]=Jg(cr(cr({},jr[Jr]),Wr),{chains:S$2(qr,(br=jr[Jr])==null?void 0:br.chains),methods:S$2(Hr,(wr=jr[Jr])==null?void 0:wr.methods),events:S$2(Vr,(Er=jr[Jr])==null?void 0:Er.events),rpcMap:cr(cr({},Zr),(kr=jr[Jr])==null?void 0:kr.rpcMap)})}return jr}function Qg(fr){return fr.includes(":")?fr.split(":")[2]:fr}function Vg(fr){const br={};for(const[wr,Er]of Object.entries(fr)){const kr=Er.methods||[],jr=Er.events||[],Br=Er.accounts||[],Wr=oe(wr)?[wr]:Er.chains?Er.chains:Sa(Er.accounts);br[wr]={chains:Wr,methods:kr,events:jr,accounts:Br}}return br}function Wi(fr){return typeof fr=="number"?fr:fr.includes("0x")?parseInt(fr,16):(fr=fr.includes(":")?fr.split(":")[1]:fr,isNaN(Number(fr))?fr:Number(fr))}const ba={},z$2=fr=>ba[fr],Fi=(fr,br)=>{ba[fr]=br};class kg{constructor(br){this.name="polkadot",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}request(br){return this.namespace.methods.includes(br.request.method)?this.client.request(br):this.getHttpProvider().request(br.request)}setDefaultChain(br,wr){this.httpProviders[br]||this.setHttpProvider(br,wr),this.chainId=br,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${br}`)}getAccounts(){const br=this.namespace.accounts;return br?br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2])||[]:[]}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{var Er;const kr=Ct(wr);br[kr]=this.createHttpProvider(kr,(Er=this.namespace.rpcMap)==null?void 0:Er[wr])}),br}getHttpProvider(){const br=`${this.name}:${this.chainId}`,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProvider(br,wr){const Er=wr||ft(br,this.namespace,this.client.core.projectId);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);return new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}}class jg{constructor(br){this.name="eip155",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(br){switch(br.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(br);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(br.request.method)?await this.client.request(br):this.getHttpProvider().request(br.request)}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}setDefaultChain(br,wr){this.httpProviders[br]||this.setHttpProvider(parseInt(br),wr),this.chainId=parseInt(br),this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${br}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}createHttpProvider(br,wr){const Er=wr||ft(`${this.name}:${br}`,this.namespace,this.client.core.projectId);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);return new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{var Er;const kr=parseInt(Ct(wr));br[kr]=this.createHttpProvider(kr,(Er=this.namespace.rpcMap)==null?void 0:Er[wr])}),br}getAccounts(){const br=this.namespace.accounts;return br?[...new Set(br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2]))]:[]}getHttpProvider(){const br=this.chainId,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}async handleSwitchChain(br){var wr,Er;let kr=br.request.params?(wr=br.request.params[0])==null?void 0:wr.chainId:"0x0";kr=kr.startsWith("0x")?kr:`0x${kr}`;const jr=parseInt(kr,16);if(this.isChainApproved(jr))this.setDefaultChain(`${jr}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:br.topic,request:{method:br.request.method,params:[{chainId:kr}]},chainId:(Er=this.namespace.chains)==null?void 0:Er[0]}),this.setDefaultChain(`${jr}`);else throw new Error(`Failed to switch to chain 'eip155:${jr}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(br){return this.namespace.chains.includes(`${this.name}:${br}`)}}class nv{constructor(br){this.name="solana",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}requestAccounts(){return this.getAccounts()}request(br){return this.namespace.methods.includes(br.request.method)?this.client.request(br):this.getHttpProvider().request(br.request)}setDefaultChain(br,wr){this.httpProviders[br]||this.setHttpProvider(br,wr),this.chainId=br,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${br}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}getAccounts(){const br=this.namespace.accounts;return br?[...new Set(br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2]))]:[]}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{var Er;const kr=Ct(wr);br[kr]=this.createHttpProvider(kr,(Er=this.namespace.rpcMap)==null?void 0:Er[wr])}),br}getHttpProvider(){const br=`${this.name}:${this.chainId}`,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProvider(br,wr){const Er=wr||ft(br,this.namespace,this.client.core.projectId);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);return new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}}class tv{constructor(br){this.name="cosmos",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}request(br){return this.namespace.methods.includes(br.request.method)?this.client.request(br):this.getHttpProvider().request(br.request)}setDefaultChain(br,wr){this.httpProviders[br]||this.setHttpProvider(br,wr),this.chainId=br,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const br=this.namespace.accounts;return br?[...new Set(br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2]))]:[]}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{var Er;const kr=Ct(wr);br[kr]=this.createHttpProvider(kr,(Er=this.namespace.rpcMap)==null?void 0:Er[wr])}),br}getHttpProvider(){const br=`${this.name}:${this.chainId}`,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProvider(br,wr){const Er=wr||ft(br,this.namespace,this.client.core.projectId);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);return new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}}class ev{constructor(br){this.name="cip34",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}request(br){return this.namespace.methods.includes(br.request.method)?this.client.request(br):this.getHttpProvider().request(br.request)}setDefaultChain(br,wr){this.httpProviders[br]||this.setHttpProvider(br,wr),this.chainId=br,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const br=this.namespace.accounts;return br?[...new Set(br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2]))]:[]}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{const Er=this.getCardanoRPCUrl(wr),kr=Ct(wr);br[kr]=this.createHttpProvider(kr,Er)}),br}getHttpProvider(){const br=`${this.name}:${this.chainId}`,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}getCardanoRPCUrl(br){const wr=this.namespace.rpcMap;if(wr)return wr[br]}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProvider(br,wr){const Er=wr||this.getCardanoRPCUrl(br);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);return new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}}class rv{constructor(br){this.name="elrond",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}requestAccounts(){return this.getAccounts()}request(br){return this.namespace.methods.includes(br.request.method)?this.client.request(br):this.getHttpProvider().request(br.request)}setDefaultChain(br,wr){this.httpProviders[br]||this.setHttpProvider(br,wr),this.chainId=br,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${br}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}getAccounts(){const br=this.namespace.accounts;return br?[...new Set(br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2]))]:[]}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{var Er;const kr=Ct(wr);br[kr]=this.createHttpProvider(kr,(Er=this.namespace.rpcMap)==null?void 0:Er[wr])}),br}getHttpProvider(){const br=`${this.name}:${this.chainId}`,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProvider(br,wr){const Er=wr||ft(br,this.namespace,this.client.core.projectId);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);return new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}}class iv{constructor(br){this.name="multiversx",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}requestAccounts(){return this.getAccounts()}request(br){return this.namespace.methods.includes(br.request.method)?this.client.request(br):this.getHttpProvider().request(br.request)}setDefaultChain(br,wr){this.httpProviders[br]||this.setHttpProvider(br,wr),this.chainId=br,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${br}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}getAccounts(){const br=this.namespace.accounts;return br?[...new Set(br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2]))]:[]}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{var Er;const kr=Ct(wr);br[kr]=this.createHttpProvider(kr,(Er=this.namespace.rpcMap)==null?void 0:Er[wr])}),br}getHttpProvider(){const br=`${this.name}:${this.chainId}`,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProvider(br,wr){const Er=wr||ft(br,this.namespace,this.client.core.projectId);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);return new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}}class sv{constructor(br){this.name="near",this.namespace=br.namespace,this.events=z$2("events"),this.client=z$2("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(br){this.namespace=Object.assign(this.namespace,br)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const br=this.namespace.chains[0];if(!br)throw new Error("ChainId not found");return br.split(":")[1]}request(br){return this.namespace.methods.includes(br.request.method)?this.client.request(br):this.getHttpProvider().request(br.request)}setDefaultChain(br,wr){if(this.chainId=br,!this.httpProviders[br]){const Er=wr||ft(`${this.name}:${br}`,this.namespace);if(!Er)throw new Error(`No RPC url provided for chainId: ${br}`);this.setHttpProvider(br,Er)}this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const br=this.namespace.accounts;return br?br.filter(wr=>wr.split(":")[1]===this.chainId.toString()).map(wr=>wr.split(":")[2])||[]:[]}createHttpProviders(){const br={};return this.namespace.chains.forEach(wr=>{var Er;br[wr]=this.createHttpProvider(wr,(Er=this.namespace.rpcMap)==null?void 0:Er[wr])}),br}getHttpProvider(){const br=`${this.name}:${this.chainId}`,wr=this.httpProviders[br];if(typeof wr>"u")throw new Error(`JSON-RPC provider for ${br} not found`);return wr}setHttpProvider(br,wr){const Er=this.createHttpProvider(br,wr);Er&&(this.httpProviders[br]=Er)}createHttpProvider(br,wr){const Er=wr||ft(br,this.namespace);return typeof Er>"u"?void 0:new JsonRpcProvider(new f$4(Er,z$2("disableProviderPing")))}}var uv=Object.defineProperty,av=Object.defineProperties,ov=Object.getOwnPropertyDescriptors,Ta=Object.getOwnPropertySymbols,fv=Object.prototype.hasOwnProperty,cv=Object.prototype.propertyIsEnumerable,La=(fr,br,wr)=>br in fr?uv(fr,br,{enumerable:!0,configurable:!0,writable:!0,value:wr}):fr[br]=wr,hr=(fr,br)=>{for(var wr in br||(br={}))fv.call(br,wr)&&La(fr,wr,br[wr]);if(Ta)for(var wr of Ta(br))cv.call(br,wr)&&La(fr,wr,br[wr]);return fr},Mi=(fr,br)=>av(fr,ov(br));class lr{constructor(br){this.events=new Ug,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=br,this.logger=typeof(br==null?void 0:br.logger)<"u"&&typeof(br==null?void 0:br.logger)!="string"?br.logger:Hg(k$4({level:(br==null?void 0:br.logger)||Ia})),this.disableProviderPing=(br==null?void 0:br.disableProviderPing)||!1}static async init(br){const wr=new lr(br);return await wr.initialize(),wr}async request(br,wr,Er){const[kr,jr]=this.validateChain(wr);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(kr).request({request:hr({},br),chainId:`${kr}:${jr}`,topic:this.session.topic,expiry:Er})}sendAsync(br,wr,Er,kr){const jr=new Date().getTime();this.request(br,Er,kr).then(Br=>wr(null,formatJsonRpcResult(jr,Br))).catch(Br=>wr(Br,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var br;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(br=this.session)==null?void 0:br.topic,reason:U$1("USER_DISCONNECTED")}),await this.cleanup()}async connect(br){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(br),await this.cleanupPendingPairings(),!br.skipPairing)return await this.pair(br.pairingTopic)}on(br,wr){this.events.on(br,wr)}once(br,wr){this.events.once(br,wr)}removeListener(br,wr){this.events.removeListener(br,wr)}off(br,wr){this.events.off(br,wr)}get isWalletConnect(){return!0}async pair(br){this.shouldAbortPairingAttempt=!1;let wr=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(wr>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:Er,approval:kr}=await this.client.connect({pairingTopic:br,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});Er&&(this.uri=Er,this.events.emit("display_uri",Er)),await kr().then(jr=>{this.session=jr;const Br=Vg(jr.namespaces);this.namespaces=Oa(this.namespaces,Br),this.persist("namespaces",this.namespaces)}).catch(jr=>{if(jr.message!==ae)throw jr;wr++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(br,wr){try{if(!this.session)return;const[Er,kr]=this.validateChain(br);this.getProvider(Er).setDefaultChain(kr,wr)}catch(Er){if(!/Please call connect/.test(Er.message))throw Er}}async cleanupPendingPairings(br={}){this.logger.info("Cleaning up inactive pairings...");const wr=this.client.pairing.getAll();if(k$2(wr)){for(const Er of wr)br.deletePairings?this.client.core.expirer.set(Er.topic,0):await this.client.core.relayer.subscriber.unsubscribe(Er.topic);this.logger.info(`Inactive pairings cleared: ${wr.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const br=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[br]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await Q$1.init({logger:this.providerOpts.logger||Ia,relayUrl:this.providerOpts.relayUrl||Fg,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const br=[...new Set(Object.keys(this.session.namespaces).map(wr=>en(wr)))];Fi("client",this.client),Fi("events",this.events),Fi("disableProviderPing",this.disableProviderPing),br.forEach(wr=>{if(!this.session)return;const Er=Xg(wr,this.session),kr=Sa(Er),jr=Oa(this.namespaces,this.optionalNamespaces),Br=Mi(hr({},jr[wr]),{accounts:Er,chains:kr});switch(wr){case"eip155":this.rpcProviders[wr]=new jg({namespace:Br});break;case"solana":this.rpcProviders[wr]=new nv({namespace:Br});break;case"cosmos":this.rpcProviders[wr]=new tv({namespace:Br});break;case"polkadot":this.rpcProviders[wr]=new kg({namespace:Br});break;case"cip34":this.rpcProviders[wr]=new ev({namespace:Br});break;case"elrond":this.rpcProviders[wr]=new rv({namespace:Br});break;case"multiversx":this.rpcProviders[wr]=new iv({namespace:Br});break;case"near":this.rpcProviders[wr]=new sv({namespace:Br});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",br=>{this.events.emit("session_ping",br)}),this.client.on("session_event",br=>{const{params:wr}=br,{event:Er}=wr;if(Er.name==="accountsChanged"){const kr=Er.data;kr&&k$2(kr)&&this.events.emit("accountsChanged",kr.map(Qg))}else if(Er.name==="chainChanged"){const kr=wr.chainId,jr=wr.event.data,Br=en(kr),Wr=Wi(kr)!==Wi(jr)?`${Br}:${Wi(jr)}`:kr;this.onChainChanged(Wr)}else this.events.emit(Er.name,Er.data);this.events.emit("session_event",br)}),this.client.on("session_update",({topic:br,params:wr})=>{var Er;const{namespaces:kr}=wr,jr=(Er=this.client)==null?void 0:Er.session.get(br);this.session=Mi(hr({},jr),{namespaces:kr}),this.onSessionUpdate(),this.events.emit("session_update",{topic:br,params:wr})}),this.client.on("session_delete",async br=>{await this.cleanup(),this.events.emit("session_delete",br),this.events.emit("disconnect",Mi(hr({},U$1("USER_DISCONNECTED")),{data:br.topic}))}),this.on(Vn.DEFAULT_CHAIN_CHANGED,br=>{this.onChainChanged(br,!0)})}getProvider(br){if(!this.rpcProviders[br])throw new Error(`Provider not found: ${br}`);return this.rpcProviders[br]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(br=>{var wr;this.getProvider(br).updateNamespace((wr=this.session)==null?void 0:wr.namespaces[br])})}setNamespaces(br){const{namespaces:wr,optionalNamespaces:Er,sessionProperties:kr}=br;wr&&Object.keys(wr).length&&(this.namespaces=wr),Er&&Object.keys(Er).length&&(this.optionalNamespaces=Er),this.sessionProperties=kr,this.persist("namespaces",wr),this.persist("optionalNamespaces",Er)}validateChain(br){const[wr,Er]=(br==null?void 0:br.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[wr,Er];if(wr&&!Object.keys(this.namespaces||{}).map(Br=>en(Br)).includes(wr))throw new Error(`Namespace '${wr}' is not configured. Please call connect() first with namespace config.`);if(wr&&Er)return[wr,Er];const kr=en(Object.keys(this.namespaces)[0]),jr=this.rpcProviders[kr].getDefaultChain();return[kr,jr]}async requestAccounts(){const[br]=this.validateChain();return await this.getProvider(br).requestAccounts()}onChainChanged(br,wr=!1){if(!this.namespaces)return;const[Er,kr]=this.validateChain(br);kr&&(wr||this.getProvider(Er).setDefaultChain(kr),this.namespaces[Er]?this.namespaces[Er].defaultChain=kr:this.namespaces[`${Er}:${kr}`]?this.namespaces[`${Er}:${kr}`].defaultChain=kr:this.namespaces[`${Er}:${kr}`]={defaultChain:kr},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",kr))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(br,wr){this.client.core.storage.setItem(`${xa}/${br}`,wr)}async getFromStore(br){return await this.client.core.storage.getItem(`${xa}/${br}`)}}const hv=lr,P$2="wc",S$1="ethereum_provider",$$1=`${P$2}@2:${S$1}:`,j$2="https://rpc.walletconnect.com/v1/",u$2=["eth_sendTransaction","personal_sign"],E$1=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],m$2=["chainChanged","accountsChanged"],_$2=["chainChanged","accountsChanged","message","disconnect","connect"];var N$1=Object.defineProperty,q$2=Object.defineProperties,D$2=Object.getOwnPropertyDescriptors,y$2=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,O$1=(fr,br,wr)=>br in fr?N$1(fr,br,{enumerable:!0,configurable:!0,writable:!0,value:wr}):fr[br]=wr,p$2=(fr,br)=>{for(var wr in br||(br={}))U.call(br,wr)&&O$1(fr,wr,br[wr]);if(y$2)for(var wr of y$2(br))Q.call(br,wr)&&O$1(fr,wr,br[wr]);return fr},M$1=(fr,br)=>q$2(fr,D$2(br));function g$2(fr){return Number(fr[0].split(":")[1])}function f$3(fr){return`0x${fr.toString(16)}`}function L$1(fr){const{chains:br,optionalChains:wr,methods:Er,optionalMethods:kr,events:jr,optionalEvents:Br,rpcMap:Wr}=fr;if(!k$6(br))throw new Error("Invalid chains");const qr={chains:br,methods:Er||u$2,events:jr||m$2,rpcMap:p$2({},br.length?{[g$2(br)]:Wr[g$2(br)]}:{})},Hr=jr==null?void 0:jr.filter(Qr=>!m$2.includes(Qr)),Vr=Er==null?void 0:Er.filter(Qr=>!u$2.includes(Qr));if(!wr&&!Br&&!kr&&!(Hr!=null&&Hr.length)&&!(Vr!=null&&Vr.length))return{required:br.length?qr:void 0};const Zr=(Hr==null?void 0:Hr.length)&&(Vr==null?void 0:Vr.length)||!wr,Jr={chains:[...new Set(Zr?qr.chains.concat(wr||[]):wr)],methods:[...new Set(qr.methods.concat(kr!=null&&kr.length?kr:E$1))],events:[...new Set(qr.events.concat(Br!=null&&Br.length?Br:_$2))],rpcMap:Wr};return{required:br.length?qr:void 0,optional:wr.length?Jr:void 0}}let v$2=class dS{constructor(){this.events=new eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=$$1,this.on=(br,wr)=>(this.events.on(br,wr),this),this.once=(br,wr)=>(this.events.once(br,wr),this),this.removeListener=(br,wr)=>(this.events.removeListener(br,wr),this),this.off=(br,wr)=>(this.events.off(br,wr),this),this.parseAccount=br=>this.isCompatibleChainId(br)?this.parseAccountId(br).address:br,this.signer={},this.rpc={}}static async init(br){const wr=new dS;return await wr.initialize(br),wr}async request(br,wr){return await this.signer.request(br,this.formatChainId(this.chainId),wr)}sendAsync(br,wr,Er){this.signer.sendAsync(br,wr,this.formatChainId(this.chainId),Er)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(br){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(br);const{required:wr,optional:Er}=L$1(this.rpc);try{const kr=await new Promise(async(Br,Wr)=>{var qr;this.rpc.showQrModal&&((qr=this.modal)==null||qr.subscribeModal(Hr=>{!Hr.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),Wr(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(M$1(p$2({namespaces:p$2({},wr&&{[this.namespace]:wr})},Er&&{optionalNamespaces:{[this.namespace]:Er}}),{pairingTopic:br==null?void 0:br.pairingTopic})).then(Hr=>{Br(Hr)}).catch(Hr=>{Wr(new Error(Hr.message))})});if(!kr)return;const jr=Un(kr.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:jr),this.setAccounts(jr),this.events.emit("connect",{chainId:f$3(this.chainId)})}catch(kr){throw this.signer.logger.error(kr),kr}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",br=>{const{params:wr}=br,{event:Er}=wr;Er.name==="accountsChanged"?(this.accounts=this.parseAccounts(Er.data),this.events.emit("accountsChanged",this.accounts)):Er.name==="chainChanged"?this.setChainId(this.formatChainId(Er.data)):this.events.emit(Er.name,Er.data),this.events.emit("session_event",br)}),this.signer.on("chainChanged",br=>{const wr=parseInt(br);this.chainId=wr,this.events.emit("chainChanged",f$3(this.chainId)),this.persist()}),this.signer.on("session_update",br=>{this.events.emit("session_update",br)}),this.signer.on("session_delete",br=>{this.reset(),this.events.emit("session_delete",br),this.events.emit("disconnect",M$1(p$2({},U$4("USER_DISCONNECTED")),{data:br.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",br=>{var wr,Er;this.rpc.showQrModal&&((wr=this.modal)==null||wr.closeModal(),(Er=this.modal)==null||Er.openModal({uri:br})),this.events.emit("display_uri",br)})}switchEthereumChain(br){this.request({method:"wallet_switchEthereumChain",params:[{chainId:br.toString(16)}]})}isCompatibleChainId(br){return typeof br=="string"?br.startsWith(`${this.namespace}:`):!1}formatChainId(br){return`${this.namespace}:${br}`}parseChainId(br){return Number(br.split(":")[1])}setChainIds(br){const wr=br.filter(Er=>this.isCompatibleChainId(Er)).map(Er=>this.parseChainId(Er));wr.length&&(this.chainId=wr[0],this.events.emit("chainChanged",f$3(this.chainId)),this.persist())}setChainId(br){if(this.isCompatibleChainId(br)){const wr=this.parseChainId(br);this.chainId=wr,this.switchEthereumChain(wr)}}parseAccountId(br){const[wr,Er,kr]=br.split(":");return{chainId:`${wr}:${Er}`,address:kr}}setAccounts(br){this.accounts=br.filter(wr=>this.parseChainId(this.parseAccountId(wr).chainId)===this.chainId).map(wr=>this.parseAccountId(wr).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(br){var wr,Er;const kr=(wr=br==null?void 0:br.chains)!=null?wr:[],jr=(Er=br==null?void 0:br.optionalChains)!=null?Er:[],Br=kr.concat(jr);if(!Br.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const Wr=kr.length?(br==null?void 0:br.methods)||u$2:[],qr=kr.length?(br==null?void 0:br.events)||m$2:[],Hr=(br==null?void 0:br.optionalMethods)||[],Vr=(br==null?void 0:br.optionalEvents)||[],Zr=(br==null?void 0:br.rpcMap)||this.buildRpcMap(Br,br.projectId),Jr=(br==null?void 0:br.qrModalOptions)||void 0;return{chains:kr==null?void 0:kr.map(Qr=>this.formatChainId(Qr)),optionalChains:jr.map(Qr=>this.formatChainId(Qr)),methods:Wr,events:qr,optionalMethods:Hr,optionalEvents:Vr,rpcMap:Zr,showQrModal:!!(br!=null&&br.showQrModal),qrModalOptions:Jr,projectId:br.projectId,metadata:br.metadata}}buildRpcMap(br,wr){const Er={};return br.forEach(kr=>{Er[kr]=this.getRpcUrl(kr,wr)}),Er}async initialize(br){if(this.rpc=this.getRpcConfig(br),this.chainId=this.rpc.chains.length?g$2(this.rpc.chains):g$2(this.rpc.optionalChains),this.signer=await hv.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:br.disableProviderPing,relayUrl:br.relayUrl,storageOptions:br.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let wr;try{const{WalletConnectModal:Er}=await __vitePreload(()=>import("./index-DrMoPmBj.js").then(kr=>kr.i),[]);wr=Er}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(wr)try{this.modal=new wr(p$2({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(Er){throw this.signer.logger.error(Er),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(br){if(!br)return;const{chains:wr,optionalChains:Er,rpcMap:kr}=br;wr&&k$6(wr)&&(this.rpc.chains=wr.map(jr=>this.formatChainId(jr)),wr.forEach(jr=>{this.rpc.rpcMap[jr]=(kr==null?void 0:kr[jr])||this.getRpcUrl(jr)})),Er&&k$6(Er)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=Er==null?void 0:Er.map(jr=>this.formatChainId(jr)),Er.forEach(jr=>{this.rpc.rpcMap[jr]=(kr==null?void 0:kr[jr])||this.getRpcUrl(jr)}))}getRpcUrl(br,wr){var Er;return((Er=this.rpc.rpcMap)==null?void 0:Er[br])||`${j$2}?chainId=eip155:${br}&projectId=${wr||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const br=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),wr=this.session.namespaces[`${this.namespace}:${br}`]?this.session.namespaces[`${this.namespace}:${br}`]:this.session.namespaces[this.namespace];this.setChainIds(br?[this.formatChainId(br)]:wr==null?void 0:wr.accounts),this.setAccounts(wr==null?void 0:wr.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(br){return typeof br=="string"||br instanceof String?[this.parseAccount(br)]:br.map(wr=>this.parseAccount(wr))}};const parseIntSafe=(fr,br=10)=>{try{const wr=parseInt(String(fr),br);if(isNaN(wr)){logger$7.error(`Error parsing ${fr}`);return}return wr}catch(wr){logger$7.error(`Error parsing ${fr} to int: ${wr}`)}},activeAccountKey=fr=>`dynamic-wc2-active-account-${fr}`,sessionTopicKey=fr=>`dynamic-wc2-session-topic-${fr}`,swicthedNetworkKey=fr=>`dynamic-wc2-switched-network-${fr}`,currentChainKey=fr=>`dynamic-wc2-current-chain-${fr}`,ee=new EventEmitter$2;class WalletConnect extends EthereumWalletConnector{constructor(br){var wr;super(br),this.supportedChains=["EVM","ETH"],this.connectedChain="EVM",this.isInitialized=!1,this.canConnectViaQrCode=!0,this.isWalletConnect=!0,this.preferredChains=[],this._hasSwitchedNetwork=!1,this.sessionEventHandler=()=>{},this.sessionDeleteHandler=()=>{},this.name=br.walletName,this.projectId=br.projectId,this.deepLinkPreference=br.deepLinkPreference||"native",this.preferredChains=br.walletConnectPreferredChains||[],this.hasSwitchedNetwork=(wr=!!localStorage.getItem(this.swicthedNetworkKey))!==null&&wr!==void 0?wr:!1;const Er=localStorage.getItem(this.currentChainKey);this.currentChainId=Er?parseIntSafe(Er):void 0}getMappedChains(){return this.evmNetworks.filter(br=>br.chainId!==11297108109).map(br=>`eip155:${br.chainId}`)}getMappedChainsByPreferredOrder(){const br=this.getMappedChains(),wr=this.preferredChains.filter(kr=>br.includes(kr)),Er=br.filter(kr=>!this.preferredChains.includes(kr));return[...wr,...Er].map(kr=>Number(kr.split(":")[1]))}initConnection(){return __awaiter$8(this,void 0,void 0,function*(){const{provider:br}=WalletConnect;if(!br)throw new DynamicError("No provider found (init connection)");br!=null&&br.signer.uri||br.connect().catch(wr=>{logger$7.error(wr),ee.emit("walletconnect_connection_failed",wr)})})}createProvider(){return __awaiter$8(this,void 0,void 0,function*(){return v$2.init({events:["chainChanged","accountsChanged"],methods:[],optionalChains:this.getMappedChainsByPreferredOrder(),optionalMethods:["eth_chainId","eth_signTypedData","eth_signTransaction","eth_sign","personal_sign","eth_sendTransaction","eth_signTypedData_v4","wallet_switchEthereumChain","wallet_addEthereumChain"],projectId:this.projectId,rpcMap:this.evmNetworkRpcMap(),showQrModal:!1})})}getWalletClientFromInitializedProvider(){return __awaiter$8(this,void 0,void 0,function*(){const br=this.createProvider();return createWalletClient({account:this.getActiveAccount(),transport:custom(yield br)})})}createInitProviderPromise(){return __awaiter$8(this,void 0,void 0,function*(){WalletConnect.provider=yield this.createProvider(),this.teardownEventListeners(),this.setupEventListeners()})}initProvider(){return __awaiter$8(this,void 0,void 0,function*(){const{provider:br}=WalletConnect;br||(this.initializePromise===void 0&&(this.initializePromise=this.createInitProviderPromise()),yield this.initializePromise)})}refreshSession(){var br,wr,Er,kr,jr;!((wr=(br=WalletConnect.provider)===null||br===void 0?void 0:br.session)===null||wr===void 0)&&wr.topic&&localStorage.getItem(this.sessionTopicKey)===((kr=(Er=WalletConnect.provider)===null||Er===void 0?void 0:Er.session)===null||kr===void 0?void 0:kr.topic)&&(this.session=WalletConnect.provider.session,this.setActiveAccount((jr=localStorage.getItem(this.activeAccountKey))!==null&&jr!==void 0?jr:void 0))}init(){return __awaiter$8(this,void 0,void 0,function*(){yield this.initProvider(),yield this.initConnection(),this.isInitialized=!0})}get sessionTopicKey(){return sessionTopicKey(this.key)}get activeAccountKey(){return activeAccountKey(this.key)}get swicthedNetworkKey(){return swicthedNetworkKey(this.key)}get currentChainKey(){return currentChainKey(this.key)}set currentChainId(br){this._currentChainId=br,br?localStorage.setItem(this.currentChainKey,br.toString()):localStorage.removeItem(this.currentChainKey)}get currentChainId(){return this._currentChainId}set hasSwitchedNetwork(br){this._hasSwitchedNetwork=br,br?localStorage.setItem(this.swicthedNetworkKey,br.toString()):localStorage.removeItem(this.swicthedNetworkKey)}get hasSwitchedNetwork(){return this._hasSwitchedNetwork}supportsNetworkSwitching(){return!0}setupEventListeners(){WalletConnect.provider&&(this.sessionEventHandler=({params:br})=>{if(logger$7.debug("session_event was called",{params:br}),!br||!br.event){logger$7.debug("session_event was called without params or params.event");return}const{name:wr,data:Er}=br.event;if(wr==="chainChanged"){const kr=parseIntSafe(Er);if(kr===this.currentChainId){logger$7.debug(`ignoring chainChanged event with same chain id as current chain id: ${kr}`);return}if(kr===void 0){logger$7.debug(`received unexpected data for chainChanged: ${Er} with type ${typeof Er}}`);return}this.currentChainId=kr,this.emit("chainChange",{chain:String(kr)}),this.hasSwitchedNetwork=!0,this.switchNetwork({networkChainId:kr})}else if(wr==="accountsChanged"){if(!Array.isArray(Er)){logger$7.debug(`received unexpected data for accountsChanged: ${Er} with type ${typeof Er}}`);return}const kr=Er[0].split(":")[2];this.setWCActiveAccount(kr)}},WalletConnect.provider.on("session_event",this.sessionEventHandler),this.sessionDeleteHandler=()=>__awaiter$8(this,void 0,void 0,function*(){this.endSession(),this.emit("disconnect")}),WalletConnect.provider.on("session_delete",this.sessionDeleteHandler))}teardownEventListeners(){WalletConnect.provider&&(WalletConnect.provider.off("session_event",this.sessionEventHandler),WalletConnect.provider.off("session_delete",this.sessionDeleteHandler))}getWalletClient(br){if(WalletConnect.provider)return createWalletClient({account:this.getActiveAccount(),chain:chainsMap[br??String(this.currentChainId)],transport:custom(WalletConnect.provider)})}getAddress(br){return __awaiter$8(this,void 0,void 0,function*(){var wr,Er;const kr=this.getActiveAccount();if(kr!=null&&kr.address)return kr.address;if((!WalletConnect.provider||!(!((wr=WalletConnect.provider)===null||wr===void 0)&&wr.signer.uri))&&(logger$7.debug("No WC2 provider found, re-initializing..."),yield this.endSession(),yield this.init(),yield sleep$1(1e3),!WalletConnect.provider||!(!((Er=WalletConnect.provider)===null||Er===void 0)&&Er.signer.uri)))throw logger$7.debug("No WC2 provider found, escaping and throwing error"),new DynamicError("No provider found");const jr=getWalletBookWallet(this.walletBook,this.key,this.walletFallback);return performPlatformSpecificConnectionMethod(WalletConnect.provider.signer.uri,jr,{onDesktopUri:br==null?void 0:br.onDesktopUri,onDisplayUri:br==null?void 0:br.onDisplayUri},this.deepLinkPreference),new Promise((Br,Wr)=>{if(!WalletConnect.provider){Wr(new DynamicError("No provider found"));return}const qr=()=>{const Zr=new DynamicError("Connection rejected. Please try again.");Zr.code="connection_rejected",WalletConnect.provider&&(WalletConnect.provider.signer.uri=void 0,this.init()),Wr(Zr),Vr()},Hr=()=>{var Zr;const Jr=(Zr=WalletConnect.provider)===null||Zr===void 0?void 0:Zr.session;if(!Jr){Wr(new DynamicError("No session found"));return}this.setSession(Jr),this.setWCActiveAccount(Jr.namespaces.eip155.accounts[0].split(":")[2]),this.getNetwork().then(Qr=>{var _n;this.currentChainId=Qr,Br((_n=this.getActiveAccount())===null||_n===void 0?void 0:_n.address)}),Vr()},Vr=()=>{var Zr;ee.off("walletconnect_connection_failed",qr),(Zr=WalletConnect.provider)===null||Zr===void 0||Zr.off("connect",Hr)};ee.on("walletconnect_connection_failed",qr),WalletConnect.provider.on("connect",Hr)})})}waitForSignMessage(br,wr){return __awaiter$8(this,void 0,void 0,function*(){const kr=yield new Promise((jr,Br)=>{this.on("chainChange",()=>jr({success:!1})),br(wr).then(Wr=>jr({signedMessage:Wr,success:!0})).catch(Br)});return kr.success===!1?br(wr):kr.signedMessage})}getDeepLink(){var br;if(!this.session)return;const wr=getWalletBookWallet(this.walletBook,this.key),Er=getDeepLink({metadata:wr,mode:"regular",preference:this.deepLinkPreference,uri:(br=WalletConnect.provider)===null||br===void 0?void 0:br.signer.uri});if(Er)return`${Er}?sessionTopic=${this.session.topic}`}signMessage(br){return __awaiter$8(this,void 0,void 0,function*(){if(!this.session)throw new DynamicError("no session");const wr=this.getDeepLink();isMobile()&&wr&&(window.location.href=wr);const Er=jr=>__awaiter$8(this,void 0,void 0,function*(){const Br=this.getActiveAccount();return Br?(yield this.getWalletClientFromInitializedProvider()).signMessage({account:Br,message:jr}):void 0});return yield this.waitForSignMessage(Er,br)})}clearActiveAccount(){localStorage.removeItem(this.activeAccountKey),this.setActiveAccount(void 0)}clearSession(){localStorage.removeItem(this.sessionTopicKey),this.session=void 0}setWCActiveAccount(br){localStorage.setItem(this.activeAccountKey,br),this.setActiveAccount(br),this.emit("accountChange",{accounts:[br]})}setSession(br){localStorage.setItem(this.sessionTopicKey,br.topic),this.session=br}endSession(){return __awaiter$8(this,void 0,void 0,function*(){var br;if(this.clearActiveAccount(),this.clearSession(),this.hasSwitchedNetwork=!1,this.currentChainId=void 0,!!(!((br=WalletConnect.provider)===null||br===void 0)&&br.session))try{yield WalletConnect.provider.disconnect(),WalletConnect.provider=void 0}catch(wr){logger$7.debug(wr)}})}getNetwork(){const br=Object.create(null,{getNetwork:{get:()=>super.getNetwork}});return __awaiter$8(this,void 0,void 0,function*(){return this.currentChainId?this.currentChainId:(yield this.initProvider(),br.getNetwork.call(this))})}providerSwitchNetwork(br){const wr=Object.create(null,{providerSwitchNetwork:{get:()=>super.providerSwitchNetwork}});return __awaiter$8(this,arguments,void 0,function*({network:Er}){const kr=yield this.getSupportedNetworks();if(!(kr!=null&&kr.includes(Er.chainId.toString()))){const Wr=new DynamicError("Network switching is not available at this time. The user should manually switch network in their wallet");throw Wr.code="network_switching_only_available_in_wallet",Wr}const jr=yield this.getNetwork();if(jr&&jr===Er.chainId)return;if(this.switchNetworkOnlyFromWallet)throw new DynamicError("Network switching is only supported through the wallet");if(!this.supportsNetworkSwitching())throw new DynamicError("Network switching not supported");const Br=yield this.getWalletClientFromInitializedProvider();if(this.isMetaMask()){const Wr=this.getDeepLink();Wr&&(window.location.href=Wr)}yield wr.providerSwitchNetwork.call(this,{network:Er,provider:Br}),this.currentChainId=Er.chainId,this.hasSwitchedNetwork=!0,this.emit("chainChange",{chain:String(Er.chainId)})})}getConnectedAccounts(){return __awaiter$8(this,void 0,void 0,function*(){this.isInitialized===!1&&(yield this.initProvider(),this.refreshSession(),this.isInitialized=!0);const br=this.getActiveAccount();return br!=null&&br.address?[br.address]:[]})}isMetaMask(){var br,wr,Er,kr,jr;return(jr=(kr=(Er=(wr=(br=this.session)===null||br===void 0?void 0:br.peer)===null||wr===void 0?void 0:wr.metadata)===null||Er===void 0?void 0:Er.name)===null||kr===void 0?void 0:kr.toLowerCase().startsWith("metamask"))!==null&&jr!==void 0?jr:!1}getSupportedNetworks(){return __awaiter$8(this,void 0,void 0,function*(){var br;if(yield this.initProvider(),this.refreshSession(),this.isMetaMask())return this.hasSwitchedNetwork?[String(this.currentChainId)]:this.evmNetworks.map(Er=>Er.chainId.toString());if(!this.session)return[];const wr=[];return Object.keys(this.session.namespaces).forEach(Er=>{Er.startsWith("eip155:")&&wr.push(Er.split(":")[1])}),(br=this.session.namespaces.eip155)===null||br===void 0||br.accounts.forEach(Er=>wr.push(Er.split(":")[1])),wr.length?wr:this.evmNetworks.map(Er=>Er.chainId.toString())})}}let InjectedWalletBase$1=class extends EthereumWalletConnector{constructor(){super(...arguments),this.supportedChains=["ETH","EVM"],this.connectedChain="EVM",this.walletConnectorFallback=!1}getEthProviderHelper(){return this.wallet||(this.wallet=findWalletBookWallet(this.walletBook,this.key)),this.wallet&&!this.ethProviderHelper&&(this.ethProviderHelper=new EthProviderHelper(this.wallet,this)),this.ethProviderHelper}getMobileOrInstalledWallet(){var br,wr;return this.wallet||(this.wallet=findWalletBookWallet(this.walletBook,this.key)),this.isInstalledOnBrowser()?this:!((wr=(br=this.wallet)===null||br===void 0?void 0:br.mobile)===null||wr===void 0)&&wr.inAppBrowser&&this.mobileExperience==="in-app-browser"&&isMobile()?this:this.walletConnectorFallback?new WalletConnect(Object.assign(Object.assign({},this.constructorProps),{walletName:this.name})):this}findProvider(){const br=this.getEthProviderHelper();if(br)return br.getInstalledProvider()}setupEventListeners(){if(!this.getWalletClient())return;const wr=this.getEthProviderHelper();if(!wr)return;const{tearDownEventListeners:Er}=wr._setupEventListeners(this);this.teardownEventListeners=Er}getWalletClient(br){var wr;return(wr=this.getEthProviderHelper())===null||wr===void 0?void 0:wr.findWalletClient(br)}isInstalledOnBrowser(){var br;return((br=this.getEthProviderHelper())===null||br===void 0?void 0:br.findProvider())!==void 0}getAddress(){return __awaiter$8(this,void 0,void 0,function*(){var br;return(br=this.getEthProviderHelper())===null||br===void 0?void 0:br.getAddress()})}connect(){return __awaiter$8(this,void 0,void 0,function*(){yield this.getAddress()})}signMessage(br){return __awaiter$8(this,void 0,void 0,function*(){var wr;return(wr=this.getEthProviderHelper())===null||wr===void 0?void 0:wr.signMessage(br)})}proveOwnership(br,wr){return __awaiter$8(this,void 0,void 0,function*(){return yield this.validateActiveWallet(br),this.signMessage(wr)})}endSession(){return __awaiter$8(this,void 0,void 0,function*(){})}providerSwitchNetwork(br){const wr=Object.create(null,{providerSwitchNetwork:{get:()=>super.providerSwitchNetwork}});return __awaiter$8(this,arguments,void 0,function*({network:Er,provider:kr}){return wr.providerSwitchNetwork.call(this,{network:Er,provider:kr})})}};class PhantomEvm extends InjectedWalletBase$1{constructor(br){super(br),this.name="Phantom",this.overrideKey="phantomevm",this.wallet=findWalletBookWallet(this.walletBook,this.key)}getAddress(){const br=Object.create(null,{getAddress:{get:()=>super.getAddress}});return __awaiter$8(this,void 0,void 0,function*(){if(this.isInstalledOnBrowser())return br.getAddress.call(this);isMobile()&&handleMobileWalletRedirect({nativeLink:"phantom://browse",universalLink:"https://phantom.app/ul/browse"})})}canGetChainAddress(){var br,wr;return!!(!((wr=(br=this.getEthProviderHelper())===null||br===void 0?void 0:br.findProvider())===null||wr===void 0)&&wr.selectedAddress)}}class ExodusEvm extends InjectedWalletBase$1{constructor(br){super(br),this.name="ExodusEvm",this.overrideKey="exodusevm",this.walletConnectorFallback=!0,this.wallet=findWalletBookWallet(this.walletBook,this.key)}}let UnknownInjected$1=class extends InjectedWalletBase$1{constructor(br){super(br),this.name="Unknown",this.overrideKey="unknown",this.wallet=findWalletBookWallet(this.walletBook,this.key)}isInstalledOnBrowser(){return!1}};class FallbackEvmConnector extends InjectedWalletBase$1{constructor(br){super(br),this.name="Fallback Connector",this.overrideKey="fallbackconnector",this.isAvailable=!1,this.wallet=findWalletBookWallet(this.walletBook,this.key)}isInstalledOnBrowser(){return!1}}const injectedWalletOverrides$1=[PhantomEvm,ExodusEvm],filteredInjectedWalletKeysOverrides$1=["phantomevm","coinbase","exodusevm"],fetchInjectedWalletConnector=({walletBook:fr})=>{var br;return Object.entries((br=fr==null?void 0:fr.wallets)!==null&&br!==void 0?br:{}).filter(([wr,Er])=>{var kr;return((kr=Er.injectedConfig)===null||kr===void 0?void 0:kr.find(jr=>jr.chain==="evm"))&&!filteredInjectedWalletKeysOverrides$1.includes(wr)}).map(([wr,Er])=>{const{shortName:kr}=Er,jr=kr||Er.name,Br=!!Er.walletConnect;return class extends InjectedWalletBase$1{constructor(Wr){super(Object.assign({},Wr)),this.name=jr,this.wallet=Er,this.walletConnectorFallback=Br,this.overrideKey=wr}getAddress(){const Wr=Object.create(null,{getAddress:{get:()=>super.getAddress}});return __awaiter$8(this,void 0,void 0,function*(){var qr;if(this.isInstalledOnBrowser())return Wr.getAddress.call(this);const Hr=(qr=this.wallet.mobile)===null||qr===void 0?void 0:qr.inAppBrowser;if(!Hr){const Vr=new Error(`No inAppBrowserBase found for ${this.name}.`);throw logger$7.error(Vr.message),Vr}window.location.href=`${Hr}/${window.location.href}`})}}})},fetchWalletConnectWallets=({walletBook:fr})=>{var br;return Object.entries((br=fr==null?void 0:fr.wallets)!==null&&br!==void 0?br:{}).filter(([,wr])=>wr.walletConnect&&!wr.filterFromWalletConnect).map(([wr,Er])=>{const{shortName:kr}=Er,jr=kr||Er.name;return class extends WalletConnect{constructor(Br){super(Object.assign(Object.assign({},Br),{walletName:jr})),this.overrideKey=wr}}})},getWalletConnectConnector=()=>class extends WalletConnect{constructor(fr){super(Object.assign(Object.assign({},fr),{walletName:"WalletConnect"}))}};var dist={},CoinbaseWalletSDK$1={},walletLogo$1={};Object.defineProperty(walletLogo$1,"__esModule",{value:!0});walletLogo$1.walletLogo=void 0;const walletLogo=(fr,br)=>{let wr;switch(fr){case"standard":return wr=br,`data:image/svg+xml,%3Csvg width='${br}' height='${wr}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return wr=br,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${br}' height='${wr}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return wr=(.1*br).toFixed(2),`data:image/svg+xml,%3Csvg width='${br}' height='${wr}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return wr=(.25*br).toFixed(2),`data:image/svg+xml,%3Csvg width='${br}' height='${wr}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return wr=(.1*br).toFixed(2),`data:image/svg+xml,%3Csvg width='${br}' height='${wr}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return wr=(.25*br).toFixed(2),`data:image/svg+xml,%3Csvg width='${br}' height='${wr}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return wr=br,`data:image/svg+xml,%3Csvg width='${br}' height='${wr}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};walletLogo$1.walletLogo=walletLogo;var CoinbaseWalletProvider$1={};const require$$0$2=getAugmentedNamespace(eventemitter3$1);var error={},constants$2={};Object.defineProperty(constants$2,"__esModule",{value:!0});constants$2.errorValues=constants$2.standardErrorCodes=void 0;constants$2.standardErrorCodes={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}};constants$2.errorValues={"-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."}};var errors$1={},utils$1={};(function(fr){Object.defineProperty(fr,"__esModule",{value:!0}),fr.serialize=fr.getErrorCode=fr.isValidCode=fr.getMessageFromCode=fr.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const br=constants$2,wr="Unspecified error message.";fr.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function Er(Jr,Qr=wr){if(Jr&&Number.isInteger(Jr)){const _n=Jr.toString();if(Vr(br.errorValues,_n))return br.errorValues[_n].message;if(qr(Jr))return fr.JSON_RPC_SERVER_ERROR_MESSAGE}return Qr}fr.getMessageFromCode=Er;function kr(Jr){if(!Number.isInteger(Jr))return!1;const Qr=Jr.toString();return!!(br.errorValues[Qr]||qr(Jr))}fr.isValidCode=kr;function jr(Jr){var Qr;if(typeof Jr=="number")return Jr;if(Br(Jr))return(Qr=Jr.code)!==null&&Qr!==void 0?Qr:Jr.errorCode}fr.getErrorCode=jr;function Br(Jr){return typeof Jr=="object"&&Jr!==null&&(typeof Jr.code=="number"||typeof Jr.errorCode=="number")}function Wr(Jr,{shouldIncludeStack:Qr=!1}={}){const _n={};if(Jr&&typeof Jr=="object"&&!Array.isArray(Jr)&&Vr(Jr,"code")&&kr(Jr.code)){const En=Jr;_n.code=En.code,En.message&&typeof En.message=="string"?(_n.message=En.message,Vr(En,"data")&&(_n.data=En.data)):(_n.message=Er(_n.code),_n.data={originalError:Hr(Jr)})}else _n.code=br.standardErrorCodes.rpc.internal,_n.message=Zr(Jr,"message")?Jr.message:wr,_n.data={originalError:Hr(Jr)};return Qr&&(_n.stack=Zr(Jr,"stack")?Jr.stack:void 0),_n}fr.serialize=Wr;function qr(Jr){return Jr>=-32099&&Jr<=-32e3}function Hr(Jr){return Jr&&typeof Jr=="object"&&!Array.isArray(Jr)?Object.assign({},Jr):Jr}function Vr(Jr,Qr){return Object.prototype.hasOwnProperty.call(Jr,Qr)}function Zr(Jr,Qr){return typeof Jr=="object"&&Jr!==null&&Qr in Jr&&typeof Jr[Qr]=="string"}})(utils$1);Object.defineProperty(errors$1,"__esModule",{value:!0});errors$1.standardErrors=void 0;const constants_1$6=constants$2,utils_1$1=utils$1;errors$1.standardErrors={rpc:{parse:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.parse,fr),invalidRequest:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.invalidRequest,fr),invalidParams:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.invalidParams,fr),methodNotFound:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.methodNotFound,fr),internal:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.internal,fr),server:fr=>{if(!fr||typeof fr!="object"||Array.isArray(fr))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:br}=fr;if(!Number.isInteger(br)||br>-32005||br<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return getEthJsonRpcError(br,fr)},invalidInput:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.invalidInput,fr),resourceNotFound:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.resourceNotFound,fr),resourceUnavailable:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.resourceUnavailable,fr),transactionRejected:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.transactionRejected,fr),methodNotSupported:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.methodNotSupported,fr),limitExceeded:fr=>getEthJsonRpcError(constants_1$6.standardErrorCodes.rpc.limitExceeded,fr)},provider:{userRejectedRequest:fr=>getEthProviderError(constants_1$6.standardErrorCodes.provider.userRejectedRequest,fr),unauthorized:fr=>getEthProviderError(constants_1$6.standardErrorCodes.provider.unauthorized,fr),unsupportedMethod:fr=>getEthProviderError(constants_1$6.standardErrorCodes.provider.unsupportedMethod,fr),disconnected:fr=>getEthProviderError(constants_1$6.standardErrorCodes.provider.disconnected,fr),chainDisconnected:fr=>getEthProviderError(constants_1$6.standardErrorCodes.provider.chainDisconnected,fr),unsupportedChain:fr=>getEthProviderError(constants_1$6.standardErrorCodes.provider.unsupportedChain,fr),custom:fr=>{if(!fr||typeof fr!="object"||Array.isArray(fr))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:br,message:wr,data:Er}=fr;if(!wr||typeof wr!="string")throw new Error('"message" must be a nonempty string');return new EthereumProviderError(br,wr,Er)}}};function getEthJsonRpcError(fr,br){const[wr,Er]=parseOpts(br);return new EthereumRpcError(fr,wr||(0,utils_1$1.getMessageFromCode)(fr),Er)}function getEthProviderError(fr,br){const[wr,Er]=parseOpts(br);return new EthereumProviderError(fr,wr||(0,utils_1$1.getMessageFromCode)(fr),Er)}function parseOpts(fr){if(fr){if(typeof fr=="string")return[fr];if(typeof fr=="object"&&!Array.isArray(fr)){const{message:br,data:wr}=fr;if(br&&typeof br!="string")throw new Error("Must specify string message.");return[br||void 0,wr]}}return[]}class EthereumRpcError extends Error{constructor(br,wr,Er){if(!Number.isInteger(br))throw new Error('"code" must be an integer.');if(!wr||typeof wr!="string")throw new Error('"message" must be a nonempty string.');super(wr),this.code=br,Er!==void 0&&(this.data=Er)}}class EthereumProviderError extends EthereumRpcError{constructor(br,wr,Er){if(!isValidEthProviderCode(br))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(br,wr,Er)}}function isValidEthProviderCode(fr){return Number.isInteger(fr)&&fr>=1e3&&fr<=4999}(function(fr){Object.defineProperty(fr,"__esModule",{value:!0}),fr.standardErrors=fr.standardErrorCodes=void 0;var br=constants$2;Object.defineProperty(fr,"standardErrorCodes",{enumerable:!0,get:function(){return br.standardErrorCodes}});var wr=errors$1;Object.defineProperty(fr,"standardErrors",{enumerable:!0,get:function(){return wr.standardErrors}})})(error);var serialize$1={},Web3Response={};Object.defineProperty(Web3Response,"__esModule",{value:!0});Web3Response.isErrorResponse=void 0;function isErrorResponse(fr){return fr.errorMessage!==void 0}Web3Response.isErrorResponse=isErrorResponse;var version$8={};Object.defineProperty(version$8,"__esModule",{value:!0});version$8.LIB_VERSION=void 0;version$8.LIB_VERSION="4.0.4";Object.defineProperty(serialize$1,"__esModule",{value:!0});serialize$1.serializeError=void 0;const Web3Response_1$2=Web3Response,version_1$3=version$8,constants_1$5=constants$2,utils_1=utils$1;function serializeError(fr,br){const wr=(0,utils_1.serialize)(getErrorObject(fr),{shouldIncludeStack:!0}),Er=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");Er.searchParams.set("version",version_1$3.LIB_VERSION),Er.searchParams.set("code",wr.code.toString());const kr=getMethod(wr.data,br);return kr&&Er.searchParams.set("method",kr),Er.searchParams.set("message",wr.message),Object.assign(Object.assign({},wr),{docUrl:Er.href})}serialize$1.serializeError=serializeError;function getErrorObject(fr){return typeof fr=="string"?{message:fr,code:constants_1$5.standardErrorCodes.rpc.internal}:(0,Web3Response_1$2.isErrorResponse)(fr)?Object.assign(Object.assign({},fr),{message:fr.errorMessage,code:fr.errorCode,data:{method:fr.method}}):fr}function getMethod(fr,br){const wr=fr==null?void 0:fr.method;if(wr)return wr;if(br!==void 0){if(typeof br=="string")return br;if(Array.isArray(br)){if(br.length>0)return br[0].method}else return br.method}}var type$3={};Object.defineProperty(type$3,"__esModule",{value:!0});type$3.RegExpString=type$3.IntNumber=type$3.BigIntString=type$3.AddressString=type$3.HexString=type$3.OpaqueType=void 0;function OpaqueType(){return fr=>fr}type$3.OpaqueType=OpaqueType;type$3.HexString=OpaqueType();type$3.AddressString=OpaqueType();type$3.BigIntString=OpaqueType();function IntNumber(fr){return Math.floor(fr)}type$3.IntNumber=IntNumber;type$3.RegExpString=OpaqueType();var util$6={};Object.defineProperty(util$6,"__esModule",{value:!0});util$6.areAddressArraysEqual=util$6.getFavicon=util$6.range=util$6.isBigNumber=util$6.ensureParsedJSONObject=util$6.ensureBigInt=util$6.ensureRegExpString=util$6.ensureIntNumber=util$6.ensureBuffer=util$6.ensureAddressString=util$6.ensureEvenLengthHexString=util$6.ensureHexString=util$6.isHexString=util$6.prepend0x=util$6.strip0x=util$6.has0xPrefix=util$6.hexStringFromIntNumber=util$6.intNumberFromHexString=util$6.bigIntStringFromBigInt=util$6.hexStringFromBuffer=util$6.hexStringToUint8Array=util$6.uint8ArrayToHex=util$6.randomBytesHex=void 0;const error_1$8=error,_1=type$3,INT_STRING_REGEX=/^[0-9]*$/,HEXADECIMAL_STRING_REGEX=/^[a-f0-9]*$/;function randomBytesHex(fr){return uint8ArrayToHex(crypto.getRandomValues(new Uint8Array(fr)))}util$6.randomBytesHex=randomBytesHex;function uint8ArrayToHex(fr){return[...fr].map(br=>br.toString(16).padStart(2,"0")).join("")}util$6.uint8ArrayToHex=uint8ArrayToHex;function hexStringToUint8Array(fr){return new Uint8Array(fr.match(/.{1,2}/g).map(br=>parseInt(br,16)))}util$6.hexStringToUint8Array=hexStringToUint8Array;function hexStringFromBuffer(fr,br=!1){const wr=fr.toString("hex");return(0,_1.HexString)(br?`0x${wr}`:wr)}util$6.hexStringFromBuffer=hexStringFromBuffer;function bigIntStringFromBigInt(fr){return(0,_1.BigIntString)(fr.toString(10))}util$6.bigIntStringFromBigInt=bigIntStringFromBigInt;function intNumberFromHexString(fr){return(0,_1.IntNumber)(Number(BigInt(ensureEvenLengthHexString(fr,!0))))}util$6.intNumberFromHexString=intNumberFromHexString;function hexStringFromIntNumber(fr){return(0,_1.HexString)(`0x${BigInt(fr).toString(16)}`)}util$6.hexStringFromIntNumber=hexStringFromIntNumber;function has0xPrefix(fr){return fr.startsWith("0x")||fr.startsWith("0X")}util$6.has0xPrefix=has0xPrefix;function strip0x(fr){return has0xPrefix(fr)?fr.slice(2):fr}util$6.strip0x=strip0x;function prepend0x(fr){return has0xPrefix(fr)?`0x${fr.slice(2)}`:`0x${fr}`}util$6.prepend0x=prepend0x;function isHexString$1(fr){if(typeof fr!="string")return!1;const br=strip0x(fr).toLowerCase();return HEXADECIMAL_STRING_REGEX.test(br)}util$6.isHexString=isHexString$1;function ensureHexString(fr,br=!1){if(typeof fr=="string"){const wr=strip0x(fr).toLowerCase();if(HEXADECIMAL_STRING_REGEX.test(wr))return(0,_1.HexString)(br?`0x${wr}`:wr)}throw error_1$8.standardErrors.rpc.invalidParams(`"${String(fr)}" is not a hexadecimal string`)}util$6.ensureHexString=ensureHexString;function ensureEvenLengthHexString(fr,br=!1){let wr=ensureHexString(fr,!1);return wr.length%2===1&&(wr=(0,_1.HexString)(`0${wr}`)),br?(0,_1.HexString)(`0x${wr}`):wr}util$6.ensureEvenLengthHexString=ensureEvenLengthHexString;function ensureAddressString(fr){if(typeof fr=="string"){const br=strip0x(fr).toLowerCase();if(isHexString$1(br)&&br.length===40)return(0,_1.AddressString)(prepend0x(br))}throw error_1$8.standardErrors.rpc.invalidParams(`Invalid Ethereum address: ${String(fr)}`)}util$6.ensureAddressString=ensureAddressString;function ensureBuffer(fr){if(Buffer$2.isBuffer(fr))return fr;if(typeof fr=="string"){if(isHexString$1(fr)){const br=ensureEvenLengthHexString(fr,!1);return Buffer$2.from(br,"hex")}return Buffer$2.from(fr,"utf8")}throw error_1$8.standardErrors.rpc.invalidParams(`Not binary data: ${String(fr)}`)}util$6.ensureBuffer=ensureBuffer;function ensureIntNumber(fr){if(typeof fr=="number"&&Number.isInteger(fr))return(0,_1.IntNumber)(fr);if(typeof fr=="string"){if(INT_STRING_REGEX.test(fr))return(0,_1.IntNumber)(Number(fr));if(isHexString$1(fr))return(0,_1.IntNumber)(Number(BigInt(ensureEvenLengthHexString(fr,!0))))}throw error_1$8.standardErrors.rpc.invalidParams(`Not an integer: ${String(fr)}`)}util$6.ensureIntNumber=ensureIntNumber;function ensureRegExpString(fr){if(fr instanceof RegExp)return(0,_1.RegExpString)(fr.toString());throw error_1$8.standardErrors.rpc.invalidParams(`Not a RegExp: ${String(fr)}`)}util$6.ensureRegExpString=ensureRegExpString;function ensureBigInt(fr){if(fr!==null&&(typeof fr=="bigint"||isBigNumber(fr)))return BigInt(fr.toString(10));if(typeof fr=="number")return BigInt(ensureIntNumber(fr));if(typeof fr=="string"){if(INT_STRING_REGEX.test(fr))return BigInt(fr);if(isHexString$1(fr))return BigInt(ensureEvenLengthHexString(fr,!0))}throw error_1$8.standardErrors.rpc.invalidParams(`Not an integer: ${String(fr)}`)}util$6.ensureBigInt=ensureBigInt;function ensureParsedJSONObject(fr){if(typeof fr=="string")return JSON.parse(fr);if(typeof fr=="object")return fr;throw error_1$8.standardErrors.rpc.invalidParams(`Not a JSON string or an object: ${String(fr)}`)}util$6.ensureParsedJSONObject=ensureParsedJSONObject;function isBigNumber(fr){if(fr==null||typeof fr.constructor!="function")return!1;const{constructor:br}=fr;return typeof br.config=="function"&&typeof br.EUCLID=="number"}util$6.isBigNumber=isBigNumber;function range(fr,br){return Array.from({length:br-fr},(wr,Er)=>fr+Er)}util$6.range=range;function getFavicon(){const fr=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:br,host:wr}=document.location,Er=fr?fr.getAttribute("href"):null;return!Er||Er.startsWith("javascript:")||Er.startsWith("vbscript:")?null:Er.startsWith("http://")||Er.startsWith("https://")||Er.startsWith("data:")?Er:Er.startsWith("//")?br+Er:`${br}//${wr}${Er}`}util$6.getFavicon=getFavicon;function areAddressArraysEqual(fr,br){return fr.length===br.length&&fr.every((wr,Er)=>wr===br[Er])}util$6.areAddressArraysEqual=areAddressArraysEqual;var util$5={},SCWSigner$1={},SCWKeyManager$1={},cipher={};Object.defineProperty(cipher,"__esModule",{value:!0});cipher.decryptContent=cipher.encryptContent=cipher.importKeyFromHexString=cipher.exportKeyToHexString=cipher.decrypt=cipher.encrypt=cipher.deriveSharedSecret=cipher.generateKeyPair=void 0;const util_1$b=util$6;async function generateKeyPair(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}cipher.generateKeyPair=generateKeyPair;async function deriveSharedSecret(fr,br){return crypto.subtle.deriveKey({name:"ECDH",public:br},fr,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}cipher.deriveSharedSecret=deriveSharedSecret;async function encrypt(fr,br){const wr=crypto.getRandomValues(new Uint8Array(12)),Er=await crypto.subtle.encrypt({name:"AES-GCM",iv:wr},fr,new TextEncoder().encode(br));return{iv:wr,cipherText:Er}}cipher.encrypt=encrypt;async function decrypt(fr,{iv:br,cipherText:wr}){const Er=await crypto.subtle.decrypt({name:"AES-GCM",iv:br},fr,wr);return new TextDecoder().decode(Er)}cipher.decrypt=decrypt;function getFormat(fr){switch(fr){case"public":return"spki";case"private":return"pkcs8"}}async function exportKeyToHexString(fr,br){const wr=getFormat(fr),Er=await crypto.subtle.exportKey(wr,br);return(0,util_1$b.uint8ArrayToHex)(new Uint8Array(Er))}cipher.exportKeyToHexString=exportKeyToHexString;async function importKeyFromHexString(fr,br){const wr=getFormat(fr),Er=(0,util_1$b.hexStringToUint8Array)(br).buffer;return await crypto.subtle.importKey(wr,Er,{name:"ECDH",namedCurve:"P-256"},!0,fr==="private"?["deriveKey"]:[])}cipher.importKeyFromHexString=importKeyFromHexString;async function encryptContent(fr,br){const wr=JSON.stringify(fr,(Er,kr)=>{if(!(kr instanceof Error))return kr;const jr=kr;return Object.assign(Object.assign({},jr.code?{code:jr.code}:{}),{message:jr.message})});return encrypt(br,wr)}cipher.encryptContent=encryptContent;async function decryptContent(fr,br){return JSON.parse(await decrypt(br,fr))}cipher.decryptContent=decryptContent;var ScopedLocalStorage$1={};Object.defineProperty(ScopedLocalStorage$1,"__esModule",{value:!0});ScopedLocalStorage$1.ScopedLocalStorage=void 0;class ScopedLocalStorage{constructor(br,wr){this.scope=br,this.module=wr}setItem(br,wr){localStorage.setItem(this.scopedKey(br),wr)}getItem(br){return localStorage.getItem(this.scopedKey(br))}removeItem(br){localStorage.removeItem(this.scopedKey(br))}clear(){const br=this.scopedKey(""),wr=[];for(let Er=0;ErlocalStorage.removeItem(Er))}scopedKey(br){return`-${this.scope}${this.module?`:${this.module}`:""}:${br}`}static clearAll(){new ScopedLocalStorage("CBWSDK").clear(),new ScopedLocalStorage("walletlink").clear()}}ScopedLocalStorage$1.ScopedLocalStorage=ScopedLocalStorage;Object.defineProperty(SCWKeyManager$1,"__esModule",{value:!0});SCWKeyManager$1.SCWKeyManager=void 0;const cipher_1$1=cipher,ScopedLocalStorage_1$6=ScopedLocalStorage$1,OWN_PRIVATE_KEY={storageKey:"ownPrivateKey",keyType:"private"},OWN_PUBLIC_KEY={storageKey:"ownPublicKey",keyType:"public"},PEER_PUBLIC_KEY={storageKey:"peerPublicKey",keyType:"public"};class SCWKeyManager{constructor(){this.storage=new ScopedLocalStorage_1$6.ScopedLocalStorage("CBWSDK","SCWKeyManager"),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(br){this.sharedSecret=null,this.peerPublicKey=br,await this.storeKey(PEER_PUBLIC_KEY,br),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,this.storage.removeItem(OWN_PUBLIC_KEY.storageKey),this.storage.removeItem(OWN_PRIVATE_KEY.storageKey),this.storage.removeItem(PEER_PUBLIC_KEY.storageKey)}async generateKeyPair(){const br=await(0,cipher_1$1.generateKeyPair)();this.ownPrivateKey=br.privateKey,this.ownPublicKey=br.publicKey,await this.storeKey(OWN_PRIVATE_KEY,br.privateKey),await this.storeKey(OWN_PUBLIC_KEY,br.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(OWN_PRIVATE_KEY)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(OWN_PUBLIC_KEY)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey(PEER_PUBLIC_KEY)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await(0,cipher_1$1.deriveSharedSecret)(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(br){const wr=this.storage.getItem(br.storageKey);return wr?(0,cipher_1$1.importKeyFromHexString)(br.keyType,wr):null}async storeKey(br,wr){const Er=await(0,cipher_1$1.exportKeyToHexString)(br.keyType,wr);this.storage.setItem(br.storageKey,Er)}}SCWKeyManager$1.SCWKeyManager=SCWKeyManager;var SCWStateManager$1={};Object.defineProperty(SCWStateManager$1,"__esModule",{value:!0});SCWStateManager$1.SCWStateManager=void 0;const ScopedLocalStorage_1$5=ScopedLocalStorage$1,ACCOUNTS_KEY="accounts",ACTIVE_CHAIN_STORAGE_KEY="activeChain",AVAILABLE_CHAINS_STORAGE_KEY="availableChains",WALLET_CAPABILITIES_STORAGE_KEY="walletCapabilities";class SCWStateManager{get accounts(){return this._accounts}get activeChain(){return this._activeChain}get walletCapabilities(){return this._walletCapabilities}constructor(br){var wr,Er;this.storage=new ScopedLocalStorage_1$5.ScopedLocalStorage("CBWSDK","SCWStateManager"),this.updateListener=br.updateListener,this.availableChains=this.loadItemFromStorage(AVAILABLE_CHAINS_STORAGE_KEY),this._walletCapabilities=this.loadItemFromStorage(WALLET_CAPABILITIES_STORAGE_KEY);const kr=this.loadItemFromStorage(ACCOUNTS_KEY),jr=this.loadItemFromStorage(ACTIVE_CHAIN_STORAGE_KEY);kr&&this.updateListener.onAccountsUpdate({accounts:kr,source:"storage"}),jr&&this.updateListener.onChainUpdate({chain:jr,source:"storage"}),this._accounts=kr||[],this._activeChain=jr||{id:(Er=(wr=br.appChainIds)===null||wr===void 0?void 0:wr[0])!==null&&Er!==void 0?Er:1}}updateAccounts(br){this._accounts=br,this.storeItemToStorage(ACCOUNTS_KEY,br),this.updateListener.onAccountsUpdate({accounts:br,source:"wallet"})}switchChain(br){var wr;const Er=(wr=this.availableChains)===null||wr===void 0?void 0:wr.find(kr=>kr.id===br);return Er?(Er===this._activeChain||(this._activeChain=Er,this.storeItemToStorage(ACTIVE_CHAIN_STORAGE_KEY,Er),this.updateListener.onChainUpdate({chain:Er,source:"wallet"})),!0):!1}updateAvailableChains(br){if(!br||Object.keys(br).length===0)return;const wr=Object.entries(br).map(([Er,kr])=>({id:Number(Er),rpcUrl:kr}));this.availableChains=wr,this.storeItemToStorage(AVAILABLE_CHAINS_STORAGE_KEY,wr),this.switchChain(this._activeChain.id)}updateWalletCapabilities(br){this._walletCapabilities=br,this.storeItemToStorage(WALLET_CAPABILITIES_STORAGE_KEY,br)}storeItemToStorage(br,wr){this.storage.setItem(br,JSON.stringify(wr))}loadItemFromStorage(br){const wr=this.storage.getItem(br);return wr?JSON.parse(wr):void 0}clear(){this.storage.clear()}}SCWStateManager$1.SCWStateManager=SCWStateManager;Object.defineProperty(SCWSigner$1,"__esModule",{value:!0});SCWSigner$1.SCWSigner=void 0;const SCWKeyManager_1=SCWKeyManager$1,SCWStateManager_1=SCWStateManager$1,error_1$7=error,util_1$a=util$6,cipher_1=cipher;class SCWSigner{constructor(br){this.metadata=br.metadata,this.communicator=br.communicator,this.keyManager=new SCWKeyManager_1.SCWKeyManager,this.stateManager=new SCWStateManager_1.SCWStateManager({appChainIds:this.metadata.appChainIds,updateListener:br.updateListener}),this.handshake=this.handshake.bind(this),this.request=this.request.bind(this),this.createRequestMessage=this.createRequestMessage.bind(this),this.decryptResponseMessage=this.decryptResponseMessage.bind(this)}async handshake(){const br=await this.createRequestMessage({handshake:{method:"eth_requestAccounts",params:this.metadata}}),wr=await this.communicator.postRequestAndWaitForResponse(br);if("failure"in wr.content)throw wr.content.failure;const Er=await(0,cipher_1.importKeyFromHexString)("public",wr.sender);await this.keyManager.setPeerPublicKey(Er);const kr=await this.decryptResponseMessage(wr);this.updateInternalState({method:"eth_requestAccounts"},kr);const jr=kr.result;if("error"in jr)throw jr.error;return this.stateManager.accounts}async request(br){const wr=this.tryLocalHandling(br);if(wr!==void 0){if(wr instanceof Error)throw wr;return wr}await this.communicator.waitForPopupLoaded();const Er=await this.sendEncryptedRequest(br),kr=await this.decryptResponseMessage(Er);this.updateInternalState(br,kr);const jr=kr.result;if("error"in jr)throw jr.error;return jr.value}async disconnect(){this.stateManager.clear(),await this.keyManager.clear()}tryLocalHandling(br){var wr;switch(br.method){case"wallet_switchEthereumChain":{const Er=br.params;if(!Er||!(!((wr=Er[0])===null||wr===void 0)&&wr.chainId))throw error_1$7.standardErrors.rpc.invalidParams();const kr=(0,util_1$a.ensureIntNumber)(Er[0].chainId);return this.stateManager.switchChain(kr)?null:void 0}case"wallet_getCapabilities":{const Er=this.stateManager.walletCapabilities;if(!Er)throw error_1$7.standardErrors.provider.unauthorized("No wallet capabilities found, please disconnect and reconnect");return Er}default:return}}async sendEncryptedRequest(br){const wr=await this.keyManager.getSharedSecret();if(!wr)throw error_1$7.standardErrors.provider.unauthorized("No valid session found, try requestAccounts before other methods");const Er=await(0,cipher_1.encryptContent)({action:br,chainId:this.stateManager.activeChain.id},wr),kr=await this.createRequestMessage({encrypted:Er});return this.communicator.postRequestAndWaitForResponse(kr)}async createRequestMessage(br){const wr=await(0,cipher_1.exportKeyToHexString)("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),sender:wr,content:br,timestamp:new Date}}async decryptResponseMessage(br){const wr=br.content;if("failure"in wr)throw wr.failure;const Er=await this.keyManager.getSharedSecret();if(!Er)throw error_1$7.standardErrors.provider.unauthorized("Invalid session");return(0,cipher_1.decryptContent)(wr.encrypted,Er)}updateInternalState(br,wr){var Er,kr;const jr=(Er=wr.data)===null||Er===void 0?void 0:Er.chains;jr&&this.stateManager.updateAvailableChains(jr);const Br=(kr=wr.data)===null||kr===void 0?void 0:kr.capabilities;Br&&this.stateManager.updateWalletCapabilities(Br);const Wr=wr.result;if(!("error"in Wr))switch(br.method){case"eth_requestAccounts":{const qr=Wr.value;this.stateManager.updateAccounts(qr);break}case"wallet_switchEthereumChain":{if(Wr.value!==null)return;const qr=br.params,Hr=(0,util_1$a.ensureIntNumber)(qr[0].chainId);this.stateManager.switchChain(Hr);break}}}}SCWSigner$1.SCWSigner=SCWSigner;var WalletLinkSigner$1={};const{Transform:Transform$1}=requireReadableBrowser$1();var keccak$2=fr=>class fS extends Transform$1{constructor(wr,Er,kr,jr,Br){super(Br),this._rate=wr,this._capacity=Er,this._delimitedSuffix=kr,this._hashBitLength=jr,this._options=Br,this._state=new fr,this._state.initialize(wr,Er),this._finalized=!1}_transform(wr,Er,kr){let jr=null;try{this.update(wr,Er)}catch(Br){jr=Br}kr(jr)}_flush(wr){let Er=null;try{this.push(this.digest())}catch(kr){Er=kr}wr(Er)}update(wr,Er){if(!Buffer$2.isBuffer(wr)&&typeof wr!="string")throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return Buffer$2.isBuffer(wr)||(wr=Buffer$2.from(wr,Er)),this._state.absorb(wr),this}digest(wr){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);let Er=this._state.squeeze(this._hashBitLength/8);return wr!==void 0&&(Er=Er.toString(wr)),this._resetState(),Er}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const wr=new fS(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(wr._state),wr._finalized=this._finalized,wr}};const{Transform}=requireReadableBrowser$1();var shake=fr=>class hS extends Transform{constructor(wr,Er,kr,jr){super(jr),this._rate=wr,this._capacity=Er,this._delimitedSuffix=kr,this._options=jr,this._state=new fr,this._state.initialize(wr,Er),this._finalized=!1}_transform(wr,Er,kr){let jr=null;try{this.update(wr,Er)}catch(Br){jr=Br}kr(jr)}_flush(){}_read(wr){this.push(this.squeeze(wr))}update(wr,Er){if(!Buffer$2.isBuffer(wr)&&typeof wr!="string")throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return Buffer$2.isBuffer(wr)||(wr=Buffer$2.from(wr,Er)),this._state.absorb(wr),this}squeeze(wr,Er){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));let kr=this._state.squeeze(wr);return Er!==void 0&&(kr=kr.toString(Er)),kr}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const wr=new hS(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(wr._state),wr._finalized=this._finalized,wr}};const createKeccak=keccak$2,createShake=shake;var api=function(fr){const br=createKeccak(fr),wr=createShake(fr);return function(Er,kr){switch(typeof Er=="string"?Er.toLowerCase():Er){case"keccak224":return new br(1152,448,null,224,kr);case"keccak256":return new br(1088,512,null,256,kr);case"keccak384":return new br(832,768,null,384,kr);case"keccak512":return new br(576,1024,null,512,kr);case"sha3-224":return new br(1152,448,6,224,kr);case"sha3-256":return new br(1088,512,6,256,kr);case"sha3-384":return new br(832,768,6,384,kr);case"sha3-512":return new br(576,1024,6,512,kr);case"shake128":return new wr(1344,256,31,kr);case"shake256":return new wr(1088,512,31,kr);default:throw new Error("Invald algorithm: "+Er)}}},keccakStateUnroll={};const P1600_ROUND_CONSTANTS=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648];keccakStateUnroll.p1600=function(fr){for(let br=0;br<24;++br){const wr=fr[0]^fr[10]^fr[20]^fr[30]^fr[40],Er=fr[1]^fr[11]^fr[21]^fr[31]^fr[41],kr=fr[2]^fr[12]^fr[22]^fr[32]^fr[42],jr=fr[3]^fr[13]^fr[23]^fr[33]^fr[43],Br=fr[4]^fr[14]^fr[24]^fr[34]^fr[44],Wr=fr[5]^fr[15]^fr[25]^fr[35]^fr[45],qr=fr[6]^fr[16]^fr[26]^fr[36]^fr[46],Hr=fr[7]^fr[17]^fr[27]^fr[37]^fr[47],Vr=fr[8]^fr[18]^fr[28]^fr[38]^fr[48],Zr=fr[9]^fr[19]^fr[29]^fr[39]^fr[49];let Jr=Vr^(kr<<1|jr>>>31),Qr=Zr^(jr<<1|kr>>>31);const _n=fr[0]^Jr,En=fr[1]^Qr,Cn=fr[10]^Jr,In=fr[11]^Qr,An=fr[20]^Jr,jn=fr[21]^Qr,eo=fr[30]^Jr,ro=fr[31]^Qr,to=fr[40]^Jr,_i=fr[41]^Qr;Jr=wr^(Br<<1|Wr>>>31),Qr=Er^(Wr<<1|Br>>>31);const oo=fr[2]^Jr,io=fr[3]^Qr,co=fr[12]^Jr,so=fr[13]^Qr,no=fr[22]^Jr,Tn=fr[23]^Qr,Gr=fr[32]^Jr,Xr=fr[33]^Qr,Sn=fr[42]^Jr,Rn=fr[43]^Qr;Jr=kr^(qr<<1|Hr>>>31),Qr=jr^(Hr<<1|qr>>>31);const Pn=fr[4]^Jr,On=fr[5]^Qr,Zn=fr[14]^Jr,Nn=fr[15]^Qr,wn=fr[24]^Jr,zn=fr[25]^Qr,fo=fr[34]^Jr,vo=fr[35]^Qr,go=fr[44]^Jr,uo=fr[45]^Qr;Jr=Br^(Vr<<1|Zr>>>31),Qr=Wr^(Zr<<1|Vr>>>31);const lo=fr[6]^Jr,Eo=fr[7]^Qr,mo=fr[16]^Jr,yo=fr[17]^Qr,_o=fr[26]^Jr,Bo=fr[27]^Qr,Lo=fr[36]^Jr,Wo=fr[37]^Qr,na=fr[46]^Jr,qo=fr[47]^Qr;Jr=qr^(wr<<1|Er>>>31),Qr=Hr^(Er<<1|wr>>>31);const ga=fr[8]^Jr,wl=fr[9]^Qr,No=fr[18]^Jr,Fo=fr[19]^Qr,Nl=fr[28]^Jr,Vo=fr[29]^Qr,Uo=fr[38]^Jr,Ol=fr[39]^Qr,$a=fr[48]^Jr,Jo=fr[49]^Qr,Zl=_n,Cl=En,ko=In<<4|Cn>>>28,wo=Cn<<4|In>>>28,bo=An<<3|jn>>>29,Io=jn<<3|An>>>29,Ho=ro<<9|eo>>>23,Do=eo<<9|ro>>>23,zo=to<<18|_i>>>14,nu=_i<<18|to>>>14,Ll=oo<<1|io>>>31,_l=io<<1|oo>>>31,bu=so<<12|co>>>20,xl=co<<12|so>>>20,Tl=no<<10|Tn>>>22,du=Tn<<10|no>>>22,Bl=Xr<<13|Gr>>>19,Il=Gr<<13|Xr>>>19,Eu=Sn<<2|Rn>>>30,Al=Rn<<2|Sn>>>30,Ml=On<<30|Pn>>>2,Tu=Pn<<30|On>>>2,Ul=Zn<<6|Nn>>>26,Sl=Nn<<6|Zn>>>26,_u=zn<<11|wn>>>21,So=wn<<11|zn>>>21,Co=fo<<15|vo>>>17,Ao=vo<<15|fo>>>17,po=uo<<29|go>>>3,Ro=go<<29|uo>>>3,Xo=lo<<28|Eo>>>4,jo=Eo<<28|lo>>>4,Ko=yo<<23|mo>>>9,Wl=mo<<23|yo>>>9,$l=_o<<25|Bo>>>7,El=Bo<<25|_o>>>7,Cu=Lo<<21|Wo>>>11,iu=Wo<<21|Lo>>>11,pu=qo<<24|na>>>8,yu=na<<24|qo>>>8,hu=ga<<27|wl>>>5,mu=wl<<27|ga>>>5,vu=No<<20|Fo>>>12,fu=Fo<<20|No>>>12,gu=Vo<<7|Nl>>>25,ou=Nl<<7|Vo>>>25,su=Uo<<8|Ol>>>24,tu=Ol<<8|Uo>>>24,zl=$a<<14|Jo>>>18,Gl=Jo<<14|$a>>>18;fr[0]=Zl^~bu&_u,fr[1]=Cl^~xl&So,fr[10]=Xo^~vu&bo,fr[11]=jo^~fu&Io,fr[20]=Ll^~Ul&$l,fr[21]=_l^~Sl&El,fr[30]=hu^~ko&Tl,fr[31]=mu^~wo&du,fr[40]=Ml^~Ko&gu,fr[41]=Tu^~Wl&ou,fr[2]=bu^~_u&Cu,fr[3]=xl^~So&iu,fr[12]=vu^~bo&Bl,fr[13]=fu^~Io&Il,fr[22]=Ul^~$l&su,fr[23]=Sl^~El&tu,fr[32]=ko^~Tl&Co,fr[33]=wo^~du&Ao,fr[42]=Ko^~gu&Ho,fr[43]=Wl^~ou&Do,fr[4]=_u^~Cu&zl,fr[5]=So^~iu&Gl,fr[14]=bo^~Bl&po,fr[15]=Io^~Il&Ro,fr[24]=$l^~su&zo,fr[25]=El^~tu&nu,fr[34]=Tl^~Co&pu,fr[35]=du^~Ao&yu,fr[44]=gu^~Ho&Eu,fr[45]=ou^~Do&Al,fr[6]=Cu^~zl&Zl,fr[7]=iu^~Gl&Cl,fr[16]=Bl^~po&Xo,fr[17]=Il^~Ro&jo,fr[26]=su^~zo&Ll,fr[27]=tu^~nu&_l,fr[36]=Co^~pu&hu,fr[37]=Ao^~yu&mu,fr[46]=Ho^~Eu&Ml,fr[47]=Do^~Al&Tu,fr[8]=zl^~Zl&bu,fr[9]=Gl^~Cl&xl,fr[18]=po^~Xo&vu,fr[19]=Ro^~jo&fu,fr[28]=zo^~Ll&Ul,fr[29]=nu^~_l&Sl,fr[38]=pu^~hu&ko,fr[39]=yu^~mu&wo,fr[48]=Eu^~Ml&Ko,fr[49]=Al^~Tu&Wl,fr[0]^=P1600_ROUND_CONSTANTS[br*2],fr[1]^=P1600_ROUND_CONSTANTS[br*2+1]}};const keccakState=keccakStateUnroll;function Keccak(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}Keccak.prototype.initialize=function(fr,br){for(let wr=0;wr<50;++wr)this.state[wr]=0;this.blockSize=fr/8,this.count=0,this.squeezing=!1};Keccak.prototype.absorb=function(fr){for(let br=0;br>>8*(this.count%4)&255,this.count+=1,this.count===this.blockSize&&(keccakState.p1600(this.state),this.count=0);return br};Keccak.prototype.copy=function(fr){for(let br=0;br<50;++br)fr.state[br]=this.state[br];fr.blockSize=this.blockSize,fr.count=this.count,fr.squeezing=this.squeezing};var keccak$1=Keccak,js=api(keccak$1);const createKeccakHash=js;function zeros(fr){return Buffer$2.allocUnsafe(fr).fill(0)}function bitLengthFromBigInt(fr){return fr.toString(2).length}function bufferBEFromBigInt(fr,br){let wr=fr.toString(16);wr.length%2!==0&&(wr="0"+wr);const Er=wr.match(/.{1,2}/g).map(kr=>parseInt(kr,16));for(;Er.length"u")throw new Error("Not an array?");if(wr=parseTypeArray(fr),wr!=="dynamic"&&wr!==0&&br.length>wr)throw new Error("Elements exceed array size: "+wr);kr=[],fr=fr.slice(0,fr.lastIndexOf("[")),typeof br=="string"&&(br=JSON.parse(br));for(jr in br)kr.push(encodeSingle(fr,br[jr]));if(wr==="dynamic"){var Br=encodeSingle("uint256",br.length);kr.unshift(Br)}return Buffer$2.concat(kr)}else{if(fr==="bytes")return br=new Buffer$2(br),kr=Buffer$2.concat([encodeSingle("uint256",br.length),br]),br.length%32!==0&&(kr=Buffer$2.concat([kr,util$3.zeros(32-br.length%32)])),kr;if(fr.startsWith("bytes")){if(wr=parseTypeN(fr),wr<1||wr>32)throw new Error("Invalid bytes width: "+wr);return util$3.setLengthRight(br,32)}else if(fr.startsWith("uint")){if(wr=parseTypeN(fr),wr%8||wr<8||wr>256)throw new Error("Invalid uint width: "+wr);Er=parseNumber(br);const Wr=util$3.bitLengthFromBigInt(Er);if(Wr>wr)throw new Error("Supplied uint exceeds width: "+wr+" vs "+Wr);if(Er<0)throw new Error("Supplied uint is negative");return util$3.bufferBEFromBigInt(Er,32)}else if(fr.startsWith("int")){if(wr=parseTypeN(fr),wr%8||wr<8||wr>256)throw new Error("Invalid int width: "+wr);Er=parseNumber(br);const Wr=util$3.bitLengthFromBigInt(Er);if(Wr>wr)throw new Error("Supplied int exceeds width: "+wr+" vs "+Wr);const qr=util$3.twosFromBigInt(Er,256);return util$3.bufferBEFromBigInt(qr,32)}else if(fr.startsWith("ufixed")){if(wr=parseTypeNxM(fr),Er=parseNumber(br),Er<0)throw new Error("Supplied ufixed is negative");return encodeSingle("uint256",Er*BigInt(2)**BigInt(wr[1]))}else if(fr.startsWith("fixed"))return wr=parseTypeNxM(fr),encodeSingle("int256",parseNumber(br)*BigInt(2)**BigInt(wr[1]))}throw new Error("Unsupported or invalid type: "+fr)}function isDynamic(fr){return fr==="string"||fr==="bytes"||parseTypeArray(fr)==="dynamic"}function isArray(fr){return fr.lastIndexOf("]")===fr.length-1}function rawEncode(fr,br){var wr=[],Er=[],kr=32*fr.length;for(var jr in fr){var Br=elementaryName(fr[jr]),Wr=br[jr],qr=encodeSingle(Br,Wr);isDynamic(Br)?(wr.push(encodeSingle("uint256",kr)),Er.push(qr),kr+=qr.length):wr.push(qr)}return Buffer$2.concat(wr.concat(Er))}function solidityPack(fr,br){if(fr.length!==br.length)throw new Error("Number of types are not matching the values");for(var wr,Er,kr=[],jr=0;jr32)throw new Error("Invalid bytes width: "+wr);kr.push(util$3.setLengthRight(Wr,wr))}else if(Br.startsWith("uint")){if(wr=parseTypeN(Br),wr%8||wr<8||wr>256)throw new Error("Invalid uint width: "+wr);Er=parseNumber(Wr);const qr=util$3.bitLengthFromBigInt(Er);if(qr>wr)throw new Error("Supplied uint exceeds width: "+wr+" vs "+qr);kr.push(util$3.bufferBEFromBigInt(Er,wr/8))}else if(Br.startsWith("int")){if(wr=parseTypeN(Br),wr%8||wr<8||wr>256)throw new Error("Invalid int width: "+wr);Er=parseNumber(Wr);const qr=util$3.bitLengthFromBigInt(Er);if(qr>wr)throw new Error("Supplied int exceeds width: "+wr+" vs "+qr);const Hr=util$3.twosFromBigInt(Er,wr);kr.push(util$3.bufferBEFromBigInt(Hr,wr/8))}else throw new Error("Unsupported or invalid type: "+Br)}return Buffer$2.concat(kr)}function soliditySHA3(fr,br){return util$3.keccak(solidityPack(fr,br))}var abi$1={rawEncode,solidityPack,soliditySHA3};const util$2=util$4,abi=abi$1,TYPED_MESSAGE_SCHEMA={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"]},TypedDataUtils={encodeData(fr,br,wr,Er=!0){const kr=["bytes32"],jr=[this.hashType(fr,wr)];if(Er){const Br=(Wr,qr,Hr)=>{if(wr[qr]!==void 0)return["bytes32",Hr==null?"0x0000000000000000000000000000000000000000000000000000000000000000":util$2.keccak(this.encodeData(qr,Hr,wr,Er))];if(Hr===void 0)throw new Error(`missing value for field ${Wr} of type ${qr}`);if(qr==="bytes")return["bytes32",util$2.keccak(Hr)];if(qr==="string")return typeof Hr=="string"&&(Hr=Buffer$2.from(Hr,"utf8")),["bytes32",util$2.keccak(Hr)];if(qr.lastIndexOf("]")===qr.length-1){const Vr=qr.slice(0,qr.lastIndexOf("[")),Zr=Hr.map(Jr=>Br(Wr,Vr,Jr));return["bytes32",util$2.keccak(abi.rawEncode(Zr.map(([Jr])=>Jr),Zr.map(([,Jr])=>Jr)))]}return[qr,Hr]};for(const Wr of wr[fr]){const[qr,Hr]=Br(Wr.name,Wr.type,br[Wr.name]);kr.push(qr),jr.push(Hr)}}else for(const Br of wr[fr]){let Wr=br[Br.name];if(Wr!==void 0)if(Br.type==="bytes")kr.push("bytes32"),Wr=util$2.keccak(Wr),jr.push(Wr);else if(Br.type==="string")kr.push("bytes32"),typeof Wr=="string"&&(Wr=Buffer$2.from(Wr,"utf8")),Wr=util$2.keccak(Wr),jr.push(Wr);else if(wr[Br.type]!==void 0)kr.push("bytes32"),Wr=util$2.keccak(this.encodeData(Br.type,Wr,wr,Er)),jr.push(Wr);else{if(Br.type.lastIndexOf("]")===Br.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");kr.push(Br.type),jr.push(Wr)}}return abi.rawEncode(kr,jr)},encodeType(fr,br){let wr="",Er=this.findTypeDependencies(fr,br).filter(kr=>kr!==fr);Er=[fr].concat(Er.sort());for(const kr of Er){if(!br[kr])throw new Error("No type definition specified: "+kr);wr+=kr+"("+br[kr].map(({name:Br,type:Wr})=>Wr+" "+Br).join(",")+")"}return wr},findTypeDependencies(fr,br,wr=[]){if(fr=fr.match(/^\w*/)[0],wr.includes(fr)||br[fr]===void 0)return wr;wr.push(fr);for(const Er of br[fr])for(const kr of this.findTypeDependencies(Er.type,br,wr))!wr.includes(kr)&&wr.push(kr);return wr},hashStruct(fr,br,wr,Er=!0){return util$2.keccak(this.encodeData(fr,br,wr,Er))},hashType(fr,br){return util$2.keccak(this.encodeType(fr,br))},sanitizeData(fr){const br={};for(const wr in TYPED_MESSAGE_SCHEMA.properties)fr[wr]&&(br[wr]=fr[wr]);return br.types&&(br.types=Object.assign({EIP712Domain:[]},br.types)),br},hash(fr,br=!0){const wr=this.sanitizeData(fr),Er=[Buffer$2.from("1901","hex")];return Er.push(this.hashStruct("EIP712Domain",wr.domain,wr.types,br)),wr.primaryType!=="EIP712Domain"&&Er.push(this.hashStruct(wr.primaryType,wr.message,wr.types,br)),util$2.keccak(Buffer$2.concat(Er))}};var ethEip712Util={TYPED_MESSAGE_SCHEMA,TypedDataUtils,hashForSignTypedDataLegacy:function(fr){return typedSignatureHashLegacy(fr.data)},hashForSignTypedData_v3:function(fr){return TypedDataUtils.hash(fr.data,!1)},hashForSignTypedData_v4:function(fr){return TypedDataUtils.hash(fr.data)}};function typedSignatureHashLegacy(fr){const br=new Error("Expect argument to be non-empty array");if(typeof fr!="object"||!fr.length)throw br;const wr=fr.map(function(jr){return jr.type==="bytes"?util$2.toBuffer(jr.value):jr.value}),Er=fr.map(function(jr){return jr.type}),kr=fr.map(function(jr){if(!jr.name)throw br;return jr.type+" "+jr.name});return abi.soliditySHA3(["bytes32","bytes32"],[abi.soliditySHA3(new Array(fr.length).fill("string"),kr),abi.soliditySHA3(Er,wr)])}var constants$1={};Object.defineProperty(constants$1,"__esModule",{value:!0});constants$1.APP_VERSION_KEY=constants$1.LOCAL_STORAGE_ADDRESSES_KEY=constants$1.WALLET_USER_NAME_KEY=void 0;constants$1.WALLET_USER_NAME_KEY="walletUsername";constants$1.LOCAL_STORAGE_ADDRESSES_KEY="Addresses";constants$1.APP_VERSION_KEY="AppVersion";var RelayEventManager$1={};Object.defineProperty(RelayEventManager$1,"__esModule",{value:!0});RelayEventManager$1.RelayEventManager=void 0;const util_1$9=util$6;class RelayEventManager{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const br=this._nextRequestId,wr=(0,util_1$9.prepend0x)(br.toString(16));return this.callbacks.get(wr)&&this.callbacks.delete(wr),br}}RelayEventManager$1.RelayEventManager=RelayEventManager;var WalletLinkRelay$1={},WalletLinkConnection$1={},WalletLinkCipher$1={};Object.defineProperty(WalletLinkCipher$1,"__esModule",{value:!0});WalletLinkCipher$1.WalletLinkCipher=void 0;const util_1$8=util$6;class WalletLinkCipher{constructor(br){this.secret=br}async encrypt(br){const wr=this.secret;if(wr.length!==64)throw Error("secret must be 256 bits");const Er=crypto.getRandomValues(new Uint8Array(12)),kr=await crypto.subtle.importKey("raw",(0,util_1$8.hexStringToUint8Array)(wr),{name:"aes-gcm"},!1,["encrypt","decrypt"]),jr=new TextEncoder,Br=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:Er},kr,jr.encode(br)),Wr=16,qr=Br.slice(Br.byteLength-Wr),Hr=Br.slice(0,Br.byteLength-Wr),Vr=new Uint8Array(qr),Zr=new Uint8Array(Hr),Jr=new Uint8Array([...Er,...Vr,...Zr]);return(0,util_1$8.uint8ArrayToHex)(Jr)}async decrypt(br){const wr=this.secret;if(wr.length!==64)throw Error("secret must be 256 bits");return new Promise((Er,kr)=>{(async function(){const jr=await crypto.subtle.importKey("raw",(0,util_1$8.hexStringToUint8Array)(wr),{name:"aes-gcm"},!1,["encrypt","decrypt"]),Br=(0,util_1$8.hexStringToUint8Array)(br),Wr=Br.slice(0,12),qr=Br.slice(12,28),Hr=Br.slice(28),Vr=new Uint8Array([...Hr,...qr]),Zr={name:"AES-GCM",iv:new Uint8Array(Wr)};try{const Jr=await window.crypto.subtle.decrypt(Zr,jr,Vr),Qr=new TextDecoder;Er(Qr.decode(Jr))}catch(Jr){kr(Jr)}})()})}}WalletLinkCipher$1.WalletLinkCipher=WalletLinkCipher;var WalletLinkHTTP$1={};Object.defineProperty(WalletLinkHTTP$1,"__esModule",{value:!0});WalletLinkHTTP$1.WalletLinkHTTP=void 0;class WalletLinkHTTP{constructor(br,wr,Er){this.linkAPIUrl=br,this.sessionId=wr;const kr=`${wr}:${Er}`;this.auth=`Basic ${btoa(kr)}`}async markUnseenEventsAsSeen(br){return Promise.all(br.map(wr=>fetch(`${this.linkAPIUrl}/events/${wr.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(wr=>console.error("Unabled to mark event as failed:",wr))}async fetchUnseenEvents(){var br;const wr=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(wr.ok){const{events:Er,error:kr}=await wr.json();if(kr)throw new Error(`Check unseen events failed: ${kr}`);const jr=(br=Er==null?void 0:Er.filter(Br=>Br.event==="Web3Response").map(Br=>({type:"Event",sessionId:this.sessionId,eventId:Br.id,event:Br.event,data:Br.data})))!==null&&br!==void 0?br:[];return this.markUnseenEventsAsSeen(jr),jr}throw new Error(`Check unseen events failed: ${wr.status}`)}}WalletLinkHTTP$1.WalletLinkHTTP=WalletLinkHTTP;var WalletLinkWebSocket$1={};Object.defineProperty(WalletLinkWebSocket$1,"__esModule",{value:!0});WalletLinkWebSocket$1.WalletLinkWebSocket=WalletLinkWebSocket$1.ConnectionState=void 0;var ConnectionState;(function(fr){fr[fr.DISCONNECTED=0]="DISCONNECTED",fr[fr.CONNECTING=1]="CONNECTING",fr[fr.CONNECTED=2]="CONNECTED"})(ConnectionState||(WalletLinkWebSocket$1.ConnectionState=ConnectionState={}));class WalletLinkWebSocket{setConnectionStateListener(br){this.connectionStateListener=br}setIncomingDataListener(br){this.incomingDataListener=br}constructor(br,wr=WebSocket){this.WebSocketClass=wr,this.webSocket=null,this.pendingData=[],this.url=br.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((br,wr)=>{var Er;let kr;try{this.webSocket=kr=new this.WebSocketClass(this.url)}catch(jr){wr(jr);return}(Er=this.connectionStateListener)===null||Er===void 0||Er.call(this,ConnectionState.CONNECTING),kr.onclose=jr=>{var Br;this.clearWebSocket(),wr(new Error(`websocket error ${jr.code}: ${jr.reason}`)),(Br=this.connectionStateListener)===null||Br===void 0||Br.call(this,ConnectionState.DISCONNECTED)},kr.onopen=jr=>{var Br;br(),(Br=this.connectionStateListener)===null||Br===void 0||Br.call(this,ConnectionState.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(qr=>this.sendData(qr)),this.pendingData=[])},kr.onmessage=jr=>{var Br,Wr;if(jr.data==="h")(Br=this.incomingDataListener)===null||Br===void 0||Br.call(this,{type:"Heartbeat"});else try{const qr=JSON.parse(jr.data);(Wr=this.incomingDataListener)===null||Wr===void 0||Wr.call(this,qr)}catch{}}})}disconnect(){var br;const{webSocket:wr}=this;if(wr){this.clearWebSocket(),(br=this.connectionStateListener)===null||br===void 0||br.call(this,ConnectionState.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{wr.close()}catch{}}}sendData(br){const{webSocket:wr}=this;if(!wr){this.pendingData.push(br),this.connect();return}wr.send(br)}clearWebSocket(){const{webSocket:br}=this;br&&(this.webSocket=null,br.onclose=null,br.onerror=null,br.onmessage=null,br.onopen=null)}}WalletLinkWebSocket$1.WalletLinkWebSocket=WalletLinkWebSocket;Object.defineProperty(WalletLinkConnection$1,"__esModule",{value:!0});WalletLinkConnection$1.WalletLinkConnection=void 0;const constants_1$4=constants$1,WalletLinkCipher_1=WalletLinkCipher$1,WalletLinkHTTP_1=WalletLinkHTTP$1,WalletLinkWebSocket_1=WalletLinkWebSocket$1,type_1$1=type$3,HEARTBEAT_INTERVAL=1e4,REQUEST_TIMEOUT=6e4;class WalletLinkConnection{constructor({session:br,linkAPIUrl:wr,listener:Er,WebSocketClass:kr=WebSocket}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=(0,type_1$1.IntNumber)(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=Br=>{if(!Br)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",qr=>Br.JsonRpcUrl&&this.handleChainUpdated(qr,Br.JsonRpcUrl)]]).forEach((qr,Hr)=>{const Vr=Br[Hr];Vr!==void 0&&qr(Vr)})},this.handleDestroyed=Br=>{var Wr;Br==="1"&&((Wr=this.listener)===null||Wr===void 0||Wr.resetAndReload())},this.handleAccountUpdated=async Br=>{var Wr;{const qr=await this.cipher.decrypt(Br);(Wr=this.listener)===null||Wr===void 0||Wr.accountUpdated(qr)}},this.handleMetadataUpdated=async(Br,Wr)=>{var qr;{const Hr=await this.cipher.decrypt(Wr);(qr=this.listener)===null||qr===void 0||qr.metadataUpdated(Br,Hr)}},this.handleWalletUsernameUpdated=async Br=>{this.handleMetadataUpdated(constants_1$4.WALLET_USER_NAME_KEY,Br)},this.handleAppVersionUpdated=async Br=>{this.handleMetadataUpdated(constants_1$4.APP_VERSION_KEY,Br)},this.handleChainUpdated=async(Br,Wr)=>{var qr;{const Hr=await this.cipher.decrypt(Br),Vr=await this.cipher.decrypt(Wr);(qr=this.listener)===null||qr===void 0||qr.chainUpdated(Hr,Vr)}},this.session=br,this.cipher=new WalletLinkCipher_1.WalletLinkCipher(br.secret),this.listener=Er;const jr=new WalletLinkWebSocket_1.WalletLinkWebSocket(`${wr}/rpc`,kr);jr.setConnectionStateListener(async Br=>{let Wr=!1;switch(Br){case WalletLinkWebSocket_1.ConnectionState.DISCONNECTED:if(!this.destroyed){const qr=async()=>{await new Promise(Hr=>setTimeout(Hr,5e3)),this.destroyed||jr.connect().catch(()=>{qr()})};qr()}break;case WalletLinkWebSocket_1.ConnectionState.CONNECTED:try{await this.authenticate(),this.sendIsLinked(),this.sendGetSessionConfig(),Wr=!0}catch{}this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},HEARTBEAT_INTERVAL),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case WalletLinkWebSocket_1.ConnectionState.CONNECTING:break}this.connected!==Wr&&(this.connected=Wr)}),jr.setIncomingDataListener(Br=>{var Wr;switch(Br.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const qr=Br.type==="IsLinkedOK"?Br.linked:void 0;this.linked=qr||Br.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(Br.metadata);break}case"Event":{this.handleIncomingEvent(Br);break}}Br.id!==void 0&&((Wr=this.requestResolutions.get(Br.id))===null||Wr===void 0||Wr(Br))}),this.ws=jr,this.http=new WalletLinkHTTP_1.WalletLinkHTTP(wr,br.id,br.key)}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}destroy(){this.destroyed=!0,this.ws.disconnect(),this.listener=void 0}get isDestroyed(){return this.destroyed}get connected(){return this._connected}set connected(br){var wr;this._connected=br,br&&((wr=this.onceConnected)===null||wr===void 0||wr.call(this))}setOnceConnected(br){return new Promise(wr=>{this.connected?br().then(wr):this.onceConnected=()=>{br().then(wr),this.onceConnected=void 0}})}get linked(){return this._linked}set linked(br){var wr,Er;this._linked=br,br&&((wr=this.onceLinked)===null||wr===void 0||wr.call(this)),(Er=this.listener)===null||Er===void 0||Er.linkedUpdated(br)}setOnceLinked(br){return new Promise(wr=>{this.linked?br().then(wr):this.onceLinked=()=>{br().then(wr),this.onceLinked=void 0}})}async handleIncomingEvent(br){var wr;if(!(br.type!=="Event"||br.event!=="Web3Response")){const Er=await this.cipher.decrypt(br.data),kr=JSON.parse(Er);if(kr.type!=="WEB3_RESPONSE")return;(wr=this.listener)===null||wr===void 0||wr.handleWeb3ResponseMessage(kr)}}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(br=>setTimeout(br,250));try{await this.fetchUnseenEventsAPI()}catch(br){console.error("Unable to check for unseen events",br)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(wr=>this.handleIncomingEvent(wr))}async setSessionMetadata(br,wr){const Er={type:"SetSessionConfig",id:(0,type_1$1.IntNumber)(this.nextReqId++),sessionId:this.session.id,metadata:{[br]:wr}};return this.setOnceConnected(async()=>{const kr=await this.makeRequest(Er);if(kr.type==="Fail")throw new Error(kr.error||"failed to set session metadata")})}async publishEvent(br,wr,Er=!1){const kr=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},wr),{origin:location.origin,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),jr={type:"PublishEvent",id:(0,type_1$1.IntNumber)(this.nextReqId++),sessionId:this.session.id,event:br,data:kr,callWebhook:Er};return this.setOnceLinked(async()=>{const Br=await this.makeRequest(jr);if(Br.type==="Fail")throw new Error(Br.error||"failed to publish event");return Br.eventId})}sendData(br){this.ws.sendData(JSON.stringify(br))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>HEARTBEAT_INTERVAL*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(br,wr=REQUEST_TIMEOUT){const Er=br.id;this.sendData(br);let kr;return Promise.race([new Promise((jr,Br)=>{kr=window.setTimeout(()=>{Br(new Error(`request ${Er} timed out`))},wr)}),new Promise(jr=>{this.requestResolutions.set(Er,Br=>{clearTimeout(kr),jr(Br),this.requestResolutions.delete(Er)})})])}async authenticate(){const br={type:"HostSession",id:(0,type_1$1.IntNumber)(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key},wr=await this.makeRequest(br);if(wr.type==="Fail")throw new Error(wr.error||"failed to authenticate")}sendIsLinked(){const br={type:"IsLinked",id:(0,type_1$1.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(br)}sendGetSessionConfig(){const br={type:"GetSessionConfig",id:(0,type_1$1.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(br)}}WalletLinkConnection$1.WalletLinkConnection=WalletLinkConnection;var WalletLinkSession$1={};Object.defineProperty(WalletLinkSession$1,"__esModule",{value:!0});WalletLinkSession$1.WalletLinkSession=void 0;const sha_js_1=requireSha_js(),util_1$7=util$6,STORAGE_KEY_SESSION_ID="session:id",STORAGE_KEY_SESSION_SECRET="session:secret",STORAGE_KEY_SESSION_LINKED="session:linked";class WalletLinkSession{constructor(br,wr,Er,kr){this._storage=br,this._id=wr||(0,util_1$7.randomBytesHex)(16),this._secret=Er||(0,util_1$7.randomBytesHex)(32),this._key=new sha_js_1.sha256().update(`${this._id}, ${this._secret} WalletLink`).digest("hex"),this._linked=!!kr}static load(br){const wr=br.getItem(STORAGE_KEY_SESSION_ID),Er=br.getItem(STORAGE_KEY_SESSION_LINKED),kr=br.getItem(STORAGE_KEY_SESSION_SECRET);return wr&&kr?new WalletLinkSession(br,wr,kr,Er==="1"):null}get id(){return this._id}get secret(){return this._secret}get key(){return this._key}get linked(){return this._linked}set linked(br){this._linked=br,this.persistLinked()}save(){return this._storage.setItem(STORAGE_KEY_SESSION_ID,this._id),this._storage.setItem(STORAGE_KEY_SESSION_SECRET,this._secret),this.persistLinked(),this}persistLinked(){this._storage.setItem(STORAGE_KEY_SESSION_LINKED,this._linked?"1":"0")}}WalletLinkSession$1.WalletLinkSession=WalletLinkSession;var util$1={};Object.defineProperty(util$1,"__esModule",{value:!0});util$1.isDarkMode=util$1.isMobileWeb=util$1.getLocation=util$1.createQrUrl=void 0;function createQrUrl(fr,br,wr,Er,kr,jr){const Br=Er?"parent-id":"id",Wr=new URLSearchParams({[Br]:fr,secret:br,server:wr,v:kr,chainId:jr.toString()}).toString();return`${wr}/#/link?${Wr}`}util$1.createQrUrl=createQrUrl;function isInIFrame(){try{return window.frameElement!==null}catch{return!1}}function getLocation(){try{return isInIFrame()&&window.top?window.top.location:window.location}catch{return window.location}}util$1.getLocation=getLocation;function isMobileWeb(){var fr;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((fr=window==null?void 0:window.navigator)===null||fr===void 0?void 0:fr.userAgent)}util$1.isMobileWeb=isMobileWeb;function isDarkMode(){var fr,br;return(br=(fr=window==null?void 0:window.matchMedia)===null||fr===void 0?void 0:fr.call(window,"(prefers-color-scheme: dark)").matches)!==null&&br!==void 0?br:!1}util$1.isDarkMode=isDarkMode;var WalletLinkRelayUI$1={},cssReset={},cssResetCss={};Object.defineProperty(cssResetCss,"__esModule",{value:!0});cssResetCss.default='@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}';var __importDefault$4=commonjsGlobal&&commonjsGlobal.__importDefault||function(fr){return fr&&fr.__esModule?fr:{default:fr}};Object.defineProperty(cssReset,"__esModule",{value:!0});cssReset.injectCssReset=void 0;const cssReset_css_1=__importDefault$4(cssResetCss);function injectCssReset(){const fr=document.createElement("style");fr.type="text/css",fr.appendChild(document.createTextNode(cssReset_css_1.default)),document.documentElement.appendChild(fr)}cssReset.injectCssReset=injectCssReset;var Snackbar={};function r$2(fr){var br,wr,Er="";if(typeof fr=="string"||typeof fr=="number")Er+=fr;else if(typeof fr=="object")if(Array.isArray(fr))for(br=0;br2&&(Br.children=arguments.length>3?n.call(arguments,2):wr),typeof fr=="function"&&fr.defaultProps!=null)for(jr in fr.defaultProps)Br[jr]===void 0&&(Br[jr]=fr.defaultProps[jr]);return g$1(fr,Br,Er,kr,null)}function g$1(fr,br,wr,Er,kr){var jr={type:fr,props:br,key:wr,ref:Er,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:kr??++u$1,__i:-1,__u:0};return kr==null&&l$1.vnode!=null&&l$1.vnode(jr),jr}function m$1(){return{current:null}}function b$1(fr){return fr.children}function k$1(fr,br){this.props=fr,this.context=br}function x$1(fr,br){if(br==null)return fr.__?x$1(fr.__,fr.__i+1):null;for(var wr;brbr&&i$2.sort(f$2));M.__r=0}function P$1(fr,br,wr,Er,kr,jr,Br,Wr,qr,Hr,Vr){var Zr,Jr,Qr,_n,En,Cn=Er&&Er.__k||v$1,In=br.length;for(wr.__d=qr,$(wr,br,Cn),qr=wr.__d,Zr=0;Zr0?g$1(kr.type,kr.props,kr.key,kr.ref?kr.ref:null,kr.__v):kr).__=fr,kr.__b=fr.__b+1,jr=null,(Wr=kr.__i=L(kr,wr,Br,Vr))!==-1&&(Vr--,(jr=wr[Wr])&&(jr.__u|=131072)),jr==null||jr.__v===null?(Wr==-1&&Zr--,typeof kr.type!="function"&&(kr.__u|=65536)):Wr!==Br&&(Wr==Br-1?Zr--:Wr==Br+1?Zr++:(Wr>Br?Zr--:Zr++,kr.__u|=65536))):kr=fr.__k[Er]=null;if(Vr)for(Er=0;Er(qr!=null&&!(131072&qr.__u)?1:0))for(;Br>=0||Wr=0){if((qr=br[Br])&&!(131072&qr.__u)&&kr==qr.key&&jr===qr.type)return Br;Br--}if(Wr2&&(Wr.children=arguments.length>3?n.call(arguments,2):wr),g$1(fr.type,Wr,Er||fr.key,kr||fr.ref,null)}function G(fr,br){var wr={__c:br="__cC"+a$1++,__:fr,Consumer:function(Er,kr){return Er.children(kr)},Provider:function(Er){var kr,jr;return this.getChildContext||(kr=new Set,(jr={})[br]=this,this.getChildContext=function(){return jr},this.componentWillUnmount=function(){kr=null},this.shouldComponentUpdate=function(Br){this.props.value!==Br.value&&kr.forEach(function(Wr){Wr.__e=!0,S(Wr)})},this.sub=function(Br){kr.add(Br);var Wr=Br.componentWillUnmount;Br.componentWillUnmount=function(){kr&&kr.delete(Br),Wr&&Wr.call(Br)}}),Er.children}};return wr.Provider.__=wr.Consumer.contextType=wr}n=v$1.slice,l$1={__e:function(fr,br,wr,Er){for(var kr,jr,Br;br=br.__;)if((kr=br.__c)&&!kr.__)try{if((jr=kr.constructor)&&jr.getDerivedStateFromError!=null&&(kr.setState(jr.getDerivedStateFromError(fr)),Br=kr.__d),kr.componentDidCatch!=null&&(kr.componentDidCatch(fr,Er||{}),Br=kr.__d),Br)return kr.__E=kr}catch(Wr){fr=Wr}throw fr}},u$1=0,t$1=function(fr){return fr!=null&&fr.constructor==null},k$1.prototype.setState=function(fr,br){var wr;wr=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=d$1({},this.state),typeof fr=="function"&&(fr=fr(d$1({},wr),this.props)),fr&&d$1(wr,fr),fr!=null&&this.__v&&(br&&this._sb.push(br),S(this))},k$1.prototype.forceUpdate=function(fr){this.__v&&(this.__e=!0,fr&&this.__h.push(fr),S(this))},k$1.prototype.render=b$1,i$2=[],r$1=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,f$2=function(fr,br){return fr.__v.__b-br.__v.__b},M.__r=0,e$1=0,c$1=F$1(!1),s$1=F$1(!0),a$1=0;const preact_module=Object.freeze(Object.defineProperty({__proto__:null,Component:k$1,Fragment:b$1,cloneElement:D$1,createContext:G,createElement:_$1,createRef:m$1,h:_$1,hydrate:B$1,get isValidElement(){return t$1},get options(){return l$1},render:q$1,toChildArray:H},Symbol.toStringTag,{value:"Module"})),require$$1=getAugmentedNamespace(preact_module);var t,r,u,i$1,o=0,f$1=[],c=l$1,e=c.__b,a=c.__r,v=c.diffed,l=c.__c,m=c.unmount,s=c.__;function d(fr,br){c.__h&&c.__h(r,fr,o||br),o=0;var wr=r.__H||(r.__H={__:[],__h:[]});return fr>=wr.__.length&&wr.__.push({}),wr.__[fr]}function h(fr){return o=1,p(D,fr)}function p(fr,br,wr){var Er=d(t++,2);if(Er.t=fr,!Er.__c&&(Er.__=[wr?wr(br):D(void 0,br),function(Wr){var qr=Er.__N?Er.__N[0]:Er.__[0],Hr=Er.t(qr,Wr);qr!==Hr&&(Er.__N=[Hr,Er.__[1]],Er.__c.setState({}))}],Er.__c=r,!r.u)){var kr=function(Wr,qr,Hr){if(!Er.__c.__H)return!0;var Vr=Er.__c.__H.__.filter(function(Jr){return!!Jr.__c});if(Vr.every(function(Jr){return!Jr.__N}))return!jr||jr.call(this,Wr,qr,Hr);var Zr=Er.__c.props!==Wr;return Vr.forEach(function(Jr){if(Jr.__N){var Qr=Jr.__[0];Jr.__=Jr.__N,Jr.__N=void 0,Qr!==Jr.__[0]&&(Zr=!0)}}),jr&&jr.call(this,Wr,qr,Hr)||Zr};r.u=!0;var jr=r.shouldComponentUpdate,Br=r.componentWillUpdate;r.componentWillUpdate=function(Wr,qr,Hr){if(this.__e){var Vr=jr;jr=void 0,kr(Wr,qr,Hr),jr=Vr}Br&&Br.call(this,Wr,qr,Hr)},r.shouldComponentUpdate=kr}return Er.__N||Er.__}function y(fr,br){var wr=d(t++,3);!c.__s&&C(wr.__H,br)&&(wr.__=fr,wr.i=br,r.__H.__h.push(wr))}function _(fr,br){var wr=d(t++,4);!c.__s&&C(wr.__H,br)&&(wr.__=fr,wr.i=br,r.__h.push(wr))}function A(fr){return o=5,T(function(){return{current:fr}},[])}function F(fr,br,wr){o=6,_(function(){return typeof fr=="function"?(fr(br()),function(){return fr(null)}):fr?(fr.current=br(),function(){return fr.current=null}):void 0},wr==null?wr:wr.concat(fr))}function T(fr,br){var wr=d(t++,7);return C(wr.__H,br)&&(wr.__=fr(),wr.__H=br,wr.__h=fr),wr.__}function q(fr,br){return o=8,T(function(){return fr},br)}function x(fr){var br=r.context[fr.__c],wr=d(t++,9);return wr.c=fr,br?(wr.__==null&&(wr.__=!0,br.sub(r)),br.props.value):fr.__}function P(fr,br){c.useDebugValue&&c.useDebugValue(br?br(fr):fr)}function b(fr){var br=d(t++,10),wr=h();return br.__=fr,r.componentDidCatch||(r.componentDidCatch=function(Er,kr){br.__&&br.__(Er,kr),wr[1](Er)}),[wr[0],function(){wr[1](void 0)}]}function g(){var fr=d(t++,11);if(!fr.__){for(var br=r.__v;br!==null&&!br.__m&&br.__!==null;)br=br.__;var wr=br.__m||(br.__m=[0,0]);fr.__="P"+wr[0]+"-"+wr[1]++}return fr.__}function j(){for(var fr;fr=f$1.shift();)if(fr.__P&&fr.__H)try{fr.__H.__h.forEach(z),fr.__H.__h.forEach(B),fr.__H.__h=[]}catch(br){fr.__H.__h=[],c.__e(br,fr.__v)}}c.__b=function(fr){r=null,e&&e(fr)},c.__=function(fr,br){fr&&br.__k&&br.__k.__m&&(fr.__m=br.__k.__m),s&&s(fr,br)},c.__r=function(fr){a&&a(fr),t=0;var br=(r=fr.__c).__H;br&&(u===r?(br.__h=[],r.__h=[],br.__.forEach(function(wr){wr.__N&&(wr.__=wr.__N),wr.i=wr.__N=void 0})):(br.__h.forEach(z),br.__h.forEach(B),br.__h=[],t=0)),u=r},c.diffed=function(fr){v&&v(fr);var br=fr.__c;br&&br.__H&&(br.__H.__h.length&&(f$1.push(br)!==1&&i$1===c.requestAnimationFrame||((i$1=c.requestAnimationFrame)||w)(j)),br.__H.__.forEach(function(wr){wr.i&&(wr.__H=wr.i),wr.i=void 0})),u=r=null},c.__c=function(fr,br){br.some(function(wr){try{wr.__h.forEach(z),wr.__h=wr.__h.filter(function(Er){return!Er.__||B(Er)})}catch(Er){br.some(function(kr){kr.__h&&(kr.__h=[])}),br=[],c.__e(Er,wr.__v)}}),l&&l(fr,br)},c.unmount=function(fr){m&&m(fr);var br,wr=fr.__c;wr&&wr.__H&&(wr.__H.__.forEach(function(Er){try{z(Er)}catch(kr){br=kr}}),wr.__H=void 0,br&&c.__e(br,wr.__v))};var k=typeof requestAnimationFrame=="function";function w(fr){var br,wr=function(){clearTimeout(Er),k&&cancelAnimationFrame(br),setTimeout(fr)},Er=setTimeout(wr,100);k&&(br=requestAnimationFrame(wr))}function z(fr){var br=r,wr=fr.__c;typeof wr=="function"&&(fr.__c=void 0,wr()),r=br}function B(fr){var br=r;fr.__c=fr.__(),r=br}function C(fr,br){return!fr||fr.length!==br.length||br.some(function(wr,Er){return wr!==fr[Er]})}function D(fr,br){return typeof br=="function"?br(fr):br}const hooks_module=Object.freeze(Object.defineProperty({__proto__:null,useCallback:q,useContext:x,useDebugValue:P,useEffect:y,useErrorBoundary:b,useId:g,useImperativeHandle:F,useLayoutEffect:_,useMemo:T,useReducer:p,useRef:A,useState:h},Symbol.toStringTag,{value:"Module"})),require$$2$1=getAugmentedNamespace(hooks_module);var SnackbarCss={};Object.defineProperty(SnackbarCss,"__esModule",{value:!0});SnackbarCss.default=".-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}";(function(fr){var br=commonjsGlobal&&commonjsGlobal.__importDefault||function(Jr){return Jr&&Jr.__esModule?Jr:{default:Jr}};Object.defineProperty(fr,"__esModule",{value:!0}),fr.SnackbarInstance=fr.SnackbarContainer=fr.Snackbar=void 0;const wr=br(require$$0$1),Er=require$$1,kr=require$$2$1,jr=util$1,Br=br(SnackbarCss),Wr="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",qr="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class Hr{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=(0,jr.isDarkMode)()}attach(Qr){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",Qr.appendChild(this.root),this.render()}presentItem(Qr){const _n=this.nextItemKey++;return this.items.set(_n,Qr),this.render(),()=>{this.items.delete(_n),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&(0,Er.render)((0,Er.h)("div",null,(0,Er.h)(fr.SnackbarContainer,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([Qr,_n])=>(0,Er.h)(fr.SnackbarInstance,Object.assign({},_n,{key:Qr}))))),this.root)}}fr.Snackbar=Hr;const Vr=Jr=>(0,Er.h)("div",{class:(0,wr.default)("-cbwsdk-snackbar-container")},(0,Er.h)("style",null,Br.default),(0,Er.h)("div",{class:"-cbwsdk-snackbar"},Jr.children));fr.SnackbarContainer=Vr;const Zr=({autoExpand:Jr,message:Qr,menuItems:_n})=>{const[En,Cn]=(0,kr.useState)(!0),[In,An]=(0,kr.useState)(Jr??!1);(0,kr.useEffect)(()=>{const eo=[window.setTimeout(()=>{Cn(!1)},1),window.setTimeout(()=>{An(!0)},1e4)];return()=>{eo.forEach(window.clearTimeout)}});const jn=()=>{An(!In)};return(0,Er.h)("div",{class:(0,wr.default)("-cbwsdk-snackbar-instance",En&&"-cbwsdk-snackbar-instance-hidden",In&&"-cbwsdk-snackbar-instance-expanded")},(0,Er.h)("div",{class:"-cbwsdk-snackbar-instance-header",onClick:jn},(0,Er.h)("img",{src:Wr,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",(0,Er.h)("div",{class:"-cbwsdk-snackbar-instance-header-message"},Qr),(0,Er.h)("div",{class:"-gear-container"},!In&&(0,Er.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,Er.h)("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),(0,Er.h)("img",{src:qr,class:"-gear-icon",title:"Expand"}))),_n&&_n.length>0&&(0,Er.h)("div",{class:"-cbwsdk-snackbar-instance-menu"},_n.map((eo,ro)=>(0,Er.h)("div",{class:(0,wr.default)("-cbwsdk-snackbar-instance-menu-item",eo.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:eo.onClick,key:ro},(0,Er.h)("svg",{width:eo.svgWidth,height:eo.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,Er.h)("path",{"fill-rule":eo.defaultFillRule,"clip-rule":eo.defaultClipRule,d:eo.path,fill:"#AAAAAA"})),(0,Er.h)("span",{class:(0,wr.default)("-cbwsdk-snackbar-instance-menu-item-info",eo.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},eo.info)))))};fr.SnackbarInstance=Zr})(Snackbar);Object.defineProperty(WalletLinkRelayUI$1,"__esModule",{value:!0});WalletLinkRelayUI$1.WalletLinkRelayUI=void 0;const cssReset_1$1=cssReset,Snackbar_1$1=Snackbar;class WalletLinkRelayUI{constructor(){this.attached=!1,this.snackbar=new Snackbar_1$1.Snackbar}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const br=document.documentElement,wr=document.createElement("div");wr.className="-cbwsdk-css-reset",br.appendChild(wr),this.snackbar.attach(wr),this.attached=!0,(0,cssReset_1$1.injectCssReset)()}showConnecting(br){let wr;return br.isUnlinkedErrorState?wr={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:br.onResetConnection}]}:wr={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:br.onCancel},{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:br.onResetConnection}]},this.snackbar.presentItem(wr)}}WalletLinkRelayUI$1.WalletLinkRelayUI=WalletLinkRelayUI;var WLMobileRelayUI$1={},RedirectDialog$1={},RedirectDialogCss={};Object.defineProperty(RedirectDialogCss,"__esModule",{value:!0});RedirectDialogCss.default=".-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}";var __importDefault$3=commonjsGlobal&&commonjsGlobal.__importDefault||function(fr){return fr&&fr.__esModule?fr:{default:fr}};Object.defineProperty(RedirectDialog$1,"__esModule",{value:!0});RedirectDialog$1.RedirectDialog=void 0;const clsx_1=__importDefault$3(require$$0$1),preact_1=require$$1,cssReset_1=cssReset,Snackbar_1=Snackbar,util_1$6=util$1,RedirectDialog_css_1=__importDefault$3(RedirectDialogCss);class RedirectDialog{constructor(){this.root=null,this.darkMode=(0,util_1$6.isDarkMode)()}attach(){const br=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",br.appendChild(this.root),(0,cssReset_1.injectCssReset)()}present(br){this.render(br)}clear(){this.render(null)}render(br){this.root&&((0,preact_1.render)(null,this.root),br&&(0,preact_1.render)((0,preact_1.h)(RedirectDialogContent,Object.assign({},br,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}RedirectDialog$1.RedirectDialog=RedirectDialog;const RedirectDialogContent=({title:fr,buttonText:br,darkMode:wr,onButtonClick:Er,onDismiss:kr})=>{const jr=wr?"dark":"light";return(0,preact_1.h)(Snackbar_1.SnackbarContainer,{darkMode:wr},(0,preact_1.h)("div",{class:"-cbwsdk-redirect-dialog"},(0,preact_1.h)("style",null,RedirectDialog_css_1.default),(0,preact_1.h)("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:kr}),(0,preact_1.h)("div",{class:(0,clsx_1.default)("-cbwsdk-redirect-dialog-box",jr)},(0,preact_1.h)("p",null,fr),(0,preact_1.h)("button",{onClick:Er},br))))};var constants={};Object.defineProperty(constants,"__esModule",{value:!0});constants.CBW_MOBILE_DEEPLINK_URL=constants.WALLETLINK_URL=constants.CB_KEYS_URL=void 0;constants.CB_KEYS_URL="https://keys.coinbase.com/connect";constants.WALLETLINK_URL="https://www.walletlink.org";constants.CBW_MOBILE_DEEPLINK_URL="https://go.cb-w.com/walletlink";Object.defineProperty(WLMobileRelayUI$1,"__esModule",{value:!0});WLMobileRelayUI$1.WLMobileRelayUI=void 0;const RedirectDialog_1=RedirectDialog$1,util_1$5=util$1,constants_1$3=constants;class WLMobileRelayUI{constructor(){this.attached=!1,this.redirectDialog=new RedirectDialog_1.RedirectDialog}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(br){const wr=new URL(constants_1$3.CBW_MOBILE_DEEPLINK_URL);wr.searchParams.append("redirect_url",(0,util_1$5.getLocation)().href),br&&wr.searchParams.append("wl_url",br);const Er=document.createElement("a");Er.target="cbw-opener",Er.href=wr.href,Er.rel="noreferrer noopener",Er.click()}openCoinbaseWalletDeeplink(br){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(br)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(br)},99)}showConnecting(br){return()=>{this.redirectDialog.clear()}}}WLMobileRelayUI$1.WLMobileRelayUI=WLMobileRelayUI;Object.defineProperty(WalletLinkRelay$1,"__esModule",{value:!0});WalletLinkRelay$1.WalletLinkRelay=void 0;const WalletLinkConnection_1=WalletLinkConnection$1,constants_1$2=constants$1,RelayEventManager_1$1=RelayEventManager$1,WalletLinkSession_1=WalletLinkSession$1,Web3Response_1$1=Web3Response,util_1$4=util$1,WalletLinkRelayUI_1=WalletLinkRelayUI$1,WLMobileRelayUI_1=WLMobileRelayUI$1,error_1$6=error,util_2$1=util$6,ScopedLocalStorage_1$4=ScopedLocalStorage$1;class WalletLinkRelay{constructor(br){this.accountsCallback=null,this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.chainCallback=null,this.dappDefaultChain=1,this.isMobileWeb=(0,util_1$4.isMobileWeb)(),this.appName="",this.appLogoUrl=null,this.linkedUpdated=jr=>{this.isLinked=jr;const Br=this.storage.getItem(constants_1$2.LOCAL_STORAGE_ADDRESSES_KEY);if(jr&&(this._session.linked=jr),this.isUnlinkedErrorState=!1,Br){const Wr=Br.split(" "),qr=this.storage.getItem("IsStandaloneSigning")==="true";Wr[0]!==""&&!jr&&this._session.linked&&!qr&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(jr,Br)=>{this.storage.setItem(jr,Br)},this.chainUpdated=(jr,Br)=>{this.chainCallbackParams.chainId===jr&&this.chainCallbackParams.jsonRpcUrl===Br||(this.chainCallbackParams={chainId:jr,jsonRpcUrl:Br},this.chainCallback&&this.chainCallback(jr,Br))},this.accountUpdated=jr=>{this.accountsCallback&&this.accountsCallback([jr]),WalletLinkRelay.accountRequestCallbackIds.size>0&&(Array.from(WalletLinkRelay.accountRequestCallbackIds.values()).forEach(Br=>{const Wr={type:"WEB3_RESPONSE",id:Br,response:{method:"requestEthereumAccounts",result:[jr]}};this.invokeCallback(Object.assign(Object.assign({},Wr),{id:Br}))}),WalletLinkRelay.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=br.linkAPIUrl,this.storage=br.storage;const{session:wr,ui:Er,connection:kr}=this.subscribe();this._session=wr,this.connection=kr,this.relayEventManager=new RelayEventManager_1$1.RelayEventManager,this.ui=Er}subscribe(){const br=WalletLinkSession_1.WalletLinkSession.load(this.storage)||new WalletLinkSession_1.WalletLinkSession(this.storage).save(),{linkAPIUrl:wr}=this,Er=new WalletLinkConnection_1.WalletLinkConnection({session:br,linkAPIUrl:wr,listener:this}),kr=this.isMobileWeb?new WLMobileRelayUI_1.WLMobileRelayUI:new WalletLinkRelayUI_1.WalletLinkRelayUI;return Er.connect(),{session:br,ui:kr,connection:Er}}attachUI(){this.ui.attach()}resetAndReload(){Promise.race([this.connection.setSessionMetadata("__destroyed","1"),new Promise(br=>setTimeout(()=>br(null),1e3))]).then(()=>{this.connection.destroy();const br=WalletLinkSession_1.WalletLinkSession.load(this.storage);(br==null?void 0:br.id)===this._session.id&&ScopedLocalStorage_1$4.ScopedLocalStorage.clearAll(),document.location.reload()}).catch(br=>{})}setAppInfo(br,wr){this.appName=br,this.appLogoUrl=wr}getStorageItem(br){return this.storage.getItem(br)}setStorageItem(br,wr){this.storage.setItem(br,wr)}signEthereumMessage(br,wr,Er,kr){return this.sendRequest({method:"signEthereumMessage",params:{message:(0,util_2$1.hexStringFromBuffer)(br,!0),address:wr,addPrefix:Er,typedDataJson:kr||null}})}ethereumAddressFromSignedMessage(br,wr,Er){return this.sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:(0,util_2$1.hexStringFromBuffer)(br,!0),signature:(0,util_2$1.hexStringFromBuffer)(wr,!0),addPrefix:Er}})}signEthereumTransaction(br){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:br.fromAddress,toAddress:br.toAddress,weiValue:(0,util_2$1.bigIntStringFromBigInt)(br.weiValue),data:(0,util_2$1.hexStringFromBuffer)(br.data,!0),nonce:br.nonce,gasPriceInWei:br.gasPriceInWei?(0,util_2$1.bigIntStringFromBigInt)(br.gasPriceInWei):null,maxFeePerGas:br.gasPriceInWei?(0,util_2$1.bigIntStringFromBigInt)(br.gasPriceInWei):null,maxPriorityFeePerGas:br.gasPriceInWei?(0,util_2$1.bigIntStringFromBigInt)(br.gasPriceInWei):null,gasLimit:br.gasLimit?(0,util_2$1.bigIntStringFromBigInt)(br.gasLimit):null,chainId:br.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(br){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:br.fromAddress,toAddress:br.toAddress,weiValue:(0,util_2$1.bigIntStringFromBigInt)(br.weiValue),data:(0,util_2$1.hexStringFromBuffer)(br.data,!0),nonce:br.nonce,gasPriceInWei:br.gasPriceInWei?(0,util_2$1.bigIntStringFromBigInt)(br.gasPriceInWei):null,maxFeePerGas:br.maxFeePerGas?(0,util_2$1.bigIntStringFromBigInt)(br.maxFeePerGas):null,maxPriorityFeePerGas:br.maxPriorityFeePerGas?(0,util_2$1.bigIntStringFromBigInt)(br.maxPriorityFeePerGas):null,gasLimit:br.gasLimit?(0,util_2$1.bigIntStringFromBigInt)(br.gasLimit):null,chainId:br.chainId,shouldSubmit:!0}})}submitEthereumTransaction(br,wr){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:(0,util_2$1.hexStringFromBuffer)(br,!0),chainId:wr}})}scanQRCode(br){return this.sendRequest({method:"scanQRCode",params:{regExp:br}})}getWalletLinkSession(){return this._session}genericRequest(br,wr){return this.sendRequest({method:"generic",params:{action:wr,data:br}})}sendGenericMessage(br){return this.sendRequest(br)}sendRequest(br){let wr=null;const Er=(0,util_2$1.randomBytesHex)(8),kr=jr=>{this.publishWeb3RequestCanceledEvent(Er),this.handleErrorResponse(Er,br.method,jr),wr==null||wr()};return new Promise((jr,Br)=>{wr=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:kr,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(Er,Wr=>{if(wr==null||wr(),(0,Web3Response_1$1.isErrorResponse)(Wr))return Br(new Error(Wr.errorMessage));jr(Wr)}),this.publishWeb3RequestEvent(Er,br)})}setAccountsCallback(br){this.accountsCallback=br}setChainCallback(br){this.chainCallback=br}setDappDefaultChainCallback(br){this.dappDefaultChain=br}publishWeb3RequestEvent(br,wr){const Er={type:"WEB3_REQUEST",id:br,request:wr};this.publishEvent("Web3Request",Er,!0).then(kr=>{}).catch(kr=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:Er.id,response:{method:wr.method,errorMessage:kr.message}})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(wr.method)}openCoinbaseWalletDeeplink(br){if(this.ui instanceof WLMobileRelayUI_1.WLMobileRelayUI)switch(br){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink();break}}publishWeb3RequestCanceledEvent(br){const wr={type:"WEB3_REQUEST_CANCELED",id:br};this.publishEvent("Web3RequestCanceled",wr,!1).then()}publishEvent(br,wr,Er){return this.connection.publishEvent(br,wr,Er)}handleWeb3ResponseMessage(br){const{response:wr}=br;if(wr.method==="requestEthereumAccounts"){WalletLinkRelay.accountRequestCallbackIds.forEach(Er=>this.invokeCallback(Object.assign(Object.assign({},br),{id:Er}))),WalletLinkRelay.accountRequestCallbackIds.clear();return}this.invokeCallback(br)}handleErrorResponse(br,wr,Er){var kr;const jr=(kr=Er==null?void 0:Er.message)!==null&&kr!==void 0?kr:"Unspecified error message.";this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:br,response:{method:wr,errorMessage:jr}})}invokeCallback(br){const wr=this.relayEventManager.callbacks.get(br.id);wr&&(wr(br.response),this.relayEventManager.callbacks.delete(br.id))}requestEthereumAccounts(){const br={method:"requestEthereumAccounts",params:{appName:this.appName,appLogoUrl:this.appLogoUrl||null}},wr=(0,util_2$1.randomBytesHex)(8);return new Promise((Er,kr)=>{this.relayEventManager.callbacks.set(wr,jr=>{if((0,Web3Response_1$1.isErrorResponse)(jr))return kr(new Error(jr.errorMessage));Er(jr)}),WalletLinkRelay.accountRequestCallbackIds.add(wr),this.publishWeb3RequestEvent(wr,br)})}watchAsset(br,wr,Er,kr,jr,Br){const Wr={method:"watchAsset",params:{type:br,options:{address:wr,symbol:Er,decimals:kr,image:jr},chainId:Br}};let qr=null;const Hr=(0,util_2$1.randomBytesHex)(8),Vr=Zr=>{this.publishWeb3RequestCanceledEvent(Hr),this.handleErrorResponse(Hr,Wr.method,Zr),qr==null||qr()};return qr=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:Vr,onResetConnection:this.resetAndReload}),new Promise((Zr,Jr)=>{this.relayEventManager.callbacks.set(Hr,Qr=>{if(qr==null||qr(),(0,Web3Response_1$1.isErrorResponse)(Qr))return Jr(new Error(Qr.errorMessage));Zr(Qr)}),this.publishWeb3RequestEvent(Hr,Wr)})}addEthereumChain(br,wr,Er,kr,jr,Br){const Wr={method:"addEthereumChain",params:{chainId:br,rpcUrls:wr,blockExplorerUrls:kr,chainName:jr,iconUrls:Er,nativeCurrency:Br}};let qr=null;const Hr=(0,util_2$1.randomBytesHex)(8),Vr=Zr=>{this.publishWeb3RequestCanceledEvent(Hr),this.handleErrorResponse(Hr,Wr.method,Zr),qr==null||qr()};return qr=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:Vr,onResetConnection:this.resetAndReload}),new Promise((Zr,Jr)=>{this.relayEventManager.callbacks.set(Hr,Qr=>{if(qr==null||qr(),(0,Web3Response_1$1.isErrorResponse)(Qr))return Jr(new Error(Qr.errorMessage));Zr(Qr)}),this.publishWeb3RequestEvent(Hr,Wr)})}switchEthereumChain(br,wr){const Er={method:"switchEthereumChain",params:Object.assign({chainId:br},{address:wr})},kr=(0,util_2$1.randomBytesHex)(8);return new Promise((jr,Br)=>{this.relayEventManager.callbacks.set(kr,Wr=>{if((0,Web3Response_1$1.isErrorResponse)(Wr)&&Wr.errorCode)return Br(error_1$6.standardErrors.provider.custom({code:Wr.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if((0,Web3Response_1$1.isErrorResponse)(Wr))return Br(new Error(Wr.errorMessage));jr(Wr)}),this.publishWeb3RequestEvent(kr,Er)})}}WalletLinkRelay$1.WalletLinkRelay=WalletLinkRelay;WalletLinkRelay.accountRequestCallbackIds=new Set;var __importDefault$2=commonjsGlobal&&commonjsGlobal.__importDefault||function(fr){return fr&&fr.__esModule?fr:{default:fr}};Object.defineProperty(WalletLinkSigner$1,"__esModule",{value:!0});WalletLinkSigner$1.WalletLinkSigner=void 0;const eth_eip712_util_1=__importDefault$2(ethEip712Util),constants_1$1=constants$1,RelayEventManager_1=RelayEventManager$1,Web3Response_1=Web3Response,WalletLinkRelay_1=WalletLinkRelay$1,constants_2=constants,error_1$5=error,util_1$3=util$6,ScopedLocalStorage_1$3=ScopedLocalStorage$1,DEFAULT_CHAIN_ID_KEY="DefaultChainId",DEFAULT_JSON_RPC_URL="DefaultJsonRpcUrl";class WalletLinkSigner{constructor(br){var wr,Er;this._relay=null,this._addresses=[],this.hasMadeFirstChainChangedEmission=!1;const{appName:kr,appLogoUrl:jr}=br.metadata;this._appName=kr,this._appLogoUrl=jr,this._storage=new ScopedLocalStorage_1$3.ScopedLocalStorage("walletlink",constants_2.WALLETLINK_URL),this.updateListener=br.updateListener,this._relayEventManager=new RelayEventManager_1.RelayEventManager,this._jsonRpcUrlFromOpts="";const Br=this._storage.getItem(constants_1$1.LOCAL_STORAGE_ADDRESSES_KEY);if(Br){const qr=Br.split(" ");qr[0]!==""&&(this._addresses=qr.map(Hr=>(0,util_1$3.ensureAddressString)(Hr)),(wr=this.updateListener)===null||wr===void 0||wr.onAccountsUpdate({accounts:this._addresses,source:"storage"}))}this._storage.getItem(DEFAULT_CHAIN_ID_KEY)&&((Er=this.updateListener)===null||Er===void 0||Er.onChainUpdate({chain:{id:this.getChainId(),rpcUrl:this.jsonRpcUrl},source:"storage"}),this.hasMadeFirstChainChangedEmission=!0),this.initializeRelay()}getSession(){const br=this.initializeRelay(),{id:wr,secret:Er}=br.getWalletLinkSession();return{id:wr,secret:Er}}async handshake(){return await this.request({method:"eth_requestAccounts"})}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var br;return(br=this._storage.getItem(DEFAULT_JSON_RPC_URL))!==null&&br!==void 0?br:this._jsonRpcUrlFromOpts}set jsonRpcUrl(br){this._storage.setItem(DEFAULT_JSON_RPC_URL,br)}updateProviderInfo(br,wr){var Er;this.jsonRpcUrl=br;const kr=this.getChainId();this._storage.setItem(DEFAULT_CHAIN_ID_KEY,wr.toString(10)),((0,util_1$3.ensureIntNumber)(wr)!==kr||!this.hasMadeFirstChainChangedEmission)&&((Er=this.updateListener)===null||Er===void 0||Er.onChainUpdate({chain:{id:wr,rpcUrl:br},source:"wallet"}),this.hasMadeFirstChainChangedEmission=!0)}async watchAsset(br,wr,Er,kr,jr,Br){const qr=await this.initializeRelay().watchAsset(br,wr,Er,kr,jr,Br==null?void 0:Br.toString());return(0,Web3Response_1.isErrorResponse)(qr)?!1:!!qr.result}async addEthereumChain(br,wr,Er,kr,jr,Br){var Wr,qr;if((0,util_1$3.ensureIntNumber)(br)===this.getChainId())return!1;const Hr=this.initializeRelay();this._isAuthorized()||await Hr.requestEthereumAccounts();const Vr=await Hr.addEthereumChain(br.toString(),wr,jr,Er,kr,Br);return(0,Web3Response_1.isErrorResponse)(Vr)?!1:(((Wr=Vr.result)===null||Wr===void 0?void 0:Wr.isApproved)===!0&&this.updateProviderInfo(wr[0],br),((qr=Vr.result)===null||qr===void 0?void 0:qr.isApproved)===!0)}async switchEthereumChain(br){const Er=await this.initializeRelay().switchEthereumChain(br.toString(10),this.selectedAddress||void 0);if((0,Web3Response_1.isErrorResponse)(Er)){if(!Er.errorCode)return;throw Er.errorCode===error_1$5.standardErrorCodes.provider.unsupportedChain?error_1$5.standardErrors.provider.unsupportedChain():error_1$5.standardErrors.provider.custom({message:Er.errorMessage,code:Er.errorCode})}const kr=Er.result;kr.isApproved&&kr.rpcUrl.length>0&&this.updateProviderInfo(kr.rpcUrl,br)}async disconnect(){this._relay&&this._relay.resetAndReload(),this._storage.clear()}async request(br){try{return this._request(br).catch(wr=>{throw wr})}catch(wr){return Promise.reject(wr)}}async _request(br){if(!br||typeof br!="object"||Array.isArray(br))throw error_1$5.standardErrors.rpc.invalidRequest({message:"Expected a single, non-array, object argument.",data:br});const{method:wr,params:Er}=br;if(typeof wr!="string"||wr.length===0)throw error_1$5.standardErrors.rpc.invalidRequest({message:"'args.method' must be a non-empty string.",data:br});if(Er!==void 0&&!Array.isArray(Er)&&(typeof Er!="object"||Er===null))throw error_1$5.standardErrors.rpc.invalidRequest({message:"'args.params' must be an object or array if provided.",data:br});const kr=Er===void 0?[]:Er,jr=this._relayEventManager.makeRequestId();return(await this._sendRequestAsync({method:wr,params:kr,jsonrpc:"2.0",id:jr})).result}_setAddresses(br,wr){var Er;if(!Array.isArray(br))throw new Error("addresses is not an array");const kr=br.map(jr=>(0,util_1$3.ensureAddressString)(jr));JSON.stringify(kr)!==JSON.stringify(this._addresses)&&(this._addresses=kr,(Er=this.updateListener)===null||Er===void 0||Er.onAccountsUpdate({accounts:kr,source:"wallet"}),this._storage.setItem(constants_1$1.LOCAL_STORAGE_ADDRESSES_KEY,kr.join(" ")))}_sendRequestAsync(br){return new Promise((wr,Er)=>{try{const kr=this._handleSynchronousMethods(br);if(kr!==void 0)return wr({jsonrpc:"2.0",id:br.id,result:kr})}catch(kr){return Er(kr)}this._handleAsynchronousMethods(br).then(kr=>kr&&wr(Object.assign(Object.assign({},kr),{id:br.id}))).catch(kr=>Er(kr))})}_handleSynchronousMethods(br){const{method:wr}=br;switch(wr){case"eth_accounts":return this._eth_accounts();case"eth_coinbase":return this._eth_coinbase();case"net_version":return this._net_version();case"eth_chainId":return this._eth_chainId();default:return}}async _handleAsynchronousMethods(br){const{method:wr}=br,Er=br.params||[];switch(wr){case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_sign":return this._eth_sign(Er);case"eth_ecRecover":return this._eth_ecRecover(Er);case"personal_sign":return this._personal_sign(Er);case"personal_ecRecover":return this._personal_ecRecover(Er);case"eth_signTransaction":return this._eth_signTransaction(Er);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(Er);case"eth_sendTransaction":return this._eth_sendTransaction(Er);case"eth_signTypedData_v1":return this._eth_signTypedData_v1(Er);case"eth_signTypedData_v2":return this._throwUnsupportedMethodError();case"eth_signTypedData_v3":return this._eth_signTypedData_v3(Er);case"eth_signTypedData_v4":case"eth_signTypedData":return this._eth_signTypedData_v4(Er);case"wallet_addEthereumChain":return this._wallet_addEthereumChain(Er);case"wallet_switchEthereumChain":return this._wallet_switchEthereumChain(Er);case"wallet_watchAsset":return this._wallet_watchAsset(Er);default:return this._throwUnsupportedMethodError()}}_isKnownAddress(br){try{const wr=(0,util_1$3.ensureAddressString)(br);return this._addresses.map(kr=>(0,util_1$3.ensureAddressString)(kr)).includes(wr)}catch{}return!1}_ensureKnownAddress(br){if(!this._isKnownAddress(br))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(br){const wr=br.from?(0,util_1$3.ensureAddressString)(br.from):this.selectedAddress;if(!wr)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(wr);const Er=br.to?(0,util_1$3.ensureAddressString)(br.to):null,kr=br.value!=null?(0,util_1$3.ensureBigInt)(br.value):BigInt(0),jr=br.data?(0,util_1$3.ensureBuffer)(br.data):Buffer$2.alloc(0),Br=br.nonce!=null?(0,util_1$3.ensureIntNumber)(br.nonce):null,Wr=br.gasPrice!=null?(0,util_1$3.ensureBigInt)(br.gasPrice):null,qr=br.maxFeePerGas!=null?(0,util_1$3.ensureBigInt)(br.maxFeePerGas):null,Hr=br.maxPriorityFeePerGas!=null?(0,util_1$3.ensureBigInt)(br.maxPriorityFeePerGas):null,Vr=br.gas!=null?(0,util_1$3.ensureBigInt)(br.gas):null,Zr=br.chainId?(0,util_1$3.ensureIntNumber)(br.chainId):this.getChainId();return{fromAddress:wr,toAddress:Er,weiValue:kr,data:jr,nonce:Br,gasPriceInWei:Wr,maxFeePerGas:qr,maxPriorityFeePerGas:Hr,gasLimit:Vr,chainId:Zr}}_isAuthorized(){return this._addresses.length>0}_requireAuthorization(){if(!this._isAuthorized())throw error_1$5.standardErrors.provider.unauthorized({})}_throwUnsupportedMethodError(){throw error_1$5.standardErrors.provider.unsupportedMethod({})}async _signEthereumMessage(br,wr,Er,kr){this._ensureKnownAddress(wr);try{const Br=await this.initializeRelay().signEthereumMessage(br,wr,Er,kr);if((0,Web3Response_1.isErrorResponse)(Br))throw new Error(Br.errorMessage);return{jsonrpc:"2.0",id:0,result:Br.result}}catch(jr){throw typeof jr.message=="string"&&jr.message.match(/(denied|rejected)/i)?error_1$5.standardErrors.provider.userRejectedRequest("User denied message signature"):jr}}async _ethereumAddressFromSignedMessage(br,wr,Er){const jr=await this.initializeRelay().ethereumAddressFromSignedMessage(br,wr,Er);if((0,Web3Response_1.isErrorResponse)(jr))throw new Error(jr.errorMessage);return{jsonrpc:"2.0",id:0,result:jr.result}}_eth_accounts(){return[...this._addresses]}_eth_coinbase(){return this.selectedAddress||null}_net_version(){return this.getChainId().toString(10)}_eth_chainId(){return(0,util_1$3.hexStringFromIntNumber)(this.getChainId())}getChainId(){const br=this._storage.getItem(DEFAULT_CHAIN_ID_KEY);if(!br)return(0,util_1$3.ensureIntNumber)(1);const wr=parseInt(br,10);return(0,util_1$3.ensureIntNumber)(wr)}async _eth_requestAccounts(){if(this._isAuthorized())return Promise.resolve({jsonrpc:"2.0",id:0,result:this._addresses});let br;try{if(br=await this.initializeRelay().requestEthereumAccounts(),(0,Web3Response_1.isErrorResponse)(br))throw new Error(br.errorMessage)}catch(wr){throw typeof wr.message=="string"&&wr.message.match(/(denied|rejected)/i)?error_1$5.standardErrors.provider.userRejectedRequest("User denied account authorization"):wr}if(!br.result)throw new Error("accounts received is empty");return this._setAddresses(br.result),{jsonrpc:"2.0",id:0,result:this._addresses}}_eth_sign(br){this._requireAuthorization();const wr=(0,util_1$3.ensureAddressString)(br[0]),Er=(0,util_1$3.ensureBuffer)(br[1]);return this._signEthereumMessage(Er,wr,!1)}_eth_ecRecover(br){const wr=(0,util_1$3.ensureBuffer)(br[0]),Er=(0,util_1$3.ensureBuffer)(br[1]);return this._ethereumAddressFromSignedMessage(wr,Er,!1)}_personal_sign(br){this._requireAuthorization();const wr=(0,util_1$3.ensureBuffer)(br[0]),Er=(0,util_1$3.ensureAddressString)(br[1]);return this._signEthereumMessage(wr,Er,!0)}_personal_ecRecover(br){const wr=(0,util_1$3.ensureBuffer)(br[0]),Er=(0,util_1$3.ensureBuffer)(br[1]);return this._ethereumAddressFromSignedMessage(wr,Er,!0)}async _eth_signTransaction(br){this._requireAuthorization();const wr=this._prepareTransactionParams(br[0]||{});try{const kr=await this.initializeRelay().signEthereumTransaction(wr);if((0,Web3Response_1.isErrorResponse)(kr))throw new Error(kr.errorMessage);return{jsonrpc:"2.0",id:0,result:kr.result}}catch(Er){throw typeof Er.message=="string"&&Er.message.match(/(denied|rejected)/i)?error_1$5.standardErrors.provider.userRejectedRequest("User denied transaction signature"):Er}}async _eth_sendRawTransaction(br){const wr=(0,util_1$3.ensureBuffer)(br[0]),kr=await this.initializeRelay().submitEthereumTransaction(wr,this.getChainId());if((0,Web3Response_1.isErrorResponse)(kr))throw new Error(kr.errorMessage);return{jsonrpc:"2.0",id:0,result:kr.result}}async _eth_sendTransaction(br){this._requireAuthorization();const wr=this._prepareTransactionParams(br[0]||{});try{const kr=await this.initializeRelay().signAndSubmitEthereumTransaction(wr);if((0,Web3Response_1.isErrorResponse)(kr))throw new Error(kr.errorMessage);return{jsonrpc:"2.0",id:0,result:kr.result}}catch(Er){throw typeof Er.message=="string"&&Er.message.match(/(denied|rejected)/i)?error_1$5.standardErrors.provider.userRejectedRequest("User denied transaction signature"):Er}}async _eth_signTypedData_v1(br){this._requireAuthorization();const wr=(0,util_1$3.ensureParsedJSONObject)(br[0]),Er=(0,util_1$3.ensureAddressString)(br[1]);this._ensureKnownAddress(Er);const kr=eth_eip712_util_1.default.hashForSignTypedDataLegacy({data:wr}),jr=JSON.stringify(wr,null,2);return this._signEthereumMessage(kr,Er,!1,jr)}async _eth_signTypedData_v3(br){this._requireAuthorization();const wr=(0,util_1$3.ensureAddressString)(br[0]),Er=(0,util_1$3.ensureParsedJSONObject)(br[1]);this._ensureKnownAddress(wr);const kr=eth_eip712_util_1.default.hashForSignTypedData_v3({data:Er}),jr=JSON.stringify(Er,null,2);return this._signEthereumMessage(kr,wr,!1,jr)}async _eth_signTypedData_v4(br){this._requireAuthorization();const wr=(0,util_1$3.ensureAddressString)(br[0]),Er=(0,util_1$3.ensureParsedJSONObject)(br[1]);this._ensureKnownAddress(wr);const kr=eth_eip712_util_1.default.hashForSignTypedData_v4({data:Er}),jr=JSON.stringify(Er,null,2);return this._signEthereumMessage(kr,wr,!1,jr)}async _wallet_addEthereumChain(br){var wr,Er,kr,jr;const Br=br[0];if(((wr=Br.rpcUrls)===null||wr===void 0?void 0:wr.length)===0)return{jsonrpc:"2.0",id:0,error:{code:2,message:"please pass in at least 1 rpcUrl"}};if(!Br.chainName||Br.chainName.trim()==="")throw error_1$5.standardErrors.rpc.invalidParams("chainName is a required field");if(!Br.nativeCurrency)throw error_1$5.standardErrors.rpc.invalidParams("nativeCurrency is a required field");const Wr=parseInt(Br.chainId,16);return await this.addEthereumChain(Wr,(Er=Br.rpcUrls)!==null&&Er!==void 0?Er:[],(kr=Br.blockExplorerUrls)!==null&&kr!==void 0?kr:[],Br.chainName,(jr=Br.iconUrls)!==null&&jr!==void 0?jr:[],Br.nativeCurrency)?{jsonrpc:"2.0",id:0,result:null}:{jsonrpc:"2.0",id:0,error:{code:2,message:"unable to add ethereum chain"}}}async _wallet_switchEthereumChain(br){const wr=br[0];return await this.switchEthereumChain(parseInt(wr.chainId,16)),{jsonrpc:"2.0",id:0,result:null}}async _wallet_watchAsset(br){const wr=Array.isArray(br)?br[0]:br;if(!wr.type)throw error_1$5.standardErrors.rpc.invalidParams("Type is required");if((wr==null?void 0:wr.type)!=="ERC20")throw error_1$5.standardErrors.rpc.invalidParams(`Asset of type '${wr.type}' is not supported`);if(!(wr!=null&&wr.options))throw error_1$5.standardErrors.rpc.invalidParams("Options are required");if(!(wr!=null&&wr.options.address))throw error_1$5.standardErrors.rpc.invalidParams("Address is required");const Er=this.getChainId(),{address:kr,symbol:jr,image:Br,decimals:Wr}=wr.options;return{jsonrpc:"2.0",id:0,result:await this.watchAsset(wr.type,kr,jr,Wr,Br,Er)}}initializeRelay(){if(!this._relay){const br=new WalletLinkRelay_1.WalletLinkRelay({linkAPIUrl:constants_2.WALLETLINK_URL,storage:this._storage});br.setAppInfo(this._appName,this._appLogoUrl),br.attachUI(),br.setAccountsCallback((wr,Er)=>this._setAddresses(wr,Er)),br.setChainCallback((wr,Er)=>{this.updateProviderInfo(Er,parseInt(wr,10))}),this._relay=br}return this._relay}}WalletLinkSigner$1.WalletLinkSigner=WalletLinkSigner;var provider={};Object.defineProperty(provider,"__esModule",{value:!0});provider.checkErrorForInvalidRequestArgs=provider.getCoinbaseInjectedProvider=provider.getCoinbaseInjectedSigner=provider.fetchRPCRequest=void 0;const version_1$2=version$8,error_1$4=error;async function fetchRPCRequest(fr,br){if(!br.rpcUrl)throw error_1$4.standardErrors.rpc.internal("No RPC URL set for chain");const wr=Object.assign(Object.assign({},fr),{jsonrpc:"2.0",id:crypto.randomUUID()});return(await(await window.fetch(br.rpcUrl,{method:"POST",body:JSON.stringify(wr),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":version_1$2.LIB_VERSION}})).json()).result}provider.fetchRPCRequest=fetchRPCRequest;function getCoinbaseInjectedSigner(){return globalThis.coinbaseWalletSigner}provider.getCoinbaseInjectedSigner=getCoinbaseInjectedSigner;function getCoinbaseInjectedLegacyProvider(){return globalThis.coinbaseWalletExtension}function getInjectedEthereum(){var fr,br;try{const wr=globalThis;return(fr=wr.ethereum)!==null&&fr!==void 0?fr:(br=wr.top)===null||br===void 0?void 0:br.ethereum}catch{return}}function getCoinbaseInjectedProvider({metadata:fr,preference:br}){var wr;if(br.options!=="smartWalletOnly"){if(getCoinbaseInjectedSigner())return;const jr=getCoinbaseInjectedLegacyProvider();if(jr){const{appName:Br,appLogoUrl:Wr,appChainIds:qr}=fr;return(wr=jr.setAppInfo)===null||wr===void 0||wr.call(jr,Br,Wr,qr),jr}}const Er=getInjectedEthereum();if(Er!=null&&Er.isCoinbaseBrowser)return Er}provider.getCoinbaseInjectedProvider=getCoinbaseInjectedProvider;function checkErrorForInvalidRequestArgs(fr){if(!fr||typeof fr!="object"||Array.isArray(fr))return error_1$4.standardErrors.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:fr});const{method:br,params:wr}=fr;if(typeof br!="string"||br.length===0)return error_1$4.standardErrors.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:fr});if(wr!==void 0&&!Array.isArray(wr)&&(typeof wr!="object"||wr===null))return error_1$4.standardErrors.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:fr})}provider.checkErrorForInvalidRequestArgs=checkErrorForInvalidRequestArgs;Object.defineProperty(util$5,"__esModule",{value:!0});util$5.createSigner=util$5.fetchSignerType=util$5.storeSignerType=util$5.loadSignerType=void 0;const SCWSigner_1=SCWSigner$1,WalletLinkSigner_1=WalletLinkSigner$1,error_1$3=error,provider_1$2=provider,ScopedLocalStorage_1$2=ScopedLocalStorage$1,SIGNER_TYPE_KEY="SignerType",storage$1=new ScopedLocalStorage_1$2.ScopedLocalStorage("CBWSDK","SignerConfigurator");function loadSignerType(){return storage$1.getItem(SIGNER_TYPE_KEY)}util$5.loadSignerType=loadSignerType;function storeSignerType(fr){storage$1.setItem(SIGNER_TYPE_KEY,fr)}util$5.storeSignerType=storeSignerType;async function fetchSignerType(fr){const{communicator:br,metadata:wr}=fr;listenForWalletLinkSessionRequest(br,wr).catch(()=>{});const Er={id:crypto.randomUUID(),event:"selectSignerType",data:fr.preference},{data:kr}=await br.postRequestAndWaitForResponse(Er);return kr}util$5.fetchSignerType=fetchSignerType;function createSigner(fr){const{signerType:br,metadata:wr,communicator:Er,updateListener:kr}=fr;switch(br){case"scw":return new SCWSigner_1.SCWSigner({metadata:wr,updateListener:kr,communicator:Er});case"walletlink":return new WalletLinkSigner_1.WalletLinkSigner({metadata:wr,updateListener:kr});case"extension":{const jr=(0,provider_1$2.getCoinbaseInjectedSigner)();if(!jr)throw error_1$3.standardErrors.rpc.internal("injected signer not found");return jr}}}util$5.createSigner=createSigner;async function listenForWalletLinkSessionRequest(fr,br){await fr.onMessage(({event:Er})=>Er==="WalletLinkSessionRequest");const wr=new WalletLinkSigner_1.WalletLinkSigner({metadata:br});fr.postMessage({event:"WalletLinkUpdate",data:{session:wr.getSession()}}),await wr.handshake(),fr.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}var Communicator$1={},util={};Object.defineProperty(util,"__esModule",{value:!0});util.closePopup=util.openPopup=void 0;const error_1$2=error,POPUP_WIDTH=420,POPUP_HEIGHT=540;function openPopup(fr){const br=(window.innerWidth-POPUP_WIDTH)/2+window.screenX,wr=(window.innerHeight-POPUP_HEIGHT)/2+window.screenY,Er=window.open(fr,"Smart Wallet",`width=${POPUP_WIDTH}, height=${POPUP_HEIGHT}, left=${br}, top=${wr}`);if(Er==null||Er.focus(),!Er)throw error_1$2.standardErrors.rpc.internal("Pop up window failed to open");return Er}util.openPopup=openPopup;function closePopup(fr){fr&&!fr.closed&&fr.close()}util.closePopup=closePopup;Object.defineProperty(Communicator$1,"__esModule",{value:!0});Communicator$1.Communicator=void 0;const version_1$1=version$8,util_1$2=util,constants_1=constants,error_1$1=error;class Communicator{constructor(br=constants_1.CB_KEYS_URL){this.popup=null,this.listeners=new Map,this.postMessage=async wr=>{(await this.waitForPopupLoaded()).postMessage(wr,this.url.origin)},this.postRequestAndWaitForResponse=async wr=>{const Er=this.onMessage(({requestId:kr})=>kr===wr.id);return this.postMessage(wr),await Er},this.onMessage=async wr=>new Promise((Er,kr)=>{const jr=Br=>{if(Br.origin!==this.url.origin)return;const Wr=Br.data;wr(Wr)&&(Er(Wr),window.removeEventListener("message",jr),this.listeners.delete(jr))};window.addEventListener("message",jr),this.listeners.set(jr,{reject:kr})}),this.disconnect=()=>{(0,util_1$2.closePopup)(this.popup),this.popup=null,this.listeners.forEach(({reject:wr},Er)=>{wr(error_1$1.standardErrors.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",Er)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(this.popup=(0,util_1$2.openPopup)(this.url),this.onMessage(({event:wr})=>wr==="PopupUnload").then(this.disconnect).catch(()=>{}),this.onMessage(({event:wr})=>wr==="PopupLoaded").then(wr=>{this.postMessage({requestId:wr.id,data:{version:version_1$1.LIB_VERSION}})}).then(()=>{if(!this.popup)throw error_1$1.standardErrors.rpc.internal();return this.popup})),this.url=new URL(br)}}Communicator$1.Communicator=Communicator;var method={};Object.defineProperty(method,"__esModule",{value:!0});method.determineMethodCategory=void 0;const mapping={handshake:["eth_requestAccounts"],sign:["eth_ecRecover","personal_sign","personal_ecRecover","eth_signTransaction","eth_sendTransaction","eth_signTypedData_v1","eth_signTypedData_v3","eth_signTypedData_v4","eth_signTypedData","wallet_addEthereumChain","wallet_switchEthereumChain","wallet_watchAsset","wallet_getCapabilities","wallet_sendCalls","wallet_showCallsStatus"],state:["eth_chainId","eth_accounts","eth_coinbase","net_version"],deprecated:["eth_sign","eth_signTypedData_v2"],unsupported:["eth_subscribe","eth_unsubscribe"],fetch:[]};function determineMethodCategory(fr){for(const br in mapping){const wr=br;if(mapping[wr].includes(fr))return wr}}method.determineMethodCategory=determineMethodCategory;var __rest$2=commonjsGlobal&&commonjsGlobal.__rest||function(fr,br){var wr={};for(var Er in fr)Object.prototype.hasOwnProperty.call(fr,Er)&&br.indexOf(Er)<0&&(wr[Er]=fr[Er]);if(fr!=null&&typeof Object.getOwnPropertySymbols=="function")for(var kr=0,Er=Object.getOwnPropertySymbols(fr);kr{try{if(this.connected)return this.emit("connect",{chainId:(0,util_1$1.hexStringFromIntNumber)((0,type_1.IntNumber)(this.chain.id))}),this.accounts;const Vr=await this.requestSignerSelection(),Zr=this.initSigner(Vr),Jr=await Zr.handshake();return this.signer=Zr,(0,util_2.storeSignerType)(Vr),this.emit("connect",{chainId:(0,util_1$1.hexStringFromIntNumber)((0,type_1.IntNumber)(this.chain.id))}),Jr}catch(Vr){throw this.handleUnauthorizedError(Vr),Vr}},sign:async Hr=>{if(!this.connected||!this.signer)throw error_1.standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods");try{return await this.signer.request(Hr)}catch(Vr){throw this.handleUnauthorizedError(Vr),Vr}},fetch:Hr=>(0,provider_1$1.fetchRPCRequest)(Hr,this.chain),state:Hr=>{const Vr=()=>{if(this.connected)return this.accounts;throw error_1.standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods")};switch(Hr.method){case"eth_chainId":return(0,util_1$1.hexStringFromIntNumber)((0,type_1.IntNumber)(this.chain.id));case"net_version":return this.chain.id;case"eth_accounts":return Vr();case"eth_coinbase":return Vr()[0];default:return this.handlers.unsupported(Hr)}},deprecated:({method:Hr})=>{throw error_1.standardErrors.rpc.methodNotSupported(`Method ${Hr} is deprecated.`)},unsupported:({method:Hr})=>{throw error_1.standardErrors.rpc.methodNotSupported(`Method ${Hr} is not supported.`)}},this.isCoinbaseWallet=!0,this.updateListener={onAccountsUpdate:({accounts:Hr,source:Vr})=>{(0,util_1$1.areAddressArraysEqual)(this.accounts,Hr)||(this.accounts=Hr,Vr!=="storage"&&this.emit("accountsChanged",this.accounts))},onChainUpdate:({chain:Hr,source:Vr})=>{Hr.id===this.chain.id&&Hr.rpcUrl===this.chain.rpcUrl||(this.chain=Hr,Vr!=="storage"&&this.emit("chainChanged",(0,util_1$1.hexStringFromIntNumber)((0,type_1.IntNumber)(Hr.id))))}},this.metadata=kr,this.preference=Wr,this.communicator=new Communicator_1.Communicator(Br),this.chain={id:(Er=(wr=kr.appChainIds)===null||wr===void 0?void 0:wr[0])!==null&&Er!==void 0?Er:1};const qr=(0,util_2.loadSignerType)();this.signer=qr?this.initSigner(qr):null}get connected(){return this.accounts.length>0}async request(br){var wr;try{const Er=(0,provider_1$1.checkErrorForInvalidRequestArgs)(br);if(Er)throw Er;const kr=(wr=(0,method_1.determineMethodCategory)(br.method))!==null&&wr!==void 0?wr:"fetch";return this.handlers[kr](br)}catch(Er){return Promise.reject((0,serialize_1$1.serializeError)(Er,br.method))}}handleUnauthorizedError(br){br.code===error_1.standardErrorCodes.provider.unauthorized&&this.disconnect()}async enable(){return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'),await this.request({method:"eth_requestAccounts"})}async disconnect(){this.accounts=[],this.chain={id:1},ScopedLocalStorage_1$1.ScopedLocalStorage.clearAll(),this.emit("disconnect",error_1.standardErrors.provider.disconnected("User initiated disconnection"))}requestSignerSelection(){return(0,util_2.fetchSignerType)({communicator:this.communicator,preference:this.preference,metadata:this.metadata})}initSigner(br){return(0,util_2.createSigner)({signerType:br,metadata:this.metadata,communicator:this.communicator,updateListener:this.updateListener})}}CoinbaseWalletProvider$1.CoinbaseWalletProvider=CoinbaseWalletProvider;Object.defineProperty(CoinbaseWalletSDK$1,"__esModule",{value:!0});CoinbaseWalletSDK$1.CoinbaseWalletSDK=void 0;const wallet_logo_1=walletLogo$1,CoinbaseWalletProvider_1=CoinbaseWalletProvider$1,ScopedLocalStorage_1=ScopedLocalStorage$1,version_1=version$8,util_1=util$6,provider_1=provider;class CoinbaseWalletSDK{constructor(br){this.metadata={appName:br.appName||"Dapp",appLogoUrl:br.appLogoUrl||(0,util_1.getFavicon)(),appChainIds:br.appChainIds||[]},this.storeLatestVersion()}makeWeb3Provider(br={options:"all"}){var wr;const Er={metadata:this.metadata,preference:br};return(wr=(0,provider_1.getCoinbaseInjectedProvider)(Er))!==null&&wr!==void 0?wr:new CoinbaseWalletProvider_1.CoinbaseWalletProvider(Er)}getCoinbaseWalletLogo(br,wr=240){return(0,wallet_logo_1.walletLogo)(br,wr)}storeLatestVersion(){new ScopedLocalStorage_1.ScopedLocalStorage("CBWSDK").setItem("VERSION",version_1.LIB_VERSION)}}CoinbaseWalletSDK$1.CoinbaseWalletSDK=CoinbaseWalletSDK;(function(fr){Object.defineProperty(fr,"__esModule",{value:!0}),fr.CoinbaseWalletSDK=void 0;const br=CoinbaseWalletSDK$1;fr.default=br.CoinbaseWalletSDK;var wr=CoinbaseWalletSDK$1;Object.defineProperty(fr,"CoinbaseWalletSDK",{enumerable:!0,get:function(){return wr.CoinbaseWalletSDK}})})(dist);let coinbaseProvider;const baseSepolia=84532,baseMainnet=8453,getCoinbaseProvider=({appLogoUrl:fr,appName:br,evmNetworks:wr,walletPreference:Er}={})=>{const kr=wr==null?void 0:wr.map(Wr=>Number(Wr.chainId));return(wr==null?void 0:wr.some(Wr=>Wr.chainId===baseSepolia))&&(kr==null||kr.sort((Wr,qr)=>Wr===baseSepolia?-1:qr===baseSepolia?1:0)),(wr==null?void 0:wr.some(Wr=>Wr.chainId===baseMainnet))&&(kr==null||kr.sort((Wr,qr)=>Wr===baseMainnet?-1:qr===baseMainnet?1:0)),coinbaseProvider||(coinbaseProvider=new dist.CoinbaseWalletSDK({appChainIds:kr,appLogoUrl:fr,appName:br}).makeWeb3Provider({options:Er??"all"})),coinbaseProvider};class Coinbase extends EthereumWalletConnector{constructor(br){var{appName:wr,appLogoUrl:Er,evmNetworks:kr,coinbaseWalletPreference:jr}=br,Br=__rest$6(br,["appName","appLogoUrl","evmNetworks","coinbaseWalletPreference"]);super(Object.assign({evmNetworks:kr},Br)),this.name="Coinbase",this.overrideKey="coinbase",this.supportedChains=["EVM","ETH"],this.connectedChain="EVM",this.canConnectViaQrCode=!1,this.canConnectViaCustodialService=!this.isInstalledOnBrowser(),this.coinbaseProviderOpts={appLogoUrl:Er,appName:wr,evmNetworks:kr,walletPreference:jr}}get coinbaseProvider(){return getCoinbaseProvider(this.coinbaseProviderOpts)}getConnectedAccounts(){return __awaiter$8(this,void 0,void 0,function*(){try{const br=yield this.coinbaseProvider.request({method:"eth_accounts"});return br[0]&&this.setActiveAccount(br[0]),br}catch{return[]}})}isInstalledOnBrowser(){var br;return!!(!((br=window==null?void 0:window.coinbaseWalletExtension)===null||br===void 0)&&br.isCoinbaseWallet)}getAddress(){return __awaiter$8(this,void 0,void 0,function*(){const[br]=yield this.coinbaseProvider.request({method:"eth_requestAccounts"});return this.setActiveAccount(br),br})}signMessage(br){return __awaiter$8(this,void 0,void 0,function*(){const[wr]=yield this.coinbaseProvider.request({method:"eth_requestAccounts"});try{return yield this.coinbaseProvider.request({method:"personal_sign",params:[toHex(toBytes$3(br)),wr.toLowerCase()]})}catch{return}})}setupEventListeners(){const{handleAccountChange:br,handleChainChange:wr,handleDisconnect:Er}=eventListenerHandlers(this);this.coinbaseProvider.on("accountsChanged",br),this.coinbaseProvider.on("chainChanged",wr),this.coinbaseProvider.on("disconnect",Er),this.teardownEventListeners=()=>{this.coinbaseProvider.removeListener("accountsChanged",br),this.coinbaseProvider.removeListener("chainChanged",wr),this.coinbaseProvider.removeListener("disconnect",Er)}}getWalletClient(br){return createWalletClient({account:this.getActiveAccount(),chain:br?chainsMap[br]:void 0,transport:custom(this.coinbaseProvider)})}}assertPackageVersion("@dynamic-labs/ethereum",version$9);const EthereumWalletConnectors=fr=>[...injectedWalletOverrides$1,...fetchInjectedWalletConnector(fr),...fetchWalletConnectWallets(fr),...TurnkeyEVMWalletConnectors(fr),Coinbase,UnknownInjected$1,FallbackEvmConnector,getWalletConnectConnector()];var version$7="3.8.2",version$6="3.8.2";function __awaiter$4(fr,br,wr,Er){function kr(jr){return jr instanceof wr?jr:new wr(function(Br){Br(jr)})}return new(wr||(wr=Promise))(function(jr,Br){function Wr(Vr){try{Hr(Er.next(Vr))}catch(Zr){Br(Zr)}}function qr(Vr){try{Hr(Er.throw(Vr))}catch(Zr){Br(Zr)}}function Hr(Vr){Vr.done?jr(Vr.value):kr(Vr.value).then(Wr,qr)}Hr((Er=Er.apply(fr,[])).next())})}typeof SuppressedError=="function"&&SuppressedError;const U32_MASK64=BigInt(2**32-1),_32n=BigInt(32);function fromBig(fr,br=!1){return br?{h:Number(fr&U32_MASK64),l:Number(fr>>_32n&U32_MASK64)}:{h:Number(fr>>_32n&U32_MASK64)|0,l:Number(fr&U32_MASK64)|0}}function split(fr,br=!1){let wr=new Uint32Array(fr.length),Er=new Uint32Array(fr.length);for(let kr=0;krBigInt(fr>>>0)<<_32n|BigInt(br>>>0),shrSH=(fr,br,wr)=>fr>>>wr,shrSL=(fr,br,wr)=>fr<<32-wr|br>>>wr,rotrSH=(fr,br,wr)=>fr>>>wr|br<<32-wr,rotrSL=(fr,br,wr)=>fr<<32-wr|br>>>wr,rotrBH=(fr,br,wr)=>fr<<64-wr|br>>>wr-32,rotrBL=(fr,br,wr)=>fr>>>wr-32|br<<64-wr,rotr32H=(fr,br)=>br,rotr32L=(fr,br)=>fr,rotlSH=(fr,br,wr)=>fr<>>32-wr,rotlSL=(fr,br,wr)=>br<>>32-wr,rotlBH=(fr,br,wr)=>br<>>64-wr,rotlBL=(fr,br,wr)=>fr<>>64-wr;function add(fr,br,wr,Er){const kr=(br>>>0)+(Er>>>0);return{h:fr+wr+(kr/2**32|0)|0,l:kr|0}}const add3L=(fr,br,wr)=>(fr>>>0)+(br>>>0)+(wr>>>0),add3H=(fr,br,wr,Er)=>br+wr+Er+(fr/2**32|0)|0,add4L=(fr,br,wr,Er)=>(fr>>>0)+(br>>>0)+(wr>>>0)+(Er>>>0),add4H=(fr,br,wr,Er,kr)=>br+wr+Er+kr+(fr/2**32|0)|0,add5L=(fr,br,wr,Er,kr)=>(fr>>>0)+(br>>>0)+(wr>>>0)+(Er>>>0)+(kr>>>0),add5H=(fr,br,wr,Er,kr,jr)=>br+wr+Er+kr+jr+(fr/2**32|0)|0,u64$4={fromBig,split,toBig,shrSH,shrSL,rotrSH,rotrSL,rotrBH,rotrBL,rotr32H,rotr32L,rotlSH,rotlSL,rotlBH,rotlBL,add,add3L,add3H,add4L,add4H,add5H,add5L},[SHA512_Kh,SHA512_Kl]=u64$4.split(["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(fr=>BigInt(fr))),SHA512_W_H=new Uint32Array(80),SHA512_W_L=new Uint32Array(80);class SHA512 extends HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:br,Al:wr,Bh:Er,Bl:kr,Ch:jr,Cl:Br,Dh:Wr,Dl:qr,Eh:Hr,El:Vr,Fh:Zr,Fl:Jr,Gh:Qr,Gl:_n,Hh:En,Hl:Cn}=this;return[br,wr,Er,kr,jr,Br,Wr,qr,Hr,Vr,Zr,Jr,Qr,_n,En,Cn]}set(br,wr,Er,kr,jr,Br,Wr,qr,Hr,Vr,Zr,Jr,Qr,_n,En,Cn){this.Ah=br|0,this.Al=wr|0,this.Bh=Er|0,this.Bl=kr|0,this.Ch=jr|0,this.Cl=Br|0,this.Dh=Wr|0,this.Dl=qr|0,this.Eh=Hr|0,this.El=Vr|0,this.Fh=Zr|0,this.Fl=Jr|0,this.Gh=Qr|0,this.Gl=_n|0,this.Hh=En|0,this.Hl=Cn|0}process(br,wr){for(let jn=0;jn<16;jn++,wr+=4)SHA512_W_H[jn]=br.getUint32(wr),SHA512_W_L[jn]=br.getUint32(wr+=4);for(let jn=16;jn<80;jn++){const eo=SHA512_W_H[jn-15]|0,ro=SHA512_W_L[jn-15]|0,to=u64$4.rotrSH(eo,ro,1)^u64$4.rotrSH(eo,ro,8)^u64$4.shrSH(eo,ro,7),_i=u64$4.rotrSL(eo,ro,1)^u64$4.rotrSL(eo,ro,8)^u64$4.shrSL(eo,ro,7),oo=SHA512_W_H[jn-2]|0,io=SHA512_W_L[jn-2]|0,co=u64$4.rotrSH(oo,io,19)^u64$4.rotrBH(oo,io,61)^u64$4.shrSH(oo,io,6),so=u64$4.rotrSL(oo,io,19)^u64$4.rotrBL(oo,io,61)^u64$4.shrSL(oo,io,6),no=u64$4.add4L(_i,so,SHA512_W_L[jn-7],SHA512_W_L[jn-16]),Tn=u64$4.add4H(no,to,co,SHA512_W_H[jn-7],SHA512_W_H[jn-16]);SHA512_W_H[jn]=Tn|0,SHA512_W_L[jn]=no|0}let{Ah:Er,Al:kr,Bh:jr,Bl:Br,Ch:Wr,Cl:qr,Dh:Hr,Dl:Vr,Eh:Zr,El:Jr,Fh:Qr,Fl:_n,Gh:En,Gl:Cn,Hh:In,Hl:An}=this;for(let jn=0;jn<80;jn++){const eo=u64$4.rotrSH(Zr,Jr,14)^u64$4.rotrSH(Zr,Jr,18)^u64$4.rotrBH(Zr,Jr,41),ro=u64$4.rotrSL(Zr,Jr,14)^u64$4.rotrSL(Zr,Jr,18)^u64$4.rotrBL(Zr,Jr,41),to=Zr&Qr^~Zr&En,_i=Jr&_n^~Jr&Cn,oo=u64$4.add5L(An,ro,_i,SHA512_Kl[jn],SHA512_W_L[jn]),io=u64$4.add5H(oo,In,eo,to,SHA512_Kh[jn],SHA512_W_H[jn]),co=oo|0,so=u64$4.rotrSH(Er,kr,28)^u64$4.rotrBH(Er,kr,34)^u64$4.rotrBH(Er,kr,39),no=u64$4.rotrSL(Er,kr,28)^u64$4.rotrBL(Er,kr,34)^u64$4.rotrBL(Er,kr,39),Tn=Er&jr^Er&Wr^jr&Wr,Gr=kr&Br^kr&qr^Br&qr;In=En|0,An=Cn|0,En=Qr|0,Cn=_n|0,Qr=Zr|0,_n=Jr|0,{h:Zr,l:Jr}=u64$4.add(Hr|0,Vr|0,io|0,co|0),Hr=Wr|0,Vr=qr|0,Wr=jr|0,qr=Br|0,jr=Er|0,Br=kr|0;const Xr=u64$4.add3L(co,no,Gr);Er=u64$4.add3H(Xr,io,so,Tn),kr=Xr|0}({h:Er,l:kr}=u64$4.add(this.Ah|0,this.Al|0,Er|0,kr|0)),{h:jr,l:Br}=u64$4.add(this.Bh|0,this.Bl|0,jr|0,Br|0),{h:Wr,l:qr}=u64$4.add(this.Ch|0,this.Cl|0,Wr|0,qr|0),{h:Hr,l:Vr}=u64$4.add(this.Dh|0,this.Dl|0,Hr|0,Vr|0),{h:Zr,l:Jr}=u64$4.add(this.Eh|0,this.El|0,Zr|0,Jr|0),{h:Qr,l:_n}=u64$4.add(this.Fh|0,this.Fl|0,Qr|0,_n|0),{h:En,l:Cn}=u64$4.add(this.Gh|0,this.Gl|0,En|0,Cn|0),{h:In,l:An}=u64$4.add(this.Hh|0,this.Hl|0,In|0,An|0),this.set(Er,kr,jr,Br,Wr,qr,Hr,Vr,Zr,Jr,Qr,_n,En,Cn,In,An)}roundClean(){SHA512_W_H.fill(0),SHA512_W_L.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const sha512=wrapConstructor(()=>new SHA512);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n=BigInt(0),_1n$1=BigInt(1),_2n$1=BigInt(2),_8n$1=BigInt(8),VERIFY_DEFAULT={zip215:!0};function validateOpts(fr){const br=validateBasic(fr);return validateObject(fr,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...br})}function twistedEdwards(fr){const br=validateOpts(fr),{Fp:wr,n:Er,prehash:kr,hash:jr,randomBytes:Br,nByteLength:Wr,h:qr}=br,Hr=_2n$1<{try{return{isValid:!0,value:wr.sqrt(Sn*wr.inv(Rn))}}catch{return{isValid:!1,value:_0n}}}),Qr=br.adjustScalarBytes||(Sn=>Sn),_n=br.domain||((Sn,Rn,Pn)=>{if(abool("phflag",Pn),Rn.length||Pn)throw new Error("Contexts/pre-hash are not supported");return Sn});function En(Sn,Rn){aInRange("coordinate "+Sn,Rn,_0n,Hr)}function Cn(Sn){if(!(Sn instanceof jn))throw new Error("ExtendedPoint expected")}const In=memoized((Sn,Rn)=>{const{ex:Pn,ey:On,ez:Zn}=Sn,Nn=Sn.is0();Rn==null&&(Rn=Nn?_8n$1:wr.inv(Zn));const wn=Vr(Pn*Rn),zn=Vr(On*Rn),fo=Vr(Zn*Rn);if(Nn)return{x:_0n,y:_1n$1};if(fo!==_1n$1)throw new Error("invZ was invalid");return{x:wn,y:zn}}),An=memoized(Sn=>{const{a:Rn,d:Pn}=br;if(Sn.is0())throw new Error("bad point: ZERO");const{ex:On,ey:Zn,ez:Nn,et:wn}=Sn,zn=Vr(On*On),fo=Vr(Zn*Zn),vo=Vr(Nn*Nn),go=Vr(vo*vo),uo=Vr(zn*Rn),lo=Vr(vo*Vr(uo+fo)),Eo=Vr(go+Vr(Pn*Vr(zn*fo)));if(lo!==Eo)throw new Error("bad point: equation left != right (1)");const mo=Vr(On*Zn),yo=Vr(Nn*wn);if(mo!==yo)throw new Error("bad point: equation left != right (2)");return!0});class jn{constructor(Rn,Pn,On,Zn){this.ex=Rn,this.ey=Pn,this.ez=On,this.et=Zn,En("x",Rn),En("y",Pn),En("z",On),En("t",Zn),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(Rn){if(Rn instanceof jn)throw new Error("extended point not allowed");const{x:Pn,y:On}=Rn||{};return En("x",Pn),En("y",On),new jn(Pn,On,_1n$1,Vr(Pn*On))}static normalizeZ(Rn){const Pn=wr.invertBatch(Rn.map(On=>On.ez));return Rn.map((On,Zn)=>On.toAffine(Pn[Zn])).map(jn.fromAffine)}static msm(Rn,Pn){return pippenger(jn,Zr,Rn,Pn)}_setWindowSize(Rn){to.setWindowSize(this,Rn)}assertValidity(){An(this)}equals(Rn){Cn(Rn);const{ex:Pn,ey:On,ez:Zn}=this,{ex:Nn,ey:wn,ez:zn}=Rn,fo=Vr(Pn*zn),vo=Vr(Nn*Zn),go=Vr(On*zn),uo=Vr(wn*Zn);return fo===vo&&go===uo}is0(){return this.equals(jn.ZERO)}negate(){return new jn(Vr(-this.ex),this.ey,this.ez,Vr(-this.et))}double(){const{a:Rn}=br,{ex:Pn,ey:On,ez:Zn}=this,Nn=Vr(Pn*Pn),wn=Vr(On*On),zn=Vr(_2n$1*Vr(Zn*Zn)),fo=Vr(Rn*Nn),vo=Pn+On,go=Vr(Vr(vo*vo)-Nn-wn),uo=fo+wn,lo=uo-zn,Eo=fo-wn,mo=Vr(go*lo),yo=Vr(uo*Eo),_o=Vr(go*Eo),Bo=Vr(lo*uo);return new jn(mo,yo,Bo,_o)}add(Rn){Cn(Rn);const{a:Pn,d:On}=br,{ex:Zn,ey:Nn,ez:wn,et:zn}=this,{ex:fo,ey:vo,ez:go,et:uo}=Rn;if(Pn===BigInt(-1)){const No=Vr((Nn-Zn)*(vo+fo)),Fo=Vr((Nn+Zn)*(vo-fo)),Nl=Vr(Fo-No);if(Nl===_0n)return this.double();const Vo=Vr(wn*_2n$1*uo),Uo=Vr(zn*_2n$1*go),Ol=Uo+Vo,$a=Fo+No,Jo=Uo-Vo,Zl=Vr(Ol*Nl),Cl=Vr($a*Jo),ko=Vr(Ol*Jo),wo=Vr(Nl*$a);return new jn(Zl,Cl,wo,ko)}const lo=Vr(Zn*fo),Eo=Vr(Nn*vo),mo=Vr(zn*On*uo),yo=Vr(wn*go),_o=Vr((Zn+Nn)*(fo+vo)-lo-Eo),Bo=yo-mo,Lo=yo+mo,Wo=Vr(Eo-Pn*lo),na=Vr(_o*Bo),qo=Vr(Lo*Wo),ga=Vr(_o*Wo),wl=Vr(Bo*Lo);return new jn(na,qo,wl,ga)}subtract(Rn){return this.add(Rn.negate())}wNAF(Rn){return to.wNAFCached(this,Rn,jn.normalizeZ)}multiply(Rn){const Pn=Rn;aInRange("scalar",Pn,_1n$1,Er);const{p:On,f:Zn}=this.wNAF(Pn);return jn.normalizeZ([On,Zn])[0]}multiplyUnsafe(Rn,Pn=jn.ZERO){const On=Rn;return aInRange("scalar",On,_0n,Er),On===_0n?ro:this.is0()||On===_1n$1?this:to.wNAFCachedUnsafe(this,On,jn.normalizeZ,Pn)}isSmallOrder(){return this.multiplyUnsafe(qr).is0()}isTorsionFree(){return to.unsafeLadder(this,Er).is0()}toAffine(Rn){return In(this,Rn)}clearCofactor(){const{h:Rn}=br;return Rn===_1n$1?this:this.multiplyUnsafe(Rn)}static fromHex(Rn,Pn=!1){const{d:On,a:Zn}=br,Nn=wr.BYTES;Rn=ensureBytes("pointHex",Rn,Nn),abool("zip215",Pn);const wn=Rn.slice(),zn=Rn[Nn-1];wn[Nn-1]=zn&-129;const fo=bytesToNumberLE(wn),vo=Pn?Hr:wr.ORDER;aInRange("pointHex.y",fo,_0n,vo);const go=Vr(fo*fo),uo=Vr(go-_1n$1),lo=Vr(On*go-Zn);let{isValid:Eo,value:mo}=Jr(uo,lo);if(!Eo)throw new Error("Point.fromHex: invalid y coordinate");const yo=(mo&_1n$1)===_1n$1,_o=(zn&128)!==0;if(!Pn&&mo===_0n&&_o)throw new Error("Point.fromHex: x=0 and x_0=1");return _o!==yo&&(mo=Vr(-mo)),jn.fromAffine({x:mo,y:fo})}static fromPrivateKey(Rn){return io(Rn).point}toRawBytes(){const{x:Rn,y:Pn}=this.toAffine(),On=numberToBytesLE(Pn,wr.BYTES);return On[On.length-1]|=Rn&_1n$1?128:0,On}toHex(){return bytesToHex(this.toRawBytes())}}jn.BASE=new jn(br.Gx,br.Gy,_1n$1,Vr(br.Gx*br.Gy)),jn.ZERO=new jn(_0n,_1n$1,_1n$1,_0n);const{BASE:eo,ZERO:ro}=jn,to=wNAF(jn,Wr*8);function _i(Sn){return mod(Sn,Er)}function oo(Sn){return _i(bytesToNumberLE(Sn))}function io(Sn){const Rn=wr.BYTES;Sn=ensureBytes("private key",Sn,Rn);const Pn=ensureBytes("hashed private key",jr(Sn),2*Rn),On=Qr(Pn.slice(0,Rn)),Zn=Pn.slice(Rn,2*Rn),Nn=oo(On),wn=eo.multiply(Nn),zn=wn.toRawBytes();return{head:On,prefix:Zn,scalar:Nn,point:wn,pointBytes:zn}}function co(Sn){return io(Sn).pointBytes}function so(Sn=new Uint8Array,...Rn){const Pn=concatBytes(...Rn);return oo(jr(_n(Pn,ensureBytes("context",Sn),!!kr)))}function no(Sn,Rn,Pn={}){Sn=ensureBytes("message",Sn),kr&&(Sn=kr(Sn));const{prefix:On,scalar:Zn,pointBytes:Nn}=io(Rn),wn=so(Pn.context,On,Sn),zn=eo.multiply(wn).toRawBytes(),fo=so(Pn.context,zn,Nn,Sn),vo=_i(wn+fo*Zn);aInRange("signature.s",vo,_0n,Er);const go=concatBytes(zn,numberToBytesLE(vo,wr.BYTES));return ensureBytes("result",go,wr.BYTES*2)}const Tn=VERIFY_DEFAULT;function Gr(Sn,Rn,Pn,On=Tn){const{context:Zn,zip215:Nn}=On,wn=wr.BYTES;Sn=ensureBytes("signature",Sn,2*wn),Rn=ensureBytes("message",Rn),Pn=ensureBytes("publicKey",Pn,wn),Nn!==void 0&&abool("zip215",Nn),kr&&(Rn=kr(Rn));const zn=bytesToNumberLE(Sn.slice(wn,2*wn));let fo,vo,go;try{fo=jn.fromHex(Pn,Nn),vo=jn.fromHex(Sn.slice(0,wn),Nn),go=eo.multiplyUnsafe(zn)}catch{return!1}if(!Nn&&fo.isSmallOrder())return!1;const uo=so(Zn,vo.toRawBytes(),fo.toRawBytes(),Rn);return vo.add(fo.multiplyUnsafe(uo)).subtract(go).clearCofactor().equals(jn.ZERO)}return eo._setWindowSize(8),{CURVE:br,getPublicKey:co,sign:no,verify:Gr,ExtendedPoint:jn,utils:{getExtendedPublicKey:io,randomPrivateKey:()=>Br(wr.BYTES),precompute(Sn=8,Rn=jn.BASE){return Rn._setWindowSize(Sn),Rn.multiply(BigInt(3)),Rn}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ED25519_P=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ED25519_SQRT_M1=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const _1n=BigInt(1),_2n=BigInt(2);BigInt(3);const _5n=BigInt(5),_8n=BigInt(8);function ed25519_pow_2_252_3(fr){const br=BigInt(10),wr=BigInt(20),Er=BigInt(40),kr=BigInt(80),jr=ED25519_P,Wr=fr*fr%jr*fr%jr,qr=pow2(Wr,_2n,jr)*Wr%jr,Hr=pow2(qr,_1n,jr)*fr%jr,Vr=pow2(Hr,_5n,jr)*Hr%jr,Zr=pow2(Vr,br,jr)*Vr%jr,Jr=pow2(Zr,wr,jr)*Zr%jr,Qr=pow2(Jr,Er,jr)*Jr%jr,_n=pow2(Qr,kr,jr)*Qr%jr,En=pow2(_n,kr,jr)*Qr%jr,Cn=pow2(En,br,jr)*Vr%jr;return{pow_p_5_8:pow2(Cn,_2n,jr)*fr%jr,b2:Wr}}function adjustScalarBytes(fr){return fr[0]&=248,fr[31]&=127,fr[31]|=64,fr}function uvRatio(fr,br){const wr=ED25519_P,Er=mod(br*br*br,wr),kr=mod(Er*Er*br,wr),jr=ed25519_pow_2_252_3(fr*kr).pow_p_5_8;let Br=mod(fr*Er*jr,wr);const Wr=mod(br*Br*Br,wr),qr=Br,Hr=mod(Br*ED25519_SQRT_M1,wr),Vr=Wr===fr,Zr=Wr===mod(-fr,wr),Jr=Wr===mod(-fr*ED25519_SQRT_M1,wr);return Vr&&(Br=qr),(Zr||Jr)&&(Br=Hr),isNegativeLE(Br,wr)&&(Br=mod(-Br,wr)),{isValid:Vr||Zr,value:Br}}const Fp=Field(ED25519_P,void 0,!0),ed25519Defaults={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:_8n,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:sha512,randomBytes,adjustScalarBytes,uvRatio},ed25519=twistedEdwards(ed25519Defaults);var bn$3={exports:{}};bn$3.exports;(function(fr){(function(br,wr){function Er(Tn,Gr){if(!Tn)throw new Error(Gr||"Assertion failed")}function kr(Tn,Gr){Tn.super_=Gr;var Xr=function(){};Xr.prototype=Gr.prototype,Tn.prototype=new Xr,Tn.prototype.constructor=Tn}function jr(Tn,Gr,Xr){if(jr.isBN(Tn))return Tn;this.negative=0,this.words=null,this.length=0,this.red=null,Tn!==null&&((Gr==="le"||Gr==="be")&&(Xr=Gr,Gr=10),this._init(Tn||0,Gr||10,Xr||"be"))}typeof br=="object"?br.exports=jr:wr.BN=jr,jr.BN=jr,jr.wordSize=26;var Br;try{typeof window<"u"&&typeof window.Buffer<"u"?Br=window.Buffer:Br=require$$0$9.Buffer}catch{}jr.isBN=function(Gr){return Gr instanceof jr?!0:Gr!==null&&typeof Gr=="object"&&Gr.constructor.wordSize===jr.wordSize&&Array.isArray(Gr.words)},jr.max=function(Gr,Xr){return Gr.cmp(Xr)>0?Gr:Xr},jr.min=function(Gr,Xr){return Gr.cmp(Xr)<0?Gr:Xr},jr.prototype._init=function(Gr,Xr,Sn){if(typeof Gr=="number")return this._initNumber(Gr,Xr,Sn);if(typeof Gr=="object")return this._initArray(Gr,Xr,Sn);Xr==="hex"&&(Xr=16),Er(Xr===(Xr|0)&&Xr>=2&&Xr<=36),Gr=Gr.toString().replace(/\s+/g,"");var Rn=0;Gr[0]==="-"&&(Rn++,this.negative=1),Rn=0;Rn-=3)On=Gr[Rn]|Gr[Rn-1]<<8|Gr[Rn-2]<<16,this.words[Pn]|=On<>>26-Zn&67108863,Zn+=24,Zn>=26&&(Zn-=26,Pn++);else if(Sn==="le")for(Rn=0,Pn=0;Rn>>26-Zn&67108863,Zn+=24,Zn>=26&&(Zn-=26,Pn++);return this._strip()};function Wr(Tn,Gr){var Xr=Tn.charCodeAt(Gr);if(Xr>=48&&Xr<=57)return Xr-48;if(Xr>=65&&Xr<=70)return Xr-55;if(Xr>=97&&Xr<=102)return Xr-87;Er(!1,"Invalid character in "+Tn)}function qr(Tn,Gr,Xr){var Sn=Wr(Tn,Xr);return Xr-1>=Gr&&(Sn|=Wr(Tn,Xr-1)<<4),Sn}jr.prototype._parseHex=function(Gr,Xr,Sn){this.length=Math.ceil((Gr.length-Xr)/6),this.words=new Array(this.length);for(var Rn=0;Rn=Xr;Rn-=2)Zn=qr(Gr,Xr,Rn)<=18?(Pn-=18,On+=1,this.words[On]|=Zn>>>26):Pn+=8;else{var Nn=Gr.length-Xr;for(Rn=Nn%2===0?Xr+1:Xr;Rn=18?(Pn-=18,On+=1,this.words[On]|=Zn>>>26):Pn+=8}this._strip()};function Hr(Tn,Gr,Xr,Sn){for(var Rn=0,Pn=0,On=Math.min(Tn.length,Xr),Zn=Gr;Zn=49?Pn=Nn-49+10:Nn>=17?Pn=Nn-17+10:Pn=Nn,Er(Nn>=0&&Pn1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},jr.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{jr.prototype[Symbol.for("nodejs.util.inspect.custom")]=Zr}catch{jr.prototype.inspect=Zr}else jr.prototype.inspect=Zr;function Zr(){return(this.red?""}var Jr=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],Qr=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],_n=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];jr.prototype.toString=function(Gr,Xr){Gr=Gr||10,Xr=Xr|0||1;var Sn;if(Gr===16||Gr==="hex"){Sn="";for(var Rn=0,Pn=0,On=0;On>>24-Rn&16777215,Rn+=2,Rn>=26&&(Rn-=26,On--),Pn!==0||On!==this.length-1?Sn=Jr[6-Nn.length]+Nn+Sn:Sn=Nn+Sn}for(Pn!==0&&(Sn=Pn.toString(16)+Sn);Sn.length%Xr!==0;)Sn="0"+Sn;return this.negative!==0&&(Sn="-"+Sn),Sn}if(Gr===(Gr|0)&&Gr>=2&&Gr<=36){var wn=Qr[Gr],zn=_n[Gr];Sn="";var fo=this.clone();for(fo.negative=0;!fo.isZero();){var vo=fo.modrn(zn).toString(Gr);fo=fo.idivn(zn),fo.isZero()?Sn=vo+Sn:Sn=Jr[wn-vo.length]+vo+Sn}for(this.isZero()&&(Sn="0"+Sn);Sn.length%Xr!==0;)Sn="0"+Sn;return this.negative!==0&&(Sn="-"+Sn),Sn}Er(!1,"Base should be between 2 and 36")},jr.prototype.toNumber=function(){var Gr=this.words[0];return this.length===2?Gr+=this.words[1]*67108864:this.length===3&&this.words[2]===1?Gr+=4503599627370496+this.words[1]*67108864:this.length>2&&Er(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-Gr:Gr},jr.prototype.toJSON=function(){return this.toString(16,2)},Br&&(jr.prototype.toBuffer=function(Gr,Xr){return this.toArrayLike(Br,Gr,Xr)}),jr.prototype.toArray=function(Gr,Xr){return this.toArrayLike(Array,Gr,Xr)};var En=function(Gr,Xr){return Gr.allocUnsafe?Gr.allocUnsafe(Xr):new Gr(Xr)};jr.prototype.toArrayLike=function(Gr,Xr,Sn){this._strip();var Rn=this.byteLength(),Pn=Sn||Math.max(1,Rn);Er(Rn<=Pn,"byte array longer than desired length"),Er(Pn>0,"Requested array length <= 0");var On=En(Gr,Pn),Zn=Xr==="le"?"LE":"BE";return this["_toArrayLike"+Zn](On,Rn),On},jr.prototype._toArrayLikeLE=function(Gr,Xr){for(var Sn=0,Rn=0,Pn=0,On=0;Pn>8&255),Sn>16&255),On===6?(Sn>24&255),Rn=0,On=0):(Rn=Zn>>>24,On+=2)}if(Sn=0&&(Gr[Sn--]=Zn>>8&255),Sn>=0&&(Gr[Sn--]=Zn>>16&255),On===6?(Sn>=0&&(Gr[Sn--]=Zn>>24&255),Rn=0,On=0):(Rn=Zn>>>24,On+=2)}if(Sn>=0)for(Gr[Sn--]=Rn;Sn>=0;)Gr[Sn--]=0},Math.clz32?jr.prototype._countBits=function(Gr){return 32-Math.clz32(Gr)}:jr.prototype._countBits=function(Gr){var Xr=Gr,Sn=0;return Xr>=4096&&(Sn+=13,Xr>>>=13),Xr>=64&&(Sn+=7,Xr>>>=7),Xr>=8&&(Sn+=4,Xr>>>=4),Xr>=2&&(Sn+=2,Xr>>>=2),Sn+Xr},jr.prototype._zeroBits=function(Gr){if(Gr===0)return 26;var Xr=Gr,Sn=0;return Xr&8191||(Sn+=13,Xr>>>=13),Xr&127||(Sn+=7,Xr>>>=7),Xr&15||(Sn+=4,Xr>>>=4),Xr&3||(Sn+=2,Xr>>>=2),Xr&1||Sn++,Sn},jr.prototype.bitLength=function(){var Gr=this.words[this.length-1],Xr=this._countBits(Gr);return(this.length-1)*26+Xr};function Cn(Tn){for(var Gr=new Array(Tn.bitLength()),Xr=0;Xr>>Rn&1}return Gr}jr.prototype.zeroBits=function(){if(this.isZero())return 0;for(var Gr=0,Xr=0;XrGr.length?this.clone().ior(Gr):Gr.clone().ior(this)},jr.prototype.uor=function(Gr){return this.length>Gr.length?this.clone().iuor(Gr):Gr.clone().iuor(this)},jr.prototype.iuand=function(Gr){var Xr;this.length>Gr.length?Xr=Gr:Xr=this;for(var Sn=0;SnGr.length?this.clone().iand(Gr):Gr.clone().iand(this)},jr.prototype.uand=function(Gr){return this.length>Gr.length?this.clone().iuand(Gr):Gr.clone().iuand(this)},jr.prototype.iuxor=function(Gr){var Xr,Sn;this.length>Gr.length?(Xr=this,Sn=Gr):(Xr=Gr,Sn=this);for(var Rn=0;RnGr.length?this.clone().ixor(Gr):Gr.clone().ixor(this)},jr.prototype.uxor=function(Gr){return this.length>Gr.length?this.clone().iuxor(Gr):Gr.clone().iuxor(this)},jr.prototype.inotn=function(Gr){Er(typeof Gr=="number"&&Gr>=0);var Xr=Math.ceil(Gr/26)|0,Sn=Gr%26;this._expand(Xr),Sn>0&&Xr--;for(var Rn=0;Rn0&&(this.words[Rn]=~this.words[Rn]&67108863>>26-Sn),this._strip()},jr.prototype.notn=function(Gr){return this.clone().inotn(Gr)},jr.prototype.setn=function(Gr,Xr){Er(typeof Gr=="number"&&Gr>=0);var Sn=Gr/26|0,Rn=Gr%26;return this._expand(Sn+1),Xr?this.words[Sn]=this.words[Sn]|1<Gr.length?(Sn=this,Rn=Gr):(Sn=Gr,Rn=this);for(var Pn=0,On=0;On>>26;for(;Pn!==0&&On>>26;if(this.length=Sn.length,Pn!==0)this.words[this.length]=Pn,this.length++;else if(Sn!==this)for(;OnGr.length?this.clone().iadd(Gr):Gr.clone().iadd(this)},jr.prototype.isub=function(Gr){if(Gr.negative!==0){Gr.negative=0;var Xr=this.iadd(Gr);return Gr.negative=1,Xr._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(Gr),this.negative=1,this._normSign();var Sn=this.cmp(Gr);if(Sn===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Rn,Pn;Sn>0?(Rn=this,Pn=Gr):(Rn=Gr,Pn=this);for(var On=0,Zn=0;Zn>26,this.words[Zn]=Xr&67108863;for(;On!==0&&Zn>26,this.words[Zn]=Xr&67108863;if(On===0&&Zn>>26,fo=Nn&67108863,vo=Math.min(wn,Gr.length-1),go=Math.max(0,wn-Tn.length+1);go<=vo;go++){var uo=wn-go|0;Rn=Tn.words[uo]|0,Pn=Gr.words[go]|0,On=Rn*Pn+fo,zn+=On/67108864|0,fo=On&67108863}Xr.words[wn]=fo|0,Nn=zn|0}return Nn!==0?Xr.words[wn]=Nn|0:Xr.length--,Xr._strip()}var An=function(Gr,Xr,Sn){var Rn=Gr.words,Pn=Xr.words,On=Sn.words,Zn=0,Nn,wn,zn,fo=Rn[0]|0,vo=fo&8191,go=fo>>>13,uo=Rn[1]|0,lo=uo&8191,Eo=uo>>>13,mo=Rn[2]|0,yo=mo&8191,_o=mo>>>13,Bo=Rn[3]|0,Lo=Bo&8191,Wo=Bo>>>13,na=Rn[4]|0,qo=na&8191,ga=na>>>13,wl=Rn[5]|0,No=wl&8191,Fo=wl>>>13,Nl=Rn[6]|0,Vo=Nl&8191,Uo=Nl>>>13,Ol=Rn[7]|0,$a=Ol&8191,Jo=Ol>>>13,Zl=Rn[8]|0,Cl=Zl&8191,ko=Zl>>>13,wo=Rn[9]|0,bo=wo&8191,Io=wo>>>13,Ho=Pn[0]|0,Do=Ho&8191,zo=Ho>>>13,nu=Pn[1]|0,Ll=nu&8191,_l=nu>>>13,bu=Pn[2]|0,xl=bu&8191,Tl=bu>>>13,du=Pn[3]|0,Bl=du&8191,Il=du>>>13,Eu=Pn[4]|0,Al=Eu&8191,Ml=Eu>>>13,Tu=Pn[5]|0,Ul=Tu&8191,Sl=Tu>>>13,_u=Pn[6]|0,So=_u&8191,Co=_u>>>13,Ao=Pn[7]|0,po=Ao&8191,Ro=Ao>>>13,Xo=Pn[8]|0,jo=Xo&8191,Ko=Xo>>>13,Wl=Pn[9]|0,$l=Wl&8191,El=Wl>>>13;Sn.negative=Gr.negative^Xr.negative,Sn.length=19,Nn=Math.imul(vo,Do),wn=Math.imul(vo,zo),wn=wn+Math.imul(go,Do)|0,zn=Math.imul(go,zo);var Cu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Cu>>>26)|0,Cu&=67108863,Nn=Math.imul(lo,Do),wn=Math.imul(lo,zo),wn=wn+Math.imul(Eo,Do)|0,zn=Math.imul(Eo,zo),Nn=Nn+Math.imul(vo,Ll)|0,wn=wn+Math.imul(vo,_l)|0,wn=wn+Math.imul(go,Ll)|0,zn=zn+Math.imul(go,_l)|0;var iu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(iu>>>26)|0,iu&=67108863,Nn=Math.imul(yo,Do),wn=Math.imul(yo,zo),wn=wn+Math.imul(_o,Do)|0,zn=Math.imul(_o,zo),Nn=Nn+Math.imul(lo,Ll)|0,wn=wn+Math.imul(lo,_l)|0,wn=wn+Math.imul(Eo,Ll)|0,zn=zn+Math.imul(Eo,_l)|0,Nn=Nn+Math.imul(vo,xl)|0,wn=wn+Math.imul(vo,Tl)|0,wn=wn+Math.imul(go,xl)|0,zn=zn+Math.imul(go,Tl)|0;var pu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(pu>>>26)|0,pu&=67108863,Nn=Math.imul(Lo,Do),wn=Math.imul(Lo,zo),wn=wn+Math.imul(Wo,Do)|0,zn=Math.imul(Wo,zo),Nn=Nn+Math.imul(yo,Ll)|0,wn=wn+Math.imul(yo,_l)|0,wn=wn+Math.imul(_o,Ll)|0,zn=zn+Math.imul(_o,_l)|0,Nn=Nn+Math.imul(lo,xl)|0,wn=wn+Math.imul(lo,Tl)|0,wn=wn+Math.imul(Eo,xl)|0,zn=zn+Math.imul(Eo,Tl)|0,Nn=Nn+Math.imul(vo,Bl)|0,wn=wn+Math.imul(vo,Il)|0,wn=wn+Math.imul(go,Bl)|0,zn=zn+Math.imul(go,Il)|0;var yu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(yu>>>26)|0,yu&=67108863,Nn=Math.imul(qo,Do),wn=Math.imul(qo,zo),wn=wn+Math.imul(ga,Do)|0,zn=Math.imul(ga,zo),Nn=Nn+Math.imul(Lo,Ll)|0,wn=wn+Math.imul(Lo,_l)|0,wn=wn+Math.imul(Wo,Ll)|0,zn=zn+Math.imul(Wo,_l)|0,Nn=Nn+Math.imul(yo,xl)|0,wn=wn+Math.imul(yo,Tl)|0,wn=wn+Math.imul(_o,xl)|0,zn=zn+Math.imul(_o,Tl)|0,Nn=Nn+Math.imul(lo,Bl)|0,wn=wn+Math.imul(lo,Il)|0,wn=wn+Math.imul(Eo,Bl)|0,zn=zn+Math.imul(Eo,Il)|0,Nn=Nn+Math.imul(vo,Al)|0,wn=wn+Math.imul(vo,Ml)|0,wn=wn+Math.imul(go,Al)|0,zn=zn+Math.imul(go,Ml)|0;var hu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(hu>>>26)|0,hu&=67108863,Nn=Math.imul(No,Do),wn=Math.imul(No,zo),wn=wn+Math.imul(Fo,Do)|0,zn=Math.imul(Fo,zo),Nn=Nn+Math.imul(qo,Ll)|0,wn=wn+Math.imul(qo,_l)|0,wn=wn+Math.imul(ga,Ll)|0,zn=zn+Math.imul(ga,_l)|0,Nn=Nn+Math.imul(Lo,xl)|0,wn=wn+Math.imul(Lo,Tl)|0,wn=wn+Math.imul(Wo,xl)|0,zn=zn+Math.imul(Wo,Tl)|0,Nn=Nn+Math.imul(yo,Bl)|0,wn=wn+Math.imul(yo,Il)|0,wn=wn+Math.imul(_o,Bl)|0,zn=zn+Math.imul(_o,Il)|0,Nn=Nn+Math.imul(lo,Al)|0,wn=wn+Math.imul(lo,Ml)|0,wn=wn+Math.imul(Eo,Al)|0,zn=zn+Math.imul(Eo,Ml)|0,Nn=Nn+Math.imul(vo,Ul)|0,wn=wn+Math.imul(vo,Sl)|0,wn=wn+Math.imul(go,Ul)|0,zn=zn+Math.imul(go,Sl)|0;var mu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(mu>>>26)|0,mu&=67108863,Nn=Math.imul(Vo,Do),wn=Math.imul(Vo,zo),wn=wn+Math.imul(Uo,Do)|0,zn=Math.imul(Uo,zo),Nn=Nn+Math.imul(No,Ll)|0,wn=wn+Math.imul(No,_l)|0,wn=wn+Math.imul(Fo,Ll)|0,zn=zn+Math.imul(Fo,_l)|0,Nn=Nn+Math.imul(qo,xl)|0,wn=wn+Math.imul(qo,Tl)|0,wn=wn+Math.imul(ga,xl)|0,zn=zn+Math.imul(ga,Tl)|0,Nn=Nn+Math.imul(Lo,Bl)|0,wn=wn+Math.imul(Lo,Il)|0,wn=wn+Math.imul(Wo,Bl)|0,zn=zn+Math.imul(Wo,Il)|0,Nn=Nn+Math.imul(yo,Al)|0,wn=wn+Math.imul(yo,Ml)|0,wn=wn+Math.imul(_o,Al)|0,zn=zn+Math.imul(_o,Ml)|0,Nn=Nn+Math.imul(lo,Ul)|0,wn=wn+Math.imul(lo,Sl)|0,wn=wn+Math.imul(Eo,Ul)|0,zn=zn+Math.imul(Eo,Sl)|0,Nn=Nn+Math.imul(vo,So)|0,wn=wn+Math.imul(vo,Co)|0,wn=wn+Math.imul(go,So)|0,zn=zn+Math.imul(go,Co)|0;var vu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(vu>>>26)|0,vu&=67108863,Nn=Math.imul($a,Do),wn=Math.imul($a,zo),wn=wn+Math.imul(Jo,Do)|0,zn=Math.imul(Jo,zo),Nn=Nn+Math.imul(Vo,Ll)|0,wn=wn+Math.imul(Vo,_l)|0,wn=wn+Math.imul(Uo,Ll)|0,zn=zn+Math.imul(Uo,_l)|0,Nn=Nn+Math.imul(No,xl)|0,wn=wn+Math.imul(No,Tl)|0,wn=wn+Math.imul(Fo,xl)|0,zn=zn+Math.imul(Fo,Tl)|0,Nn=Nn+Math.imul(qo,Bl)|0,wn=wn+Math.imul(qo,Il)|0,wn=wn+Math.imul(ga,Bl)|0,zn=zn+Math.imul(ga,Il)|0,Nn=Nn+Math.imul(Lo,Al)|0,wn=wn+Math.imul(Lo,Ml)|0,wn=wn+Math.imul(Wo,Al)|0,zn=zn+Math.imul(Wo,Ml)|0,Nn=Nn+Math.imul(yo,Ul)|0,wn=wn+Math.imul(yo,Sl)|0,wn=wn+Math.imul(_o,Ul)|0,zn=zn+Math.imul(_o,Sl)|0,Nn=Nn+Math.imul(lo,So)|0,wn=wn+Math.imul(lo,Co)|0,wn=wn+Math.imul(Eo,So)|0,zn=zn+Math.imul(Eo,Co)|0,Nn=Nn+Math.imul(vo,po)|0,wn=wn+Math.imul(vo,Ro)|0,wn=wn+Math.imul(go,po)|0,zn=zn+Math.imul(go,Ro)|0;var fu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(fu>>>26)|0,fu&=67108863,Nn=Math.imul(Cl,Do),wn=Math.imul(Cl,zo),wn=wn+Math.imul(ko,Do)|0,zn=Math.imul(ko,zo),Nn=Nn+Math.imul($a,Ll)|0,wn=wn+Math.imul($a,_l)|0,wn=wn+Math.imul(Jo,Ll)|0,zn=zn+Math.imul(Jo,_l)|0,Nn=Nn+Math.imul(Vo,xl)|0,wn=wn+Math.imul(Vo,Tl)|0,wn=wn+Math.imul(Uo,xl)|0,zn=zn+Math.imul(Uo,Tl)|0,Nn=Nn+Math.imul(No,Bl)|0,wn=wn+Math.imul(No,Il)|0,wn=wn+Math.imul(Fo,Bl)|0,zn=zn+Math.imul(Fo,Il)|0,Nn=Nn+Math.imul(qo,Al)|0,wn=wn+Math.imul(qo,Ml)|0,wn=wn+Math.imul(ga,Al)|0,zn=zn+Math.imul(ga,Ml)|0,Nn=Nn+Math.imul(Lo,Ul)|0,wn=wn+Math.imul(Lo,Sl)|0,wn=wn+Math.imul(Wo,Ul)|0,zn=zn+Math.imul(Wo,Sl)|0,Nn=Nn+Math.imul(yo,So)|0,wn=wn+Math.imul(yo,Co)|0,wn=wn+Math.imul(_o,So)|0,zn=zn+Math.imul(_o,Co)|0,Nn=Nn+Math.imul(lo,po)|0,wn=wn+Math.imul(lo,Ro)|0,wn=wn+Math.imul(Eo,po)|0,zn=zn+Math.imul(Eo,Ro)|0,Nn=Nn+Math.imul(vo,jo)|0,wn=wn+Math.imul(vo,Ko)|0,wn=wn+Math.imul(go,jo)|0,zn=zn+Math.imul(go,Ko)|0;var gu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(gu>>>26)|0,gu&=67108863,Nn=Math.imul(bo,Do),wn=Math.imul(bo,zo),wn=wn+Math.imul(Io,Do)|0,zn=Math.imul(Io,zo),Nn=Nn+Math.imul(Cl,Ll)|0,wn=wn+Math.imul(Cl,_l)|0,wn=wn+Math.imul(ko,Ll)|0,zn=zn+Math.imul(ko,_l)|0,Nn=Nn+Math.imul($a,xl)|0,wn=wn+Math.imul($a,Tl)|0,wn=wn+Math.imul(Jo,xl)|0,zn=zn+Math.imul(Jo,Tl)|0,Nn=Nn+Math.imul(Vo,Bl)|0,wn=wn+Math.imul(Vo,Il)|0,wn=wn+Math.imul(Uo,Bl)|0,zn=zn+Math.imul(Uo,Il)|0,Nn=Nn+Math.imul(No,Al)|0,wn=wn+Math.imul(No,Ml)|0,wn=wn+Math.imul(Fo,Al)|0,zn=zn+Math.imul(Fo,Ml)|0,Nn=Nn+Math.imul(qo,Ul)|0,wn=wn+Math.imul(qo,Sl)|0,wn=wn+Math.imul(ga,Ul)|0,zn=zn+Math.imul(ga,Sl)|0,Nn=Nn+Math.imul(Lo,So)|0,wn=wn+Math.imul(Lo,Co)|0,wn=wn+Math.imul(Wo,So)|0,zn=zn+Math.imul(Wo,Co)|0,Nn=Nn+Math.imul(yo,po)|0,wn=wn+Math.imul(yo,Ro)|0,wn=wn+Math.imul(_o,po)|0,zn=zn+Math.imul(_o,Ro)|0,Nn=Nn+Math.imul(lo,jo)|0,wn=wn+Math.imul(lo,Ko)|0,wn=wn+Math.imul(Eo,jo)|0,zn=zn+Math.imul(Eo,Ko)|0,Nn=Nn+Math.imul(vo,$l)|0,wn=wn+Math.imul(vo,El)|0,wn=wn+Math.imul(go,$l)|0,zn=zn+Math.imul(go,El)|0;var ou=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(ou>>>26)|0,ou&=67108863,Nn=Math.imul(bo,Ll),wn=Math.imul(bo,_l),wn=wn+Math.imul(Io,Ll)|0,zn=Math.imul(Io,_l),Nn=Nn+Math.imul(Cl,xl)|0,wn=wn+Math.imul(Cl,Tl)|0,wn=wn+Math.imul(ko,xl)|0,zn=zn+Math.imul(ko,Tl)|0,Nn=Nn+Math.imul($a,Bl)|0,wn=wn+Math.imul($a,Il)|0,wn=wn+Math.imul(Jo,Bl)|0,zn=zn+Math.imul(Jo,Il)|0,Nn=Nn+Math.imul(Vo,Al)|0,wn=wn+Math.imul(Vo,Ml)|0,wn=wn+Math.imul(Uo,Al)|0,zn=zn+Math.imul(Uo,Ml)|0,Nn=Nn+Math.imul(No,Ul)|0,wn=wn+Math.imul(No,Sl)|0,wn=wn+Math.imul(Fo,Ul)|0,zn=zn+Math.imul(Fo,Sl)|0,Nn=Nn+Math.imul(qo,So)|0,wn=wn+Math.imul(qo,Co)|0,wn=wn+Math.imul(ga,So)|0,zn=zn+Math.imul(ga,Co)|0,Nn=Nn+Math.imul(Lo,po)|0,wn=wn+Math.imul(Lo,Ro)|0,wn=wn+Math.imul(Wo,po)|0,zn=zn+Math.imul(Wo,Ro)|0,Nn=Nn+Math.imul(yo,jo)|0,wn=wn+Math.imul(yo,Ko)|0,wn=wn+Math.imul(_o,jo)|0,zn=zn+Math.imul(_o,Ko)|0,Nn=Nn+Math.imul(lo,$l)|0,wn=wn+Math.imul(lo,El)|0,wn=wn+Math.imul(Eo,$l)|0,zn=zn+Math.imul(Eo,El)|0;var su=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(su>>>26)|0,su&=67108863,Nn=Math.imul(bo,xl),wn=Math.imul(bo,Tl),wn=wn+Math.imul(Io,xl)|0,zn=Math.imul(Io,Tl),Nn=Nn+Math.imul(Cl,Bl)|0,wn=wn+Math.imul(Cl,Il)|0,wn=wn+Math.imul(ko,Bl)|0,zn=zn+Math.imul(ko,Il)|0,Nn=Nn+Math.imul($a,Al)|0,wn=wn+Math.imul($a,Ml)|0,wn=wn+Math.imul(Jo,Al)|0,zn=zn+Math.imul(Jo,Ml)|0,Nn=Nn+Math.imul(Vo,Ul)|0,wn=wn+Math.imul(Vo,Sl)|0,wn=wn+Math.imul(Uo,Ul)|0,zn=zn+Math.imul(Uo,Sl)|0,Nn=Nn+Math.imul(No,So)|0,wn=wn+Math.imul(No,Co)|0,wn=wn+Math.imul(Fo,So)|0,zn=zn+Math.imul(Fo,Co)|0,Nn=Nn+Math.imul(qo,po)|0,wn=wn+Math.imul(qo,Ro)|0,wn=wn+Math.imul(ga,po)|0,zn=zn+Math.imul(ga,Ro)|0,Nn=Nn+Math.imul(Lo,jo)|0,wn=wn+Math.imul(Lo,Ko)|0,wn=wn+Math.imul(Wo,jo)|0,zn=zn+Math.imul(Wo,Ko)|0,Nn=Nn+Math.imul(yo,$l)|0,wn=wn+Math.imul(yo,El)|0,wn=wn+Math.imul(_o,$l)|0,zn=zn+Math.imul(_o,El)|0;var tu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(tu>>>26)|0,tu&=67108863,Nn=Math.imul(bo,Bl),wn=Math.imul(bo,Il),wn=wn+Math.imul(Io,Bl)|0,zn=Math.imul(Io,Il),Nn=Nn+Math.imul(Cl,Al)|0,wn=wn+Math.imul(Cl,Ml)|0,wn=wn+Math.imul(ko,Al)|0,zn=zn+Math.imul(ko,Ml)|0,Nn=Nn+Math.imul($a,Ul)|0,wn=wn+Math.imul($a,Sl)|0,wn=wn+Math.imul(Jo,Ul)|0,zn=zn+Math.imul(Jo,Sl)|0,Nn=Nn+Math.imul(Vo,So)|0,wn=wn+Math.imul(Vo,Co)|0,wn=wn+Math.imul(Uo,So)|0,zn=zn+Math.imul(Uo,Co)|0,Nn=Nn+Math.imul(No,po)|0,wn=wn+Math.imul(No,Ro)|0,wn=wn+Math.imul(Fo,po)|0,zn=zn+Math.imul(Fo,Ro)|0,Nn=Nn+Math.imul(qo,jo)|0,wn=wn+Math.imul(qo,Ko)|0,wn=wn+Math.imul(ga,jo)|0,zn=zn+Math.imul(ga,Ko)|0,Nn=Nn+Math.imul(Lo,$l)|0,wn=wn+Math.imul(Lo,El)|0,wn=wn+Math.imul(Wo,$l)|0,zn=zn+Math.imul(Wo,El)|0;var zl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(zl>>>26)|0,zl&=67108863,Nn=Math.imul(bo,Al),wn=Math.imul(bo,Ml),wn=wn+Math.imul(Io,Al)|0,zn=Math.imul(Io,Ml),Nn=Nn+Math.imul(Cl,Ul)|0,wn=wn+Math.imul(Cl,Sl)|0,wn=wn+Math.imul(ko,Ul)|0,zn=zn+Math.imul(ko,Sl)|0,Nn=Nn+Math.imul($a,So)|0,wn=wn+Math.imul($a,Co)|0,wn=wn+Math.imul(Jo,So)|0,zn=zn+Math.imul(Jo,Co)|0,Nn=Nn+Math.imul(Vo,po)|0,wn=wn+Math.imul(Vo,Ro)|0,wn=wn+Math.imul(Uo,po)|0,zn=zn+Math.imul(Uo,Ro)|0,Nn=Nn+Math.imul(No,jo)|0,wn=wn+Math.imul(No,Ko)|0,wn=wn+Math.imul(Fo,jo)|0,zn=zn+Math.imul(Fo,Ko)|0,Nn=Nn+Math.imul(qo,$l)|0,wn=wn+Math.imul(qo,El)|0,wn=wn+Math.imul(ga,$l)|0,zn=zn+Math.imul(ga,El)|0;var Gl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Gl>>>26)|0,Gl&=67108863,Nn=Math.imul(bo,Ul),wn=Math.imul(bo,Sl),wn=wn+Math.imul(Io,Ul)|0,zn=Math.imul(Io,Sl),Nn=Nn+Math.imul(Cl,So)|0,wn=wn+Math.imul(Cl,Co)|0,wn=wn+Math.imul(ko,So)|0,zn=zn+Math.imul(ko,Co)|0,Nn=Nn+Math.imul($a,po)|0,wn=wn+Math.imul($a,Ro)|0,wn=wn+Math.imul(Jo,po)|0,zn=zn+Math.imul(Jo,Ro)|0,Nn=Nn+Math.imul(Vo,jo)|0,wn=wn+Math.imul(Vo,Ko)|0,wn=wn+Math.imul(Uo,jo)|0,zn=zn+Math.imul(Uo,Ko)|0,Nn=Nn+Math.imul(No,$l)|0,wn=wn+Math.imul(No,El)|0,wn=wn+Math.imul(Fo,$l)|0,zn=zn+Math.imul(Fo,El)|0;var Jl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Jl>>>26)|0,Jl&=67108863,Nn=Math.imul(bo,So),wn=Math.imul(bo,Co),wn=wn+Math.imul(Io,So)|0,zn=Math.imul(Io,Co),Nn=Nn+Math.imul(Cl,po)|0,wn=wn+Math.imul(Cl,Ro)|0,wn=wn+Math.imul(ko,po)|0,zn=zn+Math.imul(ko,Ro)|0,Nn=Nn+Math.imul($a,jo)|0,wn=wn+Math.imul($a,Ko)|0,wn=wn+Math.imul(Jo,jo)|0,zn=zn+Math.imul(Jo,Ko)|0,Nn=Nn+Math.imul(Vo,$l)|0,wn=wn+Math.imul(Vo,El)|0,wn=wn+Math.imul(Uo,$l)|0,zn=zn+Math.imul(Uo,El)|0;var Pl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Pl>>>26)|0,Pl&=67108863,Nn=Math.imul(bo,po),wn=Math.imul(bo,Ro),wn=wn+Math.imul(Io,po)|0,zn=Math.imul(Io,Ro),Nn=Nn+Math.imul(Cl,jo)|0,wn=wn+Math.imul(Cl,Ko)|0,wn=wn+Math.imul(ko,jo)|0,zn=zn+Math.imul(ko,Ko)|0,Nn=Nn+Math.imul($a,$l)|0,wn=wn+Math.imul($a,El)|0,wn=wn+Math.imul(Jo,$l)|0,zn=zn+Math.imul(Jo,El)|0;var Fl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Fl>>>26)|0,Fl&=67108863,Nn=Math.imul(bo,jo),wn=Math.imul(bo,Ko),wn=wn+Math.imul(Io,jo)|0,zn=Math.imul(Io,Ko),Nn=Nn+Math.imul(Cl,$l)|0,wn=wn+Math.imul(Cl,El)|0,wn=wn+Math.imul(ko,$l)|0,zn=zn+Math.imul(ko,El)|0;var Yl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Yl>>>26)|0,Yl&=67108863,Nn=Math.imul(bo,$l),wn=Math.imul(bo,El),wn=wn+Math.imul(Io,$l)|0,zn=Math.imul(Io,El);var Vl=(Zn+Nn|0)+((wn&8191)<<13)|0;return Zn=(zn+(wn>>>13)|0)+(Vl>>>26)|0,Vl&=67108863,On[0]=Cu,On[1]=iu,On[2]=pu,On[3]=yu,On[4]=hu,On[5]=mu,On[6]=vu,On[7]=fu,On[8]=gu,On[9]=ou,On[10]=su,On[11]=tu,On[12]=zl,On[13]=Gl,On[14]=Jl,On[15]=Pl,On[16]=Fl,On[17]=Yl,On[18]=Vl,Zn!==0&&(On[19]=Zn,Sn.length++),Sn};Math.imul||(An=In);function jn(Tn,Gr,Xr){Xr.negative=Gr.negative^Tn.negative,Xr.length=Tn.length+Gr.length;for(var Sn=0,Rn=0,Pn=0;Pn>>26)|0,Rn+=On>>>26,On&=67108863}Xr.words[Pn]=Zn,Sn=On,On=Rn}return Sn!==0?Xr.words[Pn]=Sn:Xr.length--,Xr._strip()}function eo(Tn,Gr,Xr){return jn(Tn,Gr,Xr)}jr.prototype.mulTo=function(Gr,Xr){var Sn,Rn=this.length+Gr.length;return this.length===10&&Gr.length===10?Sn=An(this,Gr,Xr):Rn<63?Sn=In(this,Gr,Xr):Rn<1024?Sn=jn(this,Gr,Xr):Sn=eo(this,Gr,Xr),Sn},jr.prototype.mul=function(Gr){var Xr=new jr(null);return Xr.words=new Array(this.length+Gr.length),this.mulTo(Gr,Xr)},jr.prototype.mulf=function(Gr){var Xr=new jr(null);return Xr.words=new Array(this.length+Gr.length),eo(this,Gr,Xr)},jr.prototype.imul=function(Gr){return this.clone().mulTo(Gr,this)},jr.prototype.imuln=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(typeof Gr=="number"),Er(Gr<67108864);for(var Sn=0,Rn=0;Rn>=26,Sn+=Pn/67108864|0,Sn+=On>>>26,this.words[Rn]=On&67108863}return Sn!==0&&(this.words[Rn]=Sn,this.length++),Xr?this.ineg():this},jr.prototype.muln=function(Gr){return this.clone().imuln(Gr)},jr.prototype.sqr=function(){return this.mul(this)},jr.prototype.isqr=function(){return this.imul(this.clone())},jr.prototype.pow=function(Gr){var Xr=Cn(Gr);if(Xr.length===0)return new jr(1);for(var Sn=this,Rn=0;Rn=0);var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=67108863>>>26-Xr<<26-Xr,Pn;if(Xr!==0){var On=0;for(Pn=0;Pn>>26-Xr}On&&(this.words[Pn]=On,this.length++)}if(Sn!==0){for(Pn=this.length-1;Pn>=0;Pn--)this.words[Pn+Sn]=this.words[Pn];for(Pn=0;Pn=0);var Rn;Xr?Rn=(Xr-Xr%26)/26:Rn=0;var Pn=Gr%26,On=Math.min((Gr-Pn)/26,this.length),Zn=67108863^67108863>>>Pn<On)for(this.length-=On,wn=0;wn=0&&(zn!==0||wn>=Rn);wn--){var fo=this.words[wn]|0;this.words[wn]=zn<<26-Pn|fo>>>Pn,zn=fo&Zn}return Nn&&zn!==0&&(Nn.words[Nn.length++]=zn),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},jr.prototype.ishrn=function(Gr,Xr,Sn){return Er(this.negative===0),this.iushrn(Gr,Xr,Sn)},jr.prototype.shln=function(Gr){return this.clone().ishln(Gr)},jr.prototype.ushln=function(Gr){return this.clone().iushln(Gr)},jr.prototype.shrn=function(Gr){return this.clone().ishrn(Gr)},jr.prototype.ushrn=function(Gr){return this.clone().iushrn(Gr)},jr.prototype.testn=function(Gr){Er(typeof Gr=="number"&&Gr>=0);var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=1<=0);var Xr=Gr%26,Sn=(Gr-Xr)/26;if(Er(this.negative===0,"imaskn works only with positive numbers"),this.length<=Sn)return this;if(Xr!==0&&Sn++,this.length=Math.min(Sn,this.length),Xr!==0){var Rn=67108863^67108863>>>Xr<=67108864;Xr++)this.words[Xr]-=67108864,Xr===this.length-1?this.words[Xr+1]=1:this.words[Xr+1]++;return this.length=Math.max(this.length,Xr+1),this},jr.prototype.isubn=function(Gr){if(Er(typeof Gr=="number"),Er(Gr<67108864),Gr<0)return this.iaddn(-Gr);if(this.negative!==0)return this.negative=0,this.iaddn(Gr),this.negative=1,this;if(this.words[0]-=Gr,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var Xr=0;Xr>26)-(Nn/67108864|0),this.words[Pn+Sn]=On&67108863}for(;Pn>26,this.words[Pn+Sn]=On&67108863;if(Zn===0)return this._strip();for(Er(Zn===-1),Zn=0,Pn=0;Pn>26,this.words[Pn]=On&67108863;return this.negative=1,this._strip()},jr.prototype._wordDiv=function(Gr,Xr){var Sn=this.length-Gr.length,Rn=this.clone(),Pn=Gr,On=Pn.words[Pn.length-1]|0,Zn=this._countBits(On);Sn=26-Zn,Sn!==0&&(Pn=Pn.ushln(Sn),Rn.iushln(Sn),On=Pn.words[Pn.length-1]|0);var Nn=Rn.length-Pn.length,wn;if(Xr!=="mod"){wn=new jr(null),wn.length=Nn+1,wn.words=new Array(wn.length);for(var zn=0;zn=0;vo--){var go=(Rn.words[Pn.length+vo]|0)*67108864+(Rn.words[Pn.length+vo-1]|0);for(go=Math.min(go/On|0,67108863),Rn._ishlnsubmul(Pn,go,vo);Rn.negative!==0;)go--,Rn.negative=0,Rn._ishlnsubmul(Pn,1,vo),Rn.isZero()||(Rn.negative^=1);wn&&(wn.words[vo]=go)}return wn&&wn._strip(),Rn._strip(),Xr!=="div"&&Sn!==0&&Rn.iushrn(Sn),{div:wn||null,mod:Rn}},jr.prototype.divmod=function(Gr,Xr,Sn){if(Er(!Gr.isZero()),this.isZero())return{div:new jr(0),mod:new jr(0)};var Rn,Pn,On;return this.negative!==0&&Gr.negative===0?(On=this.neg().divmod(Gr,Xr),Xr!=="mod"&&(Rn=On.div.neg()),Xr!=="div"&&(Pn=On.mod.neg(),Sn&&Pn.negative!==0&&Pn.iadd(Gr)),{div:Rn,mod:Pn}):this.negative===0&&Gr.negative!==0?(On=this.divmod(Gr.neg(),Xr),Xr!=="mod"&&(Rn=On.div.neg()),{div:Rn,mod:On.mod}):this.negative&Gr.negative?(On=this.neg().divmod(Gr.neg(),Xr),Xr!=="div"&&(Pn=On.mod.neg(),Sn&&Pn.negative!==0&&Pn.isub(Gr)),{div:On.div,mod:Pn}):Gr.length>this.length||this.cmp(Gr)<0?{div:new jr(0),mod:this}:Gr.length===1?Xr==="div"?{div:this.divn(Gr.words[0]),mod:null}:Xr==="mod"?{div:null,mod:new jr(this.modrn(Gr.words[0]))}:{div:this.divn(Gr.words[0]),mod:new jr(this.modrn(Gr.words[0]))}:this._wordDiv(Gr,Xr)},jr.prototype.div=function(Gr){return this.divmod(Gr,"div",!1).div},jr.prototype.mod=function(Gr){return this.divmod(Gr,"mod",!1).mod},jr.prototype.umod=function(Gr){return this.divmod(Gr,"mod",!0).mod},jr.prototype.divRound=function(Gr){var Xr=this.divmod(Gr);if(Xr.mod.isZero())return Xr.div;var Sn=Xr.div.negative!==0?Xr.mod.isub(Gr):Xr.mod,Rn=Gr.ushrn(1),Pn=Gr.andln(1),On=Sn.cmp(Rn);return On<0||Pn===1&&On===0?Xr.div:Xr.div.negative!==0?Xr.div.isubn(1):Xr.div.iaddn(1)},jr.prototype.modrn=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(Gr<=67108863);for(var Sn=(1<<26)%Gr,Rn=0,Pn=this.length-1;Pn>=0;Pn--)Rn=(Sn*Rn+(this.words[Pn]|0))%Gr;return Xr?-Rn:Rn},jr.prototype.modn=function(Gr){return this.modrn(Gr)},jr.prototype.idivn=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(Gr<=67108863);for(var Sn=0,Rn=this.length-1;Rn>=0;Rn--){var Pn=(this.words[Rn]|0)+Sn*67108864;this.words[Rn]=Pn/Gr|0,Sn=Pn%Gr}return this._strip(),Xr?this.ineg():this},jr.prototype.divn=function(Gr){return this.clone().idivn(Gr)},jr.prototype.egcd=function(Gr){Er(Gr.negative===0),Er(!Gr.isZero());var Xr=this,Sn=Gr.clone();Xr.negative!==0?Xr=Xr.umod(Gr):Xr=Xr.clone();for(var Rn=new jr(1),Pn=new jr(0),On=new jr(0),Zn=new jr(1),Nn=0;Xr.isEven()&&Sn.isEven();)Xr.iushrn(1),Sn.iushrn(1),++Nn;for(var wn=Sn.clone(),zn=Xr.clone();!Xr.isZero();){for(var fo=0,vo=1;!(Xr.words[0]&vo)&&fo<26;++fo,vo<<=1);if(fo>0)for(Xr.iushrn(fo);fo-- >0;)(Rn.isOdd()||Pn.isOdd())&&(Rn.iadd(wn),Pn.isub(zn)),Rn.iushrn(1),Pn.iushrn(1);for(var go=0,uo=1;!(Sn.words[0]&uo)&&go<26;++go,uo<<=1);if(go>0)for(Sn.iushrn(go);go-- >0;)(On.isOdd()||Zn.isOdd())&&(On.iadd(wn),Zn.isub(zn)),On.iushrn(1),Zn.iushrn(1);Xr.cmp(Sn)>=0?(Xr.isub(Sn),Rn.isub(On),Pn.isub(Zn)):(Sn.isub(Xr),On.isub(Rn),Zn.isub(Pn))}return{a:On,b:Zn,gcd:Sn.iushln(Nn)}},jr.prototype._invmp=function(Gr){Er(Gr.negative===0),Er(!Gr.isZero());var Xr=this,Sn=Gr.clone();Xr.negative!==0?Xr=Xr.umod(Gr):Xr=Xr.clone();for(var Rn=new jr(1),Pn=new jr(0),On=Sn.clone();Xr.cmpn(1)>0&&Sn.cmpn(1)>0;){for(var Zn=0,Nn=1;!(Xr.words[0]&Nn)&&Zn<26;++Zn,Nn<<=1);if(Zn>0)for(Xr.iushrn(Zn);Zn-- >0;)Rn.isOdd()&&Rn.iadd(On),Rn.iushrn(1);for(var wn=0,zn=1;!(Sn.words[0]&zn)&&wn<26;++wn,zn<<=1);if(wn>0)for(Sn.iushrn(wn);wn-- >0;)Pn.isOdd()&&Pn.iadd(On),Pn.iushrn(1);Xr.cmp(Sn)>=0?(Xr.isub(Sn),Rn.isub(Pn)):(Sn.isub(Xr),Pn.isub(Rn))}var fo;return Xr.cmpn(1)===0?fo=Rn:fo=Pn,fo.cmpn(0)<0&&fo.iadd(Gr),fo},jr.prototype.gcd=function(Gr){if(this.isZero())return Gr.abs();if(Gr.isZero())return this.abs();var Xr=this.clone(),Sn=Gr.clone();Xr.negative=0,Sn.negative=0;for(var Rn=0;Xr.isEven()&&Sn.isEven();Rn++)Xr.iushrn(1),Sn.iushrn(1);do{for(;Xr.isEven();)Xr.iushrn(1);for(;Sn.isEven();)Sn.iushrn(1);var Pn=Xr.cmp(Sn);if(Pn<0){var On=Xr;Xr=Sn,Sn=On}else if(Pn===0||Sn.cmpn(1)===0)break;Xr.isub(Sn)}while(!0);return Sn.iushln(Rn)},jr.prototype.invm=function(Gr){return this.egcd(Gr).a.umod(Gr)},jr.prototype.isEven=function(){return(this.words[0]&1)===0},jr.prototype.isOdd=function(){return(this.words[0]&1)===1},jr.prototype.andln=function(Gr){return this.words[0]&Gr},jr.prototype.bincn=function(Gr){Er(typeof Gr=="number");var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=1<>>26,Zn&=67108863,this.words[On]=Zn}return Pn!==0&&(this.words[On]=Pn,this.length++),this},jr.prototype.isZero=function(){return this.length===1&&this.words[0]===0},jr.prototype.cmpn=function(Gr){var Xr=Gr<0;if(this.negative!==0&&!Xr)return-1;if(this.negative===0&&Xr)return 1;this._strip();var Sn;if(this.length>1)Sn=1;else{Xr&&(Gr=-Gr),Er(Gr<=67108863,"Number is too big");var Rn=this.words[0]|0;Sn=Rn===Gr?0:RnGr.length)return 1;if(this.length=0;Sn--){var Rn=this.words[Sn]|0,Pn=Gr.words[Sn]|0;if(Rn!==Pn){RnPn&&(Xr=1);break}}return Xr},jr.prototype.gtn=function(Gr){return this.cmpn(Gr)===1},jr.prototype.gt=function(Gr){return this.cmp(Gr)===1},jr.prototype.gten=function(Gr){return this.cmpn(Gr)>=0},jr.prototype.gte=function(Gr){return this.cmp(Gr)>=0},jr.prototype.ltn=function(Gr){return this.cmpn(Gr)===-1},jr.prototype.lt=function(Gr){return this.cmp(Gr)===-1},jr.prototype.lten=function(Gr){return this.cmpn(Gr)<=0},jr.prototype.lte=function(Gr){return this.cmp(Gr)<=0},jr.prototype.eqn=function(Gr){return this.cmpn(Gr)===0},jr.prototype.eq=function(Gr){return this.cmp(Gr)===0},jr.red=function(Gr){return new so(Gr)},jr.prototype.toRed=function(Gr){return Er(!this.red,"Already a number in reduction context"),Er(this.negative===0,"red works only with positives"),Gr.convertTo(this)._forceRed(Gr)},jr.prototype.fromRed=function(){return Er(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},jr.prototype._forceRed=function(Gr){return this.red=Gr,this},jr.prototype.forceRed=function(Gr){return Er(!this.red,"Already a number in reduction context"),this._forceRed(Gr)},jr.prototype.redAdd=function(Gr){return Er(this.red,"redAdd works only with red numbers"),this.red.add(this,Gr)},jr.prototype.redIAdd=function(Gr){return Er(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,Gr)},jr.prototype.redSub=function(Gr){return Er(this.red,"redSub works only with red numbers"),this.red.sub(this,Gr)},jr.prototype.redISub=function(Gr){return Er(this.red,"redISub works only with red numbers"),this.red.isub(this,Gr)},jr.prototype.redShl=function(Gr){return Er(this.red,"redShl works only with red numbers"),this.red.shl(this,Gr)},jr.prototype.redMul=function(Gr){return Er(this.red,"redMul works only with red numbers"),this.red._verify2(this,Gr),this.red.mul(this,Gr)},jr.prototype.redIMul=function(Gr){return Er(this.red,"redMul works only with red numbers"),this.red._verify2(this,Gr),this.red.imul(this,Gr)},jr.prototype.redSqr=function(){return Er(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},jr.prototype.redISqr=function(){return Er(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},jr.prototype.redSqrt=function(){return Er(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},jr.prototype.redInvm=function(){return Er(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},jr.prototype.redNeg=function(){return Er(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},jr.prototype.redPow=function(Gr){return Er(this.red&&!Gr.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,Gr)};var ro={k256:null,p224:null,p192:null,p25519:null};function to(Tn,Gr){this.name=Tn,this.p=new jr(Gr,16),this.n=this.p.bitLength(),this.k=new jr(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}to.prototype._tmp=function(){var Gr=new jr(null);return Gr.words=new Array(Math.ceil(this.n/13)),Gr},to.prototype.ireduce=function(Gr){var Xr=Gr,Sn;do this.split(Xr,this.tmp),Xr=this.imulK(Xr),Xr=Xr.iadd(this.tmp),Sn=Xr.bitLength();while(Sn>this.n);var Rn=Sn0?Xr.isub(this.p):Xr.strip!==void 0?Xr.strip():Xr._strip(),Xr},to.prototype.split=function(Gr,Xr){Gr.iushrn(this.n,0,Xr)},to.prototype.imulK=function(Gr){return Gr.imul(this.k)};function _i(){to.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}kr(_i,to),_i.prototype.split=function(Gr,Xr){for(var Sn=4194303,Rn=Math.min(Gr.length,9),Pn=0;Pn>>22,On=Zn}On>>>=22,Gr.words[Pn-10]=On,On===0&&Gr.length>10?Gr.length-=10:Gr.length-=9},_i.prototype.imulK=function(Gr){Gr.words[Gr.length]=0,Gr.words[Gr.length+1]=0,Gr.length+=2;for(var Xr=0,Sn=0;Sn>>=26,Gr.words[Sn]=Pn,Xr=Rn}return Xr!==0&&(Gr.words[Gr.length++]=Xr),Gr},jr._prime=function(Gr){if(ro[Gr])return ro[Gr];var Xr;if(Gr==="k256")Xr=new _i;else if(Gr==="p224")Xr=new oo;else if(Gr==="p192")Xr=new io;else if(Gr==="p25519")Xr=new co;else throw new Error("Unknown prime "+Gr);return ro[Gr]=Xr,Xr};function so(Tn){if(typeof Tn=="string"){var Gr=jr._prime(Tn);this.m=Gr.p,this.prime=Gr}else Er(Tn.gtn(1),"modulus must be greater than 1"),this.m=Tn,this.prime=null}so.prototype._verify1=function(Gr){Er(Gr.negative===0,"red works only with positives"),Er(Gr.red,"red works only with red numbers")},so.prototype._verify2=function(Gr,Xr){Er((Gr.negative|Xr.negative)===0,"red works only with positives"),Er(Gr.red&&Gr.red===Xr.red,"red works only with red numbers")},so.prototype.imod=function(Gr){return this.prime?this.prime.ireduce(Gr)._forceRed(this):(Vr(Gr,Gr.umod(this.m)._forceRed(this)),Gr)},so.prototype.neg=function(Gr){return Gr.isZero()?Gr.clone():this.m.sub(Gr)._forceRed(this)},so.prototype.add=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.add(Xr);return Sn.cmp(this.m)>=0&&Sn.isub(this.m),Sn._forceRed(this)},so.prototype.iadd=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.iadd(Xr);return Sn.cmp(this.m)>=0&&Sn.isub(this.m),Sn},so.prototype.sub=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.sub(Xr);return Sn.cmpn(0)<0&&Sn.iadd(this.m),Sn._forceRed(this)},so.prototype.isub=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.isub(Xr);return Sn.cmpn(0)<0&&Sn.iadd(this.m),Sn},so.prototype.shl=function(Gr,Xr){return this._verify1(Gr),this.imod(Gr.ushln(Xr))},so.prototype.imul=function(Gr,Xr){return this._verify2(Gr,Xr),this.imod(Gr.imul(Xr))},so.prototype.mul=function(Gr,Xr){return this._verify2(Gr,Xr),this.imod(Gr.mul(Xr))},so.prototype.isqr=function(Gr){return this.imul(Gr,Gr.clone())},so.prototype.sqr=function(Gr){return this.mul(Gr,Gr)},so.prototype.sqrt=function(Gr){if(Gr.isZero())return Gr.clone();var Xr=this.m.andln(3);if(Er(Xr%2===1),Xr===3){var Sn=this.m.add(new jr(1)).iushrn(2);return this.pow(Gr,Sn)}for(var Rn=this.m.subn(1),Pn=0;!Rn.isZero()&&Rn.andln(1)===0;)Pn++,Rn.iushrn(1);Er(!Rn.isZero());var On=new jr(1).toRed(this),Zn=On.redNeg(),Nn=this.m.subn(1).iushrn(1),wn=this.m.bitLength();for(wn=new jr(2*wn*wn).toRed(this);this.pow(wn,Nn).cmp(Zn)!==0;)wn.redIAdd(Zn);for(var zn=this.pow(wn,Rn),fo=this.pow(Gr,Rn.addn(1).iushrn(1)),vo=this.pow(Gr,Rn),go=Pn;vo.cmp(On)!==0;){for(var uo=vo,lo=0;uo.cmp(On)!==0;lo++)uo=uo.redSqr();Er(lo=0;Pn--){for(var zn=Xr.words[Pn],fo=wn-1;fo>=0;fo--){var vo=zn>>fo&1;if(On!==Rn[0]&&(On=this.sqr(On)),vo===0&&Zn===0){Nn=0;continue}Zn<<=1,Zn|=vo,Nn++,!(Nn!==Sn&&(Pn!==0||fo!==0))&&(On=this.mul(On,Rn[Zn]),Nn=0,Zn=0)}wn=26}return On},so.prototype.convertTo=function(Gr){var Xr=Gr.umod(this.m);return Xr===Gr?Xr.clone():Xr},so.prototype.convertFrom=function(Gr){var Xr=Gr.clone();return Xr.red=null,Xr},jr.mont=function(Gr){return new no(Gr)};function no(Tn){so.call(this,Tn),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new jr(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}kr(no,so),no.prototype.convertTo=function(Gr){return this.imod(Gr.ushln(this.shift))},no.prototype.convertFrom=function(Gr){var Xr=this.imod(Gr.mul(this.rinv));return Xr.red=null,Xr},no.prototype.imul=function(Gr,Xr){if(Gr.isZero()||Xr.isZero())return Gr.words[0]=0,Gr.length=1,Gr;var Sn=Gr.imul(Xr),Rn=Sn.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Pn=Sn.isub(Rn).iushrn(this.shift),On=Pn;return Pn.cmp(this.m)>=0?On=Pn.isub(this.m):Pn.cmpn(0)<0&&(On=Pn.iadd(this.m)),On._forceRed(this)},no.prototype.mul=function(Gr,Xr){if(Gr.isZero()||Xr.isZero())return new jr(0)._forceRed(this);var Sn=Gr.mul(Xr),Rn=Sn.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Pn=Sn.isub(Rn).iushrn(this.shift),On=Pn;return Pn.cmp(this.m)>=0?On=Pn.isub(this.m):Pn.cmpn(0)<0&&(On=Pn.iadd(this.m)),On._forceRed(this)},no.prototype.invm=function(Gr){var Xr=this.imod(Gr._invmp(this.m).mul(this.r2));return Xr._forceRed(this)}})(fr,commonjsGlobal)})(bn$3);var bnExports$3=bn$3.exports;const BN$2=getDefaultExportFromCjs$2(bnExports$3);var _Buffer$3=safeBufferExports.Buffer;function base$3(fr){if(fr.length>=255)throw new TypeError("Alphabet too long");for(var br=new Uint8Array(256),wr=0;wr>>0,jn=new Uint8Array(An);Cn!==In;){for(var eo=Qr[Cn],ro=0,to=An-1;(eo!==0||ro>>0,jn[to]=eo%Br>>>0,eo=eo/Br>>>0;if(eo!==0)throw new Error("Non-zero carry");En=ro,Cn++}for(var _i=An-En;_i!==An&&jn[_i]===0;)_i++;for(var oo=Wr.repeat(_n);_i>>0,An=new Uint8Array(In);_n>>0,An[ro]=jn%256>>>0,jn=jn/256>>>0;if(jn!==0)throw new Error("Non-zero carry");Cn=eo,_n++}for(var to=In-Cn;to!==In&&An[to]===0;)to++;var _i=_Buffer$3.allocUnsafe(En+(In-to));_i.fill(0,0,En);for(var oo=En;to!==In;)_i[oo++]=An[to++];return _i}function Jr(Qr){var _n=Zr(Qr);if(_n)return _n;throw new Error("Non-base"+Br+" character")}return{encode:Vr,decodeUnsafe:Zr,decode:Jr}}var src$3=base$3,basex$3=src$3,ALPHABET$3="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",bs58$5=basex$3(ALPHABET$3);const bs58$6=getDefaultExportFromCjs$2(bs58$5);var lib={},bn$2={exports:{}};bn$2.exports;(function(fr){(function(br,wr){function Er(Tn,Gr){if(!Tn)throw new Error(Gr||"Assertion failed")}function kr(Tn,Gr){Tn.super_=Gr;var Xr=function(){};Xr.prototype=Gr.prototype,Tn.prototype=new Xr,Tn.prototype.constructor=Tn}function jr(Tn,Gr,Xr){if(jr.isBN(Tn))return Tn;this.negative=0,this.words=null,this.length=0,this.red=null,Tn!==null&&((Gr==="le"||Gr==="be")&&(Xr=Gr,Gr=10),this._init(Tn||0,Gr||10,Xr||"be"))}typeof br=="object"?br.exports=jr:wr.BN=jr,jr.BN=jr,jr.wordSize=26;var Br;try{typeof window<"u"&&typeof window.Buffer<"u"?Br=window.Buffer:Br=require$$0$9.Buffer}catch{}jr.isBN=function(Gr){return Gr instanceof jr?!0:Gr!==null&&typeof Gr=="object"&&Gr.constructor.wordSize===jr.wordSize&&Array.isArray(Gr.words)},jr.max=function(Gr,Xr){return Gr.cmp(Xr)>0?Gr:Xr},jr.min=function(Gr,Xr){return Gr.cmp(Xr)<0?Gr:Xr},jr.prototype._init=function(Gr,Xr,Sn){if(typeof Gr=="number")return this._initNumber(Gr,Xr,Sn);if(typeof Gr=="object")return this._initArray(Gr,Xr,Sn);Xr==="hex"&&(Xr=16),Er(Xr===(Xr|0)&&Xr>=2&&Xr<=36),Gr=Gr.toString().replace(/\s+/g,"");var Rn=0;Gr[0]==="-"&&(Rn++,this.negative=1),Rn=0;Rn-=3)On=Gr[Rn]|Gr[Rn-1]<<8|Gr[Rn-2]<<16,this.words[Pn]|=On<>>26-Zn&67108863,Zn+=24,Zn>=26&&(Zn-=26,Pn++);else if(Sn==="le")for(Rn=0,Pn=0;Rn>>26-Zn&67108863,Zn+=24,Zn>=26&&(Zn-=26,Pn++);return this._strip()};function Wr(Tn,Gr){var Xr=Tn.charCodeAt(Gr);if(Xr>=48&&Xr<=57)return Xr-48;if(Xr>=65&&Xr<=70)return Xr-55;if(Xr>=97&&Xr<=102)return Xr-87;Er(!1,"Invalid character in "+Tn)}function qr(Tn,Gr,Xr){var Sn=Wr(Tn,Xr);return Xr-1>=Gr&&(Sn|=Wr(Tn,Xr-1)<<4),Sn}jr.prototype._parseHex=function(Gr,Xr,Sn){this.length=Math.ceil((Gr.length-Xr)/6),this.words=new Array(this.length);for(var Rn=0;Rn=Xr;Rn-=2)Zn=qr(Gr,Xr,Rn)<=18?(Pn-=18,On+=1,this.words[On]|=Zn>>>26):Pn+=8;else{var Nn=Gr.length-Xr;for(Rn=Nn%2===0?Xr+1:Xr;Rn=18?(Pn-=18,On+=1,this.words[On]|=Zn>>>26):Pn+=8}this._strip()};function Hr(Tn,Gr,Xr,Sn){for(var Rn=0,Pn=0,On=Math.min(Tn.length,Xr),Zn=Gr;Zn=49?Pn=Nn-49+10:Nn>=17?Pn=Nn-17+10:Pn=Nn,Er(Nn>=0&&Pn1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},jr.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{jr.prototype[Symbol.for("nodejs.util.inspect.custom")]=Zr}catch{jr.prototype.inspect=Zr}else jr.prototype.inspect=Zr;function Zr(){return(this.red?""}var Jr=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],Qr=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],_n=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];jr.prototype.toString=function(Gr,Xr){Gr=Gr||10,Xr=Xr|0||1;var Sn;if(Gr===16||Gr==="hex"){Sn="";for(var Rn=0,Pn=0,On=0;On>>24-Rn&16777215,Rn+=2,Rn>=26&&(Rn-=26,On--),Pn!==0||On!==this.length-1?Sn=Jr[6-Nn.length]+Nn+Sn:Sn=Nn+Sn}for(Pn!==0&&(Sn=Pn.toString(16)+Sn);Sn.length%Xr!==0;)Sn="0"+Sn;return this.negative!==0&&(Sn="-"+Sn),Sn}if(Gr===(Gr|0)&&Gr>=2&&Gr<=36){var wn=Qr[Gr],zn=_n[Gr];Sn="";var fo=this.clone();for(fo.negative=0;!fo.isZero();){var vo=fo.modrn(zn).toString(Gr);fo=fo.idivn(zn),fo.isZero()?Sn=vo+Sn:Sn=Jr[wn-vo.length]+vo+Sn}for(this.isZero()&&(Sn="0"+Sn);Sn.length%Xr!==0;)Sn="0"+Sn;return this.negative!==0&&(Sn="-"+Sn),Sn}Er(!1,"Base should be between 2 and 36")},jr.prototype.toNumber=function(){var Gr=this.words[0];return this.length===2?Gr+=this.words[1]*67108864:this.length===3&&this.words[2]===1?Gr+=4503599627370496+this.words[1]*67108864:this.length>2&&Er(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-Gr:Gr},jr.prototype.toJSON=function(){return this.toString(16,2)},Br&&(jr.prototype.toBuffer=function(Gr,Xr){return this.toArrayLike(Br,Gr,Xr)}),jr.prototype.toArray=function(Gr,Xr){return this.toArrayLike(Array,Gr,Xr)};var En=function(Gr,Xr){return Gr.allocUnsafe?Gr.allocUnsafe(Xr):new Gr(Xr)};jr.prototype.toArrayLike=function(Gr,Xr,Sn){this._strip();var Rn=this.byteLength(),Pn=Sn||Math.max(1,Rn);Er(Rn<=Pn,"byte array longer than desired length"),Er(Pn>0,"Requested array length <= 0");var On=En(Gr,Pn),Zn=Xr==="le"?"LE":"BE";return this["_toArrayLike"+Zn](On,Rn),On},jr.prototype._toArrayLikeLE=function(Gr,Xr){for(var Sn=0,Rn=0,Pn=0,On=0;Pn>8&255),Sn>16&255),On===6?(Sn>24&255),Rn=0,On=0):(Rn=Zn>>>24,On+=2)}if(Sn=0&&(Gr[Sn--]=Zn>>8&255),Sn>=0&&(Gr[Sn--]=Zn>>16&255),On===6?(Sn>=0&&(Gr[Sn--]=Zn>>24&255),Rn=0,On=0):(Rn=Zn>>>24,On+=2)}if(Sn>=0)for(Gr[Sn--]=Rn;Sn>=0;)Gr[Sn--]=0},Math.clz32?jr.prototype._countBits=function(Gr){return 32-Math.clz32(Gr)}:jr.prototype._countBits=function(Gr){var Xr=Gr,Sn=0;return Xr>=4096&&(Sn+=13,Xr>>>=13),Xr>=64&&(Sn+=7,Xr>>>=7),Xr>=8&&(Sn+=4,Xr>>>=4),Xr>=2&&(Sn+=2,Xr>>>=2),Sn+Xr},jr.prototype._zeroBits=function(Gr){if(Gr===0)return 26;var Xr=Gr,Sn=0;return Xr&8191||(Sn+=13,Xr>>>=13),Xr&127||(Sn+=7,Xr>>>=7),Xr&15||(Sn+=4,Xr>>>=4),Xr&3||(Sn+=2,Xr>>>=2),Xr&1||Sn++,Sn},jr.prototype.bitLength=function(){var Gr=this.words[this.length-1],Xr=this._countBits(Gr);return(this.length-1)*26+Xr};function Cn(Tn){for(var Gr=new Array(Tn.bitLength()),Xr=0;Xr>>Rn&1}return Gr}jr.prototype.zeroBits=function(){if(this.isZero())return 0;for(var Gr=0,Xr=0;XrGr.length?this.clone().ior(Gr):Gr.clone().ior(this)},jr.prototype.uor=function(Gr){return this.length>Gr.length?this.clone().iuor(Gr):Gr.clone().iuor(this)},jr.prototype.iuand=function(Gr){var Xr;this.length>Gr.length?Xr=Gr:Xr=this;for(var Sn=0;SnGr.length?this.clone().iand(Gr):Gr.clone().iand(this)},jr.prototype.uand=function(Gr){return this.length>Gr.length?this.clone().iuand(Gr):Gr.clone().iuand(this)},jr.prototype.iuxor=function(Gr){var Xr,Sn;this.length>Gr.length?(Xr=this,Sn=Gr):(Xr=Gr,Sn=this);for(var Rn=0;RnGr.length?this.clone().ixor(Gr):Gr.clone().ixor(this)},jr.prototype.uxor=function(Gr){return this.length>Gr.length?this.clone().iuxor(Gr):Gr.clone().iuxor(this)},jr.prototype.inotn=function(Gr){Er(typeof Gr=="number"&&Gr>=0);var Xr=Math.ceil(Gr/26)|0,Sn=Gr%26;this._expand(Xr),Sn>0&&Xr--;for(var Rn=0;Rn0&&(this.words[Rn]=~this.words[Rn]&67108863>>26-Sn),this._strip()},jr.prototype.notn=function(Gr){return this.clone().inotn(Gr)},jr.prototype.setn=function(Gr,Xr){Er(typeof Gr=="number"&&Gr>=0);var Sn=Gr/26|0,Rn=Gr%26;return this._expand(Sn+1),Xr?this.words[Sn]=this.words[Sn]|1<Gr.length?(Sn=this,Rn=Gr):(Sn=Gr,Rn=this);for(var Pn=0,On=0;On>>26;for(;Pn!==0&&On>>26;if(this.length=Sn.length,Pn!==0)this.words[this.length]=Pn,this.length++;else if(Sn!==this)for(;OnGr.length?this.clone().iadd(Gr):Gr.clone().iadd(this)},jr.prototype.isub=function(Gr){if(Gr.negative!==0){Gr.negative=0;var Xr=this.iadd(Gr);return Gr.negative=1,Xr._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(Gr),this.negative=1,this._normSign();var Sn=this.cmp(Gr);if(Sn===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Rn,Pn;Sn>0?(Rn=this,Pn=Gr):(Rn=Gr,Pn=this);for(var On=0,Zn=0;Zn>26,this.words[Zn]=Xr&67108863;for(;On!==0&&Zn>26,this.words[Zn]=Xr&67108863;if(On===0&&Zn>>26,fo=Nn&67108863,vo=Math.min(wn,Gr.length-1),go=Math.max(0,wn-Tn.length+1);go<=vo;go++){var uo=wn-go|0;Rn=Tn.words[uo]|0,Pn=Gr.words[go]|0,On=Rn*Pn+fo,zn+=On/67108864|0,fo=On&67108863}Xr.words[wn]=fo|0,Nn=zn|0}return Nn!==0?Xr.words[wn]=Nn|0:Xr.length--,Xr._strip()}var An=function(Gr,Xr,Sn){var Rn=Gr.words,Pn=Xr.words,On=Sn.words,Zn=0,Nn,wn,zn,fo=Rn[0]|0,vo=fo&8191,go=fo>>>13,uo=Rn[1]|0,lo=uo&8191,Eo=uo>>>13,mo=Rn[2]|0,yo=mo&8191,_o=mo>>>13,Bo=Rn[3]|0,Lo=Bo&8191,Wo=Bo>>>13,na=Rn[4]|0,qo=na&8191,ga=na>>>13,wl=Rn[5]|0,No=wl&8191,Fo=wl>>>13,Nl=Rn[6]|0,Vo=Nl&8191,Uo=Nl>>>13,Ol=Rn[7]|0,$a=Ol&8191,Jo=Ol>>>13,Zl=Rn[8]|0,Cl=Zl&8191,ko=Zl>>>13,wo=Rn[9]|0,bo=wo&8191,Io=wo>>>13,Ho=Pn[0]|0,Do=Ho&8191,zo=Ho>>>13,nu=Pn[1]|0,Ll=nu&8191,_l=nu>>>13,bu=Pn[2]|0,xl=bu&8191,Tl=bu>>>13,du=Pn[3]|0,Bl=du&8191,Il=du>>>13,Eu=Pn[4]|0,Al=Eu&8191,Ml=Eu>>>13,Tu=Pn[5]|0,Ul=Tu&8191,Sl=Tu>>>13,_u=Pn[6]|0,So=_u&8191,Co=_u>>>13,Ao=Pn[7]|0,po=Ao&8191,Ro=Ao>>>13,Xo=Pn[8]|0,jo=Xo&8191,Ko=Xo>>>13,Wl=Pn[9]|0,$l=Wl&8191,El=Wl>>>13;Sn.negative=Gr.negative^Xr.negative,Sn.length=19,Nn=Math.imul(vo,Do),wn=Math.imul(vo,zo),wn=wn+Math.imul(go,Do)|0,zn=Math.imul(go,zo);var Cu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Cu>>>26)|0,Cu&=67108863,Nn=Math.imul(lo,Do),wn=Math.imul(lo,zo),wn=wn+Math.imul(Eo,Do)|0,zn=Math.imul(Eo,zo),Nn=Nn+Math.imul(vo,Ll)|0,wn=wn+Math.imul(vo,_l)|0,wn=wn+Math.imul(go,Ll)|0,zn=zn+Math.imul(go,_l)|0;var iu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(iu>>>26)|0,iu&=67108863,Nn=Math.imul(yo,Do),wn=Math.imul(yo,zo),wn=wn+Math.imul(_o,Do)|0,zn=Math.imul(_o,zo),Nn=Nn+Math.imul(lo,Ll)|0,wn=wn+Math.imul(lo,_l)|0,wn=wn+Math.imul(Eo,Ll)|0,zn=zn+Math.imul(Eo,_l)|0,Nn=Nn+Math.imul(vo,xl)|0,wn=wn+Math.imul(vo,Tl)|0,wn=wn+Math.imul(go,xl)|0,zn=zn+Math.imul(go,Tl)|0;var pu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(pu>>>26)|0,pu&=67108863,Nn=Math.imul(Lo,Do),wn=Math.imul(Lo,zo),wn=wn+Math.imul(Wo,Do)|0,zn=Math.imul(Wo,zo),Nn=Nn+Math.imul(yo,Ll)|0,wn=wn+Math.imul(yo,_l)|0,wn=wn+Math.imul(_o,Ll)|0,zn=zn+Math.imul(_o,_l)|0,Nn=Nn+Math.imul(lo,xl)|0,wn=wn+Math.imul(lo,Tl)|0,wn=wn+Math.imul(Eo,xl)|0,zn=zn+Math.imul(Eo,Tl)|0,Nn=Nn+Math.imul(vo,Bl)|0,wn=wn+Math.imul(vo,Il)|0,wn=wn+Math.imul(go,Bl)|0,zn=zn+Math.imul(go,Il)|0;var yu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(yu>>>26)|0,yu&=67108863,Nn=Math.imul(qo,Do),wn=Math.imul(qo,zo),wn=wn+Math.imul(ga,Do)|0,zn=Math.imul(ga,zo),Nn=Nn+Math.imul(Lo,Ll)|0,wn=wn+Math.imul(Lo,_l)|0,wn=wn+Math.imul(Wo,Ll)|0,zn=zn+Math.imul(Wo,_l)|0,Nn=Nn+Math.imul(yo,xl)|0,wn=wn+Math.imul(yo,Tl)|0,wn=wn+Math.imul(_o,xl)|0,zn=zn+Math.imul(_o,Tl)|0,Nn=Nn+Math.imul(lo,Bl)|0,wn=wn+Math.imul(lo,Il)|0,wn=wn+Math.imul(Eo,Bl)|0,zn=zn+Math.imul(Eo,Il)|0,Nn=Nn+Math.imul(vo,Al)|0,wn=wn+Math.imul(vo,Ml)|0,wn=wn+Math.imul(go,Al)|0,zn=zn+Math.imul(go,Ml)|0;var hu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(hu>>>26)|0,hu&=67108863,Nn=Math.imul(No,Do),wn=Math.imul(No,zo),wn=wn+Math.imul(Fo,Do)|0,zn=Math.imul(Fo,zo),Nn=Nn+Math.imul(qo,Ll)|0,wn=wn+Math.imul(qo,_l)|0,wn=wn+Math.imul(ga,Ll)|0,zn=zn+Math.imul(ga,_l)|0,Nn=Nn+Math.imul(Lo,xl)|0,wn=wn+Math.imul(Lo,Tl)|0,wn=wn+Math.imul(Wo,xl)|0,zn=zn+Math.imul(Wo,Tl)|0,Nn=Nn+Math.imul(yo,Bl)|0,wn=wn+Math.imul(yo,Il)|0,wn=wn+Math.imul(_o,Bl)|0,zn=zn+Math.imul(_o,Il)|0,Nn=Nn+Math.imul(lo,Al)|0,wn=wn+Math.imul(lo,Ml)|0,wn=wn+Math.imul(Eo,Al)|0,zn=zn+Math.imul(Eo,Ml)|0,Nn=Nn+Math.imul(vo,Ul)|0,wn=wn+Math.imul(vo,Sl)|0,wn=wn+Math.imul(go,Ul)|0,zn=zn+Math.imul(go,Sl)|0;var mu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(mu>>>26)|0,mu&=67108863,Nn=Math.imul(Vo,Do),wn=Math.imul(Vo,zo),wn=wn+Math.imul(Uo,Do)|0,zn=Math.imul(Uo,zo),Nn=Nn+Math.imul(No,Ll)|0,wn=wn+Math.imul(No,_l)|0,wn=wn+Math.imul(Fo,Ll)|0,zn=zn+Math.imul(Fo,_l)|0,Nn=Nn+Math.imul(qo,xl)|0,wn=wn+Math.imul(qo,Tl)|0,wn=wn+Math.imul(ga,xl)|0,zn=zn+Math.imul(ga,Tl)|0,Nn=Nn+Math.imul(Lo,Bl)|0,wn=wn+Math.imul(Lo,Il)|0,wn=wn+Math.imul(Wo,Bl)|0,zn=zn+Math.imul(Wo,Il)|0,Nn=Nn+Math.imul(yo,Al)|0,wn=wn+Math.imul(yo,Ml)|0,wn=wn+Math.imul(_o,Al)|0,zn=zn+Math.imul(_o,Ml)|0,Nn=Nn+Math.imul(lo,Ul)|0,wn=wn+Math.imul(lo,Sl)|0,wn=wn+Math.imul(Eo,Ul)|0,zn=zn+Math.imul(Eo,Sl)|0,Nn=Nn+Math.imul(vo,So)|0,wn=wn+Math.imul(vo,Co)|0,wn=wn+Math.imul(go,So)|0,zn=zn+Math.imul(go,Co)|0;var vu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(vu>>>26)|0,vu&=67108863,Nn=Math.imul($a,Do),wn=Math.imul($a,zo),wn=wn+Math.imul(Jo,Do)|0,zn=Math.imul(Jo,zo),Nn=Nn+Math.imul(Vo,Ll)|0,wn=wn+Math.imul(Vo,_l)|0,wn=wn+Math.imul(Uo,Ll)|0,zn=zn+Math.imul(Uo,_l)|0,Nn=Nn+Math.imul(No,xl)|0,wn=wn+Math.imul(No,Tl)|0,wn=wn+Math.imul(Fo,xl)|0,zn=zn+Math.imul(Fo,Tl)|0,Nn=Nn+Math.imul(qo,Bl)|0,wn=wn+Math.imul(qo,Il)|0,wn=wn+Math.imul(ga,Bl)|0,zn=zn+Math.imul(ga,Il)|0,Nn=Nn+Math.imul(Lo,Al)|0,wn=wn+Math.imul(Lo,Ml)|0,wn=wn+Math.imul(Wo,Al)|0,zn=zn+Math.imul(Wo,Ml)|0,Nn=Nn+Math.imul(yo,Ul)|0,wn=wn+Math.imul(yo,Sl)|0,wn=wn+Math.imul(_o,Ul)|0,zn=zn+Math.imul(_o,Sl)|0,Nn=Nn+Math.imul(lo,So)|0,wn=wn+Math.imul(lo,Co)|0,wn=wn+Math.imul(Eo,So)|0,zn=zn+Math.imul(Eo,Co)|0,Nn=Nn+Math.imul(vo,po)|0,wn=wn+Math.imul(vo,Ro)|0,wn=wn+Math.imul(go,po)|0,zn=zn+Math.imul(go,Ro)|0;var fu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(fu>>>26)|0,fu&=67108863,Nn=Math.imul(Cl,Do),wn=Math.imul(Cl,zo),wn=wn+Math.imul(ko,Do)|0,zn=Math.imul(ko,zo),Nn=Nn+Math.imul($a,Ll)|0,wn=wn+Math.imul($a,_l)|0,wn=wn+Math.imul(Jo,Ll)|0,zn=zn+Math.imul(Jo,_l)|0,Nn=Nn+Math.imul(Vo,xl)|0,wn=wn+Math.imul(Vo,Tl)|0,wn=wn+Math.imul(Uo,xl)|0,zn=zn+Math.imul(Uo,Tl)|0,Nn=Nn+Math.imul(No,Bl)|0,wn=wn+Math.imul(No,Il)|0,wn=wn+Math.imul(Fo,Bl)|0,zn=zn+Math.imul(Fo,Il)|0,Nn=Nn+Math.imul(qo,Al)|0,wn=wn+Math.imul(qo,Ml)|0,wn=wn+Math.imul(ga,Al)|0,zn=zn+Math.imul(ga,Ml)|0,Nn=Nn+Math.imul(Lo,Ul)|0,wn=wn+Math.imul(Lo,Sl)|0,wn=wn+Math.imul(Wo,Ul)|0,zn=zn+Math.imul(Wo,Sl)|0,Nn=Nn+Math.imul(yo,So)|0,wn=wn+Math.imul(yo,Co)|0,wn=wn+Math.imul(_o,So)|0,zn=zn+Math.imul(_o,Co)|0,Nn=Nn+Math.imul(lo,po)|0,wn=wn+Math.imul(lo,Ro)|0,wn=wn+Math.imul(Eo,po)|0,zn=zn+Math.imul(Eo,Ro)|0,Nn=Nn+Math.imul(vo,jo)|0,wn=wn+Math.imul(vo,Ko)|0,wn=wn+Math.imul(go,jo)|0,zn=zn+Math.imul(go,Ko)|0;var gu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(gu>>>26)|0,gu&=67108863,Nn=Math.imul(bo,Do),wn=Math.imul(bo,zo),wn=wn+Math.imul(Io,Do)|0,zn=Math.imul(Io,zo),Nn=Nn+Math.imul(Cl,Ll)|0,wn=wn+Math.imul(Cl,_l)|0,wn=wn+Math.imul(ko,Ll)|0,zn=zn+Math.imul(ko,_l)|0,Nn=Nn+Math.imul($a,xl)|0,wn=wn+Math.imul($a,Tl)|0,wn=wn+Math.imul(Jo,xl)|0,zn=zn+Math.imul(Jo,Tl)|0,Nn=Nn+Math.imul(Vo,Bl)|0,wn=wn+Math.imul(Vo,Il)|0,wn=wn+Math.imul(Uo,Bl)|0,zn=zn+Math.imul(Uo,Il)|0,Nn=Nn+Math.imul(No,Al)|0,wn=wn+Math.imul(No,Ml)|0,wn=wn+Math.imul(Fo,Al)|0,zn=zn+Math.imul(Fo,Ml)|0,Nn=Nn+Math.imul(qo,Ul)|0,wn=wn+Math.imul(qo,Sl)|0,wn=wn+Math.imul(ga,Ul)|0,zn=zn+Math.imul(ga,Sl)|0,Nn=Nn+Math.imul(Lo,So)|0,wn=wn+Math.imul(Lo,Co)|0,wn=wn+Math.imul(Wo,So)|0,zn=zn+Math.imul(Wo,Co)|0,Nn=Nn+Math.imul(yo,po)|0,wn=wn+Math.imul(yo,Ro)|0,wn=wn+Math.imul(_o,po)|0,zn=zn+Math.imul(_o,Ro)|0,Nn=Nn+Math.imul(lo,jo)|0,wn=wn+Math.imul(lo,Ko)|0,wn=wn+Math.imul(Eo,jo)|0,zn=zn+Math.imul(Eo,Ko)|0,Nn=Nn+Math.imul(vo,$l)|0,wn=wn+Math.imul(vo,El)|0,wn=wn+Math.imul(go,$l)|0,zn=zn+Math.imul(go,El)|0;var ou=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(ou>>>26)|0,ou&=67108863,Nn=Math.imul(bo,Ll),wn=Math.imul(bo,_l),wn=wn+Math.imul(Io,Ll)|0,zn=Math.imul(Io,_l),Nn=Nn+Math.imul(Cl,xl)|0,wn=wn+Math.imul(Cl,Tl)|0,wn=wn+Math.imul(ko,xl)|0,zn=zn+Math.imul(ko,Tl)|0,Nn=Nn+Math.imul($a,Bl)|0,wn=wn+Math.imul($a,Il)|0,wn=wn+Math.imul(Jo,Bl)|0,zn=zn+Math.imul(Jo,Il)|0,Nn=Nn+Math.imul(Vo,Al)|0,wn=wn+Math.imul(Vo,Ml)|0,wn=wn+Math.imul(Uo,Al)|0,zn=zn+Math.imul(Uo,Ml)|0,Nn=Nn+Math.imul(No,Ul)|0,wn=wn+Math.imul(No,Sl)|0,wn=wn+Math.imul(Fo,Ul)|0,zn=zn+Math.imul(Fo,Sl)|0,Nn=Nn+Math.imul(qo,So)|0,wn=wn+Math.imul(qo,Co)|0,wn=wn+Math.imul(ga,So)|0,zn=zn+Math.imul(ga,Co)|0,Nn=Nn+Math.imul(Lo,po)|0,wn=wn+Math.imul(Lo,Ro)|0,wn=wn+Math.imul(Wo,po)|0,zn=zn+Math.imul(Wo,Ro)|0,Nn=Nn+Math.imul(yo,jo)|0,wn=wn+Math.imul(yo,Ko)|0,wn=wn+Math.imul(_o,jo)|0,zn=zn+Math.imul(_o,Ko)|0,Nn=Nn+Math.imul(lo,$l)|0,wn=wn+Math.imul(lo,El)|0,wn=wn+Math.imul(Eo,$l)|0,zn=zn+Math.imul(Eo,El)|0;var su=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(su>>>26)|0,su&=67108863,Nn=Math.imul(bo,xl),wn=Math.imul(bo,Tl),wn=wn+Math.imul(Io,xl)|0,zn=Math.imul(Io,Tl),Nn=Nn+Math.imul(Cl,Bl)|0,wn=wn+Math.imul(Cl,Il)|0,wn=wn+Math.imul(ko,Bl)|0,zn=zn+Math.imul(ko,Il)|0,Nn=Nn+Math.imul($a,Al)|0,wn=wn+Math.imul($a,Ml)|0,wn=wn+Math.imul(Jo,Al)|0,zn=zn+Math.imul(Jo,Ml)|0,Nn=Nn+Math.imul(Vo,Ul)|0,wn=wn+Math.imul(Vo,Sl)|0,wn=wn+Math.imul(Uo,Ul)|0,zn=zn+Math.imul(Uo,Sl)|0,Nn=Nn+Math.imul(No,So)|0,wn=wn+Math.imul(No,Co)|0,wn=wn+Math.imul(Fo,So)|0,zn=zn+Math.imul(Fo,Co)|0,Nn=Nn+Math.imul(qo,po)|0,wn=wn+Math.imul(qo,Ro)|0,wn=wn+Math.imul(ga,po)|0,zn=zn+Math.imul(ga,Ro)|0,Nn=Nn+Math.imul(Lo,jo)|0,wn=wn+Math.imul(Lo,Ko)|0,wn=wn+Math.imul(Wo,jo)|0,zn=zn+Math.imul(Wo,Ko)|0,Nn=Nn+Math.imul(yo,$l)|0,wn=wn+Math.imul(yo,El)|0,wn=wn+Math.imul(_o,$l)|0,zn=zn+Math.imul(_o,El)|0;var tu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(tu>>>26)|0,tu&=67108863,Nn=Math.imul(bo,Bl),wn=Math.imul(bo,Il),wn=wn+Math.imul(Io,Bl)|0,zn=Math.imul(Io,Il),Nn=Nn+Math.imul(Cl,Al)|0,wn=wn+Math.imul(Cl,Ml)|0,wn=wn+Math.imul(ko,Al)|0,zn=zn+Math.imul(ko,Ml)|0,Nn=Nn+Math.imul($a,Ul)|0,wn=wn+Math.imul($a,Sl)|0,wn=wn+Math.imul(Jo,Ul)|0,zn=zn+Math.imul(Jo,Sl)|0,Nn=Nn+Math.imul(Vo,So)|0,wn=wn+Math.imul(Vo,Co)|0,wn=wn+Math.imul(Uo,So)|0,zn=zn+Math.imul(Uo,Co)|0,Nn=Nn+Math.imul(No,po)|0,wn=wn+Math.imul(No,Ro)|0,wn=wn+Math.imul(Fo,po)|0,zn=zn+Math.imul(Fo,Ro)|0,Nn=Nn+Math.imul(qo,jo)|0,wn=wn+Math.imul(qo,Ko)|0,wn=wn+Math.imul(ga,jo)|0,zn=zn+Math.imul(ga,Ko)|0,Nn=Nn+Math.imul(Lo,$l)|0,wn=wn+Math.imul(Lo,El)|0,wn=wn+Math.imul(Wo,$l)|0,zn=zn+Math.imul(Wo,El)|0;var zl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(zl>>>26)|0,zl&=67108863,Nn=Math.imul(bo,Al),wn=Math.imul(bo,Ml),wn=wn+Math.imul(Io,Al)|0,zn=Math.imul(Io,Ml),Nn=Nn+Math.imul(Cl,Ul)|0,wn=wn+Math.imul(Cl,Sl)|0,wn=wn+Math.imul(ko,Ul)|0,zn=zn+Math.imul(ko,Sl)|0,Nn=Nn+Math.imul($a,So)|0,wn=wn+Math.imul($a,Co)|0,wn=wn+Math.imul(Jo,So)|0,zn=zn+Math.imul(Jo,Co)|0,Nn=Nn+Math.imul(Vo,po)|0,wn=wn+Math.imul(Vo,Ro)|0,wn=wn+Math.imul(Uo,po)|0,zn=zn+Math.imul(Uo,Ro)|0,Nn=Nn+Math.imul(No,jo)|0,wn=wn+Math.imul(No,Ko)|0,wn=wn+Math.imul(Fo,jo)|0,zn=zn+Math.imul(Fo,Ko)|0,Nn=Nn+Math.imul(qo,$l)|0,wn=wn+Math.imul(qo,El)|0,wn=wn+Math.imul(ga,$l)|0,zn=zn+Math.imul(ga,El)|0;var Gl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Gl>>>26)|0,Gl&=67108863,Nn=Math.imul(bo,Ul),wn=Math.imul(bo,Sl),wn=wn+Math.imul(Io,Ul)|0,zn=Math.imul(Io,Sl),Nn=Nn+Math.imul(Cl,So)|0,wn=wn+Math.imul(Cl,Co)|0,wn=wn+Math.imul(ko,So)|0,zn=zn+Math.imul(ko,Co)|0,Nn=Nn+Math.imul($a,po)|0,wn=wn+Math.imul($a,Ro)|0,wn=wn+Math.imul(Jo,po)|0,zn=zn+Math.imul(Jo,Ro)|0,Nn=Nn+Math.imul(Vo,jo)|0,wn=wn+Math.imul(Vo,Ko)|0,wn=wn+Math.imul(Uo,jo)|0,zn=zn+Math.imul(Uo,Ko)|0,Nn=Nn+Math.imul(No,$l)|0,wn=wn+Math.imul(No,El)|0,wn=wn+Math.imul(Fo,$l)|0,zn=zn+Math.imul(Fo,El)|0;var Jl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Jl>>>26)|0,Jl&=67108863,Nn=Math.imul(bo,So),wn=Math.imul(bo,Co),wn=wn+Math.imul(Io,So)|0,zn=Math.imul(Io,Co),Nn=Nn+Math.imul(Cl,po)|0,wn=wn+Math.imul(Cl,Ro)|0,wn=wn+Math.imul(ko,po)|0,zn=zn+Math.imul(ko,Ro)|0,Nn=Nn+Math.imul($a,jo)|0,wn=wn+Math.imul($a,Ko)|0,wn=wn+Math.imul(Jo,jo)|0,zn=zn+Math.imul(Jo,Ko)|0,Nn=Nn+Math.imul(Vo,$l)|0,wn=wn+Math.imul(Vo,El)|0,wn=wn+Math.imul(Uo,$l)|0,zn=zn+Math.imul(Uo,El)|0;var Pl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Pl>>>26)|0,Pl&=67108863,Nn=Math.imul(bo,po),wn=Math.imul(bo,Ro),wn=wn+Math.imul(Io,po)|0,zn=Math.imul(Io,Ro),Nn=Nn+Math.imul(Cl,jo)|0,wn=wn+Math.imul(Cl,Ko)|0,wn=wn+Math.imul(ko,jo)|0,zn=zn+Math.imul(ko,Ko)|0,Nn=Nn+Math.imul($a,$l)|0,wn=wn+Math.imul($a,El)|0,wn=wn+Math.imul(Jo,$l)|0,zn=zn+Math.imul(Jo,El)|0;var Fl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Fl>>>26)|0,Fl&=67108863,Nn=Math.imul(bo,jo),wn=Math.imul(bo,Ko),wn=wn+Math.imul(Io,jo)|0,zn=Math.imul(Io,Ko),Nn=Nn+Math.imul(Cl,$l)|0,wn=wn+Math.imul(Cl,El)|0,wn=wn+Math.imul(ko,$l)|0,zn=zn+Math.imul(ko,El)|0;var Yl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Yl>>>26)|0,Yl&=67108863,Nn=Math.imul(bo,$l),wn=Math.imul(bo,El),wn=wn+Math.imul(Io,$l)|0,zn=Math.imul(Io,El);var Vl=(Zn+Nn|0)+((wn&8191)<<13)|0;return Zn=(zn+(wn>>>13)|0)+(Vl>>>26)|0,Vl&=67108863,On[0]=Cu,On[1]=iu,On[2]=pu,On[3]=yu,On[4]=hu,On[5]=mu,On[6]=vu,On[7]=fu,On[8]=gu,On[9]=ou,On[10]=su,On[11]=tu,On[12]=zl,On[13]=Gl,On[14]=Jl,On[15]=Pl,On[16]=Fl,On[17]=Yl,On[18]=Vl,Zn!==0&&(On[19]=Zn,Sn.length++),Sn};Math.imul||(An=In);function jn(Tn,Gr,Xr){Xr.negative=Gr.negative^Tn.negative,Xr.length=Tn.length+Gr.length;for(var Sn=0,Rn=0,Pn=0;Pn>>26)|0,Rn+=On>>>26,On&=67108863}Xr.words[Pn]=Zn,Sn=On,On=Rn}return Sn!==0?Xr.words[Pn]=Sn:Xr.length--,Xr._strip()}function eo(Tn,Gr,Xr){return jn(Tn,Gr,Xr)}jr.prototype.mulTo=function(Gr,Xr){var Sn,Rn=this.length+Gr.length;return this.length===10&&Gr.length===10?Sn=An(this,Gr,Xr):Rn<63?Sn=In(this,Gr,Xr):Rn<1024?Sn=jn(this,Gr,Xr):Sn=eo(this,Gr,Xr),Sn},jr.prototype.mul=function(Gr){var Xr=new jr(null);return Xr.words=new Array(this.length+Gr.length),this.mulTo(Gr,Xr)},jr.prototype.mulf=function(Gr){var Xr=new jr(null);return Xr.words=new Array(this.length+Gr.length),eo(this,Gr,Xr)},jr.prototype.imul=function(Gr){return this.clone().mulTo(Gr,this)},jr.prototype.imuln=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(typeof Gr=="number"),Er(Gr<67108864);for(var Sn=0,Rn=0;Rn>=26,Sn+=Pn/67108864|0,Sn+=On>>>26,this.words[Rn]=On&67108863}return Sn!==0&&(this.words[Rn]=Sn,this.length++),Xr?this.ineg():this},jr.prototype.muln=function(Gr){return this.clone().imuln(Gr)},jr.prototype.sqr=function(){return this.mul(this)},jr.prototype.isqr=function(){return this.imul(this.clone())},jr.prototype.pow=function(Gr){var Xr=Cn(Gr);if(Xr.length===0)return new jr(1);for(var Sn=this,Rn=0;Rn=0);var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=67108863>>>26-Xr<<26-Xr,Pn;if(Xr!==0){var On=0;for(Pn=0;Pn>>26-Xr}On&&(this.words[Pn]=On,this.length++)}if(Sn!==0){for(Pn=this.length-1;Pn>=0;Pn--)this.words[Pn+Sn]=this.words[Pn];for(Pn=0;Pn=0);var Rn;Xr?Rn=(Xr-Xr%26)/26:Rn=0;var Pn=Gr%26,On=Math.min((Gr-Pn)/26,this.length),Zn=67108863^67108863>>>Pn<On)for(this.length-=On,wn=0;wn=0&&(zn!==0||wn>=Rn);wn--){var fo=this.words[wn]|0;this.words[wn]=zn<<26-Pn|fo>>>Pn,zn=fo&Zn}return Nn&&zn!==0&&(Nn.words[Nn.length++]=zn),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},jr.prototype.ishrn=function(Gr,Xr,Sn){return Er(this.negative===0),this.iushrn(Gr,Xr,Sn)},jr.prototype.shln=function(Gr){return this.clone().ishln(Gr)},jr.prototype.ushln=function(Gr){return this.clone().iushln(Gr)},jr.prototype.shrn=function(Gr){return this.clone().ishrn(Gr)},jr.prototype.ushrn=function(Gr){return this.clone().iushrn(Gr)},jr.prototype.testn=function(Gr){Er(typeof Gr=="number"&&Gr>=0);var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=1<=0);var Xr=Gr%26,Sn=(Gr-Xr)/26;if(Er(this.negative===0,"imaskn works only with positive numbers"),this.length<=Sn)return this;if(Xr!==0&&Sn++,this.length=Math.min(Sn,this.length),Xr!==0){var Rn=67108863^67108863>>>Xr<=67108864;Xr++)this.words[Xr]-=67108864,Xr===this.length-1?this.words[Xr+1]=1:this.words[Xr+1]++;return this.length=Math.max(this.length,Xr+1),this},jr.prototype.isubn=function(Gr){if(Er(typeof Gr=="number"),Er(Gr<67108864),Gr<0)return this.iaddn(-Gr);if(this.negative!==0)return this.negative=0,this.iaddn(Gr),this.negative=1,this;if(this.words[0]-=Gr,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var Xr=0;Xr>26)-(Nn/67108864|0),this.words[Pn+Sn]=On&67108863}for(;Pn>26,this.words[Pn+Sn]=On&67108863;if(Zn===0)return this._strip();for(Er(Zn===-1),Zn=0,Pn=0;Pn>26,this.words[Pn]=On&67108863;return this.negative=1,this._strip()},jr.prototype._wordDiv=function(Gr,Xr){var Sn=this.length-Gr.length,Rn=this.clone(),Pn=Gr,On=Pn.words[Pn.length-1]|0,Zn=this._countBits(On);Sn=26-Zn,Sn!==0&&(Pn=Pn.ushln(Sn),Rn.iushln(Sn),On=Pn.words[Pn.length-1]|0);var Nn=Rn.length-Pn.length,wn;if(Xr!=="mod"){wn=new jr(null),wn.length=Nn+1,wn.words=new Array(wn.length);for(var zn=0;zn=0;vo--){var go=(Rn.words[Pn.length+vo]|0)*67108864+(Rn.words[Pn.length+vo-1]|0);for(go=Math.min(go/On|0,67108863),Rn._ishlnsubmul(Pn,go,vo);Rn.negative!==0;)go--,Rn.negative=0,Rn._ishlnsubmul(Pn,1,vo),Rn.isZero()||(Rn.negative^=1);wn&&(wn.words[vo]=go)}return wn&&wn._strip(),Rn._strip(),Xr!=="div"&&Sn!==0&&Rn.iushrn(Sn),{div:wn||null,mod:Rn}},jr.prototype.divmod=function(Gr,Xr,Sn){if(Er(!Gr.isZero()),this.isZero())return{div:new jr(0),mod:new jr(0)};var Rn,Pn,On;return this.negative!==0&&Gr.negative===0?(On=this.neg().divmod(Gr,Xr),Xr!=="mod"&&(Rn=On.div.neg()),Xr!=="div"&&(Pn=On.mod.neg(),Sn&&Pn.negative!==0&&Pn.iadd(Gr)),{div:Rn,mod:Pn}):this.negative===0&&Gr.negative!==0?(On=this.divmod(Gr.neg(),Xr),Xr!=="mod"&&(Rn=On.div.neg()),{div:Rn,mod:On.mod}):this.negative&Gr.negative?(On=this.neg().divmod(Gr.neg(),Xr),Xr!=="div"&&(Pn=On.mod.neg(),Sn&&Pn.negative!==0&&Pn.isub(Gr)),{div:On.div,mod:Pn}):Gr.length>this.length||this.cmp(Gr)<0?{div:new jr(0),mod:this}:Gr.length===1?Xr==="div"?{div:this.divn(Gr.words[0]),mod:null}:Xr==="mod"?{div:null,mod:new jr(this.modrn(Gr.words[0]))}:{div:this.divn(Gr.words[0]),mod:new jr(this.modrn(Gr.words[0]))}:this._wordDiv(Gr,Xr)},jr.prototype.div=function(Gr){return this.divmod(Gr,"div",!1).div},jr.prototype.mod=function(Gr){return this.divmod(Gr,"mod",!1).mod},jr.prototype.umod=function(Gr){return this.divmod(Gr,"mod",!0).mod},jr.prototype.divRound=function(Gr){var Xr=this.divmod(Gr);if(Xr.mod.isZero())return Xr.div;var Sn=Xr.div.negative!==0?Xr.mod.isub(Gr):Xr.mod,Rn=Gr.ushrn(1),Pn=Gr.andln(1),On=Sn.cmp(Rn);return On<0||Pn===1&&On===0?Xr.div:Xr.div.negative!==0?Xr.div.isubn(1):Xr.div.iaddn(1)},jr.prototype.modrn=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(Gr<=67108863);for(var Sn=(1<<26)%Gr,Rn=0,Pn=this.length-1;Pn>=0;Pn--)Rn=(Sn*Rn+(this.words[Pn]|0))%Gr;return Xr?-Rn:Rn},jr.prototype.modn=function(Gr){return this.modrn(Gr)},jr.prototype.idivn=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(Gr<=67108863);for(var Sn=0,Rn=this.length-1;Rn>=0;Rn--){var Pn=(this.words[Rn]|0)+Sn*67108864;this.words[Rn]=Pn/Gr|0,Sn=Pn%Gr}return this._strip(),Xr?this.ineg():this},jr.prototype.divn=function(Gr){return this.clone().idivn(Gr)},jr.prototype.egcd=function(Gr){Er(Gr.negative===0),Er(!Gr.isZero());var Xr=this,Sn=Gr.clone();Xr.negative!==0?Xr=Xr.umod(Gr):Xr=Xr.clone();for(var Rn=new jr(1),Pn=new jr(0),On=new jr(0),Zn=new jr(1),Nn=0;Xr.isEven()&&Sn.isEven();)Xr.iushrn(1),Sn.iushrn(1),++Nn;for(var wn=Sn.clone(),zn=Xr.clone();!Xr.isZero();){for(var fo=0,vo=1;!(Xr.words[0]&vo)&&fo<26;++fo,vo<<=1);if(fo>0)for(Xr.iushrn(fo);fo-- >0;)(Rn.isOdd()||Pn.isOdd())&&(Rn.iadd(wn),Pn.isub(zn)),Rn.iushrn(1),Pn.iushrn(1);for(var go=0,uo=1;!(Sn.words[0]&uo)&&go<26;++go,uo<<=1);if(go>0)for(Sn.iushrn(go);go-- >0;)(On.isOdd()||Zn.isOdd())&&(On.iadd(wn),Zn.isub(zn)),On.iushrn(1),Zn.iushrn(1);Xr.cmp(Sn)>=0?(Xr.isub(Sn),Rn.isub(On),Pn.isub(Zn)):(Sn.isub(Xr),On.isub(Rn),Zn.isub(Pn))}return{a:On,b:Zn,gcd:Sn.iushln(Nn)}},jr.prototype._invmp=function(Gr){Er(Gr.negative===0),Er(!Gr.isZero());var Xr=this,Sn=Gr.clone();Xr.negative!==0?Xr=Xr.umod(Gr):Xr=Xr.clone();for(var Rn=new jr(1),Pn=new jr(0),On=Sn.clone();Xr.cmpn(1)>0&&Sn.cmpn(1)>0;){for(var Zn=0,Nn=1;!(Xr.words[0]&Nn)&&Zn<26;++Zn,Nn<<=1);if(Zn>0)for(Xr.iushrn(Zn);Zn-- >0;)Rn.isOdd()&&Rn.iadd(On),Rn.iushrn(1);for(var wn=0,zn=1;!(Sn.words[0]&zn)&&wn<26;++wn,zn<<=1);if(wn>0)for(Sn.iushrn(wn);wn-- >0;)Pn.isOdd()&&Pn.iadd(On),Pn.iushrn(1);Xr.cmp(Sn)>=0?(Xr.isub(Sn),Rn.isub(Pn)):(Sn.isub(Xr),Pn.isub(Rn))}var fo;return Xr.cmpn(1)===0?fo=Rn:fo=Pn,fo.cmpn(0)<0&&fo.iadd(Gr),fo},jr.prototype.gcd=function(Gr){if(this.isZero())return Gr.abs();if(Gr.isZero())return this.abs();var Xr=this.clone(),Sn=Gr.clone();Xr.negative=0,Sn.negative=0;for(var Rn=0;Xr.isEven()&&Sn.isEven();Rn++)Xr.iushrn(1),Sn.iushrn(1);do{for(;Xr.isEven();)Xr.iushrn(1);for(;Sn.isEven();)Sn.iushrn(1);var Pn=Xr.cmp(Sn);if(Pn<0){var On=Xr;Xr=Sn,Sn=On}else if(Pn===0||Sn.cmpn(1)===0)break;Xr.isub(Sn)}while(!0);return Sn.iushln(Rn)},jr.prototype.invm=function(Gr){return this.egcd(Gr).a.umod(Gr)},jr.prototype.isEven=function(){return(this.words[0]&1)===0},jr.prototype.isOdd=function(){return(this.words[0]&1)===1},jr.prototype.andln=function(Gr){return this.words[0]&Gr},jr.prototype.bincn=function(Gr){Er(typeof Gr=="number");var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=1<>>26,Zn&=67108863,this.words[On]=Zn}return Pn!==0&&(this.words[On]=Pn,this.length++),this},jr.prototype.isZero=function(){return this.length===1&&this.words[0]===0},jr.prototype.cmpn=function(Gr){var Xr=Gr<0;if(this.negative!==0&&!Xr)return-1;if(this.negative===0&&Xr)return 1;this._strip();var Sn;if(this.length>1)Sn=1;else{Xr&&(Gr=-Gr),Er(Gr<=67108863,"Number is too big");var Rn=this.words[0]|0;Sn=Rn===Gr?0:RnGr.length)return 1;if(this.length=0;Sn--){var Rn=this.words[Sn]|0,Pn=Gr.words[Sn]|0;if(Rn!==Pn){RnPn&&(Xr=1);break}}return Xr},jr.prototype.gtn=function(Gr){return this.cmpn(Gr)===1},jr.prototype.gt=function(Gr){return this.cmp(Gr)===1},jr.prototype.gten=function(Gr){return this.cmpn(Gr)>=0},jr.prototype.gte=function(Gr){return this.cmp(Gr)>=0},jr.prototype.ltn=function(Gr){return this.cmpn(Gr)===-1},jr.prototype.lt=function(Gr){return this.cmp(Gr)===-1},jr.prototype.lten=function(Gr){return this.cmpn(Gr)<=0},jr.prototype.lte=function(Gr){return this.cmp(Gr)<=0},jr.prototype.eqn=function(Gr){return this.cmpn(Gr)===0},jr.prototype.eq=function(Gr){return this.cmp(Gr)===0},jr.red=function(Gr){return new so(Gr)},jr.prototype.toRed=function(Gr){return Er(!this.red,"Already a number in reduction context"),Er(this.negative===0,"red works only with positives"),Gr.convertTo(this)._forceRed(Gr)},jr.prototype.fromRed=function(){return Er(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},jr.prototype._forceRed=function(Gr){return this.red=Gr,this},jr.prototype.forceRed=function(Gr){return Er(!this.red,"Already a number in reduction context"),this._forceRed(Gr)},jr.prototype.redAdd=function(Gr){return Er(this.red,"redAdd works only with red numbers"),this.red.add(this,Gr)},jr.prototype.redIAdd=function(Gr){return Er(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,Gr)},jr.prototype.redSub=function(Gr){return Er(this.red,"redSub works only with red numbers"),this.red.sub(this,Gr)},jr.prototype.redISub=function(Gr){return Er(this.red,"redISub works only with red numbers"),this.red.isub(this,Gr)},jr.prototype.redShl=function(Gr){return Er(this.red,"redShl works only with red numbers"),this.red.shl(this,Gr)},jr.prototype.redMul=function(Gr){return Er(this.red,"redMul works only with red numbers"),this.red._verify2(this,Gr),this.red.mul(this,Gr)},jr.prototype.redIMul=function(Gr){return Er(this.red,"redMul works only with red numbers"),this.red._verify2(this,Gr),this.red.imul(this,Gr)},jr.prototype.redSqr=function(){return Er(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},jr.prototype.redISqr=function(){return Er(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},jr.prototype.redSqrt=function(){return Er(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},jr.prototype.redInvm=function(){return Er(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},jr.prototype.redNeg=function(){return Er(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},jr.prototype.redPow=function(Gr){return Er(this.red&&!Gr.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,Gr)};var ro={k256:null,p224:null,p192:null,p25519:null};function to(Tn,Gr){this.name=Tn,this.p=new jr(Gr,16),this.n=this.p.bitLength(),this.k=new jr(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}to.prototype._tmp=function(){var Gr=new jr(null);return Gr.words=new Array(Math.ceil(this.n/13)),Gr},to.prototype.ireduce=function(Gr){var Xr=Gr,Sn;do this.split(Xr,this.tmp),Xr=this.imulK(Xr),Xr=Xr.iadd(this.tmp),Sn=Xr.bitLength();while(Sn>this.n);var Rn=Sn0?Xr.isub(this.p):Xr.strip!==void 0?Xr.strip():Xr._strip(),Xr},to.prototype.split=function(Gr,Xr){Gr.iushrn(this.n,0,Xr)},to.prototype.imulK=function(Gr){return Gr.imul(this.k)};function _i(){to.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}kr(_i,to),_i.prototype.split=function(Gr,Xr){for(var Sn=4194303,Rn=Math.min(Gr.length,9),Pn=0;Pn>>22,On=Zn}On>>>=22,Gr.words[Pn-10]=On,On===0&&Gr.length>10?Gr.length-=10:Gr.length-=9},_i.prototype.imulK=function(Gr){Gr.words[Gr.length]=0,Gr.words[Gr.length+1]=0,Gr.length+=2;for(var Xr=0,Sn=0;Sn>>=26,Gr.words[Sn]=Pn,Xr=Rn}return Xr!==0&&(Gr.words[Gr.length++]=Xr),Gr},jr._prime=function(Gr){if(ro[Gr])return ro[Gr];var Xr;if(Gr==="k256")Xr=new _i;else if(Gr==="p224")Xr=new oo;else if(Gr==="p192")Xr=new io;else if(Gr==="p25519")Xr=new co;else throw new Error("Unknown prime "+Gr);return ro[Gr]=Xr,Xr};function so(Tn){if(typeof Tn=="string"){var Gr=jr._prime(Tn);this.m=Gr.p,this.prime=Gr}else Er(Tn.gtn(1),"modulus must be greater than 1"),this.m=Tn,this.prime=null}so.prototype._verify1=function(Gr){Er(Gr.negative===0,"red works only with positives"),Er(Gr.red,"red works only with red numbers")},so.prototype._verify2=function(Gr,Xr){Er((Gr.negative|Xr.negative)===0,"red works only with positives"),Er(Gr.red&&Gr.red===Xr.red,"red works only with red numbers")},so.prototype.imod=function(Gr){return this.prime?this.prime.ireduce(Gr)._forceRed(this):(Vr(Gr,Gr.umod(this.m)._forceRed(this)),Gr)},so.prototype.neg=function(Gr){return Gr.isZero()?Gr.clone():this.m.sub(Gr)._forceRed(this)},so.prototype.add=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.add(Xr);return Sn.cmp(this.m)>=0&&Sn.isub(this.m),Sn._forceRed(this)},so.prototype.iadd=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.iadd(Xr);return Sn.cmp(this.m)>=0&&Sn.isub(this.m),Sn},so.prototype.sub=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.sub(Xr);return Sn.cmpn(0)<0&&Sn.iadd(this.m),Sn._forceRed(this)},so.prototype.isub=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.isub(Xr);return Sn.cmpn(0)<0&&Sn.iadd(this.m),Sn},so.prototype.shl=function(Gr,Xr){return this._verify1(Gr),this.imod(Gr.ushln(Xr))},so.prototype.imul=function(Gr,Xr){return this._verify2(Gr,Xr),this.imod(Gr.imul(Xr))},so.prototype.mul=function(Gr,Xr){return this._verify2(Gr,Xr),this.imod(Gr.mul(Xr))},so.prototype.isqr=function(Gr){return this.imul(Gr,Gr.clone())},so.prototype.sqr=function(Gr){return this.mul(Gr,Gr)},so.prototype.sqrt=function(Gr){if(Gr.isZero())return Gr.clone();var Xr=this.m.andln(3);if(Er(Xr%2===1),Xr===3){var Sn=this.m.add(new jr(1)).iushrn(2);return this.pow(Gr,Sn)}for(var Rn=this.m.subn(1),Pn=0;!Rn.isZero()&&Rn.andln(1)===0;)Pn++,Rn.iushrn(1);Er(!Rn.isZero());var On=new jr(1).toRed(this),Zn=On.redNeg(),Nn=this.m.subn(1).iushrn(1),wn=this.m.bitLength();for(wn=new jr(2*wn*wn).toRed(this);this.pow(wn,Nn).cmp(Zn)!==0;)wn.redIAdd(Zn);for(var zn=this.pow(wn,Rn),fo=this.pow(Gr,Rn.addn(1).iushrn(1)),vo=this.pow(Gr,Rn),go=Pn;vo.cmp(On)!==0;){for(var uo=vo,lo=0;uo.cmp(On)!==0;lo++)uo=uo.redSqr();Er(lo=0;Pn--){for(var zn=Xr.words[Pn],fo=wn-1;fo>=0;fo--){var vo=zn>>fo&1;if(On!==Rn[0]&&(On=this.sqr(On)),vo===0&&Zn===0){Nn=0;continue}Zn<<=1,Zn|=vo,Nn++,!(Nn!==Sn&&(Pn!==0||fo!==0))&&(On=this.mul(On,Rn[Zn]),Nn=0,Zn=0)}wn=26}return On},so.prototype.convertTo=function(Gr){var Xr=Gr.umod(this.m);return Xr===Gr?Xr.clone():Xr},so.prototype.convertFrom=function(Gr){var Xr=Gr.clone();return Xr.red=null,Xr},jr.mont=function(Gr){return new no(Gr)};function no(Tn){so.call(this,Tn),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new jr(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}kr(no,so),no.prototype.convertTo=function(Gr){return this.imod(Gr.ushln(this.shift))},no.prototype.convertFrom=function(Gr){var Xr=this.imod(Gr.mul(this.rinv));return Xr.red=null,Xr},no.prototype.imul=function(Gr,Xr){if(Gr.isZero()||Xr.isZero())return Gr.words[0]=0,Gr.length=1,Gr;var Sn=Gr.imul(Xr),Rn=Sn.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Pn=Sn.isub(Rn).iushrn(this.shift),On=Pn;return Pn.cmp(this.m)>=0?On=Pn.isub(this.m):Pn.cmpn(0)<0&&(On=Pn.iadd(this.m)),On._forceRed(this)},no.prototype.mul=function(Gr,Xr){if(Gr.isZero()||Xr.isZero())return new jr(0)._forceRed(this);var Sn=Gr.mul(Xr),Rn=Sn.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Pn=Sn.isub(Rn).iushrn(this.shift),On=Pn;return Pn.cmp(this.m)>=0?On=Pn.isub(this.m):Pn.cmpn(0)<0&&(On=Pn.iadd(this.m)),On._forceRed(this)},no.prototype.invm=function(Gr){var Xr=this.imod(Gr._invmp(this.m).mul(this.r2));return Xr._forceRed(this)}})(fr,commonjsGlobal)})(bn$2);var bnExports$2=bn$2.exports,_Buffer$2=safeBufferExports.Buffer;function base$2(fr){if(fr.length>=255)throw new TypeError("Alphabet too long");for(var br=new Uint8Array(256),wr=0;wr>>0,jn=new Uint8Array(An);Cn!==In;){for(var eo=Qr[Cn],ro=0,to=An-1;(eo!==0||ro>>0,jn[to]=eo%Br>>>0,eo=eo/Br>>>0;if(eo!==0)throw new Error("Non-zero carry");En=ro,Cn++}for(var _i=An-En;_i!==An&&jn[_i]===0;)_i++;for(var oo=Wr.repeat(_n);_i>>0,An=new Uint8Array(In);_n>>0,An[ro]=jn%256>>>0,jn=jn/256>>>0;if(jn!==0)throw new Error("Non-zero carry");Cn=eo,_n++}for(var to=In-Cn;to!==In&&An[to]===0;)to++;var _i=_Buffer$2.allocUnsafe(En+(In-to));_i.fill(0,0,En);for(var oo=En;to!==In;)_i[oo++]=An[to++];return _i}function Jr(Qr){var _n=Zr(Qr);if(_n)return _n;throw new Error("Non-base"+Br+" character")}return{encode:Vr,decodeUnsafe:Zr,decode:Jr}}var src$2=base$2,basex$2=src$2,ALPHABET$2="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",bs58$4=basex$2(ALPHABET$2);function inRange(fr,br,wr){return br<=fr&&fr<=wr}function ToDictionary(fr){if(fr===void 0)return{};if(fr===Object(fr))return fr;throw TypeError("Could not convert argument to dictionary")}function stringToCodePoints(fr){for(var br=String(fr),wr=br.length,Er=0,kr=[];Er57343)kr.push(jr);else if(56320<=jr&&jr<=57343)kr.push(65533);else if(55296<=jr&&jr<=56319)if(Er===wr-1)kr.push(65533);else{var Br=fr.charCodeAt(Er+1);if(56320<=Br&&Br<=57343){var Wr=jr&1023,qr=Br&1023;kr.push(65536+(Wr<<10)+qr),Er+=1}else kr.push(65533)}Er+=1}return kr}function codePointsToString(fr){for(var br="",wr=0;wr>10)+55296,(Er&1023)+56320))}return br}var end_of_stream=-1;function Stream(fr){this.tokens=[].slice.call(fr)}Stream.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():end_of_stream},prepend:function(fr){if(Array.isArray(fr))for(var br=fr;br.length;)this.tokens.unshift(br.pop());else this.tokens.unshift(fr)},push:function(fr){if(Array.isArray(fr))for(var br=fr;br.length;)this.tokens.push(br.shift());else this.tokens.push(fr)}};var finished=-1;function decoderError(fr,br){if(fr)throw TypeError("Decoder error");return br||65533}var DEFAULT_ENCODING="utf-8";function TextDecoder$1(fr,br){if(!(this instanceof TextDecoder$1))return new TextDecoder$1(fr,br);if(fr=fr!==void 0?String(fr).toLowerCase():DEFAULT_ENCODING,fr!==DEFAULT_ENCODING)throw new Error("Encoding not supported. Only utf-8 is supported");br=ToDictionary(br),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!br.fatal,this._ignoreBOM=!!br.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}TextDecoder$1.prototype={decode:function fr(br,wr){var Er;typeof br=="object"&&br instanceof ArrayBuffer?Er=new Uint8Array(br):typeof br=="object"&&"buffer"in br&&br.buffer instanceof ArrayBuffer?Er=new Uint8Array(br.buffer,br.byteOffset,br.byteLength):Er=new Uint8Array(0),wr=ToDictionary(wr),this._streaming||(this._decoder=new UTF8Decoder({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!wr.stream;for(var kr=new Stream(Er),jr=[],Br;!kr.endOfStream()&&(Br=this._decoder.handler(kr,kr.read()),Br!==finished);)Br!==null&&(Array.isArray(Br)?jr.push.apply(jr,Br):jr.push(Br));if(!this._streaming){do{if(Br=this._decoder.handler(kr,kr.read()),Br===finished)break;Br!==null&&(Array.isArray(Br)?jr.push.apply(jr,Br):jr.push(Br))}while(!kr.endOfStream());this._decoder=null}return jr.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(jr[0]===65279?(this._BOMseen=!0,jr.shift()):this._BOMseen=!0),codePointsToString(jr)}};function TextEncoder$1(fr,br){if(!(this instanceof TextEncoder$1))return new TextEncoder$1(fr,br);if(fr=fr!==void 0?String(fr).toLowerCase():DEFAULT_ENCODING,fr!==DEFAULT_ENCODING)throw new Error("Encoding not supported. Only utf-8 is supported");br=ToDictionary(br),this._streaming=!1,this._encoder=null,this._options={fatal:!!br.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}TextEncoder$1.prototype={encode:function fr(br,wr){br=br?String(br):"",wr=ToDictionary(wr),this._streaming||(this._encoder=new UTF8Encoder(this._options)),this._streaming=!!wr.stream;for(var Er=[],kr=new Stream(stringToCodePoints(br)),jr;!kr.endOfStream()&&(jr=this._encoder.handler(kr,kr.read()),jr!==finished);)Array.isArray(jr)?Er.push.apply(Er,jr):Er.push(jr);if(!this._streaming){for(;jr=this._encoder.handler(kr,kr.read()),jr!==finished;)Array.isArray(jr)?Er.push.apply(Er,jr):Er.push(jr);this._encoder=null}return new Uint8Array(Er)}};function UTF8Decoder(fr){var br=fr.fatal,wr=0,Er=0,kr=0,jr=128,Br=191;this.handler=function(Wr,qr){if(qr===end_of_stream&&kr!==0)return kr=0,decoderError(br);if(qr===end_of_stream)return finished;if(kr===0){if(inRange(qr,0,127))return qr;if(inRange(qr,194,223))kr=1,wr=qr-192;else if(inRange(qr,224,239))qr===224&&(jr=160),qr===237&&(Br=159),kr=2,wr=qr-224;else if(inRange(qr,240,244))qr===240&&(jr=144),qr===244&&(Br=143),kr=3,wr=qr-240;else return decoderError(br);return wr=wr<<6*kr,null}if(!inRange(qr,jr,Br))return wr=kr=Er=0,jr=128,Br=191,Wr.prepend(qr),decoderError(br);if(jr=128,Br=191,Er+=1,wr+=qr-128<<6*(kr-Er),Er!==kr)return null;var Hr=wr;return wr=kr=Er=0,Hr}}function UTF8Encoder(fr){fr.fatal,this.handler=function(br,wr){if(wr===end_of_stream)return finished;if(inRange(wr,0,127))return wr;var Er,kr;inRange(wr,128,2047)?(Er=1,kr=192):inRange(wr,2048,65535)?(Er=2,kr=224):inRange(wr,65536,1114111)&&(Er=3,kr=240);for(var jr=[(wr>>6*Er)+kr];Er>0;){var Br=wr>>6*(Er-1);jr.push(128|Br&63),Er-=1}return jr}}const encoding$1=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:TextDecoder$1,TextEncoder:TextEncoder$1},Symbol.toStringTag,{value:"Module"})),require$$2=getAugmentedNamespace(encoding$1);var __createBinding=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(fr,br,wr,Er){Er===void 0&&(Er=wr),Object.defineProperty(fr,Er,{enumerable:!0,get:function(){return br[wr]}})}:function(fr,br,wr,Er){Er===void 0&&(Er=wr),fr[Er]=br[wr]}),__setModuleDefault=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(fr,br){Object.defineProperty(fr,"default",{enumerable:!0,value:br})}:function(fr,br){fr.default=br}),__decorate=commonjsGlobal&&commonjsGlobal.__decorate||function(fr,br,wr,Er){var kr=arguments.length,jr=kr<3?br:Er===null?Er=Object.getOwnPropertyDescriptor(br,wr):Er,Br;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")jr=Reflect.decorate(fr,br,wr,Er);else for(var Wr=fr.length-1;Wr>=0;Wr--)(Br=fr[Wr])&&(jr=(kr<3?Br(jr):kr>3?Br(br,wr,jr):Br(br,wr))||jr);return kr>3&&jr&&Object.defineProperty(br,wr,jr),jr},__importStar=commonjsGlobal&&commonjsGlobal.__importStar||function(fr){if(fr&&fr.__esModule)return fr;var br={};if(fr!=null)for(var wr in fr)wr!=="default"&&Object.hasOwnProperty.call(fr,wr)&&__createBinding(br,fr,wr);return __setModuleDefault(br,fr),br},__importDefault=commonjsGlobal&&commonjsGlobal.__importDefault||function(fr){return fr&&fr.__esModule?fr:{default:fr}};Object.defineProperty(lib,"__esModule",{value:!0});var deserializeUnchecked_1=lib.deserializeUnchecked=deserialize_1=lib.deserialize=serialize_1=lib.serialize=lib.BinaryReader=lib.BinaryWriter=lib.BorshError=lib.baseDecode=lib.baseEncode=void 0;const bn_js_1=__importDefault(bnExports$2),bs58_1=__importDefault(bs58$4),encoding=__importStar(require$$2),ResolvedTextDecoder=typeof TextDecoder!="function"?encoding.TextDecoder:TextDecoder,textDecoder=new ResolvedTextDecoder("utf-8",{fatal:!0});function baseEncode(fr){return typeof fr=="string"&&(fr=Buffer$2.from(fr,"utf8")),bs58_1.default.encode(Buffer$2.from(fr))}lib.baseEncode=baseEncode;function baseDecode(fr){return Buffer$2.from(bs58_1.default.decode(fr))}lib.baseDecode=baseDecode;const INITIAL_LENGTH=1024;class BorshError extends Error{constructor(br){super(br),this.fieldPath=[],this.originalMessage=br}addToFieldPath(br){this.fieldPath.splice(0,0,br),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}lib.BorshError=BorshError;class BinaryWriter{constructor(){this.buf=Buffer$2.alloc(INITIAL_LENGTH),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer$2.concat([this.buf,Buffer$2.alloc(INITIAL_LENGTH)]))}writeU8(br){this.maybeResize(),this.buf.writeUInt8(br,this.length),this.length+=1}writeU16(br){this.maybeResize(),this.buf.writeUInt16LE(br,this.length),this.length+=2}writeU32(br){this.maybeResize(),this.buf.writeUInt32LE(br,this.length),this.length+=4}writeU64(br){this.maybeResize(),this.writeBuffer(Buffer$2.from(new bn_js_1.default(br).toArray("le",8)))}writeU128(br){this.maybeResize(),this.writeBuffer(Buffer$2.from(new bn_js_1.default(br).toArray("le",16)))}writeU256(br){this.maybeResize(),this.writeBuffer(Buffer$2.from(new bn_js_1.default(br).toArray("le",32)))}writeU512(br){this.maybeResize(),this.writeBuffer(Buffer$2.from(new bn_js_1.default(br).toArray("le",64)))}writeBuffer(br){this.buf=Buffer$2.concat([Buffer$2.from(this.buf.subarray(0,this.length)),br,Buffer$2.alloc(INITIAL_LENGTH)]),this.length+=br.length}writeString(br){this.maybeResize();const wr=Buffer$2.from(br,"utf8");this.writeU32(wr.length),this.writeBuffer(wr)}writeFixedArray(br){this.writeBuffer(Buffer$2.from(br))}writeArray(br,wr){this.maybeResize(),this.writeU32(br.length);for(const Er of br)this.maybeResize(),wr(Er)}toArray(){return this.buf.subarray(0,this.length)}}lib.BinaryWriter=BinaryWriter;function handlingRangeError(fr,br,wr){const Er=wr.value;wr.value=function(...kr){try{return Er.apply(this,kr)}catch(jr){if(jr instanceof RangeError){const Br=jr.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(Br)>=0)throw new BorshError("Reached the end of buffer when deserializing")}throw jr}}}class BinaryReader{constructor(br){this.buf=br,this.offset=0}readU8(){const br=this.buf.readUInt8(this.offset);return this.offset+=1,br}readU16(){const br=this.buf.readUInt16LE(this.offset);return this.offset+=2,br}readU32(){const br=this.buf.readUInt32LE(this.offset);return this.offset+=4,br}readU64(){const br=this.readBuffer(8);return new bn_js_1.default(br,"le")}readU128(){const br=this.readBuffer(16);return new bn_js_1.default(br,"le")}readU256(){const br=this.readBuffer(32);return new bn_js_1.default(br,"le")}readU512(){const br=this.readBuffer(64);return new bn_js_1.default(br,"le")}readBuffer(br){if(this.offset+br>this.buf.length)throw new BorshError(`Expected buffer length ${br} isn't within bounds`);const wr=this.buf.slice(this.offset,this.offset+br);return this.offset+=br,wr}readString(){const br=this.readU32(),wr=this.readBuffer(br);try{return textDecoder.decode(wr)}catch(Er){throw new BorshError(`Error decoding UTF-8 string: ${Er}`)}}readFixedArray(br){return new Uint8Array(this.readBuffer(br))}readArray(br){const wr=this.readU32(),Er=Array();for(let kr=0;kr{serializeField(fr,br,jr,Er[0],kr)});else if(Er.kind!==void 0)switch(Er.kind){case"option":{wr==null?kr.writeU8(0):(kr.writeU8(1),serializeField(fr,br,wr,Er.type,kr));break}case"map":{kr.writeU32(wr.size),wr.forEach((jr,Br)=>{serializeField(fr,br,Br,Er.key,kr),serializeField(fr,br,jr,Er.value,kr)});break}default:throw new BorshError(`FieldType ${Er} unrecognized`)}else serializeStruct(fr,wr,kr)}catch(jr){throw jr instanceof BorshError&&jr.addToFieldPath(br),jr}}function serializeStruct(fr,br,wr){if(typeof br.borshSerialize=="function"){br.borshSerialize(wr);return}const Er=fr.get(br.constructor);if(!Er)throw new BorshError(`Class ${br.constructor.name} is missing in schema`);if(Er.kind==="struct")Er.fields.map(([kr,jr])=>{serializeField(fr,kr,br[kr],jr,wr)});else if(Er.kind==="enum"){const kr=br[Er.field];for(let jr=0;jrdeserializeField(fr,br,wr[0],Er))}if(wr.kind==="option")return Er.readU8()?deserializeField(fr,br,wr.type,Er):void 0;if(wr.kind==="map"){let kr=new Map;const jr=Er.readU32();for(let Br=0;Br=Er.values.length)throw new BorshError(`Enum index: ${kr} is out of range`);const[jr,Br]=Er.values[kr],Wr=deserializeField(fr,jr,Br,wr);return new br({[jr]:Wr})}throw new BorshError(`Unexpected schema kind: ${Er.kind} for ${br.constructor.name}`)}function deserialize(fr,br,wr,Er=BinaryReader){const kr=new Er(wr),jr=deserializeStruct(fr,br,kr);if(kr.offsetthis.span)throw new RangeError("indeterminate span");return this.span}replicate(br){const wr=Object.create(this.constructor.prototype);return Object.assign(wr,this),wr.property=br,wr}fromArray(br){}}Layout$1.Layout=Layout;function nameWithProperty(fr,br){return br.property?fr+"["+br.property+"]":fr}Layout$1.nameWithProperty=nameWithProperty;function bindConstructorLayout(fr,br){if(typeof fr!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(fr,"layout_"))throw new Error("Class is already bound to a layout");if(!(br&&br instanceof Layout))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(br,"boundConstructor_"))throw new Error("layout is already bound to a constructor");fr.layout_=br,br.boundConstructor_=fr,br.makeDestinationObject=()=>new fr,Object.defineProperty(fr.prototype,"encode",{value(wr,Er){return br.encode(this,wr,Er)},writable:!0}),Object.defineProperty(fr,"decode",{value(wr,Er){return br.decode(wr,Er)},writable:!0})}Layout$1.bindConstructorLayout=bindConstructorLayout;class ExternalLayout extends Layout{isCount(){throw new Error("ExternalLayout is abstract")}}Layout$1.ExternalLayout=ExternalLayout;class GreedyCount extends ExternalLayout{constructor(br=1,wr){if(!Number.isInteger(br)||0>=br)throw new TypeError("elementSpan must be a (positive) integer");super(-1,wr),this.elementSpan=br}isCount(){return!0}decode(br,wr=0){checkUint8Array(br);const Er=br.length-wr;return Math.floor(Er/this.elementSpan)}encode(br,wr,Er){return 0}}Layout$1.GreedyCount=GreedyCount;class OffsetLayout extends ExternalLayout{constructor(br,wr=0,Er){if(!(br instanceof Layout))throw new TypeError("layout must be a Layout");if(!Number.isInteger(wr))throw new TypeError("offset must be integer or undefined");super(br.span,Er||br.property),this.layout=br,this.offset=wr}isCount(){return this.layout instanceof UInt||this.layout instanceof UIntBE}decode(br,wr=0){return this.layout.decode(br,wr+this.offset)}encode(br,wr,Er=0){return this.layout.encode(br,wr,Er+this.offset)}}Layout$1.OffsetLayout=OffsetLayout;class UInt extends Layout{constructor(br,wr){if(super(br,wr),6Br+kr.encode(Wr,wr,Er+Br),0);return this.count instanceof ExternalLayout&&this.count.encode(br.length,wr,Er),jr}}Layout$1.Sequence=Sequence;class Structure extends Layout{constructor(br,wr,Er){if(!(Array.isArray(br)&&br.reduce((jr,Br)=>jr&&Br instanceof Layout,!0)))throw new TypeError("fields must be array of Layout instances");typeof wr=="boolean"&&Er===void 0&&(Er=wr,wr=void 0);for(const jr of br)if(0>jr.span&&jr.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let kr=-1;try{kr=br.reduce((jr,Br)=>jr+Br.getSpan(),0)}catch{}super(kr,wr),this.fields=br,this.decodePrefixes=!!Er}getSpan(br,wr=0){if(0<=this.span)return this.span;let Er=0;try{Er=this.fields.reduce((kr,jr)=>{const Br=jr.getSpan(br,wr);return wr+=Br,kr+Br},0)}catch{throw new RangeError("indeterminate span")}return Er}decode(br,wr=0){checkUint8Array(br);const Er=this.makeDestinationObject();for(const kr of this.fields)if(kr.property!==void 0&&(Er[kr.property]=kr.decode(br,wr)),wr+=kr.getSpan(br,wr),this.decodePrefixes&&br.length===wr)break;return Er}encode(br,wr,Er=0){const kr=Er;let jr=0,Br=0;for(const Wr of this.fields){let qr=Wr.span;if(Br=0qr&&(qr=Wr.getSpan(wr,Er)))}jr=Er,Er+=qr}return jr+Br-kr}fromArray(br){const wr=this.makeDestinationObject();for(const Er of this.fields)Er.property!==void 0&&0Er.span?wr=-1:0<=wr&&(wr+=Er.span)}}}Layout$1.Structure=Structure;class UnionDiscriminator{constructor(br){this.property=br}decode(br,wr){throw new Error("UnionDiscriminator is abstract")}encode(br,wr,Er){throw new Error("UnionDiscriminator is abstract")}}Layout$1.UnionDiscriminator=UnionDiscriminator;class UnionLayoutDiscriminator extends UnionDiscriminator{constructor(br,wr){if(!(br instanceof ExternalLayout&&br.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(wr||br.property||"variant"),this.layout=br}decode(br,wr){return this.layout.decode(br,wr)}encode(br,wr,Er){return this.layout.encode(br,wr,Er)}}Layout$1.UnionLayoutDiscriminator=UnionLayoutDiscriminator;class Union extends Layout{constructor(br,wr,Er){let kr;if(br instanceof UInt||br instanceof UIntBE)kr=new UnionLayoutDiscriminator(new OffsetLayout(br));else if(br instanceof ExternalLayout&&br.isCount())kr=new UnionLayoutDiscriminator(br);else if(br instanceof UnionDiscriminator)kr=br;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(wr===void 0&&(wr=null),!(wr===null||wr instanceof Layout))throw new TypeError("defaultLayout must be null or a Layout");if(wr!==null){if(0>wr.span)throw new Error("defaultLayout must have constant span");wr.property===void 0&&(wr=wr.replicate("content"))}let jr=-1;wr&&(jr=wr.span,0<=jr&&(br instanceof UInt||br instanceof UIntBE)&&(jr+=kr.layout.span)),super(jr,Er),this.discriminator=kr,this.usesPrefixDiscriminator=br instanceof UInt||br instanceof UIntBE,this.defaultLayout=wr,this.registry={};let Br=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(Wr){return Br(Wr)},this.configGetSourceVariant=function(Wr){Br=Wr.bind(this)}}getSpan(br,wr=0){if(0<=this.span)return this.span;const Er=this.getVariant(br,wr);if(!Er)throw new Error("unable to determine span for unrecognized variant");return Er.getSpan(br,wr)}defaultGetSourceVariant(br){if(Object.prototype.hasOwnProperty.call(br,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(br,this.defaultLayout.property))return;const wr=this.registry[br[this.discriminator.property]];if(wr&&(!wr.layout||wr.property&&Object.prototype.hasOwnProperty.call(br,wr.property)))return wr}else for(const wr in this.registry){const Er=this.registry[wr];if(Er.property&&Object.prototype.hasOwnProperty.call(br,Er.property))return Er}throw new Error("unable to infer src variant")}decode(br,wr=0){let Er;const kr=this.discriminator,jr=kr.decode(br,wr),Br=this.registry[jr];if(Br===void 0){const Wr=this.defaultLayout;let qr=0;this.usesPrefixDiscriminator&&(qr=kr.layout.span),Er=this.makeDestinationObject(),Er[kr.property]=jr,Er[Wr.property]=Wr.decode(br,wr+qr)}else Er=Br.decode(br,wr);return Er}encode(br,wr,Er=0){const kr=this.getSourceVariant(br);if(kr===void 0){const jr=this.discriminator,Br=this.defaultLayout;let Wr=0;return this.usesPrefixDiscriminator&&(Wr=jr.layout.span),jr.encode(br[jr.property],wr,Er),Wr+Br.encode(br[Br.property],wr,Er+Wr)}return kr.encode(br,wr,Er)}addVariant(br,wr,Er){const kr=new VariantLayout(this,br,wr,Er);return this.registry[br]=kr,kr}getVariant(br,wr=0){let Er;return br instanceof Uint8Array?Er=this.discriminator.decode(br,wr):Er=br,this.registry[Er]}}Layout$1.Union=Union;class VariantLayout extends Layout{constructor(br,wr,Er,kr){if(!(br instanceof Union))throw new TypeError("union must be a Union");if(!Number.isInteger(wr)||0>wr)throw new TypeError("variant must be a (non-negative) integer");if(typeof Er=="string"&&kr===void 0&&(kr=Er,Er=null),Er){if(!(Er instanceof Layout))throw new TypeError("layout must be a Layout");if(br.defaultLayout!==null&&0<=Er.span&&Er.span>br.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof kr!="string")throw new TypeError("variant must have a String property")}let jr=br.span;0>br.span&&(jr=Er?Er.span:0,0<=jr&&br.usesPrefixDiscriminator&&(jr+=br.discriminator.layout.span)),super(jr,kr),this.union=br,this.variant=wr,this.layout=Er||null}getSpan(br,wr=0){if(0<=this.span)return this.span;let Er=0;this.union.usesPrefixDiscriminator&&(Er=this.union.discriminator.layout.span);let kr=0;return this.layout&&(kr=this.layout.getSpan(br,wr+Er)),Er+kr}decode(br,wr=0){const Er=this.makeDestinationObject();if(this!==this.union.getVariant(br,wr))throw new Error("variant mismatch");let kr=0;return this.union.usesPrefixDiscriminator&&(kr=this.union.discriminator.layout.span),this.layout?Er[this.property]=this.layout.decode(br,wr+kr):this.property?Er[this.property]=!0:this.union.usesPrefixDiscriminator&&(Er[this.union.discriminator.property]=this.variant),Er}encode(br,wr,Er=0){let kr=0;if(this.union.usesPrefixDiscriminator&&(kr=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(br,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,wr,Er);let jr=kr;if(this.layout&&(this.layout.encode(br[this.property],wr,Er+kr),jr+=this.layout.getSpan(wr,Er+kr),0<=this.union.span&&jr>this.union.span))throw new Error("encoded variant overruns containing union");return jr}fromArray(br){if(this.layout)return this.layout.fromArray(br)}}Layout$1.VariantLayout=VariantLayout;function fixBitwiseResult(fr){return 0>fr&&(fr+=4294967296),fr}class BitStructure extends Layout{constructor(br,wr,Er){if(!(br instanceof UInt||br instanceof UIntBE))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof wr=="string"&&Er===void 0&&(Er=wr,wr=!1),4=wr)throw new TypeError("bits must be positive integer");const kr=8*br.span,jr=br.fields.reduce((Br,Wr)=>Br+Wr.bits,0);if(wr+jr>kr)throw new Error("bits too long for span remainder ("+(kr-jr)+" of "+kr+" remain)");this.container=br,this.bits=wr,this.valueMask=(1<>>this.start}encode(br){if(typeof br!="number"||!Number.isInteger(br)||br!==fixBitwiseResult(br&this.valueMask))throw new TypeError(nameWithProperty("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const wr=this.container._packedGetValue(),Er=fixBitwiseResult(br<Er&&(Er=this.length.decode(br,wr)),Er}decode(br,wr=0){let Er=this.span;return 0>Er&&(Er=this.length.decode(br,wr)),uint8ArrayToBuffer(br).slice(wr,wr+Er)}encode(br,wr,Er){let kr=this.length;if(this.length instanceof ExternalLayout&&(kr=br.length),!(br instanceof Uint8Array&&kr===br.length))throw new TypeError(nameWithProperty("Blob.encode",this)+" requires (length "+kr+") Uint8Array as src");if(Er+kr>wr.length)throw new RangeError("encoding overruns Uint8Array");const jr=uint8ArrayToBuffer(br);return uint8ArrayToBuffer(wr).write(jr.toString("hex"),Er,kr,"hex"),this.length instanceof ExternalLayout&&this.length.encode(kr,wr,Er),kr}};Layout$1.Blob=Blob$1;class CString extends Layout{constructor(br){super(-1,br)}getSpan(br,wr=0){checkUint8Array(br);let Er=wr;for(;Erwr.length)throw new RangeError("encoding overruns Buffer");const Br=uint8ArrayToBuffer(wr);return kr.copy(Br,Er),Br[Er+jr]=0,jr+1}}Layout$1.CString=CString;class UTF8 extends Layout{constructor(br,wr){if(typeof br=="string"&&wr===void 0&&(wr=br,br=void 0),br===void 0)br=-1;else if(!Number.isInteger(br))throw new TypeError("maxSpan must be an integer");super(-1,wr),this.maxSpan=br}getSpan(br,wr=0){return checkUint8Array(br),br.length-wr}decode(br,wr=0){const Er=this.getSpan(br,wr);if(0<=this.maxSpan&&this.maxSpanwr.length)throw new RangeError("encoding overruns Buffer");return kr.copy(uint8ArrayToBuffer(wr),Er),jr}}Layout$1.UTF8=UTF8;class Constant extends Layout{constructor(br,wr){super(0,wr),this.value=br}decode(br,wr){return this.value}encode(br,wr,Er){return 0}}Layout$1.Constant=Constant;Layout$1.greedy=(fr,br)=>new GreedyCount(fr,br);var offset=Layout$1.offset=(fr,br,wr)=>new OffsetLayout(fr,br,wr),u8=Layout$1.u8=fr=>new UInt(1,fr),u16=Layout$1.u16=fr=>new UInt(2,fr);Layout$1.u24=fr=>new UInt(3,fr);var u32=Layout$1.u32=fr=>new UInt(4,fr);Layout$1.u40=fr=>new UInt(5,fr);Layout$1.u48=fr=>new UInt(6,fr);var nu64=Layout$1.nu64=fr=>new NearUInt64(fr);Layout$1.u16be=fr=>new UIntBE(2,fr);Layout$1.u24be=fr=>new UIntBE(3,fr);Layout$1.u32be=fr=>new UIntBE(4,fr);Layout$1.u40be=fr=>new UIntBE(5,fr);Layout$1.u48be=fr=>new UIntBE(6,fr);Layout$1.nu64be=fr=>new NearUInt64BE(fr);Layout$1.s8=fr=>new Int(1,fr);Layout$1.s16=fr=>new Int(2,fr);Layout$1.s24=fr=>new Int(3,fr);Layout$1.s32=fr=>new Int(4,fr);Layout$1.s40=fr=>new Int(5,fr);Layout$1.s48=fr=>new Int(6,fr);var ns64=Layout$1.ns64=fr=>new NearInt64(fr);Layout$1.s16be=fr=>new IntBE(2,fr);Layout$1.s24be=fr=>new IntBE(3,fr);Layout$1.s32be=fr=>new IntBE(4,fr);Layout$1.s40be=fr=>new IntBE(5,fr);Layout$1.s48be=fr=>new IntBE(6,fr);Layout$1.ns64be=fr=>new NearInt64BE(fr);Layout$1.f32=fr=>new Float(fr);Layout$1.f32be=fr=>new FloatBE(fr);Layout$1.f64=fr=>new Double(fr);Layout$1.f64be=fr=>new DoubleBE(fr);var struct=Layout$1.struct=(fr,br,wr)=>new Structure(fr,br,wr);Layout$1.bits=(fr,br,wr)=>new BitStructure(fr,br,wr);var seq=Layout$1.seq=(fr,br,wr)=>new Sequence(fr,br,wr);Layout$1.union=(fr,br,wr)=>new Union(fr,br,wr);Layout$1.unionLayoutDiscriminator=(fr,br)=>new UnionLayoutDiscriminator(fr,br);var blob=Layout$1.blob=(fr,br)=>new Blob$1(fr,br);Layout$1.cstr=fr=>new CString(fr);Layout$1.utf8=(fr,br)=>new UTF8(fr,br);Layout$1.constant=(fr,br)=>new Constant(fr,br);var browser$1={};Object.defineProperty(browser$1,"__esModule",{value:!0});function toBigIntLE(fr){{const br=Buffer$2.from(fr);br.reverse();const wr=br.toString("hex");return wr.length===0?BigInt(0):BigInt(`0x${wr}`)}}var toBigIntLE_1=browser$1.toBigIntLE=toBigIntLE;function toBigIntBE(fr){{const br=fr.toString("hex");return br.length===0?BigInt(0):BigInt(`0x${br}`)}}browser$1.toBigIntBE=toBigIntBE;function toBufferLE(fr,br){{const wr=fr.toString(16),Er=Buffer$2.from(wr.padStart(br*2,"0").slice(0,br*2),"hex");return Er.reverse(),Er}}var toBufferLE_1=browser$1.toBufferLE=toBufferLE;function toBufferBE(fr,br){{const wr=fr.toString(16);return Buffer$2.from(wr.padStart(br*2,"0").slice(0,br*2),"hex")}}browser$1.toBufferBE=toBufferBE;let StructError$2=class extends TypeError{constructor(br,wr){let Er;const{message:kr,explanation:jr,...Br}=br,{path:Wr}=br,qr=Wr.length===0?kr:`At path: ${Wr.join(".")} -- ${kr}`;super(jr??qr),jr!=null&&(this.cause=qr),Object.assign(this,Br),this.name=this.constructor.name,this.failures=()=>Er??(Er=[br,...wr()])}};function isIterable$2(fr){return isObject$2(fr)&&typeof fr[Symbol.iterator]=="function"}function isObject$2(fr){return typeof fr=="object"&&fr!=null}function print$2(fr){return typeof fr=="symbol"?fr.toString():typeof fr=="string"?JSON.stringify(fr):`${fr}`}function shiftIterator$2(fr){const{done:br,value:wr}=fr.next();return br?void 0:wr}function toFailure$2(fr,br,wr,Er){if(fr===!0)return;fr===!1?fr={}:typeof fr=="string"&&(fr={message:fr});const{path:kr,branch:jr}=br,{type:Br}=wr,{refinement:Wr,message:qr=`Expected a value of type \`${Br}\`${Wr?` with refinement \`${Wr}\``:""}, but received: \`${print$2(Er)}\``}=fr;return{value:Er,type:Br,refinement:Wr,key:kr[kr.length-1],path:kr,branch:jr,...fr,message:qr}}function*toFailures$2(fr,br,wr,Er){isIterable$2(fr)||(fr=[fr]);for(const kr of fr){const jr=toFailure$2(kr,br,wr,Er);jr&&(yield jr)}}function*run$2(fr,br,wr={}){const{path:Er=[],branch:kr=[fr],coerce:jr=!1,mask:Br=!1}=wr,Wr={path:Er,branch:kr};if(jr&&(fr=br.coercer(fr,Wr),Br&&br.type!=="type"&&isObject$2(br.schema)&&isObject$2(fr)&&!Array.isArray(fr)))for(const Hr in fr)br.schema[Hr]===void 0&&delete fr[Hr];let qr="valid";for(const Hr of br.validator(fr,Wr))Hr.explanation=wr.message,qr="not_valid",yield[Hr,void 0];for(let[Hr,Vr,Zr]of br.entries(fr,Wr)){const Jr=run$2(Vr,Zr,{path:Hr===void 0?Er:[...Er,Hr],branch:Hr===void 0?kr:[...kr,Vr],coerce:jr,mask:Br,message:wr.message});for(const Qr of Jr)Qr[0]?(qr=Qr[0].refinement!=null?"not_refined":"not_valid",yield[Qr[0],void 0]):jr&&(Vr=Qr[1],Hr===void 0?fr=Vr:fr instanceof Map?fr.set(Hr,Vr):fr instanceof Set?fr.add(Vr):isObject$2(fr)&&(Vr!==void 0||Hr in fr)&&(fr[Hr]=Vr))}if(qr!=="not_valid")for(const Hr of br.refiner(fr,Wr))Hr.explanation=wr.message,qr="not_refined",yield[Hr,void 0];qr==="valid"&&(yield[void 0,fr])}let Struct$5=class{constructor(br){const{type:wr,schema:Er,validator:kr,refiner:jr,coercer:Br=qr=>qr,entries:Wr=function*(){}}=br;this.type=wr,this.schema=Er,this.entries=Wr,this.coercer=Br,kr?this.validator=(qr,Hr)=>{const Vr=kr(qr,Hr);return toFailures$2(Vr,Hr,this,qr)}:this.validator=()=>[],jr?this.refiner=(qr,Hr)=>{const Vr=jr(qr,Hr);return toFailures$2(Vr,Hr,this,qr)}:this.refiner=()=>[]}assert(br,wr){return assert$3(br,this,wr)}create(br,wr){return create$2(br,this,wr)}is(br){return is$2(br,this)}mask(br,wr){return mask$2(br,this,wr)}validate(br,wr={}){return validate$3(br,this,wr)}};function assert$3(fr,br,wr){const Er=validate$3(fr,br,{message:wr});if(Er[0])throw Er[0]}function create$2(fr,br,wr){const Er=validate$3(fr,br,{coerce:!0,message:wr});if(Er[0])throw Er[0];return Er[1]}function mask$2(fr,br,wr){const Er=validate$3(fr,br,{coerce:!0,mask:!0,message:wr});if(Er[0])throw Er[0];return Er[1]}function is$2(fr,br){return!validate$3(fr,br)[0]}function validate$3(fr,br,wr={}){const Er=run$2(fr,br,wr),kr=shiftIterator$2(Er);return kr[0]?[new StructError$2(kr[0],function*(){for(const Br of Er)Br[0]&&(yield Br[0])}),void 0]:[void 0,kr[1]]}function define$2(fr,br){return new Struct$5({type:fr,schema:null,validator:br})}function any$2(){return define$2("any",()=>!0)}function array$2(fr){return new Struct$5({type:"array",schema:fr,*entries(br){if(fr&&Array.isArray(br))for(const[wr,Er]of br.entries())yield[wr,Er,fr]},coercer(br){return Array.isArray(br)?br.slice():br},validator(br){return Array.isArray(br)||`Expected an array value, but received: ${print$2(br)}`}})}function boolean$2(){return define$2("boolean",fr=>typeof fr=="boolean")}function instance$2(fr){return define$2("instance",br=>br instanceof fr||`Expected a \`${fr.name}\` instance, but received: ${print$2(br)}`)}function literal$2(fr){const br=print$2(fr),wr=typeof fr;return new Struct$5({type:"literal",schema:wr==="string"||wr==="number"||wr==="boolean"?fr:null,validator(Er){return Er===fr||`Expected the literal \`${br}\`, but received: ${print$2(Er)}`}})}function never$2(){return define$2("never",()=>!1)}function nullable$2(fr){return new Struct$5({...fr,validator:(br,wr)=>br===null||fr.validator(br,wr),refiner:(br,wr)=>br===null||fr.refiner(br,wr)})}function number$2(){return define$2("number",fr=>typeof fr=="number"&&!isNaN(fr)||`Expected a number, but received: ${print$2(fr)}`)}function optional$2(fr){return new Struct$5({...fr,validator:(br,wr)=>br===void 0||fr.validator(br,wr),refiner:(br,wr)=>br===void 0||fr.refiner(br,wr)})}function record$2(fr,br){return new Struct$5({type:"record",schema:null,*entries(wr){if(isObject$2(wr))for(const Er in wr){const kr=wr[Er];yield[Er,Er,fr],yield[Er,kr,br]}},validator(wr){return isObject$2(wr)||`Expected an object, but received: ${print$2(wr)}`}})}function string$2(){return define$2("string",fr=>typeof fr=="string"||`Expected a string, but received: ${print$2(fr)}`)}function tuple$2(fr){const br=never$2();return new Struct$5({type:"tuple",schema:null,*entries(wr){if(Array.isArray(wr)){const Er=Math.max(fr.length,wr.length);for(let kr=0;krwr.type).join(" | ");return new Struct$5({type:"union",schema:null,coercer(wr){for(const Er of fr){const[kr,jr]=Er.validate(wr,{coerce:!0});if(!kr)return jr}return wr},validator(wr,Er){const kr=[];for(const jr of fr){const[...Br]=run$2(wr,jr,Er),[Wr]=Br;if(Wr[0])for(const[qr]of Br)qr&&kr.push(qr);else return[]}return[`Expected the value to satisfy a union of \`${br}\`, but received: ${print$2(wr)}`,...kr]}})}function unknown$2(){return define$2("unknown",()=>!0)}function coerce$2(fr,br,wr){return new Struct$5({...fr,coercer:(Er,kr)=>is$2(Er,br)?fr.coercer(wr(Er,kr),kr):fr.coercer(Er,kr)})}var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&(getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!getRandomValues))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}const REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate$2(fr){return typeof fr=="string"&®EX.test(fr)}var byteToHex=[];for(var i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify$1(fr){var br=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,wr=(byteToHex[fr[br+0]]+byteToHex[fr[br+1]]+byteToHex[fr[br+2]]+byteToHex[fr[br+3]]+"-"+byteToHex[fr[br+4]]+byteToHex[fr[br+5]]+"-"+byteToHex[fr[br+6]]+byteToHex[fr[br+7]]+"-"+byteToHex[fr[br+8]]+byteToHex[fr[br+9]]+"-"+byteToHex[fr[br+10]]+byteToHex[fr[br+11]]+byteToHex[fr[br+12]]+byteToHex[fr[br+13]]+byteToHex[fr[br+14]]+byteToHex[fr[br+15]]).toLowerCase();if(!validate$2(wr))throw TypeError("Stringified UUID is invalid");return wr}var _nodeId,_clockseq,_lastMSecs=0,_lastNSecs=0;function v1(fr,br,wr){var Er=br&&wr||0,kr=br||new Array(16);fr=fr||{};var jr=fr.node||_nodeId,Br=fr.clockseq!==void 0?fr.clockseq:_clockseq;if(jr==null||Br==null){var Wr=fr.random||(fr.rng||rng)();jr==null&&(jr=_nodeId=[Wr[0]|1,Wr[1],Wr[2],Wr[3],Wr[4],Wr[5]]),Br==null&&(Br=_clockseq=(Wr[6]<<8|Wr[7])&16383)}var qr=fr.msecs!==void 0?fr.msecs:Date.now(),Hr=fr.nsecs!==void 0?fr.nsecs:_lastNSecs+1,Vr=qr-_lastMSecs+(Hr-_lastNSecs)/1e4;if(Vr<0&&fr.clockseq===void 0&&(Br=Br+1&16383),(Vr<0||qr>_lastMSecs)&&fr.nsecs===void 0&&(Hr=0),Hr>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=qr,_lastNSecs=Hr,_clockseq=Br,qr+=122192928e5;var Zr=((qr&268435455)*1e4+Hr)%4294967296;kr[Er++]=Zr>>>24&255,kr[Er++]=Zr>>>16&255,kr[Er++]=Zr>>>8&255,kr[Er++]=Zr&255;var Jr=qr/4294967296*1e4&268435455;kr[Er++]=Jr>>>8&255,kr[Er++]=Jr&255,kr[Er++]=Jr>>>24&15|16,kr[Er++]=Jr>>>16&255,kr[Er++]=Br>>>8|128,kr[Er++]=Br&255;for(var Qr=0;Qr<6;++Qr)kr[Er+Qr]=jr[Qr];return br||stringify$1(kr)}function parse(fr){if(!validate$2(fr))throw TypeError("Invalid UUID");var br,wr=new Uint8Array(16);return wr[0]=(br=parseInt(fr.slice(0,8),16))>>>24,wr[1]=br>>>16&255,wr[2]=br>>>8&255,wr[3]=br&255,wr[4]=(br=parseInt(fr.slice(9,13),16))>>>8,wr[5]=br&255,wr[6]=(br=parseInt(fr.slice(14,18),16))>>>8,wr[7]=br&255,wr[8]=(br=parseInt(fr.slice(19,23),16))>>>8,wr[9]=br&255,wr[10]=(br=parseInt(fr.slice(24,36),16))/1099511627776&255,wr[11]=br/4294967296&255,wr[12]=br>>>24&255,wr[13]=br>>>16&255,wr[14]=br>>>8&255,wr[15]=br&255,wr}function stringToBytes(fr){fr=unescape(encodeURIComponent(fr));for(var br=[],wr=0;wr>5]>>>kr%32&255,Br=parseInt(Er.charAt(jr>>>4&15)+Er.charAt(jr&15),16);br.push(Br)}return br}function getOutputLength(fr){return(fr+64>>>9<<4)+14+1}function wordsToMd5(fr,br){fr[br>>5]|=128<>5]|=(fr[Er/8]&255)<>16)+(br>>16)+(wr>>16);return Er<<16|wr&65535}function bitRotateLeft(fr,br){return fr<>>32-br}function md5cmn(fr,br,wr,Er,kr,jr){return safeAdd(bitRotateLeft(safeAdd(safeAdd(br,fr),safeAdd(Er,jr)),kr),wr)}function md5ff(fr,br,wr,Er,kr,jr,Br){return md5cmn(br&wr|~br&Er,fr,br,kr,jr,Br)}function md5gg(fr,br,wr,Er,kr,jr,Br){return md5cmn(br&Er|wr&~Er,fr,br,kr,jr,Br)}function md5hh(fr,br,wr,Er,kr,jr,Br){return md5cmn(br^wr^Er,fr,br,kr,jr,Br)}function md5ii(fr,br,wr,Er,kr,jr,Br){return md5cmn(wr^(br|~Er),fr,br,kr,jr,Br)}var v3=v35("v3",48,md5);function v4(fr,br,wr){fr=fr||{};var Er=fr.random||(fr.rng||rng)();if(Er[6]=Er[6]&15|64,Er[8]=Er[8]&63|128,br){wr=wr||0;for(var kr=0;kr<16;++kr)br[wr+kr]=Er[kr];return br}return stringify$1(Er)}function f(fr,br,wr,Er){switch(fr){case 0:return br&wr^~br&Er;case 1:return br^wr^Er;case 2:return br&wr^br&Er^wr&Er;case 3:return br^wr^Er}}function ROTL(fr,br){return fr<>>32-br}function sha1(fr){var br=[1518500249,1859775393,2400959708,3395469782],wr=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof fr=="string"){var Er=unescape(encodeURIComponent(fr));fr=[];for(var kr=0;kr>>0;jn=An,An=In,In=ROTL(Cn,30)>>>0,Cn=En,En=to}wr[0]=wr[0]+En>>>0,wr[1]=wr[1]+Cn>>>0,wr[2]=wr[2]+In>>>0,wr[3]=wr[3]+An>>>0,wr[4]=wr[4]+jn>>>0}return[wr[0]>>24&255,wr[0]>>16&255,wr[0]>>8&255,wr[0]&255,wr[1]>>24&255,wr[1]>>16&255,wr[1]>>8&255,wr[1]&255,wr[2]>>24&255,wr[2]>>16&255,wr[2]>>8&255,wr[2]&255,wr[3]>>24&255,wr[3]>>16&255,wr[3]>>8&255,wr[3]&255,wr[4]>>24&255,wr[4]>>16&255,wr[4]>>8&255,wr[4]&255]}var v5=v35("v5",80,sha1);const nil="00000000-0000-0000-0000-000000000000";function version$5(fr){if(!validate$2(fr))throw TypeError("Invalid UUID");return parseInt(fr.substr(14,1),16)}const esmBrowser=Object.freeze(Object.defineProperty({__proto__:null,NIL:nil,parse,stringify:stringify$1,v1,v3,v4,v5,validate:validate$2,version:version$5},Symbol.toStringTag,{value:"Module"})),require$$0=getAugmentedNamespace(esmBrowser),uuid$1=require$$0.v4,generateRequest$1=function(fr,br,wr,Er){if(typeof fr!="string")throw new TypeError(fr+" must be a string");Er=Er||{};const kr=typeof Er.version=="number"?Er.version:2;if(kr!==1&&kr!==2)throw new TypeError(kr+" must be 1 or 2");const jr={method:fr};if(kr===2&&(jr.jsonrpc="2.0"),br){if(typeof br!="object"&&!Array.isArray(br))throw new TypeError(br+" must be an object, array or omitted");jr.params=br}if(typeof wr>"u"){const Br=typeof Er.generator=="function"?Er.generator:function(){return uuid$1()};jr.id=Br(jr,Er)}else kr===2&&wr===null?Er.notificationIdNull&&(jr.id=null):jr.id=wr;return jr};var generateRequest_1=generateRequest$1;const uuid=require$$0.v4,generateRequest=generateRequest_1,ClientBrowser=function(fr,br){if(!(this instanceof ClientBrowser))return new ClientBrowser(fr,br);br||(br={}),this.options={reviver:typeof br.reviver<"u"?br.reviver:null,replacer:typeof br.replacer<"u"?br.replacer:null,generator:typeof br.generator<"u"?br.generator:function(){return uuid()},version:typeof br.version<"u"?br.version:2,notificationIdNull:typeof br.notificationIdNull=="boolean"?br.notificationIdNull:!1},this.callServer=fr};var browser=ClientBrowser;ClientBrowser.prototype.request=function(fr,br,wr,Er){const kr=this;let jr=null;const Br=Array.isArray(fr)&&typeof br=="function";if(this.options.version===1&&Br)throw new TypeError("JSON-RPC 1.0 does not support batching");if(Br||!Br&&fr&&typeof fr=="object"&&typeof br=="function")Er=br,jr=fr;else{typeof wr=="function"&&(Er=wr,wr=void 0);const Hr=typeof Er=="function";try{jr=generateRequest(fr,br,wr,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(Vr){if(Hr)return Er(Vr);throw Vr}if(!Hr)return jr}let qr;try{qr=JSON.stringify(jr,this.options.replacer)}catch(Hr){return Er(Hr)}return this.callServer(qr,function(Hr,Vr){kr._parseResponse(Hr,Vr,Er)}),jr};ClientBrowser.prototype._parseResponse=function(fr,br,wr){if(fr){wr(fr);return}if(!br)return wr();let Er;try{Er=JSON.parse(br,this.options.reviver)}catch(kr){return wr(kr)}if(wr.length===3)if(Array.isArray(Er)){const kr=function(Br){return typeof Br.error<"u"},jr=function(Br){return!kr(Br)};return wr(null,Er.filter(kr),Er.filter(jr))}else return wr(null,Er.error,Er.result);wr(null,Er)};const RpcClient=getDefaultExportFromCjs$2(browser);var client={},eventemitter3={exports:{}};(function(fr){var br=Object.prototype.hasOwnProperty,wr="~";function Er(){}Object.create&&(Er.prototype=Object.create(null),new Er().__proto__||(wr=!1));function kr(qr,Hr,Vr){this.fn=qr,this.context=Hr,this.once=Vr||!1}function jr(qr,Hr,Vr,Zr,Jr){if(typeof Vr!="function")throw new TypeError("The listener must be a function");var Qr=new kr(Vr,Zr||qr,Jr),_n=wr?wr+Hr:Hr;return qr._events[_n]?qr._events[_n].fn?qr._events[_n]=[qr._events[_n],Qr]:qr._events[_n].push(Qr):(qr._events[_n]=Qr,qr._eventsCount++),qr}function Br(qr,Hr){--qr._eventsCount===0?qr._events=new Er:delete qr._events[Hr]}function Wr(){this._events=new Er,this._eventsCount=0}Wr.prototype.eventNames=function(){var Hr=[],Vr,Zr;if(this._eventsCount===0)return Hr;for(Zr in Vr=this._events)br.call(Vr,Zr)&&Hr.push(wr?Zr.slice(1):Zr);return Object.getOwnPropertySymbols?Hr.concat(Object.getOwnPropertySymbols(Vr)):Hr},Wr.prototype.listeners=function(Hr){var Vr=wr?wr+Hr:Hr,Zr=this._events[Vr];if(!Zr)return[];if(Zr.fn)return[Zr.fn];for(var Jr=0,Qr=Zr.length,_n=new Array(Qr);Jr++this.rpc_id),Vr?this.dataPack=Vr:this.dataPack=new utils_cjs_1.DefaultDataPack,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(wr,Er,kr,jr){return!jr&&typeof kr=="object"&&(jr=kr,kr=null),new Promise((Br,Wr)=>{if(!this.ready)return Wr(new Error("socket not ready"));const qr=this.generate_request_id(wr,Er),Hr={jsonrpc:"2.0",method:wr,params:Er||void 0,id:qr};this.socket.send(this.dataPack.encode(Hr),jr,Vr=>{if(Vr)return Wr(Vr);this.queue[qr]={promise:[Br,Wr]},kr&&(this.queue[qr].timeout=setTimeout(()=>{delete this.queue[qr],Wr(new Error("reply timeout"))},kr))})})}async login(wr){const Er=await this.call("rpc.login",wr);if(!Er)throw new Error("authentication failed");return Er}async listMethods(){return await this.call("__listMethods")}notify(wr,Er){return new Promise((kr,jr)=>{if(!this.ready)return jr(new Error("socket not ready"));const Br={jsonrpc:"2.0",method:wr,params:Er};this.socket.send(this.dataPack.encode(Br),Wr=>{if(Wr)return jr(Wr);kr()})})}async subscribe(wr){typeof wr=="string"&&(wr=[wr]);const Er=await this.call("rpc.on",wr);if(typeof wr=="string"&&Er[wr]!=="ok")throw new Error("Failed subscribing to an event '"+wr+"' with: "+Er[wr]);return Er}async unsubscribe(wr){typeof wr=="string"&&(wr=[wr]);const Er=await this.call("rpc.off",wr);if(typeof wr=="string"&&Er[wr]!=="ok")throw new Error("Failed unsubscribing from an event with: "+Er);return Er}close(wr,Er){this.socket.close(wr||1e3,Er)}setAutoReconnect(wr){this.reconnect=wr}setReconnectInterval(wr){this.reconnect_interval=wr}setMaxReconnects(wr){this.max_reconnects=wr}_connect(wr,Er){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(wr,Er),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:kr})=>{kr instanceof ArrayBuffer&&(kr=Buffer$2.from(kr).toString());try{kr=this.dataPack.decode(kr)}catch{return}if(kr.notification&&this.listeners(kr.notification).length){if(!Object.keys(kr.params).length)return this.emit(kr.notification);const jr=[kr.notification];if(kr.params.constructor===Object)jr.push(kr.params);else for(let Br=0;Br{this.emit.apply(this,jr)})}if(!this.queue[kr.id])return kr.method?Promise.resolve().then(()=>{this.emit(kr.method,kr==null?void 0:kr.params)}):void 0;"error"in kr=="result"in kr&&this.queue[kr.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[kr.id].timeout&&clearTimeout(this.queue[kr.id].timeout),kr.error?this.queue[kr.id].promise[1](kr.error):this.queue[kr.id].promise[0](kr.result),delete this.queue[kr.id]}),this.socket.addEventListener("error",kr=>this.emit("error",kr)),this.socket.addEventListener("close",({code:kr,reason:jr})=>{this.ready&&setTimeout(()=>this.emit("close",kr,jr),0),this.ready=!1,this.socket=void 0,kr!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(wr,Er),this.reconnect_interval)))})}}var _default$1=client.default=CommonClient,websocket_browser={};Object.defineProperty(websocket_browser,"__esModule",{value:!0});const eventemitter3_1=eventemitter3Exports;class WebSocketBrowserImpl extends eventemitter3_1.EventEmitter{constructor(wr,Er,kr){super();Uu(this,"socket");this.socket=new window.WebSocket(wr,kr),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=jr=>this.emit("message",jr.data),this.socket.onerror=jr=>this.emit("error",jr),this.socket.onclose=jr=>{this.emit("close",jr.code,jr.reason)}}send(wr,Er,kr){const jr=kr||Er;try{this.socket.send(wr),jr()}catch(Br){jr(Br)}}close(wr,Er){this.socket.close(wr,Er)}addEventListener(wr,Er,kr){this.socket.addEventListener(wr,Er,kr)}}function default_1(fr,br){return new WebSocketBrowserImpl(fr,br)}var _default=websocket_browser.default=default_1;function isOnCurve$2(fr){try{return ed25519.ExtendedPoint.fromHex(fr),!0}catch{return!1}}const sign=(fr,br)=>ed25519.sign(fr,br.slice(0,32)),verify=ed25519.verify,toBuffer$2=fr=>Buffer$1$1.isBuffer(fr)?fr:fr instanceof Uint8Array?Buffer$1$1.from(fr.buffer,fr.byteOffset,fr.byteLength):Buffer$1$1.from(fr);let Struct$4=class{constructor(br){Object.assign(this,br)}encode(){return Buffer$1$1.from(serialize_1(SOLANA_SCHEMA$2,this))}static decode(br){return deserialize_1(SOLANA_SCHEMA$2,this,br)}static decodeUnchecked(br){return deserializeUnchecked_1(SOLANA_SCHEMA$2,this,br)}};const SOLANA_SCHEMA$2=new Map;var _PublicKey$2;const MAX_SEED_LENGTH$2=32,PUBLIC_KEY_LENGTH$2=32;function isPublicKeyData$2(fr){return fr._bn!==void 0}let uniquePublicKeyCounter$2=1,PublicKey$2=class hy extends Struct$4{constructor(br){if(super({}),this._bn=void 0,isPublicKeyData$2(br))this._bn=br._bn;else{if(typeof br=="string"){const wr=bs58$6.decode(br);if(wr.length!=PUBLIC_KEY_LENGTH$2)throw new Error("Invalid public key input");this._bn=new BN$2(wr)}else this._bn=new BN$2(br);if(this._bn.byteLength()>PUBLIC_KEY_LENGTH$2)throw new Error("Invalid public key input")}}static unique(){const br=new hy(uniquePublicKeyCounter$2);return uniquePublicKeyCounter$2+=1,new hy(br.toBuffer())}equals(br){return this._bn.eq(br._bn)}toBase58(){return bs58$6.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const br=this.toBuffer();return new Uint8Array(br.buffer,br.byteOffset,br.byteLength)}toBuffer(){const br=this._bn.toArrayLike(Buffer$1$1);if(br.length===PUBLIC_KEY_LENGTH$2)return br;const wr=Buffer$1$1.alloc(32);return br.copy(wr,32-br.length),wr}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(br,wr,Er){const kr=Buffer$1$1.concat([br.toBuffer(),Buffer$1$1.from(wr),Er.toBuffer()]),jr=sha256$4(kr);return new hy(jr)}static createProgramAddressSync(br,wr){let Er=Buffer$1$1.alloc(0);br.forEach(function(jr){if(jr.length>MAX_SEED_LENGTH$2)throw new TypeError("Max seed length exceeded");Er=Buffer$1$1.concat([Er,toBuffer$2(jr)])}),Er=Buffer$1$1.concat([Er,wr.toBuffer(),Buffer$1$1.from("ProgramDerivedAddress")]);const kr=sha256$4(Er);if(isOnCurve$2(kr))throw new Error("Invalid seeds, address must fall off the curve");return new hy(kr)}static async createProgramAddress(br,wr){return this.createProgramAddressSync(br,wr)}static findProgramAddressSync(br,wr){let Er=255,kr;for(;Er!=0;){try{const jr=br.concat(Buffer$1$1.from([Er]));kr=this.createProgramAddressSync(jr,wr)}catch(jr){if(jr instanceof TypeError)throw jr;Er--;continue}return[kr,Er]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(br,wr){return this.findProgramAddressSync(br,wr)}static isOnCurve(br){const wr=new hy(br);return isOnCurve$2(wr.toBytes())}};_PublicKey$2=PublicKey$2;PublicKey$2.default=new _PublicKey$2("11111111111111111111111111111111");SOLANA_SCHEMA$2.set(PublicKey$2,{kind:"struct",fields:[["_bn","u256"]]});new PublicKey$2("BPFLoader1111111111111111111111111111111111");const PACKET_DATA_SIZE=1232,VERSION_PREFIX_MASK=127,SIGNATURE_LENGTH_IN_BYTES$2=64;class TransactionExpiredBlockheightExceededError extends Error{constructor(br){super(`Signature ${br} has expired: block height exceeded.`),this.signature=void 0,this.signature=br}}Object.defineProperty(TransactionExpiredBlockheightExceededError.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class TransactionExpiredTimeoutError extends Error{constructor(br,wr){super(`Transaction was not confirmed in ${wr.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${br} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=br}}Object.defineProperty(TransactionExpiredTimeoutError.prototype,"name",{value:"TransactionExpiredTimeoutError"});class TransactionExpiredNonceInvalidError extends Error{constructor(br){super(`Signature ${br} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=br}}Object.defineProperty(TransactionExpiredNonceInvalidError.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class MessageAccountKeys{constructor(br,wr){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=br,this.accountKeysFromLookups=wr}keySegments(){const br=[this.staticAccountKeys];return this.accountKeysFromLookups&&(br.push(this.accountKeysFromLookups.writable),br.push(this.accountKeysFromLookups.readonly)),br}get(br){for(const wr of this.keySegments()){if(br256)throw new Error("Account index overflow encountered during compilation");const Er=new Map;this.keySegments().flat().forEach((jr,Br)=>{Er.set(jr.toBase58(),Br)});const kr=jr=>{const Br=Er.get(jr.toBase58());if(Br===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return Br};return br.map(jr=>({programIdIndex:kr(jr.programId),accountKeyIndexes:jr.keys.map(Br=>kr(Br.pubkey)),data:jr.data}))}}const publicKey$3=(fr="publicKey")=>blob(32,fr),signature=(fr="signature")=>blob(64,fr),rustString$2=(fr="string")=>{const br=struct([u32("length"),u32("lengthPadding"),blob(offset(u32(),-8),"chars")],fr),wr=br.decode.bind(br),Er=br.encode.bind(br),kr=br;return kr.decode=(jr,Br)=>wr(jr,Br).chars.toString(),kr.encode=(jr,Br,Wr)=>{const qr={chars:Buffer$1$1.from(jr,"utf8")};return Er(qr,Br,Wr)},kr.alloc=jr=>u32().span+u32().span+Buffer$1$1.from(jr,"utf8").length,kr},authorized$2=(fr="authorized")=>struct([publicKey$3("staker"),publicKey$3("withdrawer")],fr),lockup$2=(fr="lockup")=>struct([ns64("unixTimestamp"),ns64("epoch"),publicKey$3("custodian")],fr),voteInit$2=(fr="voteInit")=>struct([publicKey$3("nodePubkey"),publicKey$3("authorizedVoter"),publicKey$3("authorizedWithdrawer"),u8("commission")],fr),voteAuthorizeWithSeedArgs$2=(fr="voteAuthorizeWithSeedArgs")=>struct([u32("voteAuthorizationType"),publicKey$3("currentAuthorityDerivedKeyOwnerPubkey"),rustString$2("currentAuthorityDerivedKeySeed"),publicKey$3("newAuthorized")],fr);function getAlloc(fr,br){const wr=kr=>{if(kr.span>=0)return kr.span;if(typeof kr.alloc=="function")return kr.alloc(br[kr.property]);if("count"in kr&&"elementLayout"in kr){const jr=br[kr.property];if(Array.isArray(jr))return jr.length*wr(kr.elementLayout)}else if("fields"in kr)return getAlloc({layout:kr},br[kr.property]);return 0};let Er=0;return fr.layout.fields.forEach(kr=>{Er+=wr(kr)}),Er}function decodeLength(fr){let br=0,wr=0;for(;;){let Er=fr.shift();if(br|=(Er&127)<>=7,wr==0){fr.push(Er);break}else Er|=128,fr.push(Er)}}function assert$2(fr,br){if(!fr)throw new Error(br||"Assertion failed")}class CompiledKeys{constructor(br,wr){this.payer=void 0,this.keyMetaMap=void 0,this.payer=br,this.keyMetaMap=wr}static compile(br,wr){const Er=new Map,kr=Br=>{const Wr=Br.toBase58();let qr=Er.get(Wr);return qr===void 0&&(qr={isSigner:!1,isWritable:!1,isInvoked:!1},Er.set(Wr,qr)),qr},jr=kr(wr);jr.isSigner=!0,jr.isWritable=!0;for(const Br of br){kr(Br.programId).isInvoked=!0;for(const Wr of Br.keys){const qr=kr(Wr.pubkey);qr.isSigner||(qr.isSigner=Wr.isSigner),qr.isWritable||(qr.isWritable=Wr.isWritable)}}return new CompiledKeys(wr,Er)}getMessageComponents(){const br=[...this.keyMetaMap.entries()];assert$2(br.length<=256,"Max static account keys length exceeded");const wr=br.filter(([,qr])=>qr.isSigner&&qr.isWritable),Er=br.filter(([,qr])=>qr.isSigner&&!qr.isWritable),kr=br.filter(([,qr])=>!qr.isSigner&&qr.isWritable),jr=br.filter(([,qr])=>!qr.isSigner&&!qr.isWritable),Br={numRequiredSignatures:wr.length+Er.length,numReadonlySignedAccounts:Er.length,numReadonlyUnsignedAccounts:jr.length};{assert$2(wr.length>0,"Expected at least one writable signer key");const[qr]=wr[0];assert$2(qr===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const Wr=[...wr.map(([qr])=>new PublicKey$2(qr)),...Er.map(([qr])=>new PublicKey$2(qr)),...kr.map(([qr])=>new PublicKey$2(qr)),...jr.map(([qr])=>new PublicKey$2(qr))];return[Br,Wr]}extractTableLookup(br){const[wr,Er]=this.drainKeysFoundInLookupTable(br.state.addresses,Br=>!Br.isSigner&&!Br.isInvoked&&Br.isWritable),[kr,jr]=this.drainKeysFoundInLookupTable(br.state.addresses,Br=>!Br.isSigner&&!Br.isInvoked&&!Br.isWritable);if(!(wr.length===0&&kr.length===0))return[{accountKey:br.key,writableIndexes:wr,readonlyIndexes:kr},{writable:Er,readonly:jr}]}drainKeysFoundInLookupTable(br,wr){const Er=new Array,kr=new Array;for(const[jr,Br]of this.keyMetaMap.entries())if(wr(Br)){const Wr=new PublicKey$2(jr),qr=br.findIndex(Hr=>Hr.equals(Wr));qr>=0&&(assert$2(qr<256,"Max lookup table index exceeded"),Er.push(qr),kr.push(Wr),this.keyMetaMap.delete(jr))}return[Er,kr]}}const END_OF_BUFFER_ERROR_MESSAGE="Reached end of buffer unexpectedly";function guardedShift(fr){if(fr.length===0)throw new Error(END_OF_BUFFER_ERROR_MESSAGE);return fr.shift()}function guardedSplice(fr,...br){const[wr]=br;if(br.length===2?wr+(br[1]??0)>fr.length:wr>=fr.length)throw new Error(END_OF_BUFFER_ERROR_MESSAGE);return fr.splice(...br)}class Message{constructor(br){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=br.header,this.accountKeys=br.accountKeys.map(wr=>new PublicKey$2(wr)),this.recentBlockhash=br.recentBlockhash,this.instructions=br.instructions,this.instructions.forEach(wr=>this.indexToProgramIds.set(wr.programIdIndex,this.accountKeys[wr.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(br=>({programIdIndex:br.programIdIndex,accountKeyIndexes:br.accounts,data:bs58$6.decode(br.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new MessageAccountKeys(this.staticAccountKeys)}static compile(br){const wr=CompiledKeys.compile(br.instructions,br.payerKey),[Er,kr]=wr.getMessageComponents(),Br=new MessageAccountKeys(kr).compileInstructions(br.instructions).map(Wr=>({programIdIndex:Wr.programIdIndex,accounts:Wr.accountKeyIndexes,data:bs58$6.encode(Wr.data)}));return new Message({header:Er,accountKeys:kr,recentBlockhash:br.recentBlockhash,instructions:Br})}isAccountSigner(br){return br=this.header.numRequiredSignatures){const Er=br-wr,jr=this.accountKeys.length-wr-this.header.numReadonlyUnsignedAccounts;return Er!this.isProgramId(wr))}serialize(){const br=this.accountKeys.length;let wr=[];encodeLength(wr,br);const Er=this.instructions.map(Zr=>{const{accounts:Jr,programIdIndex:Qr}=Zr,_n=Array.from(bs58$6.decode(Zr.data));let En=[];encodeLength(En,Jr.length);let Cn=[];return encodeLength(Cn,_n.length),{programIdIndex:Qr,keyIndicesCount:Buffer$1$1.from(En),keyIndices:Jr,dataLength:Buffer$1$1.from(Cn),data:_n}});let kr=[];encodeLength(kr,Er.length);let jr=Buffer$1$1.alloc(PACKET_DATA_SIZE);Buffer$1$1.from(kr).copy(jr);let Br=kr.length;Er.forEach(Zr=>{const Qr=struct([u8("programIdIndex"),blob(Zr.keyIndicesCount.length,"keyIndicesCount"),seq(u8("keyIndex"),Zr.keyIndices.length,"keyIndices"),blob(Zr.dataLength.length,"dataLength"),seq(u8("userdatum"),Zr.data.length,"data")]).encode(Zr,jr,Br);Br+=Qr}),jr=jr.slice(0,Br);const Wr=struct([blob(1,"numRequiredSignatures"),blob(1,"numReadonlySignedAccounts"),blob(1,"numReadonlyUnsignedAccounts"),blob(wr.length,"keyCount"),seq(publicKey$3("key"),br,"keys"),publicKey$3("recentBlockhash")]),qr={numRequiredSignatures:Buffer$1$1.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Buffer$1$1.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Buffer$1$1.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Buffer$1$1.from(wr),keys:this.accountKeys.map(Zr=>toBuffer$2(Zr.toBytes())),recentBlockhash:bs58$6.decode(this.recentBlockhash)};let Hr=Buffer$1$1.alloc(2048);const Vr=Wr.encode(qr,Hr);return jr.copy(Hr,Vr),Hr.slice(0,Vr+jr.length)}static from(br){let wr=[...br];const Er=guardedShift(wr);if(Er!==(Er&VERSION_PREFIX_MASK))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const kr=guardedShift(wr),jr=guardedShift(wr),Br=decodeLength(wr);let Wr=[];for(let Jr=0;Jr0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new MessageAccountKeys(this.staticAccountKeys,wr)}isAccountSigner(br){return br=Er){const kr=br-Er,jr=this.addressTableLookups.reduce((Br,Wr)=>Br+Wr.writableIndexes.length,0);return kr=this.header.numRequiredSignatures){const kr=br-wr,Br=Er-wr-this.header.numReadonlyUnsignedAccounts;return krjr.key.equals(Er.accountKey));if(!kr)throw new Error(`Failed to find address lookup table account for table key ${Er.accountKey.toBase58()}`);for(const jr of Er.writableIndexes)if(jrVr.toBytes()),recentBlockhash:bs58$6.decode(this.recentBlockhash),instructionsLength:new Uint8Array(Er),serializedInstructions:wr,addressTableLookupsLength:new Uint8Array(jr),serializedAddressTableLookups:kr},Wr);return Wr.slice(0,Hr)}serializeInstructions(){let br=0;const wr=new Uint8Array(PACKET_DATA_SIZE);for(const Er of this.compiledInstructions){const kr=Array();encodeLength(kr,Er.accountKeyIndexes.length);const jr=Array();encodeLength(jr,Er.data.length);const Br=struct([u8("programIdIndex"),blob(kr.length,"encodedAccountKeyIndexesLength"),seq(u8(),Er.accountKeyIndexes.length,"accountKeyIndexes"),blob(jr.length,"encodedDataLength"),blob(Er.data.length,"data")]);br+=Br.encode({programIdIndex:Er.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(kr),accountKeyIndexes:Er.accountKeyIndexes,encodedDataLength:new Uint8Array(jr),data:Er.data},wr,br)}return wr.slice(0,br)}serializeAddressTableLookups(){let br=0;const wr=new Uint8Array(PACKET_DATA_SIZE);for(const Er of this.addressTableLookups){const kr=Array();encodeLength(kr,Er.writableIndexes.length);const jr=Array();encodeLength(jr,Er.readonlyIndexes.length);const Br=struct([publicKey$3("accountKey"),blob(kr.length,"encodedWritableIndexesLength"),seq(u8(),Er.writableIndexes.length,"writableIndexes"),blob(jr.length,"encodedReadonlyIndexesLength"),seq(u8(),Er.readonlyIndexes.length,"readonlyIndexes")]);br+=Br.encode({accountKey:Er.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(kr),writableIndexes:Er.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(jr),readonlyIndexes:Er.readonlyIndexes},wr,br)}return wr.slice(0,br)}static deserialize(br){let wr=[...br];const Er=guardedShift(wr),kr=Er&VERSION_PREFIX_MASK;assert$2(Er!==kr,"Expected versioned message but received legacy message");const jr=kr;assert$2(jr===0,`Expected versioned message with version 0 but found version ${jr}`);const Br={numRequiredSignatures:guardedShift(wr),numReadonlySignedAccounts:guardedShift(wr),numReadonlyUnsignedAccounts:guardedShift(wr)},Wr=[],qr=decodeLength(wr);for(let _n=0;_n{const br=VersionedMessage.deserializeMessageVersion(fr);if(br==="legacy")return Message.from(fr);if(br===0)return MessageV0.deserialize(fr);throw new Error(`Transaction message version ${br} deserialization is not supported`)}};let TransactionStatus=function(fr){return fr[fr.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",fr[fr.PROCESSED=1]="PROCESSED",fr[fr.TIMED_OUT=2]="TIMED_OUT",fr[fr.NONCE_INVALID=3]="NONCE_INVALID",fr}({});const DEFAULT_SIGNATURE=Buffer$1$1.alloc(SIGNATURE_LENGTH_IN_BYTES$2).fill(0);class TransactionInstruction{constructor(br){this.keys=void 0,this.programId=void 0,this.data=Buffer$1$1.alloc(0),this.programId=br.programId,this.keys=br.keys,br.data&&(this.data=br.data)}toJSON(){return{keys:this.keys.map(({pubkey:br,isSigner:wr,isWritable:Er})=>({pubkey:br.toJSON(),isSigner:wr,isWritable:Er})),programId:this.programId.toJSON(),data:[...this.data]}}}class Transaction{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(br){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!br)if(br.feePayer&&(this.feePayer=br.feePayer),br.signatures&&(this.signatures=br.signatures),Object.prototype.hasOwnProperty.call(br,"nonceInfo")){const{minContextSlot:wr,nonceInfo:Er}=br;this.minNonceContextSlot=wr,this.nonceInfo=Er}else if(Object.prototype.hasOwnProperty.call(br,"lastValidBlockHeight")){const{blockhash:wr,lastValidBlockHeight:Er}=br;this.recentBlockhash=wr,this.lastValidBlockHeight=Er}else{const{recentBlockhash:wr,nonceInfo:Er}=br;Er&&(this.nonceInfo=Er),this.recentBlockhash=wr}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(br=>br.toJSON()),signers:this.signatures.map(({publicKey:br})=>br.toJSON())}}add(...br){if(br.length===0)throw new Error("No instructions");return br.forEach(wr=>{"instructions"in wr?this.instructions=this.instructions.concat(wr.instructions):"data"in wr&&"programId"in wr&&"keys"in wr?this.instructions.push(wr):this.instructions.push(new TransactionInstruction(wr))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let br,wr;if(this.nonceInfo?(br=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?wr=[this.nonceInfo.nonceInstruction,...this.instructions]:wr=this.instructions):(br=this.recentBlockhash,wr=this.instructions),!br)throw new Error("Transaction recentBlockhash required");wr.length<1&&console.warn("No instructions provided");let Er;if(this.feePayer)Er=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)Er=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let En=0;En{En.keys.forEach(In=>{jr.push({...In})});const Cn=En.programId.toString();kr.includes(Cn)||kr.push(Cn)}),kr.forEach(En=>{jr.push({pubkey:new PublicKey$2(En),isSigner:!1,isWritable:!1})});const Br=[];jr.forEach(En=>{const Cn=En.pubkey.toString(),In=Br.findIndex(An=>An.pubkey.toString()===Cn);In>-1?(Br[In].isWritable=Br[In].isWritable||En.isWritable,Br[In].isSigner=Br[In].isSigner||En.isSigner):Br.push(En)}),Br.sort(function(En,Cn){if(En.isSigner!==Cn.isSigner)return En.isSigner?-1:1;if(En.isWritable!==Cn.isWritable)return En.isWritable?-1:1;const In={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return En.pubkey.toBase58().localeCompare(Cn.pubkey.toBase58(),"en",In)});const Wr=Br.findIndex(En=>En.pubkey.equals(Er));if(Wr>-1){const[En]=Br.splice(Wr,1);En.isSigner=!0,En.isWritable=!0,Br.unshift(En)}else Br.unshift({pubkey:Er,isSigner:!0,isWritable:!0});for(const En of this.signatures){const Cn=Br.findIndex(In=>In.pubkey.equals(En.publicKey));if(Cn>-1)Br[Cn].isSigner||(Br[Cn].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${En.publicKey.toString()}`)}let qr=0,Hr=0,Vr=0;const Zr=[],Jr=[];Br.forEach(({pubkey:En,isSigner:Cn,isWritable:In})=>{Cn?(Zr.push(En.toString()),qr+=1,In||(Hr+=1)):(Jr.push(En.toString()),In||(Vr+=1))});const Qr=Zr.concat(Jr),_n=wr.map(En=>{const{data:Cn,programId:In}=En;return{programIdIndex:Qr.indexOf(In.toString()),accounts:En.keys.map(An=>Qr.indexOf(An.pubkey.toString())),data:bs58$6.encode(Cn)}});return _n.forEach(En=>{assert$2(En.programIdIndex>=0),En.accounts.forEach(Cn=>assert$2(Cn>=0))}),new Message({header:{numRequiredSignatures:qr,numReadonlySignedAccounts:Hr,numReadonlyUnsignedAccounts:Vr},accountKeys:Qr,recentBlockhash:br,instructions:_n})}_compile(){const br=this.compileMessage(),wr=br.accountKeys.slice(0,br.header.numRequiredSignatures);return this.signatures.length===wr.length&&this.signatures.every((kr,jr)=>wr[jr].equals(kr.publicKey))||(this.signatures=wr.map(Er=>({signature:null,publicKey:Er}))),br}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(br){return(await br.getFeeForMessage(this.compileMessage())).value}setSigners(...br){if(br.length===0)throw new Error("No signers");const wr=new Set;this.signatures=br.filter(Er=>{const kr=Er.toString();return wr.has(kr)?!1:(wr.add(kr),!0)}).map(Er=>({signature:null,publicKey:Er}))}sign(...br){if(br.length===0)throw new Error("No signers");const wr=new Set,Er=[];for(const jr of br){const Br=jr.publicKey.toString();wr.has(Br)||(wr.add(Br),Er.push(jr))}this.signatures=Er.map(jr=>({signature:null,publicKey:jr.publicKey}));const kr=this._compile();this._partialSign(kr,...Er)}partialSign(...br){if(br.length===0)throw new Error("No signers");const wr=new Set,Er=[];for(const jr of br){const Br=jr.publicKey.toString();wr.has(Br)||(wr.add(Br),Er.push(jr))}const kr=this._compile();this._partialSign(kr,...Er)}_partialSign(br,...wr){const Er=br.serialize();wr.forEach(kr=>{const jr=sign(Er,kr.secretKey);this._addSignature(kr.publicKey,toBuffer$2(jr))})}addSignature(br,wr){this._compile(),this._addSignature(br,wr)}_addSignature(br,wr){assert$2(wr.length===64);const Er=this.signatures.findIndex(kr=>br.equals(kr.publicKey));if(Er<0)throw new Error(`unknown signer: ${br.toString()}`);this.signatures[Er].signature=Buffer$1$1.from(wr)}verifySignatures(br=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),br)}_getMessageSignednessErrors(br,wr){const Er={};for(const{signature:kr,publicKey:jr}of this.signatures)kr===null?wr&&(Er.missing||(Er.missing=[])).push(jr):verify(kr,br,jr.toBytes())||(Er.invalid||(Er.invalid=[])).push(jr);return Er.invalid||Er.missing?Er:void 0}serialize(br){const{requireAllSignatures:wr,verifySignatures:Er}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},br),kr=this.serializeMessage();if(Er){const jr=this._getMessageSignednessErrors(kr,wr);if(jr){let Br="Signature verification failed.";throw jr.invalid&&(Br+=` Invalid signature for public key${jr.invalid.length===1?"":"(s)"} [\`${jr.invalid.map(Wr=>Wr.toBase58()).join("`, `")}\`].`),jr.missing&&(Br+=` Missing signature for public key${jr.missing.length===1?"":"(s)"} [\`${jr.missing.map(Wr=>Wr.toBase58()).join("`, `")}\`].`),new Error(Br)}}return this._serialize(kr)}_serialize(br){const{signatures:wr}=this,Er=[];encodeLength(Er,wr.length);const kr=Er.length+wr.length*64+br.length,jr=Buffer$1$1.alloc(kr);return assert$2(wr.length<256),Buffer$1$1.from(Er).copy(jr,0),wr.forEach(({signature:Br},Wr)=>{Br!==null&&(assert$2(Br.length===64,"signature has invalid length"),Buffer$1$1.from(Br).copy(jr,Er.length+Wr*64))}),br.copy(jr,Er.length+wr.length*64),assert$2(jr.length<=PACKET_DATA_SIZE,`Transaction too large: ${jr.length} > ${PACKET_DATA_SIZE}`),jr}get keys(){return assert$2(this.instructions.length===1),this.instructions[0].keys.map(br=>br.pubkey)}get programId(){return assert$2(this.instructions.length===1),this.instructions[0].programId}get data(){return assert$2(this.instructions.length===1),this.instructions[0].data}static from(br){let wr=[...br];const Er=decodeLength(wr);let kr=[];for(let jr=0;jr0&&(Er.feePayer=br.accountKeys[0]),wr.forEach((kr,jr)=>{const Br={signature:kr==bs58$6.encode(DEFAULT_SIGNATURE)?null:bs58$6.decode(kr),publicKey:br.accountKeys[jr]};Er.signatures.push(Br)}),br.instructions.forEach(kr=>{const jr=kr.accounts.map(Br=>{const Wr=br.accountKeys[Br];return{pubkey:Wr,isSigner:Er.signatures.some(qr=>qr.publicKey.toString()===Wr.toString())||br.isAccountSigner(Br),isWritable:br.isAccountWritable(Br)}});Er.instructions.push(new TransactionInstruction({keys:jr,programId:br.accountKeys[kr.programIdIndex],data:bs58$6.decode(kr.data)}))}),Er._message=br,Er._json=Er.toJSON(),Er}}class VersionedTransaction{get version(){return this.message.version}constructor(br,wr){if(this.signatures=void 0,this.message=void 0,wr!==void 0)assert$2(wr.length===br.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=wr;else{const Er=[];for(let kr=0;krBr.equals(kr.publicKey));assert$2(jr>=0,`Cannot sign with non signer key ${kr.publicKey.toBase58()}`),this.signatures[jr]=sign(wr,kr.secretKey)}}addSignature(br,wr){assert$2(wr.byteLength===64,"Signature must be 64 bytes long");const kr=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(jr=>jr.equals(br));assert$2(kr>=0,`Can not add signature; \`${br.toBase58()}\` is not required to sign this transaction`),this.signatures[kr]=wr}}const NUM_TICKS_PER_SECOND=160,DEFAULT_TICKS_PER_SLOT=64,NUM_SLOTS_PER_SECOND=NUM_TICKS_PER_SECOND/DEFAULT_TICKS_PER_SLOT,MS_PER_SLOT=1e3/NUM_SLOTS_PER_SECOND;new PublicKey$2("SysvarC1ock11111111111111111111111111111111");new PublicKey$2("SysvarEpochSchedu1e111111111111111111111111");new PublicKey$2("Sysvar1nstructions1111111111111111111111111");const SYSVAR_RECENT_BLOCKHASHES_PUBKEY=new PublicKey$2("SysvarRecentB1ockHashes11111111111111111111"),SYSVAR_RENT_PUBKEY=new PublicKey$2("SysvarRent111111111111111111111111111111111");new PublicKey$2("SysvarRewards111111111111111111111111111111");new PublicKey$2("SysvarS1otHashes111111111111111111111111111");new PublicKey$2("SysvarS1otHistory11111111111111111111111111");new PublicKey$2("SysvarStakeHistory1111111111111111111111111");class SendTransactionError extends Error{constructor({action:br,signature:wr,transactionMessage:Er,logs:kr}){let jr;switch(br){case"send":jr=`Transaction ${wr} resulted in an error. ${Er}. `+(kr?`Logs: @@ -4209,4 +4209,4 @@ ${JSON.stringify(kr.slice(-10),null,2)}. `:"")+"\nCatch the SendTransactionError `,br)}return wallets}function register(...fr){var br;return fr=fr.filter(wr=>!registered.has(wr)),fr.length?(fr.forEach(wr=>registered.add(wr)),(br=listeners.register)==null||br.forEach(wr=>guard(()=>wr(...fr))),function(){var Er;fr.forEach(kr=>registered.delete(kr)),(Er=listeners.unregister)==null||Er.forEach(kr=>guard(()=>kr(...fr)))}):()=>{}}function get(){return[...registered]}function on(fr,br){var wr;return(wr=listeners[fr])!=null&&wr.push(br)||(listeners[fr]=[br]),function(){var kr;listeners[fr]=(kr=listeners[fr])==null?void 0:kr.filter(jr=>br!==jr)}}function guard(fr){try{fr()}catch(br){console.error(br)}}class AppReadyEvent extends Event{constructor(br){super("wallet-standard:app-ready",{bubbles:!1,cancelable:!1,composed:!1}),_AppReadyEvent_detail.set(this,void 0),__classPrivateFieldSet(this,_AppReadyEvent_detail,br,"f")}get detail(){return __classPrivateFieldGet(this,_AppReadyEvent_detail,"f")}get type(){return"wallet-standard:app-ready"}preventDefault(){throw new Error("preventDefault cannot be called")}stopImmediatePropagation(){throw new Error("stopImmediatePropagation cannot be called")}stopPropagation(){throw new Error("stopPropagation cannot be called")}}_AppReadyEvent_detail=new WeakMap;const findWalletProviderFromWalletStandard=fr=>{const{walletStandardLocators:br}=fr;if(!br||br.length===0)return;const wr=getWallets().get();return br.reduce((Er,kr)=>{if(Er)return Er;const jr=wr.find(Br=>Br.name===kr.name);if(jr)return get$6(jr,kr.locator)},void 0)};class SolProviderHelper{constructor(br){this.wallet=br}getInjectedConfig(){if(!this.wallet||!this.wallet.injectedConfig)return;const{injectedConfig:br}=this.wallet;return br.find(wr=>wr.chain==="sol")}getInstalledProvider(){const br=this.getInjectedConfig();if(!(!br||!br.extensionLocators))return this.installedProviderLookup(br.extensionLocators)}installedProviders(){var br,wr;const Er=this.getInjectedConfig();if(!Er)return[];const kr=[];if(Er.windowLocations)for(const jr of Er.windowLocations){const Br=getProvidersFromWindow(jr);Br&&Br.length&&kr.push(...Br)}if(Er.extensionLocators.length!==0&&window.solana&&(window.solana.providers?window.solana.providers.forEach(jr=>kr.push(jr)):kr.push(window.solana)),((wr=(br=Er.walletStandardLocators)===null||br===void 0?void 0:br.length)!==null&&wr!==void 0?wr:0)>0){const jr=findWalletProviderFromWalletStandard(Er);jr&&kr.push(jr)}return kr}installedProviderLookup(br){const wr=this.installedProviders();return br.length===0?wr[0]:ProviderLookup(wr,br)}findProvider(){return this.getInstalledProvider()}isInstalledHelper(){return this.findProvider()!==void 0}getAddress(){return __awaiter$3(this,void 0,void 0,function*(){var br;const wr=this.findProvider();if(wr)return yield wr.connect(),(br=wr.publicKey)===null||br===void 0?void 0:br.toString()})}connect(){return __awaiter$3(this,void 0,void 0,function*(){const br=this.findProvider();if(br)try{return br.isConnected||(yield br.connect()),br}catch{return}})}signMessage(br){return __awaiter$3(this,void 0,void 0,function*(){if(!(yield this.getAddress()))return;const Er=this.findProvider();if(!Er)return;const kr=new TextEncoder().encode(br),jr=yield Er.signMessage(kr,"utf8");if(jr)return bufferToBase64(isSignedMessage(jr)?jr.signature:jr)})}handleAccountChange(br,wr,Er){return __awaiter$3(this,void 0,void 0,function*(){var kr;if(!Er){yield wr==null?void 0:wr.connect(),!((kr=wr==null?void 0:wr.publicKey)===null||kr===void 0)&&kr.toString()&&br.emit("accountChange",{accounts:[wr.publicKey.toString()]});return}Er.toString()&&br.emit("accountChange",{accounts:[Er.toString()]})})}_setupEventListeners(br){const wr=this.findProvider();if(!wr){logger$7.warn("Provider not found",{connector:br});return}if(!wr.on){logger$7.warn("Provider does not support event listeners",{connector:br,provider:wr});return}wr.on("accountChanged",Er=>this.handleAccountChange(br,wr,Er)),wr.on("disconnect",()=>br.emit("disconnect"))}_teardownEventListeners(){const br=this.findProvider();br&&br.removeAllListeners()}getConnectedAccounts(){return __awaiter$3(this,void 0,void 0,function*(){var br,wr;const Er=this.findProvider();if(!Er)return[];let kr;try{Er.isConnected||(kr=yield Er.connect({onlyIfTrusted:!0}))}catch{return[]}const jr=kr==null?void 0:kr.address,Br=(br=kr==null?void 0:kr.publicKey)!==null&&br!==void 0?br:(wr=Er.publicKey)===null||wr===void 0?void 0:wr.toString();return jr?[jr]:Br?[Br==null?void 0:Br.toString()]:[]})}}class SignMessageNotSupportedError extends NotSupportedError{constructor(br){super(`Message signing is currently not supported on ${br} hardware wallet. You can use signMessageViaTransaction instead to achieve similar functionality by signing a transaction with a memo instruction. - You can read more about it here https://github.com/solana-labs/solana/issues/21366`)}}class InjectedWalletBase extends SolanaWalletConnector{getSolProviderHelper(){return this.wallet||(this.wallet=findWalletBookWallet(this.walletBook,this.key)),this.wallet&&!this.solProviderHelper&&(this.solProviderHelper=new SolProviderHelper(this.wallet)),this.solProviderHelper}getProvider(){var br;return(br=this.getSolProviderHelper())===null||br===void 0?void 0:br.getInstalledProvider()}setupEventListeners(){var br;(br=this.getSolProviderHelper())===null||br===void 0||br._setupEventListeners(this)}teardownEventListeners(){var br;(br=this.getSolProviderHelper())===null||br===void 0||br._teardownEventListeners()}connect(){return __awaiter$3(this,void 0,void 0,function*(){var br;yield(br=this.getSolProviderHelper())===null||br===void 0?void 0:br.connect()})}getSigner(){return __awaiter$3(this,void 0,void 0,function*(){var br;return(br=this.getSolProviderHelper())===null||br===void 0?void 0:br.connect()})}createUiTransaction(br){return __awaiter$3(this,void 0,void 0,function*(){return yield this.validateActiveWallet(br),new SolanaUiTransaction$1({connection:this.getWalletClient(),from:br,onSubmit:Er=>__awaiter$3(this,void 0,void 0,function*(){var kr;if(!Er)return;const jr=yield this.getSigner();if(!jr)throw new Error("Signer not found");const Br=yield this.getWalletClient().getLatestBlockhash();if("version"in Er)Er.message.recentBlockhash=Br.blockhash;else{const Wr=yield this.getAddress();if(!Wr)throw new Error("User address not found");Er.recentBlockhash=Br.blockhash,Er.feePayer=(kr=Er.feePayer)!==null&&kr!==void 0?kr:new PublicKey$2(Wr)}return(yield jr.signAndSendTransaction(Er)).signature})})})}isInstalledOnBrowser(){var br;return!!(!((br=this.getSolProviderHelper())===null||br===void 0)&&br.isInstalledHelper())}getAddress(){return __awaiter$3(this,void 0,void 0,function*(){var br,wr;if(!this.isInstalledOnBrowser()){if(isMobile()&&(!((br=this.wallet)===null||br===void 0)&&br.mobile)&&this.wallet.mobile.inAppBrowser&&this.mobileExperience==="in-app-browser"){const kr=template(this.wallet.mobile.inAppBrowser)({encodedDappURI:encodeURIComponent(window.location.toString())});window.location.assign(kr)}return}return(wr=this.getSolProviderHelper())===null||wr===void 0?void 0:wr.getAddress()})}signMessage(br){return __awaiter$3(this,void 0,void 0,function*(){var wr,Er;const kr=yield(wr=this.getSolProviderHelper())===null||wr===void 0?void 0:wr.getAddress();if(kr&&this.isLedgerAddress(kr))throw new SignMessageNotSupportedError(this.name);return(Er=this.getSolProviderHelper())===null||Er===void 0?void 0:Er.signMessage(br)})}getConnectedAccounts(){return __awaiter$3(this,void 0,void 0,function*(){var br,wr;return(wr=(br=this.getSolProviderHelper())===null||br===void 0?void 0:br.getConnectedAccounts())!==null&&wr!==void 0?wr:[]})}}var version$4="3.8.2",dependencies={"@dynamic-labs/sdk-api-core":"0.0.570","@dynamic-labs/utils":"3.8.2","@dynamic-labs/logger":"3.8.2","@dynamic-labs/types":"3.8.2",eventemitter3:"5.0.1","@solana/web3.js":"1.92.1","@turnkey/http":"2.12.2","@turnkey/iframe-stamper":"2.0.0","@turnkey/solana":"0.3.9","@turnkey/webauthn-stamper":"0.5.0"};function __rest$1(fr,br){var wr={};for(var Er in fr)Object.prototype.hasOwnProperty.call(fr,Er)&&br.indexOf(Er)<0&&(wr[Er]=fr[Er]);if(fr!=null&&typeof Object.getOwnPropertySymbols=="function")for(var kr=0,Er=Object.getOwnPropertySymbols(fr);kr0?Gr:Xr},jr.min=function(Gr,Xr){return Gr.cmp(Xr)<0?Gr:Xr},jr.prototype._init=function(Gr,Xr,Sn){if(typeof Gr=="number")return this._initNumber(Gr,Xr,Sn);if(typeof Gr=="object")return this._initArray(Gr,Xr,Sn);Xr==="hex"&&(Xr=16),Er(Xr===(Xr|0)&&Xr>=2&&Xr<=36),Gr=Gr.toString().replace(/\s+/g,"");var Rn=0;Gr[0]==="-"&&(Rn++,this.negative=1),Rn=0;Rn-=3)On=Gr[Rn]|Gr[Rn-1]<<8|Gr[Rn-2]<<16,this.words[Pn]|=On<>>26-Zn&67108863,Zn+=24,Zn>=26&&(Zn-=26,Pn++);else if(Sn==="le")for(Rn=0,Pn=0;Rn>>26-Zn&67108863,Zn+=24,Zn>=26&&(Zn-=26,Pn++);return this._strip()};function Wr(Tn,Gr){var Xr=Tn.charCodeAt(Gr);if(Xr>=48&&Xr<=57)return Xr-48;if(Xr>=65&&Xr<=70)return Xr-55;if(Xr>=97&&Xr<=102)return Xr-87;Er(!1,"Invalid character in "+Tn)}function qr(Tn,Gr,Xr){var Sn=Wr(Tn,Xr);return Xr-1>=Gr&&(Sn|=Wr(Tn,Xr-1)<<4),Sn}jr.prototype._parseHex=function(Gr,Xr,Sn){this.length=Math.ceil((Gr.length-Xr)/6),this.words=new Array(this.length);for(var Rn=0;Rn=Xr;Rn-=2)Zn=qr(Gr,Xr,Rn)<=18?(Pn-=18,On+=1,this.words[On]|=Zn>>>26):Pn+=8;else{var Nn=Gr.length-Xr;for(Rn=Nn%2===0?Xr+1:Xr;Rn=18?(Pn-=18,On+=1,this.words[On]|=Zn>>>26):Pn+=8}this._strip()};function Hr(Tn,Gr,Xr,Sn){for(var Rn=0,Pn=0,On=Math.min(Tn.length,Xr),Zn=Gr;Zn=49?Pn=Nn-49+10:Nn>=17?Pn=Nn-17+10:Pn=Nn,Er(Nn>=0&&Pn1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},jr.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{jr.prototype[Symbol.for("nodejs.util.inspect.custom")]=Zr}catch{jr.prototype.inspect=Zr}else jr.prototype.inspect=Zr;function Zr(){return(this.red?""}var Jr=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],Qr=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],_n=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];jr.prototype.toString=function(Gr,Xr){Gr=Gr||10,Xr=Xr|0||1;var Sn;if(Gr===16||Gr==="hex"){Sn="";for(var Rn=0,Pn=0,On=0;On>>24-Rn&16777215,Rn+=2,Rn>=26&&(Rn-=26,On--),Pn!==0||On!==this.length-1?Sn=Jr[6-Nn.length]+Nn+Sn:Sn=Nn+Sn}for(Pn!==0&&(Sn=Pn.toString(16)+Sn);Sn.length%Xr!==0;)Sn="0"+Sn;return this.negative!==0&&(Sn="-"+Sn),Sn}if(Gr===(Gr|0)&&Gr>=2&&Gr<=36){var wn=Qr[Gr],zn=_n[Gr];Sn="";var fo=this.clone();for(fo.negative=0;!fo.isZero();){var vo=fo.modrn(zn).toString(Gr);fo=fo.idivn(zn),fo.isZero()?Sn=vo+Sn:Sn=Jr[wn-vo.length]+vo+Sn}for(this.isZero()&&(Sn="0"+Sn);Sn.length%Xr!==0;)Sn="0"+Sn;return this.negative!==0&&(Sn="-"+Sn),Sn}Er(!1,"Base should be between 2 and 36")},jr.prototype.toNumber=function(){var Gr=this.words[0];return this.length===2?Gr+=this.words[1]*67108864:this.length===3&&this.words[2]===1?Gr+=4503599627370496+this.words[1]*67108864:this.length>2&&Er(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-Gr:Gr},jr.prototype.toJSON=function(){return this.toString(16,2)},Br&&(jr.prototype.toBuffer=function(Gr,Xr){return this.toArrayLike(Br,Gr,Xr)}),jr.prototype.toArray=function(Gr,Xr){return this.toArrayLike(Array,Gr,Xr)};var En=function(Gr,Xr){return Gr.allocUnsafe?Gr.allocUnsafe(Xr):new Gr(Xr)};jr.prototype.toArrayLike=function(Gr,Xr,Sn){this._strip();var Rn=this.byteLength(),Pn=Sn||Math.max(1,Rn);Er(Rn<=Pn,"byte array longer than desired length"),Er(Pn>0,"Requested array length <= 0");var On=En(Gr,Pn),Zn=Xr==="le"?"LE":"BE";return this["_toArrayLike"+Zn](On,Rn),On},jr.prototype._toArrayLikeLE=function(Gr,Xr){for(var Sn=0,Rn=0,Pn=0,On=0;Pn>8&255),Sn>16&255),On===6?(Sn>24&255),Rn=0,On=0):(Rn=Zn>>>24,On+=2)}if(Sn=0&&(Gr[Sn--]=Zn>>8&255),Sn>=0&&(Gr[Sn--]=Zn>>16&255),On===6?(Sn>=0&&(Gr[Sn--]=Zn>>24&255),Rn=0,On=0):(Rn=Zn>>>24,On+=2)}if(Sn>=0)for(Gr[Sn--]=Rn;Sn>=0;)Gr[Sn--]=0},Math.clz32?jr.prototype._countBits=function(Gr){return 32-Math.clz32(Gr)}:jr.prototype._countBits=function(Gr){var Xr=Gr,Sn=0;return Xr>=4096&&(Sn+=13,Xr>>>=13),Xr>=64&&(Sn+=7,Xr>>>=7),Xr>=8&&(Sn+=4,Xr>>>=4),Xr>=2&&(Sn+=2,Xr>>>=2),Sn+Xr},jr.prototype._zeroBits=function(Gr){if(Gr===0)return 26;var Xr=Gr,Sn=0;return Xr&8191||(Sn+=13,Xr>>>=13),Xr&127||(Sn+=7,Xr>>>=7),Xr&15||(Sn+=4,Xr>>>=4),Xr&3||(Sn+=2,Xr>>>=2),Xr&1||Sn++,Sn},jr.prototype.bitLength=function(){var Gr=this.words[this.length-1],Xr=this._countBits(Gr);return(this.length-1)*26+Xr};function Cn(Tn){for(var Gr=new Array(Tn.bitLength()),Xr=0;Xr>>Rn&1}return Gr}jr.prototype.zeroBits=function(){if(this.isZero())return 0;for(var Gr=0,Xr=0;XrGr.length?this.clone().ior(Gr):Gr.clone().ior(this)},jr.prototype.uor=function(Gr){return this.length>Gr.length?this.clone().iuor(Gr):Gr.clone().iuor(this)},jr.prototype.iuand=function(Gr){var Xr;this.length>Gr.length?Xr=Gr:Xr=this;for(var Sn=0;SnGr.length?this.clone().iand(Gr):Gr.clone().iand(this)},jr.prototype.uand=function(Gr){return this.length>Gr.length?this.clone().iuand(Gr):Gr.clone().iuand(this)},jr.prototype.iuxor=function(Gr){var Xr,Sn;this.length>Gr.length?(Xr=this,Sn=Gr):(Xr=Gr,Sn=this);for(var Rn=0;RnGr.length?this.clone().ixor(Gr):Gr.clone().ixor(this)},jr.prototype.uxor=function(Gr){return this.length>Gr.length?this.clone().iuxor(Gr):Gr.clone().iuxor(this)},jr.prototype.inotn=function(Gr){Er(typeof Gr=="number"&&Gr>=0);var Xr=Math.ceil(Gr/26)|0,Sn=Gr%26;this._expand(Xr),Sn>0&&Xr--;for(var Rn=0;Rn0&&(this.words[Rn]=~this.words[Rn]&67108863>>26-Sn),this._strip()},jr.prototype.notn=function(Gr){return this.clone().inotn(Gr)},jr.prototype.setn=function(Gr,Xr){Er(typeof Gr=="number"&&Gr>=0);var Sn=Gr/26|0,Rn=Gr%26;return this._expand(Sn+1),Xr?this.words[Sn]=this.words[Sn]|1<Gr.length?(Sn=this,Rn=Gr):(Sn=Gr,Rn=this);for(var Pn=0,On=0;On>>26;for(;Pn!==0&&On>>26;if(this.length=Sn.length,Pn!==0)this.words[this.length]=Pn,this.length++;else if(Sn!==this)for(;OnGr.length?this.clone().iadd(Gr):Gr.clone().iadd(this)},jr.prototype.isub=function(Gr){if(Gr.negative!==0){Gr.negative=0;var Xr=this.iadd(Gr);return Gr.negative=1,Xr._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(Gr),this.negative=1,this._normSign();var Sn=this.cmp(Gr);if(Sn===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Rn,Pn;Sn>0?(Rn=this,Pn=Gr):(Rn=Gr,Pn=this);for(var On=0,Zn=0;Zn>26,this.words[Zn]=Xr&67108863;for(;On!==0&&Zn>26,this.words[Zn]=Xr&67108863;if(On===0&&Zn>>26,fo=Nn&67108863,vo=Math.min(wn,Gr.length-1),go=Math.max(0,wn-Tn.length+1);go<=vo;go++){var uo=wn-go|0;Rn=Tn.words[uo]|0,Pn=Gr.words[go]|0,On=Rn*Pn+fo,zn+=On/67108864|0,fo=On&67108863}Xr.words[wn]=fo|0,Nn=zn|0}return Nn!==0?Xr.words[wn]=Nn|0:Xr.length--,Xr._strip()}var An=function(Gr,Xr,Sn){var Rn=Gr.words,Pn=Xr.words,On=Sn.words,Zn=0,Nn,wn,zn,fo=Rn[0]|0,vo=fo&8191,go=fo>>>13,uo=Rn[1]|0,lo=uo&8191,Eo=uo>>>13,mo=Rn[2]|0,yo=mo&8191,_o=mo>>>13,Bo=Rn[3]|0,Lo=Bo&8191,Wo=Bo>>>13,na=Rn[4]|0,qo=na&8191,ga=na>>>13,wl=Rn[5]|0,No=wl&8191,Fo=wl>>>13,Nl=Rn[6]|0,Vo=Nl&8191,Uo=Nl>>>13,Ol=Rn[7]|0,$a=Ol&8191,Jo=Ol>>>13,Zl=Rn[8]|0,Cl=Zl&8191,ko=Zl>>>13,wo=Rn[9]|0,bo=wo&8191,Io=wo>>>13,Ho=Pn[0]|0,Do=Ho&8191,zo=Ho>>>13,nu=Pn[1]|0,Ll=nu&8191,_l=nu>>>13,bu=Pn[2]|0,xl=bu&8191,Tl=bu>>>13,du=Pn[3]|0,Bl=du&8191,Il=du>>>13,Eu=Pn[4]|0,Al=Eu&8191,Ml=Eu>>>13,Tu=Pn[5]|0,Ul=Tu&8191,Sl=Tu>>>13,_u=Pn[6]|0,So=_u&8191,Co=_u>>>13,Ao=Pn[7]|0,po=Ao&8191,Ro=Ao>>>13,Xo=Pn[8]|0,jo=Xo&8191,Ko=Xo>>>13,Wl=Pn[9]|0,$l=Wl&8191,El=Wl>>>13;Sn.negative=Gr.negative^Xr.negative,Sn.length=19,Nn=Math.imul(vo,Do),wn=Math.imul(vo,zo),wn=wn+Math.imul(go,Do)|0,zn=Math.imul(go,zo);var Cu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Cu>>>26)|0,Cu&=67108863,Nn=Math.imul(lo,Do),wn=Math.imul(lo,zo),wn=wn+Math.imul(Eo,Do)|0,zn=Math.imul(Eo,zo),Nn=Nn+Math.imul(vo,Ll)|0,wn=wn+Math.imul(vo,_l)|0,wn=wn+Math.imul(go,Ll)|0,zn=zn+Math.imul(go,_l)|0;var iu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(iu>>>26)|0,iu&=67108863,Nn=Math.imul(yo,Do),wn=Math.imul(yo,zo),wn=wn+Math.imul(_o,Do)|0,zn=Math.imul(_o,zo),Nn=Nn+Math.imul(lo,Ll)|0,wn=wn+Math.imul(lo,_l)|0,wn=wn+Math.imul(Eo,Ll)|0,zn=zn+Math.imul(Eo,_l)|0,Nn=Nn+Math.imul(vo,xl)|0,wn=wn+Math.imul(vo,Tl)|0,wn=wn+Math.imul(go,xl)|0,zn=zn+Math.imul(go,Tl)|0;var pu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(pu>>>26)|0,pu&=67108863,Nn=Math.imul(Lo,Do),wn=Math.imul(Lo,zo),wn=wn+Math.imul(Wo,Do)|0,zn=Math.imul(Wo,zo),Nn=Nn+Math.imul(yo,Ll)|0,wn=wn+Math.imul(yo,_l)|0,wn=wn+Math.imul(_o,Ll)|0,zn=zn+Math.imul(_o,_l)|0,Nn=Nn+Math.imul(lo,xl)|0,wn=wn+Math.imul(lo,Tl)|0,wn=wn+Math.imul(Eo,xl)|0,zn=zn+Math.imul(Eo,Tl)|0,Nn=Nn+Math.imul(vo,Bl)|0,wn=wn+Math.imul(vo,Il)|0,wn=wn+Math.imul(go,Bl)|0,zn=zn+Math.imul(go,Il)|0;var yu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(yu>>>26)|0,yu&=67108863,Nn=Math.imul(qo,Do),wn=Math.imul(qo,zo),wn=wn+Math.imul(ga,Do)|0,zn=Math.imul(ga,zo),Nn=Nn+Math.imul(Lo,Ll)|0,wn=wn+Math.imul(Lo,_l)|0,wn=wn+Math.imul(Wo,Ll)|0,zn=zn+Math.imul(Wo,_l)|0,Nn=Nn+Math.imul(yo,xl)|0,wn=wn+Math.imul(yo,Tl)|0,wn=wn+Math.imul(_o,xl)|0,zn=zn+Math.imul(_o,Tl)|0,Nn=Nn+Math.imul(lo,Bl)|0,wn=wn+Math.imul(lo,Il)|0,wn=wn+Math.imul(Eo,Bl)|0,zn=zn+Math.imul(Eo,Il)|0,Nn=Nn+Math.imul(vo,Al)|0,wn=wn+Math.imul(vo,Ml)|0,wn=wn+Math.imul(go,Al)|0,zn=zn+Math.imul(go,Ml)|0;var hu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(hu>>>26)|0,hu&=67108863,Nn=Math.imul(No,Do),wn=Math.imul(No,zo),wn=wn+Math.imul(Fo,Do)|0,zn=Math.imul(Fo,zo),Nn=Nn+Math.imul(qo,Ll)|0,wn=wn+Math.imul(qo,_l)|0,wn=wn+Math.imul(ga,Ll)|0,zn=zn+Math.imul(ga,_l)|0,Nn=Nn+Math.imul(Lo,xl)|0,wn=wn+Math.imul(Lo,Tl)|0,wn=wn+Math.imul(Wo,xl)|0,zn=zn+Math.imul(Wo,Tl)|0,Nn=Nn+Math.imul(yo,Bl)|0,wn=wn+Math.imul(yo,Il)|0,wn=wn+Math.imul(_o,Bl)|0,zn=zn+Math.imul(_o,Il)|0,Nn=Nn+Math.imul(lo,Al)|0,wn=wn+Math.imul(lo,Ml)|0,wn=wn+Math.imul(Eo,Al)|0,zn=zn+Math.imul(Eo,Ml)|0,Nn=Nn+Math.imul(vo,Ul)|0,wn=wn+Math.imul(vo,Sl)|0,wn=wn+Math.imul(go,Ul)|0,zn=zn+Math.imul(go,Sl)|0;var mu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(mu>>>26)|0,mu&=67108863,Nn=Math.imul(Vo,Do),wn=Math.imul(Vo,zo),wn=wn+Math.imul(Uo,Do)|0,zn=Math.imul(Uo,zo),Nn=Nn+Math.imul(No,Ll)|0,wn=wn+Math.imul(No,_l)|0,wn=wn+Math.imul(Fo,Ll)|0,zn=zn+Math.imul(Fo,_l)|0,Nn=Nn+Math.imul(qo,xl)|0,wn=wn+Math.imul(qo,Tl)|0,wn=wn+Math.imul(ga,xl)|0,zn=zn+Math.imul(ga,Tl)|0,Nn=Nn+Math.imul(Lo,Bl)|0,wn=wn+Math.imul(Lo,Il)|0,wn=wn+Math.imul(Wo,Bl)|0,zn=zn+Math.imul(Wo,Il)|0,Nn=Nn+Math.imul(yo,Al)|0,wn=wn+Math.imul(yo,Ml)|0,wn=wn+Math.imul(_o,Al)|0,zn=zn+Math.imul(_o,Ml)|0,Nn=Nn+Math.imul(lo,Ul)|0,wn=wn+Math.imul(lo,Sl)|0,wn=wn+Math.imul(Eo,Ul)|0,zn=zn+Math.imul(Eo,Sl)|0,Nn=Nn+Math.imul(vo,So)|0,wn=wn+Math.imul(vo,Co)|0,wn=wn+Math.imul(go,So)|0,zn=zn+Math.imul(go,Co)|0;var vu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(vu>>>26)|0,vu&=67108863,Nn=Math.imul($a,Do),wn=Math.imul($a,zo),wn=wn+Math.imul(Jo,Do)|0,zn=Math.imul(Jo,zo),Nn=Nn+Math.imul(Vo,Ll)|0,wn=wn+Math.imul(Vo,_l)|0,wn=wn+Math.imul(Uo,Ll)|0,zn=zn+Math.imul(Uo,_l)|0,Nn=Nn+Math.imul(No,xl)|0,wn=wn+Math.imul(No,Tl)|0,wn=wn+Math.imul(Fo,xl)|0,zn=zn+Math.imul(Fo,Tl)|0,Nn=Nn+Math.imul(qo,Bl)|0,wn=wn+Math.imul(qo,Il)|0,wn=wn+Math.imul(ga,Bl)|0,zn=zn+Math.imul(ga,Il)|0,Nn=Nn+Math.imul(Lo,Al)|0,wn=wn+Math.imul(Lo,Ml)|0,wn=wn+Math.imul(Wo,Al)|0,zn=zn+Math.imul(Wo,Ml)|0,Nn=Nn+Math.imul(yo,Ul)|0,wn=wn+Math.imul(yo,Sl)|0,wn=wn+Math.imul(_o,Ul)|0,zn=zn+Math.imul(_o,Sl)|0,Nn=Nn+Math.imul(lo,So)|0,wn=wn+Math.imul(lo,Co)|0,wn=wn+Math.imul(Eo,So)|0,zn=zn+Math.imul(Eo,Co)|0,Nn=Nn+Math.imul(vo,po)|0,wn=wn+Math.imul(vo,Ro)|0,wn=wn+Math.imul(go,po)|0,zn=zn+Math.imul(go,Ro)|0;var fu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(fu>>>26)|0,fu&=67108863,Nn=Math.imul(Cl,Do),wn=Math.imul(Cl,zo),wn=wn+Math.imul(ko,Do)|0,zn=Math.imul(ko,zo),Nn=Nn+Math.imul($a,Ll)|0,wn=wn+Math.imul($a,_l)|0,wn=wn+Math.imul(Jo,Ll)|0,zn=zn+Math.imul(Jo,_l)|0,Nn=Nn+Math.imul(Vo,xl)|0,wn=wn+Math.imul(Vo,Tl)|0,wn=wn+Math.imul(Uo,xl)|0,zn=zn+Math.imul(Uo,Tl)|0,Nn=Nn+Math.imul(No,Bl)|0,wn=wn+Math.imul(No,Il)|0,wn=wn+Math.imul(Fo,Bl)|0,zn=zn+Math.imul(Fo,Il)|0,Nn=Nn+Math.imul(qo,Al)|0,wn=wn+Math.imul(qo,Ml)|0,wn=wn+Math.imul(ga,Al)|0,zn=zn+Math.imul(ga,Ml)|0,Nn=Nn+Math.imul(Lo,Ul)|0,wn=wn+Math.imul(Lo,Sl)|0,wn=wn+Math.imul(Wo,Ul)|0,zn=zn+Math.imul(Wo,Sl)|0,Nn=Nn+Math.imul(yo,So)|0,wn=wn+Math.imul(yo,Co)|0,wn=wn+Math.imul(_o,So)|0,zn=zn+Math.imul(_o,Co)|0,Nn=Nn+Math.imul(lo,po)|0,wn=wn+Math.imul(lo,Ro)|0,wn=wn+Math.imul(Eo,po)|0,zn=zn+Math.imul(Eo,Ro)|0,Nn=Nn+Math.imul(vo,jo)|0,wn=wn+Math.imul(vo,Ko)|0,wn=wn+Math.imul(go,jo)|0,zn=zn+Math.imul(go,Ko)|0;var gu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(gu>>>26)|0,gu&=67108863,Nn=Math.imul(bo,Do),wn=Math.imul(bo,zo),wn=wn+Math.imul(Io,Do)|0,zn=Math.imul(Io,zo),Nn=Nn+Math.imul(Cl,Ll)|0,wn=wn+Math.imul(Cl,_l)|0,wn=wn+Math.imul(ko,Ll)|0,zn=zn+Math.imul(ko,_l)|0,Nn=Nn+Math.imul($a,xl)|0,wn=wn+Math.imul($a,Tl)|0,wn=wn+Math.imul(Jo,xl)|0,zn=zn+Math.imul(Jo,Tl)|0,Nn=Nn+Math.imul(Vo,Bl)|0,wn=wn+Math.imul(Vo,Il)|0,wn=wn+Math.imul(Uo,Bl)|0,zn=zn+Math.imul(Uo,Il)|0,Nn=Nn+Math.imul(No,Al)|0,wn=wn+Math.imul(No,Ml)|0,wn=wn+Math.imul(Fo,Al)|0,zn=zn+Math.imul(Fo,Ml)|0,Nn=Nn+Math.imul(qo,Ul)|0,wn=wn+Math.imul(qo,Sl)|0,wn=wn+Math.imul(ga,Ul)|0,zn=zn+Math.imul(ga,Sl)|0,Nn=Nn+Math.imul(Lo,So)|0,wn=wn+Math.imul(Lo,Co)|0,wn=wn+Math.imul(Wo,So)|0,zn=zn+Math.imul(Wo,Co)|0,Nn=Nn+Math.imul(yo,po)|0,wn=wn+Math.imul(yo,Ro)|0,wn=wn+Math.imul(_o,po)|0,zn=zn+Math.imul(_o,Ro)|0,Nn=Nn+Math.imul(lo,jo)|0,wn=wn+Math.imul(lo,Ko)|0,wn=wn+Math.imul(Eo,jo)|0,zn=zn+Math.imul(Eo,Ko)|0,Nn=Nn+Math.imul(vo,$l)|0,wn=wn+Math.imul(vo,El)|0,wn=wn+Math.imul(go,$l)|0,zn=zn+Math.imul(go,El)|0;var ou=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(ou>>>26)|0,ou&=67108863,Nn=Math.imul(bo,Ll),wn=Math.imul(bo,_l),wn=wn+Math.imul(Io,Ll)|0,zn=Math.imul(Io,_l),Nn=Nn+Math.imul(Cl,xl)|0,wn=wn+Math.imul(Cl,Tl)|0,wn=wn+Math.imul(ko,xl)|0,zn=zn+Math.imul(ko,Tl)|0,Nn=Nn+Math.imul($a,Bl)|0,wn=wn+Math.imul($a,Il)|0,wn=wn+Math.imul(Jo,Bl)|0,zn=zn+Math.imul(Jo,Il)|0,Nn=Nn+Math.imul(Vo,Al)|0,wn=wn+Math.imul(Vo,Ml)|0,wn=wn+Math.imul(Uo,Al)|0,zn=zn+Math.imul(Uo,Ml)|0,Nn=Nn+Math.imul(No,Ul)|0,wn=wn+Math.imul(No,Sl)|0,wn=wn+Math.imul(Fo,Ul)|0,zn=zn+Math.imul(Fo,Sl)|0,Nn=Nn+Math.imul(qo,So)|0,wn=wn+Math.imul(qo,Co)|0,wn=wn+Math.imul(ga,So)|0,zn=zn+Math.imul(ga,Co)|0,Nn=Nn+Math.imul(Lo,po)|0,wn=wn+Math.imul(Lo,Ro)|0,wn=wn+Math.imul(Wo,po)|0,zn=zn+Math.imul(Wo,Ro)|0,Nn=Nn+Math.imul(yo,jo)|0,wn=wn+Math.imul(yo,Ko)|0,wn=wn+Math.imul(_o,jo)|0,zn=zn+Math.imul(_o,Ko)|0,Nn=Nn+Math.imul(lo,$l)|0,wn=wn+Math.imul(lo,El)|0,wn=wn+Math.imul(Eo,$l)|0,zn=zn+Math.imul(Eo,El)|0;var su=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(su>>>26)|0,su&=67108863,Nn=Math.imul(bo,xl),wn=Math.imul(bo,Tl),wn=wn+Math.imul(Io,xl)|0,zn=Math.imul(Io,Tl),Nn=Nn+Math.imul(Cl,Bl)|0,wn=wn+Math.imul(Cl,Il)|0,wn=wn+Math.imul(ko,Bl)|0,zn=zn+Math.imul(ko,Il)|0,Nn=Nn+Math.imul($a,Al)|0,wn=wn+Math.imul($a,Ml)|0,wn=wn+Math.imul(Jo,Al)|0,zn=zn+Math.imul(Jo,Ml)|0,Nn=Nn+Math.imul(Vo,Ul)|0,wn=wn+Math.imul(Vo,Sl)|0,wn=wn+Math.imul(Uo,Ul)|0,zn=zn+Math.imul(Uo,Sl)|0,Nn=Nn+Math.imul(No,So)|0,wn=wn+Math.imul(No,Co)|0,wn=wn+Math.imul(Fo,So)|0,zn=zn+Math.imul(Fo,Co)|0,Nn=Nn+Math.imul(qo,po)|0,wn=wn+Math.imul(qo,Ro)|0,wn=wn+Math.imul(ga,po)|0,zn=zn+Math.imul(ga,Ro)|0,Nn=Nn+Math.imul(Lo,jo)|0,wn=wn+Math.imul(Lo,Ko)|0,wn=wn+Math.imul(Wo,jo)|0,zn=zn+Math.imul(Wo,Ko)|0,Nn=Nn+Math.imul(yo,$l)|0,wn=wn+Math.imul(yo,El)|0,wn=wn+Math.imul(_o,$l)|0,zn=zn+Math.imul(_o,El)|0;var tu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(tu>>>26)|0,tu&=67108863,Nn=Math.imul(bo,Bl),wn=Math.imul(bo,Il),wn=wn+Math.imul(Io,Bl)|0,zn=Math.imul(Io,Il),Nn=Nn+Math.imul(Cl,Al)|0,wn=wn+Math.imul(Cl,Ml)|0,wn=wn+Math.imul(ko,Al)|0,zn=zn+Math.imul(ko,Ml)|0,Nn=Nn+Math.imul($a,Ul)|0,wn=wn+Math.imul($a,Sl)|0,wn=wn+Math.imul(Jo,Ul)|0,zn=zn+Math.imul(Jo,Sl)|0,Nn=Nn+Math.imul(Vo,So)|0,wn=wn+Math.imul(Vo,Co)|0,wn=wn+Math.imul(Uo,So)|0,zn=zn+Math.imul(Uo,Co)|0,Nn=Nn+Math.imul(No,po)|0,wn=wn+Math.imul(No,Ro)|0,wn=wn+Math.imul(Fo,po)|0,zn=zn+Math.imul(Fo,Ro)|0,Nn=Nn+Math.imul(qo,jo)|0,wn=wn+Math.imul(qo,Ko)|0,wn=wn+Math.imul(ga,jo)|0,zn=zn+Math.imul(ga,Ko)|0,Nn=Nn+Math.imul(Lo,$l)|0,wn=wn+Math.imul(Lo,El)|0,wn=wn+Math.imul(Wo,$l)|0,zn=zn+Math.imul(Wo,El)|0;var zl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(zl>>>26)|0,zl&=67108863,Nn=Math.imul(bo,Al),wn=Math.imul(bo,Ml),wn=wn+Math.imul(Io,Al)|0,zn=Math.imul(Io,Ml),Nn=Nn+Math.imul(Cl,Ul)|0,wn=wn+Math.imul(Cl,Sl)|0,wn=wn+Math.imul(ko,Ul)|0,zn=zn+Math.imul(ko,Sl)|0,Nn=Nn+Math.imul($a,So)|0,wn=wn+Math.imul($a,Co)|0,wn=wn+Math.imul(Jo,So)|0,zn=zn+Math.imul(Jo,Co)|0,Nn=Nn+Math.imul(Vo,po)|0,wn=wn+Math.imul(Vo,Ro)|0,wn=wn+Math.imul(Uo,po)|0,zn=zn+Math.imul(Uo,Ro)|0,Nn=Nn+Math.imul(No,jo)|0,wn=wn+Math.imul(No,Ko)|0,wn=wn+Math.imul(Fo,jo)|0,zn=zn+Math.imul(Fo,Ko)|0,Nn=Nn+Math.imul(qo,$l)|0,wn=wn+Math.imul(qo,El)|0,wn=wn+Math.imul(ga,$l)|0,zn=zn+Math.imul(ga,El)|0;var Gl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Gl>>>26)|0,Gl&=67108863,Nn=Math.imul(bo,Ul),wn=Math.imul(bo,Sl),wn=wn+Math.imul(Io,Ul)|0,zn=Math.imul(Io,Sl),Nn=Nn+Math.imul(Cl,So)|0,wn=wn+Math.imul(Cl,Co)|0,wn=wn+Math.imul(ko,So)|0,zn=zn+Math.imul(ko,Co)|0,Nn=Nn+Math.imul($a,po)|0,wn=wn+Math.imul($a,Ro)|0,wn=wn+Math.imul(Jo,po)|0,zn=zn+Math.imul(Jo,Ro)|0,Nn=Nn+Math.imul(Vo,jo)|0,wn=wn+Math.imul(Vo,Ko)|0,wn=wn+Math.imul(Uo,jo)|0,zn=zn+Math.imul(Uo,Ko)|0,Nn=Nn+Math.imul(No,$l)|0,wn=wn+Math.imul(No,El)|0,wn=wn+Math.imul(Fo,$l)|0,zn=zn+Math.imul(Fo,El)|0;var Jl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Jl>>>26)|0,Jl&=67108863,Nn=Math.imul(bo,So),wn=Math.imul(bo,Co),wn=wn+Math.imul(Io,So)|0,zn=Math.imul(Io,Co),Nn=Nn+Math.imul(Cl,po)|0,wn=wn+Math.imul(Cl,Ro)|0,wn=wn+Math.imul(ko,po)|0,zn=zn+Math.imul(ko,Ro)|0,Nn=Nn+Math.imul($a,jo)|0,wn=wn+Math.imul($a,Ko)|0,wn=wn+Math.imul(Jo,jo)|0,zn=zn+Math.imul(Jo,Ko)|0,Nn=Nn+Math.imul(Vo,$l)|0,wn=wn+Math.imul(Vo,El)|0,wn=wn+Math.imul(Uo,$l)|0,zn=zn+Math.imul(Uo,El)|0;var Pl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Pl>>>26)|0,Pl&=67108863,Nn=Math.imul(bo,po),wn=Math.imul(bo,Ro),wn=wn+Math.imul(Io,po)|0,zn=Math.imul(Io,Ro),Nn=Nn+Math.imul(Cl,jo)|0,wn=wn+Math.imul(Cl,Ko)|0,wn=wn+Math.imul(ko,jo)|0,zn=zn+Math.imul(ko,Ko)|0,Nn=Nn+Math.imul($a,$l)|0,wn=wn+Math.imul($a,El)|0,wn=wn+Math.imul(Jo,$l)|0,zn=zn+Math.imul(Jo,El)|0;var Fl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Fl>>>26)|0,Fl&=67108863,Nn=Math.imul(bo,jo),wn=Math.imul(bo,Ko),wn=wn+Math.imul(Io,jo)|0,zn=Math.imul(Io,Ko),Nn=Nn+Math.imul(Cl,$l)|0,wn=wn+Math.imul(Cl,El)|0,wn=wn+Math.imul(ko,$l)|0,zn=zn+Math.imul(ko,El)|0;var Yl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Yl>>>26)|0,Yl&=67108863,Nn=Math.imul(bo,$l),wn=Math.imul(bo,El),wn=wn+Math.imul(Io,$l)|0,zn=Math.imul(Io,El);var Vl=(Zn+Nn|0)+((wn&8191)<<13)|0;return Zn=(zn+(wn>>>13)|0)+(Vl>>>26)|0,Vl&=67108863,On[0]=Cu,On[1]=iu,On[2]=pu,On[3]=yu,On[4]=hu,On[5]=mu,On[6]=vu,On[7]=fu,On[8]=gu,On[9]=ou,On[10]=su,On[11]=tu,On[12]=zl,On[13]=Gl,On[14]=Jl,On[15]=Pl,On[16]=Fl,On[17]=Yl,On[18]=Vl,Zn!==0&&(On[19]=Zn,Sn.length++),Sn};Math.imul||(An=In);function jn(Tn,Gr,Xr){Xr.negative=Gr.negative^Tn.negative,Xr.length=Tn.length+Gr.length;for(var Sn=0,Rn=0,Pn=0;Pn>>26)|0,Rn+=On>>>26,On&=67108863}Xr.words[Pn]=Zn,Sn=On,On=Rn}return Sn!==0?Xr.words[Pn]=Sn:Xr.length--,Xr._strip()}function eo(Tn,Gr,Xr){return jn(Tn,Gr,Xr)}jr.prototype.mulTo=function(Gr,Xr){var Sn,Rn=this.length+Gr.length;return this.length===10&&Gr.length===10?Sn=An(this,Gr,Xr):Rn<63?Sn=In(this,Gr,Xr):Rn<1024?Sn=jn(this,Gr,Xr):Sn=eo(this,Gr,Xr),Sn},jr.prototype.mul=function(Gr){var Xr=new jr(null);return Xr.words=new Array(this.length+Gr.length),this.mulTo(Gr,Xr)},jr.prototype.mulf=function(Gr){var Xr=new jr(null);return Xr.words=new Array(this.length+Gr.length),eo(this,Gr,Xr)},jr.prototype.imul=function(Gr){return this.clone().mulTo(Gr,this)},jr.prototype.imuln=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(typeof Gr=="number"),Er(Gr<67108864);for(var Sn=0,Rn=0;Rn>=26,Sn+=Pn/67108864|0,Sn+=On>>>26,this.words[Rn]=On&67108863}return Sn!==0&&(this.words[Rn]=Sn,this.length++),Xr?this.ineg():this},jr.prototype.muln=function(Gr){return this.clone().imuln(Gr)},jr.prototype.sqr=function(){return this.mul(this)},jr.prototype.isqr=function(){return this.imul(this.clone())},jr.prototype.pow=function(Gr){var Xr=Cn(Gr);if(Xr.length===0)return new jr(1);for(var Sn=this,Rn=0;Rn=0);var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=67108863>>>26-Xr<<26-Xr,Pn;if(Xr!==0){var On=0;for(Pn=0;Pn>>26-Xr}On&&(this.words[Pn]=On,this.length++)}if(Sn!==0){for(Pn=this.length-1;Pn>=0;Pn--)this.words[Pn+Sn]=this.words[Pn];for(Pn=0;Pn=0);var Rn;Xr?Rn=(Xr-Xr%26)/26:Rn=0;var Pn=Gr%26,On=Math.min((Gr-Pn)/26,this.length),Zn=67108863^67108863>>>Pn<On)for(this.length-=On,wn=0;wn=0&&(zn!==0||wn>=Rn);wn--){var fo=this.words[wn]|0;this.words[wn]=zn<<26-Pn|fo>>>Pn,zn=fo&Zn}return Nn&&zn!==0&&(Nn.words[Nn.length++]=zn),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},jr.prototype.ishrn=function(Gr,Xr,Sn){return Er(this.negative===0),this.iushrn(Gr,Xr,Sn)},jr.prototype.shln=function(Gr){return this.clone().ishln(Gr)},jr.prototype.ushln=function(Gr){return this.clone().iushln(Gr)},jr.prototype.shrn=function(Gr){return this.clone().ishrn(Gr)},jr.prototype.ushrn=function(Gr){return this.clone().iushrn(Gr)},jr.prototype.testn=function(Gr){Er(typeof Gr=="number"&&Gr>=0);var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=1<=0);var Xr=Gr%26,Sn=(Gr-Xr)/26;if(Er(this.negative===0,"imaskn works only with positive numbers"),this.length<=Sn)return this;if(Xr!==0&&Sn++,this.length=Math.min(Sn,this.length),Xr!==0){var Rn=67108863^67108863>>>Xr<=67108864;Xr++)this.words[Xr]-=67108864,Xr===this.length-1?this.words[Xr+1]=1:this.words[Xr+1]++;return this.length=Math.max(this.length,Xr+1),this},jr.prototype.isubn=function(Gr){if(Er(typeof Gr=="number"),Er(Gr<67108864),Gr<0)return this.iaddn(-Gr);if(this.negative!==0)return this.negative=0,this.iaddn(Gr),this.negative=1,this;if(this.words[0]-=Gr,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var Xr=0;Xr>26)-(Nn/67108864|0),this.words[Pn+Sn]=On&67108863}for(;Pn>26,this.words[Pn+Sn]=On&67108863;if(Zn===0)return this._strip();for(Er(Zn===-1),Zn=0,Pn=0;Pn>26,this.words[Pn]=On&67108863;return this.negative=1,this._strip()},jr.prototype._wordDiv=function(Gr,Xr){var Sn=this.length-Gr.length,Rn=this.clone(),Pn=Gr,On=Pn.words[Pn.length-1]|0,Zn=this._countBits(On);Sn=26-Zn,Sn!==0&&(Pn=Pn.ushln(Sn),Rn.iushln(Sn),On=Pn.words[Pn.length-1]|0);var Nn=Rn.length-Pn.length,wn;if(Xr!=="mod"){wn=new jr(null),wn.length=Nn+1,wn.words=new Array(wn.length);for(var zn=0;zn=0;vo--){var go=(Rn.words[Pn.length+vo]|0)*67108864+(Rn.words[Pn.length+vo-1]|0);for(go=Math.min(go/On|0,67108863),Rn._ishlnsubmul(Pn,go,vo);Rn.negative!==0;)go--,Rn.negative=0,Rn._ishlnsubmul(Pn,1,vo),Rn.isZero()||(Rn.negative^=1);wn&&(wn.words[vo]=go)}return wn&&wn._strip(),Rn._strip(),Xr!=="div"&&Sn!==0&&Rn.iushrn(Sn),{div:wn||null,mod:Rn}},jr.prototype.divmod=function(Gr,Xr,Sn){if(Er(!Gr.isZero()),this.isZero())return{div:new jr(0),mod:new jr(0)};var Rn,Pn,On;return this.negative!==0&&Gr.negative===0?(On=this.neg().divmod(Gr,Xr),Xr!=="mod"&&(Rn=On.div.neg()),Xr!=="div"&&(Pn=On.mod.neg(),Sn&&Pn.negative!==0&&Pn.iadd(Gr)),{div:Rn,mod:Pn}):this.negative===0&&Gr.negative!==0?(On=this.divmod(Gr.neg(),Xr),Xr!=="mod"&&(Rn=On.div.neg()),{div:Rn,mod:On.mod}):this.negative&Gr.negative?(On=this.neg().divmod(Gr.neg(),Xr),Xr!=="div"&&(Pn=On.mod.neg(),Sn&&Pn.negative!==0&&Pn.isub(Gr)),{div:On.div,mod:Pn}):Gr.length>this.length||this.cmp(Gr)<0?{div:new jr(0),mod:this}:Gr.length===1?Xr==="div"?{div:this.divn(Gr.words[0]),mod:null}:Xr==="mod"?{div:null,mod:new jr(this.modrn(Gr.words[0]))}:{div:this.divn(Gr.words[0]),mod:new jr(this.modrn(Gr.words[0]))}:this._wordDiv(Gr,Xr)},jr.prototype.div=function(Gr){return this.divmod(Gr,"div",!1).div},jr.prototype.mod=function(Gr){return this.divmod(Gr,"mod",!1).mod},jr.prototype.umod=function(Gr){return this.divmod(Gr,"mod",!0).mod},jr.prototype.divRound=function(Gr){var Xr=this.divmod(Gr);if(Xr.mod.isZero())return Xr.div;var Sn=Xr.div.negative!==0?Xr.mod.isub(Gr):Xr.mod,Rn=Gr.ushrn(1),Pn=Gr.andln(1),On=Sn.cmp(Rn);return On<0||Pn===1&&On===0?Xr.div:Xr.div.negative!==0?Xr.div.isubn(1):Xr.div.iaddn(1)},jr.prototype.modrn=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(Gr<=67108863);for(var Sn=(1<<26)%Gr,Rn=0,Pn=this.length-1;Pn>=0;Pn--)Rn=(Sn*Rn+(this.words[Pn]|0))%Gr;return Xr?-Rn:Rn},jr.prototype.modn=function(Gr){return this.modrn(Gr)},jr.prototype.idivn=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(Gr<=67108863);for(var Sn=0,Rn=this.length-1;Rn>=0;Rn--){var Pn=(this.words[Rn]|0)+Sn*67108864;this.words[Rn]=Pn/Gr|0,Sn=Pn%Gr}return this._strip(),Xr?this.ineg():this},jr.prototype.divn=function(Gr){return this.clone().idivn(Gr)},jr.prototype.egcd=function(Gr){Er(Gr.negative===0),Er(!Gr.isZero());var Xr=this,Sn=Gr.clone();Xr.negative!==0?Xr=Xr.umod(Gr):Xr=Xr.clone();for(var Rn=new jr(1),Pn=new jr(0),On=new jr(0),Zn=new jr(1),Nn=0;Xr.isEven()&&Sn.isEven();)Xr.iushrn(1),Sn.iushrn(1),++Nn;for(var wn=Sn.clone(),zn=Xr.clone();!Xr.isZero();){for(var fo=0,vo=1;!(Xr.words[0]&vo)&&fo<26;++fo,vo<<=1);if(fo>0)for(Xr.iushrn(fo);fo-- >0;)(Rn.isOdd()||Pn.isOdd())&&(Rn.iadd(wn),Pn.isub(zn)),Rn.iushrn(1),Pn.iushrn(1);for(var go=0,uo=1;!(Sn.words[0]&uo)&&go<26;++go,uo<<=1);if(go>0)for(Sn.iushrn(go);go-- >0;)(On.isOdd()||Zn.isOdd())&&(On.iadd(wn),Zn.isub(zn)),On.iushrn(1),Zn.iushrn(1);Xr.cmp(Sn)>=0?(Xr.isub(Sn),Rn.isub(On),Pn.isub(Zn)):(Sn.isub(Xr),On.isub(Rn),Zn.isub(Pn))}return{a:On,b:Zn,gcd:Sn.iushln(Nn)}},jr.prototype._invmp=function(Gr){Er(Gr.negative===0),Er(!Gr.isZero());var Xr=this,Sn=Gr.clone();Xr.negative!==0?Xr=Xr.umod(Gr):Xr=Xr.clone();for(var Rn=new jr(1),Pn=new jr(0),On=Sn.clone();Xr.cmpn(1)>0&&Sn.cmpn(1)>0;){for(var Zn=0,Nn=1;!(Xr.words[0]&Nn)&&Zn<26;++Zn,Nn<<=1);if(Zn>0)for(Xr.iushrn(Zn);Zn-- >0;)Rn.isOdd()&&Rn.iadd(On),Rn.iushrn(1);for(var wn=0,zn=1;!(Sn.words[0]&zn)&&wn<26;++wn,zn<<=1);if(wn>0)for(Sn.iushrn(wn);wn-- >0;)Pn.isOdd()&&Pn.iadd(On),Pn.iushrn(1);Xr.cmp(Sn)>=0?(Xr.isub(Sn),Rn.isub(Pn)):(Sn.isub(Xr),Pn.isub(Rn))}var fo;return Xr.cmpn(1)===0?fo=Rn:fo=Pn,fo.cmpn(0)<0&&fo.iadd(Gr),fo},jr.prototype.gcd=function(Gr){if(this.isZero())return Gr.abs();if(Gr.isZero())return this.abs();var Xr=this.clone(),Sn=Gr.clone();Xr.negative=0,Sn.negative=0;for(var Rn=0;Xr.isEven()&&Sn.isEven();Rn++)Xr.iushrn(1),Sn.iushrn(1);do{for(;Xr.isEven();)Xr.iushrn(1);for(;Sn.isEven();)Sn.iushrn(1);var Pn=Xr.cmp(Sn);if(Pn<0){var On=Xr;Xr=Sn,Sn=On}else if(Pn===0||Sn.cmpn(1)===0)break;Xr.isub(Sn)}while(!0);return Sn.iushln(Rn)},jr.prototype.invm=function(Gr){return this.egcd(Gr).a.umod(Gr)},jr.prototype.isEven=function(){return(this.words[0]&1)===0},jr.prototype.isOdd=function(){return(this.words[0]&1)===1},jr.prototype.andln=function(Gr){return this.words[0]&Gr},jr.prototype.bincn=function(Gr){Er(typeof Gr=="number");var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=1<>>26,Zn&=67108863,this.words[On]=Zn}return Pn!==0&&(this.words[On]=Pn,this.length++),this},jr.prototype.isZero=function(){return this.length===1&&this.words[0]===0},jr.prototype.cmpn=function(Gr){var Xr=Gr<0;if(this.negative!==0&&!Xr)return-1;if(this.negative===0&&Xr)return 1;this._strip();var Sn;if(this.length>1)Sn=1;else{Xr&&(Gr=-Gr),Er(Gr<=67108863,"Number is too big");var Rn=this.words[0]|0;Sn=Rn===Gr?0:RnGr.length)return 1;if(this.length=0;Sn--){var Rn=this.words[Sn]|0,Pn=Gr.words[Sn]|0;if(Rn!==Pn){RnPn&&(Xr=1);break}}return Xr},jr.prototype.gtn=function(Gr){return this.cmpn(Gr)===1},jr.prototype.gt=function(Gr){return this.cmp(Gr)===1},jr.prototype.gten=function(Gr){return this.cmpn(Gr)>=0},jr.prototype.gte=function(Gr){return this.cmp(Gr)>=0},jr.prototype.ltn=function(Gr){return this.cmpn(Gr)===-1},jr.prototype.lt=function(Gr){return this.cmp(Gr)===-1},jr.prototype.lten=function(Gr){return this.cmpn(Gr)<=0},jr.prototype.lte=function(Gr){return this.cmp(Gr)<=0},jr.prototype.eqn=function(Gr){return this.cmpn(Gr)===0},jr.prototype.eq=function(Gr){return this.cmp(Gr)===0},jr.red=function(Gr){return new so(Gr)},jr.prototype.toRed=function(Gr){return Er(!this.red,"Already a number in reduction context"),Er(this.negative===0,"red works only with positives"),Gr.convertTo(this)._forceRed(Gr)},jr.prototype.fromRed=function(){return Er(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},jr.prototype._forceRed=function(Gr){return this.red=Gr,this},jr.prototype.forceRed=function(Gr){return Er(!this.red,"Already a number in reduction context"),this._forceRed(Gr)},jr.prototype.redAdd=function(Gr){return Er(this.red,"redAdd works only with red numbers"),this.red.add(this,Gr)},jr.prototype.redIAdd=function(Gr){return Er(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,Gr)},jr.prototype.redSub=function(Gr){return Er(this.red,"redSub works only with red numbers"),this.red.sub(this,Gr)},jr.prototype.redISub=function(Gr){return Er(this.red,"redISub works only with red numbers"),this.red.isub(this,Gr)},jr.prototype.redShl=function(Gr){return Er(this.red,"redShl works only with red numbers"),this.red.shl(this,Gr)},jr.prototype.redMul=function(Gr){return Er(this.red,"redMul works only with red numbers"),this.red._verify2(this,Gr),this.red.mul(this,Gr)},jr.prototype.redIMul=function(Gr){return Er(this.red,"redMul works only with red numbers"),this.red._verify2(this,Gr),this.red.imul(this,Gr)},jr.prototype.redSqr=function(){return Er(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},jr.prototype.redISqr=function(){return Er(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},jr.prototype.redSqrt=function(){return Er(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},jr.prototype.redInvm=function(){return Er(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},jr.prototype.redNeg=function(){return Er(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},jr.prototype.redPow=function(Gr){return Er(this.red&&!Gr.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,Gr)};var ro={k256:null,p224:null,p192:null,p25519:null};function to(Tn,Gr){this.name=Tn,this.p=new jr(Gr,16),this.n=this.p.bitLength(),this.k=new jr(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}to.prototype._tmp=function(){var Gr=new jr(null);return Gr.words=new Array(Math.ceil(this.n/13)),Gr},to.prototype.ireduce=function(Gr){var Xr=Gr,Sn;do this.split(Xr,this.tmp),Xr=this.imulK(Xr),Xr=Xr.iadd(this.tmp),Sn=Xr.bitLength();while(Sn>this.n);var Rn=Sn0?Xr.isub(this.p):Xr.strip!==void 0?Xr.strip():Xr._strip(),Xr},to.prototype.split=function(Gr,Xr){Gr.iushrn(this.n,0,Xr)},to.prototype.imulK=function(Gr){return Gr.imul(this.k)};function _i(){to.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}kr(_i,to),_i.prototype.split=function(Gr,Xr){for(var Sn=4194303,Rn=Math.min(Gr.length,9),Pn=0;Pn>>22,On=Zn}On>>>=22,Gr.words[Pn-10]=On,On===0&&Gr.length>10?Gr.length-=10:Gr.length-=9},_i.prototype.imulK=function(Gr){Gr.words[Gr.length]=0,Gr.words[Gr.length+1]=0,Gr.length+=2;for(var Xr=0,Sn=0;Sn>>=26,Gr.words[Sn]=Pn,Xr=Rn}return Xr!==0&&(Gr.words[Gr.length++]=Xr),Gr},jr._prime=function(Gr){if(ro[Gr])return ro[Gr];var Xr;if(Gr==="k256")Xr=new _i;else if(Gr==="p224")Xr=new oo;else if(Gr==="p192")Xr=new io;else if(Gr==="p25519")Xr=new co;else throw new Error("Unknown prime "+Gr);return ro[Gr]=Xr,Xr};function so(Tn){if(typeof Tn=="string"){var Gr=jr._prime(Tn);this.m=Gr.p,this.prime=Gr}else Er(Tn.gtn(1),"modulus must be greater than 1"),this.m=Tn,this.prime=null}so.prototype._verify1=function(Gr){Er(Gr.negative===0,"red works only with positives"),Er(Gr.red,"red works only with red numbers")},so.prototype._verify2=function(Gr,Xr){Er((Gr.negative|Xr.negative)===0,"red works only with positives"),Er(Gr.red&&Gr.red===Xr.red,"red works only with red numbers")},so.prototype.imod=function(Gr){return this.prime?this.prime.ireduce(Gr)._forceRed(this):(Vr(Gr,Gr.umod(this.m)._forceRed(this)),Gr)},so.prototype.neg=function(Gr){return Gr.isZero()?Gr.clone():this.m.sub(Gr)._forceRed(this)},so.prototype.add=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.add(Xr);return Sn.cmp(this.m)>=0&&Sn.isub(this.m),Sn._forceRed(this)},so.prototype.iadd=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.iadd(Xr);return Sn.cmp(this.m)>=0&&Sn.isub(this.m),Sn},so.prototype.sub=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.sub(Xr);return Sn.cmpn(0)<0&&Sn.iadd(this.m),Sn._forceRed(this)},so.prototype.isub=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.isub(Xr);return Sn.cmpn(0)<0&&Sn.iadd(this.m),Sn},so.prototype.shl=function(Gr,Xr){return this._verify1(Gr),this.imod(Gr.ushln(Xr))},so.prototype.imul=function(Gr,Xr){return this._verify2(Gr,Xr),this.imod(Gr.imul(Xr))},so.prototype.mul=function(Gr,Xr){return this._verify2(Gr,Xr),this.imod(Gr.mul(Xr))},so.prototype.isqr=function(Gr){return this.imul(Gr,Gr.clone())},so.prototype.sqr=function(Gr){return this.mul(Gr,Gr)},so.prototype.sqrt=function(Gr){if(Gr.isZero())return Gr.clone();var Xr=this.m.andln(3);if(Er(Xr%2===1),Xr===3){var Sn=this.m.add(new jr(1)).iushrn(2);return this.pow(Gr,Sn)}for(var Rn=this.m.subn(1),Pn=0;!Rn.isZero()&&Rn.andln(1)===0;)Pn++,Rn.iushrn(1);Er(!Rn.isZero());var On=new jr(1).toRed(this),Zn=On.redNeg(),Nn=this.m.subn(1).iushrn(1),wn=this.m.bitLength();for(wn=new jr(2*wn*wn).toRed(this);this.pow(wn,Nn).cmp(Zn)!==0;)wn.redIAdd(Zn);for(var zn=this.pow(wn,Rn),fo=this.pow(Gr,Rn.addn(1).iushrn(1)),vo=this.pow(Gr,Rn),go=Pn;vo.cmp(On)!==0;){for(var uo=vo,lo=0;uo.cmp(On)!==0;lo++)uo=uo.redSqr();Er(lo=0;Pn--){for(var zn=Xr.words[Pn],fo=wn-1;fo>=0;fo--){var vo=zn>>fo&1;if(On!==Rn[0]&&(On=this.sqr(On)),vo===0&&Zn===0){Nn=0;continue}Zn<<=1,Zn|=vo,Nn++,!(Nn!==Sn&&(Pn!==0||fo!==0))&&(On=this.mul(On,Rn[Zn]),Nn=0,Zn=0)}wn=26}return On},so.prototype.convertTo=function(Gr){var Xr=Gr.umod(this.m);return Xr===Gr?Xr.clone():Xr},so.prototype.convertFrom=function(Gr){var Xr=Gr.clone();return Xr.red=null,Xr},jr.mont=function(Gr){return new no(Gr)};function no(Tn){so.call(this,Tn),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new jr(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}kr(no,so),no.prototype.convertTo=function(Gr){return this.imod(Gr.ushln(this.shift))},no.prototype.convertFrom=function(Gr){var Xr=this.imod(Gr.mul(this.rinv));return Xr.red=null,Xr},no.prototype.imul=function(Gr,Xr){if(Gr.isZero()||Xr.isZero())return Gr.words[0]=0,Gr.length=1,Gr;var Sn=Gr.imul(Xr),Rn=Sn.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Pn=Sn.isub(Rn).iushrn(this.shift),On=Pn;return Pn.cmp(this.m)>=0?On=Pn.isub(this.m):Pn.cmpn(0)<0&&(On=Pn.iadd(this.m)),On._forceRed(this)},no.prototype.mul=function(Gr,Xr){if(Gr.isZero()||Xr.isZero())return new jr(0)._forceRed(this);var Sn=Gr.mul(Xr),Rn=Sn.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Pn=Sn.isub(Rn).iushrn(this.shift),On=Pn;return Pn.cmp(this.m)>=0?On=Pn.isub(this.m):Pn.cmpn(0)<0&&(On=Pn.iadd(this.m)),On._forceRed(this)},no.prototype.invm=function(Gr){var Xr=this.imod(Gr._invmp(this.m).mul(this.r2));return Xr._forceRed(this)}})(fr,commonjsGlobal)})(bn);var bnExports=bn.exports;const BN=getDefaultExportFromCjs$2(bnExports);var _Buffer=safeBufferExports.Buffer;function base(fr){if(fr.length>=255)throw new TypeError("Alphabet too long");for(var br=new Uint8Array(256),wr=0;wr>>0,jn=new Uint8Array(An);Cn!==In;){for(var eo=Qr[Cn],ro=0,to=An-1;(eo!==0||ro>>0,jn[to]=eo%Br>>>0,eo=eo/Br>>>0;if(eo!==0)throw new Error("Non-zero carry");En=ro,Cn++}for(var _i=An-En;_i!==An&&jn[_i]===0;)_i++;for(var oo=Wr.repeat(_n);_i>>0,An=new Uint8Array(In);_n>>0,An[ro]=jn%256>>>0,jn=jn/256>>>0;if(jn!==0)throw new Error("Non-zero carry");Cn=eo,_n++}for(var to=In-Cn;to!==In&&An[to]===0;)to++;var _i=_Buffer.allocUnsafe(En+(In-to));_i.fill(0,0,En);for(var oo=En;to!==In;)_i[oo++]=An[to++];return _i}function Jr(Qr){var _n=Zr(Qr);if(_n)return _n;throw new Error("Non-base"+Br+" character")}return{encode:Vr,decodeUnsafe:Zr,decode:Jr}}var src=base,basex=src,ALPHABET="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",bs58=basex(ALPHABET);const bs58$1=getDefaultExportFromCjs$2(bs58);class StructError extends TypeError{constructor(br,wr){let Er;const{message:kr,explanation:jr,...Br}=br,{path:Wr}=br,qr=Wr.length===0?kr:`At path: ${Wr.join(".")} -- ${kr}`;super(jr??qr),jr!=null&&(this.cause=qr),Object.assign(this,Br),this.name=this.constructor.name,this.failures=()=>Er??(Er=[br,...wr()])}}function isIterable(fr){return isObject(fr)&&typeof fr[Symbol.iterator]=="function"}function isObject(fr){return typeof fr=="object"&&fr!=null}function isNonArrayObject(fr){return isObject(fr)&&!Array.isArray(fr)}function print(fr){return typeof fr=="symbol"?fr.toString():typeof fr=="string"?JSON.stringify(fr):`${fr}`}function shiftIterator(fr){const{done:br,value:wr}=fr.next();return br?void 0:wr}function toFailure(fr,br,wr,Er){if(fr===!0)return;fr===!1?fr={}:typeof fr=="string"&&(fr={message:fr});const{path:kr,branch:jr}=br,{type:Br}=wr,{refinement:Wr,message:qr=`Expected a value of type \`${Br}\`${Wr?` with refinement \`${Wr}\``:""}, but received: \`${print(Er)}\``}=fr;return{value:Er,type:Br,refinement:Wr,key:kr[kr.length-1],path:kr,branch:jr,...fr,message:qr}}function*toFailures(fr,br,wr,Er){isIterable(fr)||(fr=[fr]);for(const kr of fr){const jr=toFailure(kr,br,wr,Er);jr&&(yield jr)}}function*run(fr,br,wr={}){const{path:Er=[],branch:kr=[fr],coerce:jr=!1,mask:Br=!1}=wr,Wr={path:Er,branch:kr,mask:Br};jr&&(fr=br.coercer(fr,Wr));let qr="valid";for(const Hr of br.validator(fr,Wr))Hr.explanation=wr.message,qr="not_valid",yield[Hr,void 0];for(let[Hr,Vr,Zr]of br.entries(fr,Wr)){const Jr=run(Vr,Zr,{path:Hr===void 0?Er:[...Er,Hr],branch:Hr===void 0?kr:[...kr,Vr],coerce:jr,mask:Br,message:wr.message});for(const Qr of Jr)Qr[0]?(qr=Qr[0].refinement!=null?"not_refined":"not_valid",yield[Qr[0],void 0]):jr&&(Vr=Qr[1],Hr===void 0?fr=Vr:fr instanceof Map?fr.set(Hr,Vr):fr instanceof Set?fr.add(Vr):isObject(fr)&&(Vr!==void 0||Hr in fr)&&(fr[Hr]=Vr))}if(qr!=="not_valid")for(const Hr of br.refiner(fr,Wr))Hr.explanation=wr.message,qr="not_refined",yield[Hr,void 0];qr==="valid"&&(yield[void 0,fr])}let Struct$1=class{constructor(br){const{type:wr,schema:Er,validator:kr,refiner:jr,coercer:Br=qr=>qr,entries:Wr=function*(){}}=br;this.type=wr,this.schema=Er,this.entries=Wr,this.coercer=Br,kr?this.validator=(qr,Hr)=>{const Vr=kr(qr,Hr);return toFailures(Vr,Hr,this,qr)}:this.validator=()=>[],jr?this.refiner=(qr,Hr)=>{const Vr=jr(qr,Hr);return toFailures(Vr,Hr,this,qr)}:this.refiner=()=>[]}assert(br,wr){return assert(br,this,wr)}create(br,wr){return create(br,this,wr)}is(br){return is(br,this)}mask(br,wr){return mask(br,this,wr)}validate(br,wr={}){return validate(br,this,wr)}};function assert(fr,br,wr){const Er=validate(fr,br,{message:wr});if(Er[0])throw Er[0]}function create(fr,br,wr){const Er=validate(fr,br,{coerce:!0,message:wr});if(Er[0])throw Er[0];return Er[1]}function mask(fr,br,wr){const Er=validate(fr,br,{coerce:!0,mask:!0,message:wr});if(Er[0])throw Er[0];return Er[1]}function is(fr,br){return!validate(fr,br)[0]}function validate(fr,br,wr={}){const Er=run(fr,br,wr),kr=shiftIterator(Er);return kr[0]?[new StructError(kr[0],function*(){for(const Br of Er)Br[0]&&(yield Br[0])}),void 0]:[void 0,kr[1]]}function define(fr,br){return new Struct$1({type:fr,schema:null,validator:br})}function any(){return define("any",()=>!0)}function array(fr){return new Struct$1({type:"array",schema:fr,*entries(br){if(fr&&Array.isArray(br))for(const[wr,Er]of br.entries())yield[wr,Er,fr]},coercer(br){return Array.isArray(br)?br.slice():br},validator(br){return Array.isArray(br)||`Expected an array value, but received: ${print(br)}`}})}function boolean(){return define("boolean",fr=>typeof fr=="boolean")}function instance(fr){return define("instance",br=>br instanceof fr||`Expected a \`${fr.name}\` instance, but received: ${print(br)}`)}function literal(fr){const br=print(fr),wr=typeof fr;return new Struct$1({type:"literal",schema:wr==="string"||wr==="number"||wr==="boolean"?fr:null,validator(Er){return Er===fr||`Expected the literal \`${br}\`, but received: ${print(Er)}`}})}function never(){return define("never",()=>!1)}function nullable(fr){return new Struct$1({...fr,validator:(br,wr)=>br===null||fr.validator(br,wr),refiner:(br,wr)=>br===null||fr.refiner(br,wr)})}function number(){return define("number",fr=>typeof fr=="number"&&!isNaN(fr)||`Expected a number, but received: ${print(fr)}`)}function optional(fr){return new Struct$1({...fr,validator:(br,wr)=>br===void 0||fr.validator(br,wr),refiner:(br,wr)=>br===void 0||fr.refiner(br,wr)})}function record(fr,br){return new Struct$1({type:"record",schema:null,*entries(wr){if(isObject(wr))for(const Er in wr){const kr=wr[Er];yield[Er,Er,fr],yield[Er,kr,br]}},validator(wr){return isNonArrayObject(wr)||`Expected an object, but received: ${print(wr)}`},coercer(wr){return isNonArrayObject(wr)?{...wr}:wr}})}function string(){return define("string",fr=>typeof fr=="string"||`Expected a string, but received: ${print(fr)}`)}function tuple(fr){const br=never();return new Struct$1({type:"tuple",schema:null,*entries(wr){if(Array.isArray(wr)){const Er=Math.max(fr.length,wr.length);for(let kr=0;krwr.type).join(" | ");return new Struct$1({type:"union",schema:null,coercer(wr,Er){for(const kr of fr){const[jr,Br]=kr.validate(wr,{coerce:!0,mask:Er.mask});if(!jr)return Br}return wr},validator(wr,Er){const kr=[];for(const jr of fr){const[...Br]=run(wr,jr,Er),[Wr]=Br;if(Wr[0])for(const[qr]of Br)qr&&kr.push(qr);else return[]}return[`Expected the value to satisfy a union of \`${br}\`, but received: ${print(wr)}`,...kr]}})}function unknown(){return define("unknown",()=>!0)}function coerce(fr,br,wr){return new Struct$1({...fr,coercer:(Er,kr)=>is(Er,br)?fr.coercer(wr(Er,kr),kr):fr.coercer(Er,kr)})}function isOnCurve(fr){try{return ed25519.ExtendedPoint.fromHex(fr),!0}catch{return!1}}const toBuffer=fr=>Buffer$1$1.isBuffer(fr)?fr:fr instanceof Uint8Array?Buffer$1$1.from(fr.buffer,fr.byteOffset,fr.byteLength):Buffer$1$1.from(fr);class Struct{constructor(br){Object.assign(this,br)}encode(){return Buffer$1$1.from(serialize_1(SOLANA_SCHEMA,this))}static decode(br){return deserialize_1(SOLANA_SCHEMA,this,br)}static decodeUnchecked(br){return deserializeUnchecked_1(SOLANA_SCHEMA,this,br)}}const SOLANA_SCHEMA=new Map;var _PublicKey;const MAX_SEED_LENGTH=32,PUBLIC_KEY_LENGTH=32;function isPublicKeyData(fr){return fr._bn!==void 0}let uniquePublicKeyCounter=1;class PublicKey extends Struct{constructor(br){if(super({}),this._bn=void 0,isPublicKeyData(br))this._bn=br._bn;else{if(typeof br=="string"){const wr=bs58$1.decode(br);if(wr.length!=PUBLIC_KEY_LENGTH)throw new Error("Invalid public key input");this._bn=new BN(wr)}else this._bn=new BN(br);if(this._bn.byteLength()>PUBLIC_KEY_LENGTH)throw new Error("Invalid public key input")}}static unique(){const br=new PublicKey(uniquePublicKeyCounter);return uniquePublicKeyCounter+=1,new PublicKey(br.toBuffer())}equals(br){return this._bn.eq(br._bn)}toBase58(){return bs58$1.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const br=this.toBuffer();return new Uint8Array(br.buffer,br.byteOffset,br.byteLength)}toBuffer(){const br=this._bn.toArrayLike(Buffer$1$1);if(br.length===PUBLIC_KEY_LENGTH)return br;const wr=Buffer$1$1.alloc(32);return br.copy(wr,32-br.length),wr}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(br,wr,Er){const kr=Buffer$1$1.concat([br.toBuffer(),Buffer$1$1.from(wr),Er.toBuffer()]),jr=sha256$4(kr);return new PublicKey(jr)}static createProgramAddressSync(br,wr){let Er=Buffer$1$1.alloc(0);br.forEach(function(jr){if(jr.length>MAX_SEED_LENGTH)throw new TypeError("Max seed length exceeded");Er=Buffer$1$1.concat([Er,toBuffer(jr)])}),Er=Buffer$1$1.concat([Er,wr.toBuffer(),Buffer$1$1.from("ProgramDerivedAddress")]);const kr=sha256$4(Er);if(isOnCurve(kr))throw new Error("Invalid seeds, address must fall off the curve");return new PublicKey(kr)}static async createProgramAddress(br,wr){return this.createProgramAddressSync(br,wr)}static findProgramAddressSync(br,wr){let Er=255,kr;for(;Er!=0;){try{const jr=br.concat(Buffer$1$1.from([Er]));kr=this.createProgramAddressSync(jr,wr)}catch(jr){if(jr instanceof TypeError)throw jr;Er--;continue}return[kr,Er]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(br,wr){return this.findProgramAddressSync(br,wr)}static isOnCurve(br){const wr=new PublicKey(br);return isOnCurve(wr.toBytes())}}_PublicKey=PublicKey;PublicKey.default=new _PublicKey("11111111111111111111111111111111");SOLANA_SCHEMA.set(PublicKey,{kind:"struct",fields:[["_bn","u256"]]});new PublicKey("BPFLoader1111111111111111111111111111111111");const SIGNATURE_LENGTH_IN_BYTES=64,publicKey=(fr="publicKey")=>blob(32,fr),rustString=(fr="string")=>{const br=struct([u32("length"),u32("lengthPadding"),blob(offset(u32(),-8),"chars")],fr),wr=br.decode.bind(br),Er=br.encode.bind(br),kr=br;return kr.decode=(jr,Br)=>wr(jr,Br).chars.toString(),kr.encode=(jr,Br,Wr)=>{const qr={chars:Buffer$1$1.from(jr,"utf8")};return Er(qr,Br,Wr)},kr.alloc=jr=>u32().span+u32().span+Buffer$1$1.from(jr,"utf8").length,kr},authorized=(fr="authorized")=>struct([publicKey("staker"),publicKey("withdrawer")],fr),lockup=(fr="lockup")=>struct([ns64("unixTimestamp"),ns64("epoch"),publicKey("custodian")],fr),voteInit=(fr="voteInit")=>struct([publicKey("nodePubkey"),publicKey("authorizedVoter"),publicKey("authorizedWithdrawer"),u8("commission")],fr),voteAuthorizeWithSeedArgs=(fr="voteAuthorizeWithSeedArgs")=>struct([u32("voteAuthorizationType"),publicKey("currentAuthorityDerivedKeyOwnerPubkey"),rustString("currentAuthorityDerivedKeySeed"),publicKey("newAuthorized")],fr);Buffer$1$1.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);new PublicKey("SysvarC1ock11111111111111111111111111111111");new PublicKey("SysvarEpochSchedu1e111111111111111111111111");new PublicKey("Sysvar1nstructions1111111111111111111111111");new PublicKey("SysvarRecentB1ockHashes11111111111111111111");new PublicKey("SysvarRent111111111111111111111111111111111");new PublicKey("SysvarRewards111111111111111111111111111111");new PublicKey("SysvarS1otHashes111111111111111111111111111");new PublicKey("SysvarS1otHistory11111111111111111111111111");new PublicKey("SysvarStakeHistory1111111111111111111111111");const FeeCalculatorLayout=nu64("lamportsPerSignature"),NonceAccountLayout=struct([u32("version"),u32("state"),publicKey("authorizedPubkey"),publicKey("nonce"),struct([FeeCalculatorLayout],"feeCalculator")]);NonceAccountLayout.span;const encodeDecode=fr=>{const br=fr.decode.bind(fr),wr=fr.encode.bind(fr);return{decode:br,encode:wr}},bigInt=fr=>br=>{const wr=blob(fr,br),{encode:Er,decode:kr}=encodeDecode(wr),jr=wr;return jr.decode=(Br,Wr)=>{const qr=kr(Br,Wr);return toBigIntLE_1(Buffer$1$1.from(qr))},jr.encode=(Br,Wr,qr)=>{const Hr=toBufferLE_1(Br,fr);return Er(Hr,Wr,qr)},jr},u64=bigInt(8);Object.freeze({Create:{index:0,layout:struct([u32("instruction"),ns64("lamports"),ns64("space"),publicKey("programId")])},Assign:{index:1,layout:struct([u32("instruction"),publicKey("programId")])},Transfer:{index:2,layout:struct([u32("instruction"),u64("lamports")])},CreateWithSeed:{index:3,layout:struct([u32("instruction"),publicKey("base"),rustString("seed"),ns64("lamports"),ns64("space"),publicKey("programId")])},AdvanceNonceAccount:{index:4,layout:struct([u32("instruction")])},WithdrawNonceAccount:{index:5,layout:struct([u32("instruction"),ns64("lamports")])},InitializeNonceAccount:{index:6,layout:struct([u32("instruction"),publicKey("authorized")])},AuthorizeNonceAccount:{index:7,layout:struct([u32("instruction"),publicKey("authorized")])},Allocate:{index:8,layout:struct([u32("instruction"),ns64("space")])},AllocateWithSeed:{index:9,layout:struct([u32("instruction"),publicKey("base"),rustString("seed"),ns64("space"),publicKey("programId")])},AssignWithSeed:{index:10,layout:struct([u32("instruction"),publicKey("base"),rustString("seed"),publicKey("programId")])},TransferWithSeed:{index:11,layout:struct([u32("instruction"),u64("lamports"),rustString("seed"),publicKey("programId")])},UpgradeNonceAccount:{index:12,layout:struct([u32("instruction")])}});new PublicKey("11111111111111111111111111111111");new PublicKey("BPFLoader2111111111111111111111111111111111");struct([u32("typeIndex"),u64("deactivationSlot"),nu64("lastExtendedSlot"),u8("lastExtendedStartIndex"),u8(),seq(publicKey(),offset(u8(),-1),"authority")]);const PublicKeyFromString=coerce(instance(PublicKey),string(),fr=>new PublicKey(fr)),RawAccountDataResult=tuple([string(),literal("base64")]),BufferFromRawAccountData=coerce(instance(Buffer$1$1),RawAccountDataResult,fr=>Buffer$1$1.from(fr[0],"base64"));function createRpcResult(fr){return union([type({jsonrpc:literal("2.0"),id:string(),result:fr}),type({jsonrpc:literal("2.0"),id:string(),error:type({code:unknown(),message:string(),data:optional(any())})})])}const UnknownRpcResult=createRpcResult(unknown());function jsonRpcResult(fr){return coerce(createRpcResult(fr),UnknownRpcResult,br=>"error"in br?br:{...br,result:create(br.result,fr)})}function jsonRpcResultAndContext(fr){return jsonRpcResult(type({context:type({slot:number()}),value:fr}))}function notificationResultAndContext(fr){return type({context:type({slot:number()}),value:fr})}const GetInflationGovernorResult=type({foundation:number(),foundationTerm:number(),initial:number(),taper:number(),terminal:number()});jsonRpcResult(array(nullable(type({epoch:number(),effectiveSlot:number(),amount:number(),postBalance:number(),commission:optional(nullable(number()))}))));const GetRecentPrioritizationFeesResult=array(type({slot:number(),prioritizationFee:number()})),GetInflationRateResult=type({total:number(),validator:number(),foundation:number(),epoch:number()}),GetEpochInfoResult=type({epoch:number(),slotIndex:number(),slotsInEpoch:number(),absoluteSlot:number(),blockHeight:optional(number()),transactionCount:optional(number())}),GetEpochScheduleResult=type({slotsPerEpoch:number(),leaderScheduleSlotOffset:number(),warmup:boolean(),firstNormalEpoch:number(),firstNormalSlot:number()}),GetLeaderScheduleResult=record(string(),array(number())),TransactionErrorResult=nullable(union([type({}),string()])),SignatureStatusResult=type({err:TransactionErrorResult}),SignatureReceivedResult=literal("receivedSignature");type({"solana-core":string(),"feature-set":optional(number())});const ParsedInstructionStruct=type({program:string(),programId:PublicKeyFromString,parsed:unknown()}),PartiallyDecodedInstructionStruct=type({programId:PublicKeyFromString,accounts:array(PublicKeyFromString),data:string()});jsonRpcResultAndContext(type({err:nullable(union([type({}),string()])),logs:nullable(array(string())),accounts:optional(nullable(array(nullable(type({executable:boolean(),owner:string(),lamports:number(),data:array(string()),rentEpoch:optional(number())}))))),unitsConsumed:optional(number()),returnData:optional(nullable(type({programId:string(),data:tuple([string(),literal("base64")])}))),innerInstructions:optional(nullable(array(type({index:number(),instructions:array(union([ParsedInstructionStruct,PartiallyDecodedInstructionStruct]))}))))}));jsonRpcResultAndContext(type({byIdentity:record(string(),array(number())),range:type({firstSlot:number(),lastSlot:number()})}));jsonRpcResult(GetInflationGovernorResult);jsonRpcResult(GetInflationRateResult);jsonRpcResult(GetRecentPrioritizationFeesResult);jsonRpcResult(GetEpochInfoResult);jsonRpcResult(GetEpochScheduleResult);jsonRpcResult(GetLeaderScheduleResult);jsonRpcResult(number());jsonRpcResultAndContext(type({total:number(),circulating:number(),nonCirculating:number(),nonCirculatingAccounts:array(PublicKeyFromString)}));const TokenAmountResult=type({amount:string(),uiAmount:nullable(number()),decimals:number(),uiAmountString:optional(string())});jsonRpcResultAndContext(array(type({address:PublicKeyFromString,amount:string(),uiAmount:nullable(number()),decimals:number(),uiAmountString:optional(string())})));jsonRpcResultAndContext(array(type({pubkey:PublicKeyFromString,account:type({executable:boolean(),owner:PublicKeyFromString,lamports:number(),data:BufferFromRawAccountData,rentEpoch:number()})})));const ParsedAccountDataResult=type({program:string(),parsed:unknown(),space:number()});jsonRpcResultAndContext(array(type({pubkey:PublicKeyFromString,account:type({executable:boolean(),owner:PublicKeyFromString,lamports:number(),data:ParsedAccountDataResult,rentEpoch:number()})})));jsonRpcResultAndContext(array(type({lamports:number(),address:PublicKeyFromString})));const AccountInfoResult=type({executable:boolean(),owner:PublicKeyFromString,lamports:number(),data:BufferFromRawAccountData,rentEpoch:number()});type({pubkey:PublicKeyFromString,account:AccountInfoResult});const ParsedOrRawAccountData=coerce(union([instance(Buffer$1$1),ParsedAccountDataResult]),union([RawAccountDataResult,ParsedAccountDataResult]),fr=>Array.isArray(fr)?create(fr,BufferFromRawAccountData):fr),ParsedAccountInfoResult=type({executable:boolean(),owner:PublicKeyFromString,lamports:number(),data:ParsedOrRawAccountData,rentEpoch:number()});type({pubkey:PublicKeyFromString,account:ParsedAccountInfoResult});type({state:union([literal("active"),literal("inactive"),literal("activating"),literal("deactivating")]),active:number(),inactive:number()});jsonRpcResult(array(type({signature:string(),slot:number(),err:TransactionErrorResult,memo:nullable(string()),blockTime:optional(nullable(number()))})));jsonRpcResult(array(type({signature:string(),slot:number(),err:TransactionErrorResult,memo:nullable(string()),blockTime:optional(nullable(number()))})));type({subscription:number(),result:notificationResultAndContext(AccountInfoResult)});const ProgramAccountInfoResult=type({pubkey:PublicKeyFromString,account:AccountInfoResult});type({subscription:number(),result:notificationResultAndContext(ProgramAccountInfoResult)});const SlotInfoResult=type({parent:number(),slot:number(),root:number()});type({subscription:number(),result:SlotInfoResult});const SlotUpdateResult=union([type({type:union([literal("firstShredReceived"),literal("completed"),literal("optimisticConfirmation"),literal("root")]),slot:number(),timestamp:number()}),type({type:literal("createdBank"),parent:number(),slot:number(),timestamp:number()}),type({type:literal("frozen"),slot:number(),timestamp:number(),stats:type({numTransactionEntries:number(),numSuccessfulTransactions:number(),numFailedTransactions:number(),maxTransactionsPerEntry:number()})}),type({type:literal("dead"),slot:number(),timestamp:number(),err:string()})]);type({subscription:number(),result:SlotUpdateResult});type({subscription:number(),result:notificationResultAndContext(union([SignatureStatusResult,SignatureReceivedResult]))});type({subscription:number(),result:number()});type({pubkey:string(),gossip:nullable(string()),tpu:nullable(string()),rpc:nullable(string()),version:nullable(string())});const VoteAccountInfoResult=type({votePubkey:string(),nodePubkey:string(),activatedStake:number(),epochVoteAccount:boolean(),epochCredits:array(tuple([number(),number(),number()])),commission:number(),lastVote:number(),rootSlot:nullable(number())});jsonRpcResult(type({current:array(VoteAccountInfoResult),delinquent:array(VoteAccountInfoResult)}));const ConfirmationStatus=union([literal("processed"),literal("confirmed"),literal("finalized")]),SignatureStatusResponse=type({slot:number(),confirmations:nullable(number()),err:TransactionErrorResult,confirmationStatus:optional(ConfirmationStatus)});jsonRpcResultAndContext(array(nullable(SignatureStatusResponse)));jsonRpcResult(number());const AddressTableLookupStruct=type({accountKey:PublicKeyFromString,writableIndexes:array(number()),readonlyIndexes:array(number())}),ConfirmedTransactionResult=type({signatures:array(string()),message:type({accountKeys:array(string()),header:type({numRequiredSignatures:number(),numReadonlySignedAccounts:number(),numReadonlyUnsignedAccounts:number()}),instructions:array(type({accounts:array(number()),data:string(),programIdIndex:number()})),recentBlockhash:string(),addressTableLookups:optional(array(AddressTableLookupStruct))})}),AnnotatedAccountKey=type({pubkey:PublicKeyFromString,signer:boolean(),writable:boolean(),source:optional(union([literal("transaction"),literal("lookupTable")]))}),ConfirmedTransactionAccountsModeResult=type({accountKeys:array(AnnotatedAccountKey),signatures:array(string())}),ParsedInstructionResult=type({parsed:unknown(),program:string(),programId:PublicKeyFromString}),RawInstructionResult=type({accounts:array(PublicKeyFromString),data:string(),programId:PublicKeyFromString}),InstructionResult=union([RawInstructionResult,ParsedInstructionResult]),UnknownInstructionResult=union([type({parsed:unknown(),program:string(),programId:string()}),type({accounts:array(string()),data:string(),programId:string()})]),ParsedOrRawInstruction=coerce(InstructionResult,UnknownInstructionResult,fr=>"accounts"in fr?create(fr,RawInstructionResult):create(fr,ParsedInstructionResult)),ParsedConfirmedTransactionResult=type({signatures:array(string()),message:type({accountKeys:array(AnnotatedAccountKey),instructions:array(ParsedOrRawInstruction),recentBlockhash:string(),addressTableLookups:optional(nullable(array(AddressTableLookupStruct)))})}),TokenBalanceResult=type({accountIndex:number(),mint:string(),owner:optional(string()),programId:optional(string()),uiTokenAmount:TokenAmountResult}),LoadedAddressesResult=type({writable:array(PublicKeyFromString),readonly:array(PublicKeyFromString)}),ConfirmedTransactionMetaResult=type({err:TransactionErrorResult,fee:number(),innerInstructions:optional(nullable(array(type({index:number(),instructions:array(type({accounts:array(number()),data:string(),programIdIndex:number()}))})))),preBalances:array(number()),postBalances:array(number()),logMessages:optional(nullable(array(string()))),preTokenBalances:optional(nullable(array(TokenBalanceResult))),postTokenBalances:optional(nullable(array(TokenBalanceResult))),loadedAddresses:optional(LoadedAddressesResult),computeUnitsConsumed:optional(number())}),ParsedConfirmedTransactionMetaResult=type({err:TransactionErrorResult,fee:number(),innerInstructions:optional(nullable(array(type({index:number(),instructions:array(ParsedOrRawInstruction)})))),preBalances:array(number()),postBalances:array(number()),logMessages:optional(nullable(array(string()))),preTokenBalances:optional(nullable(array(TokenBalanceResult))),postTokenBalances:optional(nullable(array(TokenBalanceResult))),loadedAddresses:optional(LoadedAddressesResult),computeUnitsConsumed:optional(number())}),TransactionVersionStruct=union([literal(0),literal("legacy")]),RewardsResult=type({pubkey:string(),lamports:number(),postBalance:nullable(number()),rewardType:nullable(string()),commission:optional(nullable(number()))});jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),transactions:array(type({transaction:ConfirmedTransactionResult,meta:nullable(ConfirmedTransactionMetaResult),version:optional(TransactionVersionStruct)})),rewards:optional(array(RewardsResult)),blockTime:nullable(number()),blockHeight:nullable(number())})));jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),rewards:optional(array(RewardsResult)),blockTime:nullable(number()),blockHeight:nullable(number())})));jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),transactions:array(type({transaction:ConfirmedTransactionAccountsModeResult,meta:nullable(ConfirmedTransactionMetaResult),version:optional(TransactionVersionStruct)})),rewards:optional(array(RewardsResult)),blockTime:nullable(number()),blockHeight:nullable(number())})));jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),transactions:array(type({transaction:ParsedConfirmedTransactionResult,meta:nullable(ParsedConfirmedTransactionMetaResult),version:optional(TransactionVersionStruct)})),rewards:optional(array(RewardsResult)),blockTime:nullable(number()),blockHeight:nullable(number())})));jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),transactions:array(type({transaction:ConfirmedTransactionAccountsModeResult,meta:nullable(ParsedConfirmedTransactionMetaResult),version:optional(TransactionVersionStruct)})),rewards:optional(array(RewardsResult)),blockTime:nullable(number()),blockHeight:nullable(number())})));jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),rewards:optional(array(RewardsResult)),blockTime:nullable(number()),blockHeight:nullable(number())})));jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),transactions:array(type({transaction:ConfirmedTransactionResult,meta:nullable(ConfirmedTransactionMetaResult)})),rewards:optional(array(RewardsResult)),blockTime:nullable(number())})));jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),signatures:array(string()),blockTime:nullable(number())})));jsonRpcResult(nullable(type({slot:number(),meta:nullable(ConfirmedTransactionMetaResult),blockTime:optional(nullable(number())),transaction:ConfirmedTransactionResult,version:optional(TransactionVersionStruct)})));jsonRpcResult(nullable(type({slot:number(),transaction:ParsedConfirmedTransactionResult,meta:nullable(ParsedConfirmedTransactionMetaResult),blockTime:optional(nullable(number())),version:optional(TransactionVersionStruct)})));jsonRpcResultAndContext(type({blockhash:string(),feeCalculator:type({lamportsPerSignature:number()})}));jsonRpcResultAndContext(type({blockhash:string(),lastValidBlockHeight:number()}));jsonRpcResultAndContext(boolean());const PerfSampleResult=type({slot:number(),numTransactions:number(),numSlots:number(),samplePeriodSecs:number()});jsonRpcResult(array(PerfSampleResult));jsonRpcResultAndContext(nullable(type({feeCalculator:type({lamportsPerSignature:number()})})));jsonRpcResult(string());jsonRpcResult(string());const LogsResult=type({err:TransactionErrorResult,logs:array(string()),signature:string()});type({result:notificationResultAndContext(LogsResult),subscription:number()});Object.freeze({CreateLookupTable:{index:0,layout:struct([u32("instruction"),u64("recentSlot"),u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:struct([u32("instruction")])},ExtendLookupTable:{index:2,layout:struct([u32("instruction"),u64(),seq(publicKey(),offset(u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:struct([u32("instruction")])},CloseLookupTable:{index:4,layout:struct([u32("instruction")])}});new PublicKey("AddressLookupTab1e1111111111111111111111111");Object.freeze({RequestUnits:{index:0,layout:struct([u8("instruction"),u32("units"),u32("additionalFee")])},RequestHeapFrame:{index:1,layout:struct([u8("instruction"),u32("bytes")])},SetComputeUnitLimit:{index:2,layout:struct([u8("instruction"),u32("units")])},SetComputeUnitPrice:{index:3,layout:struct([u8("instruction"),u64("microLamports")])}});new PublicKey("ComputeBudget111111111111111111111111111111");struct([u8("numSignatures"),u8("padding"),u16("signatureOffset"),u16("signatureInstructionIndex"),u16("publicKeyOffset"),u16("publicKeyInstructionIndex"),u16("messageDataOffset"),u16("messageDataSize"),u16("messageInstructionIndex")]);new PublicKey("Ed25519SigVerify111111111111111111111111111");secp256k1$1.utils.isValidPrivateKey;secp256k1$1.getPublicKey;struct([u8("numSignatures"),u16("signatureOffset"),u8("signatureInstructionIndex"),u16("ethAddressOffset"),u8("ethAddressInstructionIndex"),u16("messageDataOffset"),u16("messageDataSize"),u8("messageInstructionIndex"),blob(20,"ethAddress"),blob(64,"signature"),u8("recoveryId")]);new PublicKey("KeccakSecp256k11111111111111111111111111111");var _Lockup;new PublicKey("StakeConfig11111111111111111111111111111111");class Lockup{constructor(br,wr,Er){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=br,this.epoch=wr,this.custodian=Er}}_Lockup=Lockup;Lockup.default=new _Lockup(0,0,PublicKey.default);Object.freeze({Initialize:{index:0,layout:struct([u32("instruction"),authorized(),lockup()])},Authorize:{index:1,layout:struct([u32("instruction"),publicKey("newAuthorized"),u32("stakeAuthorizationType")])},Delegate:{index:2,layout:struct([u32("instruction")])},Split:{index:3,layout:struct([u32("instruction"),ns64("lamports")])},Withdraw:{index:4,layout:struct([u32("instruction"),ns64("lamports")])},Deactivate:{index:5,layout:struct([u32("instruction")])},Merge:{index:7,layout:struct([u32("instruction")])},AuthorizeWithSeed:{index:8,layout:struct([u32("instruction"),publicKey("newAuthorized"),u32("stakeAuthorizationType"),rustString("authoritySeed"),publicKey("authorityOwner")])}});new PublicKey("Stake11111111111111111111111111111111111111");Object.freeze({InitializeAccount:{index:0,layout:struct([u32("instruction"),voteInit()])},Authorize:{index:1,layout:struct([u32("instruction"),publicKey("newAuthorized"),u32("voteAuthorizationType")])},Withdraw:{index:3,layout:struct([u32("instruction"),ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:struct([u32("instruction")])},AuthorizeWithSeed:{index:10,layout:struct([u32("instruction"),voteAuthorizeWithSeedArgs()])}});new PublicKey("Vote111111111111111111111111111111111111111");new PublicKey("Va1idator1nfo111111111111111111111111111111");type({name:string(),website:optional(string()),details:optional(string()),iconUrl:optional(string()),keybaseUsername:optional(string())});new PublicKey("Vote111111111111111111111111111111111111111");struct([publicKey("nodePubkey"),publicKey("authorizedWithdrawer"),u8("commission"),nu64(),seq(struct([nu64("slot"),u32("confirmationCount")]),offset(u32(),-8),"votes"),u8("rootSlotValid"),nu64("rootSlot"),nu64(),seq(struct([nu64("epoch"),publicKey("authorizedVoter")]),offset(u32(),-8),"authorizedVoters"),struct([seq(struct([publicKey("authorizedPubkey"),nu64("epochOfLastAuthorizedSwitch"),nu64("targetEpoch")]),32,"buf"),nu64("idx"),u8("isEmpty")],"priorVoters"),nu64(),seq(struct([nu64("epoch"),nu64("credits"),nu64("prevCredits")]),offset(u32(),-8),"epochCredits"),struct([nu64("slot"),nu64("timestamp")],"lastTimestamp")]);class TurnkeySigner{constructor(br){this.organizationId=br.organizationId,this.client=br.client}async signAllTransactions(br,wr){var Wr,qr,Hr;const Er=new PublicKey(wr);let kr=br.map(Vr=>this.getMessageToSign(Vr).toString("hex"));const Br=(qr=(Wr=(await this.signRawPayloads(kr,wr)).signRawPayloadsResult)==null?void 0:Wr.signatures)==null?void 0:qr.map(Vr=>`${Vr==null?void 0:Vr.r}${Vr==null?void 0:Vr.s}`);for(let Vr in br)(Hr=br[Vr])==null||Hr.addSignature(Er,Buffer$2.from(Br[Vr],"hex"));return br}async addSignature(br,wr){var Wr,qr;const Er=new PublicKey(wr);let kr=this.getMessageToSign(br);const jr=await this.signRawPayload(kr.toString("hex"),wr),Br=`${(Wr=jr.signRawPayloadResult)==null?void 0:Wr.r}${(qr=jr.signRawPayloadResult)==null?void 0:qr.s}`;br.addSignature(Er,Buffer$2.from(Br,"hex"))}async signMessage(br,wr){var kr,jr;const Er=await this.signRawPayload(Buffer$2.from(br).toString("hex"),wr);return Buffer$2.from(`${(kr=Er.signRawPayloadResult)==null?void 0:kr.r}${(jr=Er.signRawPayloadResult)==null?void 0:jr.s}`,"hex")}async signRawPayload(br,wr){const Er=await this.client.signRawPayload({type:"ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2",organizationId:this.organizationId,timestampMs:String(Date.now()),parameters:{signWith:wr,payload:br,encoding:"PAYLOAD_ENCODING_HEXADECIMAL",hashFunction:"HASH_FUNCTION_NOT_APPLICABLE"}}),{id:kr,status:jr,type:Br,result:Wr}=Er.activity;if(jr!=="ACTIVITY_STATUS_COMPLETED")throw new TurnkeyActivityError({message:`Expected COMPLETED status, got ${jr}`,activityId:kr,activityStatus:jr,activityType:Br});return Wr}async signRawPayloads(br,wr){const Er=await this.client.signRawPayloads({type:"ACTIVITY_TYPE_SIGN_RAW_PAYLOADS",organizationId:this.organizationId,timestampMs:String(Date.now()),parameters:{signWith:wr,payloads:br,encoding:"PAYLOAD_ENCODING_HEXADECIMAL",hashFunction:"HASH_FUNCTION_NOT_APPLICABLE"}}),{id:kr,status:jr,type:Br,result:Wr}=Er.activity;if(jr!=="ACTIVITY_STATUS_COMPLETED")throw new TurnkeyActivityError({message:`Expected COMPLETED status, got ${jr}`,activityId:kr,activityStatus:jr,activityType:Br});return Wr}getMessageToSign(br){let wr;return typeof br.serializeMessage=="function"?wr=br.serializeMessage():wr=Buffer$2.from(br.message.serialize()),wr}}var version$3="3.8.2";function __awaiter$1(fr,br,wr,Er){function kr(jr){return jr instanceof wr?jr:new wr(function(Br){Br(jr)})}return new(wr||(wr=Promise))(function(jr,Br){function Wr(Vr){try{Hr(Er.next(Vr))}catch(Zr){Br(Zr)}}function qr(Vr){try{Hr(Er.throw(Vr))}catch(Zr){Br(Zr)}}function Hr(Vr){Vr.done?jr(Vr.value):kr(Vr.value).then(Wr,qr)}Hr((Er=Er.apply(fr,[])).next())})}typeof SuppressedError=="function"&&SuppressedError;var version$2="3.8.2";function __rest(fr,br){var wr={};for(var Er in fr)Object.prototype.hasOwnProperty.call(fr,Er)&&br.indexOf(Er)<0&&(wr[Er]=fr[Er]);if(fr!=null&&typeof Object.getOwnPropertySymbols=="function")for(var kr=0,Er=Object.getOwnPropertySymbols(fr);kr{var fr,br,wr;return typeof process$1$1<"u"&&define_process_env_default$1&&(wr=(br=(fr=define_process_env_default$1.ICONIC_SPRITE_CDN_URL)!==null&&fr!==void 0?fr:define_process_env_default$1.NEXT_PUBLIC_ICONIC_SPRITE_CDN_URL)!==null&&br!==void 0?br:define_process_env_default$1.REACT_APP_ICONIC_SPRITE_CDN_URLL)!==null&&wr!==void 0?wr:DEFAULT_ICONIC_SPRITE_URL},ICONIC_SPRITE_URL=getIconicSpriteUrl(),createIconic=fr=>{const br=Object.assign(Object.assign({},fr),{function:Er=>{const kr=`${ICONIC_SPRITE_URL}#${br.iconName}`;return reactExports.createElement("img",Object.assign(Object.assign({"data-testid":`iconic-${br.iconName}`},Er),{alt:br.alt,src:kr}))}}),wr=br.function.bind(br);return Object.assign(wr,{iconName:br.iconName,sourcePath:br.sourcePath}),wr};createIconic({alt:"Brave Browser",iconName:"brave",sourcePath:"icons/browsers/brave.svg"});createIconic({alt:"Chrome Browser",iconName:"chrome",sourcePath:"icons/browsers/chrome.svg"});createIconic({alt:"Edge Browser",iconName:"edge",sourcePath:"icons/browsers/edge.svg"});createIconic({alt:"Firefox Browser",iconName:"firefox",sourcePath:"icons/browsers/firefox.svg"});createIconic({alt:"Opera Browser",iconName:"opera",sourcePath:"icons/browsers/opera.svg"});createIconic({alt:"Opera Browser",iconName:"safari",sourcePath:"icons/browsers/safari.svg"});createIconic({alt:"Algorand Chain",iconName:"algorand",sourcePath:"icons/chains/algorand.svg"});createIconic({alt:"Arbitrum Chain",iconName:"arbitrum",sourcePath:"icons/chains/arbitrum.svg"});createIconic({alt:"Aurora Chain",iconName:"aurora",sourcePath:"icons/chains/aurora.svg"});createIconic({alt:"Base Chain",iconName:"base",sourcePath:"icons/chains/base.svg"});createIconic({alt:"Berachain Chain",iconName:"berachain",sourcePath:"icons/chains/berachain.svg"});createIconic({alt:"Bitcoin Chain",iconName:"bitcoin",sourcePath:"icons/chains/bitcoin.svg"});createIconic({alt:"BNB Chain",iconName:"bnb",sourcePath:"icons/chains/bnb.svg"});createIconic({alt:"Cosmos Chain",iconName:"cosmos",sourcePath:"icons/chains/cosmos.svg"});createIconic({alt:"Osmosis Chain",iconName:"osmosis",sourcePath:"icons/chains/osmosis.svg"});createIconic({alt:"Axelar Chain",iconName:"axelar",sourcePath:"icons/chains/axelar.svg"});createIconic({alt:"Ethereum Chain",iconName:"ethereum",sourcePath:"icons/chains/ethereum.svg"});createIconic({alt:"Goerli Chain",iconName:"goerli",sourcePath:"icons/chains/goerli.svg"});createIconic({alt:"zkSync Era Chain",iconName:"zkSync",sourcePath:"icons/chains/zkSync.svg"});createIconic({alt:"Flow Chain",iconName:"flow",sourcePath:"icons/chains/flow.svg"});createIconic({alt:"Gnosis Chain",iconName:"gnosis",sourcePath:"icons/chains/gnosis.svg"});createIconic({alt:"Optimism Chain",iconName:"optimism",sourcePath:"icons/chains/optimism.svg"});createIconic({alt:"Palm Chain",iconName:"palm",sourcePath:"icons/chains/palm.svg"});createIconic({alt:"Polygon Chain",iconName:"polygon",sourcePath:"icons/chains/polygon.svg"});createIconic({alt:"Solana Chain",iconName:"solana",sourcePath:"icons/chains/solana.svg"});createIconic({alt:"Starknet Chain",iconName:"starknet",sourcePath:"icons/chains/starknet.svg"});createIconic({alt:"1inch Wallet",iconName:"1inch.svg",sourcePath:"icons/wallets/1inch.svg"});createIconic({alt:"Argent X Wallet",iconName:"argentx",sourcePath:"icons/wallets/argentx.svg"});createIconic({alt:"Argent Mobile",iconName:"argentmobile",sourcePath:"icons/wallets/argent-mobile.svg"});createIconic({alt:"Argent Web Wallet",iconName:"argentwebwallet",sourcePath:"icons/wallets/argent-web-wallet.svg"});createIconic({alt:"Backpack Wallet",iconName:"backpack",sourcePath:"icons/wallets/backpack.svg"});createIconic({alt:"Binance Wallet",iconName:"binance.svg",sourcePath:"icons/wallets/binance.svg"});createIconic({alt:"BitPay Wallet",iconName:"bitpay.svg",sourcePath:"icons/wallets/bitpay.svg"});createIconic({alt:"Blocto Wallet",iconName:"blocto",sourcePath:"icons/wallets/blocto.svg"});createIconic({alt:"Braavos Wallet",iconName:"braavos",sourcePath:"icons/wallets/braavos.svg"});createIconic({alt:"Coin98 Wallet",iconName:"coin98",sourcePath:"icons/wallets/coin98.svg"});createIconic({alt:"Coinbase Wallet",iconName:"coinbase",sourcePath:"icons/wallets/coinbase.svg"});createIconic({alt:"Crypto Wallet",iconName:"crypto.svg",sourcePath:"icons/wallets/crypto.svg"});createIconic({alt:"Dapper Wallet",iconName:"dapper",sourcePath:"icons/wallets/dapper.svg"});createIconic({alt:"Dawn Wallet",iconName:"dawn",sourcePath:"icons/wallets/dawn.svg"});createIconic({alt:"Default Wallet",iconName:"defaultwallet",sourcePath:"icons/wallets/default.svg"});createIconic({alt:"Dapper Wallet",iconName:"emailsign.svg",sourcePath:"icons/wallets/emailsign.svg"});createIconic({alt:"Sign in with Email",iconName:"signinwithemail",sourcePath:"icons/wallets/signinwithemail.svg"});createIconic({alt:"Exodus Wallet",iconName:"exodus",sourcePath:"icons/wallets/exodus.svg"});createIconic({alt:"Fireblocks Wallet",iconName:"fireblocks.svg",sourcePath:"icons/wallets/fireblocks.svg"});createIconic({alt:"Fortmatic Wallet",iconName:"fortmatic",sourcePath:"icons/wallets/fortmatic.svg"});createIconic({alt:"Frame Wallet",iconName:"frame",sourcePath:"icons/wallets/frame.svg"});createIconic({alt:"Gamestop Wallet",iconName:"gamestop",sourcePath:"icons/wallets/gamestop.svg"});createIconic({alt:"Glow Wallet",iconName:"glow",sourcePath:"icons/wallets/glow.svg"});createIconic({alt:"ImToken Wallet",iconName:"imtoken.svg",sourcePath:"icons/wallets/imtoken.svg"});createIconic({alt:"Injected Wallet",iconName:"injectedwallet",sourcePath:"icons/wallets/injectedwallet.svg"});createIconic({alt:"Keplr Wallet",iconName:"keplr",sourcePath:"icons/wallets/keplr.svg"});createIconic({alt:"Ledger Wallet",iconName:"ledger",sourcePath:"icons/wallets/ledger.svg"});createIconic({alt:"Lilico Wallet",iconName:"lilico",sourcePath:"icons/wallets/lilico.svg"});createIconic({alt:"Linen Wallet",iconName:"linen.svg",sourcePath:"icons/wallets/linen.svg"});createIconic({alt:"Matic Wallet",iconName:"matic",sourcePath:"icons/wallets/matic.svg"});createIconic({alt:"MetaMask Wallet",iconName:"metamask",sourcePath:"icons/wallets/metamask.svg"});createIconic({alt:"Missing Wallet",iconName:"missing",sourcePath:"icons/wallets/missing.svg"});createIconic({alt:"MyAlgo Wallet",iconName:"myalgo",sourcePath:"icons/wallets/myalgo.svg"});createIconic({alt:"Omni Wallet",iconName:"omni",sourcePath:"icons/wallets/omni.svg"});createIconic({alt:"OpeanSea Wallet",iconName:"opeansea",sourcePath:"icons/wallets/opensea.svg"});createIconic({alt:"Pera Wallet",iconName:"pera",sourcePath:"icons/wallets/pera.svg"});createIconic({alt:"Phantom Wallet",iconName:"phantom",sourcePath:"icons/wallets/phantom.svg"});createIconic({alt:"Rabby Wallet",iconName:"rabby",sourcePath:"icons/wallets/rabby.svg"});createIconic({alt:"Rainbow Wallet",iconName:"rainbow",sourcePath:"icons/wallets/rainbow.svg"});createIconic({alt:"Safe Wallet",iconName:"safe",sourcePath:"icons/wallets/safe.svg"});createIconic({alt:"Sequence Wallet",iconName:"sequence",sourcePath:"icons/wallets/sequence.svg"});createIconic({alt:"Solflare Wallet",iconName:"solflare",sourcePath:"icons/wallets/solflare.svg"});createIconic({alt:"Spot Wallet",iconName:"spot",sourcePath:"icons/wallets/spot.svg"});createIconic({alt:"Stroke Wallet",iconName:"stroke",sourcePath:"icons/wallets/stroke.svg"});createIconic({alt:"Taho Wallet",iconName:"tallycash",sourcePath:"icons/wallets/tallycash.svg"});createIconic({alt:"Terra Wallet",iconName:"terra",sourcePath:"icons/wallets/terra.svg"});createIconic({alt:"Torus Wallet",iconName:"torus",sourcePath:"icons/wallets/torus.svg"});createIconic({alt:"Trust Wallet",iconName:"trust",sourcePath:"icons/wallets/trust.svg"});createIconic({alt:"Unstoppable Wallet",iconName:"unstoppable",sourcePath:"icons/wallets/unstoppable.svg"});createIconic({alt:"Venly Wallet",iconName:"venly",sourcePath:"icons/wallets/venly.svg"});createIconic({alt:"Wallet Connect Wallet",iconName:"walletconnect",sourcePath:"icons/wallets/walletconnect.svg"});createIconic({alt:"Magic Link Wallet",iconName:"magiclink",sourcePath:"icons/wallets/magic-link.svg"});createIconic({alt:"Turnkey",iconName:"turnkey",sourcePath:"icons/wallets/embedded-wallet.svg"});createIconic({alt:"Zengo Wallet",iconName:"zengo",sourcePath:"icons/wallets/zengo.svg"});createIconic({alt:"Superb Wallet",iconName:"superb",sourcePath:"icons/wallets/superb.svg"});createIconic({alt:"ZeroDev",iconName:"zerodev",sourcePath:"icons/wallets/embedded-wallet.svg"});createIconic({alt:"Smart Wallet",iconName:"smartwallet",sourcePath:"icons/wallets/smart-wallet.svg"});createIconic({alt:"Magic Eden",iconName:"magiceden",sourcePath:"icons/wallets/magiceden.svg"});createIconic({alt:"Xverse",iconName:"xverse",sourcePath:"icons/wallets/xverse.svg"});createIconic({alt:"Unisat",iconName:"unisat",sourcePath:"icons/wallets/unisat.svg"});createIconic({alt:"Leather",iconName:"leather",sourcePath:"icons/wallets/leather.svg"});createIconic({alt:"OKX",iconName:"okx",sourcePath:"icons/wallets/okx.svg"});createIconic({alt:"Coinbase WaaS",iconName:"coinbasewaas",sourcePath:"icons/wallets/embedded-wallet.svg"});createIconic({alt:"MetaMask Starknet Snap",iconName:"metamaskstarknetsnap",sourcePath:"icons/wallets/metamask-starknet.svg"});createIconic({alt:"Nightly",iconName:"nightly",sourcePath:"icons/wallets/nightly.svg"});createIconic({alt:"OneKey",iconName:"onekey",sourcePath:"icons/wallets/onekey.svg"});createIconic({alt:"Ambire",iconName:"ambire",sourcePath:"icons/wallets/ambire.svg"});createIconic({alt:"Bitget Wallet",iconName:"bitgetwallet",sourcePath:"icons/wallets/bitgetwallet.svg"});createIconic({alt:"Math Wallet",iconName:"coin98",sourcePath:"icons/wallets/coin98.svg"});createIconic({alt:"Clover Wallet",iconName:"clover",sourcePath:"icons/wallets/clover.svg"});createIconic({alt:"Apple",iconName:"apple",sourcePath:"icons/mobile/apple.svg"});createIconic({alt:"Android",iconName:"android",sourcePath:"icons/mobile/android.svg"});createIconic({alt:"Bitbucket",iconName:"bitbucket",sourcePath:"icons/social/bitbucket.svg"});createIconic({alt:"Discord",iconName:"discord",sourcePath:"icons/social/discord.svg"});createIconic({alt:"Facebook",iconName:"facebook",sourcePath:"icons/social/facebook.svg"});createIconic({alt:"Farcaster",iconName:"farcaster",sourcePath:"icons/social/farcaster.svg"});createIconic({alt:"Github",iconName:"github",sourcePath:"icons/social/github.svg"});createIconic({alt:"Github",iconName:"github-dark",sourcePath:"icons/social/github-dark.svg"});createIconic({alt:"Gitlab",iconName:"gitlab",sourcePath:"icons/social/gitlab.svg"});createIconic({alt:"Google",iconName:"google",sourcePath:"icons/social/google.svg"});createIconic({alt:"Helpdesk",iconName:"helpdesk",sourcePath:"icons/social/helpdesk.svg"});createIconic({alt:"Linkedin",iconName:"linkedin",sourcePath:"icons/social/linkedin.svg"});createIconic({alt:"Microsoft",iconName:"microsoft",sourcePath:"icons/social/microsoft.svg"});createIconic({alt:"Slack",iconName:"slack",sourcePath:"icons/social/slack.svg"});createIconic({alt:"Telegram",iconName:"telegram",sourcePath:"icons/social/telegram.svg"});createIconic({alt:"Twitch",iconName:"twitch",sourcePath:"icons/social/twitch.svg"});createIconic({alt:"Twitch",iconName:"twitch-dark",sourcePath:"icons/social/twitch-dark.svg"});createIconic({alt:"Twitter",iconName:"twitter",sourcePath:"icons/social/twitter.svg"});createIconic({alt:"Twitter",iconName:"twitter-dark",sourcePath:"icons/social/twitter-dark.svg"});createIconic({alt:"Apple",iconName:"apple",sourcePath:"icons/social/apple.svg"});createIconic({alt:"Apple",iconName:"apple-dark",sourcePath:"icons/social/apple-dark.svg"});createIconic({alt:"Coinbase",iconName:"coinbasesocial",sourcePath:"icons/social/coinbasesocial.svg"});createIconic({alt:"Coinbase",iconName:"coinbasesocial-dark",sourcePath:"icons/social/coinbasesocial-dark.svg"});createIconic({alt:"Instagram",iconName:"instagram",sourcePath:"icons/social/instagram.svg"});createIconic({alt:"YouTube",iconName:"youtube",sourcePath:"icons/social/youtube.svg"});createIconic({alt:"onePassword",iconName:"one-password",sourcePath:"icons/social/onePassword.svg"});createIconic({alt:"onePassword-dark",iconName:"one-password-dark",sourcePath:"icons/social/onePassword-dark.svg"});createIconic({alt:"epicGames",iconName:"epicgames",sourcePath:"icons/social/epicgames.svg"});createIconic({alt:"epicGames-dark",iconName:"epicgames-dark",sourcePath:"icons/social/epicgames-dark.svg"});createIconic({alt:"spotify",iconName:"spotify",sourcePath:"icons/social/spotify.svg"});createIconic({alt:"spotify-dark",iconName:"spotify-dark",sourcePath:"icons/social/spotify-dark.svg"});createIconic({alt:"steam",iconName:"steam",sourcePath:"icons/social/steam.svg"});createIconic({alt:"steam-dark",iconName:"steam-dark",sourcePath:"icons/social/steam-dark.svg"});createIconic({alt:"tiktok",iconName:"tiktok",sourcePath:"icons/social/tiktok.svg"});createIconic({alt:"tiktok-dark",iconName:"tiktok-dark",sourcePath:"icons/social/tiktok-dark.svg"});createIconic({alt:"line",iconName:"line",sourcePath:"icons/social/line.svg"});createIconic({alt:"Captcha Wave",iconName:"captcha-wave",sourcePath:"icons/misc/captcha-wave.svg"});createIconic({alt:"User Profile",iconName:"user-profile",sourcePath:"icons/misc/user-profile.svg"});createIconic({alt:"Arrow Send",iconName:"arrow-send",sourcePath:"icons/misc/arrow-send.svg"});typeof SuppressedError=="function"&&SuppressedError;new Logger$1("iconic");assertPackageVersion("@dynamic-labs/iconic",version);`${getIconicSpriteUrl()}`;new Logger$1("WalletBook");typeof SuppressedError=="function"&&SuppressedError;const walletConnectSourceValueSchema=z$6.object({app:z$6.object({android:z$6.string().nullable(),browser:z$6.string().nullable(),chrome:z$6.string().nullable(),edge:z$6.string().nullable(),firefox:z$6.string().nullable(),ios:z$6.string().nullable(),linux:z$6.string().nullable(),mac:z$6.string().nullable(),opera:z$6.string().nullable(),safari:z$6.string().nullable(),windows:z$6.string().nullable()}),app_type:z$6.string(),category:z$6.string().nullable(),chains:z$6.array(z$6.string()),description:z$6.string().nullable(),desktop:z$6.object({native:z$6.string().nullable(),universal:z$6.string().nullable()}),homepage:z$6.string(),id:z$6.string(),image_id:z$6.string(),image_url:z$6.object({lg:z$6.string(),md:z$6.string(),sm:z$6.string()}),injected:z$6.array(z$6.object({injected_id:z$6.string(),namespace:z$6.string()})).nullable(),metadata:z$6.object({colors:z$6.object({primary:z$6.string().nullable(),secondary:z$6.string().nullable()}),shortName:z$6.string().nullable()}),mobile:z$6.object({native:z$6.string().nullable(),universal:z$6.string().nullable()}),name:z$6.string(),rdns:z$6.string().nullable(),sdks:z$6.array(z$6.string()),slug:z$6.string(),supported_standards:z$6.array(z$6.object({id:z$6.string(),standard_id:z$6.number(),standard_prefix:z$6.string(),title:z$6.string(),url:z$6.string()})).optional(),updatedAt:z$6.string(),versions:z$6.array(z$6.string())}).strict();z$6.record(z$6.string(),walletConnectSourceValueSchema);const nonEmptyString=z$6.preprocess(fr=>fr||void 0,z$6.string().optional()),transformChromeExtensionId=fr=>{if(fr!=null&&fr.match(/^[a-z]{32}$/))return fr;if(fr!=null&&fr.includes("chrome.google.com/webstore/detail/"))try{return new URL(fr).pathname.split("/").at(-1)}catch{}},transformEdgeExtensionId=fr=>{if(fr!=null&&fr.match(/^[a-z]{32}$/))return fr;if(fr!=null&&fr.includes("microsoftedge.microsoft.com/addons/detail/"))try{return new URL(fr).pathname.split("/").at(-1)}catch{}},transformFirefoxExtensionId=fr=>{if(!(fr!=null&&fr.match(/^https?:\/\//)))return fr;if(fr!=null&&fr.includes("addons.mozilla.org"))try{return new URL(fr).pathname.replace(/\/$/,"").split("/").at(-1)}catch{}},idRegex=/^id[0-9]{1,36}$/,transformIosId=fr=>{if(fr!=null&&fr.match(idRegex))return fr;if(fr!=null&&fr.match(/^https:\/\/[a-zA-Z0-9-]+\.apple\.com/))try{const wr=new URL(fr).pathname.replace(/\/$/,"").split("/").at(-1);if(wr!=null&&wr.match(idRegex))return wr}catch{}},transformAndroidId=fr=>{if(!(fr!=null&&fr.match(/^https?:\/\//)))return fr;if(fr)try{const wr=new URL(fr).searchParams.get("id");if(wr)return wr}catch{}},nonEmptyStringArray=z$6.preprocess(fr=>Array.isArray(fr)&&fr.length>0?fr:void 0,z$6.array(z$6.string()).optional()),filterEmptyObject=fr=>fr&&Object.values(fr).some(br=>!!br)?fr:void 0,injectedConfigSchema=z$6.object({chain:z$6.string(),extensionLocators:z$6.array(z$6.object({flag:z$6.string(),value:z$6.boolean().optional().default(!0)})),providerInterface:z$6.string().optional(),walletStandard:z$6.object({features:z$6.array(z$6.string()),name:z$6.string(),providerId:z$6.string().optional()}).optional(),walletStandardLocators:z$6.array(z$6.object({locator:z$6.string(),name:z$6.string()})).optional(),windowLocations:z$6.array(z$6.string()).optional().refine(fr=>!fr||!fr.some(br=>["ethereum","ethereum.providers"].includes(br)),{message:"windowLocations cannot include ethereum or ethereum.providers as they are included by default",path:["config"]})}),brandSchema=z$6.object({alt:nonEmptyString,primaryColor:nonEmptyString,spriteId:nonEmptyString}),walletSchema=z$6.preprocess(fr=>fr,z$6.object({brand:brandSchema.optional(),chainGroup:z$6.string().optional(),chains:z$6.array(z$6.string()).optional(),desktop:z$6.object({chromeId:nonEmptyString.transform(transformChromeExtensionId),edgeId:nonEmptyString.transform(transformEdgeExtensionId),firefoxId:nonEmptyString.transform(transformFirefoxExtensionId),native:nonEmptyString,operaId:nonEmptyString,safariId:nonEmptyString,universal:nonEmptyString}).optional().transform(filterEmptyObject),eip6963Config:z$6.object({rdns:z$6.string()}).optional(),filterFromWalletConnect:z$6.boolean().optional(),group:z$6.string().optional(),hardwareWallets:z$6.array(z$6.string()).optional(),injectedConfig:z$6.array(injectedConfigSchema).optional(),mobile:z$6.object({android:stringType().nullish(),androidId:nonEmptyString.transform(transformAndroidId),inAppBrowser:stringType().nullish(),ios:stringType().nullish(),iosId:nonEmptyString.transform(transformIosId),native:nonEmptyString,universal:nonEmptyString}).optional().transform(filterEmptyObject),mobileExperience:z$6.enum(["in-app-browser","redirect"]).optional(),name:z$6.string(),shortName:nonEmptyString,showOnlyIfInstalled:z$6.boolean().optional(),switchNetworkOnlyFromWallet:z$6.boolean().optional(),walletConnect:z$6.object({sdks:nonEmptyStringArray}).optional().transform(filterEmptyObject),walletGroup:z$6.string().optional(),walletLimitations:z$6.object({browserExtension:z$6.object({unsupportedEvents:z$6.array(z$6.string()).optional(),unsupportedMethods:z$6.array(z$6.string()).optional()}).optional(),mobile:z$6.object({unsupportedEvents:z$6.array(z$6.string()).optional(),unsupportedMethods:z$6.array(z$6.string()).optional()}).optional()}).optional()})).transform(fr=>{var br,wr,Er,kr,jr,Br;return fr.group&&(fr.chainGroup=fr.group),(!((br=fr.mobile)===null||br===void 0)&&br.iosId||((wr=fr.mobile)===null||wr===void 0?void 0:wr.ios)===null)&&((Er=fr.mobile)===null||Er===void 0||delete Er.ios),(!((kr=fr.mobile)===null||kr===void 0)&&kr.androidId||((jr=fr.mobile)===null||jr===void 0?void 0:jr.android)===null)&&((Br=fr.mobile)===null||Br===void 0||delete Br.android),fr}),WalletOverrideEntrySchema=z$6.object({brand:brandSchema.optional(),name:nonEmptyString}),walletGroupSchema=z$6.object({brand:z$6.object({alt:nonEmptyString,primaryColor:nonEmptyString,spriteId:nonEmptyString}).optional(),key:z$6.string(),name:z$6.string(),walletOverrides:z$6.record(WalletOverrideEntrySchema).optional()});z$6.record(z$6.string(),walletSchema);z$6.preprocess(fr=>fr,z$6.object({groups:z$6.record(z$6.string(),walletGroupSchema),wallets:z$6.record(z$6.string(),walletSchema)}));z$6.record(z$6.string(),walletGroupSchema);assertPackageVersion("@dynamic-labs/wallet-book",version$1);const logger$1=new Logger$1("WalletConnector"),shouldLowercaseAddress=fr=>["eip155","flow","evm","eth","avax","matic"].includes(fr.toLowerCase()),normalizeAddress=(fr,br)=>(fr.startsWith("0x")&&(fr=fr.slice(2)),shouldLowercaseAddress(br)?fr.toLowerCase():fr),isSameAddress=(fr,br,wr)=>normalizeAddress(fr,wr)===normalizeAddress(br,wr);new EventEmitter$2;class Wallet extends BaseWallet{constructor(br){var{connector:wr}=br,Er=__rest(br,["connector"]);super(Er),this._connector=wr}get connector(){return this._connector}getBalance(){return __awaiter(this,void 0,void 0,function*(){return this._connector.getBalance(this.address)})}getNameService(){return __awaiter(this,void 0,void 0,function*(){return this._connector.getNameService(this.address)})}getNetwork(){return __awaiter(this,void 0,void 0,function*(){return this._connector.getNetwork()})}isConnected(){return __awaiter(this,void 0,void 0,function*(){try{return(yield this._connector.getConnectedAccounts()).map(wr=>normalizeAddress(wr,this.chain)).includes(normalizeAddress(this.address,this.chain))}catch(br){return logger$1.error("[Wallet] isConnected - Error detecting if wallet is connected",br),!1}})}proveOwnership(br){return __awaiter(this,void 0,void 0,function*(){return this._connector.proveOwnership(this.address,br)})}signMessage(br){return __awaiter(this,void 0,void 0,function*(){return yield this.sync(),this._connector.signMessage(br,this.address)})}switchNetwork(br){return __awaiter(this,void 0,void 0,function*(){return this._connector.switchNetwork({networkChainId:br})})}sync(){return __awaiter(this,void 0,void 0,function*(){return this._connector.validateActiveWallet(this.address)})}}assertPackageVersion("@dynamic-labs/wallet-connector-core",version$2);class SolanaWallet extends Wallet{getConnection(){return __awaiter$1(this,void 0,void 0,function*(){return this._connector.getWalletClient()})}getSigner(){return __awaiter$1(this,void 0,void 0,function*(){const br=yield this._connector.getSigner();if(!br)throw new Error("unable to retrieve Solana signer");try{return cloneObjectWithOverrides(br,{signAllTransactions:wr=>__awaiter$1(this,void 0,void 0,function*(){return yield this.sync(),br.signAllTransactions(wr)}),signAndSendTransaction:(wr,...Er)=>__awaiter$1(this,void 0,void 0,function*(){return yield this.sync(),br.signAndSendTransaction(wr,...Er)}),signMessage:(wr,...Er)=>__awaiter$1(this,void 0,void 0,function*(){return yield this.sync(),br.signMessage(wr,...Er)}),signTransaction:wr=>__awaiter$1(this,void 0,void 0,function*(){return yield this.sync(),br.signTransaction(wr)})})}catch(wr){return logger$1.warn(`Failed to add logic to auto-sync the wallet. Signer might be out of sync for wallet: ${this._connector.name} (${this.address})`,wr),br}})}}const SOLANA_GENESIS_HASH="genesis-hash",getGenesisHashLSKey=fr=>`${fr}_${SOLANA_GENESIS_HASH}`;new PublicKey$2("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");ChainRpcProviders.getSolanaProviderByChainId=(fr,br)=>{var wr;return(wr=fr.solana)===null||wr===void 0?void 0:wr.find(kr=>kr.chainId===br)};ChainRpcProviders.registerSolanaProviders=fr=>{ChainRpcProviders.registerChainProviders(ProviderChain.SOLANA,br=>{const wr={};return br!=null&&br.solana&&(wr.solana=br.solana.map(Er=>{var kr;const jr=((kr=Er.privateCustomerRpcUrls)===null||kr===void 0?void 0:kr[0])||Er.rpcUrls[0],Br=new Connection(jr,fr);return{chainId:Er.chainId.toString(),chainName:Er.name,provider:Br}})),wr.solana})};const isTxAlreadySigned=fr=>{let br=!1;return"version"in fr?br=fr.signatures.some(wr=>!wr.every(Er=>Er===0)):br=fr.signatures.some(wr=>wr.signature),br},LAMPORTS_PER_SOL=1e9;class SolanaUiTransaction{constructor({onSubmit:br,from:wr,connection:Er,multipleTransactions:kr}){this.chain="SOL",this.data=void 0,this.fee={gas:void 0},this.formatNonNativeToken=(jr,Br)=>(Number(jr)/Number(Math.pow(10,Br))).toString(),this.from=wr,this.onSubmit=br,this.connection=Er,this.multipleTransactions=kr}fetchFee(){return __awaiter$1(this,void 0,void 0,function*(){if(this.fee.gas)return;let br=this.multipleTransactions;if(!br){const Br=yield this.createTransactionSafe();if(!Br)return;br=Br instanceof Array?Br:[Br]}const{blockhash:wr}=yield this.connection.getLatestBlockhash(),Er=yield Promise.all(br.map(Br=>__awaiter$1(this,void 0,void 0,function*(){return"version"in Br?((yield isTxAlreadySigned(Br))||(Br.message.recentBlockhash=wr),Br.message):((yield isTxAlreadySigned(Br))||(Br.recentBlockhash=wr),Br.compileMessage())})));if(Er.some(Br=>!Br))throw new Error("Invalid transaction");const kr=Br=>__awaiter$1(this,void 0,void 0,function*(){let Wr=yield this.connection.getFeeForMessage(Br),qr=0;for(;Wr.value===null&&qr<5;)Wr=yield this.connection.getFeeForMessage(Br),qr++;return Wr.value?BigInt(Wr.value):BigInt(0)}),jr=yield Promise.all(Er.map(Br=>kr(Br)));this.fee.gas=jr.reduce((Br,Wr)=>Br+Wr,BigInt(0)),this.fee.gas===BigInt(0)&&(this.fee.gas=void 0)})}isGasSponsored(){var br;return!((br=this.multipleTransactions)===null||br===void 0)&&br.length?this.multipleTransactions.every(wr=>{var Er;return"version"in wr?this.from!==wr.message.staticAccountKeys[0].toBase58():"feePayer"in wr?this.from!==((Er=wr.feePayer)===null||Er===void 0?void 0:Er.toBase58()):!1}):!1}parse(br){const wr=parseFloat(br),Er=Math.round(wr*LAMPORTS_PER_SOL);return BigInt(Er)}parseNonNativeToken(br,wr){return BigInt(Math.floor(Number(br)*Math.pow(10,wr)))}format(br,{precision:wr}={}){const kr=(Number(br)/LAMPORTS_PER_SOL).toLocaleString("fullwide",{maximumFractionDigits:20,minimumFractionDigits:0,useGrouping:!1});return formatNumberText(kr,{precision:wr})}submit(){return __awaiter$1(this,void 0,void 0,function*(){if(this.multipleTransactions)return this.onSubmit();const br=yield this.createTransaction();return this.onSubmit(br)})}getBalance(){return __awaiter$1(this,void 0,void 0,function*(){const br=new PublicKey$2(this.from),wr=yield this.connection.getBalance(br);return BigInt(wr)})}validateAddressFormat(br){return br==="dyn_send_transaction.multiple_recipients"?!0:/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(br)}createTransaction(){return __awaiter$1(this,void 0,void 0,function*(){var br;const{value:wr,to:Er,nonNativeAddress:kr,nonNativeValue:jr}=this;if(!Er)throw new Error("Destination is required");if(this.multipleTransactions)return this.multipleTransactions;const Br=new Transaction,Wr=new PublicKey$2(this.from),qr=new PublicKey$2(Er);if(kr&&jr){const Vr=new PublicKey$2(kr),Zr=jr,Jr=(br=(yield this.connection.getTokenAccountsByOwner(Wr,{mint:Vr})).value[0])===null||br===void 0?void 0:br.pubkey;if(!Jr)throw new Error("Source token account not found");let Qr;try{Qr=yield getAssociatedTokenAddress(Vr,qr),yield this.connection.getTokenAccountBalance(Qr)}catch{Qr=yield getAssociatedTokenAddress(Vr,qr),Br.add(createAssociatedTokenAccountInstruction(Wr,Qr,qr,Vr))}Br.add(createTransferInstruction(Jr,Qr,Wr,Zr))}else{const Vr=wr??BigInt(0);Br.add(SystemProgram.transfer({fromPubkey:Wr,lamports:Vr,toPubkey:qr}))}const{blockhash:Hr}=yield this.connection.getLatestBlockhash();return Br.feePayer=new PublicKey$2(this.from),Br.recentBlockhash=Hr,Br})}createTransactionSafe(){return __awaiter$1(this,void 0,void 0,function*(){try{return yield this.createTransaction()}catch{return}})}}assertPackageVersion("@dynamic-labs/solana-core",version$3);const createSolanaConnection=(fr,br)=>{if(!fr)throw new Error("rpcUrl is required");return new Connection(fr,br)},logger=new Logger$1("DynamicSDK"),AUTH_MIN_TOKEN="dynamic_min_authentication_token",AUTH_MIN_TOKEN_DEMO="dynamic_min_authentication_token_demo",isCookieEnabled=()=>{var fr,br,wr,Er;let kr=(fr=StorageService.getItem("dynamic_store"))!==null&&fr!==void 0?fr:StorageService.getItem("dynamic_store_demo");if(kr=(br=kr==null?void 0:kr.settings)===null||br===void 0?void 0:br.security,!kr)return!1;const jr=(((wr=kr.auth)===null||wr===void 0?void 0:wr.storage)||[]).includes(AuthStorageEnum.Cookie),Br=!!(!((Er=kr.externalAuth)===null||Er===void 0)&&Er.cookieName);return jr||Br},parseToken=fr=>{var br;if(!fr)return;const wr=(br=fr.split(".")[1])===null||br===void 0?void 0:br.replace(/-/g,"+").replace(/_/g,"/"),Er=wr&&decodeURIComponent(atob(wr).split("").map(kr=>`%${`00${kr.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));return JSON.parse(Er)},decodeMinJwt=fr=>{try{const br=parseToken(fr);return br?MinifiedDynamicJwtFromJSON(br):void 0}catch(br){logger.error(br);return}},getMinAuthToken=()=>{var fr;if(typeof window>"u")return;const br=(fr=StorageService.getItem(AUTH_MIN_TOKEN,{priority:["secureStorage","localStorage"]}))!==null&&fr!==void 0?fr:StorageService.getItem(AUTH_MIN_TOKEN_DEMO,{priority:["secureStorage","localStorage"]});if(!(!br||isMinAuthTokenExpired(br)))return br},isMinAuthTokenExpired=fr=>{const br=decodeMinJwt(fr);return isTokenExpired(br)},isTokenExpired=fr=>{if(!fr||!fr.exp)return!0;const br=new Date(fr.exp*1e3).getTime();return new Date().getTime()>=br};class ApiEndpoint{}ApiEndpoint.getBaseUrl=()=>{if(!ApiEndpoint.__defined__)throw new Error("ApiEndpoint Base URL has not been initialized");return ApiEndpoint.__baseUrl__};ApiEndpoint.setBaseUrl=fr=>{if(!ApiEndpoint.__defined__)fr?ApiEndpoint.__baseUrl__=fr:ApiEndpoint.__baseUrl__=new Configuration().basePath,ApiEndpoint.__defined__=!0;else{if(!fr&&ApiEndpoint.__defined__)return;if(ApiEndpoint.__baseUrl__!==fr)throw new Error(`ApiEndpoint baseUrl is already set to ${ApiEndpoint.__baseUrl__}, cannot change it to ${fr}`)}Object.freeze(ApiEndpoint)};const VERSION=version$4,API_VERSION=dependencies["@dynamic-labs/sdk-api-core"];var define_process_env_default={};const sdkApi=()=>{const fr=define_process_env_default.API_BASE_URL||define_process_env_default.NX_API_BASE_URL||"https://app.dynamic.xyz/api/v0";ApiEndpoint.setBaseUrl(fr);const br={basePath:ApiEndpoint.getBaseUrl(),headers:{"Content-Type":"application/json"}},wr=getMinAuthToken();wr&&(br.headers.Authorization=`Bearer ${wr}`);const Er=isCookieEnabled()?"include":void 0;return br.headers["x-dyn-version"]=`WalletKit/${VERSION}`,br.headers["x-dyn-api-version"]=`API/${API_VERSION}`,new SDKApi(new Configuration(Object.assign(Object.assign({},br),{credentials:Er,fetchApi:FetchService.fetch})))},serializeTransaction=fr=>fr instanceof VersionedTransaction?Buffer$2.from(fr.serialize()).toString("base64"):Buffer$2.from(fr.serialize({verifySignatures:!1})).toString("base64"),deserializeTransaction=fr=>{const br=Buffer$2.from(fr,"base64");return VersionedTransaction.deserialize(br)},optimizeSolanaTransaction=(fr,br,wr)=>__awaiter$2(void 0,void 0,void 0,function*(){const Er=serializeTransaction(br),kr={environmentId:fr,solanaTransactionOptimizationRequest:{address:wr,transaction:Er}},jr=yield sdkApi().optimizeTransaction(kr);return deserializeTransaction(jr.transaction)});class TurnkeySolanaSigner{constructor({walletConnector:br}){this.isConnected=!0,this.providers=[this],this.walletConnector=br,this.turnkeyAddress=this.walletConnector.turnkeyAddress,this.publicKey=this.turnkeyAddress?new PublicKey$2(this.turnkeyAddress):void 0}signMessage(br){return __awaiter$2(this,void 0,void 0,function*(){return{signature:yield this.walletConnector.signUint8ArrayMessage(br)}})}signTransaction(br){return __awaiter$2(this,void 0,void 0,function*(){return this.walletConnector.signTransaction(br)})}signAllTransactions(br){return __awaiter$2(this,void 0,void 0,function*(){return this.walletConnector.signAllTransactions(br)})}signAndSendTransaction(br,wr){return __awaiter$2(this,void 0,void 0,function*(){return{signature:yield this.walletConnector.signAndSendTransaction(br,wr)}})}connect(br){return __awaiter$2(this,void 0,void 0,function*(){return{address:this.turnkeyAddress,publicKey:this.publicKey}})}disconnect(){return __awaiter$2(this,void 0,void 0,function*(){})}}class TurnkeySolanaWalletConnector extends TurnkeyWalletConnectorBase{constructor(br,wr){var Er;super(br,wr),this.ChainWallet=SolanaWallet,this.connectedChain="SOL",this.supportedChains=["SOL"],this.verifiedCredentialChain="solana",this.getEnvId=()=>{const kr=localStorage.getItem("dynamic_nonce");if(kr){const Br=JSON.parse(kr);if(Br&&Br.environmentId)return Br.environmentId}const jr=localStorage.getItem("dynamic_nonce_demo");if(jr){const Br=JSON.parse(jr);if(Br&&Br.environmentId)return Br.environmentId}throw new Error("Failed to get environment id")},this.stampCreateWalletAccountRequest=kr=>__awaiter$2(this,[kr],void 0,function*({request:jr}){return yield this.createOrRestoreSession(),this.getTurnkeyClient().stampCreateWalletAccounts(jr)}),this.solNetworks=wr.solNetworks,this.walletUiUtils=wr.walletUiUtils,this._turnkeyAccount=void 0,this._connectionClient=void 0,this.chainRpcProviders=wr.chainRpcProviders,this.connectionConfig=wr.connectionConfig,(Er=this.chainRpcProviders)===null||Er===void 0||Er.registerSolanaProviders(this.connectionConfig),this.__turnkeyClient=this.getTurnkeyClient()}getRpcUrl(){var br;const[wr]=this.solNetworks;if(!wr)throw new DynamicError("No enabled networks");return((br=wr.privateCustomerRpcUrls)===null||br===void 0?void 0:br[0])||wr.rpcUrls[0]}getConnection(br){if(!this._connectionClient){const wr=this.getRpcUrl();if(!wr)throw new DynamicError("No rpcUrl");const Er=typeof br=="string"?Object.assign(Object.assign({},this.connectionConfig),{commitment:br}):Object.assign(Object.assign({},this.connectionConfig),br);this._connectionClient=createSolanaConnection(wr,Er)}return this._connectionClient}getWalletClient(){return this.getConnection()}getNetwork(){return __awaiter$2(this,void 0,void 0,function*(){const br=this.getConnection();let wr=localStorage.getItem(getGenesisHashLSKey(br.rpcEndpoint));return wr||(wr=yield br.getGenesisHash(),localStorage.setItem(getGenesisHashLSKey(br.rpcEndpoint),wr)),wr=wr.substring(0,32),wr==="5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"?"mainnet":wr==="EtWTRABZaYq6iMfeYKouRu166VU2xqa1"?"devnet":"testnet"})}getPublicClient(){return __awaiter$2(this,void 0,void 0,function*(){var br;if(this.solNetworks.length===0)return;const wr={cosmos:[],evm:void 0,solana:this.solNetworks,starknet:void 0};if(!this.chainRpcProviders)return;const Er=this.chainRpcProviders.getProviders(wr);return(br=this.chainRpcProviders.getSolanaProviderByChainId(Er,"101"))===null||br===void 0?void 0:br.provider})}supportsNetworkSwitching(){return!1}setVerifiedCredentials(br){const wr=findTurnkeyVerifiedCredentials(br,ProviderChain.SOLANA),[Er]=wr;JSON.stringify(this.verifiedCredentials)!==JSON.stringify(wr)&&(this.verifiedCredential=Er,this.verifiedCredentials=wr,this.refreshTurnkeyAccount())}validateActiveWallet(br){return __awaiter$2(this,void 0,void 0,function*(){var wr,Er;const kr=((wr=this.verifiedCredential)===null||wr===void 0?void 0:wr.address)||"";if(!isSameAddress(kr,br,this.connectedChain)){const Br=(Er=this.verifiedCredentials)===null||Er===void 0?void 0:Er.find(Wr=>(Wr==null?void 0:Wr.address)===br);if(!Br)throw new DynamicError("Account not found");this.verifiedCredential=Br,this.refreshTurnkeyAccount()}})}getAccount(){return this.turnkeyAddress}endSession(){return __awaiter$2(this,void 0,void 0,function*(){localStorage.removeItem(getGenesisHashLSKey(this.getRpcUrl()))})}refreshTurnkeyAccount(){return __awaiter$2(this,void 0,void 0,function*(){return this._turnkeyAccount=void 0,this.getTurnkeyAccount()})}getTurnkeyClient(){var br;let wr=getTLD();wr||(wr=PlatformService.getHostname());const Er=PasskeyService.createWebauthnStamper({rpId:wr}),kr=TurnkeyWalletConnectorBase==null?void 0:TurnkeyWalletConnectorBase.apiKeyStamper,jr=kr??Er;return this.__turnkeyClient=(br=this.getAuthenticatorHandler().client)!==null&&br!==void 0?br:new TurnkeyClient({baseUrl:TURNKEY_API_BASE_URL},jr),this.__turnkeyClient}createTurnkeyAccount(br){return __awaiter$2(this,arguments,void 0,function*({organizationId:wr}){const Er=this.getTurnkeyClient();return new TurnkeySigner({client:Er,organizationId:wr})})}getTurnkeyAccount(){return __awaiter$2(this,void 0,void 0,function*(){var br,wr,Er,kr;if(this._turnkeyAccount&&(this.getAuthenticatorHandler().recoveryType==="passkey"&&((br=this.__turnkeyClient)===null||br===void 0?void 0:br.stamper)instanceof WebauthnStamper||this.getAuthenticatorHandler().recoveryType==="email"&&((wr=this.__turnkeyClient)===null||wr===void 0?void 0:wr.stamper)instanceof IframeStamper)&&this.__turnkeyClient===this.getAuthenticatorHandler().client)return this._turnkeyAccount;const{turnkeySubOrganizationId:jr}=(Er=this.walletProperties)!==null&&Er!==void 0?Er:{},{address:Br}=(kr=this.verifiedCredential)!==null&&kr!==void 0?kr:{};if(!(!jr||!Br))return this._turnkeyAccount=yield this.createTurnkeyAccount({organizationId:jr}),this.setLoggerMetadata(),this._turnkeyAccount})}getSigner(){return __awaiter$2(this,void 0,void 0,function*(){return new TurnkeySolanaSigner({walletConnector:this})})}getBalance(br){return __awaiter$2(this,void 0,void 0,function*(){const wr=this.getConnection(),Er=new PublicKey$2(br),kr=yield wr.getBalance(Er);return this.lamportsToSol(kr).toString()})}signUint8ArrayMessage(br){return __awaiter$2(this,void 0,void 0,function*(){if(!this.turnkeyAddress)throw new DynamicError("No turnkey account");const wr=this.turnkeyAddress;let Er;if(yield this.createOrRestoreSession(),yield this.walletUiUtils.signMessage({handler:()=>__awaiter$2(this,void 0,void 0,function*(){let kr=yield this.getTurnkeyAccount();try{Er=yield kr==null?void 0:kr.signMessage(br,wr)}catch{yield this.removeSessionKeys(),yield this.createOrRestoreSession({ignoreRestore:!0}),kr=yield this.getTurnkeyAccount(),Er=yield kr==null?void 0:kr.signMessage(br,wr)}return bufferToBase64(Er||Buffer$2.from([]))}),message:new TextDecoder().decode(br)}),!Er)throw new Error("Failed to sign message");return Er})}signMessage(br){return __awaiter$2(this,void 0,void 0,function*(){const Er=new TextEncoder().encode(br),kr=yield this.signUint8ArrayMessage(Er);return bufferToBase64(kr)})}internalSignTransaction(br){return __awaiter$2(this,void 0,void 0,function*(){yield this.createOrRestoreSession();let wr=yield this.getTurnkeyAccount();const Er=this.turnkeyAddress;if(!wr||!Er)throw new Error("No turnkey account");try{yield wr.addSignature(br,Er)}catch(kr){if(TURNKEY_SDK_SESSION_KEY_RETRYABLE_ERRORS.some(jr=>kr.message.includes(jr)))yield this.removeSessionKeys(),yield this.createOrRestoreSession({ignoreRestore:!0}),wr=yield this.getTurnkeyAccount(),yield wr.addSignature(br,Er);else throw logger$4.error("[TK] failed to perform SignTransaction activity",kr),kr}return br})}signTransaction(br){return __awaiter$2(this,void 0,void 0,function*(){if(!this.turnkeyAddress)throw new DynamicError("No turnkey account");const wr=new SolanaUiTransaction({connection:this.getConnection("confirmed"),from:this.turnkeyAddress,multipleTransactions:[br],onSubmit:()=>__awaiter$2(this,void 0,void 0,function*(){return this.internalSignTransaction(br)})});return this.walletUiUtils.signTransaction(this,wr)})}createUiTransaction(br){return __awaiter$2(this,void 0,void 0,function*(){return yield this.validateActiveWallet(br),new SolanaUiTransaction({connection:this.getConnection("confirmed"),from:br,onSubmit:Er=>__awaiter$2(this,void 0,void 0,function*(){if(Er)return this.internalSignAndSendTransaction(Er)})})})}internalSignAllTransactions(br){return __awaiter$2(this,void 0,void 0,function*(){yield this.createOrRestoreSession();let wr=yield this.getTurnkeyAccount();const Er=this.turnkeyAddress;if(!wr||!Er)throw new Error("No turnkey account");try{return yield wr.signAllTransactions(br,Er)}catch(kr){if(TURNKEY_SDK_SESSION_KEY_RETRYABLE_ERRORS.some(jr=>kr.message.includes(jr)))return yield this.removeSessionKeys(),yield this.createOrRestoreSession({ignoreRestore:!0}),wr=yield this.getTurnkeyAccount(),yield wr.signAllTransactions(br,Er);throw logger$4.error("[TK] failed to perform SignAllTransactions activity",kr),kr}})}signAllTransactions(br){return __awaiter$2(this,void 0,void 0,function*(){if(!this.turnkeyAddress)throw new DynamicError("No turnkey account");const wr=new SolanaUiTransaction({connection:this.getConnection("confirmed"),from:this.turnkeyAddress,multipleTransactions:br,onSubmit:()=>__awaiter$2(this,void 0,void 0,function*(){return this.internalSignAllTransactions(br)})});return this.walletUiUtils.signTransaction(this,wr)})}internalSignAndSendTransaction(br,wr){return __awaiter$2(this,void 0,void 0,function*(){var Er,kr;if(!this.turnkeyAddress)throw new DynamicError("Solana wallet not found");const jr=this.getConnection((kr=(Er=this.connectionConfig)===null||Er===void 0?void 0:Er.commitment)!==null&&kr!==void 0?kr:"confirmed"),Br=yield this.internalSignTransaction(br),Wr=yield jr.sendRawTransaction(Br.serialize(),wr);return new Promise((qr,Hr)=>{const Vr=setTimeout(()=>{Hr(new DynamicError("Transaction timed out"))},6e4);jr.onSignature(Wr,Zr=>{clearTimeout(Vr),Zr.err?Hr(new DynamicError("Transaction failed")):qr(Wr)},"confirmed")})})}signAndSendTransaction(br,wr){return __awaiter$2(this,void 0,void 0,function*(){if(!this.turnkeyAddress)throw new DynamicError("Solana wallet not found");const Er=yield this.optimizeTransaction(br),kr=new SolanaUiTransaction({connection:this.getConnection("confirmed"),from:this.turnkeyAddress,multipleTransactions:[Er],onSubmit:()=>__awaiter$2(this,void 0,void 0,function*(){return this.internalSignAndSendTransaction(Er,wr)})});return this.walletUiUtils.sendTransaction(this,kr)})}sendTransaction(br,wr){return __awaiter$2(this,arguments,void 0,function*(Er,kr,jr={}){var Br;if(!this.turnkeyAddress)throw new DynamicError("Solana wallet not found");if(!Er||!kr)throw new DynamicError("Transaction and connection are required");const{signers:Wr}=jr,qr=__rest$1(jr,["signers"]),Hr=yield kr.getLatestBlockhash({commitment:jr.preflightCommitment,minContextSlot:jr.minContextSlot});"version"in Er?Wr!=null&&Wr.length&&Er.sign(Wr):(Er.feePayer=Er.feePayer||new PublicKey$2(this.turnkeyAddress),Er.recentBlockhash=Er.recentBlockhash||Hr.blockhash,Wr!=null&&Wr.length&&Er.partialSign(...Wr)),qr.preflightCommitment=qr.preflightCommitment||kr.commitment;const Vr=yield kr.sendRawTransaction(Er.serialize(),jr),Zr={blockhash:Hr.blockhash,lastValidBlockHeight:Hr.lastValidBlockHeight,signature:Vr},Jr=yield kr==null?void 0:kr.confirmTransaction(Zr);return!((Br=Jr==null?void 0:Jr.value)===null||Br===void 0)&&Br.err?JSON.stringify(Jr.value.err):Vr})}lamportsToSol(br){return br/LAMPORTS_PER_SOL$2}optimizeTransaction(br){return __awaiter$2(this,void 0,void 0,function*(){var wr;let Er=br;try{(yield this.getNetwork())==="mainnet"&&!isTxAlreadySigned(br)&&(Er=yield optimizeSolanaTransaction(this.getEnvId(),br,(wr=this.turnkeyAddress)!==null&&wr!==void 0?wr:""))}catch(kr){logger$4.warn("Failed to optimize transaction",kr)}return Er})}}const TurnkeySolanaWalletConnectors=fr=>{var br;return!((br=fr.apiProviders)===null||br===void 0)&&br.turnkey?[class extends TurnkeySolanaWalletConnector{constructor(wr){super(TurnkeyWalletConnectorInfo.TurnkeyHD,Object.assign(Object.assign({},fr),wr))}}]:[]};assertPackageVersion("@dynamic-labs/embedded-wallet-solana",version$4);var naclFast={exports:{}};(function(fr){(function(br){var wr=function(So){var Co,Ao=new Float64Array(16);if(So)for(Co=0;Co>24&255,So[Co+1]=Ao>>16&255,So[Co+2]=Ao>>8&255,So[Co+3]=Ao&255,So[Co+4]=po>>24&255,So[Co+5]=po>>16&255,So[Co+6]=po>>8&255,So[Co+7]=po&255}function En(So,Co,Ao,po,Ro){var Xo,jo=0;for(Xo=0;Xo>>8)-1}function Cn(So,Co,Ao,po){return En(So,Co,Ao,po,16)}function In(So,Co,Ao,po){return En(So,Co,Ao,po,32)}function An(So,Co,Ao,po){for(var Ro=po[0]&255|(po[1]&255)<<8|(po[2]&255)<<16|(po[3]&255)<<24,Xo=Ao[0]&255|(Ao[1]&255)<<8|(Ao[2]&255)<<16|(Ao[3]&255)<<24,jo=Ao[4]&255|(Ao[5]&255)<<8|(Ao[6]&255)<<16|(Ao[7]&255)<<24,Ko=Ao[8]&255|(Ao[9]&255)<<8|(Ao[10]&255)<<16|(Ao[11]&255)<<24,Wl=Ao[12]&255|(Ao[13]&255)<<8|(Ao[14]&255)<<16|(Ao[15]&255)<<24,$l=po[4]&255|(po[5]&255)<<8|(po[6]&255)<<16|(po[7]&255)<<24,El=Co[0]&255|(Co[1]&255)<<8|(Co[2]&255)<<16|(Co[3]&255)<<24,Cu=Co[4]&255|(Co[5]&255)<<8|(Co[6]&255)<<16|(Co[7]&255)<<24,iu=Co[8]&255|(Co[9]&255)<<8|(Co[10]&255)<<16|(Co[11]&255)<<24,pu=Co[12]&255|(Co[13]&255)<<8|(Co[14]&255)<<16|(Co[15]&255)<<24,yu=po[8]&255|(po[9]&255)<<8|(po[10]&255)<<16|(po[11]&255)<<24,hu=Ao[16]&255|(Ao[17]&255)<<8|(Ao[18]&255)<<16|(Ao[19]&255)<<24,mu=Ao[20]&255|(Ao[21]&255)<<8|(Ao[22]&255)<<16|(Ao[23]&255)<<24,vu=Ao[24]&255|(Ao[25]&255)<<8|(Ao[26]&255)<<16|(Ao[27]&255)<<24,fu=Ao[28]&255|(Ao[29]&255)<<8|(Ao[30]&255)<<16|(Ao[31]&255)<<24,gu=po[12]&255|(po[13]&255)<<8|(po[14]&255)<<16|(po[15]&255)<<24,ou=Ro,su=Xo,tu=jo,zl=Ko,Gl=Wl,Jl=$l,Pl=El,Fl=Cu,Yl=iu,Vl=pu,Ql=yu,au=hu,Nu=mu,Wu=vu,zu=fu,Bu=gu,Qo,Zu=0;Zu<20;Zu+=2)Qo=ou+Nu|0,Gl^=Qo<<7|Qo>>>25,Qo=Gl+ou|0,Yl^=Qo<<9|Qo>>>23,Qo=Yl+Gl|0,Nu^=Qo<<13|Qo>>>19,Qo=Nu+Yl|0,ou^=Qo<<18|Qo>>>14,Qo=Jl+su|0,Vl^=Qo<<7|Qo>>>25,Qo=Vl+Jl|0,Wu^=Qo<<9|Qo>>>23,Qo=Wu+Vl|0,su^=Qo<<13|Qo>>>19,Qo=su+Wu|0,Jl^=Qo<<18|Qo>>>14,Qo=Ql+Pl|0,zu^=Qo<<7|Qo>>>25,Qo=zu+Ql|0,tu^=Qo<<9|Qo>>>23,Qo=tu+zu|0,Pl^=Qo<<13|Qo>>>19,Qo=Pl+tu|0,Ql^=Qo<<18|Qo>>>14,Qo=Bu+au|0,zl^=Qo<<7|Qo>>>25,Qo=zl+Bu|0,Fl^=Qo<<9|Qo>>>23,Qo=Fl+zl|0,au^=Qo<<13|Qo>>>19,Qo=au+Fl|0,Bu^=Qo<<18|Qo>>>14,Qo=ou+zl|0,su^=Qo<<7|Qo>>>25,Qo=su+ou|0,tu^=Qo<<9|Qo>>>23,Qo=tu+su|0,zl^=Qo<<13|Qo>>>19,Qo=zl+tu|0,ou^=Qo<<18|Qo>>>14,Qo=Jl+Gl|0,Pl^=Qo<<7|Qo>>>25,Qo=Pl+Jl|0,Fl^=Qo<<9|Qo>>>23,Qo=Fl+Pl|0,Gl^=Qo<<13|Qo>>>19,Qo=Gl+Fl|0,Jl^=Qo<<18|Qo>>>14,Qo=Ql+Vl|0,au^=Qo<<7|Qo>>>25,Qo=au+Ql|0,Yl^=Qo<<9|Qo>>>23,Qo=Yl+au|0,Vl^=Qo<<13|Qo>>>19,Qo=Vl+Yl|0,Ql^=Qo<<18|Qo>>>14,Qo=Bu+zu|0,Nu^=Qo<<7|Qo>>>25,Qo=Nu+Bu|0,Wu^=Qo<<9|Qo>>>23,Qo=Wu+Nu|0,zu^=Qo<<13|Qo>>>19,Qo=zu+Wu|0,Bu^=Qo<<18|Qo>>>14;ou=ou+Ro|0,su=su+Xo|0,tu=tu+jo|0,zl=zl+Ko|0,Gl=Gl+Wl|0,Jl=Jl+$l|0,Pl=Pl+El|0,Fl=Fl+Cu|0,Yl=Yl+iu|0,Vl=Vl+pu|0,Ql=Ql+yu|0,au=au+hu|0,Nu=Nu+mu|0,Wu=Wu+vu|0,zu=zu+fu|0,Bu=Bu+gu|0,So[0]=ou>>>0&255,So[1]=ou>>>8&255,So[2]=ou>>>16&255,So[3]=ou>>>24&255,So[4]=su>>>0&255,So[5]=su>>>8&255,So[6]=su>>>16&255,So[7]=su>>>24&255,So[8]=tu>>>0&255,So[9]=tu>>>8&255,So[10]=tu>>>16&255,So[11]=tu>>>24&255,So[12]=zl>>>0&255,So[13]=zl>>>8&255,So[14]=zl>>>16&255,So[15]=zl>>>24&255,So[16]=Gl>>>0&255,So[17]=Gl>>>8&255,So[18]=Gl>>>16&255,So[19]=Gl>>>24&255,So[20]=Jl>>>0&255,So[21]=Jl>>>8&255,So[22]=Jl>>>16&255,So[23]=Jl>>>24&255,So[24]=Pl>>>0&255,So[25]=Pl>>>8&255,So[26]=Pl>>>16&255,So[27]=Pl>>>24&255,So[28]=Fl>>>0&255,So[29]=Fl>>>8&255,So[30]=Fl>>>16&255,So[31]=Fl>>>24&255,So[32]=Yl>>>0&255,So[33]=Yl>>>8&255,So[34]=Yl>>>16&255,So[35]=Yl>>>24&255,So[36]=Vl>>>0&255,So[37]=Vl>>>8&255,So[38]=Vl>>>16&255,So[39]=Vl>>>24&255,So[40]=Ql>>>0&255,So[41]=Ql>>>8&255,So[42]=Ql>>>16&255,So[43]=Ql>>>24&255,So[44]=au>>>0&255,So[45]=au>>>8&255,So[46]=au>>>16&255,So[47]=au>>>24&255,So[48]=Nu>>>0&255,So[49]=Nu>>>8&255,So[50]=Nu>>>16&255,So[51]=Nu>>>24&255,So[52]=Wu>>>0&255,So[53]=Wu>>>8&255,So[54]=Wu>>>16&255,So[55]=Wu>>>24&255,So[56]=zu>>>0&255,So[57]=zu>>>8&255,So[58]=zu>>>16&255,So[59]=zu>>>24&255,So[60]=Bu>>>0&255,So[61]=Bu>>>8&255,So[62]=Bu>>>16&255,So[63]=Bu>>>24&255}function jn(So,Co,Ao,po){for(var Ro=po[0]&255|(po[1]&255)<<8|(po[2]&255)<<16|(po[3]&255)<<24,Xo=Ao[0]&255|(Ao[1]&255)<<8|(Ao[2]&255)<<16|(Ao[3]&255)<<24,jo=Ao[4]&255|(Ao[5]&255)<<8|(Ao[6]&255)<<16|(Ao[7]&255)<<24,Ko=Ao[8]&255|(Ao[9]&255)<<8|(Ao[10]&255)<<16|(Ao[11]&255)<<24,Wl=Ao[12]&255|(Ao[13]&255)<<8|(Ao[14]&255)<<16|(Ao[15]&255)<<24,$l=po[4]&255|(po[5]&255)<<8|(po[6]&255)<<16|(po[7]&255)<<24,El=Co[0]&255|(Co[1]&255)<<8|(Co[2]&255)<<16|(Co[3]&255)<<24,Cu=Co[4]&255|(Co[5]&255)<<8|(Co[6]&255)<<16|(Co[7]&255)<<24,iu=Co[8]&255|(Co[9]&255)<<8|(Co[10]&255)<<16|(Co[11]&255)<<24,pu=Co[12]&255|(Co[13]&255)<<8|(Co[14]&255)<<16|(Co[15]&255)<<24,yu=po[8]&255|(po[9]&255)<<8|(po[10]&255)<<16|(po[11]&255)<<24,hu=Ao[16]&255|(Ao[17]&255)<<8|(Ao[18]&255)<<16|(Ao[19]&255)<<24,mu=Ao[20]&255|(Ao[21]&255)<<8|(Ao[22]&255)<<16|(Ao[23]&255)<<24,vu=Ao[24]&255|(Ao[25]&255)<<8|(Ao[26]&255)<<16|(Ao[27]&255)<<24,fu=Ao[28]&255|(Ao[29]&255)<<8|(Ao[30]&255)<<16|(Ao[31]&255)<<24,gu=po[12]&255|(po[13]&255)<<8|(po[14]&255)<<16|(po[15]&255)<<24,ou=Ro,su=Xo,tu=jo,zl=Ko,Gl=Wl,Jl=$l,Pl=El,Fl=Cu,Yl=iu,Vl=pu,Ql=yu,au=hu,Nu=mu,Wu=vu,zu=fu,Bu=gu,Qo,Zu=0;Zu<20;Zu+=2)Qo=ou+Nu|0,Gl^=Qo<<7|Qo>>>25,Qo=Gl+ou|0,Yl^=Qo<<9|Qo>>>23,Qo=Yl+Gl|0,Nu^=Qo<<13|Qo>>>19,Qo=Nu+Yl|0,ou^=Qo<<18|Qo>>>14,Qo=Jl+su|0,Vl^=Qo<<7|Qo>>>25,Qo=Vl+Jl|0,Wu^=Qo<<9|Qo>>>23,Qo=Wu+Vl|0,su^=Qo<<13|Qo>>>19,Qo=su+Wu|0,Jl^=Qo<<18|Qo>>>14,Qo=Ql+Pl|0,zu^=Qo<<7|Qo>>>25,Qo=zu+Ql|0,tu^=Qo<<9|Qo>>>23,Qo=tu+zu|0,Pl^=Qo<<13|Qo>>>19,Qo=Pl+tu|0,Ql^=Qo<<18|Qo>>>14,Qo=Bu+au|0,zl^=Qo<<7|Qo>>>25,Qo=zl+Bu|0,Fl^=Qo<<9|Qo>>>23,Qo=Fl+zl|0,au^=Qo<<13|Qo>>>19,Qo=au+Fl|0,Bu^=Qo<<18|Qo>>>14,Qo=ou+zl|0,su^=Qo<<7|Qo>>>25,Qo=su+ou|0,tu^=Qo<<9|Qo>>>23,Qo=tu+su|0,zl^=Qo<<13|Qo>>>19,Qo=zl+tu|0,ou^=Qo<<18|Qo>>>14,Qo=Jl+Gl|0,Pl^=Qo<<7|Qo>>>25,Qo=Pl+Jl|0,Fl^=Qo<<9|Qo>>>23,Qo=Fl+Pl|0,Gl^=Qo<<13|Qo>>>19,Qo=Gl+Fl|0,Jl^=Qo<<18|Qo>>>14,Qo=Ql+Vl|0,au^=Qo<<7|Qo>>>25,Qo=au+Ql|0,Yl^=Qo<<9|Qo>>>23,Qo=Yl+au|0,Vl^=Qo<<13|Qo>>>19,Qo=Vl+Yl|0,Ql^=Qo<<18|Qo>>>14,Qo=Bu+zu|0,Nu^=Qo<<7|Qo>>>25,Qo=Nu+Bu|0,Wu^=Qo<<9|Qo>>>23,Qo=Wu+Nu|0,zu^=Qo<<13|Qo>>>19,Qo=zu+Wu|0,Bu^=Qo<<18|Qo>>>14;So[0]=ou>>>0&255,So[1]=ou>>>8&255,So[2]=ou>>>16&255,So[3]=ou>>>24&255,So[4]=Jl>>>0&255,So[5]=Jl>>>8&255,So[6]=Jl>>>16&255,So[7]=Jl>>>24&255,So[8]=Ql>>>0&255,So[9]=Ql>>>8&255,So[10]=Ql>>>16&255,So[11]=Ql>>>24&255,So[12]=Bu>>>0&255,So[13]=Bu>>>8&255,So[14]=Bu>>>16&255,So[15]=Bu>>>24&255,So[16]=Pl>>>0&255,So[17]=Pl>>>8&255,So[18]=Pl>>>16&255,So[19]=Pl>>>24&255,So[20]=Fl>>>0&255,So[21]=Fl>>>8&255,So[22]=Fl>>>16&255,So[23]=Fl>>>24&255,So[24]=Yl>>>0&255,So[25]=Yl>>>8&255,So[26]=Yl>>>16&255,So[27]=Yl>>>24&255,So[28]=Vl>>>0&255,So[29]=Vl>>>8&255,So[30]=Vl>>>16&255,So[31]=Vl>>>24&255}function eo(So,Co,Ao,po){An(So,Co,Ao,po)}function ro(So,Co,Ao,po){jn(So,Co,Ao,po)}var to=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _i(So,Co,Ao,po,Ro,Xo,jo){var Ko=new Uint8Array(16),Wl=new Uint8Array(64),$l,El;for(El=0;El<16;El++)Ko[El]=0;for(El=0;El<8;El++)Ko[El]=Xo[El];for(;Ro>=64;){for(eo(Wl,Ko,jo,to),El=0;El<64;El++)So[Co+El]=Ao[po+El]^Wl[El];for($l=1,El=8;El<16;El++)$l=$l+(Ko[El]&255)|0,Ko[El]=$l&255,$l>>>=8;Ro-=64,Co+=64,po+=64}if(Ro>0)for(eo(Wl,Ko,jo,to),El=0;El=64;){for(eo(jo,Xo,Ro,to),Wl=0;Wl<64;Wl++)So[Co+Wl]=jo[Wl];for(Ko=1,Wl=8;Wl<16;Wl++)Ko=Ko+(Xo[Wl]&255)|0,Xo[Wl]=Ko&255,Ko>>>=8;Ao-=64,Co+=64}if(Ao>0)for(eo(jo,Xo,Ro,to),Wl=0;Wl>>13|Ao<<3)&8191,po=So[4]&255|(So[5]&255)<<8,this.r[2]=(Ao>>>10|po<<6)&7939,Ro=So[6]&255|(So[7]&255)<<8,this.r[3]=(po>>>7|Ro<<9)&8191,Xo=So[8]&255|(So[9]&255)<<8,this.r[4]=(Ro>>>4|Xo<<12)&255,this.r[5]=Xo>>>1&8190,jo=So[10]&255|(So[11]&255)<<8,this.r[6]=(Xo>>>14|jo<<2)&8191,Ko=So[12]&255|(So[13]&255)<<8,this.r[7]=(jo>>>11|Ko<<5)&8065,Wl=So[14]&255|(So[15]&255)<<8,this.r[8]=(Ko>>>8|Wl<<8)&8191,this.r[9]=Wl>>>5&127,this.pad[0]=So[16]&255|(So[17]&255)<<8,this.pad[1]=So[18]&255|(So[19]&255)<<8,this.pad[2]=So[20]&255|(So[21]&255)<<8,this.pad[3]=So[22]&255|(So[23]&255)<<8,this.pad[4]=So[24]&255|(So[25]&255)<<8,this.pad[5]=So[26]&255|(So[27]&255)<<8,this.pad[6]=So[28]&255|(So[29]&255)<<8,this.pad[7]=So[30]&255|(So[31]&255)<<8};so.prototype.blocks=function(So,Co,Ao){for(var po=this.fin?0:2048,Ro,Xo,jo,Ko,Wl,$l,El,Cu,iu,pu,yu,hu,mu,vu,fu,gu,ou,su,tu,zl=this.h[0],Gl=this.h[1],Jl=this.h[2],Pl=this.h[3],Fl=this.h[4],Yl=this.h[5],Vl=this.h[6],Ql=this.h[7],au=this.h[8],Nu=this.h[9],Wu=this.r[0],zu=this.r[1],Bu=this.r[2],Qo=this.r[3],Zu=this.r[4],Qu=this.r[5],_h=this.r[6],qu=this.r[7],Ju=this.r[8],_d=this.r[9];Ao>=16;)Ro=So[Co+0]&255|(So[Co+1]&255)<<8,zl+=Ro&8191,Xo=So[Co+2]&255|(So[Co+3]&255)<<8,Gl+=(Ro>>>13|Xo<<3)&8191,jo=So[Co+4]&255|(So[Co+5]&255)<<8,Jl+=(Xo>>>10|jo<<6)&8191,Ko=So[Co+6]&255|(So[Co+7]&255)<<8,Pl+=(jo>>>7|Ko<<9)&8191,Wl=So[Co+8]&255|(So[Co+9]&255)<<8,Fl+=(Ko>>>4|Wl<<12)&8191,Yl+=Wl>>>1&8191,$l=So[Co+10]&255|(So[Co+11]&255)<<8,Vl+=(Wl>>>14|$l<<2)&8191,El=So[Co+12]&255|(So[Co+13]&255)<<8,Ql+=($l>>>11|El<<5)&8191,Cu=So[Co+14]&255|(So[Co+15]&255)<<8,au+=(El>>>8|Cu<<8)&8191,Nu+=Cu>>>5|po,iu=0,pu=iu,pu+=zl*Wu,pu+=Gl*(5*_d),pu+=Jl*(5*Ju),pu+=Pl*(5*qu),pu+=Fl*(5*_h),iu=pu>>>13,pu&=8191,pu+=Yl*(5*Qu),pu+=Vl*(5*Zu),pu+=Ql*(5*Qo),pu+=au*(5*Bu),pu+=Nu*(5*zu),iu+=pu>>>13,pu&=8191,yu=iu,yu+=zl*zu,yu+=Gl*Wu,yu+=Jl*(5*_d),yu+=Pl*(5*Ju),yu+=Fl*(5*qu),iu=yu>>>13,yu&=8191,yu+=Yl*(5*_h),yu+=Vl*(5*Qu),yu+=Ql*(5*Zu),yu+=au*(5*Qo),yu+=Nu*(5*Bu),iu+=yu>>>13,yu&=8191,hu=iu,hu+=zl*Bu,hu+=Gl*zu,hu+=Jl*Wu,hu+=Pl*(5*_d),hu+=Fl*(5*Ju),iu=hu>>>13,hu&=8191,hu+=Yl*(5*qu),hu+=Vl*(5*_h),hu+=Ql*(5*Qu),hu+=au*(5*Zu),hu+=Nu*(5*Qo),iu+=hu>>>13,hu&=8191,mu=iu,mu+=zl*Qo,mu+=Gl*Bu,mu+=Jl*zu,mu+=Pl*Wu,mu+=Fl*(5*_d),iu=mu>>>13,mu&=8191,mu+=Yl*(5*Ju),mu+=Vl*(5*qu),mu+=Ql*(5*_h),mu+=au*(5*Qu),mu+=Nu*(5*Zu),iu+=mu>>>13,mu&=8191,vu=iu,vu+=zl*Zu,vu+=Gl*Qo,vu+=Jl*Bu,vu+=Pl*zu,vu+=Fl*Wu,iu=vu>>>13,vu&=8191,vu+=Yl*(5*_d),vu+=Vl*(5*Ju),vu+=Ql*(5*qu),vu+=au*(5*_h),vu+=Nu*(5*Qu),iu+=vu>>>13,vu&=8191,fu=iu,fu+=zl*Qu,fu+=Gl*Zu,fu+=Jl*Qo,fu+=Pl*Bu,fu+=Fl*zu,iu=fu>>>13,fu&=8191,fu+=Yl*Wu,fu+=Vl*(5*_d),fu+=Ql*(5*Ju),fu+=au*(5*qu),fu+=Nu*(5*_h),iu+=fu>>>13,fu&=8191,gu=iu,gu+=zl*_h,gu+=Gl*Qu,gu+=Jl*Zu,gu+=Pl*Qo,gu+=Fl*Bu,iu=gu>>>13,gu&=8191,gu+=Yl*zu,gu+=Vl*Wu,gu+=Ql*(5*_d),gu+=au*(5*Ju),gu+=Nu*(5*qu),iu+=gu>>>13,gu&=8191,ou=iu,ou+=zl*qu,ou+=Gl*_h,ou+=Jl*Qu,ou+=Pl*Zu,ou+=Fl*Qo,iu=ou>>>13,ou&=8191,ou+=Yl*Bu,ou+=Vl*zu,ou+=Ql*Wu,ou+=au*(5*_d),ou+=Nu*(5*Ju),iu+=ou>>>13,ou&=8191,su=iu,su+=zl*Ju,su+=Gl*qu,su+=Jl*_h,su+=Pl*Qu,su+=Fl*Zu,iu=su>>>13,su&=8191,su+=Yl*Qo,su+=Vl*Bu,su+=Ql*zu,su+=au*Wu,su+=Nu*(5*_d),iu+=su>>>13,su&=8191,tu=iu,tu+=zl*_d,tu+=Gl*Ju,tu+=Jl*qu,tu+=Pl*_h,tu+=Fl*Qu,iu=tu>>>13,tu&=8191,tu+=Yl*Zu,tu+=Vl*Qo,tu+=Ql*Bu,tu+=au*zu,tu+=Nu*Wu,iu+=tu>>>13,tu&=8191,iu=(iu<<2)+iu|0,iu=iu+pu|0,pu=iu&8191,iu=iu>>>13,yu+=iu,zl=pu,Gl=yu,Jl=hu,Pl=mu,Fl=vu,Yl=fu,Vl=gu,Ql=ou,au=su,Nu=tu,Co+=16,Ao-=16;this.h[0]=zl,this.h[1]=Gl,this.h[2]=Jl,this.h[3]=Pl,this.h[4]=Fl,this.h[5]=Yl,this.h[6]=Vl,this.h[7]=Ql,this.h[8]=au,this.h[9]=Nu},so.prototype.finish=function(So,Co){var Ao=new Uint16Array(10),po,Ro,Xo,jo;if(this.leftover){for(jo=this.leftover,this.buffer[jo++]=1;jo<16;jo++)this.buffer[jo]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(po=this.h[1]>>>13,this.h[1]&=8191,jo=2;jo<10;jo++)this.h[jo]+=po,po=this.h[jo]>>>13,this.h[jo]&=8191;for(this.h[0]+=po*5,po=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=po,po=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=po,Ao[0]=this.h[0]+5,po=Ao[0]>>>13,Ao[0]&=8191,jo=1;jo<10;jo++)Ao[jo]=this.h[jo]+po,po=Ao[jo]>>>13,Ao[jo]&=8191;for(Ao[9]-=8192,Ro=(po^1)-1,jo=0;jo<10;jo++)Ao[jo]&=Ro;for(Ro=~Ro,jo=0;jo<10;jo++)this.h[jo]=this.h[jo]&Ro|Ao[jo];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,Xo=this.h[0]+this.pad[0],this.h[0]=Xo&65535,jo=1;jo<8;jo++)Xo=(this.h[jo]+this.pad[jo]|0)+(Xo>>>16)|0,this.h[jo]=Xo&65535;So[Co+0]=this.h[0]>>>0&255,So[Co+1]=this.h[0]>>>8&255,So[Co+2]=this.h[1]>>>0&255,So[Co+3]=this.h[1]>>>8&255,So[Co+4]=this.h[2]>>>0&255,So[Co+5]=this.h[2]>>>8&255,So[Co+6]=this.h[3]>>>0&255,So[Co+7]=this.h[3]>>>8&255,So[Co+8]=this.h[4]>>>0&255,So[Co+9]=this.h[4]>>>8&255,So[Co+10]=this.h[5]>>>0&255,So[Co+11]=this.h[5]>>>8&255,So[Co+12]=this.h[6]>>>0&255,So[Co+13]=this.h[6]>>>8&255,So[Co+14]=this.h[7]>>>0&255,So[Co+15]=this.h[7]>>>8&255},so.prototype.update=function(So,Co,Ao){var po,Ro;if(this.leftover){for(Ro=16-this.leftover,Ro>Ao&&(Ro=Ao),po=0;po=16&&(Ro=Ao-Ao%16,this.blocks(So,Co,Ro),Co+=Ro,Ao-=Ro),Ao){for(po=0;po>16&1),Xo[Ao-1]&=65535;Xo[15]=jo[15]-32767-(Xo[14]>>16&1),Ro=Xo[15]>>16&1,Xo[14]&=65535,Pn(jo,Xo,1-Ro)}for(Ao=0;Ao<16;Ao++)So[2*Ao]=jo[Ao]&255,So[2*Ao+1]=jo[Ao]>>8}function Zn(So,Co){var Ao=new Uint8Array(32),po=new Uint8Array(32);return On(Ao,So),On(po,Co),In(Ao,0,po,0)}function Nn(So){var Co=new Uint8Array(32);return On(Co,So),Co[0]&1}function wn(So,Co){var Ao;for(Ao=0;Ao<16;Ao++)So[Ao]=Co[2*Ao]+(Co[2*Ao+1]<<8);So[15]&=32767}function zn(So,Co,Ao){for(var po=0;po<16;po++)So[po]=Co[po]+Ao[po]}function fo(So,Co,Ao){for(var po=0;po<16;po++)So[po]=Co[po]-Ao[po]}function vo(So,Co,Ao){var po,Ro,Xo=0,jo=0,Ko=0,Wl=0,$l=0,El=0,Cu=0,iu=0,pu=0,yu=0,hu=0,mu=0,vu=0,fu=0,gu=0,ou=0,su=0,tu=0,zl=0,Gl=0,Jl=0,Pl=0,Fl=0,Yl=0,Vl=0,Ql=0,au=0,Nu=0,Wu=0,zu=0,Bu=0,Qo=Ao[0],Zu=Ao[1],Qu=Ao[2],_h=Ao[3],qu=Ao[4],Ju=Ao[5],_d=Ao[6],dp=Ao[7],Ku=Ao[8],Vu=Ao[9],cp=Ao[10],fp=Ao[11],lp=Ao[12],np=Ao[13],Rp=Ao[14],wp=Ao[15];po=Co[0],Xo+=po*Qo,jo+=po*Zu,Ko+=po*Qu,Wl+=po*_h,$l+=po*qu,El+=po*Ju,Cu+=po*_d,iu+=po*dp,pu+=po*Ku,yu+=po*Vu,hu+=po*cp,mu+=po*fp,vu+=po*lp,fu+=po*np,gu+=po*Rp,ou+=po*wp,po=Co[1],jo+=po*Qo,Ko+=po*Zu,Wl+=po*Qu,$l+=po*_h,El+=po*qu,Cu+=po*Ju,iu+=po*_d,pu+=po*dp,yu+=po*Ku,hu+=po*Vu,mu+=po*cp,vu+=po*fp,fu+=po*lp,gu+=po*np,ou+=po*Rp,su+=po*wp,po=Co[2],Ko+=po*Qo,Wl+=po*Zu,$l+=po*Qu,El+=po*_h,Cu+=po*qu,iu+=po*Ju,pu+=po*_d,yu+=po*dp,hu+=po*Ku,mu+=po*Vu,vu+=po*cp,fu+=po*fp,gu+=po*lp,ou+=po*np,su+=po*Rp,tu+=po*wp,po=Co[3],Wl+=po*Qo,$l+=po*Zu,El+=po*Qu,Cu+=po*_h,iu+=po*qu,pu+=po*Ju,yu+=po*_d,hu+=po*dp,mu+=po*Ku,vu+=po*Vu,fu+=po*cp,gu+=po*fp,ou+=po*lp,su+=po*np,tu+=po*Rp,zl+=po*wp,po=Co[4],$l+=po*Qo,El+=po*Zu,Cu+=po*Qu,iu+=po*_h,pu+=po*qu,yu+=po*Ju,hu+=po*_d,mu+=po*dp,vu+=po*Ku,fu+=po*Vu,gu+=po*cp,ou+=po*fp,su+=po*lp,tu+=po*np,zl+=po*Rp,Gl+=po*wp,po=Co[5],El+=po*Qo,Cu+=po*Zu,iu+=po*Qu,pu+=po*_h,yu+=po*qu,hu+=po*Ju,mu+=po*_d,vu+=po*dp,fu+=po*Ku,gu+=po*Vu,ou+=po*cp,su+=po*fp,tu+=po*lp,zl+=po*np,Gl+=po*Rp,Jl+=po*wp,po=Co[6],Cu+=po*Qo,iu+=po*Zu,pu+=po*Qu,yu+=po*_h,hu+=po*qu,mu+=po*Ju,vu+=po*_d,fu+=po*dp,gu+=po*Ku,ou+=po*Vu,su+=po*cp,tu+=po*fp,zl+=po*lp,Gl+=po*np,Jl+=po*Rp,Pl+=po*wp,po=Co[7],iu+=po*Qo,pu+=po*Zu,yu+=po*Qu,hu+=po*_h,mu+=po*qu,vu+=po*Ju,fu+=po*_d,gu+=po*dp,ou+=po*Ku,su+=po*Vu,tu+=po*cp,zl+=po*fp,Gl+=po*lp,Jl+=po*np,Pl+=po*Rp,Fl+=po*wp,po=Co[8],pu+=po*Qo,yu+=po*Zu,hu+=po*Qu,mu+=po*_h,vu+=po*qu,fu+=po*Ju,gu+=po*_d,ou+=po*dp,su+=po*Ku,tu+=po*Vu,zl+=po*cp,Gl+=po*fp,Jl+=po*lp,Pl+=po*np,Fl+=po*Rp,Yl+=po*wp,po=Co[9],yu+=po*Qo,hu+=po*Zu,mu+=po*Qu,vu+=po*_h,fu+=po*qu,gu+=po*Ju,ou+=po*_d,su+=po*dp,tu+=po*Ku,zl+=po*Vu,Gl+=po*cp,Jl+=po*fp,Pl+=po*lp,Fl+=po*np,Yl+=po*Rp,Vl+=po*wp,po=Co[10],hu+=po*Qo,mu+=po*Zu,vu+=po*Qu,fu+=po*_h,gu+=po*qu,ou+=po*Ju,su+=po*_d,tu+=po*dp,zl+=po*Ku,Gl+=po*Vu,Jl+=po*cp,Pl+=po*fp,Fl+=po*lp,Yl+=po*np,Vl+=po*Rp,Ql+=po*wp,po=Co[11],mu+=po*Qo,vu+=po*Zu,fu+=po*Qu,gu+=po*_h,ou+=po*qu,su+=po*Ju,tu+=po*_d,zl+=po*dp,Gl+=po*Ku,Jl+=po*Vu,Pl+=po*cp,Fl+=po*fp,Yl+=po*lp,Vl+=po*np,Ql+=po*Rp,au+=po*wp,po=Co[12],vu+=po*Qo,fu+=po*Zu,gu+=po*Qu,ou+=po*_h,su+=po*qu,tu+=po*Ju,zl+=po*_d,Gl+=po*dp,Jl+=po*Ku,Pl+=po*Vu,Fl+=po*cp,Yl+=po*fp,Vl+=po*lp,Ql+=po*np,au+=po*Rp,Nu+=po*wp,po=Co[13],fu+=po*Qo,gu+=po*Zu,ou+=po*Qu,su+=po*_h,tu+=po*qu,zl+=po*Ju,Gl+=po*_d,Jl+=po*dp,Pl+=po*Ku,Fl+=po*Vu,Yl+=po*cp,Vl+=po*fp,Ql+=po*lp,au+=po*np,Nu+=po*Rp,Wu+=po*wp,po=Co[14],gu+=po*Qo,ou+=po*Zu,su+=po*Qu,tu+=po*_h,zl+=po*qu,Gl+=po*Ju,Jl+=po*_d,Pl+=po*dp,Fl+=po*Ku,Yl+=po*Vu,Vl+=po*cp,Ql+=po*fp,au+=po*lp,Nu+=po*np,Wu+=po*Rp,zu+=po*wp,po=Co[15],ou+=po*Qo,su+=po*Zu,tu+=po*Qu,zl+=po*_h,Gl+=po*qu,Jl+=po*Ju,Pl+=po*_d,Fl+=po*dp,Yl+=po*Ku,Vl+=po*Vu,Ql+=po*cp,au+=po*fp,Nu+=po*lp,Wu+=po*np,zu+=po*Rp,Bu+=po*wp,Xo+=38*su,jo+=38*tu,Ko+=38*zl,Wl+=38*Gl,$l+=38*Jl,El+=38*Pl,Cu+=38*Fl,iu+=38*Yl,pu+=38*Vl,yu+=38*Ql,hu+=38*au,mu+=38*Nu,vu+=38*Wu,fu+=38*zu,gu+=38*Bu,Ro=1,po=Xo+Ro+65535,Ro=Math.floor(po/65536),Xo=po-Ro*65536,po=jo+Ro+65535,Ro=Math.floor(po/65536),jo=po-Ro*65536,po=Ko+Ro+65535,Ro=Math.floor(po/65536),Ko=po-Ro*65536,po=Wl+Ro+65535,Ro=Math.floor(po/65536),Wl=po-Ro*65536,po=$l+Ro+65535,Ro=Math.floor(po/65536),$l=po-Ro*65536,po=El+Ro+65535,Ro=Math.floor(po/65536),El=po-Ro*65536,po=Cu+Ro+65535,Ro=Math.floor(po/65536),Cu=po-Ro*65536,po=iu+Ro+65535,Ro=Math.floor(po/65536),iu=po-Ro*65536,po=pu+Ro+65535,Ro=Math.floor(po/65536),pu=po-Ro*65536,po=yu+Ro+65535,Ro=Math.floor(po/65536),yu=po-Ro*65536,po=hu+Ro+65535,Ro=Math.floor(po/65536),hu=po-Ro*65536,po=mu+Ro+65535,Ro=Math.floor(po/65536),mu=po-Ro*65536,po=vu+Ro+65535,Ro=Math.floor(po/65536),vu=po-Ro*65536,po=fu+Ro+65535,Ro=Math.floor(po/65536),fu=po-Ro*65536,po=gu+Ro+65535,Ro=Math.floor(po/65536),gu=po-Ro*65536,po=ou+Ro+65535,Ro=Math.floor(po/65536),ou=po-Ro*65536,Xo+=Ro-1+37*(Ro-1),Ro=1,po=Xo+Ro+65535,Ro=Math.floor(po/65536),Xo=po-Ro*65536,po=jo+Ro+65535,Ro=Math.floor(po/65536),jo=po-Ro*65536,po=Ko+Ro+65535,Ro=Math.floor(po/65536),Ko=po-Ro*65536,po=Wl+Ro+65535,Ro=Math.floor(po/65536),Wl=po-Ro*65536,po=$l+Ro+65535,Ro=Math.floor(po/65536),$l=po-Ro*65536,po=El+Ro+65535,Ro=Math.floor(po/65536),El=po-Ro*65536,po=Cu+Ro+65535,Ro=Math.floor(po/65536),Cu=po-Ro*65536,po=iu+Ro+65535,Ro=Math.floor(po/65536),iu=po-Ro*65536,po=pu+Ro+65535,Ro=Math.floor(po/65536),pu=po-Ro*65536,po=yu+Ro+65535,Ro=Math.floor(po/65536),yu=po-Ro*65536,po=hu+Ro+65535,Ro=Math.floor(po/65536),hu=po-Ro*65536,po=mu+Ro+65535,Ro=Math.floor(po/65536),mu=po-Ro*65536,po=vu+Ro+65535,Ro=Math.floor(po/65536),vu=po-Ro*65536,po=fu+Ro+65535,Ro=Math.floor(po/65536),fu=po-Ro*65536,po=gu+Ro+65535,Ro=Math.floor(po/65536),gu=po-Ro*65536,po=ou+Ro+65535,Ro=Math.floor(po/65536),ou=po-Ro*65536,Xo+=Ro-1+37*(Ro-1),So[0]=Xo,So[1]=jo,So[2]=Ko,So[3]=Wl,So[4]=$l,So[5]=El,So[6]=Cu,So[7]=iu,So[8]=pu,So[9]=yu,So[10]=hu,So[11]=mu,So[12]=vu,So[13]=fu,So[14]=gu,So[15]=ou}function go(So,Co){vo(So,Co,Co)}function uo(So,Co){var Ao=wr(),po;for(po=0;po<16;po++)Ao[po]=Co[po];for(po=253;po>=0;po--)go(Ao,Ao),po!==2&&po!==4&&vo(Ao,Ao,Co);for(po=0;po<16;po++)So[po]=Ao[po]}function lo(So,Co){var Ao=wr(),po;for(po=0;po<16;po++)Ao[po]=Co[po];for(po=250;po>=0;po--)go(Ao,Ao),po!==1&&vo(Ao,Ao,Co);for(po=0;po<16;po++)So[po]=Ao[po]}function Eo(So,Co,Ao){var po=new Uint8Array(32),Ro=new Float64Array(80),Xo,jo,Ko=wr(),Wl=wr(),$l=wr(),El=wr(),Cu=wr(),iu=wr();for(jo=0;jo<31;jo++)po[jo]=Co[jo];for(po[31]=Co[31]&127|64,po[0]&=248,wn(Ro,Ao),jo=0;jo<16;jo++)Wl[jo]=Ro[jo],El[jo]=Ko[jo]=$l[jo]=0;for(Ko[0]=El[0]=1,jo=254;jo>=0;--jo)Xo=po[jo>>>3]>>>(jo&7)&1,Pn(Ko,Wl,Xo),Pn($l,El,Xo),zn(Cu,Ko,$l),fo(Ko,Ko,$l),zn($l,Wl,El),fo(Wl,Wl,El),go(El,Cu),go(iu,Ko),vo(Ko,$l,Ko),vo($l,Wl,Cu),zn(Cu,Ko,$l),fo(Ko,Ko,$l),go(Wl,Ko),fo($l,El,iu),vo(Ko,$l,qr),zn(Ko,Ko,El),vo($l,$l,Ko),vo(Ko,El,iu),vo(El,Wl,Ro),go(Wl,Cu),Pn(Ko,Wl,Xo),Pn($l,El,Xo);for(jo=0;jo<16;jo++)Ro[jo+16]=Ko[jo],Ro[jo+32]=$l[jo],Ro[jo+48]=Wl[jo],Ro[jo+64]=El[jo];var pu=Ro.subarray(32),yu=Ro.subarray(16);return uo(pu,pu),vo(yu,yu,pu),On(So,yu),0}function mo(So,Co){return Eo(So,Co,jr)}function yo(So,Co){return Er(Co,32),mo(So,Co)}function _o(So,Co,Ao){var po=new Uint8Array(32);return Eo(po,Ao,Co),ro(So,kr,po,to)}var Bo=Gr,Lo=Xr;function Wo(So,Co,Ao,po,Ro,Xo){var jo=new Uint8Array(32);return _o(jo,Ro,Xo),Bo(So,Co,Ao,po,jo)}function na(So,Co,Ao,po,Ro,Xo){var jo=new Uint8Array(32);return _o(jo,Ro,Xo),Lo(So,Co,Ao,po,jo)}var qo=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function ga(So,Co,Ao,po){for(var Ro=new Int32Array(16),Xo=new Int32Array(16),jo,Ko,Wl,$l,El,Cu,iu,pu,yu,hu,mu,vu,fu,gu,ou,su,tu,zl,Gl,Jl,Pl,Fl,Yl,Vl,Ql,au,Nu=So[0],Wu=So[1],zu=So[2],Bu=So[3],Qo=So[4],Zu=So[5],Qu=So[6],_h=So[7],qu=Co[0],Ju=Co[1],_d=Co[2],dp=Co[3],Ku=Co[4],Vu=Co[5],cp=Co[6],fp=Co[7],lp=0;po>=128;){for(Gl=0;Gl<16;Gl++)Jl=8*Gl+lp,Ro[Gl]=Ao[Jl+0]<<24|Ao[Jl+1]<<16|Ao[Jl+2]<<8|Ao[Jl+3],Xo[Gl]=Ao[Jl+4]<<24|Ao[Jl+5]<<16|Ao[Jl+6]<<8|Ao[Jl+7];for(Gl=0;Gl<80;Gl++)if(jo=Nu,Ko=Wu,Wl=zu,$l=Bu,El=Qo,Cu=Zu,iu=Qu,pu=_h,yu=qu,hu=Ju,mu=_d,vu=dp,fu=Ku,gu=Vu,ou=cp,su=fp,Pl=_h,Fl=fp,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=(Qo>>>14|Ku<<18)^(Qo>>>18|Ku<<14)^(Ku>>>9|Qo<<23),Fl=(Ku>>>14|Qo<<18)^(Ku>>>18|Qo<<14)^(Qo>>>9|Ku<<23),Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Pl=Qo&Zu^~Qo&Qu,Fl=Ku&Vu^~Ku&cp,Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Pl=qo[Gl*2],Fl=qo[Gl*2+1],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Pl=Ro[Gl%16],Fl=Xo[Gl%16],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,tu=Ql&65535|au<<16,zl=Yl&65535|Vl<<16,Pl=tu,Fl=zl,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=(Nu>>>28|qu<<4)^(qu>>>2|Nu<<30)^(qu>>>7|Nu<<25),Fl=(qu>>>28|Nu<<4)^(Nu>>>2|qu<<30)^(Nu>>>7|qu<<25),Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Pl=Nu&Wu^Nu&zu^Wu&zu,Fl=qu&Ju^qu&_d^Ju&_d,Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,pu=Ql&65535|au<<16,su=Yl&65535|Vl<<16,Pl=$l,Fl=vu,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=tu,Fl=zl,Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,$l=Ql&65535|au<<16,vu=Yl&65535|Vl<<16,Wu=jo,zu=Ko,Bu=Wl,Qo=$l,Zu=El,Qu=Cu,_h=iu,Nu=pu,Ju=yu,_d=hu,dp=mu,Ku=vu,Vu=fu,cp=gu,fp=ou,qu=su,Gl%16===15)for(Jl=0;Jl<16;Jl++)Pl=Ro[Jl],Fl=Xo[Jl],Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=Ro[(Jl+9)%16],Fl=Xo[(Jl+9)%16],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,tu=Ro[(Jl+1)%16],zl=Xo[(Jl+1)%16],Pl=(tu>>>1|zl<<31)^(tu>>>8|zl<<24)^tu>>>7,Fl=(zl>>>1|tu<<31)^(zl>>>8|tu<<24)^(zl>>>7|tu<<25),Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,tu=Ro[(Jl+14)%16],zl=Xo[(Jl+14)%16],Pl=(tu>>>19|zl<<13)^(zl>>>29|tu<<3)^tu>>>6,Fl=(zl>>>19|tu<<13)^(tu>>>29|zl<<3)^(zl>>>6|tu<<26),Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,Ro[Jl]=Ql&65535|au<<16,Xo[Jl]=Yl&65535|Vl<<16;Pl=Nu,Fl=qu,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[0],Fl=Co[0],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[0]=Nu=Ql&65535|au<<16,Co[0]=qu=Yl&65535|Vl<<16,Pl=Wu,Fl=Ju,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[1],Fl=Co[1],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[1]=Wu=Ql&65535|au<<16,Co[1]=Ju=Yl&65535|Vl<<16,Pl=zu,Fl=_d,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[2],Fl=Co[2],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[2]=zu=Ql&65535|au<<16,Co[2]=_d=Yl&65535|Vl<<16,Pl=Bu,Fl=dp,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[3],Fl=Co[3],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[3]=Bu=Ql&65535|au<<16,Co[3]=dp=Yl&65535|Vl<<16,Pl=Qo,Fl=Ku,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[4],Fl=Co[4],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[4]=Qo=Ql&65535|au<<16,Co[4]=Ku=Yl&65535|Vl<<16,Pl=Zu,Fl=Vu,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[5],Fl=Co[5],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[5]=Zu=Ql&65535|au<<16,Co[5]=Vu=Yl&65535|Vl<<16,Pl=Qu,Fl=cp,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[6],Fl=Co[6],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[6]=Qu=Ql&65535|au<<16,Co[6]=cp=Yl&65535|Vl<<16,Pl=_h,Fl=fp,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[7],Fl=Co[7],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[7]=_h=Ql&65535|au<<16,Co[7]=fp=Yl&65535|Vl<<16,lp+=128,po-=128}return po}function wl(So,Co,Ao){var po=new Int32Array(8),Ro=new Int32Array(8),Xo=new Uint8Array(256),jo,Ko=Ao;for(po[0]=1779033703,po[1]=3144134277,po[2]=1013904242,po[3]=2773480762,po[4]=1359893119,po[5]=2600822924,po[6]=528734635,po[7]=1541459225,Ro[0]=4089235720,Ro[1]=2227873595,Ro[2]=4271175723,Ro[3]=1595750129,Ro[4]=2917565137,Ro[5]=725511199,Ro[6]=4215389547,Ro[7]=327033209,ga(po,Ro,Co,Ao),Ao%=128,jo=0;jo=0;--Ro)po=Ao[Ro/8|0]>>(Ro&7)&1,Fo(So,Co,po),No(Co,So),No(So,So),Fo(So,Co,po)}function Uo(So,Co){var Ao=[wr(),wr(),wr(),wr()];Sn(Ao[0],Zr),Sn(Ao[1],Jr),Sn(Ao[2],Wr),vo(Ao[3],Zr,Jr),Vo(So,Ao,Co)}function Ol(So,Co,Ao){var po=new Uint8Array(64),Ro=[wr(),wr(),wr(),wr()],Xo;for(Ao||Er(Co,32),wl(po,Co,32),po[0]&=248,po[31]&=127,po[31]|=64,Uo(Ro,po),Nl(So,Ro),Xo=0;Xo<32;Xo++)Co[Xo+32]=So[Xo];return 0}var $a=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Jo(So,Co){var Ao,po,Ro,Xo;for(po=63;po>=32;--po){for(Ao=0,Ro=po-32,Xo=po-12;Ro>4)*$a[Ro],Ao=Co[Ro]>>8,Co[Ro]&=255;for(Ro=0;Ro<32;Ro++)Co[Ro]-=Ao*$a[Ro];for(po=0;po<32;po++)Co[po+1]+=Co[po]>>8,So[po]=Co[po]&255}function Zl(So){var Co=new Float64Array(64),Ao;for(Ao=0;Ao<64;Ao++)Co[Ao]=So[Ao];for(Ao=0;Ao<64;Ao++)So[Ao]=0;Jo(So,Co)}function Cl(So,Co,Ao,po){var Ro=new Uint8Array(64),Xo=new Uint8Array(64),jo=new Uint8Array(64),Ko,Wl,$l=new Float64Array(64),El=[wr(),wr(),wr(),wr()];wl(Ro,po,32),Ro[0]&=248,Ro[31]&=127,Ro[31]|=64;var Cu=Ao+64;for(Ko=0;Ko>7&&fo(So[0],Br,So[0]),vo(So[3],So[0],So[1]),0)}function wo(So,Co,Ao,po){var Ro,Xo=new Uint8Array(32),jo=new Uint8Array(64),Ko=[wr(),wr(),wr(),wr()],Wl=[wr(),wr(),wr(),wr()];if(Ao<64||ko(Wl,po))return-1;for(Ro=0;Ro=0},br.sign.keyPair=function(){var So=new Uint8Array(Il),Co=new Uint8Array(Eu);return Ol(So,Co),{publicKey:So,secretKey:Co}},br.sign.keyPair.fromSecretKey=function(So){if(Sl(So),So.length!==Eu)throw new Error("bad secret key size");for(var Co=new Uint8Array(Il),Ao=0;Ao`https://phantom.app/ul/v1/${fr}?${br.toString()}`,decryptPayload=(fr,br,wr)=>{const Er=nacl.box.open.after(bs58$8.decode(fr),bs58$8.decode(br),wr);if(!Er)throw new Error("Unable to decrypt data");return JSON.parse(Buffer$2.from(Er).toString("utf8"))},encryptPayload=(fr,br)=>{const wr=nacl.randomBytes(24),Er=nacl.box.after(Buffer$2.from(JSON.stringify(fr)),wr,br);return[wr,Er]},GENESIS_HASHES={"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY":"testnet","5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d":"mainnet-beta",EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG:"devnet"},fetchCluster=fr=>__awaiter$3(void 0,void 0,void 0,function*(){try{const{result:br}=yield(yield fetch(fr,{body:JSON.stringify({id:1,jsonrpc:"2.0",method:"getGenesisHash"}),headers:{"Content-Type":"application/json"},method:"POST"})).json();return GENESIS_HASHES[br]}catch{return"mainnet-beta"}}),storage={address:{get:()=>{var fr;return(fr=localStorage.getItem("dynamic_phantom_wallet_address"))!==null&&fr!==void 0?fr:void 0},remove:()=>{localStorage.removeItem("dynamic_phantom_wallet_address")},set:fr=>{localStorage.setItem("dynamic_phantom_wallet_address",fr.toString())}},encryptionPublicKey:{get:()=>{const fr=localStorage.getItem("dynamic_phantom_public_key");if(fr)return new Uint8Array(JSON.parse(fr))},remove:()=>{localStorage.removeItem("dynamic_phantom_public_key")},set:fr=>{localStorage.setItem("dynamic_phantom_public_key",JSON.stringify([...fr]))}},encryptionSecretKey:{get:()=>{const fr=localStorage.getItem("dynamic_phantom_secret_key");if(fr)return new Uint8Array(JSON.parse(fr))},remove:()=>{localStorage.removeItem("dynamic_phantom_secret_key")},set:fr=>{localStorage.setItem("dynamic_phantom_secret_key",JSON.stringify([...fr]))}},message:{get:()=>{var fr;return(fr=localStorage.getItem("dynamic_phantom_message_to_sign"))!==null&&fr!==void 0?fr:void 0},remove:()=>{localStorage.removeItem("dynamic_phantom_message_to_sign")},set:fr=>{localStorage.setItem("dynamic_phantom_message_to_sign",fr)}},method:{get:()=>{var fr;return(fr=localStorage.getItem("dynamic_phantom_method"))!==null&&fr!==void 0?fr:void 0},remove:()=>{localStorage.removeItem("dynamic_phantom_method")},set:fr=>{localStorage.setItem("dynamic_phantom_method",fr)}},session:{get:()=>{var fr;return(fr=localStorage.getItem("dynamic_phantom_session"))!==null&&fr!==void 0?fr:void 0},remove:()=>{localStorage.removeItem("dynamic_phantom_session")},set:fr=>{localStorage.setItem("dynamic_phantom_session",fr)}},sharedSecret:{get:()=>{const fr=localStorage.getItem("dynamic_phantom_shared_secret");if(fr)return new Uint8Array(JSON.parse(fr))},remove:()=>{localStorage.removeItem("dynamic_phantom_shared_secret")},set:fr=>{localStorage.setItem("dynamic_phantom_shared_secret",JSON.stringify([...fr]))}}},clearStorage=()=>{for(const fr in storage)storage[fr].remove()};class PhantomRedirect extends SolanaWalletConnector{constructor(br){super(Object.assign({},br)),this.name="Phantom",this.overrideKey="phantom"}getMethod(){throw new Error("Method not implemented.")}getAddress(){return __awaiter$3(this,void 0,void 0,function*(){const br=storage.address.get();if(br)return br;yield this.connect()})}connect(){return __awaiter$3(this,void 0,void 0,function*(){var br,wr;const Er=nacl.box.keyPair();storage.encryptionPublicKey.set(Er.publicKey),storage.encryptionSecretKey.set(Er.secretKey);const kr=window.location.href.includes("localhost")||window.location.href.includes("0.0.0.0")||window.location.href.includes("127.0.0.1"),jr=(wr=(br=this.solNetworks[0].privateCustomerRpcUrls)===null||br===void 0?void 0:br[0])!==null&&wr!==void 0?wr:this.solNetworks[0].rpcUrls[0],Br=new URLSearchParams({app_url:kr?"https://demo.dynamic.xyz":window.location.href,cluster:yield fetchCluster(jr),dapp_encryption_public_key:bs58$8.encode(Er.publicKey),redirect_link:window.location.href}),Wr=buildUrl("connect",Br);window.location.href=Wr})}getSession(){return __awaiter$3(this,void 0,void 0,function*(){const br=new URLSearchParams(window.location.search),{data:wr,nonce:Er,phantom_encryption_public_key:kr,encryptionSecretKey:jr}=this.getInputsOrThrow("getSession",["data","nonce","phantom_encryption_public_key"],["encryptionSecretKey"]),Br=nacl.box.before(bs58$8.decode(kr),jr);storage.sharedSecret.set(Br);const Wr=decryptPayload(wr,Er,Br);return storage.session.set(Wr.session),storage.address.set(new PublicKey$2(Wr.public_key)),br.delete("phantom_encryption_public_key"),br.delete("data"),br.delete("nonce"),history.replaceState(null,"",`${window.location.origin}${window.location.pathname}?${br.toString()}`),Wr.public_key})}signMessage(br){return __awaiter$3(this,void 0,void 0,function*(){const{session:wr,sharedSecret:Er,encryptionPublicKey:kr}=this.getInputsOrThrow("signMessage",[],["session","sharedSecret","encryptionPublicKey"]);storage.message.set(br);const jr={message:bs58$8.encode(Buffer$2.from(br)),session:wr},[Br,Wr]=encryptPayload(jr,Er),qr=new URLSearchParams({dapp_encryption_public_key:bs58$8.encode(kr),nonce:bs58$8.encode(Br),payload:bs58$8.encode(Wr),redirect_link:window.location.href}),Hr=buildUrl("signMessage",qr);throw storage.method.set("signMessage"),window.location.href=Hr,new Error("ignore")})}extractSignature(){const br=new URLSearchParams(window.location.search),{data:wr,nonce:Er,sharedSecret:kr,message:jr}=this.getInputsOrThrow("extractSignature",["data","nonce"],["sharedSecret","message"]),Br=decryptPayload(wr,Er,kr);return br.delete("data"),br.delete("nonce"),history.replaceState(null,"",`${window.location.origin}${window.location.pathname}?${br.toString()}`),{message:jr,signature:Br.signature}}extractTransactions(){const br=new URLSearchParams(window.location.search),{data:wr,nonce:Er,sharedSecret:kr}=this.getInputsOrThrow("extractTransactions",["data","nonce"],["sharedSecret"]),Br=decryptPayload(wr,Er,kr).transactions.map(Wr=>Transaction.from(bs58$8.decode(Wr)));return br.delete("data"),br.delete("nonce"),history.replaceState(null,"",`${window.location.origin}${window.location.pathname}?${br.toString()}`),Br}extractTransaction(){const br=new URLSearchParams(window.location.search),{data:wr,nonce:Er,sharedSecret:kr}=this.getInputsOrThrow("extractTransaction",["data","nonce"],["sharedSecret"]),jr=decryptPayload(wr,Er,kr),Br=Transaction.from(bs58$8.decode(jr.transaction));return br.delete("data"),br.delete("nonce"),history.replaceState(null,"",`${window.location.origin}${window.location.pathname}?${br.toString()}`),Br}consumeMethod(){const br=storage.method.get();return storage.method.remove(),br}getSigner(){return __awaiter$3(this,void 0,void 0,function*(){const br=storage.address.get();if(br)return{addListener:()=>{throw new Error("Not implemented")},connect:()=>{throw new Error("Not implemented")},disconnect:()=>{throw new Error("Not implemented")},emit:()=>{throw new Error("Not implemented")},eventNames:()=>{throw new Error("Not implemented")},isBackpack:!1,isBraveWallet:!1,isConnected:!0,isExodus:!1,isGlow:!1,isMagicEden:!1,isPhantom:!0,isSolflare:!1,listenerCount:()=>{throw new Error("Not implemented")},listeners:()=>{throw new Error("Not implemented")},off:()=>{throw new Error("Not implemented")},on:()=>{throw new Error("Not implemented")},once:()=>{throw new Error("Not implemented")},providers:[],publicKey:new PublicKey$2(br),removeAllListeners:()=>{throw new Error("Not implemented")},removeListener:()=>{throw new Error("Not implemented")},signAllTransactions:wr=>__awaiter$3(this,void 0,void 0,function*(){const Er=wr.map(Jr=>bs58$8.encode(Jr.serialize({requireAllSignatures:!1}))),{session:kr,sharedSecret:jr,encryptionPublicKey:Br}=this.getInputsOrThrow("signAllTransactions",[],["session","sharedSecret","encryptionPublicKey"]),Wr={session:kr,transactions:Er},[qr,Hr]=encryptPayload(Wr,jr),Vr=new URLSearchParams({dapp_encryption_public_key:bs58$8.encode(Br),nonce:bs58$8.encode(qr),payload:bs58$8.encode(Hr),redirect_link:window.location.href}),Zr=buildUrl("signAllTransactions",Vr);return window.location.href=Zr,[]}),signAndSendTransaction:(wr,Er)=>__awaiter$3(this,void 0,void 0,function*(){const{session:kr,sharedSecret:jr,encryptionPublicKey:Br}=this.getInputsOrThrow("signAndSendTransaction",[],["session","sharedSecret","encryptionPublicKey"]),Wr={options:Er,session:kr,transaction:bs58$8.encode(wr.serialize({requireAllSignatures:!1}))},[qr,Hr]=encryptPayload(Wr,jr),Vr=new URLSearchParams({dapp_encryption_public_key:bs58$8.encode(Br),nonce:bs58$8.encode(qr),payload:bs58$8.encode(Hr),redirect_link:window.location.href}),Zr=buildUrl("signAndSendTransaction",Vr);return storage.method.set("signAndSendTransaction"),window.location.href=Zr,{signature:""}}),signMessage:wr=>__awaiter$3(this,void 0,void 0,function*(){const{session:Er,sharedSecret:kr,encryptionPublicKey:jr}=this.getInputsOrThrow("signMessage",[],["session","sharedSecret","encryptionPublicKey"]),Br={message:bs58$8.encode(Buffer$2.from(wr)),session:Er},[Wr,qr]=encryptPayload(Br,kr),Hr=new URLSearchParams({dapp_encryption_public_key:bs58$8.encode(jr),nonce:bs58$8.encode(Wr),payload:bs58$8.encode(qr),redirect_link:window.location.href}),Vr=buildUrl("signMessage",Hr);return window.location.href=Vr,{signature:Buffer$2.from("")}}),signTransaction:wr=>__awaiter$3(this,void 0,void 0,function*(){const Er=bs58$8.encode(wr.serialize({requireAllSignatures:!1})),{session:kr,sharedSecret:jr,encryptionPublicKey:Br}=this.getInputsOrThrow("signTransaction",[],["session","sharedSecret","encryptionPublicKey"]),Wr={session:kr,transaction:Er},[qr,Hr]=encryptPayload(Wr,jr),Vr=new URLSearchParams({dapp_encryption_public_key:bs58$8.encode(Br),nonce:bs58$8.encode(qr),payload:bs58$8.encode(Hr),redirect_link:window.location.href}),Zr=buildUrl("signTransaction",Vr);return window.location.href=Zr,wr})}})}getConnectedAccounts(){return __awaiter$3(this,void 0,void 0,function*(){const br=storage.address.get();return br?[br]:[]})}endSession(){return __awaiter$3(this,void 0,void 0,function*(){const br=storage.address.get(),wr=storage.session.get(),Er=storage.sharedSecret.get(),kr=storage.encryptionPublicKey.get();if(clearStorage(),!br||!wr||!kr||!Er)return;const jr={session:wr},[Br,Wr]=encryptPayload(jr,Er),qr=new URLSearchParams({dapp_encryption_public_key:bs58$8.encode(kr),nonce:bs58$8.encode(Br),payload:bs58$8.encode(Wr),redirect_link:window.location.href}),Hr=buildUrl("disconnect",qr);window.location.href=Hr})}getInputsOrThrow(br,wr,Er){const kr={},jr=new URLSearchParams(window.location.search);return wr.forEach(Br=>{const Wr=jr.get(Br);if(!Wr)throw new Error(`[PhantomRedirect] ${br} called, but required input '${Br}' not found in query params`);kr[Br]=Wr}),Er.forEach(Br=>{const Wr=storage[Br].get();if(!Wr)throw new Error(`[PhantomRedirect] ${br} called, but required input '${Br}' not found in local storage`);kr[Br]=Wr}),kr}}class PhantomInjected extends InjectedWalletBase{constructor(br){super(br),this.name="Phantom",this.overrideKey="phantom",this.wallet=findWalletBookWallet(this.walletBook,this.key)}getAddress(){const br=Object.create(null,{getAddress:{get:()=>super.getAddress}});return __awaiter$3(this,void 0,void 0,function*(){if(this.isInstalledOnBrowser())return br.getAddress.call(this);isMobile()&&handleMobileWalletRedirect({nativeLink:"phantom://browse",universalLink:"https://phantom.app/ul/browse"})})}canGetChainAddress(){var br,wr;return((wr=(br=this.getSolProviderHelper())===null||br===void 0?void 0:br.findProvider())===null||wr===void 0?void 0:wr.publicKey)!==null}}class Phantom extends SolanaWalletConnector{constructor(br){super(br),this.name="Phantom",this.overrideKey="phantom",this.wallet=findWalletBookWallet(this.walletBook,this.key)}connect(){return __awaiter$3(this,void 0,void 0,function*(){yield this.getMobileOrInstalledWallet().connect()})}getSigner(){return __awaiter$3(this,void 0,void 0,function*(){return this.getMobileOrInstalledWallet().getSigner()})}getMobileOrInstalledWallet(){const br=new PhantomInjected(this.constructorProps);return!isMobile()||br.isInstalledOnBrowser()?br:this.mobileExperience==="redirect"?new PhantomRedirect(this.constructorProps):new PhantomInjected(this.constructorProps)}}class CoinbaseSolana extends InjectedWalletBase{constructor(br){super(br),this.name="CoinbaseSolana",this.overrideKey="coinbasesolana",this.wallet=findWalletBookWallet(this.walletBook,this.key)}getSigner(){return __awaiter$3(this,void 0,void 0,function*(){var br;return(br=this.getSolProviderHelper())===null||br===void 0?void 0:br.connect()})}signMessage(br){return __awaiter$3(this,void 0,void 0,function*(){const wr=yield this.getAddress();if(!wr)return;const Er=yield this.getSigner();if(!Er)return;const kr=new TextEncoder().encode(br),jr=yield Er.signMessage(kr,wr);if(jr)return bufferToBase64(isSignedMessage(jr)?jr.signature:jr)})}}class Solflare extends InjectedWalletBase{constructor(br){super(br),this.name="Solflare",this.overrideKey="solflare",this.wallet=findWalletBookWallet(this.walletBook,this.key)}getAddress(){return __awaiter$3(this,void 0,void 0,function*(){var br,wr,Er,kr,jr;if(isMobile()&&!this.isInstalledOnBrowser()){handleMobileWalletRedirect({nativeLink:((wr=(br=this.wallet)===null||br===void 0?void 0:br.mobile)===null||wr===void 0?void 0:wr.native)||"solflare://ul/v1/browse",universalLink:((kr=(Er=this.wallet)===null||Er===void 0?void 0:Er.mobile)===null||kr===void 0?void 0:kr.universal)||"https://solflare.com/ul/v1/browse"});return}return(jr=this.getSolProviderHelper())===null||jr===void 0?void 0:jr.getAddress()})}signMessage(br){return __awaiter$3(this,void 0,void 0,function*(){if(!(yield this.getAddress()))return;const Er=yield this.getSigner();if(!Er)return;const kr=new TextEncoder().encode(br),jr=Wr=>Wr.signature!==void 0;yield Er.connect(),yield new Promise(Wr=>{setTimeout(Wr,100)});const Br=yield Er.signMessage(kr,"utf8");return jr(Br)?bufferToBase64(Br.signature):void 0})}}const isVersionedTransaction=fr=>!("instructions"in fr),createSolanaSignerFromWalletStandard=(fr,br)=>{const wr=fr.features,Er=()=>__awaiter$3(void 0,void 0,void 0,function*(){const Hr=yield br.getAddress(),Vr=fr.accounts.find(Zr=>Zr.address===Hr);if(!Vr)throw new Error("Account not found");return Vr}),kr=()=>__awaiter$3(void 0,void 0,void 0,function*(){var Hr,Vr;const Zr=(Vr=(Hr=br.solNetworks[0].privateCustomerRpcUrls)===null||Hr===void 0?void 0:Hr[0])!==null&&Vr!==void 0?Vr:br.solNetworks[0].rpcUrls[0];return`solana:${yield fetchCluster(Zr)}`}),jr=Hr=>__awaiter$3(void 0,void 0,void 0,function*(){const Vr=yield Er(),Zr=yield wr["solana:signTransaction"].signTransaction({account:Vr,chain:yield kr(),transaction:Hr.serialize({requireAllSignatures:!1})});return isVersionedTransaction(Hr)?VersionedTransaction.deserialize(Zr[0].signedTransaction):Transaction.from(Zr[0].signedTransaction)});return{addListener:()=>{throw new Error("Not implemented")},connect:()=>{throw new Error("Not implemented")},disconnect:()=>br.endSession(),emit:()=>{throw new Error("Not implemented")},eventNames:()=>{throw new Error("Not implemented")},isBackpack:!1,isBraveWallet:!1,isConnected:!0,isExodus:!1,isGlow:!1,isMagicEden:!1,isPhantom:!1,isSolflare:!1,listenerCount:()=>{throw new Error("Not implemented")},listeners:()=>{throw new Error("Not implemented")},off:()=>{throw new Error("Not implemented")},on:()=>{throw new Error("Not implemented")},once:()=>{throw new Error("Not implemented")},providers:[],get publicKey(){return new PublicKey$2(fr.accounts[0].publicKey)},removeAllListeners:()=>{throw new Error("Not implemented")},removeListener:()=>{throw new Error("Not implemented")},send:()=>{throw new Error("Not implemented")},signAllTransactions:Hr=>__awaiter$3(void 0,void 0,void 0,function*(){return Promise.all(Hr.map(jr))}),signAndSendTransaction:Hr=>__awaiter$3(void 0,void 0,void 0,function*(){const Vr=yield Er(),Zr=yield wr["solana:signAndSendTransaction"].signAndSendTransaction({account:Vr,chain:yield kr(),transaction:Hr.serialize()}),[{signature:Jr}]=Zr;return{signature:new TextDecoder().decode(Jr)}}),signMessage:Hr=>__awaiter$3(void 0,void 0,void 0,function*(){const Vr=yield Er();return{signature:(yield wr["solana:signMessage"].signMessage({account:Vr,message:Hr}))[0].signature}}),signTransaction:jr}},encoder=new TextEncoder;class SolanaWalletStandardConnector extends SolanaWalletConnector{constructor(br){super(br),this.connectedChain="SOL",this.supportedChains=["SOL"]}get wallet(){const br=SolanaWalletStandardConnector.getWallet(this.walletBook,this.key);if(!br)throw new Error("Wallet not found");return br}get walletFeatures(){return this.wallet.features}connect(){return __awaiter$3(this,void 0,void 0,function*(){yield this.walletFeatures["standard:connect"].connect()})}endSession(){return __awaiter$3(this,void 0,void 0,function*(){yield this.walletFeatures["standard:disconnect"].disconnect()})}isInstalledOnBrowser(){return!0}getAddress(){return __awaiter$3(this,void 0,void 0,function*(){yield this.connect();const[br]=yield this.getConnectedAccounts();return br})}getConnectedAccounts(){return __awaiter$3(this,void 0,void 0,function*(){return this.wallet.accounts.map(wr=>wr.address)})}signMessage(br){return __awaiter$3(this,void 0,void 0,function*(){const wr=yield this.getSigner();if(!wr)throw new Error("Signer not found");const Er=encoder.encode(br),{signature:kr}=yield wr.signMessage(Er);if(!(kr instanceof Uint8Array))throw new Error("Signature not found");return Buffer$2.from(kr).toString("base64")})}getSigner(){return __awaiter$3(this,void 0,void 0,function*(){const{wallet:br}=this;return createSolanaSignerFromWalletStandard(br,this)})}static getWallet(br,wr){var Er,kr;const jr=getWallets().get(),Br=(Er=br.wallets[wr].injectedConfig)===null||Er===void 0?void 0:Er.find(Hr=>Hr.chain==="sol");if(!Br)return;const{features:Wr}=(kr=Br.walletStandard)!==null&&kr!==void 0?kr:{};return Wr?jr.find(Hr=>{var Vr;return Hr.name===((Vr=Br.walletStandard)===null||Vr===void 0?void 0:Vr.name)?Wr.reduce((Qr,_n)=>{const En=Object.keys(Hr.features);return Qr?En.includes(_n):!1},!0):!1}):void 0}}class BackpackSol extends InjectedWalletBase{constructor(br){super(br),this.name="Backpack",this.overrideKey="backpacksol",this.wallet=findWalletBookWallet(this.walletBook,this.key)}getSigner(){return __awaiter$3(this,void 0,void 0,function*(){var br;return(br=this.getSolProviderHelper())===null||br===void 0?void 0:br.connect()})}signMessage(br){return __awaiter$3(this,void 0,void 0,function*(){if(!(yield this.getAddress()))return;const Er=yield this.getSigner();if(!Er)return;const kr=yield Er.signMessage(Buffer$2.from(br,"utf8"));if(kr)return typeof kr=="object"&&"signature"in kr?bufferToBase64(kr.signature):bufferToBase64(kr)})}}const injectedWalletOverrides=[CoinbaseSolana,BackpackSol,Solflare],filteredInjectedWalletKeysOverrides=["coinbasesolana","phantom","phantomledger","backpacksol","solflare"],fetchInjectedWalletConnectors=({walletBook:fr})=>{var br;return Object.entries((br=fr==null?void 0:fr.wallets)!==null&&br!==void 0?br:{}).filter(([wr,Er])=>{var kr;const jr=!!(!((kr=Er.injectedConfig)===null||kr===void 0)&&kr.find(Wr=>Wr.chain==="sol")),Br=filteredInjectedWalletKeysOverrides.includes(wr);return jr&&!Br}).map(([wr,Er])=>{var kr;const{shortName:jr}=Er,Br=jr||Er.name;return!!(!((kr=Er.injectedConfig)===null||kr===void 0)&&kr.find(qr=>qr.walletStandard))&&!!SolanaWalletStandardConnector.getWallet(fr,wr)?class extends SolanaWalletStandardConnector{constructor(Hr){super(Object.assign({},Hr)),this.name=Br,this.overrideKey=wr}}:class extends InjectedWalletBase{constructor(qr){super(Object.assign({},qr)),this.name=Br,this.wallet=Er,this.overrideKey=wr}}})};class UnknownInjected extends InjectedWalletBase{constructor(br){super(br),this.name="Unknown",this.overrideKey="unknown",this.wallet=findWalletBookWallet(this.walletBook,this.key)}isInstalledOnBrowser(){return!1}}class FallbackSolanaConnector extends InjectedWalletBase{constructor(br){super(br),this.name="Fallback Connector",this.overrideKey="fallbackconnector",this.isAvailable=!1,this.wallet=findWalletBookWallet(this.walletBook,this.key)}isInstalledOnBrowser(){return!1}}const SolanaWalletConnectors=fr=>[...injectedWalletOverrides,...fetchInjectedWalletConnectors(fr),...TurnkeySolanaWalletConnectors(fr),Phantom,UnknownInjected,FallbackSolanaConnector];assertPackageVersion("@dynamic-labs/solana",version$7);client$1.createRoot(document.getElementById("root")).render(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(DynamicContextProvider,{settings:{initialAuthenticationMode:"connect-only",environmentId:"fbb6bfb2-f61f-4105-a9c8-76d8cfc4c1a9",walletConnectors:[EthereumWalletConnectors,SolanaWalletConnectors]},children:jsxRuntimeExports.jsx(App,{})})}));export{Buffer$2 as B,DEFAULT_JWK_MEMBER_BYTE_LENGTH as D,Field as F,__vitePreload as _,uint8ArrayFromHexString as a,createHash as b,createCurve as c,dijkstraExports as d,encodeUtf8$1 as e,global$1 as g,hexStringToBase64url as h,requireCryptoBrowserify as r,sha256$3 as s,uint8ArrayToHexString as u}; + You can read more about it here https://github.com/solana-labs/solana/issues/21366`)}}class InjectedWalletBase extends SolanaWalletConnector{getSolProviderHelper(){return this.wallet||(this.wallet=findWalletBookWallet(this.walletBook,this.key)),this.wallet&&!this.solProviderHelper&&(this.solProviderHelper=new SolProviderHelper(this.wallet)),this.solProviderHelper}getProvider(){var br;return(br=this.getSolProviderHelper())===null||br===void 0?void 0:br.getInstalledProvider()}setupEventListeners(){var br;(br=this.getSolProviderHelper())===null||br===void 0||br._setupEventListeners(this)}teardownEventListeners(){var br;(br=this.getSolProviderHelper())===null||br===void 0||br._teardownEventListeners()}connect(){return __awaiter$3(this,void 0,void 0,function*(){var br;yield(br=this.getSolProviderHelper())===null||br===void 0?void 0:br.connect()})}getSigner(){return __awaiter$3(this,void 0,void 0,function*(){var br;return(br=this.getSolProviderHelper())===null||br===void 0?void 0:br.connect()})}createUiTransaction(br){return __awaiter$3(this,void 0,void 0,function*(){return yield this.validateActiveWallet(br),new SolanaUiTransaction$1({connection:this.getWalletClient(),from:br,onSubmit:Er=>__awaiter$3(this,void 0,void 0,function*(){var kr;if(!Er)return;const jr=yield this.getSigner();if(!jr)throw new Error("Signer not found");const Br=yield this.getWalletClient().getLatestBlockhash();if("version"in Er)Er.message.recentBlockhash=Br.blockhash;else{const Wr=yield this.getAddress();if(!Wr)throw new Error("User address not found");Er.recentBlockhash=Br.blockhash,Er.feePayer=(kr=Er.feePayer)!==null&&kr!==void 0?kr:new PublicKey$2(Wr)}return(yield jr.signAndSendTransaction(Er)).signature})})})}isInstalledOnBrowser(){var br;return!!(!((br=this.getSolProviderHelper())===null||br===void 0)&&br.isInstalledHelper())}getAddress(){return __awaiter$3(this,void 0,void 0,function*(){var br,wr;if(!this.isInstalledOnBrowser()){if(isMobile()&&(!((br=this.wallet)===null||br===void 0)&&br.mobile)&&this.wallet.mobile.inAppBrowser&&this.mobileExperience==="in-app-browser"){const kr=template(this.wallet.mobile.inAppBrowser)({encodedDappURI:encodeURIComponent(window.location.toString())});window.location.assign(kr)}return}return(wr=this.getSolProviderHelper())===null||wr===void 0?void 0:wr.getAddress()})}signMessage(br){return __awaiter$3(this,void 0,void 0,function*(){var wr,Er;const kr=yield(wr=this.getSolProviderHelper())===null||wr===void 0?void 0:wr.getAddress();if(kr&&this.isLedgerAddress(kr))throw new SignMessageNotSupportedError(this.name);return(Er=this.getSolProviderHelper())===null||Er===void 0?void 0:Er.signMessage(br)})}getConnectedAccounts(){return __awaiter$3(this,void 0,void 0,function*(){var br,wr;return(wr=(br=this.getSolProviderHelper())===null||br===void 0?void 0:br.getConnectedAccounts())!==null&&wr!==void 0?wr:[]})}}var version$4="3.8.2",dependencies={"@dynamic-labs/sdk-api-core":"0.0.570","@dynamic-labs/utils":"3.8.2","@dynamic-labs/logger":"3.8.2","@dynamic-labs/types":"3.8.2",eventemitter3:"5.0.1","@solana/web3.js":"1.92.1","@turnkey/http":"2.12.2","@turnkey/iframe-stamper":"2.0.0","@turnkey/solana":"0.3.9","@turnkey/webauthn-stamper":"0.5.0"};function __rest$1(fr,br){var wr={};for(var Er in fr)Object.prototype.hasOwnProperty.call(fr,Er)&&br.indexOf(Er)<0&&(wr[Er]=fr[Er]);if(fr!=null&&typeof Object.getOwnPropertySymbols=="function")for(var kr=0,Er=Object.getOwnPropertySymbols(fr);kr0?Gr:Xr},jr.min=function(Gr,Xr){return Gr.cmp(Xr)<0?Gr:Xr},jr.prototype._init=function(Gr,Xr,Sn){if(typeof Gr=="number")return this._initNumber(Gr,Xr,Sn);if(typeof Gr=="object")return this._initArray(Gr,Xr,Sn);Xr==="hex"&&(Xr=16),Er(Xr===(Xr|0)&&Xr>=2&&Xr<=36),Gr=Gr.toString().replace(/\s+/g,"");var Rn=0;Gr[0]==="-"&&(Rn++,this.negative=1),Rn=0;Rn-=3)On=Gr[Rn]|Gr[Rn-1]<<8|Gr[Rn-2]<<16,this.words[Pn]|=On<>>26-Zn&67108863,Zn+=24,Zn>=26&&(Zn-=26,Pn++);else if(Sn==="le")for(Rn=0,Pn=0;Rn>>26-Zn&67108863,Zn+=24,Zn>=26&&(Zn-=26,Pn++);return this._strip()};function Wr(Tn,Gr){var Xr=Tn.charCodeAt(Gr);if(Xr>=48&&Xr<=57)return Xr-48;if(Xr>=65&&Xr<=70)return Xr-55;if(Xr>=97&&Xr<=102)return Xr-87;Er(!1,"Invalid character in "+Tn)}function qr(Tn,Gr,Xr){var Sn=Wr(Tn,Xr);return Xr-1>=Gr&&(Sn|=Wr(Tn,Xr-1)<<4),Sn}jr.prototype._parseHex=function(Gr,Xr,Sn){this.length=Math.ceil((Gr.length-Xr)/6),this.words=new Array(this.length);for(var Rn=0;Rn=Xr;Rn-=2)Zn=qr(Gr,Xr,Rn)<=18?(Pn-=18,On+=1,this.words[On]|=Zn>>>26):Pn+=8;else{var Nn=Gr.length-Xr;for(Rn=Nn%2===0?Xr+1:Xr;Rn=18?(Pn-=18,On+=1,this.words[On]|=Zn>>>26):Pn+=8}this._strip()};function Hr(Tn,Gr,Xr,Sn){for(var Rn=0,Pn=0,On=Math.min(Tn.length,Xr),Zn=Gr;Zn=49?Pn=Nn-49+10:Nn>=17?Pn=Nn-17+10:Pn=Nn,Er(Nn>=0&&Pn1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},jr.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{jr.prototype[Symbol.for("nodejs.util.inspect.custom")]=Zr}catch{jr.prototype.inspect=Zr}else jr.prototype.inspect=Zr;function Zr(){return(this.red?""}var Jr=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],Qr=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],_n=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];jr.prototype.toString=function(Gr,Xr){Gr=Gr||10,Xr=Xr|0||1;var Sn;if(Gr===16||Gr==="hex"){Sn="";for(var Rn=0,Pn=0,On=0;On>>24-Rn&16777215,Rn+=2,Rn>=26&&(Rn-=26,On--),Pn!==0||On!==this.length-1?Sn=Jr[6-Nn.length]+Nn+Sn:Sn=Nn+Sn}for(Pn!==0&&(Sn=Pn.toString(16)+Sn);Sn.length%Xr!==0;)Sn="0"+Sn;return this.negative!==0&&(Sn="-"+Sn),Sn}if(Gr===(Gr|0)&&Gr>=2&&Gr<=36){var wn=Qr[Gr],zn=_n[Gr];Sn="";var fo=this.clone();for(fo.negative=0;!fo.isZero();){var vo=fo.modrn(zn).toString(Gr);fo=fo.idivn(zn),fo.isZero()?Sn=vo+Sn:Sn=Jr[wn-vo.length]+vo+Sn}for(this.isZero()&&(Sn="0"+Sn);Sn.length%Xr!==0;)Sn="0"+Sn;return this.negative!==0&&(Sn="-"+Sn),Sn}Er(!1,"Base should be between 2 and 36")},jr.prototype.toNumber=function(){var Gr=this.words[0];return this.length===2?Gr+=this.words[1]*67108864:this.length===3&&this.words[2]===1?Gr+=4503599627370496+this.words[1]*67108864:this.length>2&&Er(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-Gr:Gr},jr.prototype.toJSON=function(){return this.toString(16,2)},Br&&(jr.prototype.toBuffer=function(Gr,Xr){return this.toArrayLike(Br,Gr,Xr)}),jr.prototype.toArray=function(Gr,Xr){return this.toArrayLike(Array,Gr,Xr)};var En=function(Gr,Xr){return Gr.allocUnsafe?Gr.allocUnsafe(Xr):new Gr(Xr)};jr.prototype.toArrayLike=function(Gr,Xr,Sn){this._strip();var Rn=this.byteLength(),Pn=Sn||Math.max(1,Rn);Er(Rn<=Pn,"byte array longer than desired length"),Er(Pn>0,"Requested array length <= 0");var On=En(Gr,Pn),Zn=Xr==="le"?"LE":"BE";return this["_toArrayLike"+Zn](On,Rn),On},jr.prototype._toArrayLikeLE=function(Gr,Xr){for(var Sn=0,Rn=0,Pn=0,On=0;Pn>8&255),Sn>16&255),On===6?(Sn>24&255),Rn=0,On=0):(Rn=Zn>>>24,On+=2)}if(Sn=0&&(Gr[Sn--]=Zn>>8&255),Sn>=0&&(Gr[Sn--]=Zn>>16&255),On===6?(Sn>=0&&(Gr[Sn--]=Zn>>24&255),Rn=0,On=0):(Rn=Zn>>>24,On+=2)}if(Sn>=0)for(Gr[Sn--]=Rn;Sn>=0;)Gr[Sn--]=0},Math.clz32?jr.prototype._countBits=function(Gr){return 32-Math.clz32(Gr)}:jr.prototype._countBits=function(Gr){var Xr=Gr,Sn=0;return Xr>=4096&&(Sn+=13,Xr>>>=13),Xr>=64&&(Sn+=7,Xr>>>=7),Xr>=8&&(Sn+=4,Xr>>>=4),Xr>=2&&(Sn+=2,Xr>>>=2),Sn+Xr},jr.prototype._zeroBits=function(Gr){if(Gr===0)return 26;var Xr=Gr,Sn=0;return Xr&8191||(Sn+=13,Xr>>>=13),Xr&127||(Sn+=7,Xr>>>=7),Xr&15||(Sn+=4,Xr>>>=4),Xr&3||(Sn+=2,Xr>>>=2),Xr&1||Sn++,Sn},jr.prototype.bitLength=function(){var Gr=this.words[this.length-1],Xr=this._countBits(Gr);return(this.length-1)*26+Xr};function Cn(Tn){for(var Gr=new Array(Tn.bitLength()),Xr=0;Xr>>Rn&1}return Gr}jr.prototype.zeroBits=function(){if(this.isZero())return 0;for(var Gr=0,Xr=0;XrGr.length?this.clone().ior(Gr):Gr.clone().ior(this)},jr.prototype.uor=function(Gr){return this.length>Gr.length?this.clone().iuor(Gr):Gr.clone().iuor(this)},jr.prototype.iuand=function(Gr){var Xr;this.length>Gr.length?Xr=Gr:Xr=this;for(var Sn=0;SnGr.length?this.clone().iand(Gr):Gr.clone().iand(this)},jr.prototype.uand=function(Gr){return this.length>Gr.length?this.clone().iuand(Gr):Gr.clone().iuand(this)},jr.prototype.iuxor=function(Gr){var Xr,Sn;this.length>Gr.length?(Xr=this,Sn=Gr):(Xr=Gr,Sn=this);for(var Rn=0;RnGr.length?this.clone().ixor(Gr):Gr.clone().ixor(this)},jr.prototype.uxor=function(Gr){return this.length>Gr.length?this.clone().iuxor(Gr):Gr.clone().iuxor(this)},jr.prototype.inotn=function(Gr){Er(typeof Gr=="number"&&Gr>=0);var Xr=Math.ceil(Gr/26)|0,Sn=Gr%26;this._expand(Xr),Sn>0&&Xr--;for(var Rn=0;Rn0&&(this.words[Rn]=~this.words[Rn]&67108863>>26-Sn),this._strip()},jr.prototype.notn=function(Gr){return this.clone().inotn(Gr)},jr.prototype.setn=function(Gr,Xr){Er(typeof Gr=="number"&&Gr>=0);var Sn=Gr/26|0,Rn=Gr%26;return this._expand(Sn+1),Xr?this.words[Sn]=this.words[Sn]|1<Gr.length?(Sn=this,Rn=Gr):(Sn=Gr,Rn=this);for(var Pn=0,On=0;On>>26;for(;Pn!==0&&On>>26;if(this.length=Sn.length,Pn!==0)this.words[this.length]=Pn,this.length++;else if(Sn!==this)for(;OnGr.length?this.clone().iadd(Gr):Gr.clone().iadd(this)},jr.prototype.isub=function(Gr){if(Gr.negative!==0){Gr.negative=0;var Xr=this.iadd(Gr);return Gr.negative=1,Xr._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(Gr),this.negative=1,this._normSign();var Sn=this.cmp(Gr);if(Sn===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Rn,Pn;Sn>0?(Rn=this,Pn=Gr):(Rn=Gr,Pn=this);for(var On=0,Zn=0;Zn>26,this.words[Zn]=Xr&67108863;for(;On!==0&&Zn>26,this.words[Zn]=Xr&67108863;if(On===0&&Zn>>26,fo=Nn&67108863,vo=Math.min(wn,Gr.length-1),go=Math.max(0,wn-Tn.length+1);go<=vo;go++){var uo=wn-go|0;Rn=Tn.words[uo]|0,Pn=Gr.words[go]|0,On=Rn*Pn+fo,zn+=On/67108864|0,fo=On&67108863}Xr.words[wn]=fo|0,Nn=zn|0}return Nn!==0?Xr.words[wn]=Nn|0:Xr.length--,Xr._strip()}var An=function(Gr,Xr,Sn){var Rn=Gr.words,Pn=Xr.words,On=Sn.words,Zn=0,Nn,wn,zn,fo=Rn[0]|0,vo=fo&8191,go=fo>>>13,uo=Rn[1]|0,lo=uo&8191,Eo=uo>>>13,mo=Rn[2]|0,yo=mo&8191,_o=mo>>>13,Bo=Rn[3]|0,Lo=Bo&8191,Wo=Bo>>>13,na=Rn[4]|0,qo=na&8191,ga=na>>>13,wl=Rn[5]|0,No=wl&8191,Fo=wl>>>13,Nl=Rn[6]|0,Vo=Nl&8191,Uo=Nl>>>13,Ol=Rn[7]|0,$a=Ol&8191,Jo=Ol>>>13,Zl=Rn[8]|0,Cl=Zl&8191,ko=Zl>>>13,wo=Rn[9]|0,bo=wo&8191,Io=wo>>>13,Ho=Pn[0]|0,Do=Ho&8191,zo=Ho>>>13,nu=Pn[1]|0,Ll=nu&8191,_l=nu>>>13,bu=Pn[2]|0,xl=bu&8191,Tl=bu>>>13,du=Pn[3]|0,Bl=du&8191,Il=du>>>13,Eu=Pn[4]|0,Al=Eu&8191,Ml=Eu>>>13,Tu=Pn[5]|0,Ul=Tu&8191,Sl=Tu>>>13,_u=Pn[6]|0,So=_u&8191,Co=_u>>>13,Ao=Pn[7]|0,po=Ao&8191,Ro=Ao>>>13,Xo=Pn[8]|0,jo=Xo&8191,Ko=Xo>>>13,Wl=Pn[9]|0,$l=Wl&8191,El=Wl>>>13;Sn.negative=Gr.negative^Xr.negative,Sn.length=19,Nn=Math.imul(vo,Do),wn=Math.imul(vo,zo),wn=wn+Math.imul(go,Do)|0,zn=Math.imul(go,zo);var Cu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Cu>>>26)|0,Cu&=67108863,Nn=Math.imul(lo,Do),wn=Math.imul(lo,zo),wn=wn+Math.imul(Eo,Do)|0,zn=Math.imul(Eo,zo),Nn=Nn+Math.imul(vo,Ll)|0,wn=wn+Math.imul(vo,_l)|0,wn=wn+Math.imul(go,Ll)|0,zn=zn+Math.imul(go,_l)|0;var iu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(iu>>>26)|0,iu&=67108863,Nn=Math.imul(yo,Do),wn=Math.imul(yo,zo),wn=wn+Math.imul(_o,Do)|0,zn=Math.imul(_o,zo),Nn=Nn+Math.imul(lo,Ll)|0,wn=wn+Math.imul(lo,_l)|0,wn=wn+Math.imul(Eo,Ll)|0,zn=zn+Math.imul(Eo,_l)|0,Nn=Nn+Math.imul(vo,xl)|0,wn=wn+Math.imul(vo,Tl)|0,wn=wn+Math.imul(go,xl)|0,zn=zn+Math.imul(go,Tl)|0;var pu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(pu>>>26)|0,pu&=67108863,Nn=Math.imul(Lo,Do),wn=Math.imul(Lo,zo),wn=wn+Math.imul(Wo,Do)|0,zn=Math.imul(Wo,zo),Nn=Nn+Math.imul(yo,Ll)|0,wn=wn+Math.imul(yo,_l)|0,wn=wn+Math.imul(_o,Ll)|0,zn=zn+Math.imul(_o,_l)|0,Nn=Nn+Math.imul(lo,xl)|0,wn=wn+Math.imul(lo,Tl)|0,wn=wn+Math.imul(Eo,xl)|0,zn=zn+Math.imul(Eo,Tl)|0,Nn=Nn+Math.imul(vo,Bl)|0,wn=wn+Math.imul(vo,Il)|0,wn=wn+Math.imul(go,Bl)|0,zn=zn+Math.imul(go,Il)|0;var yu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(yu>>>26)|0,yu&=67108863,Nn=Math.imul(qo,Do),wn=Math.imul(qo,zo),wn=wn+Math.imul(ga,Do)|0,zn=Math.imul(ga,zo),Nn=Nn+Math.imul(Lo,Ll)|0,wn=wn+Math.imul(Lo,_l)|0,wn=wn+Math.imul(Wo,Ll)|0,zn=zn+Math.imul(Wo,_l)|0,Nn=Nn+Math.imul(yo,xl)|0,wn=wn+Math.imul(yo,Tl)|0,wn=wn+Math.imul(_o,xl)|0,zn=zn+Math.imul(_o,Tl)|0,Nn=Nn+Math.imul(lo,Bl)|0,wn=wn+Math.imul(lo,Il)|0,wn=wn+Math.imul(Eo,Bl)|0,zn=zn+Math.imul(Eo,Il)|0,Nn=Nn+Math.imul(vo,Al)|0,wn=wn+Math.imul(vo,Ml)|0,wn=wn+Math.imul(go,Al)|0,zn=zn+Math.imul(go,Ml)|0;var hu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(hu>>>26)|0,hu&=67108863,Nn=Math.imul(No,Do),wn=Math.imul(No,zo),wn=wn+Math.imul(Fo,Do)|0,zn=Math.imul(Fo,zo),Nn=Nn+Math.imul(qo,Ll)|0,wn=wn+Math.imul(qo,_l)|0,wn=wn+Math.imul(ga,Ll)|0,zn=zn+Math.imul(ga,_l)|0,Nn=Nn+Math.imul(Lo,xl)|0,wn=wn+Math.imul(Lo,Tl)|0,wn=wn+Math.imul(Wo,xl)|0,zn=zn+Math.imul(Wo,Tl)|0,Nn=Nn+Math.imul(yo,Bl)|0,wn=wn+Math.imul(yo,Il)|0,wn=wn+Math.imul(_o,Bl)|0,zn=zn+Math.imul(_o,Il)|0,Nn=Nn+Math.imul(lo,Al)|0,wn=wn+Math.imul(lo,Ml)|0,wn=wn+Math.imul(Eo,Al)|0,zn=zn+Math.imul(Eo,Ml)|0,Nn=Nn+Math.imul(vo,Ul)|0,wn=wn+Math.imul(vo,Sl)|0,wn=wn+Math.imul(go,Ul)|0,zn=zn+Math.imul(go,Sl)|0;var mu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(mu>>>26)|0,mu&=67108863,Nn=Math.imul(Vo,Do),wn=Math.imul(Vo,zo),wn=wn+Math.imul(Uo,Do)|0,zn=Math.imul(Uo,zo),Nn=Nn+Math.imul(No,Ll)|0,wn=wn+Math.imul(No,_l)|0,wn=wn+Math.imul(Fo,Ll)|0,zn=zn+Math.imul(Fo,_l)|0,Nn=Nn+Math.imul(qo,xl)|0,wn=wn+Math.imul(qo,Tl)|0,wn=wn+Math.imul(ga,xl)|0,zn=zn+Math.imul(ga,Tl)|0,Nn=Nn+Math.imul(Lo,Bl)|0,wn=wn+Math.imul(Lo,Il)|0,wn=wn+Math.imul(Wo,Bl)|0,zn=zn+Math.imul(Wo,Il)|0,Nn=Nn+Math.imul(yo,Al)|0,wn=wn+Math.imul(yo,Ml)|0,wn=wn+Math.imul(_o,Al)|0,zn=zn+Math.imul(_o,Ml)|0,Nn=Nn+Math.imul(lo,Ul)|0,wn=wn+Math.imul(lo,Sl)|0,wn=wn+Math.imul(Eo,Ul)|0,zn=zn+Math.imul(Eo,Sl)|0,Nn=Nn+Math.imul(vo,So)|0,wn=wn+Math.imul(vo,Co)|0,wn=wn+Math.imul(go,So)|0,zn=zn+Math.imul(go,Co)|0;var vu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(vu>>>26)|0,vu&=67108863,Nn=Math.imul($a,Do),wn=Math.imul($a,zo),wn=wn+Math.imul(Jo,Do)|0,zn=Math.imul(Jo,zo),Nn=Nn+Math.imul(Vo,Ll)|0,wn=wn+Math.imul(Vo,_l)|0,wn=wn+Math.imul(Uo,Ll)|0,zn=zn+Math.imul(Uo,_l)|0,Nn=Nn+Math.imul(No,xl)|0,wn=wn+Math.imul(No,Tl)|0,wn=wn+Math.imul(Fo,xl)|0,zn=zn+Math.imul(Fo,Tl)|0,Nn=Nn+Math.imul(qo,Bl)|0,wn=wn+Math.imul(qo,Il)|0,wn=wn+Math.imul(ga,Bl)|0,zn=zn+Math.imul(ga,Il)|0,Nn=Nn+Math.imul(Lo,Al)|0,wn=wn+Math.imul(Lo,Ml)|0,wn=wn+Math.imul(Wo,Al)|0,zn=zn+Math.imul(Wo,Ml)|0,Nn=Nn+Math.imul(yo,Ul)|0,wn=wn+Math.imul(yo,Sl)|0,wn=wn+Math.imul(_o,Ul)|0,zn=zn+Math.imul(_o,Sl)|0,Nn=Nn+Math.imul(lo,So)|0,wn=wn+Math.imul(lo,Co)|0,wn=wn+Math.imul(Eo,So)|0,zn=zn+Math.imul(Eo,Co)|0,Nn=Nn+Math.imul(vo,po)|0,wn=wn+Math.imul(vo,Ro)|0,wn=wn+Math.imul(go,po)|0,zn=zn+Math.imul(go,Ro)|0;var fu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(fu>>>26)|0,fu&=67108863,Nn=Math.imul(Cl,Do),wn=Math.imul(Cl,zo),wn=wn+Math.imul(ko,Do)|0,zn=Math.imul(ko,zo),Nn=Nn+Math.imul($a,Ll)|0,wn=wn+Math.imul($a,_l)|0,wn=wn+Math.imul(Jo,Ll)|0,zn=zn+Math.imul(Jo,_l)|0,Nn=Nn+Math.imul(Vo,xl)|0,wn=wn+Math.imul(Vo,Tl)|0,wn=wn+Math.imul(Uo,xl)|0,zn=zn+Math.imul(Uo,Tl)|0,Nn=Nn+Math.imul(No,Bl)|0,wn=wn+Math.imul(No,Il)|0,wn=wn+Math.imul(Fo,Bl)|0,zn=zn+Math.imul(Fo,Il)|0,Nn=Nn+Math.imul(qo,Al)|0,wn=wn+Math.imul(qo,Ml)|0,wn=wn+Math.imul(ga,Al)|0,zn=zn+Math.imul(ga,Ml)|0,Nn=Nn+Math.imul(Lo,Ul)|0,wn=wn+Math.imul(Lo,Sl)|0,wn=wn+Math.imul(Wo,Ul)|0,zn=zn+Math.imul(Wo,Sl)|0,Nn=Nn+Math.imul(yo,So)|0,wn=wn+Math.imul(yo,Co)|0,wn=wn+Math.imul(_o,So)|0,zn=zn+Math.imul(_o,Co)|0,Nn=Nn+Math.imul(lo,po)|0,wn=wn+Math.imul(lo,Ro)|0,wn=wn+Math.imul(Eo,po)|0,zn=zn+Math.imul(Eo,Ro)|0,Nn=Nn+Math.imul(vo,jo)|0,wn=wn+Math.imul(vo,Ko)|0,wn=wn+Math.imul(go,jo)|0,zn=zn+Math.imul(go,Ko)|0;var gu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(gu>>>26)|0,gu&=67108863,Nn=Math.imul(bo,Do),wn=Math.imul(bo,zo),wn=wn+Math.imul(Io,Do)|0,zn=Math.imul(Io,zo),Nn=Nn+Math.imul(Cl,Ll)|0,wn=wn+Math.imul(Cl,_l)|0,wn=wn+Math.imul(ko,Ll)|0,zn=zn+Math.imul(ko,_l)|0,Nn=Nn+Math.imul($a,xl)|0,wn=wn+Math.imul($a,Tl)|0,wn=wn+Math.imul(Jo,xl)|0,zn=zn+Math.imul(Jo,Tl)|0,Nn=Nn+Math.imul(Vo,Bl)|0,wn=wn+Math.imul(Vo,Il)|0,wn=wn+Math.imul(Uo,Bl)|0,zn=zn+Math.imul(Uo,Il)|0,Nn=Nn+Math.imul(No,Al)|0,wn=wn+Math.imul(No,Ml)|0,wn=wn+Math.imul(Fo,Al)|0,zn=zn+Math.imul(Fo,Ml)|0,Nn=Nn+Math.imul(qo,Ul)|0,wn=wn+Math.imul(qo,Sl)|0,wn=wn+Math.imul(ga,Ul)|0,zn=zn+Math.imul(ga,Sl)|0,Nn=Nn+Math.imul(Lo,So)|0,wn=wn+Math.imul(Lo,Co)|0,wn=wn+Math.imul(Wo,So)|0,zn=zn+Math.imul(Wo,Co)|0,Nn=Nn+Math.imul(yo,po)|0,wn=wn+Math.imul(yo,Ro)|0,wn=wn+Math.imul(_o,po)|0,zn=zn+Math.imul(_o,Ro)|0,Nn=Nn+Math.imul(lo,jo)|0,wn=wn+Math.imul(lo,Ko)|0,wn=wn+Math.imul(Eo,jo)|0,zn=zn+Math.imul(Eo,Ko)|0,Nn=Nn+Math.imul(vo,$l)|0,wn=wn+Math.imul(vo,El)|0,wn=wn+Math.imul(go,$l)|0,zn=zn+Math.imul(go,El)|0;var ou=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(ou>>>26)|0,ou&=67108863,Nn=Math.imul(bo,Ll),wn=Math.imul(bo,_l),wn=wn+Math.imul(Io,Ll)|0,zn=Math.imul(Io,_l),Nn=Nn+Math.imul(Cl,xl)|0,wn=wn+Math.imul(Cl,Tl)|0,wn=wn+Math.imul(ko,xl)|0,zn=zn+Math.imul(ko,Tl)|0,Nn=Nn+Math.imul($a,Bl)|0,wn=wn+Math.imul($a,Il)|0,wn=wn+Math.imul(Jo,Bl)|0,zn=zn+Math.imul(Jo,Il)|0,Nn=Nn+Math.imul(Vo,Al)|0,wn=wn+Math.imul(Vo,Ml)|0,wn=wn+Math.imul(Uo,Al)|0,zn=zn+Math.imul(Uo,Ml)|0,Nn=Nn+Math.imul(No,Ul)|0,wn=wn+Math.imul(No,Sl)|0,wn=wn+Math.imul(Fo,Ul)|0,zn=zn+Math.imul(Fo,Sl)|0,Nn=Nn+Math.imul(qo,So)|0,wn=wn+Math.imul(qo,Co)|0,wn=wn+Math.imul(ga,So)|0,zn=zn+Math.imul(ga,Co)|0,Nn=Nn+Math.imul(Lo,po)|0,wn=wn+Math.imul(Lo,Ro)|0,wn=wn+Math.imul(Wo,po)|0,zn=zn+Math.imul(Wo,Ro)|0,Nn=Nn+Math.imul(yo,jo)|0,wn=wn+Math.imul(yo,Ko)|0,wn=wn+Math.imul(_o,jo)|0,zn=zn+Math.imul(_o,Ko)|0,Nn=Nn+Math.imul(lo,$l)|0,wn=wn+Math.imul(lo,El)|0,wn=wn+Math.imul(Eo,$l)|0,zn=zn+Math.imul(Eo,El)|0;var su=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(su>>>26)|0,su&=67108863,Nn=Math.imul(bo,xl),wn=Math.imul(bo,Tl),wn=wn+Math.imul(Io,xl)|0,zn=Math.imul(Io,Tl),Nn=Nn+Math.imul(Cl,Bl)|0,wn=wn+Math.imul(Cl,Il)|0,wn=wn+Math.imul(ko,Bl)|0,zn=zn+Math.imul(ko,Il)|0,Nn=Nn+Math.imul($a,Al)|0,wn=wn+Math.imul($a,Ml)|0,wn=wn+Math.imul(Jo,Al)|0,zn=zn+Math.imul(Jo,Ml)|0,Nn=Nn+Math.imul(Vo,Ul)|0,wn=wn+Math.imul(Vo,Sl)|0,wn=wn+Math.imul(Uo,Ul)|0,zn=zn+Math.imul(Uo,Sl)|0,Nn=Nn+Math.imul(No,So)|0,wn=wn+Math.imul(No,Co)|0,wn=wn+Math.imul(Fo,So)|0,zn=zn+Math.imul(Fo,Co)|0,Nn=Nn+Math.imul(qo,po)|0,wn=wn+Math.imul(qo,Ro)|0,wn=wn+Math.imul(ga,po)|0,zn=zn+Math.imul(ga,Ro)|0,Nn=Nn+Math.imul(Lo,jo)|0,wn=wn+Math.imul(Lo,Ko)|0,wn=wn+Math.imul(Wo,jo)|0,zn=zn+Math.imul(Wo,Ko)|0,Nn=Nn+Math.imul(yo,$l)|0,wn=wn+Math.imul(yo,El)|0,wn=wn+Math.imul(_o,$l)|0,zn=zn+Math.imul(_o,El)|0;var tu=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(tu>>>26)|0,tu&=67108863,Nn=Math.imul(bo,Bl),wn=Math.imul(bo,Il),wn=wn+Math.imul(Io,Bl)|0,zn=Math.imul(Io,Il),Nn=Nn+Math.imul(Cl,Al)|0,wn=wn+Math.imul(Cl,Ml)|0,wn=wn+Math.imul(ko,Al)|0,zn=zn+Math.imul(ko,Ml)|0,Nn=Nn+Math.imul($a,Ul)|0,wn=wn+Math.imul($a,Sl)|0,wn=wn+Math.imul(Jo,Ul)|0,zn=zn+Math.imul(Jo,Sl)|0,Nn=Nn+Math.imul(Vo,So)|0,wn=wn+Math.imul(Vo,Co)|0,wn=wn+Math.imul(Uo,So)|0,zn=zn+Math.imul(Uo,Co)|0,Nn=Nn+Math.imul(No,po)|0,wn=wn+Math.imul(No,Ro)|0,wn=wn+Math.imul(Fo,po)|0,zn=zn+Math.imul(Fo,Ro)|0,Nn=Nn+Math.imul(qo,jo)|0,wn=wn+Math.imul(qo,Ko)|0,wn=wn+Math.imul(ga,jo)|0,zn=zn+Math.imul(ga,Ko)|0,Nn=Nn+Math.imul(Lo,$l)|0,wn=wn+Math.imul(Lo,El)|0,wn=wn+Math.imul(Wo,$l)|0,zn=zn+Math.imul(Wo,El)|0;var zl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(zl>>>26)|0,zl&=67108863,Nn=Math.imul(bo,Al),wn=Math.imul(bo,Ml),wn=wn+Math.imul(Io,Al)|0,zn=Math.imul(Io,Ml),Nn=Nn+Math.imul(Cl,Ul)|0,wn=wn+Math.imul(Cl,Sl)|0,wn=wn+Math.imul(ko,Ul)|0,zn=zn+Math.imul(ko,Sl)|0,Nn=Nn+Math.imul($a,So)|0,wn=wn+Math.imul($a,Co)|0,wn=wn+Math.imul(Jo,So)|0,zn=zn+Math.imul(Jo,Co)|0,Nn=Nn+Math.imul(Vo,po)|0,wn=wn+Math.imul(Vo,Ro)|0,wn=wn+Math.imul(Uo,po)|0,zn=zn+Math.imul(Uo,Ro)|0,Nn=Nn+Math.imul(No,jo)|0,wn=wn+Math.imul(No,Ko)|0,wn=wn+Math.imul(Fo,jo)|0,zn=zn+Math.imul(Fo,Ko)|0,Nn=Nn+Math.imul(qo,$l)|0,wn=wn+Math.imul(qo,El)|0,wn=wn+Math.imul(ga,$l)|0,zn=zn+Math.imul(ga,El)|0;var Gl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Gl>>>26)|0,Gl&=67108863,Nn=Math.imul(bo,Ul),wn=Math.imul(bo,Sl),wn=wn+Math.imul(Io,Ul)|0,zn=Math.imul(Io,Sl),Nn=Nn+Math.imul(Cl,So)|0,wn=wn+Math.imul(Cl,Co)|0,wn=wn+Math.imul(ko,So)|0,zn=zn+Math.imul(ko,Co)|0,Nn=Nn+Math.imul($a,po)|0,wn=wn+Math.imul($a,Ro)|0,wn=wn+Math.imul(Jo,po)|0,zn=zn+Math.imul(Jo,Ro)|0,Nn=Nn+Math.imul(Vo,jo)|0,wn=wn+Math.imul(Vo,Ko)|0,wn=wn+Math.imul(Uo,jo)|0,zn=zn+Math.imul(Uo,Ko)|0,Nn=Nn+Math.imul(No,$l)|0,wn=wn+Math.imul(No,El)|0,wn=wn+Math.imul(Fo,$l)|0,zn=zn+Math.imul(Fo,El)|0;var Jl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Jl>>>26)|0,Jl&=67108863,Nn=Math.imul(bo,So),wn=Math.imul(bo,Co),wn=wn+Math.imul(Io,So)|0,zn=Math.imul(Io,Co),Nn=Nn+Math.imul(Cl,po)|0,wn=wn+Math.imul(Cl,Ro)|0,wn=wn+Math.imul(ko,po)|0,zn=zn+Math.imul(ko,Ro)|0,Nn=Nn+Math.imul($a,jo)|0,wn=wn+Math.imul($a,Ko)|0,wn=wn+Math.imul(Jo,jo)|0,zn=zn+Math.imul(Jo,Ko)|0,Nn=Nn+Math.imul(Vo,$l)|0,wn=wn+Math.imul(Vo,El)|0,wn=wn+Math.imul(Uo,$l)|0,zn=zn+Math.imul(Uo,El)|0;var Pl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Pl>>>26)|0,Pl&=67108863,Nn=Math.imul(bo,po),wn=Math.imul(bo,Ro),wn=wn+Math.imul(Io,po)|0,zn=Math.imul(Io,Ro),Nn=Nn+Math.imul(Cl,jo)|0,wn=wn+Math.imul(Cl,Ko)|0,wn=wn+Math.imul(ko,jo)|0,zn=zn+Math.imul(ko,Ko)|0,Nn=Nn+Math.imul($a,$l)|0,wn=wn+Math.imul($a,El)|0,wn=wn+Math.imul(Jo,$l)|0,zn=zn+Math.imul(Jo,El)|0;var Fl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Fl>>>26)|0,Fl&=67108863,Nn=Math.imul(bo,jo),wn=Math.imul(bo,Ko),wn=wn+Math.imul(Io,jo)|0,zn=Math.imul(Io,Ko),Nn=Nn+Math.imul(Cl,$l)|0,wn=wn+Math.imul(Cl,El)|0,wn=wn+Math.imul(ko,$l)|0,zn=zn+Math.imul(ko,El)|0;var Yl=(Zn+Nn|0)+((wn&8191)<<13)|0;Zn=(zn+(wn>>>13)|0)+(Yl>>>26)|0,Yl&=67108863,Nn=Math.imul(bo,$l),wn=Math.imul(bo,El),wn=wn+Math.imul(Io,$l)|0,zn=Math.imul(Io,El);var Vl=(Zn+Nn|0)+((wn&8191)<<13)|0;return Zn=(zn+(wn>>>13)|0)+(Vl>>>26)|0,Vl&=67108863,On[0]=Cu,On[1]=iu,On[2]=pu,On[3]=yu,On[4]=hu,On[5]=mu,On[6]=vu,On[7]=fu,On[8]=gu,On[9]=ou,On[10]=su,On[11]=tu,On[12]=zl,On[13]=Gl,On[14]=Jl,On[15]=Pl,On[16]=Fl,On[17]=Yl,On[18]=Vl,Zn!==0&&(On[19]=Zn,Sn.length++),Sn};Math.imul||(An=In);function jn(Tn,Gr,Xr){Xr.negative=Gr.negative^Tn.negative,Xr.length=Tn.length+Gr.length;for(var Sn=0,Rn=0,Pn=0;Pn>>26)|0,Rn+=On>>>26,On&=67108863}Xr.words[Pn]=Zn,Sn=On,On=Rn}return Sn!==0?Xr.words[Pn]=Sn:Xr.length--,Xr._strip()}function eo(Tn,Gr,Xr){return jn(Tn,Gr,Xr)}jr.prototype.mulTo=function(Gr,Xr){var Sn,Rn=this.length+Gr.length;return this.length===10&&Gr.length===10?Sn=An(this,Gr,Xr):Rn<63?Sn=In(this,Gr,Xr):Rn<1024?Sn=jn(this,Gr,Xr):Sn=eo(this,Gr,Xr),Sn},jr.prototype.mul=function(Gr){var Xr=new jr(null);return Xr.words=new Array(this.length+Gr.length),this.mulTo(Gr,Xr)},jr.prototype.mulf=function(Gr){var Xr=new jr(null);return Xr.words=new Array(this.length+Gr.length),eo(this,Gr,Xr)},jr.prototype.imul=function(Gr){return this.clone().mulTo(Gr,this)},jr.prototype.imuln=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(typeof Gr=="number"),Er(Gr<67108864);for(var Sn=0,Rn=0;Rn>=26,Sn+=Pn/67108864|0,Sn+=On>>>26,this.words[Rn]=On&67108863}return Sn!==0&&(this.words[Rn]=Sn,this.length++),Xr?this.ineg():this},jr.prototype.muln=function(Gr){return this.clone().imuln(Gr)},jr.prototype.sqr=function(){return this.mul(this)},jr.prototype.isqr=function(){return this.imul(this.clone())},jr.prototype.pow=function(Gr){var Xr=Cn(Gr);if(Xr.length===0)return new jr(1);for(var Sn=this,Rn=0;Rn=0);var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=67108863>>>26-Xr<<26-Xr,Pn;if(Xr!==0){var On=0;for(Pn=0;Pn>>26-Xr}On&&(this.words[Pn]=On,this.length++)}if(Sn!==0){for(Pn=this.length-1;Pn>=0;Pn--)this.words[Pn+Sn]=this.words[Pn];for(Pn=0;Pn=0);var Rn;Xr?Rn=(Xr-Xr%26)/26:Rn=0;var Pn=Gr%26,On=Math.min((Gr-Pn)/26,this.length),Zn=67108863^67108863>>>Pn<On)for(this.length-=On,wn=0;wn=0&&(zn!==0||wn>=Rn);wn--){var fo=this.words[wn]|0;this.words[wn]=zn<<26-Pn|fo>>>Pn,zn=fo&Zn}return Nn&&zn!==0&&(Nn.words[Nn.length++]=zn),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},jr.prototype.ishrn=function(Gr,Xr,Sn){return Er(this.negative===0),this.iushrn(Gr,Xr,Sn)},jr.prototype.shln=function(Gr){return this.clone().ishln(Gr)},jr.prototype.ushln=function(Gr){return this.clone().iushln(Gr)},jr.prototype.shrn=function(Gr){return this.clone().ishrn(Gr)},jr.prototype.ushrn=function(Gr){return this.clone().iushrn(Gr)},jr.prototype.testn=function(Gr){Er(typeof Gr=="number"&&Gr>=0);var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=1<=0);var Xr=Gr%26,Sn=(Gr-Xr)/26;if(Er(this.negative===0,"imaskn works only with positive numbers"),this.length<=Sn)return this;if(Xr!==0&&Sn++,this.length=Math.min(Sn,this.length),Xr!==0){var Rn=67108863^67108863>>>Xr<=67108864;Xr++)this.words[Xr]-=67108864,Xr===this.length-1?this.words[Xr+1]=1:this.words[Xr+1]++;return this.length=Math.max(this.length,Xr+1),this},jr.prototype.isubn=function(Gr){if(Er(typeof Gr=="number"),Er(Gr<67108864),Gr<0)return this.iaddn(-Gr);if(this.negative!==0)return this.negative=0,this.iaddn(Gr),this.negative=1,this;if(this.words[0]-=Gr,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var Xr=0;Xr>26)-(Nn/67108864|0),this.words[Pn+Sn]=On&67108863}for(;Pn>26,this.words[Pn+Sn]=On&67108863;if(Zn===0)return this._strip();for(Er(Zn===-1),Zn=0,Pn=0;Pn>26,this.words[Pn]=On&67108863;return this.negative=1,this._strip()},jr.prototype._wordDiv=function(Gr,Xr){var Sn=this.length-Gr.length,Rn=this.clone(),Pn=Gr,On=Pn.words[Pn.length-1]|0,Zn=this._countBits(On);Sn=26-Zn,Sn!==0&&(Pn=Pn.ushln(Sn),Rn.iushln(Sn),On=Pn.words[Pn.length-1]|0);var Nn=Rn.length-Pn.length,wn;if(Xr!=="mod"){wn=new jr(null),wn.length=Nn+1,wn.words=new Array(wn.length);for(var zn=0;zn=0;vo--){var go=(Rn.words[Pn.length+vo]|0)*67108864+(Rn.words[Pn.length+vo-1]|0);for(go=Math.min(go/On|0,67108863),Rn._ishlnsubmul(Pn,go,vo);Rn.negative!==0;)go--,Rn.negative=0,Rn._ishlnsubmul(Pn,1,vo),Rn.isZero()||(Rn.negative^=1);wn&&(wn.words[vo]=go)}return wn&&wn._strip(),Rn._strip(),Xr!=="div"&&Sn!==0&&Rn.iushrn(Sn),{div:wn||null,mod:Rn}},jr.prototype.divmod=function(Gr,Xr,Sn){if(Er(!Gr.isZero()),this.isZero())return{div:new jr(0),mod:new jr(0)};var Rn,Pn,On;return this.negative!==0&&Gr.negative===0?(On=this.neg().divmod(Gr,Xr),Xr!=="mod"&&(Rn=On.div.neg()),Xr!=="div"&&(Pn=On.mod.neg(),Sn&&Pn.negative!==0&&Pn.iadd(Gr)),{div:Rn,mod:Pn}):this.negative===0&&Gr.negative!==0?(On=this.divmod(Gr.neg(),Xr),Xr!=="mod"&&(Rn=On.div.neg()),{div:Rn,mod:On.mod}):this.negative&Gr.negative?(On=this.neg().divmod(Gr.neg(),Xr),Xr!=="div"&&(Pn=On.mod.neg(),Sn&&Pn.negative!==0&&Pn.isub(Gr)),{div:On.div,mod:Pn}):Gr.length>this.length||this.cmp(Gr)<0?{div:new jr(0),mod:this}:Gr.length===1?Xr==="div"?{div:this.divn(Gr.words[0]),mod:null}:Xr==="mod"?{div:null,mod:new jr(this.modrn(Gr.words[0]))}:{div:this.divn(Gr.words[0]),mod:new jr(this.modrn(Gr.words[0]))}:this._wordDiv(Gr,Xr)},jr.prototype.div=function(Gr){return this.divmod(Gr,"div",!1).div},jr.prototype.mod=function(Gr){return this.divmod(Gr,"mod",!1).mod},jr.prototype.umod=function(Gr){return this.divmod(Gr,"mod",!0).mod},jr.prototype.divRound=function(Gr){var Xr=this.divmod(Gr);if(Xr.mod.isZero())return Xr.div;var Sn=Xr.div.negative!==0?Xr.mod.isub(Gr):Xr.mod,Rn=Gr.ushrn(1),Pn=Gr.andln(1),On=Sn.cmp(Rn);return On<0||Pn===1&&On===0?Xr.div:Xr.div.negative!==0?Xr.div.isubn(1):Xr.div.iaddn(1)},jr.prototype.modrn=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(Gr<=67108863);for(var Sn=(1<<26)%Gr,Rn=0,Pn=this.length-1;Pn>=0;Pn--)Rn=(Sn*Rn+(this.words[Pn]|0))%Gr;return Xr?-Rn:Rn},jr.prototype.modn=function(Gr){return this.modrn(Gr)},jr.prototype.idivn=function(Gr){var Xr=Gr<0;Xr&&(Gr=-Gr),Er(Gr<=67108863);for(var Sn=0,Rn=this.length-1;Rn>=0;Rn--){var Pn=(this.words[Rn]|0)+Sn*67108864;this.words[Rn]=Pn/Gr|0,Sn=Pn%Gr}return this._strip(),Xr?this.ineg():this},jr.prototype.divn=function(Gr){return this.clone().idivn(Gr)},jr.prototype.egcd=function(Gr){Er(Gr.negative===0),Er(!Gr.isZero());var Xr=this,Sn=Gr.clone();Xr.negative!==0?Xr=Xr.umod(Gr):Xr=Xr.clone();for(var Rn=new jr(1),Pn=new jr(0),On=new jr(0),Zn=new jr(1),Nn=0;Xr.isEven()&&Sn.isEven();)Xr.iushrn(1),Sn.iushrn(1),++Nn;for(var wn=Sn.clone(),zn=Xr.clone();!Xr.isZero();){for(var fo=0,vo=1;!(Xr.words[0]&vo)&&fo<26;++fo,vo<<=1);if(fo>0)for(Xr.iushrn(fo);fo-- >0;)(Rn.isOdd()||Pn.isOdd())&&(Rn.iadd(wn),Pn.isub(zn)),Rn.iushrn(1),Pn.iushrn(1);for(var go=0,uo=1;!(Sn.words[0]&uo)&&go<26;++go,uo<<=1);if(go>0)for(Sn.iushrn(go);go-- >0;)(On.isOdd()||Zn.isOdd())&&(On.iadd(wn),Zn.isub(zn)),On.iushrn(1),Zn.iushrn(1);Xr.cmp(Sn)>=0?(Xr.isub(Sn),Rn.isub(On),Pn.isub(Zn)):(Sn.isub(Xr),On.isub(Rn),Zn.isub(Pn))}return{a:On,b:Zn,gcd:Sn.iushln(Nn)}},jr.prototype._invmp=function(Gr){Er(Gr.negative===0),Er(!Gr.isZero());var Xr=this,Sn=Gr.clone();Xr.negative!==0?Xr=Xr.umod(Gr):Xr=Xr.clone();for(var Rn=new jr(1),Pn=new jr(0),On=Sn.clone();Xr.cmpn(1)>0&&Sn.cmpn(1)>0;){for(var Zn=0,Nn=1;!(Xr.words[0]&Nn)&&Zn<26;++Zn,Nn<<=1);if(Zn>0)for(Xr.iushrn(Zn);Zn-- >0;)Rn.isOdd()&&Rn.iadd(On),Rn.iushrn(1);for(var wn=0,zn=1;!(Sn.words[0]&zn)&&wn<26;++wn,zn<<=1);if(wn>0)for(Sn.iushrn(wn);wn-- >0;)Pn.isOdd()&&Pn.iadd(On),Pn.iushrn(1);Xr.cmp(Sn)>=0?(Xr.isub(Sn),Rn.isub(Pn)):(Sn.isub(Xr),Pn.isub(Rn))}var fo;return Xr.cmpn(1)===0?fo=Rn:fo=Pn,fo.cmpn(0)<0&&fo.iadd(Gr),fo},jr.prototype.gcd=function(Gr){if(this.isZero())return Gr.abs();if(Gr.isZero())return this.abs();var Xr=this.clone(),Sn=Gr.clone();Xr.negative=0,Sn.negative=0;for(var Rn=0;Xr.isEven()&&Sn.isEven();Rn++)Xr.iushrn(1),Sn.iushrn(1);do{for(;Xr.isEven();)Xr.iushrn(1);for(;Sn.isEven();)Sn.iushrn(1);var Pn=Xr.cmp(Sn);if(Pn<0){var On=Xr;Xr=Sn,Sn=On}else if(Pn===0||Sn.cmpn(1)===0)break;Xr.isub(Sn)}while(!0);return Sn.iushln(Rn)},jr.prototype.invm=function(Gr){return this.egcd(Gr).a.umod(Gr)},jr.prototype.isEven=function(){return(this.words[0]&1)===0},jr.prototype.isOdd=function(){return(this.words[0]&1)===1},jr.prototype.andln=function(Gr){return this.words[0]&Gr},jr.prototype.bincn=function(Gr){Er(typeof Gr=="number");var Xr=Gr%26,Sn=(Gr-Xr)/26,Rn=1<>>26,Zn&=67108863,this.words[On]=Zn}return Pn!==0&&(this.words[On]=Pn,this.length++),this},jr.prototype.isZero=function(){return this.length===1&&this.words[0]===0},jr.prototype.cmpn=function(Gr){var Xr=Gr<0;if(this.negative!==0&&!Xr)return-1;if(this.negative===0&&Xr)return 1;this._strip();var Sn;if(this.length>1)Sn=1;else{Xr&&(Gr=-Gr),Er(Gr<=67108863,"Number is too big");var Rn=this.words[0]|0;Sn=Rn===Gr?0:RnGr.length)return 1;if(this.length=0;Sn--){var Rn=this.words[Sn]|0,Pn=Gr.words[Sn]|0;if(Rn!==Pn){RnPn&&(Xr=1);break}}return Xr},jr.prototype.gtn=function(Gr){return this.cmpn(Gr)===1},jr.prototype.gt=function(Gr){return this.cmp(Gr)===1},jr.prototype.gten=function(Gr){return this.cmpn(Gr)>=0},jr.prototype.gte=function(Gr){return this.cmp(Gr)>=0},jr.prototype.ltn=function(Gr){return this.cmpn(Gr)===-1},jr.prototype.lt=function(Gr){return this.cmp(Gr)===-1},jr.prototype.lten=function(Gr){return this.cmpn(Gr)<=0},jr.prototype.lte=function(Gr){return this.cmp(Gr)<=0},jr.prototype.eqn=function(Gr){return this.cmpn(Gr)===0},jr.prototype.eq=function(Gr){return this.cmp(Gr)===0},jr.red=function(Gr){return new so(Gr)},jr.prototype.toRed=function(Gr){return Er(!this.red,"Already a number in reduction context"),Er(this.negative===0,"red works only with positives"),Gr.convertTo(this)._forceRed(Gr)},jr.prototype.fromRed=function(){return Er(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},jr.prototype._forceRed=function(Gr){return this.red=Gr,this},jr.prototype.forceRed=function(Gr){return Er(!this.red,"Already a number in reduction context"),this._forceRed(Gr)},jr.prototype.redAdd=function(Gr){return Er(this.red,"redAdd works only with red numbers"),this.red.add(this,Gr)},jr.prototype.redIAdd=function(Gr){return Er(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,Gr)},jr.prototype.redSub=function(Gr){return Er(this.red,"redSub works only with red numbers"),this.red.sub(this,Gr)},jr.prototype.redISub=function(Gr){return Er(this.red,"redISub works only with red numbers"),this.red.isub(this,Gr)},jr.prototype.redShl=function(Gr){return Er(this.red,"redShl works only with red numbers"),this.red.shl(this,Gr)},jr.prototype.redMul=function(Gr){return Er(this.red,"redMul works only with red numbers"),this.red._verify2(this,Gr),this.red.mul(this,Gr)},jr.prototype.redIMul=function(Gr){return Er(this.red,"redMul works only with red numbers"),this.red._verify2(this,Gr),this.red.imul(this,Gr)},jr.prototype.redSqr=function(){return Er(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},jr.prototype.redISqr=function(){return Er(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},jr.prototype.redSqrt=function(){return Er(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},jr.prototype.redInvm=function(){return Er(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},jr.prototype.redNeg=function(){return Er(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},jr.prototype.redPow=function(Gr){return Er(this.red&&!Gr.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,Gr)};var ro={k256:null,p224:null,p192:null,p25519:null};function to(Tn,Gr){this.name=Tn,this.p=new jr(Gr,16),this.n=this.p.bitLength(),this.k=new jr(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}to.prototype._tmp=function(){var Gr=new jr(null);return Gr.words=new Array(Math.ceil(this.n/13)),Gr},to.prototype.ireduce=function(Gr){var Xr=Gr,Sn;do this.split(Xr,this.tmp),Xr=this.imulK(Xr),Xr=Xr.iadd(this.tmp),Sn=Xr.bitLength();while(Sn>this.n);var Rn=Sn0?Xr.isub(this.p):Xr.strip!==void 0?Xr.strip():Xr._strip(),Xr},to.prototype.split=function(Gr,Xr){Gr.iushrn(this.n,0,Xr)},to.prototype.imulK=function(Gr){return Gr.imul(this.k)};function _i(){to.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}kr(_i,to),_i.prototype.split=function(Gr,Xr){for(var Sn=4194303,Rn=Math.min(Gr.length,9),Pn=0;Pn>>22,On=Zn}On>>>=22,Gr.words[Pn-10]=On,On===0&&Gr.length>10?Gr.length-=10:Gr.length-=9},_i.prototype.imulK=function(Gr){Gr.words[Gr.length]=0,Gr.words[Gr.length+1]=0,Gr.length+=2;for(var Xr=0,Sn=0;Sn>>=26,Gr.words[Sn]=Pn,Xr=Rn}return Xr!==0&&(Gr.words[Gr.length++]=Xr),Gr},jr._prime=function(Gr){if(ro[Gr])return ro[Gr];var Xr;if(Gr==="k256")Xr=new _i;else if(Gr==="p224")Xr=new oo;else if(Gr==="p192")Xr=new io;else if(Gr==="p25519")Xr=new co;else throw new Error("Unknown prime "+Gr);return ro[Gr]=Xr,Xr};function so(Tn){if(typeof Tn=="string"){var Gr=jr._prime(Tn);this.m=Gr.p,this.prime=Gr}else Er(Tn.gtn(1),"modulus must be greater than 1"),this.m=Tn,this.prime=null}so.prototype._verify1=function(Gr){Er(Gr.negative===0,"red works only with positives"),Er(Gr.red,"red works only with red numbers")},so.prototype._verify2=function(Gr,Xr){Er((Gr.negative|Xr.negative)===0,"red works only with positives"),Er(Gr.red&&Gr.red===Xr.red,"red works only with red numbers")},so.prototype.imod=function(Gr){return this.prime?this.prime.ireduce(Gr)._forceRed(this):(Vr(Gr,Gr.umod(this.m)._forceRed(this)),Gr)},so.prototype.neg=function(Gr){return Gr.isZero()?Gr.clone():this.m.sub(Gr)._forceRed(this)},so.prototype.add=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.add(Xr);return Sn.cmp(this.m)>=0&&Sn.isub(this.m),Sn._forceRed(this)},so.prototype.iadd=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.iadd(Xr);return Sn.cmp(this.m)>=0&&Sn.isub(this.m),Sn},so.prototype.sub=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.sub(Xr);return Sn.cmpn(0)<0&&Sn.iadd(this.m),Sn._forceRed(this)},so.prototype.isub=function(Gr,Xr){this._verify2(Gr,Xr);var Sn=Gr.isub(Xr);return Sn.cmpn(0)<0&&Sn.iadd(this.m),Sn},so.prototype.shl=function(Gr,Xr){return this._verify1(Gr),this.imod(Gr.ushln(Xr))},so.prototype.imul=function(Gr,Xr){return this._verify2(Gr,Xr),this.imod(Gr.imul(Xr))},so.prototype.mul=function(Gr,Xr){return this._verify2(Gr,Xr),this.imod(Gr.mul(Xr))},so.prototype.isqr=function(Gr){return this.imul(Gr,Gr.clone())},so.prototype.sqr=function(Gr){return this.mul(Gr,Gr)},so.prototype.sqrt=function(Gr){if(Gr.isZero())return Gr.clone();var Xr=this.m.andln(3);if(Er(Xr%2===1),Xr===3){var Sn=this.m.add(new jr(1)).iushrn(2);return this.pow(Gr,Sn)}for(var Rn=this.m.subn(1),Pn=0;!Rn.isZero()&&Rn.andln(1)===0;)Pn++,Rn.iushrn(1);Er(!Rn.isZero());var On=new jr(1).toRed(this),Zn=On.redNeg(),Nn=this.m.subn(1).iushrn(1),wn=this.m.bitLength();for(wn=new jr(2*wn*wn).toRed(this);this.pow(wn,Nn).cmp(Zn)!==0;)wn.redIAdd(Zn);for(var zn=this.pow(wn,Rn),fo=this.pow(Gr,Rn.addn(1).iushrn(1)),vo=this.pow(Gr,Rn),go=Pn;vo.cmp(On)!==0;){for(var uo=vo,lo=0;uo.cmp(On)!==0;lo++)uo=uo.redSqr();Er(lo=0;Pn--){for(var zn=Xr.words[Pn],fo=wn-1;fo>=0;fo--){var vo=zn>>fo&1;if(On!==Rn[0]&&(On=this.sqr(On)),vo===0&&Zn===0){Nn=0;continue}Zn<<=1,Zn|=vo,Nn++,!(Nn!==Sn&&(Pn!==0||fo!==0))&&(On=this.mul(On,Rn[Zn]),Nn=0,Zn=0)}wn=26}return On},so.prototype.convertTo=function(Gr){var Xr=Gr.umod(this.m);return Xr===Gr?Xr.clone():Xr},so.prototype.convertFrom=function(Gr){var Xr=Gr.clone();return Xr.red=null,Xr},jr.mont=function(Gr){return new no(Gr)};function no(Tn){so.call(this,Tn),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new jr(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}kr(no,so),no.prototype.convertTo=function(Gr){return this.imod(Gr.ushln(this.shift))},no.prototype.convertFrom=function(Gr){var Xr=this.imod(Gr.mul(this.rinv));return Xr.red=null,Xr},no.prototype.imul=function(Gr,Xr){if(Gr.isZero()||Xr.isZero())return Gr.words[0]=0,Gr.length=1,Gr;var Sn=Gr.imul(Xr),Rn=Sn.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Pn=Sn.isub(Rn).iushrn(this.shift),On=Pn;return Pn.cmp(this.m)>=0?On=Pn.isub(this.m):Pn.cmpn(0)<0&&(On=Pn.iadd(this.m)),On._forceRed(this)},no.prototype.mul=function(Gr,Xr){if(Gr.isZero()||Xr.isZero())return new jr(0)._forceRed(this);var Sn=Gr.mul(Xr),Rn=Sn.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Pn=Sn.isub(Rn).iushrn(this.shift),On=Pn;return Pn.cmp(this.m)>=0?On=Pn.isub(this.m):Pn.cmpn(0)<0&&(On=Pn.iadd(this.m)),On._forceRed(this)},no.prototype.invm=function(Gr){var Xr=this.imod(Gr._invmp(this.m).mul(this.r2));return Xr._forceRed(this)}})(fr,commonjsGlobal)})(bn);var bnExports=bn.exports;const BN=getDefaultExportFromCjs$2(bnExports);var _Buffer=safeBufferExports.Buffer;function base(fr){if(fr.length>=255)throw new TypeError("Alphabet too long");for(var br=new Uint8Array(256),wr=0;wr>>0,jn=new Uint8Array(An);Cn!==In;){for(var eo=Qr[Cn],ro=0,to=An-1;(eo!==0||ro>>0,jn[to]=eo%Br>>>0,eo=eo/Br>>>0;if(eo!==0)throw new Error("Non-zero carry");En=ro,Cn++}for(var _i=An-En;_i!==An&&jn[_i]===0;)_i++;for(var oo=Wr.repeat(_n);_i>>0,An=new Uint8Array(In);_n>>0,An[ro]=jn%256>>>0,jn=jn/256>>>0;if(jn!==0)throw new Error("Non-zero carry");Cn=eo,_n++}for(var to=In-Cn;to!==In&&An[to]===0;)to++;var _i=_Buffer.allocUnsafe(En+(In-to));_i.fill(0,0,En);for(var oo=En;to!==In;)_i[oo++]=An[to++];return _i}function Jr(Qr){var _n=Zr(Qr);if(_n)return _n;throw new Error("Non-base"+Br+" character")}return{encode:Vr,decodeUnsafe:Zr,decode:Jr}}var src=base,basex=src,ALPHABET="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",bs58=basex(ALPHABET);const bs58$1=getDefaultExportFromCjs$2(bs58);class StructError extends TypeError{constructor(br,wr){let Er;const{message:kr,explanation:jr,...Br}=br,{path:Wr}=br,qr=Wr.length===0?kr:`At path: ${Wr.join(".")} -- ${kr}`;super(jr??qr),jr!=null&&(this.cause=qr),Object.assign(this,Br),this.name=this.constructor.name,this.failures=()=>Er??(Er=[br,...wr()])}}function isIterable(fr){return isObject(fr)&&typeof fr[Symbol.iterator]=="function"}function isObject(fr){return typeof fr=="object"&&fr!=null}function isNonArrayObject(fr){return isObject(fr)&&!Array.isArray(fr)}function print(fr){return typeof fr=="symbol"?fr.toString():typeof fr=="string"?JSON.stringify(fr):`${fr}`}function shiftIterator(fr){const{done:br,value:wr}=fr.next();return br?void 0:wr}function toFailure(fr,br,wr,Er){if(fr===!0)return;fr===!1?fr={}:typeof fr=="string"&&(fr={message:fr});const{path:kr,branch:jr}=br,{type:Br}=wr,{refinement:Wr,message:qr=`Expected a value of type \`${Br}\`${Wr?` with refinement \`${Wr}\``:""}, but received: \`${print(Er)}\``}=fr;return{value:Er,type:Br,refinement:Wr,key:kr[kr.length-1],path:kr,branch:jr,...fr,message:qr}}function*toFailures(fr,br,wr,Er){isIterable(fr)||(fr=[fr]);for(const kr of fr){const jr=toFailure(kr,br,wr,Er);jr&&(yield jr)}}function*run(fr,br,wr={}){const{path:Er=[],branch:kr=[fr],coerce:jr=!1,mask:Br=!1}=wr,Wr={path:Er,branch:kr,mask:Br};jr&&(fr=br.coercer(fr,Wr));let qr="valid";for(const Hr of br.validator(fr,Wr))Hr.explanation=wr.message,qr="not_valid",yield[Hr,void 0];for(let[Hr,Vr,Zr]of br.entries(fr,Wr)){const Jr=run(Vr,Zr,{path:Hr===void 0?Er:[...Er,Hr],branch:Hr===void 0?kr:[...kr,Vr],coerce:jr,mask:Br,message:wr.message});for(const Qr of Jr)Qr[0]?(qr=Qr[0].refinement!=null?"not_refined":"not_valid",yield[Qr[0],void 0]):jr&&(Vr=Qr[1],Hr===void 0?fr=Vr:fr instanceof Map?fr.set(Hr,Vr):fr instanceof Set?fr.add(Vr):isObject(fr)&&(Vr!==void 0||Hr in fr)&&(fr[Hr]=Vr))}if(qr!=="not_valid")for(const Hr of br.refiner(fr,Wr))Hr.explanation=wr.message,qr="not_refined",yield[Hr,void 0];qr==="valid"&&(yield[void 0,fr])}let Struct$1=class{constructor(br){const{type:wr,schema:Er,validator:kr,refiner:jr,coercer:Br=qr=>qr,entries:Wr=function*(){}}=br;this.type=wr,this.schema=Er,this.entries=Wr,this.coercer=Br,kr?this.validator=(qr,Hr)=>{const Vr=kr(qr,Hr);return toFailures(Vr,Hr,this,qr)}:this.validator=()=>[],jr?this.refiner=(qr,Hr)=>{const Vr=jr(qr,Hr);return toFailures(Vr,Hr,this,qr)}:this.refiner=()=>[]}assert(br,wr){return assert(br,this,wr)}create(br,wr){return create(br,this,wr)}is(br){return is(br,this)}mask(br,wr){return mask(br,this,wr)}validate(br,wr={}){return validate(br,this,wr)}};function assert(fr,br,wr){const Er=validate(fr,br,{message:wr});if(Er[0])throw Er[0]}function create(fr,br,wr){const Er=validate(fr,br,{coerce:!0,message:wr});if(Er[0])throw Er[0];return Er[1]}function mask(fr,br,wr){const Er=validate(fr,br,{coerce:!0,mask:!0,message:wr});if(Er[0])throw Er[0];return Er[1]}function is(fr,br){return!validate(fr,br)[0]}function validate(fr,br,wr={}){const Er=run(fr,br,wr),kr=shiftIterator(Er);return kr[0]?[new StructError(kr[0],function*(){for(const Br of Er)Br[0]&&(yield Br[0])}),void 0]:[void 0,kr[1]]}function define(fr,br){return new Struct$1({type:fr,schema:null,validator:br})}function any(){return define("any",()=>!0)}function array(fr){return new Struct$1({type:"array",schema:fr,*entries(br){if(fr&&Array.isArray(br))for(const[wr,Er]of br.entries())yield[wr,Er,fr]},coercer(br){return Array.isArray(br)?br.slice():br},validator(br){return Array.isArray(br)||`Expected an array value, but received: ${print(br)}`}})}function boolean(){return define("boolean",fr=>typeof fr=="boolean")}function instance(fr){return define("instance",br=>br instanceof fr||`Expected a \`${fr.name}\` instance, but received: ${print(br)}`)}function literal(fr){const br=print(fr),wr=typeof fr;return new Struct$1({type:"literal",schema:wr==="string"||wr==="number"||wr==="boolean"?fr:null,validator(Er){return Er===fr||`Expected the literal \`${br}\`, but received: ${print(Er)}`}})}function never(){return define("never",()=>!1)}function nullable(fr){return new Struct$1({...fr,validator:(br,wr)=>br===null||fr.validator(br,wr),refiner:(br,wr)=>br===null||fr.refiner(br,wr)})}function number(){return define("number",fr=>typeof fr=="number"&&!isNaN(fr)||`Expected a number, but received: ${print(fr)}`)}function optional(fr){return new Struct$1({...fr,validator:(br,wr)=>br===void 0||fr.validator(br,wr),refiner:(br,wr)=>br===void 0||fr.refiner(br,wr)})}function record(fr,br){return new Struct$1({type:"record",schema:null,*entries(wr){if(isObject(wr))for(const Er in wr){const kr=wr[Er];yield[Er,Er,fr],yield[Er,kr,br]}},validator(wr){return isNonArrayObject(wr)||`Expected an object, but received: ${print(wr)}`},coercer(wr){return isNonArrayObject(wr)?{...wr}:wr}})}function string(){return define("string",fr=>typeof fr=="string"||`Expected a string, but received: ${print(fr)}`)}function tuple(fr){const br=never();return new Struct$1({type:"tuple",schema:null,*entries(wr){if(Array.isArray(wr)){const Er=Math.max(fr.length,wr.length);for(let kr=0;krwr.type).join(" | ");return new Struct$1({type:"union",schema:null,coercer(wr,Er){for(const kr of fr){const[jr,Br]=kr.validate(wr,{coerce:!0,mask:Er.mask});if(!jr)return Br}return wr},validator(wr,Er){const kr=[];for(const jr of fr){const[...Br]=run(wr,jr,Er),[Wr]=Br;if(Wr[0])for(const[qr]of Br)qr&&kr.push(qr);else return[]}return[`Expected the value to satisfy a union of \`${br}\`, but received: ${print(wr)}`,...kr]}})}function unknown(){return define("unknown",()=>!0)}function coerce(fr,br,wr){return new Struct$1({...fr,coercer:(Er,kr)=>is(Er,br)?fr.coercer(wr(Er,kr),kr):fr.coercer(Er,kr)})}function isOnCurve(fr){try{return ed25519.ExtendedPoint.fromHex(fr),!0}catch{return!1}}const toBuffer=fr=>Buffer$1$1.isBuffer(fr)?fr:fr instanceof Uint8Array?Buffer$1$1.from(fr.buffer,fr.byteOffset,fr.byteLength):Buffer$1$1.from(fr);class Struct{constructor(br){Object.assign(this,br)}encode(){return Buffer$1$1.from(serialize_1(SOLANA_SCHEMA,this))}static decode(br){return deserialize_1(SOLANA_SCHEMA,this,br)}static decodeUnchecked(br){return deserializeUnchecked_1(SOLANA_SCHEMA,this,br)}}const SOLANA_SCHEMA=new Map;var _PublicKey;const MAX_SEED_LENGTH=32,PUBLIC_KEY_LENGTH=32;function isPublicKeyData(fr){return fr._bn!==void 0}let uniquePublicKeyCounter=1;class PublicKey extends Struct{constructor(br){if(super({}),this._bn=void 0,isPublicKeyData(br))this._bn=br._bn;else{if(typeof br=="string"){const wr=bs58$1.decode(br);if(wr.length!=PUBLIC_KEY_LENGTH)throw new Error("Invalid public key input");this._bn=new BN(wr)}else this._bn=new BN(br);if(this._bn.byteLength()>PUBLIC_KEY_LENGTH)throw new Error("Invalid public key input")}}static unique(){const br=new PublicKey(uniquePublicKeyCounter);return uniquePublicKeyCounter+=1,new PublicKey(br.toBuffer())}equals(br){return this._bn.eq(br._bn)}toBase58(){return bs58$1.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const br=this.toBuffer();return new Uint8Array(br.buffer,br.byteOffset,br.byteLength)}toBuffer(){const br=this._bn.toArrayLike(Buffer$1$1);if(br.length===PUBLIC_KEY_LENGTH)return br;const wr=Buffer$1$1.alloc(32);return br.copy(wr,32-br.length),wr}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(br,wr,Er){const kr=Buffer$1$1.concat([br.toBuffer(),Buffer$1$1.from(wr),Er.toBuffer()]),jr=sha256$4(kr);return new PublicKey(jr)}static createProgramAddressSync(br,wr){let Er=Buffer$1$1.alloc(0);br.forEach(function(jr){if(jr.length>MAX_SEED_LENGTH)throw new TypeError("Max seed length exceeded");Er=Buffer$1$1.concat([Er,toBuffer(jr)])}),Er=Buffer$1$1.concat([Er,wr.toBuffer(),Buffer$1$1.from("ProgramDerivedAddress")]);const kr=sha256$4(Er);if(isOnCurve(kr))throw new Error("Invalid seeds, address must fall off the curve");return new PublicKey(kr)}static async createProgramAddress(br,wr){return this.createProgramAddressSync(br,wr)}static findProgramAddressSync(br,wr){let Er=255,kr;for(;Er!=0;){try{const jr=br.concat(Buffer$1$1.from([Er]));kr=this.createProgramAddressSync(jr,wr)}catch(jr){if(jr instanceof TypeError)throw jr;Er--;continue}return[kr,Er]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(br,wr){return this.findProgramAddressSync(br,wr)}static isOnCurve(br){const wr=new PublicKey(br);return isOnCurve(wr.toBytes())}}_PublicKey=PublicKey;PublicKey.default=new _PublicKey("11111111111111111111111111111111");SOLANA_SCHEMA.set(PublicKey,{kind:"struct",fields:[["_bn","u256"]]});new PublicKey("BPFLoader1111111111111111111111111111111111");const SIGNATURE_LENGTH_IN_BYTES=64,publicKey=(fr="publicKey")=>blob(32,fr),rustString=(fr="string")=>{const br=struct([u32("length"),u32("lengthPadding"),blob(offset(u32(),-8),"chars")],fr),wr=br.decode.bind(br),Er=br.encode.bind(br),kr=br;return kr.decode=(jr,Br)=>wr(jr,Br).chars.toString(),kr.encode=(jr,Br,Wr)=>{const qr={chars:Buffer$1$1.from(jr,"utf8")};return Er(qr,Br,Wr)},kr.alloc=jr=>u32().span+u32().span+Buffer$1$1.from(jr,"utf8").length,kr},authorized=(fr="authorized")=>struct([publicKey("staker"),publicKey("withdrawer")],fr),lockup=(fr="lockup")=>struct([ns64("unixTimestamp"),ns64("epoch"),publicKey("custodian")],fr),voteInit=(fr="voteInit")=>struct([publicKey("nodePubkey"),publicKey("authorizedVoter"),publicKey("authorizedWithdrawer"),u8("commission")],fr),voteAuthorizeWithSeedArgs=(fr="voteAuthorizeWithSeedArgs")=>struct([u32("voteAuthorizationType"),publicKey("currentAuthorityDerivedKeyOwnerPubkey"),rustString("currentAuthorityDerivedKeySeed"),publicKey("newAuthorized")],fr);Buffer$1$1.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);new PublicKey("SysvarC1ock11111111111111111111111111111111");new PublicKey("SysvarEpochSchedu1e111111111111111111111111");new PublicKey("Sysvar1nstructions1111111111111111111111111");new PublicKey("SysvarRecentB1ockHashes11111111111111111111");new PublicKey("SysvarRent111111111111111111111111111111111");new PublicKey("SysvarRewards111111111111111111111111111111");new PublicKey("SysvarS1otHashes111111111111111111111111111");new PublicKey("SysvarS1otHistory11111111111111111111111111");new PublicKey("SysvarStakeHistory1111111111111111111111111");const FeeCalculatorLayout=nu64("lamportsPerSignature"),NonceAccountLayout=struct([u32("version"),u32("state"),publicKey("authorizedPubkey"),publicKey("nonce"),struct([FeeCalculatorLayout],"feeCalculator")]);NonceAccountLayout.span;const encodeDecode=fr=>{const br=fr.decode.bind(fr),wr=fr.encode.bind(fr);return{decode:br,encode:wr}},bigInt=fr=>br=>{const wr=blob(fr,br),{encode:Er,decode:kr}=encodeDecode(wr),jr=wr;return jr.decode=(Br,Wr)=>{const qr=kr(Br,Wr);return toBigIntLE_1(Buffer$1$1.from(qr))},jr.encode=(Br,Wr,qr)=>{const Hr=toBufferLE_1(Br,fr);return Er(Hr,Wr,qr)},jr},u64=bigInt(8);Object.freeze({Create:{index:0,layout:struct([u32("instruction"),ns64("lamports"),ns64("space"),publicKey("programId")])},Assign:{index:1,layout:struct([u32("instruction"),publicKey("programId")])},Transfer:{index:2,layout:struct([u32("instruction"),u64("lamports")])},CreateWithSeed:{index:3,layout:struct([u32("instruction"),publicKey("base"),rustString("seed"),ns64("lamports"),ns64("space"),publicKey("programId")])},AdvanceNonceAccount:{index:4,layout:struct([u32("instruction")])},WithdrawNonceAccount:{index:5,layout:struct([u32("instruction"),ns64("lamports")])},InitializeNonceAccount:{index:6,layout:struct([u32("instruction"),publicKey("authorized")])},AuthorizeNonceAccount:{index:7,layout:struct([u32("instruction"),publicKey("authorized")])},Allocate:{index:8,layout:struct([u32("instruction"),ns64("space")])},AllocateWithSeed:{index:9,layout:struct([u32("instruction"),publicKey("base"),rustString("seed"),ns64("space"),publicKey("programId")])},AssignWithSeed:{index:10,layout:struct([u32("instruction"),publicKey("base"),rustString("seed"),publicKey("programId")])},TransferWithSeed:{index:11,layout:struct([u32("instruction"),u64("lamports"),rustString("seed"),publicKey("programId")])},UpgradeNonceAccount:{index:12,layout:struct([u32("instruction")])}});new PublicKey("11111111111111111111111111111111");new PublicKey("BPFLoader2111111111111111111111111111111111");struct([u32("typeIndex"),u64("deactivationSlot"),nu64("lastExtendedSlot"),u8("lastExtendedStartIndex"),u8(),seq(publicKey(),offset(u8(),-1),"authority")]);const PublicKeyFromString=coerce(instance(PublicKey),string(),fr=>new PublicKey(fr)),RawAccountDataResult=tuple([string(),literal("base64")]),BufferFromRawAccountData=coerce(instance(Buffer$1$1),RawAccountDataResult,fr=>Buffer$1$1.from(fr[0],"base64"));function createRpcResult(fr){return union([type({jsonrpc:literal("2.0"),id:string(),result:fr}),type({jsonrpc:literal("2.0"),id:string(),error:type({code:unknown(),message:string(),data:optional(any())})})])}const UnknownRpcResult=createRpcResult(unknown());function jsonRpcResult(fr){return coerce(createRpcResult(fr),UnknownRpcResult,br=>"error"in br?br:{...br,result:create(br.result,fr)})}function jsonRpcResultAndContext(fr){return jsonRpcResult(type({context:type({slot:number()}),value:fr}))}function notificationResultAndContext(fr){return type({context:type({slot:number()}),value:fr})}const GetInflationGovernorResult=type({foundation:number(),foundationTerm:number(),initial:number(),taper:number(),terminal:number()});jsonRpcResult(array(nullable(type({epoch:number(),effectiveSlot:number(),amount:number(),postBalance:number(),commission:optional(nullable(number()))}))));const GetRecentPrioritizationFeesResult=array(type({slot:number(),prioritizationFee:number()})),GetInflationRateResult=type({total:number(),validator:number(),foundation:number(),epoch:number()}),GetEpochInfoResult=type({epoch:number(),slotIndex:number(),slotsInEpoch:number(),absoluteSlot:number(),blockHeight:optional(number()),transactionCount:optional(number())}),GetEpochScheduleResult=type({slotsPerEpoch:number(),leaderScheduleSlotOffset:number(),warmup:boolean(),firstNormalEpoch:number(),firstNormalSlot:number()}),GetLeaderScheduleResult=record(string(),array(number())),TransactionErrorResult=nullable(union([type({}),string()])),SignatureStatusResult=type({err:TransactionErrorResult}),SignatureReceivedResult=literal("receivedSignature");type({"solana-core":string(),"feature-set":optional(number())});const ParsedInstructionStruct=type({program:string(),programId:PublicKeyFromString,parsed:unknown()}),PartiallyDecodedInstructionStruct=type({programId:PublicKeyFromString,accounts:array(PublicKeyFromString),data:string()});jsonRpcResultAndContext(type({err:nullable(union([type({}),string()])),logs:nullable(array(string())),accounts:optional(nullable(array(nullable(type({executable:boolean(),owner:string(),lamports:number(),data:array(string()),rentEpoch:optional(number())}))))),unitsConsumed:optional(number()),returnData:optional(nullable(type({programId:string(),data:tuple([string(),literal("base64")])}))),innerInstructions:optional(nullable(array(type({index:number(),instructions:array(union([ParsedInstructionStruct,PartiallyDecodedInstructionStruct]))}))))}));jsonRpcResultAndContext(type({byIdentity:record(string(),array(number())),range:type({firstSlot:number(),lastSlot:number()})}));jsonRpcResult(GetInflationGovernorResult);jsonRpcResult(GetInflationRateResult);jsonRpcResult(GetRecentPrioritizationFeesResult);jsonRpcResult(GetEpochInfoResult);jsonRpcResult(GetEpochScheduleResult);jsonRpcResult(GetLeaderScheduleResult);jsonRpcResult(number());jsonRpcResultAndContext(type({total:number(),circulating:number(),nonCirculating:number(),nonCirculatingAccounts:array(PublicKeyFromString)}));const TokenAmountResult=type({amount:string(),uiAmount:nullable(number()),decimals:number(),uiAmountString:optional(string())});jsonRpcResultAndContext(array(type({address:PublicKeyFromString,amount:string(),uiAmount:nullable(number()),decimals:number(),uiAmountString:optional(string())})));jsonRpcResultAndContext(array(type({pubkey:PublicKeyFromString,account:type({executable:boolean(),owner:PublicKeyFromString,lamports:number(),data:BufferFromRawAccountData,rentEpoch:number()})})));const ParsedAccountDataResult=type({program:string(),parsed:unknown(),space:number()});jsonRpcResultAndContext(array(type({pubkey:PublicKeyFromString,account:type({executable:boolean(),owner:PublicKeyFromString,lamports:number(),data:ParsedAccountDataResult,rentEpoch:number()})})));jsonRpcResultAndContext(array(type({lamports:number(),address:PublicKeyFromString})));const AccountInfoResult=type({executable:boolean(),owner:PublicKeyFromString,lamports:number(),data:BufferFromRawAccountData,rentEpoch:number()});type({pubkey:PublicKeyFromString,account:AccountInfoResult});const ParsedOrRawAccountData=coerce(union([instance(Buffer$1$1),ParsedAccountDataResult]),union([RawAccountDataResult,ParsedAccountDataResult]),fr=>Array.isArray(fr)?create(fr,BufferFromRawAccountData):fr),ParsedAccountInfoResult=type({executable:boolean(),owner:PublicKeyFromString,lamports:number(),data:ParsedOrRawAccountData,rentEpoch:number()});type({pubkey:PublicKeyFromString,account:ParsedAccountInfoResult});type({state:union([literal("active"),literal("inactive"),literal("activating"),literal("deactivating")]),active:number(),inactive:number()});jsonRpcResult(array(type({signature:string(),slot:number(),err:TransactionErrorResult,memo:nullable(string()),blockTime:optional(nullable(number()))})));jsonRpcResult(array(type({signature:string(),slot:number(),err:TransactionErrorResult,memo:nullable(string()),blockTime:optional(nullable(number()))})));type({subscription:number(),result:notificationResultAndContext(AccountInfoResult)});const ProgramAccountInfoResult=type({pubkey:PublicKeyFromString,account:AccountInfoResult});type({subscription:number(),result:notificationResultAndContext(ProgramAccountInfoResult)});const SlotInfoResult=type({parent:number(),slot:number(),root:number()});type({subscription:number(),result:SlotInfoResult});const SlotUpdateResult=union([type({type:union([literal("firstShredReceived"),literal("completed"),literal("optimisticConfirmation"),literal("root")]),slot:number(),timestamp:number()}),type({type:literal("createdBank"),parent:number(),slot:number(),timestamp:number()}),type({type:literal("frozen"),slot:number(),timestamp:number(),stats:type({numTransactionEntries:number(),numSuccessfulTransactions:number(),numFailedTransactions:number(),maxTransactionsPerEntry:number()})}),type({type:literal("dead"),slot:number(),timestamp:number(),err:string()})]);type({subscription:number(),result:SlotUpdateResult});type({subscription:number(),result:notificationResultAndContext(union([SignatureStatusResult,SignatureReceivedResult]))});type({subscription:number(),result:number()});type({pubkey:string(),gossip:nullable(string()),tpu:nullable(string()),rpc:nullable(string()),version:nullable(string())});const VoteAccountInfoResult=type({votePubkey:string(),nodePubkey:string(),activatedStake:number(),epochVoteAccount:boolean(),epochCredits:array(tuple([number(),number(),number()])),commission:number(),lastVote:number(),rootSlot:nullable(number())});jsonRpcResult(type({current:array(VoteAccountInfoResult),delinquent:array(VoteAccountInfoResult)}));const ConfirmationStatus=union([literal("processed"),literal("confirmed"),literal("finalized")]),SignatureStatusResponse=type({slot:number(),confirmations:nullable(number()),err:TransactionErrorResult,confirmationStatus:optional(ConfirmationStatus)});jsonRpcResultAndContext(array(nullable(SignatureStatusResponse)));jsonRpcResult(number());const AddressTableLookupStruct=type({accountKey:PublicKeyFromString,writableIndexes:array(number()),readonlyIndexes:array(number())}),ConfirmedTransactionResult=type({signatures:array(string()),message:type({accountKeys:array(string()),header:type({numRequiredSignatures:number(),numReadonlySignedAccounts:number(),numReadonlyUnsignedAccounts:number()}),instructions:array(type({accounts:array(number()),data:string(),programIdIndex:number()})),recentBlockhash:string(),addressTableLookups:optional(array(AddressTableLookupStruct))})}),AnnotatedAccountKey=type({pubkey:PublicKeyFromString,signer:boolean(),writable:boolean(),source:optional(union([literal("transaction"),literal("lookupTable")]))}),ConfirmedTransactionAccountsModeResult=type({accountKeys:array(AnnotatedAccountKey),signatures:array(string())}),ParsedInstructionResult=type({parsed:unknown(),program:string(),programId:PublicKeyFromString}),RawInstructionResult=type({accounts:array(PublicKeyFromString),data:string(),programId:PublicKeyFromString}),InstructionResult=union([RawInstructionResult,ParsedInstructionResult]),UnknownInstructionResult=union([type({parsed:unknown(),program:string(),programId:string()}),type({accounts:array(string()),data:string(),programId:string()})]),ParsedOrRawInstruction=coerce(InstructionResult,UnknownInstructionResult,fr=>"accounts"in fr?create(fr,RawInstructionResult):create(fr,ParsedInstructionResult)),ParsedConfirmedTransactionResult=type({signatures:array(string()),message:type({accountKeys:array(AnnotatedAccountKey),instructions:array(ParsedOrRawInstruction),recentBlockhash:string(),addressTableLookups:optional(nullable(array(AddressTableLookupStruct)))})}),TokenBalanceResult=type({accountIndex:number(),mint:string(),owner:optional(string()),programId:optional(string()),uiTokenAmount:TokenAmountResult}),LoadedAddressesResult=type({writable:array(PublicKeyFromString),readonly:array(PublicKeyFromString)}),ConfirmedTransactionMetaResult=type({err:TransactionErrorResult,fee:number(),innerInstructions:optional(nullable(array(type({index:number(),instructions:array(type({accounts:array(number()),data:string(),programIdIndex:number()}))})))),preBalances:array(number()),postBalances:array(number()),logMessages:optional(nullable(array(string()))),preTokenBalances:optional(nullable(array(TokenBalanceResult))),postTokenBalances:optional(nullable(array(TokenBalanceResult))),loadedAddresses:optional(LoadedAddressesResult),computeUnitsConsumed:optional(number())}),ParsedConfirmedTransactionMetaResult=type({err:TransactionErrorResult,fee:number(),innerInstructions:optional(nullable(array(type({index:number(),instructions:array(ParsedOrRawInstruction)})))),preBalances:array(number()),postBalances:array(number()),logMessages:optional(nullable(array(string()))),preTokenBalances:optional(nullable(array(TokenBalanceResult))),postTokenBalances:optional(nullable(array(TokenBalanceResult))),loadedAddresses:optional(LoadedAddressesResult),computeUnitsConsumed:optional(number())}),TransactionVersionStruct=union([literal(0),literal("legacy")]),RewardsResult=type({pubkey:string(),lamports:number(),postBalance:nullable(number()),rewardType:nullable(string()),commission:optional(nullable(number()))});jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),transactions:array(type({transaction:ConfirmedTransactionResult,meta:nullable(ConfirmedTransactionMetaResult),version:optional(TransactionVersionStruct)})),rewards:optional(array(RewardsResult)),blockTime:nullable(number()),blockHeight:nullable(number())})));jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),rewards:optional(array(RewardsResult)),blockTime:nullable(number()),blockHeight:nullable(number())})));jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),transactions:array(type({transaction:ConfirmedTransactionAccountsModeResult,meta:nullable(ConfirmedTransactionMetaResult),version:optional(TransactionVersionStruct)})),rewards:optional(array(RewardsResult)),blockTime:nullable(number()),blockHeight:nullable(number())})));jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),transactions:array(type({transaction:ParsedConfirmedTransactionResult,meta:nullable(ParsedConfirmedTransactionMetaResult),version:optional(TransactionVersionStruct)})),rewards:optional(array(RewardsResult)),blockTime:nullable(number()),blockHeight:nullable(number())})));jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),transactions:array(type({transaction:ConfirmedTransactionAccountsModeResult,meta:nullable(ParsedConfirmedTransactionMetaResult),version:optional(TransactionVersionStruct)})),rewards:optional(array(RewardsResult)),blockTime:nullable(number()),blockHeight:nullable(number())})));jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),rewards:optional(array(RewardsResult)),blockTime:nullable(number()),blockHeight:nullable(number())})));jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),transactions:array(type({transaction:ConfirmedTransactionResult,meta:nullable(ConfirmedTransactionMetaResult)})),rewards:optional(array(RewardsResult)),blockTime:nullable(number())})));jsonRpcResult(nullable(type({blockhash:string(),previousBlockhash:string(),parentSlot:number(),signatures:array(string()),blockTime:nullable(number())})));jsonRpcResult(nullable(type({slot:number(),meta:nullable(ConfirmedTransactionMetaResult),blockTime:optional(nullable(number())),transaction:ConfirmedTransactionResult,version:optional(TransactionVersionStruct)})));jsonRpcResult(nullable(type({slot:number(),transaction:ParsedConfirmedTransactionResult,meta:nullable(ParsedConfirmedTransactionMetaResult),blockTime:optional(nullable(number())),version:optional(TransactionVersionStruct)})));jsonRpcResultAndContext(type({blockhash:string(),feeCalculator:type({lamportsPerSignature:number()})}));jsonRpcResultAndContext(type({blockhash:string(),lastValidBlockHeight:number()}));jsonRpcResultAndContext(boolean());const PerfSampleResult=type({slot:number(),numTransactions:number(),numSlots:number(),samplePeriodSecs:number()});jsonRpcResult(array(PerfSampleResult));jsonRpcResultAndContext(nullable(type({feeCalculator:type({lamportsPerSignature:number()})})));jsonRpcResult(string());jsonRpcResult(string());const LogsResult=type({err:TransactionErrorResult,logs:array(string()),signature:string()});type({result:notificationResultAndContext(LogsResult),subscription:number()});Object.freeze({CreateLookupTable:{index:0,layout:struct([u32("instruction"),u64("recentSlot"),u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:struct([u32("instruction")])},ExtendLookupTable:{index:2,layout:struct([u32("instruction"),u64(),seq(publicKey(),offset(u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:struct([u32("instruction")])},CloseLookupTable:{index:4,layout:struct([u32("instruction")])}});new PublicKey("AddressLookupTab1e1111111111111111111111111");Object.freeze({RequestUnits:{index:0,layout:struct([u8("instruction"),u32("units"),u32("additionalFee")])},RequestHeapFrame:{index:1,layout:struct([u8("instruction"),u32("bytes")])},SetComputeUnitLimit:{index:2,layout:struct([u8("instruction"),u32("units")])},SetComputeUnitPrice:{index:3,layout:struct([u8("instruction"),u64("microLamports")])}});new PublicKey("ComputeBudget111111111111111111111111111111");struct([u8("numSignatures"),u8("padding"),u16("signatureOffset"),u16("signatureInstructionIndex"),u16("publicKeyOffset"),u16("publicKeyInstructionIndex"),u16("messageDataOffset"),u16("messageDataSize"),u16("messageInstructionIndex")]);new PublicKey("Ed25519SigVerify111111111111111111111111111");secp256k1$1.utils.isValidPrivateKey;secp256k1$1.getPublicKey;struct([u8("numSignatures"),u16("signatureOffset"),u8("signatureInstructionIndex"),u16("ethAddressOffset"),u8("ethAddressInstructionIndex"),u16("messageDataOffset"),u16("messageDataSize"),u8("messageInstructionIndex"),blob(20,"ethAddress"),blob(64,"signature"),u8("recoveryId")]);new PublicKey("KeccakSecp256k11111111111111111111111111111");var _Lockup;new PublicKey("StakeConfig11111111111111111111111111111111");class Lockup{constructor(br,wr,Er){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=br,this.epoch=wr,this.custodian=Er}}_Lockup=Lockup;Lockup.default=new _Lockup(0,0,PublicKey.default);Object.freeze({Initialize:{index:0,layout:struct([u32("instruction"),authorized(),lockup()])},Authorize:{index:1,layout:struct([u32("instruction"),publicKey("newAuthorized"),u32("stakeAuthorizationType")])},Delegate:{index:2,layout:struct([u32("instruction")])},Split:{index:3,layout:struct([u32("instruction"),ns64("lamports")])},Withdraw:{index:4,layout:struct([u32("instruction"),ns64("lamports")])},Deactivate:{index:5,layout:struct([u32("instruction")])},Merge:{index:7,layout:struct([u32("instruction")])},AuthorizeWithSeed:{index:8,layout:struct([u32("instruction"),publicKey("newAuthorized"),u32("stakeAuthorizationType"),rustString("authoritySeed"),publicKey("authorityOwner")])}});new PublicKey("Stake11111111111111111111111111111111111111");Object.freeze({InitializeAccount:{index:0,layout:struct([u32("instruction"),voteInit()])},Authorize:{index:1,layout:struct([u32("instruction"),publicKey("newAuthorized"),u32("voteAuthorizationType")])},Withdraw:{index:3,layout:struct([u32("instruction"),ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:struct([u32("instruction")])},AuthorizeWithSeed:{index:10,layout:struct([u32("instruction"),voteAuthorizeWithSeedArgs()])}});new PublicKey("Vote111111111111111111111111111111111111111");new PublicKey("Va1idator1nfo111111111111111111111111111111");type({name:string(),website:optional(string()),details:optional(string()),iconUrl:optional(string()),keybaseUsername:optional(string())});new PublicKey("Vote111111111111111111111111111111111111111");struct([publicKey("nodePubkey"),publicKey("authorizedWithdrawer"),u8("commission"),nu64(),seq(struct([nu64("slot"),u32("confirmationCount")]),offset(u32(),-8),"votes"),u8("rootSlotValid"),nu64("rootSlot"),nu64(),seq(struct([nu64("epoch"),publicKey("authorizedVoter")]),offset(u32(),-8),"authorizedVoters"),struct([seq(struct([publicKey("authorizedPubkey"),nu64("epochOfLastAuthorizedSwitch"),nu64("targetEpoch")]),32,"buf"),nu64("idx"),u8("isEmpty")],"priorVoters"),nu64(),seq(struct([nu64("epoch"),nu64("credits"),nu64("prevCredits")]),offset(u32(),-8),"epochCredits"),struct([nu64("slot"),nu64("timestamp")],"lastTimestamp")]);class TurnkeySigner{constructor(br){this.organizationId=br.organizationId,this.client=br.client}async signAllTransactions(br,wr){var Wr,qr,Hr;const Er=new PublicKey(wr);let kr=br.map(Vr=>this.getMessageToSign(Vr).toString("hex"));const Br=(qr=(Wr=(await this.signRawPayloads(kr,wr)).signRawPayloadsResult)==null?void 0:Wr.signatures)==null?void 0:qr.map(Vr=>`${Vr==null?void 0:Vr.r}${Vr==null?void 0:Vr.s}`);for(let Vr in br)(Hr=br[Vr])==null||Hr.addSignature(Er,Buffer$2.from(Br[Vr],"hex"));return br}async addSignature(br,wr){var Wr,qr;const Er=new PublicKey(wr);let kr=this.getMessageToSign(br);const jr=await this.signRawPayload(kr.toString("hex"),wr),Br=`${(Wr=jr.signRawPayloadResult)==null?void 0:Wr.r}${(qr=jr.signRawPayloadResult)==null?void 0:qr.s}`;br.addSignature(Er,Buffer$2.from(Br,"hex"))}async signMessage(br,wr){var kr,jr;const Er=await this.signRawPayload(Buffer$2.from(br).toString("hex"),wr);return Buffer$2.from(`${(kr=Er.signRawPayloadResult)==null?void 0:kr.r}${(jr=Er.signRawPayloadResult)==null?void 0:jr.s}`,"hex")}async signRawPayload(br,wr){const Er=await this.client.signRawPayload({type:"ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2",organizationId:this.organizationId,timestampMs:String(Date.now()),parameters:{signWith:wr,payload:br,encoding:"PAYLOAD_ENCODING_HEXADECIMAL",hashFunction:"HASH_FUNCTION_NOT_APPLICABLE"}}),{id:kr,status:jr,type:Br,result:Wr}=Er.activity;if(jr!=="ACTIVITY_STATUS_COMPLETED")throw new TurnkeyActivityError({message:`Expected COMPLETED status, got ${jr}`,activityId:kr,activityStatus:jr,activityType:Br});return Wr}async signRawPayloads(br,wr){const Er=await this.client.signRawPayloads({type:"ACTIVITY_TYPE_SIGN_RAW_PAYLOADS",organizationId:this.organizationId,timestampMs:String(Date.now()),parameters:{signWith:wr,payloads:br,encoding:"PAYLOAD_ENCODING_HEXADECIMAL",hashFunction:"HASH_FUNCTION_NOT_APPLICABLE"}}),{id:kr,status:jr,type:Br,result:Wr}=Er.activity;if(jr!=="ACTIVITY_STATUS_COMPLETED")throw new TurnkeyActivityError({message:`Expected COMPLETED status, got ${jr}`,activityId:kr,activityStatus:jr,activityType:Br});return Wr}getMessageToSign(br){let wr;return typeof br.serializeMessage=="function"?wr=br.serializeMessage():wr=Buffer$2.from(br.message.serialize()),wr}}var version$3="3.8.2";function __awaiter$1(fr,br,wr,Er){function kr(jr){return jr instanceof wr?jr:new wr(function(Br){Br(jr)})}return new(wr||(wr=Promise))(function(jr,Br){function Wr(Vr){try{Hr(Er.next(Vr))}catch(Zr){Br(Zr)}}function qr(Vr){try{Hr(Er.throw(Vr))}catch(Zr){Br(Zr)}}function Hr(Vr){Vr.done?jr(Vr.value):kr(Vr.value).then(Wr,qr)}Hr((Er=Er.apply(fr,[])).next())})}typeof SuppressedError=="function"&&SuppressedError;var version$2="3.8.2";function __rest(fr,br){var wr={};for(var Er in fr)Object.prototype.hasOwnProperty.call(fr,Er)&&br.indexOf(Er)<0&&(wr[Er]=fr[Er]);if(fr!=null&&typeof Object.getOwnPropertySymbols=="function")for(var kr=0,Er=Object.getOwnPropertySymbols(fr);kr{var fr,br,wr;return typeof process$1$1<"u"&&define_process_env_default$1&&(wr=(br=(fr=define_process_env_default$1.ICONIC_SPRITE_CDN_URL)!==null&&fr!==void 0?fr:define_process_env_default$1.NEXT_PUBLIC_ICONIC_SPRITE_CDN_URL)!==null&&br!==void 0?br:define_process_env_default$1.REACT_APP_ICONIC_SPRITE_CDN_URLL)!==null&&wr!==void 0?wr:DEFAULT_ICONIC_SPRITE_URL},ICONIC_SPRITE_URL=getIconicSpriteUrl(),createIconic=fr=>{const br=Object.assign(Object.assign({},fr),{function:Er=>{const kr=`${ICONIC_SPRITE_URL}#${br.iconName}`;return reactExports.createElement("img",Object.assign(Object.assign({"data-testid":`iconic-${br.iconName}`},Er),{alt:br.alt,src:kr}))}}),wr=br.function.bind(br);return Object.assign(wr,{iconName:br.iconName,sourcePath:br.sourcePath}),wr};createIconic({alt:"Brave Browser",iconName:"brave",sourcePath:"icons/browsers/brave.svg"});createIconic({alt:"Chrome Browser",iconName:"chrome",sourcePath:"icons/browsers/chrome.svg"});createIconic({alt:"Edge Browser",iconName:"edge",sourcePath:"icons/browsers/edge.svg"});createIconic({alt:"Firefox Browser",iconName:"firefox",sourcePath:"icons/browsers/firefox.svg"});createIconic({alt:"Opera Browser",iconName:"opera",sourcePath:"icons/browsers/opera.svg"});createIconic({alt:"Opera Browser",iconName:"safari",sourcePath:"icons/browsers/safari.svg"});createIconic({alt:"Algorand Chain",iconName:"algorand",sourcePath:"icons/chains/algorand.svg"});createIconic({alt:"Arbitrum Chain",iconName:"arbitrum",sourcePath:"icons/chains/arbitrum.svg"});createIconic({alt:"Aurora Chain",iconName:"aurora",sourcePath:"icons/chains/aurora.svg"});createIconic({alt:"Base Chain",iconName:"base",sourcePath:"icons/chains/base.svg"});createIconic({alt:"Berachain Chain",iconName:"berachain",sourcePath:"icons/chains/berachain.svg"});createIconic({alt:"Bitcoin Chain",iconName:"bitcoin",sourcePath:"icons/chains/bitcoin.svg"});createIconic({alt:"BNB Chain",iconName:"bnb",sourcePath:"icons/chains/bnb.svg"});createIconic({alt:"Cosmos Chain",iconName:"cosmos",sourcePath:"icons/chains/cosmos.svg"});createIconic({alt:"Osmosis Chain",iconName:"osmosis",sourcePath:"icons/chains/osmosis.svg"});createIconic({alt:"Axelar Chain",iconName:"axelar",sourcePath:"icons/chains/axelar.svg"});createIconic({alt:"Ethereum Chain",iconName:"ethereum",sourcePath:"icons/chains/ethereum.svg"});createIconic({alt:"Goerli Chain",iconName:"goerli",sourcePath:"icons/chains/goerli.svg"});createIconic({alt:"zkSync Era Chain",iconName:"zkSync",sourcePath:"icons/chains/zkSync.svg"});createIconic({alt:"Flow Chain",iconName:"flow",sourcePath:"icons/chains/flow.svg"});createIconic({alt:"Gnosis Chain",iconName:"gnosis",sourcePath:"icons/chains/gnosis.svg"});createIconic({alt:"Optimism Chain",iconName:"optimism",sourcePath:"icons/chains/optimism.svg"});createIconic({alt:"Palm Chain",iconName:"palm",sourcePath:"icons/chains/palm.svg"});createIconic({alt:"Polygon Chain",iconName:"polygon",sourcePath:"icons/chains/polygon.svg"});createIconic({alt:"Solana Chain",iconName:"solana",sourcePath:"icons/chains/solana.svg"});createIconic({alt:"Starknet Chain",iconName:"starknet",sourcePath:"icons/chains/starknet.svg"});createIconic({alt:"1inch Wallet",iconName:"1inch.svg",sourcePath:"icons/wallets/1inch.svg"});createIconic({alt:"Argent X Wallet",iconName:"argentx",sourcePath:"icons/wallets/argentx.svg"});createIconic({alt:"Argent Mobile",iconName:"argentmobile",sourcePath:"icons/wallets/argent-mobile.svg"});createIconic({alt:"Argent Web Wallet",iconName:"argentwebwallet",sourcePath:"icons/wallets/argent-web-wallet.svg"});createIconic({alt:"Backpack Wallet",iconName:"backpack",sourcePath:"icons/wallets/backpack.svg"});createIconic({alt:"Binance Wallet",iconName:"binance.svg",sourcePath:"icons/wallets/binance.svg"});createIconic({alt:"BitPay Wallet",iconName:"bitpay.svg",sourcePath:"icons/wallets/bitpay.svg"});createIconic({alt:"Blocto Wallet",iconName:"blocto",sourcePath:"icons/wallets/blocto.svg"});createIconic({alt:"Braavos Wallet",iconName:"braavos",sourcePath:"icons/wallets/braavos.svg"});createIconic({alt:"Coin98 Wallet",iconName:"coin98",sourcePath:"icons/wallets/coin98.svg"});createIconic({alt:"Coinbase Wallet",iconName:"coinbase",sourcePath:"icons/wallets/coinbase.svg"});createIconic({alt:"Crypto Wallet",iconName:"crypto.svg",sourcePath:"icons/wallets/crypto.svg"});createIconic({alt:"Dapper Wallet",iconName:"dapper",sourcePath:"icons/wallets/dapper.svg"});createIconic({alt:"Dawn Wallet",iconName:"dawn",sourcePath:"icons/wallets/dawn.svg"});createIconic({alt:"Default Wallet",iconName:"defaultwallet",sourcePath:"icons/wallets/default.svg"});createIconic({alt:"Dapper Wallet",iconName:"emailsign.svg",sourcePath:"icons/wallets/emailsign.svg"});createIconic({alt:"Sign in with Email",iconName:"signinwithemail",sourcePath:"icons/wallets/signinwithemail.svg"});createIconic({alt:"Exodus Wallet",iconName:"exodus",sourcePath:"icons/wallets/exodus.svg"});createIconic({alt:"Fireblocks Wallet",iconName:"fireblocks.svg",sourcePath:"icons/wallets/fireblocks.svg"});createIconic({alt:"Fortmatic Wallet",iconName:"fortmatic",sourcePath:"icons/wallets/fortmatic.svg"});createIconic({alt:"Frame Wallet",iconName:"frame",sourcePath:"icons/wallets/frame.svg"});createIconic({alt:"Gamestop Wallet",iconName:"gamestop",sourcePath:"icons/wallets/gamestop.svg"});createIconic({alt:"Glow Wallet",iconName:"glow",sourcePath:"icons/wallets/glow.svg"});createIconic({alt:"ImToken Wallet",iconName:"imtoken.svg",sourcePath:"icons/wallets/imtoken.svg"});createIconic({alt:"Injected Wallet",iconName:"injectedwallet",sourcePath:"icons/wallets/injectedwallet.svg"});createIconic({alt:"Keplr Wallet",iconName:"keplr",sourcePath:"icons/wallets/keplr.svg"});createIconic({alt:"Ledger Wallet",iconName:"ledger",sourcePath:"icons/wallets/ledger.svg"});createIconic({alt:"Lilico Wallet",iconName:"lilico",sourcePath:"icons/wallets/lilico.svg"});createIconic({alt:"Linen Wallet",iconName:"linen.svg",sourcePath:"icons/wallets/linen.svg"});createIconic({alt:"Matic Wallet",iconName:"matic",sourcePath:"icons/wallets/matic.svg"});createIconic({alt:"MetaMask Wallet",iconName:"metamask",sourcePath:"icons/wallets/metamask.svg"});createIconic({alt:"Missing Wallet",iconName:"missing",sourcePath:"icons/wallets/missing.svg"});createIconic({alt:"MyAlgo Wallet",iconName:"myalgo",sourcePath:"icons/wallets/myalgo.svg"});createIconic({alt:"Omni Wallet",iconName:"omni",sourcePath:"icons/wallets/omni.svg"});createIconic({alt:"OpeanSea Wallet",iconName:"opeansea",sourcePath:"icons/wallets/opensea.svg"});createIconic({alt:"Pera Wallet",iconName:"pera",sourcePath:"icons/wallets/pera.svg"});createIconic({alt:"Phantom Wallet",iconName:"phantom",sourcePath:"icons/wallets/phantom.svg"});createIconic({alt:"Rabby Wallet",iconName:"rabby",sourcePath:"icons/wallets/rabby.svg"});createIconic({alt:"Rainbow Wallet",iconName:"rainbow",sourcePath:"icons/wallets/rainbow.svg"});createIconic({alt:"Safe Wallet",iconName:"safe",sourcePath:"icons/wallets/safe.svg"});createIconic({alt:"Sequence Wallet",iconName:"sequence",sourcePath:"icons/wallets/sequence.svg"});createIconic({alt:"Solflare Wallet",iconName:"solflare",sourcePath:"icons/wallets/solflare.svg"});createIconic({alt:"Spot Wallet",iconName:"spot",sourcePath:"icons/wallets/spot.svg"});createIconic({alt:"Stroke Wallet",iconName:"stroke",sourcePath:"icons/wallets/stroke.svg"});createIconic({alt:"Taho Wallet",iconName:"tallycash",sourcePath:"icons/wallets/tallycash.svg"});createIconic({alt:"Terra Wallet",iconName:"terra",sourcePath:"icons/wallets/terra.svg"});createIconic({alt:"Torus Wallet",iconName:"torus",sourcePath:"icons/wallets/torus.svg"});createIconic({alt:"Trust Wallet",iconName:"trust",sourcePath:"icons/wallets/trust.svg"});createIconic({alt:"Unstoppable Wallet",iconName:"unstoppable",sourcePath:"icons/wallets/unstoppable.svg"});createIconic({alt:"Venly Wallet",iconName:"venly",sourcePath:"icons/wallets/venly.svg"});createIconic({alt:"Wallet Connect Wallet",iconName:"walletconnect",sourcePath:"icons/wallets/walletconnect.svg"});createIconic({alt:"Magic Link Wallet",iconName:"magiclink",sourcePath:"icons/wallets/magic-link.svg"});createIconic({alt:"Turnkey",iconName:"turnkey",sourcePath:"icons/wallets/embedded-wallet.svg"});createIconic({alt:"Zengo Wallet",iconName:"zengo",sourcePath:"icons/wallets/zengo.svg"});createIconic({alt:"Superb Wallet",iconName:"superb",sourcePath:"icons/wallets/superb.svg"});createIconic({alt:"ZeroDev",iconName:"zerodev",sourcePath:"icons/wallets/embedded-wallet.svg"});createIconic({alt:"Smart Wallet",iconName:"smartwallet",sourcePath:"icons/wallets/smart-wallet.svg"});createIconic({alt:"Magic Eden",iconName:"magiceden",sourcePath:"icons/wallets/magiceden.svg"});createIconic({alt:"Xverse",iconName:"xverse",sourcePath:"icons/wallets/xverse.svg"});createIconic({alt:"Unisat",iconName:"unisat",sourcePath:"icons/wallets/unisat.svg"});createIconic({alt:"Leather",iconName:"leather",sourcePath:"icons/wallets/leather.svg"});createIconic({alt:"OKX",iconName:"okx",sourcePath:"icons/wallets/okx.svg"});createIconic({alt:"Coinbase WaaS",iconName:"coinbasewaas",sourcePath:"icons/wallets/embedded-wallet.svg"});createIconic({alt:"MetaMask Starknet Snap",iconName:"metamaskstarknetsnap",sourcePath:"icons/wallets/metamask-starknet.svg"});createIconic({alt:"Nightly",iconName:"nightly",sourcePath:"icons/wallets/nightly.svg"});createIconic({alt:"OneKey",iconName:"onekey",sourcePath:"icons/wallets/onekey.svg"});createIconic({alt:"Ambire",iconName:"ambire",sourcePath:"icons/wallets/ambire.svg"});createIconic({alt:"Bitget Wallet",iconName:"bitgetwallet",sourcePath:"icons/wallets/bitgetwallet.svg"});createIconic({alt:"Math Wallet",iconName:"coin98",sourcePath:"icons/wallets/coin98.svg"});createIconic({alt:"Clover Wallet",iconName:"clover",sourcePath:"icons/wallets/clover.svg"});createIconic({alt:"Apple",iconName:"apple",sourcePath:"icons/mobile/apple.svg"});createIconic({alt:"Android",iconName:"android",sourcePath:"icons/mobile/android.svg"});createIconic({alt:"Bitbucket",iconName:"bitbucket",sourcePath:"icons/social/bitbucket.svg"});createIconic({alt:"Discord",iconName:"discord",sourcePath:"icons/social/discord.svg"});createIconic({alt:"Facebook",iconName:"facebook",sourcePath:"icons/social/facebook.svg"});createIconic({alt:"Farcaster",iconName:"farcaster",sourcePath:"icons/social/farcaster.svg"});createIconic({alt:"Github",iconName:"github",sourcePath:"icons/social/github.svg"});createIconic({alt:"Github",iconName:"github-dark",sourcePath:"icons/social/github-dark.svg"});createIconic({alt:"Gitlab",iconName:"gitlab",sourcePath:"icons/social/gitlab.svg"});createIconic({alt:"Google",iconName:"google",sourcePath:"icons/social/google.svg"});createIconic({alt:"Helpdesk",iconName:"helpdesk",sourcePath:"icons/social/helpdesk.svg"});createIconic({alt:"Linkedin",iconName:"linkedin",sourcePath:"icons/social/linkedin.svg"});createIconic({alt:"Microsoft",iconName:"microsoft",sourcePath:"icons/social/microsoft.svg"});createIconic({alt:"Slack",iconName:"slack",sourcePath:"icons/social/slack.svg"});createIconic({alt:"Telegram",iconName:"telegram",sourcePath:"icons/social/telegram.svg"});createIconic({alt:"Twitch",iconName:"twitch",sourcePath:"icons/social/twitch.svg"});createIconic({alt:"Twitch",iconName:"twitch-dark",sourcePath:"icons/social/twitch-dark.svg"});createIconic({alt:"Twitter",iconName:"twitter",sourcePath:"icons/social/twitter.svg"});createIconic({alt:"Twitter",iconName:"twitter-dark",sourcePath:"icons/social/twitter-dark.svg"});createIconic({alt:"Apple",iconName:"apple",sourcePath:"icons/social/apple.svg"});createIconic({alt:"Apple",iconName:"apple-dark",sourcePath:"icons/social/apple-dark.svg"});createIconic({alt:"Coinbase",iconName:"coinbasesocial",sourcePath:"icons/social/coinbasesocial.svg"});createIconic({alt:"Coinbase",iconName:"coinbasesocial-dark",sourcePath:"icons/social/coinbasesocial-dark.svg"});createIconic({alt:"Instagram",iconName:"instagram",sourcePath:"icons/social/instagram.svg"});createIconic({alt:"YouTube",iconName:"youtube",sourcePath:"icons/social/youtube.svg"});createIconic({alt:"onePassword",iconName:"one-password",sourcePath:"icons/social/onePassword.svg"});createIconic({alt:"onePassword-dark",iconName:"one-password-dark",sourcePath:"icons/social/onePassword-dark.svg"});createIconic({alt:"epicGames",iconName:"epicgames",sourcePath:"icons/social/epicgames.svg"});createIconic({alt:"epicGames-dark",iconName:"epicgames-dark",sourcePath:"icons/social/epicgames-dark.svg"});createIconic({alt:"spotify",iconName:"spotify",sourcePath:"icons/social/spotify.svg"});createIconic({alt:"spotify-dark",iconName:"spotify-dark",sourcePath:"icons/social/spotify-dark.svg"});createIconic({alt:"steam",iconName:"steam",sourcePath:"icons/social/steam.svg"});createIconic({alt:"steam-dark",iconName:"steam-dark",sourcePath:"icons/social/steam-dark.svg"});createIconic({alt:"tiktok",iconName:"tiktok",sourcePath:"icons/social/tiktok.svg"});createIconic({alt:"tiktok-dark",iconName:"tiktok-dark",sourcePath:"icons/social/tiktok-dark.svg"});createIconic({alt:"line",iconName:"line",sourcePath:"icons/social/line.svg"});createIconic({alt:"Captcha Wave",iconName:"captcha-wave",sourcePath:"icons/misc/captcha-wave.svg"});createIconic({alt:"User Profile",iconName:"user-profile",sourcePath:"icons/misc/user-profile.svg"});createIconic({alt:"Arrow Send",iconName:"arrow-send",sourcePath:"icons/misc/arrow-send.svg"});typeof SuppressedError=="function"&&SuppressedError;new Logger$1("iconic");assertPackageVersion("@dynamic-labs/iconic",version);`${getIconicSpriteUrl()}`;new Logger$1("WalletBook");typeof SuppressedError=="function"&&SuppressedError;const walletConnectSourceValueSchema=z$6.object({app:z$6.object({android:z$6.string().nullable(),browser:z$6.string().nullable(),chrome:z$6.string().nullable(),edge:z$6.string().nullable(),firefox:z$6.string().nullable(),ios:z$6.string().nullable(),linux:z$6.string().nullable(),mac:z$6.string().nullable(),opera:z$6.string().nullable(),safari:z$6.string().nullable(),windows:z$6.string().nullable()}),app_type:z$6.string(),category:z$6.string().nullable(),chains:z$6.array(z$6.string()),description:z$6.string().nullable(),desktop:z$6.object({native:z$6.string().nullable(),universal:z$6.string().nullable()}),homepage:z$6.string(),id:z$6.string(),image_id:z$6.string(),image_url:z$6.object({lg:z$6.string(),md:z$6.string(),sm:z$6.string()}),injected:z$6.array(z$6.object({injected_id:z$6.string(),namespace:z$6.string()})).nullable(),metadata:z$6.object({colors:z$6.object({primary:z$6.string().nullable(),secondary:z$6.string().nullable()}),shortName:z$6.string().nullable()}),mobile:z$6.object({native:z$6.string().nullable(),universal:z$6.string().nullable()}),name:z$6.string(),rdns:z$6.string().nullable(),sdks:z$6.array(z$6.string()),slug:z$6.string(),supported_standards:z$6.array(z$6.object({id:z$6.string(),standard_id:z$6.number(),standard_prefix:z$6.string(),title:z$6.string(),url:z$6.string()})).optional(),updatedAt:z$6.string(),versions:z$6.array(z$6.string())}).strict();z$6.record(z$6.string(),walletConnectSourceValueSchema);const nonEmptyString=z$6.preprocess(fr=>fr||void 0,z$6.string().optional()),transformChromeExtensionId=fr=>{if(fr!=null&&fr.match(/^[a-z]{32}$/))return fr;if(fr!=null&&fr.includes("chrome.google.com/webstore/detail/"))try{return new URL(fr).pathname.split("/").at(-1)}catch{}},transformEdgeExtensionId=fr=>{if(fr!=null&&fr.match(/^[a-z]{32}$/))return fr;if(fr!=null&&fr.includes("microsoftedge.microsoft.com/addons/detail/"))try{return new URL(fr).pathname.split("/").at(-1)}catch{}},transformFirefoxExtensionId=fr=>{if(!(fr!=null&&fr.match(/^https?:\/\//)))return fr;if(fr!=null&&fr.includes("addons.mozilla.org"))try{return new URL(fr).pathname.replace(/\/$/,"").split("/").at(-1)}catch{}},idRegex=/^id[0-9]{1,36}$/,transformIosId=fr=>{if(fr!=null&&fr.match(idRegex))return fr;if(fr!=null&&fr.match(/^https:\/\/[a-zA-Z0-9-]+\.apple\.com/))try{const wr=new URL(fr).pathname.replace(/\/$/,"").split("/").at(-1);if(wr!=null&&wr.match(idRegex))return wr}catch{}},transformAndroidId=fr=>{if(!(fr!=null&&fr.match(/^https?:\/\//)))return fr;if(fr)try{const wr=new URL(fr).searchParams.get("id");if(wr)return wr}catch{}},nonEmptyStringArray=z$6.preprocess(fr=>Array.isArray(fr)&&fr.length>0?fr:void 0,z$6.array(z$6.string()).optional()),filterEmptyObject=fr=>fr&&Object.values(fr).some(br=>!!br)?fr:void 0,injectedConfigSchema=z$6.object({chain:z$6.string(),extensionLocators:z$6.array(z$6.object({flag:z$6.string(),value:z$6.boolean().optional().default(!0)})),providerInterface:z$6.string().optional(),walletStandard:z$6.object({features:z$6.array(z$6.string()),name:z$6.string(),providerId:z$6.string().optional()}).optional(),walletStandardLocators:z$6.array(z$6.object({locator:z$6.string(),name:z$6.string()})).optional(),windowLocations:z$6.array(z$6.string()).optional().refine(fr=>!fr||!fr.some(br=>["ethereum","ethereum.providers"].includes(br)),{message:"windowLocations cannot include ethereum or ethereum.providers as they are included by default",path:["config"]})}),brandSchema=z$6.object({alt:nonEmptyString,primaryColor:nonEmptyString,spriteId:nonEmptyString}),walletSchema=z$6.preprocess(fr=>fr,z$6.object({brand:brandSchema.optional(),chainGroup:z$6.string().optional(),chains:z$6.array(z$6.string()).optional(),desktop:z$6.object({chromeId:nonEmptyString.transform(transformChromeExtensionId),edgeId:nonEmptyString.transform(transformEdgeExtensionId),firefoxId:nonEmptyString.transform(transformFirefoxExtensionId),native:nonEmptyString,operaId:nonEmptyString,safariId:nonEmptyString,universal:nonEmptyString}).optional().transform(filterEmptyObject),eip6963Config:z$6.object({rdns:z$6.string()}).optional(),filterFromWalletConnect:z$6.boolean().optional(),group:z$6.string().optional(),hardwareWallets:z$6.array(z$6.string()).optional(),injectedConfig:z$6.array(injectedConfigSchema).optional(),mobile:z$6.object({android:stringType().nullish(),androidId:nonEmptyString.transform(transformAndroidId),inAppBrowser:stringType().nullish(),ios:stringType().nullish(),iosId:nonEmptyString.transform(transformIosId),native:nonEmptyString,universal:nonEmptyString}).optional().transform(filterEmptyObject),mobileExperience:z$6.enum(["in-app-browser","redirect"]).optional(),name:z$6.string(),shortName:nonEmptyString,showOnlyIfInstalled:z$6.boolean().optional(),switchNetworkOnlyFromWallet:z$6.boolean().optional(),walletConnect:z$6.object({sdks:nonEmptyStringArray}).optional().transform(filterEmptyObject),walletGroup:z$6.string().optional(),walletLimitations:z$6.object({browserExtension:z$6.object({unsupportedEvents:z$6.array(z$6.string()).optional(),unsupportedMethods:z$6.array(z$6.string()).optional()}).optional(),mobile:z$6.object({unsupportedEvents:z$6.array(z$6.string()).optional(),unsupportedMethods:z$6.array(z$6.string()).optional()}).optional()}).optional()})).transform(fr=>{var br,wr,Er,kr,jr,Br;return fr.group&&(fr.chainGroup=fr.group),(!((br=fr.mobile)===null||br===void 0)&&br.iosId||((wr=fr.mobile)===null||wr===void 0?void 0:wr.ios)===null)&&((Er=fr.mobile)===null||Er===void 0||delete Er.ios),(!((kr=fr.mobile)===null||kr===void 0)&&kr.androidId||((jr=fr.mobile)===null||jr===void 0?void 0:jr.android)===null)&&((Br=fr.mobile)===null||Br===void 0||delete Br.android),fr}),WalletOverrideEntrySchema=z$6.object({brand:brandSchema.optional(),name:nonEmptyString}),walletGroupSchema=z$6.object({brand:z$6.object({alt:nonEmptyString,primaryColor:nonEmptyString,spriteId:nonEmptyString}).optional(),key:z$6.string(),name:z$6.string(),walletOverrides:z$6.record(WalletOverrideEntrySchema).optional()});z$6.record(z$6.string(),walletSchema);z$6.preprocess(fr=>fr,z$6.object({groups:z$6.record(z$6.string(),walletGroupSchema),wallets:z$6.record(z$6.string(),walletSchema)}));z$6.record(z$6.string(),walletGroupSchema);assertPackageVersion("@dynamic-labs/wallet-book",version$1);const logger$1=new Logger$1("WalletConnector"),shouldLowercaseAddress=fr=>["eip155","flow","evm","eth","avax","matic"].includes(fr.toLowerCase()),normalizeAddress=(fr,br)=>(fr.startsWith("0x")&&(fr=fr.slice(2)),shouldLowercaseAddress(br)?fr.toLowerCase():fr),isSameAddress=(fr,br,wr)=>normalizeAddress(fr,wr)===normalizeAddress(br,wr);new EventEmitter$2;class Wallet extends BaseWallet{constructor(br){var{connector:wr}=br,Er=__rest(br,["connector"]);super(Er),this._connector=wr}get connector(){return this._connector}getBalance(){return __awaiter(this,void 0,void 0,function*(){return this._connector.getBalance(this.address)})}getNameService(){return __awaiter(this,void 0,void 0,function*(){return this._connector.getNameService(this.address)})}getNetwork(){return __awaiter(this,void 0,void 0,function*(){return this._connector.getNetwork()})}isConnected(){return __awaiter(this,void 0,void 0,function*(){try{return(yield this._connector.getConnectedAccounts()).map(wr=>normalizeAddress(wr,this.chain)).includes(normalizeAddress(this.address,this.chain))}catch(br){return logger$1.error("[Wallet] isConnected - Error detecting if wallet is connected",br),!1}})}proveOwnership(br){return __awaiter(this,void 0,void 0,function*(){return this._connector.proveOwnership(this.address,br)})}signMessage(br){return __awaiter(this,void 0,void 0,function*(){return yield this.sync(),this._connector.signMessage(br,this.address)})}switchNetwork(br){return __awaiter(this,void 0,void 0,function*(){return this._connector.switchNetwork({networkChainId:br})})}sync(){return __awaiter(this,void 0,void 0,function*(){return this._connector.validateActiveWallet(this.address)})}}assertPackageVersion("@dynamic-labs/wallet-connector-core",version$2);class SolanaWallet extends Wallet{getConnection(){return __awaiter$1(this,void 0,void 0,function*(){return this._connector.getWalletClient()})}getSigner(){return __awaiter$1(this,void 0,void 0,function*(){const br=yield this._connector.getSigner();if(!br)throw new Error("unable to retrieve Solana signer");try{return cloneObjectWithOverrides(br,{signAllTransactions:wr=>__awaiter$1(this,void 0,void 0,function*(){return yield this.sync(),br.signAllTransactions(wr)}),signAndSendTransaction:(wr,...Er)=>__awaiter$1(this,void 0,void 0,function*(){return yield this.sync(),br.signAndSendTransaction(wr,...Er)}),signMessage:(wr,...Er)=>__awaiter$1(this,void 0,void 0,function*(){return yield this.sync(),br.signMessage(wr,...Er)}),signTransaction:wr=>__awaiter$1(this,void 0,void 0,function*(){return yield this.sync(),br.signTransaction(wr)})})}catch(wr){return logger$1.warn(`Failed to add logic to auto-sync the wallet. Signer might be out of sync for wallet: ${this._connector.name} (${this.address})`,wr),br}})}}const SOLANA_GENESIS_HASH="genesis-hash",getGenesisHashLSKey=fr=>`${fr}_${SOLANA_GENESIS_HASH}`;new PublicKey$2("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");ChainRpcProviders.getSolanaProviderByChainId=(fr,br)=>{var wr;return(wr=fr.solana)===null||wr===void 0?void 0:wr.find(kr=>kr.chainId===br)};ChainRpcProviders.registerSolanaProviders=fr=>{ChainRpcProviders.registerChainProviders(ProviderChain.SOLANA,br=>{const wr={};return br!=null&&br.solana&&(wr.solana=br.solana.map(Er=>{var kr;const jr=((kr=Er.privateCustomerRpcUrls)===null||kr===void 0?void 0:kr[0])||Er.rpcUrls[0],Br=new Connection(jr,fr);return{chainId:Er.chainId.toString(),chainName:Er.name,provider:Br}})),wr.solana})};const isTxAlreadySigned=fr=>{let br=!1;return"version"in fr?br=fr.signatures.some(wr=>!wr.every(Er=>Er===0)):br=fr.signatures.some(wr=>wr.signature),br},LAMPORTS_PER_SOL=1e9;class SolanaUiTransaction{constructor({onSubmit:br,from:wr,connection:Er,multipleTransactions:kr}){this.chain="SOL",this.data=void 0,this.fee={gas:void 0},this.formatNonNativeToken=(jr,Br)=>(Number(jr)/Number(Math.pow(10,Br))).toString(),this.from=wr,this.onSubmit=br,this.connection=Er,this.multipleTransactions=kr}fetchFee(){return __awaiter$1(this,void 0,void 0,function*(){if(this.fee.gas)return;let br=this.multipleTransactions;if(!br){const Br=yield this.createTransactionSafe();if(!Br)return;br=Br instanceof Array?Br:[Br]}const{blockhash:wr}=yield this.connection.getLatestBlockhash(),Er=yield Promise.all(br.map(Br=>__awaiter$1(this,void 0,void 0,function*(){return"version"in Br?((yield isTxAlreadySigned(Br))||(Br.message.recentBlockhash=wr),Br.message):((yield isTxAlreadySigned(Br))||(Br.recentBlockhash=wr),Br.compileMessage())})));if(Er.some(Br=>!Br))throw new Error("Invalid transaction");const kr=Br=>__awaiter$1(this,void 0,void 0,function*(){let Wr=yield this.connection.getFeeForMessage(Br),qr=0;for(;Wr.value===null&&qr<5;)Wr=yield this.connection.getFeeForMessage(Br),qr++;return Wr.value?BigInt(Wr.value):BigInt(0)}),jr=yield Promise.all(Er.map(Br=>kr(Br)));this.fee.gas=jr.reduce((Br,Wr)=>Br+Wr,BigInt(0)),this.fee.gas===BigInt(0)&&(this.fee.gas=void 0)})}isGasSponsored(){var br;return!((br=this.multipleTransactions)===null||br===void 0)&&br.length?this.multipleTransactions.every(wr=>{var Er;return"version"in wr?this.from!==wr.message.staticAccountKeys[0].toBase58():"feePayer"in wr?this.from!==((Er=wr.feePayer)===null||Er===void 0?void 0:Er.toBase58()):!1}):!1}parse(br){const wr=parseFloat(br),Er=Math.round(wr*LAMPORTS_PER_SOL);return BigInt(Er)}parseNonNativeToken(br,wr){return BigInt(Math.floor(Number(br)*Math.pow(10,wr)))}format(br,{precision:wr}={}){const kr=(Number(br)/LAMPORTS_PER_SOL).toLocaleString("fullwide",{maximumFractionDigits:20,minimumFractionDigits:0,useGrouping:!1});return formatNumberText(kr,{precision:wr})}submit(){return __awaiter$1(this,void 0,void 0,function*(){if(this.multipleTransactions)return this.onSubmit();const br=yield this.createTransaction();return this.onSubmit(br)})}getBalance(){return __awaiter$1(this,void 0,void 0,function*(){const br=new PublicKey$2(this.from),wr=yield this.connection.getBalance(br);return BigInt(wr)})}validateAddressFormat(br){return br==="dyn_send_transaction.multiple_recipients"?!0:/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(br)}createTransaction(){return __awaiter$1(this,void 0,void 0,function*(){var br;const{value:wr,to:Er,nonNativeAddress:kr,nonNativeValue:jr}=this;if(!Er)throw new Error("Destination is required");if(this.multipleTransactions)return this.multipleTransactions;const Br=new Transaction,Wr=new PublicKey$2(this.from),qr=new PublicKey$2(Er);if(kr&&jr){const Vr=new PublicKey$2(kr),Zr=jr,Jr=(br=(yield this.connection.getTokenAccountsByOwner(Wr,{mint:Vr})).value[0])===null||br===void 0?void 0:br.pubkey;if(!Jr)throw new Error("Source token account not found");let Qr;try{Qr=yield getAssociatedTokenAddress(Vr,qr),yield this.connection.getTokenAccountBalance(Qr)}catch{Qr=yield getAssociatedTokenAddress(Vr,qr),Br.add(createAssociatedTokenAccountInstruction(Wr,Qr,qr,Vr))}Br.add(createTransferInstruction(Jr,Qr,Wr,Zr))}else{const Vr=wr??BigInt(0);Br.add(SystemProgram.transfer({fromPubkey:Wr,lamports:Vr,toPubkey:qr}))}const{blockhash:Hr}=yield this.connection.getLatestBlockhash();return Br.feePayer=new PublicKey$2(this.from),Br.recentBlockhash=Hr,Br})}createTransactionSafe(){return __awaiter$1(this,void 0,void 0,function*(){try{return yield this.createTransaction()}catch{return}})}}assertPackageVersion("@dynamic-labs/solana-core",version$3);const createSolanaConnection=(fr,br)=>{if(!fr)throw new Error("rpcUrl is required");return new Connection(fr,br)},logger=new Logger$1("DynamicSDK"),AUTH_MIN_TOKEN="dynamic_min_authentication_token",AUTH_MIN_TOKEN_DEMO="dynamic_min_authentication_token_demo",isCookieEnabled=()=>{var fr,br,wr,Er;let kr=(fr=StorageService.getItem("dynamic_store"))!==null&&fr!==void 0?fr:StorageService.getItem("dynamic_store_demo");if(kr=(br=kr==null?void 0:kr.settings)===null||br===void 0?void 0:br.security,!kr)return!1;const jr=(((wr=kr.auth)===null||wr===void 0?void 0:wr.storage)||[]).includes(AuthStorageEnum.Cookie),Br=!!(!((Er=kr.externalAuth)===null||Er===void 0)&&Er.cookieName);return jr||Br},parseToken=fr=>{var br;if(!fr)return;const wr=(br=fr.split(".")[1])===null||br===void 0?void 0:br.replace(/-/g,"+").replace(/_/g,"/"),Er=wr&&decodeURIComponent(atob(wr).split("").map(kr=>`%${`00${kr.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));return JSON.parse(Er)},decodeMinJwt=fr=>{try{const br=parseToken(fr);return br?MinifiedDynamicJwtFromJSON(br):void 0}catch(br){logger.error(br);return}},getMinAuthToken=()=>{var fr;if(typeof window>"u")return;const br=(fr=StorageService.getItem(AUTH_MIN_TOKEN,{priority:["secureStorage","localStorage"]}))!==null&&fr!==void 0?fr:StorageService.getItem(AUTH_MIN_TOKEN_DEMO,{priority:["secureStorage","localStorage"]});if(!(!br||isMinAuthTokenExpired(br)))return br},isMinAuthTokenExpired=fr=>{const br=decodeMinJwt(fr);return isTokenExpired(br)},isTokenExpired=fr=>{if(!fr||!fr.exp)return!0;const br=new Date(fr.exp*1e3).getTime();return new Date().getTime()>=br};class ApiEndpoint{}ApiEndpoint.getBaseUrl=()=>{if(!ApiEndpoint.__defined__)throw new Error("ApiEndpoint Base URL has not been initialized");return ApiEndpoint.__baseUrl__};ApiEndpoint.setBaseUrl=fr=>{if(!ApiEndpoint.__defined__)fr?ApiEndpoint.__baseUrl__=fr:ApiEndpoint.__baseUrl__=new Configuration().basePath,ApiEndpoint.__defined__=!0;else{if(!fr&&ApiEndpoint.__defined__)return;if(ApiEndpoint.__baseUrl__!==fr)throw new Error(`ApiEndpoint baseUrl is already set to ${ApiEndpoint.__baseUrl__}, cannot change it to ${fr}`)}Object.freeze(ApiEndpoint)};const VERSION=version$4,API_VERSION=dependencies["@dynamic-labs/sdk-api-core"];var define_process_env_default={};const sdkApi=()=>{const fr=define_process_env_default.API_BASE_URL||define_process_env_default.NX_API_BASE_URL||"https://app.dynamic.xyz/api/v0";ApiEndpoint.setBaseUrl(fr);const br={basePath:ApiEndpoint.getBaseUrl(),headers:{"Content-Type":"application/json"}},wr=getMinAuthToken();wr&&(br.headers.Authorization=`Bearer ${wr}`);const Er=isCookieEnabled()?"include":void 0;return br.headers["x-dyn-version"]=`WalletKit/${VERSION}`,br.headers["x-dyn-api-version"]=`API/${API_VERSION}`,new SDKApi(new Configuration(Object.assign(Object.assign({},br),{credentials:Er,fetchApi:FetchService.fetch})))},serializeTransaction=fr=>fr instanceof VersionedTransaction?Buffer$2.from(fr.serialize()).toString("base64"):Buffer$2.from(fr.serialize({verifySignatures:!1})).toString("base64"),deserializeTransaction=fr=>{const br=Buffer$2.from(fr,"base64");return VersionedTransaction.deserialize(br)},optimizeSolanaTransaction=(fr,br,wr)=>__awaiter$2(void 0,void 0,void 0,function*(){const Er=serializeTransaction(br),kr={environmentId:fr,solanaTransactionOptimizationRequest:{address:wr,transaction:Er}},jr=yield sdkApi().optimizeTransaction(kr);return deserializeTransaction(jr.transaction)});class TurnkeySolanaSigner{constructor({walletConnector:br}){this.isConnected=!0,this.providers=[this],this.walletConnector=br,this.turnkeyAddress=this.walletConnector.turnkeyAddress,this.publicKey=this.turnkeyAddress?new PublicKey$2(this.turnkeyAddress):void 0}signMessage(br){return __awaiter$2(this,void 0,void 0,function*(){return{signature:yield this.walletConnector.signUint8ArrayMessage(br)}})}signTransaction(br){return __awaiter$2(this,void 0,void 0,function*(){return this.walletConnector.signTransaction(br)})}signAllTransactions(br){return __awaiter$2(this,void 0,void 0,function*(){return this.walletConnector.signAllTransactions(br)})}signAndSendTransaction(br,wr){return __awaiter$2(this,void 0,void 0,function*(){return{signature:yield this.walletConnector.signAndSendTransaction(br,wr)}})}connect(br){return __awaiter$2(this,void 0,void 0,function*(){return{address:this.turnkeyAddress,publicKey:this.publicKey}})}disconnect(){return __awaiter$2(this,void 0,void 0,function*(){})}}class TurnkeySolanaWalletConnector extends TurnkeyWalletConnectorBase{constructor(br,wr){var Er;super(br,wr),this.ChainWallet=SolanaWallet,this.connectedChain="SOL",this.supportedChains=["SOL"],this.verifiedCredentialChain="solana",this.getEnvId=()=>{const kr=localStorage.getItem("dynamic_nonce");if(kr){const Br=JSON.parse(kr);if(Br&&Br.environmentId)return Br.environmentId}const jr=localStorage.getItem("dynamic_nonce_demo");if(jr){const Br=JSON.parse(jr);if(Br&&Br.environmentId)return Br.environmentId}throw new Error("Failed to get environment id")},this.stampCreateWalletAccountRequest=kr=>__awaiter$2(this,[kr],void 0,function*({request:jr}){return yield this.createOrRestoreSession(),this.getTurnkeyClient().stampCreateWalletAccounts(jr)}),this.solNetworks=wr.solNetworks,this.walletUiUtils=wr.walletUiUtils,this._turnkeyAccount=void 0,this._connectionClient=void 0,this.chainRpcProviders=wr.chainRpcProviders,this.connectionConfig=wr.connectionConfig,(Er=this.chainRpcProviders)===null||Er===void 0||Er.registerSolanaProviders(this.connectionConfig),this.__turnkeyClient=this.getTurnkeyClient()}getRpcUrl(){var br;const[wr]=this.solNetworks;if(!wr)throw new DynamicError("No enabled networks");return((br=wr.privateCustomerRpcUrls)===null||br===void 0?void 0:br[0])||wr.rpcUrls[0]}getConnection(br){if(!this._connectionClient){const wr=this.getRpcUrl();if(!wr)throw new DynamicError("No rpcUrl");const Er=typeof br=="string"?Object.assign(Object.assign({},this.connectionConfig),{commitment:br}):Object.assign(Object.assign({},this.connectionConfig),br);this._connectionClient=createSolanaConnection(wr,Er)}return this._connectionClient}getWalletClient(){return this.getConnection()}getNetwork(){return __awaiter$2(this,void 0,void 0,function*(){const br=this.getConnection();let wr=localStorage.getItem(getGenesisHashLSKey(br.rpcEndpoint));return wr||(wr=yield br.getGenesisHash(),localStorage.setItem(getGenesisHashLSKey(br.rpcEndpoint),wr)),wr=wr.substring(0,32),wr==="5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"?"mainnet":wr==="EtWTRABZaYq6iMfeYKouRu166VU2xqa1"?"devnet":"testnet"})}getPublicClient(){return __awaiter$2(this,void 0,void 0,function*(){var br;if(this.solNetworks.length===0)return;const wr={cosmos:[],evm:void 0,solana:this.solNetworks,starknet:void 0};if(!this.chainRpcProviders)return;const Er=this.chainRpcProviders.getProviders(wr);return(br=this.chainRpcProviders.getSolanaProviderByChainId(Er,"101"))===null||br===void 0?void 0:br.provider})}supportsNetworkSwitching(){return!1}setVerifiedCredentials(br){const wr=findTurnkeyVerifiedCredentials(br,ProviderChain.SOLANA),[Er]=wr;JSON.stringify(this.verifiedCredentials)!==JSON.stringify(wr)&&(this.verifiedCredential=Er,this.verifiedCredentials=wr,this.refreshTurnkeyAccount())}validateActiveWallet(br){return __awaiter$2(this,void 0,void 0,function*(){var wr,Er;const kr=((wr=this.verifiedCredential)===null||wr===void 0?void 0:wr.address)||"";if(!isSameAddress(kr,br,this.connectedChain)){const Br=(Er=this.verifiedCredentials)===null||Er===void 0?void 0:Er.find(Wr=>(Wr==null?void 0:Wr.address)===br);if(!Br)throw new DynamicError("Account not found");this.verifiedCredential=Br,this.refreshTurnkeyAccount()}})}getAccount(){return this.turnkeyAddress}endSession(){return __awaiter$2(this,void 0,void 0,function*(){localStorage.removeItem(getGenesisHashLSKey(this.getRpcUrl()))})}refreshTurnkeyAccount(){return __awaiter$2(this,void 0,void 0,function*(){return this._turnkeyAccount=void 0,this.getTurnkeyAccount()})}getTurnkeyClient(){var br;let wr=getTLD();wr||(wr=PlatformService.getHostname());const Er=PasskeyService.createWebauthnStamper({rpId:wr}),kr=TurnkeyWalletConnectorBase==null?void 0:TurnkeyWalletConnectorBase.apiKeyStamper,jr=kr??Er;return this.__turnkeyClient=(br=this.getAuthenticatorHandler().client)!==null&&br!==void 0?br:new TurnkeyClient({baseUrl:TURNKEY_API_BASE_URL},jr),this.__turnkeyClient}createTurnkeyAccount(br){return __awaiter$2(this,arguments,void 0,function*({organizationId:wr}){const Er=this.getTurnkeyClient();return new TurnkeySigner({client:Er,organizationId:wr})})}getTurnkeyAccount(){return __awaiter$2(this,void 0,void 0,function*(){var br,wr,Er,kr;if(this._turnkeyAccount&&(this.getAuthenticatorHandler().recoveryType==="passkey"&&((br=this.__turnkeyClient)===null||br===void 0?void 0:br.stamper)instanceof WebauthnStamper||this.getAuthenticatorHandler().recoveryType==="email"&&((wr=this.__turnkeyClient)===null||wr===void 0?void 0:wr.stamper)instanceof IframeStamper)&&this.__turnkeyClient===this.getAuthenticatorHandler().client)return this._turnkeyAccount;const{turnkeySubOrganizationId:jr}=(Er=this.walletProperties)!==null&&Er!==void 0?Er:{},{address:Br}=(kr=this.verifiedCredential)!==null&&kr!==void 0?kr:{};if(!(!jr||!Br))return this._turnkeyAccount=yield this.createTurnkeyAccount({organizationId:jr}),this.setLoggerMetadata(),this._turnkeyAccount})}getSigner(){return __awaiter$2(this,void 0,void 0,function*(){return new TurnkeySolanaSigner({walletConnector:this})})}getBalance(br){return __awaiter$2(this,void 0,void 0,function*(){const wr=this.getConnection(),Er=new PublicKey$2(br),kr=yield wr.getBalance(Er);return this.lamportsToSol(kr).toString()})}signUint8ArrayMessage(br){return __awaiter$2(this,void 0,void 0,function*(){if(!this.turnkeyAddress)throw new DynamicError("No turnkey account");const wr=this.turnkeyAddress;let Er;if(yield this.createOrRestoreSession(),yield this.walletUiUtils.signMessage({handler:()=>__awaiter$2(this,void 0,void 0,function*(){let kr=yield this.getTurnkeyAccount();try{Er=yield kr==null?void 0:kr.signMessage(br,wr)}catch{yield this.removeSessionKeys(),yield this.createOrRestoreSession({ignoreRestore:!0}),kr=yield this.getTurnkeyAccount(),Er=yield kr==null?void 0:kr.signMessage(br,wr)}return bufferToBase64(Er||Buffer$2.from([]))}),message:new TextDecoder().decode(br)}),!Er)throw new Error("Failed to sign message");return Er})}signMessage(br){return __awaiter$2(this,void 0,void 0,function*(){const Er=new TextEncoder().encode(br),kr=yield this.signUint8ArrayMessage(Er);return bufferToBase64(kr)})}internalSignTransaction(br){return __awaiter$2(this,void 0,void 0,function*(){yield this.createOrRestoreSession();let wr=yield this.getTurnkeyAccount();const Er=this.turnkeyAddress;if(!wr||!Er)throw new Error("No turnkey account");try{yield wr.addSignature(br,Er)}catch(kr){if(TURNKEY_SDK_SESSION_KEY_RETRYABLE_ERRORS.some(jr=>kr.message.includes(jr)))yield this.removeSessionKeys(),yield this.createOrRestoreSession({ignoreRestore:!0}),wr=yield this.getTurnkeyAccount(),yield wr.addSignature(br,Er);else throw logger$4.error("[TK] failed to perform SignTransaction activity",kr),kr}return br})}signTransaction(br){return __awaiter$2(this,void 0,void 0,function*(){if(!this.turnkeyAddress)throw new DynamicError("No turnkey account");const wr=new SolanaUiTransaction({connection:this.getConnection("confirmed"),from:this.turnkeyAddress,multipleTransactions:[br],onSubmit:()=>__awaiter$2(this,void 0,void 0,function*(){return this.internalSignTransaction(br)})});return this.walletUiUtils.signTransaction(this,wr)})}createUiTransaction(br){return __awaiter$2(this,void 0,void 0,function*(){return yield this.validateActiveWallet(br),new SolanaUiTransaction({connection:this.getConnection("confirmed"),from:br,onSubmit:Er=>__awaiter$2(this,void 0,void 0,function*(){if(Er)return this.internalSignAndSendTransaction(Er)})})})}internalSignAllTransactions(br){return __awaiter$2(this,void 0,void 0,function*(){yield this.createOrRestoreSession();let wr=yield this.getTurnkeyAccount();const Er=this.turnkeyAddress;if(!wr||!Er)throw new Error("No turnkey account");try{return yield wr.signAllTransactions(br,Er)}catch(kr){if(TURNKEY_SDK_SESSION_KEY_RETRYABLE_ERRORS.some(jr=>kr.message.includes(jr)))return yield this.removeSessionKeys(),yield this.createOrRestoreSession({ignoreRestore:!0}),wr=yield this.getTurnkeyAccount(),yield wr.signAllTransactions(br,Er);throw logger$4.error("[TK] failed to perform SignAllTransactions activity",kr),kr}})}signAllTransactions(br){return __awaiter$2(this,void 0,void 0,function*(){if(!this.turnkeyAddress)throw new DynamicError("No turnkey account");const wr=new SolanaUiTransaction({connection:this.getConnection("confirmed"),from:this.turnkeyAddress,multipleTransactions:br,onSubmit:()=>__awaiter$2(this,void 0,void 0,function*(){return this.internalSignAllTransactions(br)})});return this.walletUiUtils.signTransaction(this,wr)})}internalSignAndSendTransaction(br,wr){return __awaiter$2(this,void 0,void 0,function*(){var Er,kr;if(!this.turnkeyAddress)throw new DynamicError("Solana wallet not found");const jr=this.getConnection((kr=(Er=this.connectionConfig)===null||Er===void 0?void 0:Er.commitment)!==null&&kr!==void 0?kr:"confirmed"),Br=yield this.internalSignTransaction(br),Wr=yield jr.sendRawTransaction(Br.serialize(),wr);return new Promise((qr,Hr)=>{const Vr=setTimeout(()=>{Hr(new DynamicError("Transaction timed out"))},6e4);jr.onSignature(Wr,Zr=>{clearTimeout(Vr),Zr.err?Hr(new DynamicError("Transaction failed")):qr(Wr)},"confirmed")})})}signAndSendTransaction(br,wr){return __awaiter$2(this,void 0,void 0,function*(){if(!this.turnkeyAddress)throw new DynamicError("Solana wallet not found");const Er=yield this.optimizeTransaction(br),kr=new SolanaUiTransaction({connection:this.getConnection("confirmed"),from:this.turnkeyAddress,multipleTransactions:[Er],onSubmit:()=>__awaiter$2(this,void 0,void 0,function*(){return this.internalSignAndSendTransaction(Er,wr)})});return this.walletUiUtils.sendTransaction(this,kr)})}sendTransaction(br,wr){return __awaiter$2(this,arguments,void 0,function*(Er,kr,jr={}){var Br;if(!this.turnkeyAddress)throw new DynamicError("Solana wallet not found");if(!Er||!kr)throw new DynamicError("Transaction and connection are required");const{signers:Wr}=jr,qr=__rest$1(jr,["signers"]),Hr=yield kr.getLatestBlockhash({commitment:jr.preflightCommitment,minContextSlot:jr.minContextSlot});"version"in Er?Wr!=null&&Wr.length&&Er.sign(Wr):(Er.feePayer=Er.feePayer||new PublicKey$2(this.turnkeyAddress),Er.recentBlockhash=Er.recentBlockhash||Hr.blockhash,Wr!=null&&Wr.length&&Er.partialSign(...Wr)),qr.preflightCommitment=qr.preflightCommitment||kr.commitment;const Vr=yield kr.sendRawTransaction(Er.serialize(),jr),Zr={blockhash:Hr.blockhash,lastValidBlockHeight:Hr.lastValidBlockHeight,signature:Vr},Jr=yield kr==null?void 0:kr.confirmTransaction(Zr);return!((Br=Jr==null?void 0:Jr.value)===null||Br===void 0)&&Br.err?JSON.stringify(Jr.value.err):Vr})}lamportsToSol(br){return br/LAMPORTS_PER_SOL$2}optimizeTransaction(br){return __awaiter$2(this,void 0,void 0,function*(){var wr;let Er=br;try{(yield this.getNetwork())==="mainnet"&&!isTxAlreadySigned(br)&&(Er=yield optimizeSolanaTransaction(this.getEnvId(),br,(wr=this.turnkeyAddress)!==null&&wr!==void 0?wr:""))}catch(kr){logger$4.warn("Failed to optimize transaction",kr)}return Er})}}const TurnkeySolanaWalletConnectors=fr=>{var br;return!((br=fr.apiProviders)===null||br===void 0)&&br.turnkey?[class extends TurnkeySolanaWalletConnector{constructor(wr){super(TurnkeyWalletConnectorInfo.TurnkeyHD,Object.assign(Object.assign({},fr),wr))}}]:[]};assertPackageVersion("@dynamic-labs/embedded-wallet-solana",version$4);var naclFast={exports:{}};(function(fr){(function(br){var wr=function(So){var Co,Ao=new Float64Array(16);if(So)for(Co=0;Co>24&255,So[Co+1]=Ao>>16&255,So[Co+2]=Ao>>8&255,So[Co+3]=Ao&255,So[Co+4]=po>>24&255,So[Co+5]=po>>16&255,So[Co+6]=po>>8&255,So[Co+7]=po&255}function En(So,Co,Ao,po,Ro){var Xo,jo=0;for(Xo=0;Xo>>8)-1}function Cn(So,Co,Ao,po){return En(So,Co,Ao,po,16)}function In(So,Co,Ao,po){return En(So,Co,Ao,po,32)}function An(So,Co,Ao,po){for(var Ro=po[0]&255|(po[1]&255)<<8|(po[2]&255)<<16|(po[3]&255)<<24,Xo=Ao[0]&255|(Ao[1]&255)<<8|(Ao[2]&255)<<16|(Ao[3]&255)<<24,jo=Ao[4]&255|(Ao[5]&255)<<8|(Ao[6]&255)<<16|(Ao[7]&255)<<24,Ko=Ao[8]&255|(Ao[9]&255)<<8|(Ao[10]&255)<<16|(Ao[11]&255)<<24,Wl=Ao[12]&255|(Ao[13]&255)<<8|(Ao[14]&255)<<16|(Ao[15]&255)<<24,$l=po[4]&255|(po[5]&255)<<8|(po[6]&255)<<16|(po[7]&255)<<24,El=Co[0]&255|(Co[1]&255)<<8|(Co[2]&255)<<16|(Co[3]&255)<<24,Cu=Co[4]&255|(Co[5]&255)<<8|(Co[6]&255)<<16|(Co[7]&255)<<24,iu=Co[8]&255|(Co[9]&255)<<8|(Co[10]&255)<<16|(Co[11]&255)<<24,pu=Co[12]&255|(Co[13]&255)<<8|(Co[14]&255)<<16|(Co[15]&255)<<24,yu=po[8]&255|(po[9]&255)<<8|(po[10]&255)<<16|(po[11]&255)<<24,hu=Ao[16]&255|(Ao[17]&255)<<8|(Ao[18]&255)<<16|(Ao[19]&255)<<24,mu=Ao[20]&255|(Ao[21]&255)<<8|(Ao[22]&255)<<16|(Ao[23]&255)<<24,vu=Ao[24]&255|(Ao[25]&255)<<8|(Ao[26]&255)<<16|(Ao[27]&255)<<24,fu=Ao[28]&255|(Ao[29]&255)<<8|(Ao[30]&255)<<16|(Ao[31]&255)<<24,gu=po[12]&255|(po[13]&255)<<8|(po[14]&255)<<16|(po[15]&255)<<24,ou=Ro,su=Xo,tu=jo,zl=Ko,Gl=Wl,Jl=$l,Pl=El,Fl=Cu,Yl=iu,Vl=pu,Ql=yu,au=hu,Nu=mu,Wu=vu,zu=fu,Bu=gu,Qo,Zu=0;Zu<20;Zu+=2)Qo=ou+Nu|0,Gl^=Qo<<7|Qo>>>25,Qo=Gl+ou|0,Yl^=Qo<<9|Qo>>>23,Qo=Yl+Gl|0,Nu^=Qo<<13|Qo>>>19,Qo=Nu+Yl|0,ou^=Qo<<18|Qo>>>14,Qo=Jl+su|0,Vl^=Qo<<7|Qo>>>25,Qo=Vl+Jl|0,Wu^=Qo<<9|Qo>>>23,Qo=Wu+Vl|0,su^=Qo<<13|Qo>>>19,Qo=su+Wu|0,Jl^=Qo<<18|Qo>>>14,Qo=Ql+Pl|0,zu^=Qo<<7|Qo>>>25,Qo=zu+Ql|0,tu^=Qo<<9|Qo>>>23,Qo=tu+zu|0,Pl^=Qo<<13|Qo>>>19,Qo=Pl+tu|0,Ql^=Qo<<18|Qo>>>14,Qo=Bu+au|0,zl^=Qo<<7|Qo>>>25,Qo=zl+Bu|0,Fl^=Qo<<9|Qo>>>23,Qo=Fl+zl|0,au^=Qo<<13|Qo>>>19,Qo=au+Fl|0,Bu^=Qo<<18|Qo>>>14,Qo=ou+zl|0,su^=Qo<<7|Qo>>>25,Qo=su+ou|0,tu^=Qo<<9|Qo>>>23,Qo=tu+su|0,zl^=Qo<<13|Qo>>>19,Qo=zl+tu|0,ou^=Qo<<18|Qo>>>14,Qo=Jl+Gl|0,Pl^=Qo<<7|Qo>>>25,Qo=Pl+Jl|0,Fl^=Qo<<9|Qo>>>23,Qo=Fl+Pl|0,Gl^=Qo<<13|Qo>>>19,Qo=Gl+Fl|0,Jl^=Qo<<18|Qo>>>14,Qo=Ql+Vl|0,au^=Qo<<7|Qo>>>25,Qo=au+Ql|0,Yl^=Qo<<9|Qo>>>23,Qo=Yl+au|0,Vl^=Qo<<13|Qo>>>19,Qo=Vl+Yl|0,Ql^=Qo<<18|Qo>>>14,Qo=Bu+zu|0,Nu^=Qo<<7|Qo>>>25,Qo=Nu+Bu|0,Wu^=Qo<<9|Qo>>>23,Qo=Wu+Nu|0,zu^=Qo<<13|Qo>>>19,Qo=zu+Wu|0,Bu^=Qo<<18|Qo>>>14;ou=ou+Ro|0,su=su+Xo|0,tu=tu+jo|0,zl=zl+Ko|0,Gl=Gl+Wl|0,Jl=Jl+$l|0,Pl=Pl+El|0,Fl=Fl+Cu|0,Yl=Yl+iu|0,Vl=Vl+pu|0,Ql=Ql+yu|0,au=au+hu|0,Nu=Nu+mu|0,Wu=Wu+vu|0,zu=zu+fu|0,Bu=Bu+gu|0,So[0]=ou>>>0&255,So[1]=ou>>>8&255,So[2]=ou>>>16&255,So[3]=ou>>>24&255,So[4]=su>>>0&255,So[5]=su>>>8&255,So[6]=su>>>16&255,So[7]=su>>>24&255,So[8]=tu>>>0&255,So[9]=tu>>>8&255,So[10]=tu>>>16&255,So[11]=tu>>>24&255,So[12]=zl>>>0&255,So[13]=zl>>>8&255,So[14]=zl>>>16&255,So[15]=zl>>>24&255,So[16]=Gl>>>0&255,So[17]=Gl>>>8&255,So[18]=Gl>>>16&255,So[19]=Gl>>>24&255,So[20]=Jl>>>0&255,So[21]=Jl>>>8&255,So[22]=Jl>>>16&255,So[23]=Jl>>>24&255,So[24]=Pl>>>0&255,So[25]=Pl>>>8&255,So[26]=Pl>>>16&255,So[27]=Pl>>>24&255,So[28]=Fl>>>0&255,So[29]=Fl>>>8&255,So[30]=Fl>>>16&255,So[31]=Fl>>>24&255,So[32]=Yl>>>0&255,So[33]=Yl>>>8&255,So[34]=Yl>>>16&255,So[35]=Yl>>>24&255,So[36]=Vl>>>0&255,So[37]=Vl>>>8&255,So[38]=Vl>>>16&255,So[39]=Vl>>>24&255,So[40]=Ql>>>0&255,So[41]=Ql>>>8&255,So[42]=Ql>>>16&255,So[43]=Ql>>>24&255,So[44]=au>>>0&255,So[45]=au>>>8&255,So[46]=au>>>16&255,So[47]=au>>>24&255,So[48]=Nu>>>0&255,So[49]=Nu>>>8&255,So[50]=Nu>>>16&255,So[51]=Nu>>>24&255,So[52]=Wu>>>0&255,So[53]=Wu>>>8&255,So[54]=Wu>>>16&255,So[55]=Wu>>>24&255,So[56]=zu>>>0&255,So[57]=zu>>>8&255,So[58]=zu>>>16&255,So[59]=zu>>>24&255,So[60]=Bu>>>0&255,So[61]=Bu>>>8&255,So[62]=Bu>>>16&255,So[63]=Bu>>>24&255}function jn(So,Co,Ao,po){for(var Ro=po[0]&255|(po[1]&255)<<8|(po[2]&255)<<16|(po[3]&255)<<24,Xo=Ao[0]&255|(Ao[1]&255)<<8|(Ao[2]&255)<<16|(Ao[3]&255)<<24,jo=Ao[4]&255|(Ao[5]&255)<<8|(Ao[6]&255)<<16|(Ao[7]&255)<<24,Ko=Ao[8]&255|(Ao[9]&255)<<8|(Ao[10]&255)<<16|(Ao[11]&255)<<24,Wl=Ao[12]&255|(Ao[13]&255)<<8|(Ao[14]&255)<<16|(Ao[15]&255)<<24,$l=po[4]&255|(po[5]&255)<<8|(po[6]&255)<<16|(po[7]&255)<<24,El=Co[0]&255|(Co[1]&255)<<8|(Co[2]&255)<<16|(Co[3]&255)<<24,Cu=Co[4]&255|(Co[5]&255)<<8|(Co[6]&255)<<16|(Co[7]&255)<<24,iu=Co[8]&255|(Co[9]&255)<<8|(Co[10]&255)<<16|(Co[11]&255)<<24,pu=Co[12]&255|(Co[13]&255)<<8|(Co[14]&255)<<16|(Co[15]&255)<<24,yu=po[8]&255|(po[9]&255)<<8|(po[10]&255)<<16|(po[11]&255)<<24,hu=Ao[16]&255|(Ao[17]&255)<<8|(Ao[18]&255)<<16|(Ao[19]&255)<<24,mu=Ao[20]&255|(Ao[21]&255)<<8|(Ao[22]&255)<<16|(Ao[23]&255)<<24,vu=Ao[24]&255|(Ao[25]&255)<<8|(Ao[26]&255)<<16|(Ao[27]&255)<<24,fu=Ao[28]&255|(Ao[29]&255)<<8|(Ao[30]&255)<<16|(Ao[31]&255)<<24,gu=po[12]&255|(po[13]&255)<<8|(po[14]&255)<<16|(po[15]&255)<<24,ou=Ro,su=Xo,tu=jo,zl=Ko,Gl=Wl,Jl=$l,Pl=El,Fl=Cu,Yl=iu,Vl=pu,Ql=yu,au=hu,Nu=mu,Wu=vu,zu=fu,Bu=gu,Qo,Zu=0;Zu<20;Zu+=2)Qo=ou+Nu|0,Gl^=Qo<<7|Qo>>>25,Qo=Gl+ou|0,Yl^=Qo<<9|Qo>>>23,Qo=Yl+Gl|0,Nu^=Qo<<13|Qo>>>19,Qo=Nu+Yl|0,ou^=Qo<<18|Qo>>>14,Qo=Jl+su|0,Vl^=Qo<<7|Qo>>>25,Qo=Vl+Jl|0,Wu^=Qo<<9|Qo>>>23,Qo=Wu+Vl|0,su^=Qo<<13|Qo>>>19,Qo=su+Wu|0,Jl^=Qo<<18|Qo>>>14,Qo=Ql+Pl|0,zu^=Qo<<7|Qo>>>25,Qo=zu+Ql|0,tu^=Qo<<9|Qo>>>23,Qo=tu+zu|0,Pl^=Qo<<13|Qo>>>19,Qo=Pl+tu|0,Ql^=Qo<<18|Qo>>>14,Qo=Bu+au|0,zl^=Qo<<7|Qo>>>25,Qo=zl+Bu|0,Fl^=Qo<<9|Qo>>>23,Qo=Fl+zl|0,au^=Qo<<13|Qo>>>19,Qo=au+Fl|0,Bu^=Qo<<18|Qo>>>14,Qo=ou+zl|0,su^=Qo<<7|Qo>>>25,Qo=su+ou|0,tu^=Qo<<9|Qo>>>23,Qo=tu+su|0,zl^=Qo<<13|Qo>>>19,Qo=zl+tu|0,ou^=Qo<<18|Qo>>>14,Qo=Jl+Gl|0,Pl^=Qo<<7|Qo>>>25,Qo=Pl+Jl|0,Fl^=Qo<<9|Qo>>>23,Qo=Fl+Pl|0,Gl^=Qo<<13|Qo>>>19,Qo=Gl+Fl|0,Jl^=Qo<<18|Qo>>>14,Qo=Ql+Vl|0,au^=Qo<<7|Qo>>>25,Qo=au+Ql|0,Yl^=Qo<<9|Qo>>>23,Qo=Yl+au|0,Vl^=Qo<<13|Qo>>>19,Qo=Vl+Yl|0,Ql^=Qo<<18|Qo>>>14,Qo=Bu+zu|0,Nu^=Qo<<7|Qo>>>25,Qo=Nu+Bu|0,Wu^=Qo<<9|Qo>>>23,Qo=Wu+Nu|0,zu^=Qo<<13|Qo>>>19,Qo=zu+Wu|0,Bu^=Qo<<18|Qo>>>14;So[0]=ou>>>0&255,So[1]=ou>>>8&255,So[2]=ou>>>16&255,So[3]=ou>>>24&255,So[4]=Jl>>>0&255,So[5]=Jl>>>8&255,So[6]=Jl>>>16&255,So[7]=Jl>>>24&255,So[8]=Ql>>>0&255,So[9]=Ql>>>8&255,So[10]=Ql>>>16&255,So[11]=Ql>>>24&255,So[12]=Bu>>>0&255,So[13]=Bu>>>8&255,So[14]=Bu>>>16&255,So[15]=Bu>>>24&255,So[16]=Pl>>>0&255,So[17]=Pl>>>8&255,So[18]=Pl>>>16&255,So[19]=Pl>>>24&255,So[20]=Fl>>>0&255,So[21]=Fl>>>8&255,So[22]=Fl>>>16&255,So[23]=Fl>>>24&255,So[24]=Yl>>>0&255,So[25]=Yl>>>8&255,So[26]=Yl>>>16&255,So[27]=Yl>>>24&255,So[28]=Vl>>>0&255,So[29]=Vl>>>8&255,So[30]=Vl>>>16&255,So[31]=Vl>>>24&255}function eo(So,Co,Ao,po){An(So,Co,Ao,po)}function ro(So,Co,Ao,po){jn(So,Co,Ao,po)}var to=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _i(So,Co,Ao,po,Ro,Xo,jo){var Ko=new Uint8Array(16),Wl=new Uint8Array(64),$l,El;for(El=0;El<16;El++)Ko[El]=0;for(El=0;El<8;El++)Ko[El]=Xo[El];for(;Ro>=64;){for(eo(Wl,Ko,jo,to),El=0;El<64;El++)So[Co+El]=Ao[po+El]^Wl[El];for($l=1,El=8;El<16;El++)$l=$l+(Ko[El]&255)|0,Ko[El]=$l&255,$l>>>=8;Ro-=64,Co+=64,po+=64}if(Ro>0)for(eo(Wl,Ko,jo,to),El=0;El=64;){for(eo(jo,Xo,Ro,to),Wl=0;Wl<64;Wl++)So[Co+Wl]=jo[Wl];for(Ko=1,Wl=8;Wl<16;Wl++)Ko=Ko+(Xo[Wl]&255)|0,Xo[Wl]=Ko&255,Ko>>>=8;Ao-=64,Co+=64}if(Ao>0)for(eo(jo,Xo,Ro,to),Wl=0;Wl>>13|Ao<<3)&8191,po=So[4]&255|(So[5]&255)<<8,this.r[2]=(Ao>>>10|po<<6)&7939,Ro=So[6]&255|(So[7]&255)<<8,this.r[3]=(po>>>7|Ro<<9)&8191,Xo=So[8]&255|(So[9]&255)<<8,this.r[4]=(Ro>>>4|Xo<<12)&255,this.r[5]=Xo>>>1&8190,jo=So[10]&255|(So[11]&255)<<8,this.r[6]=(Xo>>>14|jo<<2)&8191,Ko=So[12]&255|(So[13]&255)<<8,this.r[7]=(jo>>>11|Ko<<5)&8065,Wl=So[14]&255|(So[15]&255)<<8,this.r[8]=(Ko>>>8|Wl<<8)&8191,this.r[9]=Wl>>>5&127,this.pad[0]=So[16]&255|(So[17]&255)<<8,this.pad[1]=So[18]&255|(So[19]&255)<<8,this.pad[2]=So[20]&255|(So[21]&255)<<8,this.pad[3]=So[22]&255|(So[23]&255)<<8,this.pad[4]=So[24]&255|(So[25]&255)<<8,this.pad[5]=So[26]&255|(So[27]&255)<<8,this.pad[6]=So[28]&255|(So[29]&255)<<8,this.pad[7]=So[30]&255|(So[31]&255)<<8};so.prototype.blocks=function(So,Co,Ao){for(var po=this.fin?0:2048,Ro,Xo,jo,Ko,Wl,$l,El,Cu,iu,pu,yu,hu,mu,vu,fu,gu,ou,su,tu,zl=this.h[0],Gl=this.h[1],Jl=this.h[2],Pl=this.h[3],Fl=this.h[4],Yl=this.h[5],Vl=this.h[6],Ql=this.h[7],au=this.h[8],Nu=this.h[9],Wu=this.r[0],zu=this.r[1],Bu=this.r[2],Qo=this.r[3],Zu=this.r[4],Qu=this.r[5],_h=this.r[6],qu=this.r[7],Ju=this.r[8],_d=this.r[9];Ao>=16;)Ro=So[Co+0]&255|(So[Co+1]&255)<<8,zl+=Ro&8191,Xo=So[Co+2]&255|(So[Co+3]&255)<<8,Gl+=(Ro>>>13|Xo<<3)&8191,jo=So[Co+4]&255|(So[Co+5]&255)<<8,Jl+=(Xo>>>10|jo<<6)&8191,Ko=So[Co+6]&255|(So[Co+7]&255)<<8,Pl+=(jo>>>7|Ko<<9)&8191,Wl=So[Co+8]&255|(So[Co+9]&255)<<8,Fl+=(Ko>>>4|Wl<<12)&8191,Yl+=Wl>>>1&8191,$l=So[Co+10]&255|(So[Co+11]&255)<<8,Vl+=(Wl>>>14|$l<<2)&8191,El=So[Co+12]&255|(So[Co+13]&255)<<8,Ql+=($l>>>11|El<<5)&8191,Cu=So[Co+14]&255|(So[Co+15]&255)<<8,au+=(El>>>8|Cu<<8)&8191,Nu+=Cu>>>5|po,iu=0,pu=iu,pu+=zl*Wu,pu+=Gl*(5*_d),pu+=Jl*(5*Ju),pu+=Pl*(5*qu),pu+=Fl*(5*_h),iu=pu>>>13,pu&=8191,pu+=Yl*(5*Qu),pu+=Vl*(5*Zu),pu+=Ql*(5*Qo),pu+=au*(5*Bu),pu+=Nu*(5*zu),iu+=pu>>>13,pu&=8191,yu=iu,yu+=zl*zu,yu+=Gl*Wu,yu+=Jl*(5*_d),yu+=Pl*(5*Ju),yu+=Fl*(5*qu),iu=yu>>>13,yu&=8191,yu+=Yl*(5*_h),yu+=Vl*(5*Qu),yu+=Ql*(5*Zu),yu+=au*(5*Qo),yu+=Nu*(5*Bu),iu+=yu>>>13,yu&=8191,hu=iu,hu+=zl*Bu,hu+=Gl*zu,hu+=Jl*Wu,hu+=Pl*(5*_d),hu+=Fl*(5*Ju),iu=hu>>>13,hu&=8191,hu+=Yl*(5*qu),hu+=Vl*(5*_h),hu+=Ql*(5*Qu),hu+=au*(5*Zu),hu+=Nu*(5*Qo),iu+=hu>>>13,hu&=8191,mu=iu,mu+=zl*Qo,mu+=Gl*Bu,mu+=Jl*zu,mu+=Pl*Wu,mu+=Fl*(5*_d),iu=mu>>>13,mu&=8191,mu+=Yl*(5*Ju),mu+=Vl*(5*qu),mu+=Ql*(5*_h),mu+=au*(5*Qu),mu+=Nu*(5*Zu),iu+=mu>>>13,mu&=8191,vu=iu,vu+=zl*Zu,vu+=Gl*Qo,vu+=Jl*Bu,vu+=Pl*zu,vu+=Fl*Wu,iu=vu>>>13,vu&=8191,vu+=Yl*(5*_d),vu+=Vl*(5*Ju),vu+=Ql*(5*qu),vu+=au*(5*_h),vu+=Nu*(5*Qu),iu+=vu>>>13,vu&=8191,fu=iu,fu+=zl*Qu,fu+=Gl*Zu,fu+=Jl*Qo,fu+=Pl*Bu,fu+=Fl*zu,iu=fu>>>13,fu&=8191,fu+=Yl*Wu,fu+=Vl*(5*_d),fu+=Ql*(5*Ju),fu+=au*(5*qu),fu+=Nu*(5*_h),iu+=fu>>>13,fu&=8191,gu=iu,gu+=zl*_h,gu+=Gl*Qu,gu+=Jl*Zu,gu+=Pl*Qo,gu+=Fl*Bu,iu=gu>>>13,gu&=8191,gu+=Yl*zu,gu+=Vl*Wu,gu+=Ql*(5*_d),gu+=au*(5*Ju),gu+=Nu*(5*qu),iu+=gu>>>13,gu&=8191,ou=iu,ou+=zl*qu,ou+=Gl*_h,ou+=Jl*Qu,ou+=Pl*Zu,ou+=Fl*Qo,iu=ou>>>13,ou&=8191,ou+=Yl*Bu,ou+=Vl*zu,ou+=Ql*Wu,ou+=au*(5*_d),ou+=Nu*(5*Ju),iu+=ou>>>13,ou&=8191,su=iu,su+=zl*Ju,su+=Gl*qu,su+=Jl*_h,su+=Pl*Qu,su+=Fl*Zu,iu=su>>>13,su&=8191,su+=Yl*Qo,su+=Vl*Bu,su+=Ql*zu,su+=au*Wu,su+=Nu*(5*_d),iu+=su>>>13,su&=8191,tu=iu,tu+=zl*_d,tu+=Gl*Ju,tu+=Jl*qu,tu+=Pl*_h,tu+=Fl*Qu,iu=tu>>>13,tu&=8191,tu+=Yl*Zu,tu+=Vl*Qo,tu+=Ql*Bu,tu+=au*zu,tu+=Nu*Wu,iu+=tu>>>13,tu&=8191,iu=(iu<<2)+iu|0,iu=iu+pu|0,pu=iu&8191,iu=iu>>>13,yu+=iu,zl=pu,Gl=yu,Jl=hu,Pl=mu,Fl=vu,Yl=fu,Vl=gu,Ql=ou,au=su,Nu=tu,Co+=16,Ao-=16;this.h[0]=zl,this.h[1]=Gl,this.h[2]=Jl,this.h[3]=Pl,this.h[4]=Fl,this.h[5]=Yl,this.h[6]=Vl,this.h[7]=Ql,this.h[8]=au,this.h[9]=Nu},so.prototype.finish=function(So,Co){var Ao=new Uint16Array(10),po,Ro,Xo,jo;if(this.leftover){for(jo=this.leftover,this.buffer[jo++]=1;jo<16;jo++)this.buffer[jo]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(po=this.h[1]>>>13,this.h[1]&=8191,jo=2;jo<10;jo++)this.h[jo]+=po,po=this.h[jo]>>>13,this.h[jo]&=8191;for(this.h[0]+=po*5,po=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=po,po=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=po,Ao[0]=this.h[0]+5,po=Ao[0]>>>13,Ao[0]&=8191,jo=1;jo<10;jo++)Ao[jo]=this.h[jo]+po,po=Ao[jo]>>>13,Ao[jo]&=8191;for(Ao[9]-=8192,Ro=(po^1)-1,jo=0;jo<10;jo++)Ao[jo]&=Ro;for(Ro=~Ro,jo=0;jo<10;jo++)this.h[jo]=this.h[jo]&Ro|Ao[jo];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,Xo=this.h[0]+this.pad[0],this.h[0]=Xo&65535,jo=1;jo<8;jo++)Xo=(this.h[jo]+this.pad[jo]|0)+(Xo>>>16)|0,this.h[jo]=Xo&65535;So[Co+0]=this.h[0]>>>0&255,So[Co+1]=this.h[0]>>>8&255,So[Co+2]=this.h[1]>>>0&255,So[Co+3]=this.h[1]>>>8&255,So[Co+4]=this.h[2]>>>0&255,So[Co+5]=this.h[2]>>>8&255,So[Co+6]=this.h[3]>>>0&255,So[Co+7]=this.h[3]>>>8&255,So[Co+8]=this.h[4]>>>0&255,So[Co+9]=this.h[4]>>>8&255,So[Co+10]=this.h[5]>>>0&255,So[Co+11]=this.h[5]>>>8&255,So[Co+12]=this.h[6]>>>0&255,So[Co+13]=this.h[6]>>>8&255,So[Co+14]=this.h[7]>>>0&255,So[Co+15]=this.h[7]>>>8&255},so.prototype.update=function(So,Co,Ao){var po,Ro;if(this.leftover){for(Ro=16-this.leftover,Ro>Ao&&(Ro=Ao),po=0;po=16&&(Ro=Ao-Ao%16,this.blocks(So,Co,Ro),Co+=Ro,Ao-=Ro),Ao){for(po=0;po>16&1),Xo[Ao-1]&=65535;Xo[15]=jo[15]-32767-(Xo[14]>>16&1),Ro=Xo[15]>>16&1,Xo[14]&=65535,Pn(jo,Xo,1-Ro)}for(Ao=0;Ao<16;Ao++)So[2*Ao]=jo[Ao]&255,So[2*Ao+1]=jo[Ao]>>8}function Zn(So,Co){var Ao=new Uint8Array(32),po=new Uint8Array(32);return On(Ao,So),On(po,Co),In(Ao,0,po,0)}function Nn(So){var Co=new Uint8Array(32);return On(Co,So),Co[0]&1}function wn(So,Co){var Ao;for(Ao=0;Ao<16;Ao++)So[Ao]=Co[2*Ao]+(Co[2*Ao+1]<<8);So[15]&=32767}function zn(So,Co,Ao){for(var po=0;po<16;po++)So[po]=Co[po]+Ao[po]}function fo(So,Co,Ao){for(var po=0;po<16;po++)So[po]=Co[po]-Ao[po]}function vo(So,Co,Ao){var po,Ro,Xo=0,jo=0,Ko=0,Wl=0,$l=0,El=0,Cu=0,iu=0,pu=0,yu=0,hu=0,mu=0,vu=0,fu=0,gu=0,ou=0,su=0,tu=0,zl=0,Gl=0,Jl=0,Pl=0,Fl=0,Yl=0,Vl=0,Ql=0,au=0,Nu=0,Wu=0,zu=0,Bu=0,Qo=Ao[0],Zu=Ao[1],Qu=Ao[2],_h=Ao[3],qu=Ao[4],Ju=Ao[5],_d=Ao[6],dp=Ao[7],Ku=Ao[8],Vu=Ao[9],cp=Ao[10],fp=Ao[11],lp=Ao[12],np=Ao[13],Rp=Ao[14],wp=Ao[15];po=Co[0],Xo+=po*Qo,jo+=po*Zu,Ko+=po*Qu,Wl+=po*_h,$l+=po*qu,El+=po*Ju,Cu+=po*_d,iu+=po*dp,pu+=po*Ku,yu+=po*Vu,hu+=po*cp,mu+=po*fp,vu+=po*lp,fu+=po*np,gu+=po*Rp,ou+=po*wp,po=Co[1],jo+=po*Qo,Ko+=po*Zu,Wl+=po*Qu,$l+=po*_h,El+=po*qu,Cu+=po*Ju,iu+=po*_d,pu+=po*dp,yu+=po*Ku,hu+=po*Vu,mu+=po*cp,vu+=po*fp,fu+=po*lp,gu+=po*np,ou+=po*Rp,su+=po*wp,po=Co[2],Ko+=po*Qo,Wl+=po*Zu,$l+=po*Qu,El+=po*_h,Cu+=po*qu,iu+=po*Ju,pu+=po*_d,yu+=po*dp,hu+=po*Ku,mu+=po*Vu,vu+=po*cp,fu+=po*fp,gu+=po*lp,ou+=po*np,su+=po*Rp,tu+=po*wp,po=Co[3],Wl+=po*Qo,$l+=po*Zu,El+=po*Qu,Cu+=po*_h,iu+=po*qu,pu+=po*Ju,yu+=po*_d,hu+=po*dp,mu+=po*Ku,vu+=po*Vu,fu+=po*cp,gu+=po*fp,ou+=po*lp,su+=po*np,tu+=po*Rp,zl+=po*wp,po=Co[4],$l+=po*Qo,El+=po*Zu,Cu+=po*Qu,iu+=po*_h,pu+=po*qu,yu+=po*Ju,hu+=po*_d,mu+=po*dp,vu+=po*Ku,fu+=po*Vu,gu+=po*cp,ou+=po*fp,su+=po*lp,tu+=po*np,zl+=po*Rp,Gl+=po*wp,po=Co[5],El+=po*Qo,Cu+=po*Zu,iu+=po*Qu,pu+=po*_h,yu+=po*qu,hu+=po*Ju,mu+=po*_d,vu+=po*dp,fu+=po*Ku,gu+=po*Vu,ou+=po*cp,su+=po*fp,tu+=po*lp,zl+=po*np,Gl+=po*Rp,Jl+=po*wp,po=Co[6],Cu+=po*Qo,iu+=po*Zu,pu+=po*Qu,yu+=po*_h,hu+=po*qu,mu+=po*Ju,vu+=po*_d,fu+=po*dp,gu+=po*Ku,ou+=po*Vu,su+=po*cp,tu+=po*fp,zl+=po*lp,Gl+=po*np,Jl+=po*Rp,Pl+=po*wp,po=Co[7],iu+=po*Qo,pu+=po*Zu,yu+=po*Qu,hu+=po*_h,mu+=po*qu,vu+=po*Ju,fu+=po*_d,gu+=po*dp,ou+=po*Ku,su+=po*Vu,tu+=po*cp,zl+=po*fp,Gl+=po*lp,Jl+=po*np,Pl+=po*Rp,Fl+=po*wp,po=Co[8],pu+=po*Qo,yu+=po*Zu,hu+=po*Qu,mu+=po*_h,vu+=po*qu,fu+=po*Ju,gu+=po*_d,ou+=po*dp,su+=po*Ku,tu+=po*Vu,zl+=po*cp,Gl+=po*fp,Jl+=po*lp,Pl+=po*np,Fl+=po*Rp,Yl+=po*wp,po=Co[9],yu+=po*Qo,hu+=po*Zu,mu+=po*Qu,vu+=po*_h,fu+=po*qu,gu+=po*Ju,ou+=po*_d,su+=po*dp,tu+=po*Ku,zl+=po*Vu,Gl+=po*cp,Jl+=po*fp,Pl+=po*lp,Fl+=po*np,Yl+=po*Rp,Vl+=po*wp,po=Co[10],hu+=po*Qo,mu+=po*Zu,vu+=po*Qu,fu+=po*_h,gu+=po*qu,ou+=po*Ju,su+=po*_d,tu+=po*dp,zl+=po*Ku,Gl+=po*Vu,Jl+=po*cp,Pl+=po*fp,Fl+=po*lp,Yl+=po*np,Vl+=po*Rp,Ql+=po*wp,po=Co[11],mu+=po*Qo,vu+=po*Zu,fu+=po*Qu,gu+=po*_h,ou+=po*qu,su+=po*Ju,tu+=po*_d,zl+=po*dp,Gl+=po*Ku,Jl+=po*Vu,Pl+=po*cp,Fl+=po*fp,Yl+=po*lp,Vl+=po*np,Ql+=po*Rp,au+=po*wp,po=Co[12],vu+=po*Qo,fu+=po*Zu,gu+=po*Qu,ou+=po*_h,su+=po*qu,tu+=po*Ju,zl+=po*_d,Gl+=po*dp,Jl+=po*Ku,Pl+=po*Vu,Fl+=po*cp,Yl+=po*fp,Vl+=po*lp,Ql+=po*np,au+=po*Rp,Nu+=po*wp,po=Co[13],fu+=po*Qo,gu+=po*Zu,ou+=po*Qu,su+=po*_h,tu+=po*qu,zl+=po*Ju,Gl+=po*_d,Jl+=po*dp,Pl+=po*Ku,Fl+=po*Vu,Yl+=po*cp,Vl+=po*fp,Ql+=po*lp,au+=po*np,Nu+=po*Rp,Wu+=po*wp,po=Co[14],gu+=po*Qo,ou+=po*Zu,su+=po*Qu,tu+=po*_h,zl+=po*qu,Gl+=po*Ju,Jl+=po*_d,Pl+=po*dp,Fl+=po*Ku,Yl+=po*Vu,Vl+=po*cp,Ql+=po*fp,au+=po*lp,Nu+=po*np,Wu+=po*Rp,zu+=po*wp,po=Co[15],ou+=po*Qo,su+=po*Zu,tu+=po*Qu,zl+=po*_h,Gl+=po*qu,Jl+=po*Ju,Pl+=po*_d,Fl+=po*dp,Yl+=po*Ku,Vl+=po*Vu,Ql+=po*cp,au+=po*fp,Nu+=po*lp,Wu+=po*np,zu+=po*Rp,Bu+=po*wp,Xo+=38*su,jo+=38*tu,Ko+=38*zl,Wl+=38*Gl,$l+=38*Jl,El+=38*Pl,Cu+=38*Fl,iu+=38*Yl,pu+=38*Vl,yu+=38*Ql,hu+=38*au,mu+=38*Nu,vu+=38*Wu,fu+=38*zu,gu+=38*Bu,Ro=1,po=Xo+Ro+65535,Ro=Math.floor(po/65536),Xo=po-Ro*65536,po=jo+Ro+65535,Ro=Math.floor(po/65536),jo=po-Ro*65536,po=Ko+Ro+65535,Ro=Math.floor(po/65536),Ko=po-Ro*65536,po=Wl+Ro+65535,Ro=Math.floor(po/65536),Wl=po-Ro*65536,po=$l+Ro+65535,Ro=Math.floor(po/65536),$l=po-Ro*65536,po=El+Ro+65535,Ro=Math.floor(po/65536),El=po-Ro*65536,po=Cu+Ro+65535,Ro=Math.floor(po/65536),Cu=po-Ro*65536,po=iu+Ro+65535,Ro=Math.floor(po/65536),iu=po-Ro*65536,po=pu+Ro+65535,Ro=Math.floor(po/65536),pu=po-Ro*65536,po=yu+Ro+65535,Ro=Math.floor(po/65536),yu=po-Ro*65536,po=hu+Ro+65535,Ro=Math.floor(po/65536),hu=po-Ro*65536,po=mu+Ro+65535,Ro=Math.floor(po/65536),mu=po-Ro*65536,po=vu+Ro+65535,Ro=Math.floor(po/65536),vu=po-Ro*65536,po=fu+Ro+65535,Ro=Math.floor(po/65536),fu=po-Ro*65536,po=gu+Ro+65535,Ro=Math.floor(po/65536),gu=po-Ro*65536,po=ou+Ro+65535,Ro=Math.floor(po/65536),ou=po-Ro*65536,Xo+=Ro-1+37*(Ro-1),Ro=1,po=Xo+Ro+65535,Ro=Math.floor(po/65536),Xo=po-Ro*65536,po=jo+Ro+65535,Ro=Math.floor(po/65536),jo=po-Ro*65536,po=Ko+Ro+65535,Ro=Math.floor(po/65536),Ko=po-Ro*65536,po=Wl+Ro+65535,Ro=Math.floor(po/65536),Wl=po-Ro*65536,po=$l+Ro+65535,Ro=Math.floor(po/65536),$l=po-Ro*65536,po=El+Ro+65535,Ro=Math.floor(po/65536),El=po-Ro*65536,po=Cu+Ro+65535,Ro=Math.floor(po/65536),Cu=po-Ro*65536,po=iu+Ro+65535,Ro=Math.floor(po/65536),iu=po-Ro*65536,po=pu+Ro+65535,Ro=Math.floor(po/65536),pu=po-Ro*65536,po=yu+Ro+65535,Ro=Math.floor(po/65536),yu=po-Ro*65536,po=hu+Ro+65535,Ro=Math.floor(po/65536),hu=po-Ro*65536,po=mu+Ro+65535,Ro=Math.floor(po/65536),mu=po-Ro*65536,po=vu+Ro+65535,Ro=Math.floor(po/65536),vu=po-Ro*65536,po=fu+Ro+65535,Ro=Math.floor(po/65536),fu=po-Ro*65536,po=gu+Ro+65535,Ro=Math.floor(po/65536),gu=po-Ro*65536,po=ou+Ro+65535,Ro=Math.floor(po/65536),ou=po-Ro*65536,Xo+=Ro-1+37*(Ro-1),So[0]=Xo,So[1]=jo,So[2]=Ko,So[3]=Wl,So[4]=$l,So[5]=El,So[6]=Cu,So[7]=iu,So[8]=pu,So[9]=yu,So[10]=hu,So[11]=mu,So[12]=vu,So[13]=fu,So[14]=gu,So[15]=ou}function go(So,Co){vo(So,Co,Co)}function uo(So,Co){var Ao=wr(),po;for(po=0;po<16;po++)Ao[po]=Co[po];for(po=253;po>=0;po--)go(Ao,Ao),po!==2&&po!==4&&vo(Ao,Ao,Co);for(po=0;po<16;po++)So[po]=Ao[po]}function lo(So,Co){var Ao=wr(),po;for(po=0;po<16;po++)Ao[po]=Co[po];for(po=250;po>=0;po--)go(Ao,Ao),po!==1&&vo(Ao,Ao,Co);for(po=0;po<16;po++)So[po]=Ao[po]}function Eo(So,Co,Ao){var po=new Uint8Array(32),Ro=new Float64Array(80),Xo,jo,Ko=wr(),Wl=wr(),$l=wr(),El=wr(),Cu=wr(),iu=wr();for(jo=0;jo<31;jo++)po[jo]=Co[jo];for(po[31]=Co[31]&127|64,po[0]&=248,wn(Ro,Ao),jo=0;jo<16;jo++)Wl[jo]=Ro[jo],El[jo]=Ko[jo]=$l[jo]=0;for(Ko[0]=El[0]=1,jo=254;jo>=0;--jo)Xo=po[jo>>>3]>>>(jo&7)&1,Pn(Ko,Wl,Xo),Pn($l,El,Xo),zn(Cu,Ko,$l),fo(Ko,Ko,$l),zn($l,Wl,El),fo(Wl,Wl,El),go(El,Cu),go(iu,Ko),vo(Ko,$l,Ko),vo($l,Wl,Cu),zn(Cu,Ko,$l),fo(Ko,Ko,$l),go(Wl,Ko),fo($l,El,iu),vo(Ko,$l,qr),zn(Ko,Ko,El),vo($l,$l,Ko),vo(Ko,El,iu),vo(El,Wl,Ro),go(Wl,Cu),Pn(Ko,Wl,Xo),Pn($l,El,Xo);for(jo=0;jo<16;jo++)Ro[jo+16]=Ko[jo],Ro[jo+32]=$l[jo],Ro[jo+48]=Wl[jo],Ro[jo+64]=El[jo];var pu=Ro.subarray(32),yu=Ro.subarray(16);return uo(pu,pu),vo(yu,yu,pu),On(So,yu),0}function mo(So,Co){return Eo(So,Co,jr)}function yo(So,Co){return Er(Co,32),mo(So,Co)}function _o(So,Co,Ao){var po=new Uint8Array(32);return Eo(po,Ao,Co),ro(So,kr,po,to)}var Bo=Gr,Lo=Xr;function Wo(So,Co,Ao,po,Ro,Xo){var jo=new Uint8Array(32);return _o(jo,Ro,Xo),Bo(So,Co,Ao,po,jo)}function na(So,Co,Ao,po,Ro,Xo){var jo=new Uint8Array(32);return _o(jo,Ro,Xo),Lo(So,Co,Ao,po,jo)}var qo=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function ga(So,Co,Ao,po){for(var Ro=new Int32Array(16),Xo=new Int32Array(16),jo,Ko,Wl,$l,El,Cu,iu,pu,yu,hu,mu,vu,fu,gu,ou,su,tu,zl,Gl,Jl,Pl,Fl,Yl,Vl,Ql,au,Nu=So[0],Wu=So[1],zu=So[2],Bu=So[3],Qo=So[4],Zu=So[5],Qu=So[6],_h=So[7],qu=Co[0],Ju=Co[1],_d=Co[2],dp=Co[3],Ku=Co[4],Vu=Co[5],cp=Co[6],fp=Co[7],lp=0;po>=128;){for(Gl=0;Gl<16;Gl++)Jl=8*Gl+lp,Ro[Gl]=Ao[Jl+0]<<24|Ao[Jl+1]<<16|Ao[Jl+2]<<8|Ao[Jl+3],Xo[Gl]=Ao[Jl+4]<<24|Ao[Jl+5]<<16|Ao[Jl+6]<<8|Ao[Jl+7];for(Gl=0;Gl<80;Gl++)if(jo=Nu,Ko=Wu,Wl=zu,$l=Bu,El=Qo,Cu=Zu,iu=Qu,pu=_h,yu=qu,hu=Ju,mu=_d,vu=dp,fu=Ku,gu=Vu,ou=cp,su=fp,Pl=_h,Fl=fp,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=(Qo>>>14|Ku<<18)^(Qo>>>18|Ku<<14)^(Ku>>>9|Qo<<23),Fl=(Ku>>>14|Qo<<18)^(Ku>>>18|Qo<<14)^(Qo>>>9|Ku<<23),Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Pl=Qo&Zu^~Qo&Qu,Fl=Ku&Vu^~Ku&cp,Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Pl=qo[Gl*2],Fl=qo[Gl*2+1],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Pl=Ro[Gl%16],Fl=Xo[Gl%16],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,tu=Ql&65535|au<<16,zl=Yl&65535|Vl<<16,Pl=tu,Fl=zl,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=(Nu>>>28|qu<<4)^(qu>>>2|Nu<<30)^(qu>>>7|Nu<<25),Fl=(qu>>>28|Nu<<4)^(Nu>>>2|qu<<30)^(Nu>>>7|qu<<25),Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Pl=Nu&Wu^Nu&zu^Wu&zu,Fl=qu&Ju^qu&_d^Ju&_d,Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,pu=Ql&65535|au<<16,su=Yl&65535|Vl<<16,Pl=$l,Fl=vu,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=tu,Fl=zl,Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,$l=Ql&65535|au<<16,vu=Yl&65535|Vl<<16,Wu=jo,zu=Ko,Bu=Wl,Qo=$l,Zu=El,Qu=Cu,_h=iu,Nu=pu,Ju=yu,_d=hu,dp=mu,Ku=vu,Vu=fu,cp=gu,fp=ou,qu=su,Gl%16===15)for(Jl=0;Jl<16;Jl++)Pl=Ro[Jl],Fl=Xo[Jl],Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=Ro[(Jl+9)%16],Fl=Xo[(Jl+9)%16],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,tu=Ro[(Jl+1)%16],zl=Xo[(Jl+1)%16],Pl=(tu>>>1|zl<<31)^(tu>>>8|zl<<24)^tu>>>7,Fl=(zl>>>1|tu<<31)^(zl>>>8|tu<<24)^(zl>>>7|tu<<25),Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,tu=Ro[(Jl+14)%16],zl=Xo[(Jl+14)%16],Pl=(tu>>>19|zl<<13)^(zl>>>29|tu<<3)^tu>>>6,Fl=(zl>>>19|tu<<13)^(tu>>>29|zl<<3)^(zl>>>6|tu<<26),Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,Ro[Jl]=Ql&65535|au<<16,Xo[Jl]=Yl&65535|Vl<<16;Pl=Nu,Fl=qu,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[0],Fl=Co[0],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[0]=Nu=Ql&65535|au<<16,Co[0]=qu=Yl&65535|Vl<<16,Pl=Wu,Fl=Ju,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[1],Fl=Co[1],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[1]=Wu=Ql&65535|au<<16,Co[1]=Ju=Yl&65535|Vl<<16,Pl=zu,Fl=_d,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[2],Fl=Co[2],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[2]=zu=Ql&65535|au<<16,Co[2]=_d=Yl&65535|Vl<<16,Pl=Bu,Fl=dp,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[3],Fl=Co[3],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[3]=Bu=Ql&65535|au<<16,Co[3]=dp=Yl&65535|Vl<<16,Pl=Qo,Fl=Ku,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[4],Fl=Co[4],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[4]=Qo=Ql&65535|au<<16,Co[4]=Ku=Yl&65535|Vl<<16,Pl=Zu,Fl=Vu,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[5],Fl=Co[5],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[5]=Zu=Ql&65535|au<<16,Co[5]=Vu=Yl&65535|Vl<<16,Pl=Qu,Fl=cp,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[6],Fl=Co[6],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[6]=Qu=Ql&65535|au<<16,Co[6]=cp=Yl&65535|Vl<<16,Pl=_h,Fl=fp,Yl=Fl&65535,Vl=Fl>>>16,Ql=Pl&65535,au=Pl>>>16,Pl=So[7],Fl=Co[7],Yl+=Fl&65535,Vl+=Fl>>>16,Ql+=Pl&65535,au+=Pl>>>16,Vl+=Yl>>>16,Ql+=Vl>>>16,au+=Ql>>>16,So[7]=_h=Ql&65535|au<<16,Co[7]=fp=Yl&65535|Vl<<16,lp+=128,po-=128}return po}function wl(So,Co,Ao){var po=new Int32Array(8),Ro=new Int32Array(8),Xo=new Uint8Array(256),jo,Ko=Ao;for(po[0]=1779033703,po[1]=3144134277,po[2]=1013904242,po[3]=2773480762,po[4]=1359893119,po[5]=2600822924,po[6]=528734635,po[7]=1541459225,Ro[0]=4089235720,Ro[1]=2227873595,Ro[2]=4271175723,Ro[3]=1595750129,Ro[4]=2917565137,Ro[5]=725511199,Ro[6]=4215389547,Ro[7]=327033209,ga(po,Ro,Co,Ao),Ao%=128,jo=0;jo=0;--Ro)po=Ao[Ro/8|0]>>(Ro&7)&1,Fo(So,Co,po),No(Co,So),No(So,So),Fo(So,Co,po)}function Uo(So,Co){var Ao=[wr(),wr(),wr(),wr()];Sn(Ao[0],Zr),Sn(Ao[1],Jr),Sn(Ao[2],Wr),vo(Ao[3],Zr,Jr),Vo(So,Ao,Co)}function Ol(So,Co,Ao){var po=new Uint8Array(64),Ro=[wr(),wr(),wr(),wr()],Xo;for(Ao||Er(Co,32),wl(po,Co,32),po[0]&=248,po[31]&=127,po[31]|=64,Uo(Ro,po),Nl(So,Ro),Xo=0;Xo<32;Xo++)Co[Xo+32]=So[Xo];return 0}var $a=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Jo(So,Co){var Ao,po,Ro,Xo;for(po=63;po>=32;--po){for(Ao=0,Ro=po-32,Xo=po-12;Ro>4)*$a[Ro],Ao=Co[Ro]>>8,Co[Ro]&=255;for(Ro=0;Ro<32;Ro++)Co[Ro]-=Ao*$a[Ro];for(po=0;po<32;po++)Co[po+1]+=Co[po]>>8,So[po]=Co[po]&255}function Zl(So){var Co=new Float64Array(64),Ao;for(Ao=0;Ao<64;Ao++)Co[Ao]=So[Ao];for(Ao=0;Ao<64;Ao++)So[Ao]=0;Jo(So,Co)}function Cl(So,Co,Ao,po){var Ro=new Uint8Array(64),Xo=new Uint8Array(64),jo=new Uint8Array(64),Ko,Wl,$l=new Float64Array(64),El=[wr(),wr(),wr(),wr()];wl(Ro,po,32),Ro[0]&=248,Ro[31]&=127,Ro[31]|=64;var Cu=Ao+64;for(Ko=0;Ko>7&&fo(So[0],Br,So[0]),vo(So[3],So[0],So[1]),0)}function wo(So,Co,Ao,po){var Ro,Xo=new Uint8Array(32),jo=new Uint8Array(64),Ko=[wr(),wr(),wr(),wr()],Wl=[wr(),wr(),wr(),wr()];if(Ao<64||ko(Wl,po))return-1;for(Ro=0;Ro=0},br.sign.keyPair=function(){var So=new Uint8Array(Il),Co=new Uint8Array(Eu);return Ol(So,Co),{publicKey:So,secretKey:Co}},br.sign.keyPair.fromSecretKey=function(So){if(Sl(So),So.length!==Eu)throw new Error("bad secret key size");for(var Co=new Uint8Array(Il),Ao=0;Ao`https://phantom.app/ul/v1/${fr}?${br.toString()}`,decryptPayload=(fr,br,wr)=>{const Er=nacl.box.open.after(bs58$8.decode(fr),bs58$8.decode(br),wr);if(!Er)throw new Error("Unable to decrypt data");return JSON.parse(Buffer$2.from(Er).toString("utf8"))},encryptPayload=(fr,br)=>{const wr=nacl.randomBytes(24),Er=nacl.box.after(Buffer$2.from(JSON.stringify(fr)),wr,br);return[wr,Er]},GENESIS_HASHES={"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY":"testnet","5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d":"mainnet-beta",EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG:"devnet"},fetchCluster=fr=>__awaiter$3(void 0,void 0,void 0,function*(){try{const{result:br}=yield(yield fetch(fr,{body:JSON.stringify({id:1,jsonrpc:"2.0",method:"getGenesisHash"}),headers:{"Content-Type":"application/json"},method:"POST"})).json();return GENESIS_HASHES[br]}catch{return"mainnet-beta"}}),storage={address:{get:()=>{var fr;return(fr=localStorage.getItem("dynamic_phantom_wallet_address"))!==null&&fr!==void 0?fr:void 0},remove:()=>{localStorage.removeItem("dynamic_phantom_wallet_address")},set:fr=>{localStorage.setItem("dynamic_phantom_wallet_address",fr.toString())}},encryptionPublicKey:{get:()=>{const fr=localStorage.getItem("dynamic_phantom_public_key");if(fr)return new Uint8Array(JSON.parse(fr))},remove:()=>{localStorage.removeItem("dynamic_phantom_public_key")},set:fr=>{localStorage.setItem("dynamic_phantom_public_key",JSON.stringify([...fr]))}},encryptionSecretKey:{get:()=>{const fr=localStorage.getItem("dynamic_phantom_secret_key");if(fr)return new Uint8Array(JSON.parse(fr))},remove:()=>{localStorage.removeItem("dynamic_phantom_secret_key")},set:fr=>{localStorage.setItem("dynamic_phantom_secret_key",JSON.stringify([...fr]))}},message:{get:()=>{var fr;return(fr=localStorage.getItem("dynamic_phantom_message_to_sign"))!==null&&fr!==void 0?fr:void 0},remove:()=>{localStorage.removeItem("dynamic_phantom_message_to_sign")},set:fr=>{localStorage.setItem("dynamic_phantom_message_to_sign",fr)}},method:{get:()=>{var fr;return(fr=localStorage.getItem("dynamic_phantom_method"))!==null&&fr!==void 0?fr:void 0},remove:()=>{localStorage.removeItem("dynamic_phantom_method")},set:fr=>{localStorage.setItem("dynamic_phantom_method",fr)}},session:{get:()=>{var fr;return(fr=localStorage.getItem("dynamic_phantom_session"))!==null&&fr!==void 0?fr:void 0},remove:()=>{localStorage.removeItem("dynamic_phantom_session")},set:fr=>{localStorage.setItem("dynamic_phantom_session",fr)}},sharedSecret:{get:()=>{const fr=localStorage.getItem("dynamic_phantom_shared_secret");if(fr)return new Uint8Array(JSON.parse(fr))},remove:()=>{localStorage.removeItem("dynamic_phantom_shared_secret")},set:fr=>{localStorage.setItem("dynamic_phantom_shared_secret",JSON.stringify([...fr]))}}},clearStorage=()=>{for(const fr in storage)storage[fr].remove()};class PhantomRedirect extends SolanaWalletConnector{constructor(br){super(Object.assign({},br)),this.name="Phantom",this.overrideKey="phantom"}getMethod(){throw new Error("Method not implemented.")}getAddress(){return __awaiter$3(this,void 0,void 0,function*(){const br=storage.address.get();if(br)return br;yield this.connect()})}connect(){return __awaiter$3(this,void 0,void 0,function*(){var br,wr;const Er=nacl.box.keyPair();storage.encryptionPublicKey.set(Er.publicKey),storage.encryptionSecretKey.set(Er.secretKey);const kr=window.location.href.includes("localhost")||window.location.href.includes("0.0.0.0")||window.location.href.includes("127.0.0.1"),jr=(wr=(br=this.solNetworks[0].privateCustomerRpcUrls)===null||br===void 0?void 0:br[0])!==null&&wr!==void 0?wr:this.solNetworks[0].rpcUrls[0],Br=new URLSearchParams({app_url:kr?"https://demo.dynamic.xyz":window.location.href,cluster:yield fetchCluster(jr),dapp_encryption_public_key:bs58$8.encode(Er.publicKey),redirect_link:window.location.href}),Wr=buildUrl("connect",Br);window.location.href=Wr})}getSession(){return __awaiter$3(this,void 0,void 0,function*(){const br=new URLSearchParams(window.location.search),{data:wr,nonce:Er,phantom_encryption_public_key:kr,encryptionSecretKey:jr}=this.getInputsOrThrow("getSession",["data","nonce","phantom_encryption_public_key"],["encryptionSecretKey"]),Br=nacl.box.before(bs58$8.decode(kr),jr);storage.sharedSecret.set(Br);const Wr=decryptPayload(wr,Er,Br);return storage.session.set(Wr.session),storage.address.set(new PublicKey$2(Wr.public_key)),br.delete("phantom_encryption_public_key"),br.delete("data"),br.delete("nonce"),history.replaceState(null,"",`${window.location.origin}${window.location.pathname}?${br.toString()}`),Wr.public_key})}signMessage(br){return __awaiter$3(this,void 0,void 0,function*(){const{session:wr,sharedSecret:Er,encryptionPublicKey:kr}=this.getInputsOrThrow("signMessage",[],["session","sharedSecret","encryptionPublicKey"]);storage.message.set(br);const jr={message:bs58$8.encode(Buffer$2.from(br)),session:wr},[Br,Wr]=encryptPayload(jr,Er),qr=new URLSearchParams({dapp_encryption_public_key:bs58$8.encode(kr),nonce:bs58$8.encode(Br),payload:bs58$8.encode(Wr),redirect_link:window.location.href}),Hr=buildUrl("signMessage",qr);throw storage.method.set("signMessage"),window.location.href=Hr,new Error("ignore")})}extractSignature(){const br=new URLSearchParams(window.location.search),{data:wr,nonce:Er,sharedSecret:kr,message:jr}=this.getInputsOrThrow("extractSignature",["data","nonce"],["sharedSecret","message"]),Br=decryptPayload(wr,Er,kr);return br.delete("data"),br.delete("nonce"),history.replaceState(null,"",`${window.location.origin}${window.location.pathname}?${br.toString()}`),{message:jr,signature:Br.signature}}extractTransactions(){const br=new URLSearchParams(window.location.search),{data:wr,nonce:Er,sharedSecret:kr}=this.getInputsOrThrow("extractTransactions",["data","nonce"],["sharedSecret"]),Br=decryptPayload(wr,Er,kr).transactions.map(Wr=>Transaction.from(bs58$8.decode(Wr)));return br.delete("data"),br.delete("nonce"),history.replaceState(null,"",`${window.location.origin}${window.location.pathname}?${br.toString()}`),Br}extractTransaction(){const br=new URLSearchParams(window.location.search),{data:wr,nonce:Er,sharedSecret:kr}=this.getInputsOrThrow("extractTransaction",["data","nonce"],["sharedSecret"]),jr=decryptPayload(wr,Er,kr),Br=Transaction.from(bs58$8.decode(jr.transaction));return br.delete("data"),br.delete("nonce"),history.replaceState(null,"",`${window.location.origin}${window.location.pathname}?${br.toString()}`),Br}consumeMethod(){const br=storage.method.get();return storage.method.remove(),br}getSigner(){return __awaiter$3(this,void 0,void 0,function*(){const br=storage.address.get();if(br)return{addListener:()=>{throw new Error("Not implemented")},connect:()=>{throw new Error("Not implemented")},disconnect:()=>{throw new Error("Not implemented")},emit:()=>{throw new Error("Not implemented")},eventNames:()=>{throw new Error("Not implemented")},isBackpack:!1,isBraveWallet:!1,isConnected:!0,isExodus:!1,isGlow:!1,isMagicEden:!1,isPhantom:!0,isSolflare:!1,listenerCount:()=>{throw new Error("Not implemented")},listeners:()=>{throw new Error("Not implemented")},off:()=>{throw new Error("Not implemented")},on:()=>{throw new Error("Not implemented")},once:()=>{throw new Error("Not implemented")},providers:[],publicKey:new PublicKey$2(br),removeAllListeners:()=>{throw new Error("Not implemented")},removeListener:()=>{throw new Error("Not implemented")},signAllTransactions:wr=>__awaiter$3(this,void 0,void 0,function*(){const Er=wr.map(Jr=>bs58$8.encode(Jr.serialize({requireAllSignatures:!1}))),{session:kr,sharedSecret:jr,encryptionPublicKey:Br}=this.getInputsOrThrow("signAllTransactions",[],["session","sharedSecret","encryptionPublicKey"]),Wr={session:kr,transactions:Er},[qr,Hr]=encryptPayload(Wr,jr),Vr=new URLSearchParams({dapp_encryption_public_key:bs58$8.encode(Br),nonce:bs58$8.encode(qr),payload:bs58$8.encode(Hr),redirect_link:window.location.href}),Zr=buildUrl("signAllTransactions",Vr);return window.location.href=Zr,[]}),signAndSendTransaction:(wr,Er)=>__awaiter$3(this,void 0,void 0,function*(){const{session:kr,sharedSecret:jr,encryptionPublicKey:Br}=this.getInputsOrThrow("signAndSendTransaction",[],["session","sharedSecret","encryptionPublicKey"]),Wr={options:Er,session:kr,transaction:bs58$8.encode(wr.serialize({requireAllSignatures:!1}))},[qr,Hr]=encryptPayload(Wr,jr),Vr=new URLSearchParams({dapp_encryption_public_key:bs58$8.encode(Br),nonce:bs58$8.encode(qr),payload:bs58$8.encode(Hr),redirect_link:window.location.href}),Zr=buildUrl("signAndSendTransaction",Vr);return storage.method.set("signAndSendTransaction"),window.location.href=Zr,{signature:""}}),signMessage:wr=>__awaiter$3(this,void 0,void 0,function*(){const{session:Er,sharedSecret:kr,encryptionPublicKey:jr}=this.getInputsOrThrow("signMessage",[],["session","sharedSecret","encryptionPublicKey"]),Br={message:bs58$8.encode(Buffer$2.from(wr)),session:Er},[Wr,qr]=encryptPayload(Br,kr),Hr=new URLSearchParams({dapp_encryption_public_key:bs58$8.encode(jr),nonce:bs58$8.encode(Wr),payload:bs58$8.encode(qr),redirect_link:window.location.href}),Vr=buildUrl("signMessage",Hr);return window.location.href=Vr,{signature:Buffer$2.from("")}}),signTransaction:wr=>__awaiter$3(this,void 0,void 0,function*(){const Er=bs58$8.encode(wr.serialize({requireAllSignatures:!1})),{session:kr,sharedSecret:jr,encryptionPublicKey:Br}=this.getInputsOrThrow("signTransaction",[],["session","sharedSecret","encryptionPublicKey"]),Wr={session:kr,transaction:Er},[qr,Hr]=encryptPayload(Wr,jr),Vr=new URLSearchParams({dapp_encryption_public_key:bs58$8.encode(Br),nonce:bs58$8.encode(qr),payload:bs58$8.encode(Hr),redirect_link:window.location.href}),Zr=buildUrl("signTransaction",Vr);return window.location.href=Zr,wr})}})}getConnectedAccounts(){return __awaiter$3(this,void 0,void 0,function*(){const br=storage.address.get();return br?[br]:[]})}endSession(){return __awaiter$3(this,void 0,void 0,function*(){const br=storage.address.get(),wr=storage.session.get(),Er=storage.sharedSecret.get(),kr=storage.encryptionPublicKey.get();if(clearStorage(),!br||!wr||!kr||!Er)return;const jr={session:wr},[Br,Wr]=encryptPayload(jr,Er),qr=new URLSearchParams({dapp_encryption_public_key:bs58$8.encode(kr),nonce:bs58$8.encode(Br),payload:bs58$8.encode(Wr),redirect_link:window.location.href}),Hr=buildUrl("disconnect",qr);window.location.href=Hr})}getInputsOrThrow(br,wr,Er){const kr={},jr=new URLSearchParams(window.location.search);return wr.forEach(Br=>{const Wr=jr.get(Br);if(!Wr)throw new Error(`[PhantomRedirect] ${br} called, but required input '${Br}' not found in query params`);kr[Br]=Wr}),Er.forEach(Br=>{const Wr=storage[Br].get();if(!Wr)throw new Error(`[PhantomRedirect] ${br} called, but required input '${Br}' not found in local storage`);kr[Br]=Wr}),kr}}class PhantomInjected extends InjectedWalletBase{constructor(br){super(br),this.name="Phantom",this.overrideKey="phantom",this.wallet=findWalletBookWallet(this.walletBook,this.key)}getAddress(){const br=Object.create(null,{getAddress:{get:()=>super.getAddress}});return __awaiter$3(this,void 0,void 0,function*(){if(this.isInstalledOnBrowser())return br.getAddress.call(this);isMobile()&&handleMobileWalletRedirect({nativeLink:"phantom://browse",universalLink:"https://phantom.app/ul/browse"})})}canGetChainAddress(){var br,wr;return((wr=(br=this.getSolProviderHelper())===null||br===void 0?void 0:br.findProvider())===null||wr===void 0?void 0:wr.publicKey)!==null}}class Phantom extends SolanaWalletConnector{constructor(br){super(br),this.name="Phantom",this.overrideKey="phantom",this.wallet=findWalletBookWallet(this.walletBook,this.key)}connect(){return __awaiter$3(this,void 0,void 0,function*(){yield this.getMobileOrInstalledWallet().connect()})}getSigner(){return __awaiter$3(this,void 0,void 0,function*(){return this.getMobileOrInstalledWallet().getSigner()})}getMobileOrInstalledWallet(){const br=new PhantomInjected(this.constructorProps);return!isMobile()||br.isInstalledOnBrowser()?br:this.mobileExperience==="redirect"?new PhantomRedirect(this.constructorProps):new PhantomInjected(this.constructorProps)}}class CoinbaseSolana extends InjectedWalletBase{constructor(br){super(br),this.name="CoinbaseSolana",this.overrideKey="coinbasesolana",this.wallet=findWalletBookWallet(this.walletBook,this.key)}getSigner(){return __awaiter$3(this,void 0,void 0,function*(){var br;return(br=this.getSolProviderHelper())===null||br===void 0?void 0:br.connect()})}signMessage(br){return __awaiter$3(this,void 0,void 0,function*(){const wr=yield this.getAddress();if(!wr)return;const Er=yield this.getSigner();if(!Er)return;const kr=new TextEncoder().encode(br),jr=yield Er.signMessage(kr,wr);if(jr)return bufferToBase64(isSignedMessage(jr)?jr.signature:jr)})}}class Solflare extends InjectedWalletBase{constructor(br){super(br),this.name="Solflare",this.overrideKey="solflare",this.wallet=findWalletBookWallet(this.walletBook,this.key)}getAddress(){return __awaiter$3(this,void 0,void 0,function*(){var br,wr,Er,kr,jr;if(isMobile()&&!this.isInstalledOnBrowser()){handleMobileWalletRedirect({nativeLink:((wr=(br=this.wallet)===null||br===void 0?void 0:br.mobile)===null||wr===void 0?void 0:wr.native)||"solflare://ul/v1/browse",universalLink:((kr=(Er=this.wallet)===null||Er===void 0?void 0:Er.mobile)===null||kr===void 0?void 0:kr.universal)||"https://solflare.com/ul/v1/browse"});return}return(jr=this.getSolProviderHelper())===null||jr===void 0?void 0:jr.getAddress()})}signMessage(br){return __awaiter$3(this,void 0,void 0,function*(){if(!(yield this.getAddress()))return;const Er=yield this.getSigner();if(!Er)return;const kr=new TextEncoder().encode(br),jr=Wr=>Wr.signature!==void 0;yield Er.connect(),yield new Promise(Wr=>{setTimeout(Wr,100)});const Br=yield Er.signMessage(kr,"utf8");return jr(Br)?bufferToBase64(Br.signature):void 0})}}const isVersionedTransaction=fr=>!("instructions"in fr),createSolanaSignerFromWalletStandard=(fr,br)=>{const wr=fr.features,Er=()=>__awaiter$3(void 0,void 0,void 0,function*(){const Hr=yield br.getAddress(),Vr=fr.accounts.find(Zr=>Zr.address===Hr);if(!Vr)throw new Error("Account not found");return Vr}),kr=()=>__awaiter$3(void 0,void 0,void 0,function*(){var Hr,Vr;const Zr=(Vr=(Hr=br.solNetworks[0].privateCustomerRpcUrls)===null||Hr===void 0?void 0:Hr[0])!==null&&Vr!==void 0?Vr:br.solNetworks[0].rpcUrls[0];return`solana:${yield fetchCluster(Zr)}`}),jr=Hr=>__awaiter$3(void 0,void 0,void 0,function*(){const Vr=yield Er(),Zr=yield wr["solana:signTransaction"].signTransaction({account:Vr,chain:yield kr(),transaction:Hr.serialize({requireAllSignatures:!1})});return isVersionedTransaction(Hr)?VersionedTransaction.deserialize(Zr[0].signedTransaction):Transaction.from(Zr[0].signedTransaction)});return{addListener:()=>{throw new Error("Not implemented")},connect:()=>{throw new Error("Not implemented")},disconnect:()=>br.endSession(),emit:()=>{throw new Error("Not implemented")},eventNames:()=>{throw new Error("Not implemented")},isBackpack:!1,isBraveWallet:!1,isConnected:!0,isExodus:!1,isGlow:!1,isMagicEden:!1,isPhantom:!1,isSolflare:!1,listenerCount:()=>{throw new Error("Not implemented")},listeners:()=>{throw new Error("Not implemented")},off:()=>{throw new Error("Not implemented")},on:()=>{throw new Error("Not implemented")},once:()=>{throw new Error("Not implemented")},providers:[],get publicKey(){return new PublicKey$2(fr.accounts[0].publicKey)},removeAllListeners:()=>{throw new Error("Not implemented")},removeListener:()=>{throw new Error("Not implemented")},send:()=>{throw new Error("Not implemented")},signAllTransactions:Hr=>__awaiter$3(void 0,void 0,void 0,function*(){return Promise.all(Hr.map(jr))}),signAndSendTransaction:Hr=>__awaiter$3(void 0,void 0,void 0,function*(){const Vr=yield Er(),Zr=yield wr["solana:signAndSendTransaction"].signAndSendTransaction({account:Vr,chain:yield kr(),transaction:Hr.serialize()}),[{signature:Jr}]=Zr;return{signature:new TextDecoder().decode(Jr)}}),signMessage:Hr=>__awaiter$3(void 0,void 0,void 0,function*(){const Vr=yield Er();return{signature:(yield wr["solana:signMessage"].signMessage({account:Vr,message:Hr}))[0].signature}}),signTransaction:jr}},encoder=new TextEncoder;class SolanaWalletStandardConnector extends SolanaWalletConnector{constructor(br){super(br),this.connectedChain="SOL",this.supportedChains=["SOL"]}get wallet(){const br=SolanaWalletStandardConnector.getWallet(this.walletBook,this.key);if(!br)throw new Error("Wallet not found");return br}get walletFeatures(){return this.wallet.features}connect(){return __awaiter$3(this,void 0,void 0,function*(){yield this.walletFeatures["standard:connect"].connect()})}endSession(){return __awaiter$3(this,void 0,void 0,function*(){yield this.walletFeatures["standard:disconnect"].disconnect()})}isInstalledOnBrowser(){return!0}getAddress(){return __awaiter$3(this,void 0,void 0,function*(){yield this.connect();const[br]=yield this.getConnectedAccounts();return br})}getConnectedAccounts(){return __awaiter$3(this,void 0,void 0,function*(){return this.wallet.accounts.map(wr=>wr.address)})}signMessage(br){return __awaiter$3(this,void 0,void 0,function*(){const wr=yield this.getSigner();if(!wr)throw new Error("Signer not found");const Er=encoder.encode(br),{signature:kr}=yield wr.signMessage(Er);if(!(kr instanceof Uint8Array))throw new Error("Signature not found");return Buffer$2.from(kr).toString("base64")})}getSigner(){return __awaiter$3(this,void 0,void 0,function*(){const{wallet:br}=this;return createSolanaSignerFromWalletStandard(br,this)})}static getWallet(br,wr){var Er,kr;const jr=getWallets().get(),Br=(Er=br.wallets[wr].injectedConfig)===null||Er===void 0?void 0:Er.find(Hr=>Hr.chain==="sol");if(!Br)return;const{features:Wr}=(kr=Br.walletStandard)!==null&&kr!==void 0?kr:{};return Wr?jr.find(Hr=>{var Vr;return Hr.name===((Vr=Br.walletStandard)===null||Vr===void 0?void 0:Vr.name)?Wr.reduce((Qr,_n)=>{const En=Object.keys(Hr.features);return Qr?En.includes(_n):!1},!0):!1}):void 0}}class BackpackSol extends InjectedWalletBase{constructor(br){super(br),this.name="Backpack",this.overrideKey="backpacksol",this.wallet=findWalletBookWallet(this.walletBook,this.key)}getSigner(){return __awaiter$3(this,void 0,void 0,function*(){var br;return(br=this.getSolProviderHelper())===null||br===void 0?void 0:br.connect()})}signMessage(br){return __awaiter$3(this,void 0,void 0,function*(){if(!(yield this.getAddress()))return;const Er=yield this.getSigner();if(!Er)return;const kr=yield Er.signMessage(Buffer$2.from(br,"utf8"));if(kr)return typeof kr=="object"&&"signature"in kr?bufferToBase64(kr.signature):bufferToBase64(kr)})}}const injectedWalletOverrides=[CoinbaseSolana,BackpackSol,Solflare],filteredInjectedWalletKeysOverrides=["coinbasesolana","phantom","phantomledger","backpacksol","solflare"],fetchInjectedWalletConnectors=({walletBook:fr})=>{var br;return Object.entries((br=fr==null?void 0:fr.wallets)!==null&&br!==void 0?br:{}).filter(([wr,Er])=>{var kr;const jr=!!(!((kr=Er.injectedConfig)===null||kr===void 0)&&kr.find(Wr=>Wr.chain==="sol")),Br=filteredInjectedWalletKeysOverrides.includes(wr);return jr&&!Br}).map(([wr,Er])=>{var kr;const{shortName:jr}=Er,Br=jr||Er.name;return!!(!((kr=Er.injectedConfig)===null||kr===void 0)&&kr.find(qr=>qr.walletStandard))&&!!SolanaWalletStandardConnector.getWallet(fr,wr)?class extends SolanaWalletStandardConnector{constructor(Hr){super(Object.assign({},Hr)),this.name=Br,this.overrideKey=wr}}:class extends InjectedWalletBase{constructor(qr){super(Object.assign({},qr)),this.name=Br,this.wallet=Er,this.overrideKey=wr}}})};class UnknownInjected extends InjectedWalletBase{constructor(br){super(br),this.name="Unknown",this.overrideKey="unknown",this.wallet=findWalletBookWallet(this.walletBook,this.key)}isInstalledOnBrowser(){return!1}}class FallbackSolanaConnector extends InjectedWalletBase{constructor(br){super(br),this.name="Fallback Connector",this.overrideKey="fallbackconnector",this.isAvailable=!1,this.wallet=findWalletBookWallet(this.walletBook,this.key)}isInstalledOnBrowser(){return!1}}const SolanaWalletConnectors=fr=>[...injectedWalletOverrides,...fetchInjectedWalletConnectors(fr),...TurnkeySolanaWalletConnectors(fr),Phantom,UnknownInjected,FallbackSolanaConnector];assertPackageVersion("@dynamic-labs/solana",version$7);client$1.createRoot(document.getElementById("root")).render(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(DynamicContextProvider,{theme:"dark",settings:{initialAuthenticationMode:"connect-only",environmentId:"fbb6bfb2-f61f-4105-a9c8-76d8cfc4c1a9",walletConnectors:[EthereumWalletConnectors,SolanaWalletConnectors]},children:jsxRuntimeExports.jsx(App,{})})}));export{Buffer$2 as B,DEFAULT_JWK_MEMBER_BYTE_LENGTH as D,Field as F,__vitePreload as _,uint8ArrayFromHexString as a,createHash as b,createCurve as c,dijkstraExports as d,encodeUtf8$1 as e,global$1 as g,hexStringToBase64url as h,requireCryptoBrowserify as r,sha256$3 as s,uint8ArrayToHexString as u}; diff --git a/assets/native-CVg7kFyP.js b/assets/native-bMdAWj-e.js similarity index 81% rename from assets/native-CVg7kFyP.js rename to assets/native-bMdAWj-e.js index f34cb69..1117709 100644 --- a/assets/native-CVg7kFyP.js +++ b/assets/native-bMdAWj-e.js @@ -1 +1 @@ -import{g as e}from"./index-BLNnbgD0.js";function t(){if(typeof WebSocket<"u")return WebSocket;if(typeof e.WebSocket<"u")return e.WebSocket;if(typeof window.WebSocket<"u")return window.WebSocket;if(typeof self.WebSocket<"u")return self.WebSocket;throw new Error("`WebSocket` is not supported in this environment")}const n=t();export{n as WebSocket}; +import{g as e}from"./index-kgT-H_GF.js";function t(){if(typeof WebSocket<"u")return WebSocket;if(typeof e.WebSocket<"u")return e.WebSocket;if(typeof window.WebSocket<"u")return window.WebSocket;if(typeof self.WebSocket<"u")return self.WebSocket;throw new Error("`WebSocket` is not supported in this environment")}const n=t();export{n as WebSocket}; diff --git a/assets/nodecrypto-DBt_cM49.js b/assets/nodecrypto-D6j4PjE1.js similarity index 64% rename from assets/nodecrypto-DBt_cM49.js rename to assets/nodecrypto-D6j4PjE1.js index 0a66887..6e26250 100644 --- a/assets/nodecrypto-DBt_cM49.js +++ b/assets/nodecrypto-D6j4PjE1.js @@ -1 +1 @@ -import{r as n,B as y}from"./index-BLNnbgD0.js";import{c as p}from"./utils-XOiObzyy.js";var r=n();const m=async t=>{const{content:o,publicKey:i,privateKey:s}=t,c=r.createPrivateKey({key:p({uncompressedPrivateKeyHex:s,compressedPublicKeyHex:i}),format:"jwk"}),e=r.createSign("SHA256");return e.write(y.from(o)),e.end(),e.sign(c,"hex")};export{m as signWithApiKey}; +import{r as n,B as y}from"./index-kgT-H_GF.js";import{c as p}from"./utils-kOKXth6J.js";var r=n();const m=async t=>{const{content:o,publicKey:i,privateKey:s}=t,c=r.createPrivateKey({key:p({uncompressedPrivateKeyHex:s,compressedPublicKeyHex:i}),format:"jwk"}),e=r.createSign("SHA256");return e.write(y.from(o)),e.end(),e.sign(c,"hex")};export{m as signWithApiKey}; diff --git a/assets/purejs-D68kuBYn.js b/assets/purejs-DbBnR00B.js similarity index 92% rename from assets/purejs-D68kuBYn.js rename to assets/purejs-DbBnR00B.js index d083b19..348150a 100644 --- a/assets/purejs-D68kuBYn.js +++ b/assets/purejs-DbBnR00B.js @@ -1 +1 @@ -import{F as n,c as s,s as i,u as r,b as o}from"./index-BLNnbgD0.js";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const t=n(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),g=t.create(BigInt("-3")),d=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),c=s({a:g,b:d,Fp:t,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},i),u=async f=>{const a=c.getPublicKey(f.privateKey,!0),e=r(a);if(e!=f.publicKey)throw new Error(`Bad API key. Expected to get public key ${f.publicKey}, got ${e}`);const b=o().update(f.content).digest();return c.sign(b,f.privateKey).toDERHex()};export{u as signWithApiKey}; +import{F as n,c as s,s as i,u as r,b as o}from"./index-kgT-H_GF.js";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const t=n(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),g=t.create(BigInt("-3")),d=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),c=s({a:g,b:d,Fp:t,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},i),u=async f=>{const a=c.getPublicKey(f.privateKey,!0),e=r(a);if(e!=f.publicKey)throw new Error(`Bad API key. Expected to get public key ${f.publicKey}, got ${e}`);const b=o().update(f.content).digest();return c.sign(b,f.privateKey).toDERHex()};export{u as signWithApiKey}; diff --git a/assets/utils-XOiObzyy.js b/assets/utils-kOKXth6J.js similarity index 98% rename from assets/utils-XOiObzyy.js rename to assets/utils-kOKXth6J.js index eea9c52..21e3537 100644 --- a/assets/utils-XOiObzyy.js +++ b/assets/utils-kOKXth6J.js @@ -1,4 +1,4 @@ -import{a as d,h as B,D as w}from"./index-BLNnbgD0.js";/** +import{a as d,h as B,D as w}from"./index-kgT-H_GF.js";/** * Code modified from https://github.com/google/tink/blob/6f74b99a2bfe6677e3670799116a57268fd067fa/javascript/subtle/bytes.ts * * @license diff --git a/assets/webcrypto-BG4hfxBn.js b/assets/webcrypto-D3OqlkPG.js similarity index 90% rename from assets/webcrypto-BG4hfxBn.js rename to assets/webcrypto-D3OqlkPG.js index 013a6b0..829af81 100644 --- a/assets/webcrypto-BG4hfxBn.js +++ b/assets/webcrypto-D3OqlkPG.js @@ -1 +1 @@ -import{c}from"./utils-XOiObzyy.js";import{u as i}from"./index-BLNnbgD0.js";const p=async n=>{const{content:e,publicKey:s,privateKey:t}=n,o=await g({uncompressedPrivateKeyHex:t,compressedPublicKeyHex:s});return await l({key:o,content:e})};async function g(n){const{uncompressedPrivateKeyHex:e,compressedPublicKeyHex:s}=n,t=c({uncompressedPrivateKeyHex:e,compressedPublicKeyHex:s});return await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"])}async function l(n){const{key:e,content:s}=n,t=await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},e,new TextEncoder().encode(s)),o=u(new Uint8Array(t));return i(o)}function u(n){if(n.length%2!=0||n.length==0||n.length>132)throw new Error("Invalid IEEE P1363 signature encoding. Length: "+n.length);const e=a(n.subarray(0,n.length/2)),s=a(n.subarray(n.length/2,n.length));let t=0;const o=2+e.length+1+1+s.length;let r;return o>=128?(r=new Uint8Array(o+3),r[t++]=48,r[t++]=129,r[t++]=o):(r=new Uint8Array(o+2),r[t++]=48,r[t++]=o),r[t++]=2,r[t++]=e.length,r.set(e,t),t+=e.length,r[t++]=2,r[t++]=s.length,r.set(s,t),r}function a(n){let e=0;for(;e{const{content:e,publicKey:s,privateKey:t}=n,o=await g({uncompressedPrivateKeyHex:t,compressedPublicKeyHex:s});return await l({key:o,content:e})};async function g(n){const{uncompressedPrivateKeyHex:e,compressedPublicKeyHex:s}=n,t=c({uncompressedPrivateKeyHex:e,compressedPublicKeyHex:s});return await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"])}async function l(n){const{key:e,content:s}=n,t=await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},e,new TextEncoder().encode(s)),o=u(new Uint8Array(t));return i(o)}function u(n){if(n.length%2!=0||n.length==0||n.length>132)throw new Error("Invalid IEEE P1363 signature encoding. Length: "+n.length);const e=a(n.subarray(0,n.length/2)),s=a(n.subarray(n.length/2,n.length));let t=0;const o=2+e.length+1+1+s.length;let r;return o>=128?(r=new Uint8Array(o+3),r[t++]=48,r[t++]=129,r[t++]=o):(r=new Uint8Array(o+2),r[t++]=48,r[t++]=o),r[t++]=2,r[t++]=e.length,r.set(e,t),t+=e.length,r[t++]=2,r[t++]=s.length,r.set(s,t),r}function a(n){let e=0;for(;e - +