@dcl/auth-site 4.11.8-22595822532.commit-afd96dd → 4.11.8-22634160443.commit-5b1560f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/assets/{ConstantsUtil-IDdlcd1R.js → ConstantsUtil-C6xH9UyP.js} +1 -1
  2. package/assets/{ContentfulRichText-D4aBlOCS.js → ContentfulRichText-CvZFzzK_.js} +1 -1
  3. package/assets/{ExchangeController-CdNMWCFY.js → ExchangeController-FZnj4LxT.js} +1 -1
  4. package/assets/{HelpersUtil-C-tF-mFe.js → HelpersUtil-BHTKFyTY.js} +1 -1
  5. package/assets/NetworkUtil-CiToBAqH.js +1 -0
  6. package/assets/{SwapController-C22Z0wcW.js → SwapController-DIK3_Pq2.js} +1 -1
  7. package/assets/{biconomy-CsbeHKGc.js → biconomy-BLH4Umhx.js} +1 -1
  8. package/assets/ccip-DjAX3Bdw.js +1 -0
  9. package/assets/{data-capture-CsxiqOap.js → data-capture-BNDInnY2.js} +3 -3
  10. package/assets/{email-fUFAiT2-.js → email-dhyjmszY.js} +6 -6
  11. package/assets/{embedded-wallet-ByhNQW_m.js → embedded-wallet-70Hh47Ef.js} +6 -6
  12. package/assets/{engine-D-Ovp2TM.js → engine-Cm7828E0.js} +1 -1
  13. package/assets/{extractIPFS-CLKrpjwD.js → extractIPFS-QEKpuDLZ.js} +1 -1
  14. package/assets/{features-CWGDlAbL.js → features-jSIGbet2.js} +1 -1
  15. package/assets/{fortmatic-dqMA7imt.js → fortmatic-D4Nrstgq.js} +1 -1
  16. package/assets/{getInstalledModules-I7ouqKHk.js → getInstalledModules-C0hChFxJ.js} +1 -1
  17. package/assets/{if-defined-CX592d7e.js → if-defined-D89My_ZP.js} +1 -1
  18. package/assets/{in-app-wallet-calls-BojXfO-N.js → in-app-wallet-calls-IsDTrLc7.js} +1 -1
  19. package/assets/{index-oScHGSy6.js → index-4I9NzFJv.js} +4 -4
  20. package/assets/{index-BFxczUld.js → index-7Va013F9.js} +1 -1
  21. package/assets/{index-DrVuM1V8.js → index-9peCPOrA.js} +1 -1
  22. package/assets/{index-_oohqe1q.js → index-B0HsKsDe.js} +3 -3
  23. package/assets/{index-Dz4wl94s.js → index-BB6s2-It.js} +1 -1
  24. package/assets/{index-DYhRHUaQ.js → index-BQ-sm_aL.js} +4 -4
  25. package/assets/{index-Cu7g55gd.js → index-BUM4MaNm.js} +1 -1
  26. package/assets/{index-VteGn-Hg.js → index-BY-hlUy7.js} +1 -1
  27. package/assets/{index-B-_eFHsW.js → index-B_AZ5wDn.js} +224 -195
  28. package/assets/{index-Cb7OJiUx.js → index-B_Uq8T7O.js} +1 -1
  29. package/assets/{index-CyQsNS2n.js → index-BhRCRgqq.js} +1 -1
  30. package/assets/{index-rdqbhPin.js → index-BiA2OKXm.js} +3 -3
  31. package/assets/{index-Bqa3GYNx.js → index-Bm_9y4d7.js} +1 -1
  32. package/assets/{index-Ptgsp97-.js → index-Bvcttfx0.js} +3 -3
  33. package/assets/{index-BC8kwCHT.js → index-BylUKYVf.js} +1 -1
  34. package/assets/index-C-EGhobM.js +21 -0
  35. package/assets/{index-s8aUs3iQ.js → index-CEbf5QXy.js} +1 -1
  36. package/assets/{index-D756ZP2E.js → index-CP2cHryG.js} +3 -3
  37. package/assets/{index-BLCMf4Dl.css → index-C_zlIEPk.css} +1 -1
  38. package/assets/index-ChXyq-Se.js +248 -0
  39. package/assets/index-Ci6kXWGE.js +13 -0
  40. package/assets/{index-889I9oIL.js → index-Cjn948YY.js} +3 -3
  41. package/assets/{index-CGtyOtb5.js → index-D2-MyM60.js} +1 -1
  42. package/assets/{index-BQomJqTo.js → index-D45rnhLA.js} +1 -1
  43. package/assets/{index-BSjmiClU.js → index-D5Kr4XIM.js} +1 -1
  44. package/assets/{index-BZVL4XGs.js → index-D9Ojjvvg.js} +3 -3
  45. package/assets/index-D9ZXbxtp.js +5 -0
  46. package/assets/{index-DtYhmtF7.js → index-DB0dbsZQ.js} +1 -1
  47. package/assets/index-DBY-jyYA.js +1 -0
  48. package/assets/{index-GhwyMHy6.js → index-DFJXow4r.js} +2 -2
  49. package/assets/{index-CfV4oumQ.js → index-DJapa1rL.js} +1 -1
  50. package/assets/{index-DGiPcc80.js → index-DM81rvDu.js} +4 -4
  51. package/assets/{index-DsAAirdR.js → index-Dc3BxEVE.js} +1 -1
  52. package/assets/{index-CxrHy176.js → index-DgQPUqhC.js} +1 -1
  53. package/assets/{index-uVpOzjx_.js → index-G7LJ1T06.js} +4 -4
  54. package/assets/index-TNWcYR4u.js +1 -0
  55. package/assets/{index-B5bQO_5Q.js → index-ZaFiMYvX.js} +2 -2
  56. package/assets/{index-DbFP4sQZ.js → index-Zt5i2Oy-.js} +1 -1
  57. package/assets/{index-CIdBLhTD.js → index-bWp6345C.js} +1 -1
  58. package/assets/{index-CwgUmhAO.js → index-eq19eLN8.js} +1 -1
  59. package/assets/{index-D4mhVfJ7.js → index-oSVEqpLR.js} +1 -1
  60. package/assets/index-uvW5oC3m.js +1 -0
  61. package/assets/{index-BmFli_oI.js → index-yfF0dl2Q.js} +1 -1
  62. package/assets/networks-DvJ9hDdm.js +3 -0
  63. package/assets/{onramp-DNtmpA6Y.js → onramp-DAHdHkh9.js} +1 -1
  64. package/assets/{openzeppelin-BVmZw860.js → openzeppelin--cyvYNdd.js} +1 -1
  65. package/assets/{parse-typed-data-Bz7EM74g.js → parse-typed-data-D_uwWtsO.js} +1 -1
  66. package/assets/passkeys-C02NitlT.js +1 -0
  67. package/assets/{pay-with-exchange-COuzct72.js → pay-with-exchange-qaM6jswB.js} +3 -3
  68. package/assets/{receive-DJ-kCiiX.js → receive-D1a8nATh.js} +3 -3
  69. package/assets/{ref-4FoIik5B.js → ref-Ed0dvGxF.js} +1 -1
  70. package/assets/{resolveImplementation-CWTRQlvf.js → resolveImplementation-DLIH3kSd.js} +1 -1
  71. package/assets/secp256k1-BkSYD3WR.js +1 -0
  72. package/assets/{send-BGQ3IUrv.js → send-BaXR8N2H.js} +4 -4
  73. package/assets/{send-eip712-transaction-b1J3Gfv4.js → send-eip712-transaction-BrJp8PDA.js} +1 -1
  74. package/assets/{send-gasless-transaction-CG-7Oc6z.js → send-gasless-transaction-JsxjV1UQ.js} +2 -2
  75. package/assets/{socials-Cx5_uD8B.js → socials-CWi5VKFt.js} +8 -8
  76. package/assets/successAnimation_Lottie-BpyTLLuX.js +1 -0
  77. package/assets/{swaps-BQNZs4oR.js → swaps-D7c5xvns.js} +1 -1
  78. package/assets/{thirdweb-CozZI4bW.js → thirdweb-ClXIkdqD.js} +6 -6
  79. package/assets/{transactions-4STPUm57.js → transactions-C0JnqWuq.js} +2 -2
  80. package/assets/ui-DHTUsjAL.js +741 -0
  81. package/assets/{vendor-CE6cyrlI.js → vendor-DrMguKq4.js} +1 -1
  82. package/assets/{w3m-modal-HqHeH3Ma.js → w3m-modal-B_18_udz.js} +1 -1
  83. package/assets/{web-connector-Dc49-8eH.js → web-connector-T2s1CHyq.js} +3 -3
  84. package/index.html +5 -5
  85. package/package.json +3 -3
  86. package/assets/NetworkUtil-B_5naIJv.js +0 -2
  87. package/assets/ccip-Ck_6HlbQ.js +0 -1
  88. package/assets/index-BWLwEJXK.js +0 -42
  89. package/assets/index-D2Kun0LZ.js +0 -13
  90. package/assets/index-Dv-Wyp9h.js +0 -1
  91. package/assets/index-IPnwlwFJ.js +0 -251
  92. package/assets/index-WkSlxog0.js +0 -7
  93. package/assets/networks-w0_eLt2M.js +0 -38
  94. package/assets/passkeys-DNsQ_KOr.js +0 -1
  95. package/assets/secp256k1-j5B89ek6.js +0 -1
  96. package/assets/sha256-D6ei3Af4.js +0 -1
  97. package/assets/ui-CqQlCpnD.js +0 -762
@@ -1,4 +1,4 @@
1
- import{g as sd}from"./thirdweb-CozZI4bW.js";function ad(o,c){for(var s=0;s<c.length;s++){const m=c[s];if(typeof m!="string"&&!Array.isArray(m)){for(const g in m)if(g!=="default"&&!(g in o)){const w=Object.getOwnPropertyDescriptor(m,g);w&&Object.defineProperty(o,g,w.get?w:{enumerable:!0,get:()=>m[g]})}}}return Object.freeze(Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}))}var Oi={exports:{}},Y={};/**
1
+ import{g as sd}from"./thirdweb-ClXIkdqD.js";function ad(o,c){for(var s=0;s<c.length;s++){const m=c[s];if(typeof m!="string"&&!Array.isArray(m)){for(const g in m)if(g!=="default"&&!(g in o)){const w=Object.getOwnPropertyDescriptor(m,g);w&&Object.defineProperty(o,g,w.get?w:{enumerable:!0,get:()=>m[g]})}}}return Object.freeze(Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}))}var Oi={exports:{}},Y={};/**
2
2
  * @license React
3
3
  * react.production.min.js
4
4
  *
@@ -1,4 +1,4 @@
1
- import{M as x,a4 as ae,R as c,o as de,j as C,r as L,l as y,m as d,u as _,k as ue,v as D,C as g,z as j,a1 as he,E as U,O as R,y as F,n as pe,S as O,L as z,T as me,a5 as fe,a6 as we}from"./index-IPnwlwFJ.js";import{c as w,n as l,r as u,U as ne}from"./index-GhwyMHy6.js";import{o as W}from"./if-defined-CX592d7e.js";import"./index-Cu7g55gd.js";import"./index-DtYhmtF7.js";import{H as ee}from"./HelpersUtil-C-tF-mFe.js";import{C as V}from"./ConstantsUtil-IDdlcd1R.js";import"./index-rdqbhPin.js";import"./index-DsAAirdR.js";import"./index-BFxczUld.js";import"./index-s8aUs3iQ.js";import{S as be}from"./SwapController-C22Z0wcW.js";import"./index-DrVuM1V8.js";import"./thirdweb-CozZI4bW.js";import"./NetworkUtil-B_5naIJv.js";import"./index-B-_eFHsW.js";import"./ui-CqQlCpnD.js";import"./vendor-CE6cyrlI.js";import"./index-D756ZP2E.js";import"./index-CIdBLhTD.js";import"./index-_oohqe1q.js";const se={isUnsupportedChainView(){return c.state.view==="UnsupportedChain"||c.state.view==="SwitchNetwork"&&c.state.history.includes("UnsupportedChain")},async safeClose(){if(this.isUnsupportedChainView()){x.shake();return}if(await ae.isSIWXCloseDisabled()){x.shake();return}(c.state.view==="DataCapture"||c.state.view==="DataCaptureOtpConfirm")&&de.disconnect(),x.close()}},ge=C`
1
+ import{M as x,a9 as ae,R as c,x as de,m as C,r as L,o as y,q as d,D as _,n as ue,v as D,C as g,H as j,a6 as he,E as U,O as R,G as F,t as pe,S as O,X as z,T as me,aa as fe,ab as we}from"./index-ChXyq-Se.js";import{c as w,n as l,r as u,U as ne}from"./index-DFJXow4r.js";import{o as W}from"./if-defined-D89My_ZP.js";import"./index-BUM4MaNm.js";import"./index-DB0dbsZQ.js";import{H as ee}from"./HelpersUtil-BHTKFyTY.js";import{C as V}from"./ConstantsUtil-C6xH9UyP.js";import"./index-BiA2OKXm.js";import"./index-Dc3BxEVE.js";import"./index-7Va013F9.js";import"./index-CEbf5QXy.js";import{S as be}from"./SwapController-DIK3_Pq2.js";import"./index-9peCPOrA.js";import"./thirdweb-ClXIkdqD.js";import"./NetworkUtil-CiToBAqH.js";import"./index-B_AZ5wDn.js";import"./ui-DHTUsjAL.js";import"./vendor-DrMguKq4.js";import"./index-CP2cHryG.js";import"./index-bWp6345C.js";import"./index-B0HsKsDe.js";const se={isUnsupportedChainView(){return c.state.view==="UnsupportedChain"||c.state.view==="SwitchNetwork"&&c.state.history.includes("UnsupportedChain")},async safeClose(){if(this.isUnsupportedChainView()){x.shake();return}if(await ae.isSIWXCloseDisabled()){x.shake();return}(c.state.view==="DataCapture"||c.state.view==="DataCaptureOtpConfirm")&&de.disconnect(),x.close()}},ge=C`
2
2
  :host {
3
3
  display: block;
4
4
  border-radius: clamp(0px, ${({borderRadius:e})=>e[8]}, 44px);
@@ -1,9 +1,9 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/in-app-wallet-calls-BojXfO-N.js","assets/thirdweb-CozZI4bW.js","assets/passkeys-DNsQ_KOr.js","assets/index-B-_eFHsW.js","assets/ui-CqQlCpnD.js","assets/vendor-CE6cyrlI.js","assets/index-BLCMf4Dl.css"])))=>i.map(i=>d[i]);
2
- import{K as w,ai as g,i as p,r as X,T as I,m as y,_ as k,aj as Z,b as P,A as M,ad as z,y as W,j as ee,ak as v,al as $,am as te}from"./thirdweb-CozZI4bW.js";import{a as ne}from"./types-DC0Zmj1B.js";import{p as G}from"./parse-typed-data-Bz7EM74g.js";const x={async getItem(n){try{if(typeof window<"u"&&window.localStorage)return localStorage.getItem(n)}catch{}return null},async removeItem(n){typeof window<"u"&&window.localStorage&&localStorage.removeItem(n)},async setItem(n,e){try{typeof window<"u"&&window.localStorage&&localStorage.setItem(n,e)}catch{}}},ae="/sdk/2022-08-12/embedded-wallet",A=n=>`thirdwebEwsWalletUserId-${n}`,ie="walletToken",T=n=>`${ie}-${n}`,j=n=>`passkey-credential-id-${n}`,re="a",E=(n,e)=>`${re}-${n}-${e}`,D=n=>`walletConnectSessions-${n}`,U=n=>`thirdweb_guest_session_id_${n}`,F=new Map;class H{constructor({storage:e,clientId:t,ecosystem:a}){Object.defineProperty(this,"key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.storage=e,this.key=se(t,a==null?void 0:a.id),this.ecosystem=a}async getItem(e){return this.storage?this.storage.getItem(e):F.get(e)??null}async setItem(e,t){if(this.storage)return this.storage.setItem(e,t);F.set(e,t)}async removeItem(e){const t=await this.getItem(e);return this.storage&&t?(this.storage.removeItem(e),!0):!1}async getWalletConnectSessions(){return this.getItem(D(this.key))}async saveWalletConnectSessions(e){await this.setItem(D(this.key),e)}async savePasskeyCredentialId(e){await this.setItem(j(this.key),e)}async getPasskeyCredentialId(){return this.getItem(j(this.key))}async saveAuthCookie(e){await this.setItem(T(this.key),e)}async getAuthCookie(){return this.getItem(T(this.key))}async removeAuthCookie(){return this.removeItem(T(this.key))}async saveDeviceShare(e,t){await this.saveWalletUserId(t),await this.setItem(E(this.key,t),e)}async getDeviceShare(){const e=await this.getWalletUserId();return e?this.getItem(E(this.key,e)):null}async removeDeviceShare(){const e=await this.getWalletUserId();return e?this.removeItem(E(this.key,e)):!1}async getWalletUserId(){return this.getItem(A(this.key))}async saveWalletUserId(e){await this.setItem(A(this.key),e)}async removeWalletUserId(){return this.removeItem(A(this.key))}async getGuestSessionId(){return this.getItem(U(this.key))}async saveGuestSessionId(e){await this.setItem(U(this.key),e)}}const se=(n,e)=>`${n}${e?`-${e}`:""}`,L=new Map,oe={getItem:async n=>L.get(n)??null,removeItem:async n=>{L.delete(n)},setItem:async(n,e)=>{L.set(n,e)}};async function O({authToken:n,client:e,ecosystem:t}){const r=await w(e,t)(`${g("inAppWallet")}/api/2024-05-05/accounts`,{headers:{Authorization:`Bearer embedded-wallet-token:${n}`,"Content-Type":"application/json"},method:"GET"});if(!r.ok){const c=await r.text().catch(()=>"Unknown error");throw new Error(`Failed to get user info: ${c}`)}return await r.json()}const ce=g("inAppWallet"),le=`${ce}/`,V=`${le}api/2023-10-20`,ue=`${V}/embedded-wallet/validate-custom-jwt`,de=`${V}/embedded-wallet/validate-custom-auth-endpoint`,q=(n,e)=>e instanceof Error?`${n}: ${e.message}`:`${n}: ${p(e)}`;async function he(n){const t=await w(n.client,n.ecosystem)(de,{body:p({developerClientId:n.client.clientId,payload:n.payload}),headers:{"Content-Type":"application/json"},method:"POST"});if(!t.ok){const a=await t.json();throw new Error(`Custom auth endpoint authentication error: ${a.message}`)}try{const{verifiedToken:a}=await t.json();return{storedToken:a}}catch(a){throw new Error(q("Malformed response from post auth_endpoint authentication",a))}}const Q=n=>{if(!ne.includes(n))throw new Error(`Unknown auth option ${n}`);switch(n){case"wallet":return"siwe";default:return n}},b=({authOption:n,client:e,ecosystem:t,mode:a="popup",redirectUrl:r})=>{if(a==="popup"&&r)throw new Error("Redirect URL is not supported for popup mode");if(a==="window"&&!r)throw new Error("Redirect URL is required for window mode");const c=Q(n);let o=`${g("inAppWallet")}/api/2024-05-05/login/${c}?clientId=${e.clientId}`;if(t!=null&&t.partnerId?o=`${o}&ecosystemId=${t.id}&ecosystemPartnerId=${t.partnerId}`:t&&(o=`${o}&ecosystemId=${t.id}`),a!=="popup"){const i=new URL(r||window.location.href);i.searchParams.set("walletId",(t==null?void 0:t.id)||"inApp"),i.searchParams.set("authProvider",n),o=`${o}&redirectUrl=${encodeURIComponent(i.toString())}`}return o},C=({authOption:n,client:e,ecosystem:t})=>{const a=Q(n);let r=`${g("inAppWallet")}/api/2024-05-05/login/${a}/callback?clientId=${e.clientId}`;return t!=null&&t.partnerId?r=`${r}&ecosystemId=${t.id}&ecosystemPartnerId=${t.partnerId}`:t&&(r=`${r}&ecosystemId=${t.id}`),r};async function we(n){const e=w(n.client,n.ecosystem),t=b({authOption:"backend",client:n.client,ecosystem:n.ecosystem}),a=await e(`${t}`,{body:p({walletSecret:n.walletSecret}),headers:{"Content-Type":"application/json"},method:"POST"});if(!a.ok){const r=await a.text();throw new Error(`Failed to generate backend account: ${r}`)}return await a.json()}async function ge(n){let e=await n.storage.getGuestSessionId();e||(e=X(32),n.storage.saveGuestSessionId(e));const t=w(n.client,n.ecosystem),a=C({authOption:"guest",client:n.client,ecosystem:n.ecosystem}),r=await t(`${a}`,{body:p({sessionId:e}),headers:{"Content-Type":"application/json"},method:"POST"});if(!r.ok){const c=await r.text();throw new Error(`Failed to generate guest account: ${r.status} ${r.statusText} ${c}`)}return await r.json()}async function pe(n){const t=await w(n.client,n.ecosystem)(ue,{body:p({developerClientId:n.client.clientId,jwt:n.jwt}),headers:{"Content-Type":"application/json"},method:"POST"});if(!t.ok){const a=await t.json();throw new Error(`JWT authentication error: ${a.message}`)}try{const{verifiedToken:a}=await t.json();return{storedToken:a}}catch(a){throw new Error(q("Malformed response from post jwt authentication",a))}}async function me({client:n,ecosystem:e,tokenToLink:t,storage:a}){const r=w(n,e),c=g("inAppWallet"),o=await a.getAuthCookie();if(!o)throw new Error("Failed to link account, no user logged in");const i={Authorization:`Bearer iaw-auth-token:${o}`,"Content-Type":"application/json"},l=await r(`${c}/api/2024-05-05/account/connect`,{body:p({accountAuthTokenToConnect:t}),headers:i,method:"POST"});if(!l.ok){const u=await l.json();throw new Error(u.message||"Failed to link account.")}const{linkedAccounts:s}=await l.json();return s??[]}async function fe({client:n,ecosystem:e,profileToUnlink:t,allowAccountDeletion:a=!1,storage:r}){const c=w(n,e),o=g("inAppWallet"),i=await r.getAuthCookie();if(!i)throw new Error("Failed to unlink account, no user logged in");const l={Authorization:`Bearer iaw-auth-token:${i}`,"Content-Type":"application/json"},s=await c(`${o}/api/2024-05-05/account/disconnect`,{body:p({allowAccountDeletion:a,details:t.details,type:t.type}),headers:l,method:"POST"});if(!s.ok){const d=await s.json();throw new Error(d.message||"Failed to unlink account.")}const{linkedAccounts:u}=await s.json();return u??[]}async function ye({client:n,ecosystem:e,storage:t}){const a=w(n,e),r=g("inAppWallet"),c=await t.getAuthCookie();if(!c)throw new Error("Failed to get linked accounts, no user logged in");const o={Authorization:`Bearer iaw-auth-token:${c}`,"Content-Type":"application/json"},i=await a(`${r}/api/2024-05-05/accounts`,{headers:o,method:"GET"});if(!i.ok){const s=await i.json();throw new Error(s.message||"Failed to get linked accounts.")}const{linkedAccounts:l}=await i.json();return l??[]}function J(){return`${g("inAppWallet")}/api/2024-05-05/login/passkey/callback`}function K(n,e){return`${g("inAppWallet")}/api/2024-05-05/login/passkey?type=${n}${e?`&username=${e}`:""}`}async function Ie(n){var u,d,h;if(!n.passkeyClient.isAvailable())throw new Error("Passkeys are not available on this device");const e=w(n.client,n.ecosystem),t=n.username??ke(n.ecosystem),r=await(await e(K("sign-up",t))).json();if(!r.challenge)throw new Error("No challenge received");const c=r.challenge,o=await n.passkeyClient.register({challenge:c,name:t,rp:n.rp}),i={};(u=n.ecosystem)!=null&&u.partnerId&&(i["x-ecosystem-partner-id"]=n.ecosystem.partnerId),(d=n.ecosystem)!=null&&d.id&&(i["x-ecosystem-id"]=n.ecosystem.id);const s=await(await e(J(),{body:p({authenticatorData:o.authenticatorData,clientData:o.clientData,credential:{algorithm:o.credential.algorithm,publicKey:o.credential.publicKey},credentialId:o.credentialId,origin:o.origin,rpId:n.rp.id,serverVerificationId:r.serverVerificationId,type:"sign-up",username:t}),headers:{"Content-Type":"application/json",...i},method:"POST"})).json();if(!s||!s.storedToken)throw new Error(`Error verifying passkey: ${s.message??"unknown error"}`);return await((h=n.storage)==null?void 0:h.savePasskeyCredentialId(o.credentialId)),s}async function be(n){var s,u,d,h;if(!n.passkeyClient.isAvailable())throw new Error("Passkeys are not available on this device");const e=w(n.client,n.ecosystem),[t,a]=await Promise.all([e(K("sign-in")).then(f=>f.json()),(s=n.storage)==null?void 0:s.getPasskeyCredentialId()]);if(!t.challenge)throw new Error("No challenge received");const r=t.challenge,c=await n.passkeyClient.authenticate({challenge:r,credentialId:a??void 0,rp:n.rp}),o={};(u=n.ecosystem)!=null&&u.partnerId&&(o["x-ecosystem-partner-id"]=n.ecosystem.partnerId),(d=n.ecosystem)!=null&&d.id&&(o["x-ecosystem-id"]=n.ecosystem.id);const l=await(await e(J(),{body:p({authenticatorData:c.authenticatorData,clientData:c.clientData,credentialId:c.credentialId,origin:c.origin,rpId:n.rp.id,serverVerificationId:t.serverVerificationId,signature:c.signature,type:"sign-in"}),headers:{"Content-Type":"application/json",...o},method:"POST"})).json();if(!l||!l.storedToken)throw new Error(`Error verifying passkey: ${l.message??"unknown error"}`);return await((h=n.storage)==null?void 0:h.savePasskeyCredentialId(c.credentialId)),l}function ke(n){return`${(n==null?void 0:n.id)??"wallet"}-${new Date().toISOString()}`}function ve(n){let a=[`${n.domain} wants you to sign in with your Ethereum account:`,n.address].join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/in-app-wallet-calls-IsDTrLc7.js","assets/thirdweb-ClXIkdqD.js","assets/passkeys-C02NitlT.js","assets/index-B_AZ5wDn.js","assets/ui-DHTUsjAL.js","assets/vendor-DrMguKq4.js","assets/index-C_zlIEPk.css"])))=>i.map(i=>d[i]);
2
+ import{K as w,ai as g,i as p,r as X,T as I,m as y,_ as k,aj as Z,b as P,A as M,ad as z,y as W,j as ee,ak as v,al as $,am as te}from"./thirdweb-ClXIkdqD.js";import{a as ne}from"./types-DC0Zmj1B.js";import{p as G}from"./parse-typed-data-D_uwWtsO.js";const x={async getItem(n){try{if(typeof window<"u"&&window.localStorage)return localStorage.getItem(n)}catch{}return null},async removeItem(n){typeof window<"u"&&window.localStorage&&localStorage.removeItem(n)},async setItem(n,e){try{typeof window<"u"&&window.localStorage&&localStorage.setItem(n,e)}catch{}}},ae="/sdk/2022-08-12/embedded-wallet",A=n=>`thirdwebEwsWalletUserId-${n}`,ie="walletToken",T=n=>`${ie}-${n}`,j=n=>`passkey-credential-id-${n}`,re="a",E=(n,e)=>`${re}-${n}-${e}`,D=n=>`walletConnectSessions-${n}`,U=n=>`thirdweb_guest_session_id_${n}`,F=new Map;class H{constructor({storage:e,clientId:t,ecosystem:a}){Object.defineProperty(this,"key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.storage=e,this.key=se(t,a==null?void 0:a.id),this.ecosystem=a}async getItem(e){return this.storage?this.storage.getItem(e):F.get(e)??null}async setItem(e,t){if(this.storage)return this.storage.setItem(e,t);F.set(e,t)}async removeItem(e){const t=await this.getItem(e);return this.storage&&t?(this.storage.removeItem(e),!0):!1}async getWalletConnectSessions(){return this.getItem(D(this.key))}async saveWalletConnectSessions(e){await this.setItem(D(this.key),e)}async savePasskeyCredentialId(e){await this.setItem(j(this.key),e)}async getPasskeyCredentialId(){return this.getItem(j(this.key))}async saveAuthCookie(e){await this.setItem(T(this.key),e)}async getAuthCookie(){return this.getItem(T(this.key))}async removeAuthCookie(){return this.removeItem(T(this.key))}async saveDeviceShare(e,t){await this.saveWalletUserId(t),await this.setItem(E(this.key,t),e)}async getDeviceShare(){const e=await this.getWalletUserId();return e?this.getItem(E(this.key,e)):null}async removeDeviceShare(){const e=await this.getWalletUserId();return e?this.removeItem(E(this.key,e)):!1}async getWalletUserId(){return this.getItem(A(this.key))}async saveWalletUserId(e){await this.setItem(A(this.key),e)}async removeWalletUserId(){return this.removeItem(A(this.key))}async getGuestSessionId(){return this.getItem(U(this.key))}async saveGuestSessionId(e){await this.setItem(U(this.key),e)}}const se=(n,e)=>`${n}${e?`-${e}`:""}`,L=new Map,oe={getItem:async n=>L.get(n)??null,removeItem:async n=>{L.delete(n)},setItem:async(n,e)=>{L.set(n,e)}};async function O({authToken:n,client:e,ecosystem:t}){const r=await w(e,t)(`${g("inAppWallet")}/api/2024-05-05/accounts`,{headers:{Authorization:`Bearer embedded-wallet-token:${n}`,"Content-Type":"application/json"},method:"GET"});if(!r.ok){const c=await r.text().catch(()=>"Unknown error");throw new Error(`Failed to get user info: ${c}`)}return await r.json()}const ce=g("inAppWallet"),le=`${ce}/`,V=`${le}api/2023-10-20`,ue=`${V}/embedded-wallet/validate-custom-jwt`,de=`${V}/embedded-wallet/validate-custom-auth-endpoint`,q=(n,e)=>e instanceof Error?`${n}: ${e.message}`:`${n}: ${p(e)}`;async function he(n){const t=await w(n.client,n.ecosystem)(de,{body:p({developerClientId:n.client.clientId,payload:n.payload}),headers:{"Content-Type":"application/json"},method:"POST"});if(!t.ok){const a=await t.json();throw new Error(`Custom auth endpoint authentication error: ${a.message}`)}try{const{verifiedToken:a}=await t.json();return{storedToken:a}}catch(a){throw new Error(q("Malformed response from post auth_endpoint authentication",a))}}const Q=n=>{if(!ne.includes(n))throw new Error(`Unknown auth option ${n}`);switch(n){case"wallet":return"siwe";default:return n}},b=({authOption:n,client:e,ecosystem:t,mode:a="popup",redirectUrl:r})=>{if(a==="popup"&&r)throw new Error("Redirect URL is not supported for popup mode");if(a==="window"&&!r)throw new Error("Redirect URL is required for window mode");const c=Q(n);let o=`${g("inAppWallet")}/api/2024-05-05/login/${c}?clientId=${e.clientId}`;if(t!=null&&t.partnerId?o=`${o}&ecosystemId=${t.id}&ecosystemPartnerId=${t.partnerId}`:t&&(o=`${o}&ecosystemId=${t.id}`),a!=="popup"){const i=new URL(r||window.location.href);i.searchParams.set("walletId",(t==null?void 0:t.id)||"inApp"),i.searchParams.set("authProvider",n),o=`${o}&redirectUrl=${encodeURIComponent(i.toString())}`}return o},C=({authOption:n,client:e,ecosystem:t})=>{const a=Q(n);let r=`${g("inAppWallet")}/api/2024-05-05/login/${a}/callback?clientId=${e.clientId}`;return t!=null&&t.partnerId?r=`${r}&ecosystemId=${t.id}&ecosystemPartnerId=${t.partnerId}`:t&&(r=`${r}&ecosystemId=${t.id}`),r};async function we(n){const e=w(n.client,n.ecosystem),t=b({authOption:"backend",client:n.client,ecosystem:n.ecosystem}),a=await e(`${t}`,{body:p({walletSecret:n.walletSecret}),headers:{"Content-Type":"application/json"},method:"POST"});if(!a.ok){const r=await a.text();throw new Error(`Failed to generate backend account: ${r}`)}return await a.json()}async function ge(n){let e=await n.storage.getGuestSessionId();e||(e=X(32),n.storage.saveGuestSessionId(e));const t=w(n.client,n.ecosystem),a=C({authOption:"guest",client:n.client,ecosystem:n.ecosystem}),r=await t(`${a}`,{body:p({sessionId:e}),headers:{"Content-Type":"application/json"},method:"POST"});if(!r.ok){const c=await r.text();throw new Error(`Failed to generate guest account: ${r.status} ${r.statusText} ${c}`)}return await r.json()}async function pe(n){const t=await w(n.client,n.ecosystem)(ue,{body:p({developerClientId:n.client.clientId,jwt:n.jwt}),headers:{"Content-Type":"application/json"},method:"POST"});if(!t.ok){const a=await t.json();throw new Error(`JWT authentication error: ${a.message}`)}try{const{verifiedToken:a}=await t.json();return{storedToken:a}}catch(a){throw new Error(q("Malformed response from post jwt authentication",a))}}async function me({client:n,ecosystem:e,tokenToLink:t,storage:a}){const r=w(n,e),c=g("inAppWallet"),o=await a.getAuthCookie();if(!o)throw new Error("Failed to link account, no user logged in");const i={Authorization:`Bearer iaw-auth-token:${o}`,"Content-Type":"application/json"},l=await r(`${c}/api/2024-05-05/account/connect`,{body:p({accountAuthTokenToConnect:t}),headers:i,method:"POST"});if(!l.ok){const u=await l.json();throw new Error(u.message||"Failed to link account.")}const{linkedAccounts:s}=await l.json();return s??[]}async function fe({client:n,ecosystem:e,profileToUnlink:t,allowAccountDeletion:a=!1,storage:r}){const c=w(n,e),o=g("inAppWallet"),i=await r.getAuthCookie();if(!i)throw new Error("Failed to unlink account, no user logged in");const l={Authorization:`Bearer iaw-auth-token:${i}`,"Content-Type":"application/json"},s=await c(`${o}/api/2024-05-05/account/disconnect`,{body:p({allowAccountDeletion:a,details:t.details,type:t.type}),headers:l,method:"POST"});if(!s.ok){const d=await s.json();throw new Error(d.message||"Failed to unlink account.")}const{linkedAccounts:u}=await s.json();return u??[]}async function ye({client:n,ecosystem:e,storage:t}){const a=w(n,e),r=g("inAppWallet"),c=await t.getAuthCookie();if(!c)throw new Error("Failed to get linked accounts, no user logged in");const o={Authorization:`Bearer iaw-auth-token:${c}`,"Content-Type":"application/json"},i=await a(`${r}/api/2024-05-05/accounts`,{headers:o,method:"GET"});if(!i.ok){const s=await i.json();throw new Error(s.message||"Failed to get linked accounts.")}const{linkedAccounts:l}=await i.json();return l??[]}function J(){return`${g("inAppWallet")}/api/2024-05-05/login/passkey/callback`}function K(n,e){return`${g("inAppWallet")}/api/2024-05-05/login/passkey?type=${n}${e?`&username=${e}`:""}`}async function Ie(n){var u,d,h;if(!n.passkeyClient.isAvailable())throw new Error("Passkeys are not available on this device");const e=w(n.client,n.ecosystem),t=n.username??ke(n.ecosystem),r=await(await e(K("sign-up",t))).json();if(!r.challenge)throw new Error("No challenge received");const c=r.challenge,o=await n.passkeyClient.register({challenge:c,name:t,rp:n.rp}),i={};(u=n.ecosystem)!=null&&u.partnerId&&(i["x-ecosystem-partner-id"]=n.ecosystem.partnerId),(d=n.ecosystem)!=null&&d.id&&(i["x-ecosystem-id"]=n.ecosystem.id);const s=await(await e(J(),{body:p({authenticatorData:o.authenticatorData,clientData:o.clientData,credential:{algorithm:o.credential.algorithm,publicKey:o.credential.publicKey},credentialId:o.credentialId,origin:o.origin,rpId:n.rp.id,serverVerificationId:r.serverVerificationId,type:"sign-up",username:t}),headers:{"Content-Type":"application/json",...i},method:"POST"})).json();if(!s||!s.storedToken)throw new Error(`Error verifying passkey: ${s.message??"unknown error"}`);return await((h=n.storage)==null?void 0:h.savePasskeyCredentialId(o.credentialId)),s}async function be(n){var s,u,d,h;if(!n.passkeyClient.isAvailable())throw new Error("Passkeys are not available on this device");const e=w(n.client,n.ecosystem),[t,a]=await Promise.all([e(K("sign-in")).then(f=>f.json()),(s=n.storage)==null?void 0:s.getPasskeyCredentialId()]);if(!t.challenge)throw new Error("No challenge received");const r=t.challenge,c=await n.passkeyClient.authenticate({challenge:r,credentialId:a??void 0,rp:n.rp}),o={};(u=n.ecosystem)!=null&&u.partnerId&&(o["x-ecosystem-partner-id"]=n.ecosystem.partnerId),(d=n.ecosystem)!=null&&d.id&&(o["x-ecosystem-id"]=n.ecosystem.id);const l=await(await e(J(),{body:p({authenticatorData:c.authenticatorData,clientData:c.clientData,credentialId:c.credentialId,origin:c.origin,rpId:n.rp.id,serverVerificationId:t.serverVerificationId,signature:c.signature,type:"sign-in"}),headers:{"Content-Type":"application/json",...o},method:"POST"})).json();if(!l||!l.storedToken)throw new Error(`Error verifying passkey: ${l.message??"unknown error"}`);return await((h=n.storage)==null?void 0:h.savePasskeyCredentialId(c.credentialId)),l}function ke(n){return`${(n==null?void 0:n.id)??"wallet"}-${new Date().toISOString()}`}function ve(n){let a=[`${n.domain} wants you to sign in with your Ethereum account:`,n.address].join(`
3
3
  `);a=[a,n.statement].join(`
4
4
 
5
5
  `),n.statement&&(a+=`
6
6
  `);const r=[];if(n.uri){const u=`URI: ${n.uri}`;r.push(u)}const c=`Version: ${n.version}`;if(r.push(c),n.chain_id){const u=`Chain ID: ${n.chain_id}`||"1";r.push(u)}const o=`Nonce: ${n.nonce}`;r.push(o);const i=`Issued At: ${n.issued_at}`;r.push(i);const l=`Expiration Time: ${n.expiration_time}`;if(r.push(l),n.invalid_before){const u=`Not Before: ${n.invalid_before}`;r.push(u)}n.resources&&r.push(["Resources:",...n.resources.map(u=>`- ${u}`)].join(`
7
7
  `));const s=r.join(`
8
8
  `);return[a,s].join(`
9
- `)}async function Ae(n){const{payload:e,account:t}=n,a=await t.signMessage({message:ve(e)});return{payload:e,signature:a}}const Te=["xyz.abs"];async function Ee(n){const{wallet:e,client:t,ecosystem:a,chain:r}=n,c=Te.includes(e.id)?r||I(1):I(1),o=e.getAccount()||await e.connect({chain:c,client:t}),i=w(t,a),l=await(async()=>{const d=b({authOption:"wallet",client:n.client,ecosystem:n.ecosystem}),h=await i(`${d}&address=${o.address}&chainId=${c.id}`);if(!h.ok)throw new Error("Failed to generate SIWE login payload");return await h.json()})(),{signature:s}=await Ae({account:o,payload:l});return await(async()=>{const d=C({authOption:"wallet",client:n.client,ecosystem:n.ecosystem}),h=await i(`${d}&signature=${s}&payload=${encodeURIComponent(l)}`,{body:p({payload:l,signature:s}),headers:{"Content-Type":"application/json"},method:"POST"});if(!h.ok)throw new Error("Failed to verify SIWE signature");return await h.json()})()}async function Le({client:n,payload:e,storage:t}){const a=await t.getAuthCookie(),r=t.ecosystem,c=w(n,r);if(!a)throw new Error("No auth token found when signing message");const o={address:e.address,chainId:e.chainId,nonce:Number(e.nonce)},i=await c(`${g("inAppWallet")}/api/v1/enclave-wallet/sign-authorization`,{body:p(o),headers:{Authorization:`Bearer embedded-wallet-token:${a}`,"Content-Type":"application/json","x-thirdweb-client-id":n.clientId},method:"POST"});if(!i.ok)throw new Error(`Failed to sign message - ${i.status} ${i.statusText}`);return await i.json()}async function Se({client:n,payload:{message:e,isRaw:t,originalMessage:a,chainId:r},storage:c}){const o=await c.getAuthCookie(),i=c.ecosystem,l=w(n,i);if(!o)throw new Error("No auth token found when signing message");const s=await l(`${g("inAppWallet")}/api/v1/enclave-wallet/sign-message`,{body:p({messagePayload:{chainId:r,isRaw:t,message:e,originalMessage:a}}),headers:{Authorization:`Bearer embedded-wallet-token:${o}`,"Content-Type":"application/json","x-thirdweb-client-id":n.clientId},method:"POST"});if(!s.ok)throw new Error(`Failed to sign message - ${s.status} ${s.statusText}`);return await s.json()}async function Pe({client:n,payload:e,storage:t}){const a=await t.getAuthCookie(),r=t.ecosystem,c=w(n,r);if(!a)throw new Error("No auth token found when signing transaction");const o=await c(`${g("inAppWallet")}/api/v1/enclave-wallet/sign-transaction`,{body:p({transactionPayload:e}),headers:{Authorization:`Bearer embedded-wallet-token:${a}`,"Content-Type":"application/json","x-thirdweb-client-id":n.clientId},method:"POST"});if(!o.ok)throw new Error(`Failed to sign transaction - ${o.status} ${o.statusText}`);return(await o.json()).signature}async function We({client:n,payload:e,storage:t}){const a=await t.getAuthCookie(),r=t.ecosystem,c=w(n,r);if(!a)throw new Error("No auth token found when signing typed data");const o=await c(`${g("inAppWallet")}/api/v1/enclave-wallet/sign-typed-data`,{body:p({...e}),headers:{Authorization:`Bearer embedded-wallet-token:${a}`,"Content-Type":"application/json","x-thirdweb-client-id":n.clientId},method:"POST"});if(!o.ok)throw new Error(`Failed to sign typed data - ${o.status} ${o.statusText}`);return await o.json()}class Oe{constructor({client:e,ecosystem:t,address:a,storage:r}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"address",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=t,this.address=a,this.localStorage=r}async postWalletSetUp(e){await this.localStorage.saveAuthCookie(e.storedToken.cookieString)}async getUserWalletStatus(){var c,o;const e=await this.localStorage.getAuthCookie();if(!e)return{status:"Logged Out"};const t=await O({authToken:e,client:this.client,ecosystem:this.ecosystem});if(!t)return{status:"Logged Out"};const a=t.wallets[0],r={email:(c=t.linkedAccounts.find(i=>i.details.email!==void 0))==null?void 0:c.details.email,phoneNumber:(o=t.linkedAccounts.find(i=>i.details.phone!==void 0))==null?void 0:o.details.phone,recoveryShareManagement:"ENCLAVE",userWalletId:t.id||""};return a?{account:await this.getAccount(),authDetails:r,status:"Logged In, Wallet Initialized",walletAddress:a.address}:{authDetails:r,status:"Logged In, Wallet Uninitialized"}}async getAccount(){const e=this.client,t=this.localStorage,a=this.address,r=this.ecosystem,c=async i=>{const l=P({chain:I(i.chainId),client:e}),s={chainId:W(i.chainId),data:i.data,gas:m(i.gas),nonce:m(i.nonce)||W(await k(async()=>{const{eth_getTransactionCount:u}=await import("./thirdweb-CozZI4bW.js").then(d=>d.av);return{eth_getTransactionCount:u}},[]).then(({eth_getTransactionCount:u})=>u(l,{address:y(this.address),blockTag:"pending"}))),to:i.to?y(i.to):void 0,value:m(i.value)};return i.authorizationList&&i.authorizationList.length>0?(s.type=4,s.authorizationList=i.authorizationList,s.maxFeePerGas=m(i.maxFeePerGas),s.maxPriorityFeePerGas=m(i.maxPriorityFeePerGas)):m(i.maxFeePerGas)?(s.maxFeePerGas=m(i.maxFeePerGas),s.maxPriorityFeePerGas=m(i.maxPriorityFeePerGas),s.type=2):(s.gasPrice=m(i.gasPrice),s.type=0),Pe({client:e,payload:s,storage:t})},o={address:y(a),async sendTransaction(i){const l=P({chain:I(i.chainId),client:e}),s=await c(i),u=await M(l,s);return z({chainId:i.chainId,client:e,contractAddress:i.to??void 0,ecosystem:r,gasPrice:i.gasPrice,transactionHash:u,walletAddress:a,walletType:"inApp"}),{transactionHash:u}},async signAuthorization(i){const l=await Le({client:e,payload:i,storage:t});return{address:y(l.address),chainId:Number.parseInt(l.chainId),nonce:BigInt(l.nonce),r:BigInt(l.r),s:BigInt(l.s),yParity:Number.parseInt(l.yParity)}},async signMessage({message:i,originalMessage:l,chainId:s}){const u=typeof i=="string"?{chainId:s,isRaw:!1,message:i,originalMessage:l}:{chainId:s,isRaw:!0,message:typeof i.raw=="string"?i.raw:Z(i.raw),originalMessage:l},{signature:d}=await Se({client:e,payload:u,storage:t});return d},async signTransaction(i){if(!i.chainId)throw new Error("chainId required in tx to sign");return c({chainId:i.chainId,...i})},async signTypedData(i){const l=G(i),{signature:s}=await We({client:e,payload:l,storage:t});return s},sendCalls:async i=>{const{inAppWalletSendCalls:l}=await k(async()=>{const{inAppWalletSendCalls:f}=await import("./in-app-wallet-calls-BojXfO-N.js");return{inAppWalletSendCalls:f}},__vite__mapDeps([0,1])),s=i.calls[0];if(!s)throw new Error("No calls to send");const u=s.client,d=s.chain||i.chain,h=await l({account:o,calls:i.calls,chain:d});return{chain:d,client:u,id:h}},getCallsStatus:async i=>{const{inAppWalletGetCallsStatus:l}=await k(async()=>{const{inAppWalletGetCallsStatus:s}=await import("./in-app-wallet-calls-BojXfO-N.js");return{inAppWalletGetCallsStatus:s}},__vite__mapDeps([0,1]));return l(i)},getCapabilities:async i=>({[i.chainId??1]:{atomic:{status:"unsupported"},paymasterService:{supported:!1}}})};return o}}function m(n){return n===void 0||ee(n)?n:W(n)}const Ce={backgroundColor:"transparent",border:"none",colorScheme:"light",display:"none",height:"100%",pointerEvents:"all",position:"fixed",right:"0px",top:"0px",width:"100%",zIndex:"2147483646"},S=new Map;class _e{constructor({link:e,baseUrl:t,iframeId:a,container:r,onIframeInitialize:c,localStorage:o,clientId:i,ecosystem:l}){if(Object.defineProperty(this,"iframe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"POLLING_INTERVAL_SECONDS",{enumerable:!0,configurable:!0,writable:!0,value:1.4}),Object.defineProperty(this,"iframeBaseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.localStorage=o,this.clientId=i,this.ecosystem=l,this.iframeBaseUrl=t,typeof document>"u")return;r=r??document.body;let s=document.getElementById(a);const u=new URL(e);if(!s||s.src!==u.href){s=document.createElement("iframe");const d={...Ce};Object.assign(s.style,d),s.setAttribute("id",a),s.setAttribute("fetchpriority","high"),r.appendChild(s),s.src=u.href;const h=f=>{if(f.data.eventType==="ewsIframeLoaded"){if(window.removeEventListener("message",h),!s){console.warn("thirdweb iFrame not found");return}this.onIframeLoadHandler(s,c)()}};window.addEventListener("message",h)}this.iframe=s}async onIframeLoadedInitVariables(){var e,t;return{authCookie:await this.localStorage.getAuthCookie(),clientId:this.clientId,deviceShareStored:await this.localStorage.getDeviceShare(),ecosystemId:(e=this.ecosystem)==null?void 0:e.id,partnerId:(t=this.ecosystem)==null?void 0:t.partnerId,walletUserId:await this.localStorage.getWalletUserId()}}onIframeLoadHandler(e,t){return async()=>{var c;const a=new MessageChannel,r=new Promise((o,i)=>{a.port1.onmessage=l=>{const{data:s}=l;a.port1.close(),s.success||i(new Error(s.error)),S.set(e.src,!0),t&&t(),o(!0)}});(c=e==null?void 0:e.contentWindow)==null||c.postMessage({data:await this.onIframeLoadedInitVariables(),eventType:"initIframe"},this.iframeBaseUrl,[a.port2]),await r}}async call({procedureName:e,params:t,showIframe:a=!1}){var o;if(!this.iframe)throw new Error("Iframe not found. You are likely calling this from the backend where the DOM is not available.");for(;!S.get(this.iframe.src);)await v(this.POLLING_INTERVAL_SECONDS*1e3);a&&(this.iframe.style.display="block",await v(.005*1e3));const r=new MessageChannel,c=new Promise((i,l)=>{r.port1.onmessage=async s=>{const{data:u}=s;r.port1.close(),a&&(await v(.1*1e3),this.iframe&&(this.iframe.style.display="none")),u.success?i(u.data):l(new Error(u.error))}});return(o=this.iframe.contentWindow)==null||o.postMessage({data:{...t,...await this.onIframeLoadedInitVariables()},eventType:e},this.iframeBaseUrl,[r.port2]),c}destroy(){this.iframe&&S.delete(this.iframe.src)}}class $e extends _e{constructor({clientId:e,baseUrl:t,ecosystem:a}){super({baseUrl:t,clientId:e,container:typeof document>"u"?void 0:document.body,ecosystem:a,iframeId:De+((a==null?void 0:a.id)||""),link:je({baseUrl:t,clientId:e,ecosystem:a,path:ae}).href,localStorage:new H({clientId:e,ecosystem:a,storage:x})}),this.clientId=e,this.ecosystem=a}}function je({clientId:n,baseUrl:e,path:t,ecosystem:a,queryParams:r}){var o;const c=new URL(`${t}`,e);if(r)for(const i of Object.keys(r))c.searchParams.set(i,((o=r[i])==null?void 0:o.toString())||"");return c.searchParams.set("clientId",n),(a==null?void 0:a.partnerId)!==void 0&&c.searchParams.set("partnerId",a.partnerId),(a==null?void 0:a.id)!==void 0&&c.searchParams.set("ecosystemId",a.id),c}const De="thirdweb-in-app-wallet-iframe";async function Ue({client:n,ecosystem:e,authToken:t}){const r=await w(n,e)(`${g("inAppWallet")}/api/v1/enclave-wallet/generate`,{headers:{Authorization:`Bearer embedded-wallet-token:${t}`,"Content-Type":"application/json","x-thirdweb-client-id":n.clientId},method:"POST"});if(!r.ok)throw new Error(`Failed to generate wallet - ${r.status} ${r.statusText}`);const{wallet:c}=await r.json();return c}class Fe{constructor({baseUrl:e,querier:t,preLogin:a,postLogin:r,client:c,ecosystem:o}){Object.defineProperty(this,"LoginQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"preLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"postLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.baseUrl=e,this.LoginQuerier=t,this.preLogin=a,this.postLogin=r,this.client=c,this.ecosystem=o}async sendEmailLoginOtp({email:e}){return await this.LoginQuerier.call({params:{email:e},procedureName:"sendThirdwebEmailLoginOtp"})}async sendSmsLoginOtp({phoneNumber:e}){return await this.LoginQuerier.call({params:{phoneNumber:e},procedureName:"sendThirdwebSmsLoginOtp"})}}class Ne extends Fe{async authenticateWithModal(){return this.LoginQuerier.call({params:void 0,procedureName:"loginWithThirdwebModal",showIframe:!0})}async loginWithModal(){await this.preLogin();const e=await this.authenticateWithModal();return this.postLogin(e)}async authenticateWithIframe({email:e}){return this.LoginQuerier.call({params:{email:e},procedureName:"loginWithThirdwebModal",showIframe:!0})}async loginWithIframe({email:e}){await this.preLogin();const t=await this.authenticateWithIframe({email:e});return this.postLogin(t)}async authenticateWithCustomJwt({encryptionKey:e,jwt:t}){if(!e||e.length===0)throw new Error("Encryption key is required for custom jwt auth");return this.LoginQuerier.call({params:{encryptionKey:e,jwt:t},procedureName:"loginWithCustomJwt"})}async loginWithCustomJwt({encryptionKey:e,jwt:t}){if(!e||e.length===0)throw new Error("Encryption key is required for custom jwt auth");await this.preLogin();const a=await this.authenticateWithCustomJwt({encryptionKey:e,jwt:t});return this.postLogin(a)}async authenticateWithCustomAuthEndpoint({encryptionKey:e,payload:t}){return this.LoginQuerier.call({params:{encryptionKey:e,payload:t},procedureName:"loginWithCustomAuthEndpoint"})}async loginWithCustomAuthEndpoint({encryptionKey:e,payload:t}){if(!e||e.length===0)throw new Error("Encryption key is required for custom auth");await this.preLogin();const a=await this.authenticateWithCustomAuthEndpoint({encryptionKey:e,payload:t});return this.postLogin(a)}async authenticateWithEmailOtp({email:e,otp:t,recoveryCode:a}){return this.LoginQuerier.call({params:{email:e,otp:t,recoveryCode:a},procedureName:"verifyThirdwebEmailLoginOtp"})}async loginWithEmailOtp({email:e,otp:t,recoveryCode:a}){const r=await this.authenticateWithEmailOtp({email:e,otp:t,recoveryCode:a});return this.postLogin(r)}async authenticateWithSmsOtp({phoneNumber:e,otp:t,recoveryCode:a}){return this.LoginQuerier.call({params:{otp:t,phoneNumber:e,recoveryCode:a},procedureName:"verifyThirdwebSmsLoginOtp"})}async loginWithSmsOtp({phoneNumber:e,otp:t,recoveryCode:a}){const r=await this.authenticateWithSmsOtp({otp:t,phoneNumber:e,recoveryCode:a});return this.postLogin(r)}}class Re{constructor({client:e,querier:t,onAuthSuccess:a,ecosystem:r,baseUrl:c,localStorage:o}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"AuthQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onAuthSuccess",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BaseLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=r,this.AuthQuerier=t,this.localStorage=o,this.onAuthSuccess=a,this.BaseLogin=new Ne({baseUrl:c,client:e,ecosystem:r,postLogin:async i=>this.postLogin(i),preLogin:async()=>{await this.preLogin()},querier:t})}async preLogin(){await this.logout()}async postLogin({storedToken:e,walletDetails:t}){return e.shouldStoreCookieString&&await this.localStorage.saveAuthCookie(e.cookieString),await this.onAuthSuccess({storedToken:e,walletDetails:t})}async loginWithAuthToken(e,t){var c;e.storedToken.authProvider!=="Backend"&&await this.preLogin();const a=await O({authToken:e.storedToken.cookieString,client:this.client,ecosystem:this.ecosystem});if(!a)throw new Error("Cannot login, no user found for auth token");if(a.wallets.length>0&&((c=a.wallets[0])==null?void 0:c.type)==="enclave")return this.postLogin({storedToken:e.storedToken,walletDetails:{walletAddress:a.wallets[0].address}});if(a.wallets.length===0){const o=await Ue({authToken:e.storedToken.cookieString,client:this.client,ecosystem:this.ecosystem});return this.postLogin({storedToken:e.storedToken,walletDetails:{walletAddress:o.address}})}const r=await this.AuthQuerier.call({params:{recoveryCode:t,storedToken:e.storedToken},procedureName:"loginWithStoredTokenDetails"});return this.postLogin(r)}async loginWithModal(){return this.BaseLogin.loginWithModal()}async authenticateWithModal(){return this.BaseLogin.authenticateWithModal()}async loginWithIframe(e){return this.BaseLogin.loginWithIframe(e)}async authenticateWithIframe(e){return this.BaseLogin.authenticateWithIframe(e)}async loginWithCustomJwt(e){return this.BaseLogin.loginWithCustomJwt(e)}async authenticateWithCustomJwt(e){return this.BaseLogin.authenticateWithCustomJwt(e)}async loginWithCustomAuthEndpoint(e){return this.BaseLogin.loginWithCustomAuthEndpoint(e)}async authenticateWithCustomAuthEndpoint(e){return this.BaseLogin.authenticateWithCustomAuthEndpoint(e)}async sendEmailLoginOtp({email:e}){return this.BaseLogin.sendEmailLoginOtp({email:e})}async sendSmsLoginOtp({phoneNumber:e}){return this.BaseLogin.sendSmsLoginOtp({phoneNumber:e})}async loginWithEmailOtp(e){return await this.preLogin(),this.BaseLogin.loginWithEmailOtp(e)}async authenticateWithEmailOtp(e){return this.BaseLogin.authenticateWithEmailOtp(e)}async loginWithSmsOtp(e){return await this.preLogin(),this.BaseLogin.loginWithSmsOtp(e)}async authenticateWithSmsOtp(e){return this.BaseLogin.authenticateWithSmsOtp(e)}async logout(){const e=await this.localStorage.removeAuthCookie(),t=await this.localStorage.removeWalletUserId();return{success:e||t}}}const Be="width=350, height=500",N=({isWindowOpenedByFn:n,win:e,closeOpenedWindow:t})=>{n?e==null||e.close():e&&t?t(e):e&&e.close()};async function Me(n){const e=b({...n,mode:n.mode||"redirect"});n.mode==="redirect"?window.location.href=e:window.open(e),await new Promise(t=>setTimeout(t,5e3))}const ze=async n=>{let e=n.openedWindow,t=!1;if(e||(e=window.open(b({...n,mode:"popup"}),`Login to ${n.authOption}`,Be),t=!0),!e)throw new Error("Something went wrong opening pop-up");return await new Promise((r,c)=>{const o=window.setInterval(async()=>{e.closed&&(clearInterval(o),window.removeEventListener("message",i),c(new Error("User closed login window")))},1e3),i=async l=>{if(l.origin===g("inAppWallet")){if(typeof l.data!="object"){c(new Error("Invalid event data"));return}switch(l.data.eventType){case"oauthSuccessResult":{window.removeEventListener("message",i),clearInterval(o),N({closeOpenedWindow:n.closeOpenedWindow,isWindowOpenedByFn:t,win:e}),l.data.authResult&&r(l.data.authResult);break}case"oauthFailureResult":{window.removeEventListener("message",i),clearInterval(o),N({closeOpenedWindow:n.closeOpenedWindow,isWindowOpenedByFn:t,win:e}),c(new Error(l.data.errorString));break}}}};window.addEventListener("message",i)})},Ge=async n=>{const{client:e,ecosystem:t}=n,a=b({authOption:n.strategy,client:e,ecosystem:t}),r={"Content-Type":"application/json","x-client-id":e.clientId};t!=null&&t.id&&(r["x-ecosystem-id"]=t.id),t!=null&&t.partnerId&&(r["x-ecosystem-partner-id"]=t.partnerId);const c=(()=>{switch(n.strategy){case"email":return{email:n.email};case"phone":return{phone:n.phoneNumber}}})(),o=await fetch(a,{body:p(c),headers:r,method:"POST"});if(!o.ok)throw new Error("Failed to send verification code");return await o.json()},R=async n=>{const{client:e,ecosystem:t}=n,a=C({authOption:n.strategy,client:n.client,ecosystem:n.ecosystem}),r={"Content-Type":"application/json","x-client-id":e.clientId};t!=null&&t.id&&(r["x-ecosystem-id"]=t.id),t!=null&&t.partnerId&&(r["x-ecosystem-partner-id"]=t.partnerId);const c=(()=>{switch(n.strategy){case"email":return{code:n.verificationCode,email:n.email};case"phone":return{code:n.verificationCode,phone:n.phoneNumber}}})(),o=await fetch(a,{body:p(c),headers:r,method:"POST"});if(!o.ok)throw new Error("Failed to verify verification code");return await o.json()};class B{constructor({client:e,ecosystem:t,querier:a,localStorage:r}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"walletManagerQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=t,this.walletManagerQuerier=a,this.localStorage=r}async postWalletSetUp(e){e.deviceShareStored&&await this.localStorage.saveDeviceShare(e.deviceShareStored,e.storedToken.authDetails.userWalletId)}async getUserWalletStatus(){const e=await this.walletManagerQuerier.call({params:void 0,procedureName:"getUserStatus"});return e.status==="Logged In, Wallet Initialized"?{status:"Logged In, Wallet Initialized",...e.user,account:await this.getAccount()}:e.status==="Logged In, New Device"?{status:"Logged In, New Device",...e.user}:e.status==="Logged In, Wallet Uninitialized"?{status:"Logged In, Wallet Uninitialized",...e.user}:{status:e.status}}async getAccount(){var o;const e=this.walletManagerQuerier,t=this.client,a=(o=this.ecosystem)==null?void 0:o.partnerId,{address:r}=await e.call({params:void 0,procedureName:"getAddress"}),c=async i=>{const l={chainId:i.chainId,data:i.data,gasLimit:i.gas,nonce:i.nonce,to:i.to??void 0,value:i.value};i.maxFeePerGas?(l.accessList=i.accessList,l.maxFeePerGas=i.maxFeePerGas,l.maxPriorityFeePerGas=i.maxPriorityFeePerGas,l.type=2):(l.gasPrice=i.gasPrice,l.type=0);const s=$().rpc,{signedTransaction:u}=await e.call({params:{chainId:i.chainId,partnerId:a,rpcEndpoint:`https://${i.chainId}.${s}`,transaction:l},procedureName:"signTransaction"});return u};return{address:y(r),async sendTransaction(i){const l=P({chain:I(i.chainId),client:t}),s=await c(i),u=await M(l,s);return z({chainId:i.chainId,client:t,contractAddress:i.to??void 0,gasPrice:i.gasPrice,transactionHash:u,walletAddress:r,walletType:"inApp"}),{transactionHash:u}},async signMessage({message:i}){const l=typeof i=="string"?i:i.raw instanceof Uint8Array?i.raw:te(i.raw),{signedMessage:s}=await e.call({params:{chainId:1,message:l,partnerId:a},procedureName:"signMessage"});return s},async signTransaction(i){if(!i.chainId)throw new Error("chainId required in tx to sign");return c({...i,chainId:i.chainId})},async signTypedData(i){var _;const l=G(i);(_=l.types)!=null&&_.EIP712Domain&&(l.types.EIP712Domain=void 0);const s=l.domain,u=s==null?void 0:s.chainId,h={...s!=null&&s.verifyingContract?{verifyingContract:s==null?void 0:s.verifyingContract}:{},name:s==null?void 0:s.name,version:s==null?void 0:s.version};u&&(h.chainId=u);const f=$().rpc,{signedTypedData:Y}=await e.call({params:{chainId:Number.parseInt(BigInt(u||1).toString()),domain:h,message:l.message,partnerId:a,rpcEndpoint:`https://${u}.${f}`,types:l.types},procedureName:"signTypedDataV4"});return Y}}}}class Je{isClientIdLegacyPaper(e){return e.indexOf("-")>0&&e.length===36}constructor({client:e,onAuthSuccess:t,ecosystem:a,passkeyDomain:r,storage:c}){if(Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"querier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"wallet",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"auth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"passkeyDomain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.isClientIdLegacyPaper(e.clientId))throw new Error("You are using a legacy clientId. Please use the clientId found on the thirdweb dashboard settings page");const o=g("inAppWallet");this.client=e,this.ecosystem=a,this.passkeyDomain=r,this.storage=new H({clientId:e.clientId,ecosystem:a,storage:c??He()}),this.querier=new $e({baseUrl:o,clientId:e.clientId,ecosystem:a}),this.auth=new Re({baseUrl:o,client:e,ecosystem:a,localStorage:this.storage,onAuthSuccess:async i=>{if(t==null||t(i),i.storedToken.authDetails.walletType==="sharded"&&(await this.querier.call({params:{storedToken:i.storedToken},procedureName:"migrateFromShardToEnclave"})||console.warn("Failed to migrate from sharded to enclave wallet, continuing with sharded wallet")),this.wallet=await this.initializeWallet(i.storedToken.cookieString),!this.wallet)throw new Error("Failed to initialize wallet");const l="deviceShareStored"in i.walletDetails?i.walletDetails.deviceShareStored:void 0;return await this.wallet.postWalletSetUp({deviceShareStored:l,storedToken:i.storedToken}),this.wallet instanceof B&&await this.querier.call({params:{authCookie:i.storedToken.cookieString,clientId:this.client.clientId,deviceShareStored:"deviceShareStored"in i.walletDetails?i.walletDetails.deviceShareStored:null,ecosystemId:a==null?void 0:a.id,partnerId:a==null?void 0:a.partnerId,walletUserId:i.storedToken.authDetails.userWalletId},procedureName:"initIframe"}),{user:{account:await this.wallet.getAccount(),authDetails:i.storedToken.authDetails,status:"Logged In, Wallet Initialized",walletAddress:i.walletDetails.walletAddress}}},querier:this.querier})}async initializeWallet(e){var r;const t=await this.storage.getAuthCookie();if(!e&&t===null)throw new Error("No auth token provided and no stored auth token found to initialize the wallet");const a=await O({authToken:e||t,client:this.client,ecosystem:this.ecosystem});if(!a)throw new Error("Cannot initialize wallet, no user logged in");if(a.wallets.length===0)throw new Error("Cannot initialize wallet, this user does not have a wallet generated yet");return((r=a.wallets[0])==null?void 0:r.type)==="enclave"?new Oe({address:a.wallets[0].address,client:this.client,ecosystem:this.ecosystem,storage:this.storage}):new B({client:this.client,ecosystem:this.ecosystem,localStorage:this.storage,querier:this.querier})}async getUser(){if(!this.wallet){const e=await this.storage.getAuthCookie();if(!e)return{status:"Logged Out"};this.wallet=await this.initializeWallet(e)}if(!this.wallet)throw new Error("Wallet not initialized");return await this.wallet.getUserWalletStatus()}getAccount(){if(!this.wallet)throw new Error("Wallet not initialized");return this.wallet.getAccount()}async preAuthenticate(e){return Ge({...e,client:this.client,ecosystem:this.ecosystem})}async authenticateWithRedirect(e,t,a){return Me({authOption:e,client:this.client,ecosystem:this.ecosystem,mode:t,redirectUrl:a})}async loginWithAuthToken(e,t){return this.auth.loginWithAuthToken(e,t)}async authenticate(e){const t=e.strategy;switch(t){case"email":return R({...e,client:this.client,ecosystem:this.ecosystem});case"phone":return R({...e,client:this.client,ecosystem:this.ecosystem});case"auth_endpoint":return he({client:this.client,ecosystem:this.ecosystem,payload:e.payload});case"jwt":return pe({client:this.client,ecosystem:this.ecosystem,jwt:e.jwt});case"passkey":return this.passkeyAuth(e);case"iframe_email_verification":return this.auth.authenticateWithIframe({email:e.email});case"iframe":return this.auth.authenticateWithModal();case"apple":case"facebook":case"google":case"telegram":case"github":case"twitch":case"farcaster":case"line":case"x":case"tiktok":case"epic":case"steam":case"coinbase":case"discord":return ze({authOption:t,client:this.client,closeOpenedWindow:e.closeOpenedWindow,ecosystem:this.ecosystem,openedWindow:e.openedWindow});case"guest":return ge({client:this.client,ecosystem:this.ecosystem,storage:this.storage});case"backend":return we({client:this.client,ecosystem:this.ecosystem,walletSecret:e.walletSecret});case"wallet":return Ee({client:this.client,ecosystem:this.ecosystem,wallet:e.wallet,chain:e.chain})}}async connect(e){const t=e.strategy;switch(t){case"auth_endpoint":case"jwt":{const a=await this.authenticate(e);return await this.loginWithAuthToken(a,e.encryptionKey)}case"iframe_email_verification":return this.auth.loginWithIframe({email:e.email});case"iframe":return this.auth.loginWithModal();case"passkey":{const a=await this.passkeyAuth(e);return this.loginWithAuthToken(a)}case"backend":case"phone":case"email":case"wallet":case"apple":case"facebook":case"google":case"farcaster":case"telegram":case"github":case"line":case"x":case"tiktok":case"epic":case"guest":case"coinbase":case"twitch":case"steam":case"discord":{const a=await this.authenticate(e);return await this.auth.loginWithAuthToken(a)}default:xe(t)}}async logout(){return await this.auth.logout()}async passkeyAuth(e){const{PasskeyWebClient:t}=await k(async()=>{const{PasskeyWebClient:i}=await import("./passkeys-DNsQ_KOr.js");return{PasskeyWebClient:i}},__vite__mapDeps([2,3,1,4,5,6])),{passkeyName:a,storeLastUsedPasskey:r=!0}=e,c=new t,o=this.storage;return e.type==="sign-up"?Ie({client:this.client,ecosystem:this.ecosystem,passkeyClient:c,rp:{id:this.passkeyDomain??window.location.hostname,name:this.passkeyDomain??window.document.title},storage:r?o:void 0,username:a}):be({client:this.client,ecosystem:this.ecosystem,passkeyClient:c,rp:{id:this.passkeyDomain??window.location.hostname,name:this.passkeyDomain??window.document.title},storage:r?o:void 0})}async linkProfile(e){const{storedToken:t}=await this.authenticate(e);return await me({client:e.client,ecosystem:e.ecosystem||this.ecosystem,storage:this.storage,tokenToLink:t.cookieString})}async unlinkProfile(e,t){return await fe({allowAccountDeletion:t,client:this.client,ecosystem:this.ecosystem,profileToUnlink:e,storage:this.storage})}async getProfiles(){return ye({client:this.client,ecosystem:this.ecosystem,storage:this.storage})}}function xe(n,e){throw new Error(`Invalid param: ${n}`)}function He(){return typeof window<"u"&&window.localStorage?x:oe}export{Je as InAppWebConnector};
9
+ `)}async function Ae(n){const{payload:e,account:t}=n,a=await t.signMessage({message:ve(e)});return{payload:e,signature:a}}const Te=["xyz.abs"];async function Ee(n){const{wallet:e,client:t,ecosystem:a,chain:r}=n,c=Te.includes(e.id)?r||I(1):I(1),o=e.getAccount()||await e.connect({chain:c,client:t}),i=w(t,a),l=await(async()=>{const d=b({authOption:"wallet",client:n.client,ecosystem:n.ecosystem}),h=await i(`${d}&address=${o.address}&chainId=${c.id}`);if(!h.ok)throw new Error("Failed to generate SIWE login payload");return await h.json()})(),{signature:s}=await Ae({account:o,payload:l});return await(async()=>{const d=C({authOption:"wallet",client:n.client,ecosystem:n.ecosystem}),h=await i(`${d}&signature=${s}&payload=${encodeURIComponent(l)}`,{body:p({payload:l,signature:s}),headers:{"Content-Type":"application/json"},method:"POST"});if(!h.ok)throw new Error("Failed to verify SIWE signature");return await h.json()})()}async function Le({client:n,payload:e,storage:t}){const a=await t.getAuthCookie(),r=t.ecosystem,c=w(n,r);if(!a)throw new Error("No auth token found when signing message");const o={address:e.address,chainId:e.chainId,nonce:Number(e.nonce)},i=await c(`${g("inAppWallet")}/api/v1/enclave-wallet/sign-authorization`,{body:p(o),headers:{Authorization:`Bearer embedded-wallet-token:${a}`,"Content-Type":"application/json","x-thirdweb-client-id":n.clientId},method:"POST"});if(!i.ok)throw new Error(`Failed to sign message - ${i.status} ${i.statusText}`);return await i.json()}async function Se({client:n,payload:{message:e,isRaw:t,originalMessage:a,chainId:r},storage:c}){const o=await c.getAuthCookie(),i=c.ecosystem,l=w(n,i);if(!o)throw new Error("No auth token found when signing message");const s=await l(`${g("inAppWallet")}/api/v1/enclave-wallet/sign-message`,{body:p({messagePayload:{chainId:r,isRaw:t,message:e,originalMessage:a}}),headers:{Authorization:`Bearer embedded-wallet-token:${o}`,"Content-Type":"application/json","x-thirdweb-client-id":n.clientId},method:"POST"});if(!s.ok)throw new Error(`Failed to sign message - ${s.status} ${s.statusText}`);return await s.json()}async function Pe({client:n,payload:e,storage:t}){const a=await t.getAuthCookie(),r=t.ecosystem,c=w(n,r);if(!a)throw new Error("No auth token found when signing transaction");const o=await c(`${g("inAppWallet")}/api/v1/enclave-wallet/sign-transaction`,{body:p({transactionPayload:e}),headers:{Authorization:`Bearer embedded-wallet-token:${a}`,"Content-Type":"application/json","x-thirdweb-client-id":n.clientId},method:"POST"});if(!o.ok)throw new Error(`Failed to sign transaction - ${o.status} ${o.statusText}`);return(await o.json()).signature}async function We({client:n,payload:e,storage:t}){const a=await t.getAuthCookie(),r=t.ecosystem,c=w(n,r);if(!a)throw new Error("No auth token found when signing typed data");const o=await c(`${g("inAppWallet")}/api/v1/enclave-wallet/sign-typed-data`,{body:p({...e}),headers:{Authorization:`Bearer embedded-wallet-token:${a}`,"Content-Type":"application/json","x-thirdweb-client-id":n.clientId},method:"POST"});if(!o.ok)throw new Error(`Failed to sign typed data - ${o.status} ${o.statusText}`);return await o.json()}class Oe{constructor({client:e,ecosystem:t,address:a,storage:r}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"address",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=t,this.address=a,this.localStorage=r}async postWalletSetUp(e){await this.localStorage.saveAuthCookie(e.storedToken.cookieString)}async getUserWalletStatus(){var c,o;const e=await this.localStorage.getAuthCookie();if(!e)return{status:"Logged Out"};const t=await O({authToken:e,client:this.client,ecosystem:this.ecosystem});if(!t)return{status:"Logged Out"};const a=t.wallets[0],r={email:(c=t.linkedAccounts.find(i=>i.details.email!==void 0))==null?void 0:c.details.email,phoneNumber:(o=t.linkedAccounts.find(i=>i.details.phone!==void 0))==null?void 0:o.details.phone,recoveryShareManagement:"ENCLAVE",userWalletId:t.id||""};return a?{account:await this.getAccount(),authDetails:r,status:"Logged In, Wallet Initialized",walletAddress:a.address}:{authDetails:r,status:"Logged In, Wallet Uninitialized"}}async getAccount(){const e=this.client,t=this.localStorage,a=this.address,r=this.ecosystem,c=async i=>{const l=P({chain:I(i.chainId),client:e}),s={chainId:W(i.chainId),data:i.data,gas:m(i.gas),nonce:m(i.nonce)||W(await k(async()=>{const{eth_getTransactionCount:u}=await import("./thirdweb-ClXIkdqD.js").then(d=>d.av);return{eth_getTransactionCount:u}},[]).then(({eth_getTransactionCount:u})=>u(l,{address:y(this.address),blockTag:"pending"}))),to:i.to?y(i.to):void 0,value:m(i.value)};return i.authorizationList&&i.authorizationList.length>0?(s.type=4,s.authorizationList=i.authorizationList,s.maxFeePerGas=m(i.maxFeePerGas),s.maxPriorityFeePerGas=m(i.maxPriorityFeePerGas)):m(i.maxFeePerGas)?(s.maxFeePerGas=m(i.maxFeePerGas),s.maxPriorityFeePerGas=m(i.maxPriorityFeePerGas),s.type=2):(s.gasPrice=m(i.gasPrice),s.type=0),Pe({client:e,payload:s,storage:t})},o={address:y(a),async sendTransaction(i){const l=P({chain:I(i.chainId),client:e}),s=await c(i),u=await M(l,s);return z({chainId:i.chainId,client:e,contractAddress:i.to??void 0,ecosystem:r,gasPrice:i.gasPrice,transactionHash:u,walletAddress:a,walletType:"inApp"}),{transactionHash:u}},async signAuthorization(i){const l=await Le({client:e,payload:i,storage:t});return{address:y(l.address),chainId:Number.parseInt(l.chainId),nonce:BigInt(l.nonce),r:BigInt(l.r),s:BigInt(l.s),yParity:Number.parseInt(l.yParity)}},async signMessage({message:i,originalMessage:l,chainId:s}){const u=typeof i=="string"?{chainId:s,isRaw:!1,message:i,originalMessage:l}:{chainId:s,isRaw:!0,message:typeof i.raw=="string"?i.raw:Z(i.raw),originalMessage:l},{signature:d}=await Se({client:e,payload:u,storage:t});return d},async signTransaction(i){if(!i.chainId)throw new Error("chainId required in tx to sign");return c({chainId:i.chainId,...i})},async signTypedData(i){const l=G(i),{signature:s}=await We({client:e,payload:l,storage:t});return s},sendCalls:async i=>{const{inAppWalletSendCalls:l}=await k(async()=>{const{inAppWalletSendCalls:f}=await import("./in-app-wallet-calls-IsDTrLc7.js");return{inAppWalletSendCalls:f}},__vite__mapDeps([0,1])),s=i.calls[0];if(!s)throw new Error("No calls to send");const u=s.client,d=s.chain||i.chain,h=await l({account:o,calls:i.calls,chain:d});return{chain:d,client:u,id:h}},getCallsStatus:async i=>{const{inAppWalletGetCallsStatus:l}=await k(async()=>{const{inAppWalletGetCallsStatus:s}=await import("./in-app-wallet-calls-IsDTrLc7.js");return{inAppWalletGetCallsStatus:s}},__vite__mapDeps([0,1]));return l(i)},getCapabilities:async i=>({[i.chainId??1]:{atomic:{status:"unsupported"},paymasterService:{supported:!1}}})};return o}}function m(n){return n===void 0||ee(n)?n:W(n)}const Ce={backgroundColor:"transparent",border:"none",colorScheme:"light",display:"none",height:"100%",pointerEvents:"all",position:"fixed",right:"0px",top:"0px",width:"100%",zIndex:"2147483646"},S=new Map;class _e{constructor({link:e,baseUrl:t,iframeId:a,container:r,onIframeInitialize:c,localStorage:o,clientId:i,ecosystem:l}){if(Object.defineProperty(this,"iframe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"POLLING_INTERVAL_SECONDS",{enumerable:!0,configurable:!0,writable:!0,value:1.4}),Object.defineProperty(this,"iframeBaseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.localStorage=o,this.clientId=i,this.ecosystem=l,this.iframeBaseUrl=t,typeof document>"u")return;r=r??document.body;let s=document.getElementById(a);const u=new URL(e);if(!s||s.src!==u.href){s=document.createElement("iframe");const d={...Ce};Object.assign(s.style,d),s.setAttribute("id",a),s.setAttribute("fetchpriority","high"),r.appendChild(s),s.src=u.href;const h=f=>{if(f.data.eventType==="ewsIframeLoaded"){if(window.removeEventListener("message",h),!s){console.warn("thirdweb iFrame not found");return}this.onIframeLoadHandler(s,c)()}};window.addEventListener("message",h)}this.iframe=s}async onIframeLoadedInitVariables(){var e,t;return{authCookie:await this.localStorage.getAuthCookie(),clientId:this.clientId,deviceShareStored:await this.localStorage.getDeviceShare(),ecosystemId:(e=this.ecosystem)==null?void 0:e.id,partnerId:(t=this.ecosystem)==null?void 0:t.partnerId,walletUserId:await this.localStorage.getWalletUserId()}}onIframeLoadHandler(e,t){return async()=>{var c;const a=new MessageChannel,r=new Promise((o,i)=>{a.port1.onmessage=l=>{const{data:s}=l;a.port1.close(),s.success||i(new Error(s.error)),S.set(e.src,!0),t&&t(),o(!0)}});(c=e==null?void 0:e.contentWindow)==null||c.postMessage({data:await this.onIframeLoadedInitVariables(),eventType:"initIframe"},this.iframeBaseUrl,[a.port2]),await r}}async call({procedureName:e,params:t,showIframe:a=!1}){var o;if(!this.iframe)throw new Error("Iframe not found. You are likely calling this from the backend where the DOM is not available.");for(;!S.get(this.iframe.src);)await v(this.POLLING_INTERVAL_SECONDS*1e3);a&&(this.iframe.style.display="block",await v(.005*1e3));const r=new MessageChannel,c=new Promise((i,l)=>{r.port1.onmessage=async s=>{const{data:u}=s;r.port1.close(),a&&(await v(.1*1e3),this.iframe&&(this.iframe.style.display="none")),u.success?i(u.data):l(new Error(u.error))}});return(o=this.iframe.contentWindow)==null||o.postMessage({data:{...t,...await this.onIframeLoadedInitVariables()},eventType:e},this.iframeBaseUrl,[r.port2]),c}destroy(){this.iframe&&S.delete(this.iframe.src)}}class $e extends _e{constructor({clientId:e,baseUrl:t,ecosystem:a}){super({baseUrl:t,clientId:e,container:typeof document>"u"?void 0:document.body,ecosystem:a,iframeId:De+((a==null?void 0:a.id)||""),link:je({baseUrl:t,clientId:e,ecosystem:a,path:ae}).href,localStorage:new H({clientId:e,ecosystem:a,storage:x})}),this.clientId=e,this.ecosystem=a}}function je({clientId:n,baseUrl:e,path:t,ecosystem:a,queryParams:r}){var o;const c=new URL(`${t}`,e);if(r)for(const i of Object.keys(r))c.searchParams.set(i,((o=r[i])==null?void 0:o.toString())||"");return c.searchParams.set("clientId",n),(a==null?void 0:a.partnerId)!==void 0&&c.searchParams.set("partnerId",a.partnerId),(a==null?void 0:a.id)!==void 0&&c.searchParams.set("ecosystemId",a.id),c}const De="thirdweb-in-app-wallet-iframe";async function Ue({client:n,ecosystem:e,authToken:t}){const r=await w(n,e)(`${g("inAppWallet")}/api/v1/enclave-wallet/generate`,{headers:{Authorization:`Bearer embedded-wallet-token:${t}`,"Content-Type":"application/json","x-thirdweb-client-id":n.clientId},method:"POST"});if(!r.ok)throw new Error(`Failed to generate wallet - ${r.status} ${r.statusText}`);const{wallet:c}=await r.json();return c}class Fe{constructor({baseUrl:e,querier:t,preLogin:a,postLogin:r,client:c,ecosystem:o}){Object.defineProperty(this,"LoginQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"preLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"postLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.baseUrl=e,this.LoginQuerier=t,this.preLogin=a,this.postLogin=r,this.client=c,this.ecosystem=o}async sendEmailLoginOtp({email:e}){return await this.LoginQuerier.call({params:{email:e},procedureName:"sendThirdwebEmailLoginOtp"})}async sendSmsLoginOtp({phoneNumber:e}){return await this.LoginQuerier.call({params:{phoneNumber:e},procedureName:"sendThirdwebSmsLoginOtp"})}}class Ne extends Fe{async authenticateWithModal(){return this.LoginQuerier.call({params:void 0,procedureName:"loginWithThirdwebModal",showIframe:!0})}async loginWithModal(){await this.preLogin();const e=await this.authenticateWithModal();return this.postLogin(e)}async authenticateWithIframe({email:e}){return this.LoginQuerier.call({params:{email:e},procedureName:"loginWithThirdwebModal",showIframe:!0})}async loginWithIframe({email:e}){await this.preLogin();const t=await this.authenticateWithIframe({email:e});return this.postLogin(t)}async authenticateWithCustomJwt({encryptionKey:e,jwt:t}){if(!e||e.length===0)throw new Error("Encryption key is required for custom jwt auth");return this.LoginQuerier.call({params:{encryptionKey:e,jwt:t},procedureName:"loginWithCustomJwt"})}async loginWithCustomJwt({encryptionKey:e,jwt:t}){if(!e||e.length===0)throw new Error("Encryption key is required for custom jwt auth");await this.preLogin();const a=await this.authenticateWithCustomJwt({encryptionKey:e,jwt:t});return this.postLogin(a)}async authenticateWithCustomAuthEndpoint({encryptionKey:e,payload:t}){return this.LoginQuerier.call({params:{encryptionKey:e,payload:t},procedureName:"loginWithCustomAuthEndpoint"})}async loginWithCustomAuthEndpoint({encryptionKey:e,payload:t}){if(!e||e.length===0)throw new Error("Encryption key is required for custom auth");await this.preLogin();const a=await this.authenticateWithCustomAuthEndpoint({encryptionKey:e,payload:t});return this.postLogin(a)}async authenticateWithEmailOtp({email:e,otp:t,recoveryCode:a}){return this.LoginQuerier.call({params:{email:e,otp:t,recoveryCode:a},procedureName:"verifyThirdwebEmailLoginOtp"})}async loginWithEmailOtp({email:e,otp:t,recoveryCode:a}){const r=await this.authenticateWithEmailOtp({email:e,otp:t,recoveryCode:a});return this.postLogin(r)}async authenticateWithSmsOtp({phoneNumber:e,otp:t,recoveryCode:a}){return this.LoginQuerier.call({params:{otp:t,phoneNumber:e,recoveryCode:a},procedureName:"verifyThirdwebSmsLoginOtp"})}async loginWithSmsOtp({phoneNumber:e,otp:t,recoveryCode:a}){const r=await this.authenticateWithSmsOtp({otp:t,phoneNumber:e,recoveryCode:a});return this.postLogin(r)}}class Re{constructor({client:e,querier:t,onAuthSuccess:a,ecosystem:r,baseUrl:c,localStorage:o}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"AuthQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onAuthSuccess",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BaseLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=r,this.AuthQuerier=t,this.localStorage=o,this.onAuthSuccess=a,this.BaseLogin=new Ne({baseUrl:c,client:e,ecosystem:r,postLogin:async i=>this.postLogin(i),preLogin:async()=>{await this.preLogin()},querier:t})}async preLogin(){await this.logout()}async postLogin({storedToken:e,walletDetails:t}){return e.shouldStoreCookieString&&await this.localStorage.saveAuthCookie(e.cookieString),await this.onAuthSuccess({storedToken:e,walletDetails:t})}async loginWithAuthToken(e,t){var c;e.storedToken.authProvider!=="Backend"&&await this.preLogin();const a=await O({authToken:e.storedToken.cookieString,client:this.client,ecosystem:this.ecosystem});if(!a)throw new Error("Cannot login, no user found for auth token");if(a.wallets.length>0&&((c=a.wallets[0])==null?void 0:c.type)==="enclave")return this.postLogin({storedToken:e.storedToken,walletDetails:{walletAddress:a.wallets[0].address}});if(a.wallets.length===0){const o=await Ue({authToken:e.storedToken.cookieString,client:this.client,ecosystem:this.ecosystem});return this.postLogin({storedToken:e.storedToken,walletDetails:{walletAddress:o.address}})}const r=await this.AuthQuerier.call({params:{recoveryCode:t,storedToken:e.storedToken},procedureName:"loginWithStoredTokenDetails"});return this.postLogin(r)}async loginWithModal(){return this.BaseLogin.loginWithModal()}async authenticateWithModal(){return this.BaseLogin.authenticateWithModal()}async loginWithIframe(e){return this.BaseLogin.loginWithIframe(e)}async authenticateWithIframe(e){return this.BaseLogin.authenticateWithIframe(e)}async loginWithCustomJwt(e){return this.BaseLogin.loginWithCustomJwt(e)}async authenticateWithCustomJwt(e){return this.BaseLogin.authenticateWithCustomJwt(e)}async loginWithCustomAuthEndpoint(e){return this.BaseLogin.loginWithCustomAuthEndpoint(e)}async authenticateWithCustomAuthEndpoint(e){return this.BaseLogin.authenticateWithCustomAuthEndpoint(e)}async sendEmailLoginOtp({email:e}){return this.BaseLogin.sendEmailLoginOtp({email:e})}async sendSmsLoginOtp({phoneNumber:e}){return this.BaseLogin.sendSmsLoginOtp({phoneNumber:e})}async loginWithEmailOtp(e){return await this.preLogin(),this.BaseLogin.loginWithEmailOtp(e)}async authenticateWithEmailOtp(e){return this.BaseLogin.authenticateWithEmailOtp(e)}async loginWithSmsOtp(e){return await this.preLogin(),this.BaseLogin.loginWithSmsOtp(e)}async authenticateWithSmsOtp(e){return this.BaseLogin.authenticateWithSmsOtp(e)}async logout(){const e=await this.localStorage.removeAuthCookie(),t=await this.localStorage.removeWalletUserId();return{success:e||t}}}const Be="width=350, height=500",N=({isWindowOpenedByFn:n,win:e,closeOpenedWindow:t})=>{n?e==null||e.close():e&&t?t(e):e&&e.close()};async function Me(n){const e=b({...n,mode:n.mode||"redirect"});n.mode==="redirect"?window.location.href=e:window.open(e),await new Promise(t=>setTimeout(t,5e3))}const ze=async n=>{let e=n.openedWindow,t=!1;if(e||(e=window.open(b({...n,mode:"popup"}),`Login to ${n.authOption}`,Be),t=!0),!e)throw new Error("Something went wrong opening pop-up");return await new Promise((r,c)=>{const o=window.setInterval(async()=>{e.closed&&(clearInterval(o),window.removeEventListener("message",i),c(new Error("User closed login window")))},1e3),i=async l=>{if(l.origin===g("inAppWallet")){if(typeof l.data!="object"){c(new Error("Invalid event data"));return}switch(l.data.eventType){case"oauthSuccessResult":{window.removeEventListener("message",i),clearInterval(o),N({closeOpenedWindow:n.closeOpenedWindow,isWindowOpenedByFn:t,win:e}),l.data.authResult&&r(l.data.authResult);break}case"oauthFailureResult":{window.removeEventListener("message",i),clearInterval(o),N({closeOpenedWindow:n.closeOpenedWindow,isWindowOpenedByFn:t,win:e}),c(new Error(l.data.errorString));break}}}};window.addEventListener("message",i)})},Ge=async n=>{const{client:e,ecosystem:t}=n,a=b({authOption:n.strategy,client:e,ecosystem:t}),r={"Content-Type":"application/json","x-client-id":e.clientId};t!=null&&t.id&&(r["x-ecosystem-id"]=t.id),t!=null&&t.partnerId&&(r["x-ecosystem-partner-id"]=t.partnerId);const c=(()=>{switch(n.strategy){case"email":return{email:n.email};case"phone":return{phone:n.phoneNumber}}})(),o=await fetch(a,{body:p(c),headers:r,method:"POST"});if(!o.ok)throw new Error("Failed to send verification code");return await o.json()},R=async n=>{const{client:e,ecosystem:t}=n,a=C({authOption:n.strategy,client:n.client,ecosystem:n.ecosystem}),r={"Content-Type":"application/json","x-client-id":e.clientId};t!=null&&t.id&&(r["x-ecosystem-id"]=t.id),t!=null&&t.partnerId&&(r["x-ecosystem-partner-id"]=t.partnerId);const c=(()=>{switch(n.strategy){case"email":return{code:n.verificationCode,email:n.email};case"phone":return{code:n.verificationCode,phone:n.phoneNumber}}})(),o=await fetch(a,{body:p(c),headers:r,method:"POST"});if(!o.ok)throw new Error("Failed to verify verification code");return await o.json()};class B{constructor({client:e,ecosystem:t,querier:a,localStorage:r}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"walletManagerQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=t,this.walletManagerQuerier=a,this.localStorage=r}async postWalletSetUp(e){e.deviceShareStored&&await this.localStorage.saveDeviceShare(e.deviceShareStored,e.storedToken.authDetails.userWalletId)}async getUserWalletStatus(){const e=await this.walletManagerQuerier.call({params:void 0,procedureName:"getUserStatus"});return e.status==="Logged In, Wallet Initialized"?{status:"Logged In, Wallet Initialized",...e.user,account:await this.getAccount()}:e.status==="Logged In, New Device"?{status:"Logged In, New Device",...e.user}:e.status==="Logged In, Wallet Uninitialized"?{status:"Logged In, Wallet Uninitialized",...e.user}:{status:e.status}}async getAccount(){var o;const e=this.walletManagerQuerier,t=this.client,a=(o=this.ecosystem)==null?void 0:o.partnerId,{address:r}=await e.call({params:void 0,procedureName:"getAddress"}),c=async i=>{const l={chainId:i.chainId,data:i.data,gasLimit:i.gas,nonce:i.nonce,to:i.to??void 0,value:i.value};i.maxFeePerGas?(l.accessList=i.accessList,l.maxFeePerGas=i.maxFeePerGas,l.maxPriorityFeePerGas=i.maxPriorityFeePerGas,l.type=2):(l.gasPrice=i.gasPrice,l.type=0);const s=$().rpc,{signedTransaction:u}=await e.call({params:{chainId:i.chainId,partnerId:a,rpcEndpoint:`https://${i.chainId}.${s}`,transaction:l},procedureName:"signTransaction"});return u};return{address:y(r),async sendTransaction(i){const l=P({chain:I(i.chainId),client:t}),s=await c(i),u=await M(l,s);return z({chainId:i.chainId,client:t,contractAddress:i.to??void 0,gasPrice:i.gasPrice,transactionHash:u,walletAddress:r,walletType:"inApp"}),{transactionHash:u}},async signMessage({message:i}){const l=typeof i=="string"?i:i.raw instanceof Uint8Array?i.raw:te(i.raw),{signedMessage:s}=await e.call({params:{chainId:1,message:l,partnerId:a},procedureName:"signMessage"});return s},async signTransaction(i){if(!i.chainId)throw new Error("chainId required in tx to sign");return c({...i,chainId:i.chainId})},async signTypedData(i){var _;const l=G(i);(_=l.types)!=null&&_.EIP712Domain&&(l.types.EIP712Domain=void 0);const s=l.domain,u=s==null?void 0:s.chainId,h={...s!=null&&s.verifyingContract?{verifyingContract:s==null?void 0:s.verifyingContract}:{},name:s==null?void 0:s.name,version:s==null?void 0:s.version};u&&(h.chainId=u);const f=$().rpc,{signedTypedData:Y}=await e.call({params:{chainId:Number.parseInt(BigInt(u||1).toString()),domain:h,message:l.message,partnerId:a,rpcEndpoint:`https://${u}.${f}`,types:l.types},procedureName:"signTypedDataV4"});return Y}}}}class Je{isClientIdLegacyPaper(e){return e.indexOf("-")>0&&e.length===36}constructor({client:e,onAuthSuccess:t,ecosystem:a,passkeyDomain:r,storage:c}){if(Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"querier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"wallet",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"auth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"passkeyDomain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.isClientIdLegacyPaper(e.clientId))throw new Error("You are using a legacy clientId. Please use the clientId found on the thirdweb dashboard settings page");const o=g("inAppWallet");this.client=e,this.ecosystem=a,this.passkeyDomain=r,this.storage=new H({clientId:e.clientId,ecosystem:a,storage:c??He()}),this.querier=new $e({baseUrl:o,clientId:e.clientId,ecosystem:a}),this.auth=new Re({baseUrl:o,client:e,ecosystem:a,localStorage:this.storage,onAuthSuccess:async i=>{if(t==null||t(i),i.storedToken.authDetails.walletType==="sharded"&&(await this.querier.call({params:{storedToken:i.storedToken},procedureName:"migrateFromShardToEnclave"})||console.warn("Failed to migrate from sharded to enclave wallet, continuing with sharded wallet")),this.wallet=await this.initializeWallet(i.storedToken.cookieString),!this.wallet)throw new Error("Failed to initialize wallet");const l="deviceShareStored"in i.walletDetails?i.walletDetails.deviceShareStored:void 0;return await this.wallet.postWalletSetUp({deviceShareStored:l,storedToken:i.storedToken}),this.wallet instanceof B&&await this.querier.call({params:{authCookie:i.storedToken.cookieString,clientId:this.client.clientId,deviceShareStored:"deviceShareStored"in i.walletDetails?i.walletDetails.deviceShareStored:null,ecosystemId:a==null?void 0:a.id,partnerId:a==null?void 0:a.partnerId,walletUserId:i.storedToken.authDetails.userWalletId},procedureName:"initIframe"}),{user:{account:await this.wallet.getAccount(),authDetails:i.storedToken.authDetails,status:"Logged In, Wallet Initialized",walletAddress:i.walletDetails.walletAddress}}},querier:this.querier})}async initializeWallet(e){var r;const t=await this.storage.getAuthCookie();if(!e&&t===null)throw new Error("No auth token provided and no stored auth token found to initialize the wallet");const a=await O({authToken:e||t,client:this.client,ecosystem:this.ecosystem});if(!a)throw new Error("Cannot initialize wallet, no user logged in");if(a.wallets.length===0)throw new Error("Cannot initialize wallet, this user does not have a wallet generated yet");return((r=a.wallets[0])==null?void 0:r.type)==="enclave"?new Oe({address:a.wallets[0].address,client:this.client,ecosystem:this.ecosystem,storage:this.storage}):new B({client:this.client,ecosystem:this.ecosystem,localStorage:this.storage,querier:this.querier})}async getUser(){if(!this.wallet){const e=await this.storage.getAuthCookie();if(!e)return{status:"Logged Out"};this.wallet=await this.initializeWallet(e)}if(!this.wallet)throw new Error("Wallet not initialized");return await this.wallet.getUserWalletStatus()}getAccount(){if(!this.wallet)throw new Error("Wallet not initialized");return this.wallet.getAccount()}async preAuthenticate(e){return Ge({...e,client:this.client,ecosystem:this.ecosystem})}async authenticateWithRedirect(e,t,a){return Me({authOption:e,client:this.client,ecosystem:this.ecosystem,mode:t,redirectUrl:a})}async loginWithAuthToken(e,t){return this.auth.loginWithAuthToken(e,t)}async authenticate(e){const t=e.strategy;switch(t){case"email":return R({...e,client:this.client,ecosystem:this.ecosystem});case"phone":return R({...e,client:this.client,ecosystem:this.ecosystem});case"auth_endpoint":return he({client:this.client,ecosystem:this.ecosystem,payload:e.payload});case"jwt":return pe({client:this.client,ecosystem:this.ecosystem,jwt:e.jwt});case"passkey":return this.passkeyAuth(e);case"iframe_email_verification":return this.auth.authenticateWithIframe({email:e.email});case"iframe":return this.auth.authenticateWithModal();case"apple":case"facebook":case"google":case"telegram":case"github":case"twitch":case"farcaster":case"line":case"x":case"tiktok":case"epic":case"steam":case"coinbase":case"discord":return ze({authOption:t,client:this.client,closeOpenedWindow:e.closeOpenedWindow,ecosystem:this.ecosystem,openedWindow:e.openedWindow});case"guest":return ge({client:this.client,ecosystem:this.ecosystem,storage:this.storage});case"backend":return we({client:this.client,ecosystem:this.ecosystem,walletSecret:e.walletSecret});case"wallet":return Ee({client:this.client,ecosystem:this.ecosystem,wallet:e.wallet,chain:e.chain})}}async connect(e){const t=e.strategy;switch(t){case"auth_endpoint":case"jwt":{const a=await this.authenticate(e);return await this.loginWithAuthToken(a,e.encryptionKey)}case"iframe_email_verification":return this.auth.loginWithIframe({email:e.email});case"iframe":return this.auth.loginWithModal();case"passkey":{const a=await this.passkeyAuth(e);return this.loginWithAuthToken(a)}case"backend":case"phone":case"email":case"wallet":case"apple":case"facebook":case"google":case"farcaster":case"telegram":case"github":case"line":case"x":case"tiktok":case"epic":case"guest":case"coinbase":case"twitch":case"steam":case"discord":{const a=await this.authenticate(e);return await this.auth.loginWithAuthToken(a)}default:xe(t)}}async logout(){return await this.auth.logout()}async passkeyAuth(e){const{PasskeyWebClient:t}=await k(async()=>{const{PasskeyWebClient:i}=await import("./passkeys-C02NitlT.js");return{PasskeyWebClient:i}},__vite__mapDeps([2,3,1,4,5,6])),{passkeyName:a,storeLastUsedPasskey:r=!0}=e,c=new t,o=this.storage;return e.type==="sign-up"?Ie({client:this.client,ecosystem:this.ecosystem,passkeyClient:c,rp:{id:this.passkeyDomain??window.location.hostname,name:this.passkeyDomain??window.document.title},storage:r?o:void 0,username:a}):be({client:this.client,ecosystem:this.ecosystem,passkeyClient:c,rp:{id:this.passkeyDomain??window.location.hostname,name:this.passkeyDomain??window.document.title},storage:r?o:void 0})}async linkProfile(e){const{storedToken:t}=await this.authenticate(e);return await me({client:e.client,ecosystem:e.ecosystem||this.ecosystem,storage:this.storage,tokenToLink:t.cookieString})}async unlinkProfile(e,t){return await fe({allowAccountDeletion:t,client:this.client,ecosystem:this.ecosystem,profileToUnlink:e,storage:this.storage})}async getProfiles(){return ye({client:this.client,ecosystem:this.ecosystem,storage:this.storage})}}function xe(n,e){throw new Error(`Invalid param: ${n}`)}function He(){return typeof window<"u"&&window.localStorage?x:oe}export{Je as InAppWebConnector};
package/index.html CHANGED
@@ -5,11 +5,11 @@
5
5
  <link rel="shortcut icon" type="image/x-icon" href="https://decentraland.org/images/icons/favicon-32x32.png" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Decentraland | Authorization</title>
8
- <script type="module" crossorigin src="https://cdn.decentraland.org/@dcl/auth-site/4.11.8-22595822532.commit-afd96dd/assets/index-B-_eFHsW.js"></script>
9
- <link rel="modulepreload" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.8-22595822532.commit-afd96dd/assets/thirdweb-CozZI4bW.js">
10
- <link rel="modulepreload" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.8-22595822532.commit-afd96dd/assets/vendor-CE6cyrlI.js">
11
- <link rel="modulepreload" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.8-22595822532.commit-afd96dd/assets/ui-CqQlCpnD.js">
12
- <link rel="stylesheet" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.8-22595822532.commit-afd96dd/assets/index-BLCMf4Dl.css">
8
+ <script type="module" crossorigin src="https://cdn.decentraland.org/@dcl/auth-site/4.11.8-22634160443.commit-5b1560f/assets/index-B_AZ5wDn.js"></script>
9
+ <link rel="modulepreload" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.8-22634160443.commit-5b1560f/assets/thirdweb-ClXIkdqD.js">
10
+ <link rel="modulepreload" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.8-22634160443.commit-5b1560f/assets/vendor-DrMguKq4.js">
11
+ <link rel="modulepreload" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.8-22634160443.commit-5b1560f/assets/ui-DHTUsjAL.js">
12
+ <link rel="stylesheet" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.8-22634160443.commit-5b1560f/assets/index-C_zlIEPk.css">
13
13
  </head>
14
14
  <body>
15
15
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcl/auth-site",
3
- "version": "4.11.8-22595822532.commit-afd96dd",
3
+ "version": "4.11.8-22634160443.commit-5b1560f",
4
4
  "description": "Auth website",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,6 +17,6 @@
17
17
  ],
18
18
  "author": "Decentraland",
19
19
  "license": "Apache-2.0",
20
- "homepage": "https://cdn.decentraland.org/@dcl/auth-site/4.11.8-22595822532.commit-afd96dd",
21
- "commit": "afd96dd3efa73b172bb4aced452231940daf4fc2"
20
+ "homepage": "https://cdn.decentraland.org/@dcl/auth-site/4.11.8-22634160443.commit-5b1560f",
21
+ "commit": "5b1560fdb7c3629ec184dcaa72061ff729bf956a"
22
22
  }
@@ -1,2 +0,0 @@
1
- import{p as re}from"./thirdweb-CozZI4bW.js";const xe="2.46.3";let $={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:s})=>e?`${t??"https://viem.sh"}${e}${s?`#${s}`:""}`:void 0,version:`viem@${xe}`};class _ extends Error{constructor(e,s={}){var c;const n=(()=>{var h;return s.cause instanceof _?s.cause.details:(h=s.cause)!=null&&h.message?s.cause.message:s.details})(),i=s.cause instanceof _&&s.cause.docsPath||s.docsPath,o=(c=$.getDocsUrl)==null?void 0:c.call($,{...s,docsPath:i}),r=[e||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...o?[`Docs: ${o}`]:[],...n?[`Details: ${n}`]:[],...$.version?[`Version: ${$.version}`]:[]].join(`
2
- `);super(r,s.cause?{cause:s.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=n,this.docsPath=i,this.metaMessages=s.metaMessages,this.name=s.name??this.name,this.shortMessage=e,this.version=xe}walk(e){return Ee(this,e)}}function Ee(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Ee(t.cause,e):e?null:t}class pe extends _{constructor({max:e,min:s,signed:n,size:i,value:o}){super(`Number "${o}" is not in safe ${i?`${i*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${s} to ${e})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class wt extends _{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class Le extends _{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}class Be extends _{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Ue(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function ce(t){return Ue(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}function ee(t,{dir:e="left"}={}){let s=typeof t=="string"?t.replace("0x",""):t,n=0;for(let i=0;i<s.length-1&&s[e==="left"?i:s.length-i-1].toString()==="0";i++)n++;return s=e==="left"?s.slice(n):s.slice(0,s.length-n),typeof t=="string"?(s.length===1&&e==="right"&&(s=`${s}0`),`0x${s.length%2===1?`0${s}`:s}`):s}class yt extends _{constructor({offset:e,position:s,size:n}){super(`Slice ${s==="start"?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class Ae extends _{constructor({size:e,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}class St extends _{constructor({size:e,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${s} ${n} long, but is ${e} ${n} long.`,{name:"InvalidBytesLengthError"})}}function se(t,{dir:e,size:s=32}={}){return typeof t=="string"?Me(t,{dir:e,size:s}):Re(t,{dir:e,size:s})}function Me(t,{dir:e,size:s=32}={}){if(s===null)return t;const n=t.replace("0x","");if(n.length>s*2)throw new Ae({size:Math.ceil(n.length/2),targetSize:s,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](s*2,"0")}`}function Re(t,{dir:e,size:s=32}={}){if(s===null)return t;if(t.length>s)throw new Ae({size:t.length,targetSize:s,type:"bytes"});const n=new Uint8Array(s);for(let i=0;i<s;i++){const o=e==="right";n[o?i:s-i-1]=t[o?i:t.length-i-1]}return n}const De=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function mt(t,e={}){return typeof t=="number"||typeof t=="bigint"?Pe(t,e):typeof t=="string"?Fe(t,e):typeof t=="boolean"?ke(t,e):ge(t,e)}function ke(t,e={}){const s=`0x${Number(t)}`;return typeof e.size=="number"?(X(s,{size:e.size}),se(s,{size:e.size})):s}function ge(t,e={}){let s="";for(let i=0;i<t.length;i++)s+=De[t[i]];const n=`0x${s}`;return typeof e.size=="number"?(X(n,{size:e.size}),se(n,{dir:"right",size:e.size})):n}function Pe(t,e={}){const{signed:s,size:n}=e,i=BigInt(t);let o;n?s?o=(1n<<BigInt(n)*8n-1n)-1n:o=2n**(BigInt(n)*8n)-1n:typeof t=="number"&&(o=BigInt(Number.MAX_SAFE_INTEGER));const r=typeof o=="bigint"&&s?-o-1n:0;if(o&&i>o||i<r){const h=typeof t=="bigint"?"n":"";throw new pe({max:o?`${o}${h}`:void 0,min:`${r}${h}`,signed:s,size:n,value:`${t}${h}`})}const c=`0x${(s&&i<0?(1n<<BigInt(n*8))+BigInt(i):i).toString(16)}`;return n?se(c,{size:n}):c}const $e=new TextEncoder;function Fe(t,e={}){const s=$e.encode(t);return ge(s,e)}function X(t,{size:e}){if(ce(t)>e)throw new Be({givenSize:ce(t),maxSize:e})}function ve(t,e={}){const{signed:s}=e;e.size&&X(t,{size:e.size});const n=BigInt(t);if(!s)return n;const i=(t.length-2)/2,o=(1n<<BigInt(i)*8n-1n)-1n;return n<=o?n:n-BigInt(`0x${"f".padStart(i*2,"f")}`)-1n}function Ht(t,e={}){let s=t;if(e.size&&(X(s,{size:e.size}),s=ee(s)),ee(s)==="0x00")return!1;if(ee(s)==="0x01")return!0;throw new Le(s)}function Lt(t,e={}){const s=ve(t,e),n=Number(s);if(!Number.isSafeInteger(n))throw new pe({max:`${Number.MAX_SAFE_INTEGER}`,min:`${Number.MIN_SAFE_INTEGER}`,signed:e.signed,size:e.size,value:`${s}n`});return n}const U=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function We(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function V(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function B(t,...e){if(!We(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function ze(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");V(t.outputLen),V(t.blockLen)}function D(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ne(t,e){B(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function Ge(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function L(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function te(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function N(t,e){return t<<32-e|t>>>e}const Ke=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ve(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Xe(t){for(let e=0;e<t.length;e++)t[e]=Ve(t[e]);return t}const ae=Ke?t=>t:Xe;function je(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function j(t){return typeof t=="string"&&(t=je(t)),B(t),t}function Bt(...t){let e=0;for(let n=0;n<t.length;n++){const i=t[n];B(i),e+=i.length}const s=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){const o=t[n];s.set(o,i),i+=o.length}return s}class ne{}function Y(t){const e=n=>t().update(j(n)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function Ut(t=32){if(U&&typeof U.getRandomValues=="function")return U.getRandomValues(new Uint8Array(t));if(U&&typeof U.randomBytes=="function")return Uint8Array.from(U.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}function Ye(t,e,s,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,s,n);const i=BigInt(32),o=BigInt(4294967295),r=Number(s>>i&o),c=Number(s&o),h=n?4:0,f=n?0:4;t.setUint32(e+h,r,n),t.setUint32(e+f,c,n)}function Je(t,e,s){return t&e^~t&s}function qe(t,e,s){return t&e^t&s^e&s}class _e extends ne{constructor(e,s,n,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=s,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(e),this.view=te(this.buffer)}update(e){D(this),e=j(e),B(e);const{view:s,buffer:n,blockLen:i}=this,o=e.length;for(let r=0;r<o;){const c=Math.min(i-this.pos,o-r);if(c===i){const h=te(e);for(;i<=o-r;r+=i)this.process(h,r);continue}n.set(e.subarray(r,r+c),this.pos),this.pos+=c,r+=c,this.pos===i&&(this.process(s,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){D(this),Ne(e,this),this.finished=!0;const{buffer:s,view:n,blockLen:i,isLE:o}=this;let{pos:r}=this;s[r++]=128,L(this.buffer.subarray(r)),this.padOffset>i-r&&(this.process(n,0),r=0);for(let a=r;a<i;a++)s[a]=0;Ye(n,i-8,BigInt(this.length*8),o),this.process(n,0);const c=te(e),h=this.outputLen;if(h%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=h/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let a=0;a<f;a++)c.setUint32(4*a,l[a],o)}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const n=e.slice(0,s);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:s,buffer:n,length:i,finished:o,destroyed:r,pos:c}=this;return e.destroyed=r,e.finished=o,e.length=i,e.pos=c,i%s&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const y=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),x=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),E=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),z=BigInt(2**32-1),he=BigInt(32);function Qe(t,e=!1){return e?{h:Number(t&z),l:Number(t>>he&z)}:{h:Number(t>>he&z)|0,l:Number(t&z)|0}}function Te(t,e=!1){const s=t.length;let n=new Uint32Array(s),i=new Uint32Array(s);for(let o=0;o<s;o++){const{h:r,l:c}=Qe(t[o],e);[n[o],i[o]]=[r,c]}return[n,i]}const fe=(t,e,s)=>t>>>s,le=(t,e,s)=>t<<32-s|e>>>s,M=(t,e,s)=>t>>>s|e<<32-s,R=(t,e,s)=>t<<32-s|e>>>s,G=(t,e,s)=>t<<64-s|e>>>s-32,K=(t,e,s)=>t>>>s-32|e<<64-s,Ze=(t,e,s)=>t<<s|e>>>32-s,et=(t,e,s)=>e<<s|t>>>32-s,tt=(t,e,s)=>e<<s-32|t>>>64-s,st=(t,e,s)=>t<<s-32|e>>>64-s;function C(t,e,s,n){const i=(e>>>0)+(n>>>0);return{h:t+s+(i/2**32|0)|0,l:i|0}}const nt=(t,e,s)=>(t>>>0)+(e>>>0)+(s>>>0),it=(t,e,s,n)=>e+s+n+(t/2**32|0)|0,ot=(t,e,s,n)=>(t>>>0)+(e>>>0)+(s>>>0)+(n>>>0),rt=(t,e,s,n,i)=>e+s+n+i+(t/2**32|0)|0,ct=(t,e,s,n,i)=>(t>>>0)+(e>>>0)+(s>>>0)+(n>>>0)+(i>>>0),at=(t,e,s,n,i,o)=>e+s+n+i+o+(t/2**32|0)|0,ht=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),S=new Uint32Array(64);class ft extends _e{constructor(e=32){super(64,e,8,!1),this.A=y[0]|0,this.B=y[1]|0,this.C=y[2]|0,this.D=y[3]|0,this.E=y[4]|0,this.F=y[5]|0,this.G=y[6]|0,this.H=y[7]|0}get(){const{A:e,B:s,C:n,D:i,E:o,F:r,G:c,H:h}=this;return[e,s,n,i,o,r,c,h]}set(e,s,n,i,o,r,c,h){this.A=e|0,this.B=s|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=r|0,this.G=c|0,this.H=h|0}process(e,s){for(let a=0;a<16;a++,s+=4)S[a]=e.getUint32(s,!1);for(let a=16;a<64;a++){const u=S[a-15],b=S[a-2],A=N(u,7)^N(u,18)^u>>>3,p=N(b,17)^N(b,19)^b>>>10;S[a]=p+S[a-7]+A+S[a-16]|0}let{A:n,B:i,C:o,D:r,E:c,F:h,G:f,H:l}=this;for(let a=0;a<64;a++){const u=N(c,6)^N(c,11)^N(c,25),b=l+u+Je(c,h,f)+ht[a]+S[a]|0,p=(N(n,2)^N(n,13)^N(n,22))+qe(n,i,o)|0;l=f,f=h,h=c,c=r+b|0,r=o,o=i,i=n,n=b+p|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,r=r+this.D|0,c=c+this.E|0,h=h+this.F|0,f=f+this.G|0,l=l+this.H|0,this.set(n,i,o,r,c,h,f,l)}roundClean(){L(S)}destroy(){this.set(0,0,0,0,0,0,0,0),L(this.buffer)}}const Oe=Te(["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(t=>BigInt(t))),lt=Oe[0],ut=Oe[1],m=new Uint32Array(80),H=new Uint32Array(80);class Ce extends _e{constructor(e=64){super(128,e,16,!1),this.Ah=E[0]|0,this.Al=E[1]|0,this.Bh=E[2]|0,this.Bl=E[3]|0,this.Ch=E[4]|0,this.Cl=E[5]|0,this.Dh=E[6]|0,this.Dl=E[7]|0,this.Eh=E[8]|0,this.El=E[9]|0,this.Fh=E[10]|0,this.Fl=E[11]|0,this.Gh=E[12]|0,this.Gl=E[13]|0,this.Hh=E[14]|0,this.Hl=E[15]|0}get(){const{Ah:e,Al:s,Bh:n,Bl:i,Ch:o,Cl:r,Dh:c,Dl:h,Eh:f,El:l,Fh:a,Fl:u,Gh:b,Gl:A,Hh:p,Hl:g}=this;return[e,s,n,i,o,r,c,h,f,l,a,u,b,A,p,g]}set(e,s,n,i,o,r,c,h,f,l,a,u,b,A,p,g){this.Ah=e|0,this.Al=s|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=r|0,this.Dh=c|0,this.Dl=h|0,this.Eh=f|0,this.El=l|0,this.Fh=a|0,this.Fl=u|0,this.Gh=b|0,this.Gl=A|0,this.Hh=p|0,this.Hl=g|0}process(e,s){for(let d=0;d<16;d++,s+=4)m[d]=e.getUint32(s),H[d]=e.getUint32(s+=4);for(let d=16;d<80;d++){const I=m[d-15]|0,w=H[d-15]|0,J=M(I,w,1)^M(I,w,8)^fe(I,w,7),q=R(I,w,1)^R(I,w,8)^le(I,w,7),T=m[d-2]|0,O=H[d-2]|0,v=M(T,O,19)^G(T,O,61)^fe(T,O,6),Q=R(T,O,19)^K(T,O,61)^le(T,O,6),W=ot(q,Q,H[d-7],H[d-16]),Z=rt(W,J,v,m[d-7],m[d-16]);m[d]=Z|0,H[d]=W|0}let{Ah:n,Al:i,Bh:o,Bl:r,Ch:c,Cl:h,Dh:f,Dl:l,Eh:a,El:u,Fh:b,Fl:A,Gh:p,Gl:g,Hh:k,Hl:P}=this;for(let d=0;d<80;d++){const I=M(a,u,14)^M(a,u,18)^G(a,u,41),w=R(a,u,14)^R(a,u,18)^K(a,u,41),J=a&b^~a&p,q=u&A^~u&g,T=ct(P,w,q,ut[d],H[d]),O=at(T,k,I,J,lt[d],m[d]),v=T|0,Q=M(n,i,28)^G(n,i,34)^G(n,i,39),W=R(n,i,28)^K(n,i,34)^K(n,i,39),Z=n&o^n&c^o&c,He=i&r^i&h^r&h;k=p|0,P=g|0,p=b|0,g=A|0,b=a|0,A=u|0,{h:a,l:u}=C(f|0,l|0,O|0,v|0),f=c|0,l=h|0,c=o|0,h=r|0,o=n|0,r=i|0;const oe=nt(v,W,He);n=it(oe,O,Q,Z),i=oe|0}({h:n,l:i}=C(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:r}=C(this.Bh|0,this.Bl|0,o|0,r|0),{h:c,l:h}=C(this.Ch|0,this.Cl|0,c|0,h|0),{h:f,l}=C(this.Dh|0,this.Dl|0,f|0,l|0),{h:a,l:u}=C(this.Eh|0,this.El|0,a|0,u|0),{h:b,l:A}=C(this.Fh|0,this.Fl|0,b|0,A|0),{h:p,l:g}=C(this.Gh|0,this.Gl|0,p|0,g|0),{h:k,l:P}=C(this.Hh|0,this.Hl|0,k|0,P|0),this.set(n,i,o,r,c,h,f,l,a,u,b,A,p,g,k,P)}roundClean(){L(m,H)}destroy(){L(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class dt extends Ce{constructor(){super(48),this.Ah=x[0]|0,this.Al=x[1]|0,this.Bh=x[2]|0,this.Bl=x[3]|0,this.Ch=x[4]|0,this.Cl=x[5]|0,this.Dh=x[6]|0,this.Dl=x[7]|0,this.Eh=x[8]|0,this.El=x[9]|0,this.Fh=x[10]|0,this.Fl=x[11]|0,this.Gh=x[12]|0,this.Gl=x[13]|0,this.Hh=x[14]|0,this.Hl=x[15]|0}}const Mt=Y(()=>new ft),Rt=Y(()=>new Ce),Dt=Y(()=>new dt),bt=BigInt(0),F=BigInt(1),xt=BigInt(2),Et=BigInt(7),pt=BigInt(256),At=BigInt(113),Ie=[],we=[],ye=[];for(let t=0,e=F,s=1,n=0;t<24;t++){[s,n]=[n,(2*s+3*n)%5],Ie.push(2*(5*n+s)),we.push((t+1)*(t+2)/2%64);let i=bt;for(let o=0;o<7;o++)e=(e<<F^(e>>Et)*At)%pt,e&xt&&(i^=F<<(F<<BigInt(o))-F);ye.push(i)}const Se=Te(ye,!0),gt=Se[0],Nt=Se[1],ue=(t,e,s)=>s>32?tt(t,e,s):Ze(t,e,s),de=(t,e,s)=>s>32?st(t,e,s):et(t,e,s);function _t(t,e=24){const s=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let r=0;r<10;r++)s[r]=t[r]^t[r+10]^t[r+20]^t[r+30]^t[r+40];for(let r=0;r<10;r+=2){const c=(r+8)%10,h=(r+2)%10,f=s[h],l=s[h+1],a=ue(f,l,1)^s[c],u=de(f,l,1)^s[c+1];for(let b=0;b<50;b+=10)t[r+b]^=a,t[r+b+1]^=u}let i=t[2],o=t[3];for(let r=0;r<24;r++){const c=we[r],h=ue(i,o,c),f=de(i,o,c),l=Ie[r];i=t[l],o=t[l+1],t[l]=h,t[l+1]=f}for(let r=0;r<50;r+=10){for(let c=0;c<10;c++)s[c]=t[r+c];for(let c=0;c<10;c++)t[r+c]^=~s[(c+2)%10]&s[(c+4)%10]}t[0]^=gt[n],t[1]^=Nt[n]}L(s)}class ie extends ne{constructor(e,s,n,i=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=s,this.outputLen=n,this.enableXOF=i,this.rounds=o,V(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ge(this.state)}clone(){return this._cloneInto()}keccak(){ae(this.state32),_t(this.state32,this.rounds),ae(this.state32),this.posOut=0,this.pos=0}update(e){D(this),e=j(e),B(e);const{blockLen:s,state:n}=this,i=e.length;for(let o=0;o<i;){const r=Math.min(s-this.pos,i-o);for(let c=0;c<r;c++)n[this.pos++]^=e[o++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:n,blockLen:i}=this;e[n]^=s,s&128&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){D(this,!1),B(e),this.finish();const s=this.state,{blockLen:n}=this;for(let i=0,o=e.length;i<o;){this.posOut>=n&&this.keccak();const r=Math.min(n-this.posOut,o-i);e.set(s.subarray(this.posOut,this.posOut+r),i),this.posOut+=r,i+=r}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return V(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ne(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,L(this.state)}_cloneInto(e){const{blockLen:s,suffix:n,outputLen:i,rounds:o,enableXOF:r}=this;return e||(e=new ie(s,n,i,r,o)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=o,e.suffix=n,e.outputLen=i,e.enableXOF=r,e.destroyed=this.destroyed,e}}const Tt=(t,e,s)=>Y(()=>new ie(e,t,s)),kt=Tt(1,136,256/8);class me extends ne{constructor(e,s){super(),this.finished=!1,this.destroyed=!1,ze(e);const n=j(s);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let r=0;r<o.length;r++)o[r]^=54;this.iHash.update(o),this.oHash=e.create();for(let r=0;r<o.length;r++)o[r]^=106;this.oHash.update(o),L(o)}update(e){return D(this),this.iHash.update(e),this}digestInto(e){D(this),B(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:s,iHash:n,finished:i,destroyed:o,blockLen:r,outputLen:c}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=r,e.outputLen=c,e.oHash=s._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ot=(t,e,s)=>new me(t,e).update(s).digest();Ot.create=(t,e)=>new me(t,e);var be={};const Ct={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",BASE_ACCOUNT:"baseAccount",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122",TON:"ton"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin",cosmos:"Cosmos",sui:"Sui",stacks:"Stacks",ton:"TON"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",TON:"ton"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],SOLANA_SPL_TOKEN_ADDRESSES:{SOL:"So11111111111111111111111111111111111111112"},HTTP_STATUS_CODES:{SERVER_ERROR:500,TOO_MANY_REQUESTS:429,SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network",SECURE_SITE_SDK_ORIGIN:(typeof re<"u"&&typeof be<"u"?be.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",REMOTE_FEATURES_ALERTS:{MULTI_WALLET_NOT_ENABLED:{DEFAULT:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com."},CONNECTIONS_HOOK:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com to use the useAppKitConnections hook."},CONNECTION_HOOK:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com to use the useAppKitConnection hook."}},HEADLESS_NOT_ENABLED:{DEFAULT:{displayMessage:"",debugMessage:"Headless support is not enabled. Please enable it with the features.headless option in the AppKit configuration and make sure your current plan supports it."}}},IS_DEVELOPMENT:typeof re<"u"&&!1,DEFAULT_ALLOWED_ANCESTORS:["http://localhost:*","https://localhost:*","http://127.0.0.1:*","https://127.0.0.1:*","https://*.pages.dev","https://*.vercel.app","https://*.ngrok-free.app","https://secure-mobile.walletconnect.com","https://secure-mobile.walletconnect.org"],METMASK_CONNECTOR_NAME:"MetaMask",TRUST_CONNECTOR_NAME:"Trust Wallet",SOLFLARE_CONNECTOR_NAME:"Solflare",PHANTOM_CONNECTOR_NAME:"Phantom",COIN98_CONNECTOR_NAME:"Coin98",MAGIC_EDEN_CONNECTOR_NAME:"Magic Eden",BACKPACK_CONNECTOR_NAME:"Backpack",BITGET_CONNECTOR_NAME:"Bitget Wallet",FRONTIER_CONNECTOR_NAME:"Frontier",XVERSE_CONNECTOR_NAME:"Xverse Wallet",LEATHER_CONNECTOR_NAME:"Leather",OKX_CONNECTOR_NAME:"OKX Wallet",BINANCE_CONNECTOR_NAME:"Binance Wallet",EIP155:"eip155",ADD_CHAIN_METHOD:"wallet_addEthereumChain",EIP6963_ANNOUNCE_EVENT:"eip6963:announceProvider",EIP6963_REQUEST_EVENT:"eip6963:requestProvider",CONNECTOR_RDNS_MAP:{coinbaseWallet:"com.coinbase.wallet",coinbaseWalletSDK:"com.coinbase.wallet"},CONNECTOR_TYPE_EXTERNAL:"EXTERNAL",CONNECTOR_TYPE_WALLET_CONNECT:"WALLET_CONNECT",CONNECTOR_TYPE_INJECTED:"INJECTED",CONNECTOR_TYPE_ANNOUNCED:"ANNOUNCED",CONNECTOR_TYPE_AUTH:"AUTH",CONNECTOR_TYPE_MULTI_CHAIN:"MULTI_CHAIN",CONNECTOR_TYPE_W3M_AUTH:"AUTH"},Pt={caipNetworkIdToNumber(t){return t?Number(t.split(":")[1]):void 0},parseEvmChainId(t){return typeof t=="string"?this.caipNetworkIdToNumber(t):t},getNetworksByNamespace(t,e){return(t==null?void 0:t.filter(s=>s.chainNamespace===e))||[]},getFirstNetworkByNamespace(t,e){return this.getNetworksByNamespace(t,e)[0]},getNetworkNameByCaipNetworkId(t,e){var i;if(!e)return;const s=t.find(o=>o.caipNetworkId===e);if(s)return s.name;const[n]=e.split(":");return((i=Ct.CHAIN_NAME_MAP)==null?void 0:i[n])||void 0}},$t=["eip155","solana","polkadot","bip122","cosmos","sui","stacks"];export{$t as A,_ as B,Ct as C,wt as I,Pt as N,yt as S,V as a,X as b,Bt as c,Lt as d,ge as e,ve as f,ce as g,Ot as h,Ue as i,ee as j,kt as k,Me as l,ke as m,Pe as n,pe as o,se as p,Fe as q,Ut as r,Mt as s,mt as t,Dt as u,Rt as v,St as w,Ht as x};
@@ -1 +0,0 @@
1
- import{s as b,t as O,f as x,A as S,d as $,g as F,a as E,b as I,e as w,c as D,h as A,i as G,I as T,j as m,k as C,l as L,m as M,n as H,o as j,p as v,q as B,H as R}from"./networks-w0_eLt2M.js";import{B as y,i as U}from"./NetworkUtil-B_5naIJv.js";import"./sha256-D6ei3Af4.js";import"./thirdweb-CozZI4bW.js";function _(a){const{abi:n,data:e}=a,s=b(e,0,4),t=n.find(o=>o.type==="function"&&s===O(x(o)));if(!t)throw new S(s,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:t.name,args:"inputs"in t&&t.inputs&&t.inputs.length>0?$(t.inputs,b(e,4)):void 0}}const p="/docs/contract/encodeErrorResult";function k(a){const{abi:n,errorName:e,args:s}=a;let t=n[0];if(e){const u=F({abi:n,args:s,name:e});if(!u)throw new E(e,{docsPath:p});t=u}if(t.type!=="error")throw new E(void 0,{docsPath:p});const o=x(t),r=O(o);let c="0x";if(s&&s.length>0){if(!t.inputs)throw new I(t.name,{docsPath:p});c=w(t.inputs,s)}return D([r,c])}const h="/docs/contract/encodeFunctionResult";function J(a){const{abi:n,functionName:e,result:s}=a;let t=n[0];if(e){const r=F({abi:n,name:e});if(!r)throw new A(e,{docsPath:h});t=r}if(t.type!=="function")throw new A(void 0,{docsPath:h});if(!t.outputs)throw new G(t.name,{docsPath:h});const o=(()=>{if(t.outputs.length===0)return[];if(t.outputs.length===1)return[s];if(Array.isArray(s))return s;throw new T(s)})();return w(t.outputs,o)}const N="x-batch-gateway:true";async function P(a){const{data:n,ccipRequest:e}=a,{args:[s]}=_({abi:m,data:n}),t=[],o=[];return await Promise.all(s.map(async(r,c)=>{try{o[c]=r.urls.includes(N)?await P({data:r.data,ccipRequest:e}):await e(r),t[c]=!1}catch(u){t[c]=!0,o[c]=W(u)}})),J({abi:m,functionName:"query",result:[t,o]})}function W(a){return a.name==="HttpRequestError"&&a.status?k({abi:m,errorName:"HttpError",args:[a.status,a.shortMessage]}):k({abi:[C],errorName:"Error",args:["shortMessage"in a?a.shortMessage:a.message]})}class z extends y{constructor({callbackSelector:n,cause:e,data:s,extraData:t,sender:o,urls:r}){var c;super(e.shortMessage||"An error occurred while fetching for an offchain result.",{cause:e,metaMessages:[...e.metaMessages||[],(c=e.metaMessages)!=null&&c.length?"":[],"Offchain Gateway Call:",r&&[" Gateway URL(s):",...r.map(u=>` ${L(u)}`)],` Sender: ${o}`,` Data: ${s}`,` Callback selector: ${n}`,` Extra data: ${t}`].flat(),name:"OffchainLookupError"})}}class K extends y{constructor({result:n,url:e}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${L(e)}`,`Response: ${M(n)}`],name:"OffchainLookupResponseMalformedError"})}}class Q extends y{constructor({sender:n,to:e}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${e}`,`OffchainLookup sender address: ${n}`],name:"OffchainLookupSenderMismatchError"})}}const at="0x556f1830",V={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 st(a,{blockNumber:n,blockTag:e,data:s,to:t}){const{args:o}=H({data:s,abi:[V]}),[r,c,u,f,d]=o,{ccipRead:i}=a,g=i&&typeof(i==null?void 0:i.request)=="function"?i.request:X;try{if(!j(t,r))throw new Q({sender:r,to:t});const l=c.includes(N)?await P({data:u,ccipRequest:g}):await g({data:u,sender:r,urls:c}),{data:q}=await v(a,{blockNumber:n,blockTag:e,data:B([f,w([{type:"bytes"},{type:"bytes"}],[l,d])]),to:t});return q}catch(l){throw new z({callbackSelector:f,cause:l,data:s,extraData:d,sender:r,urls:c})}}async function X({data:a,sender:n,urls:e}){var t;let s=new Error("An unknown error occurred.");for(let o=0;o<e.length;o++){const r=e[o],c=r.includes("{data}")?"GET":"POST",u=c==="POST"?{data:a,sender:n}:void 0,f=c==="POST"?{"Content-Type":"application/json"}:{};try{const d=await fetch(r.replace("{sender}",n.toLowerCase()).replace("{data}",a),{body:JSON.stringify(u),headers:f,method:c});let i;if((t=d.headers.get("Content-Type"))!=null&&t.startsWith("application/json")?i=(await d.json()).data:i=await d.text(),!d.ok){s=new R({body:u,details:i!=null&&i.error?M(i.error):d.statusText,headers:d.headers,status:d.status,url:r});continue}if(!U(i)){s=new K({result:i,url:r});continue}return i}catch(d){s=new R({body:u,details:d.message,url:r})}}throw s}export{X as ccipRequest,st as offchainLookup,V as offchainLookupAbiItem,at as offchainLookupSignature};