@privy-io/react-auth 2.15.0 → 2.15.1

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.
@@ -1,4 +1,4 @@
1
- "use strict";var e=require("react/jsx-runtime"),t=require("mipd"),r=require("react"),n=require("react-device-detect"),a=require("viem/utils"),i=require("@privy-io/js-sdk-core"),o=require("./paths-CdRs2pll.js"),s=require("./internal-context-CrTqNb_c.js"),l=require("viem"),c=require("uuid"),d=require("jose"),u=require("./use-sign-with-user-signer-h5JGn1CY.js"),h=require("eventemitter3"),p=require("@coinbase/wallet-sdk"),y=require("@privy-io/ethereum"),m=require("@marsidev/react-turnstile"),g=require("styled-components"),f=require("tinycolor2"),w=require("@heroicons/react/24/outline/DevicePhoneMobileIcon"),v=require("@heroicons/react/24/outline/FingerPrintIcon"),x=require("@heroicons/react/24/outline/PhoneIcon"),C=require("@heroicons/react/24/outline/ShieldCheckIcon"),b=require("@heroicons/react/24/outline/ArrowLeftIcon");require("@heroicons/react/24/outline/ArrowRightIcon");var j=require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),E=require("@heroicons/react/24/outline/XMarkIcon"),k=require("@heroicons/react/24/outline/ChevronDownIcon"),T=require("@heroicons/react/24/outline/CalendarIcon"),A=require("@heroicons/react/24/outline/ExclamationTriangleIcon"),I=require("@headlessui/react"),S=require("@walletconnect/ethereum-provider"),P=require("zustand"),_=require("fast-password-entropy"),N=require("secure-password-utilities"),M=require("secure-password-utilities/wordlists"),W=require("@heroicons/react/24/outline/UserCircleIcon"),U=require("@heroicons/react/24/outline/EnvelopeIcon"),O=require("@heroicons/react/20/solid/CheckIcon"),F=require("@heroicons/react/24/outline/WalletIcon"),R=require("@heroicons/react/24/outline/CheckIcon"),L=require("@heroicons/react/24/outline/Square2StackIcon"),D=require("@heroicons/react/24/outline/ExclamationCircleIcon"),B=require("@heroicons/react/24/outline/ArrowTopRightOnSquareIcon"),z=require("@heroicons/react/24/solid/DocumentCheckIcon"),$=require("@heroicons/react/24/solid/XCircleIcon"),q=require("@heroicons/react/24/solid/CheckCircleIcon"),V=require("qrcode"),H=require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),K=require("@heroicons/react/24/outline/ChevronRightIcon"),Z=require("@heroicons/react/24/outline/LockClosedIcon"),Y=require("@heroicons/react/24/outline/PencilSquareIcon"),G=require("@heroicons/react/24/outline/ArrowPathIcon"),J=require("@heroicons/react/24/outline/EyeIcon"),Q=require("@heroicons/react/24/outline/EyeSlashIcon"),X=require("@heroicons/react/24/outline/KeyIcon"),ee=require("@heroicons/react/24/outline/ArrowDownTrayIcon"),te=require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),re=require("@heroicons/react/24/outline/DocumentDuplicateIcon"),ne=require("@heroicons/react/24/solid/LockClosedIcon"),ae=require("@heroicons/react/24/outline/CheckCircleIcon"),ie=require("@heroicons/react/24/outline/InformationCircleIcon"),oe=require("@heroicons/react/24/outline/CreditCardIcon"),se=require("@heroicons/react/24/outline/QrCodeIcon"),le=require("@heroicons/react/24/outline/GlobeAltIcon"),ce=require("ofetch"),de=require("@heroicons/react/24/outline"),ue=require("@heroicons/react/24/outline/ClipboardDocumentIcon"),he=require("@heroicons/react/24/outline/CloudArrowUpIcon"),pe=require("@heroicons/react/24/outline/NoSymbolIcon"),ye=require("@heroicons/react/24/outline/ClockIcon"),me=require("@heroicons/react/24/outline/TrashIcon"),ge=require("@heroicons/react/24/solid/CheckBadgeIcon"),fe=require("@heroicons/react/24/solid/IdentificationIcon"),we=require("@heroicons/react/24/outline/MinusCircleIcon"),ve=require("@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon"),xe=require("@heroicons/react/24/solid/ShieldCheckIcon"),Ce=require("js-cookie");function be(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function je(e){if(e&&"object"==typeof e&&"default"in e)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var Ee=/*#__PURE__*/be(r),ke=/*#__PURE__*/je(n),Te=/*#__PURE__*/be(i),Ae=/*#__PURE__*/je(d),Ie=/*#__PURE__*/be(h),Se=/*#__PURE__*/be(f),Pe=/*#__PURE__*/be(w),_e=/*#__PURE__*/be(v),Ne=/*#__PURE__*/be(x),Me=/*#__PURE__*/be(C),We=/*#__PURE__*/be(b),Ue=/*#__PURE__*/be(j),Oe=/*#__PURE__*/be(E),Fe=/*#__PURE__*/be(k),Re=/*#__PURE__*/be(T),Le=/*#__PURE__*/be(A),De=/*#__PURE__*/be(_),Be=/*#__PURE__*/je(N),ze=/*#__PURE__*/be(W),$e=/*#__PURE__*/be(U),qe=/*#__PURE__*/be(O),Ve=/*#__PURE__*/be(F),He=/*#__PURE__*/be(R),Ke=/*#__PURE__*/be(L),Ze=/*#__PURE__*/be(D),Ye=/*#__PURE__*/be(B),Ge=/*#__PURE__*/be(z),Je=/*#__PURE__*/be($),Qe=/*#__PURE__*/be(q),Xe=/*#__PURE__*/be(V),et=/*#__PURE__*/be(H),tt=/*#__PURE__*/be(K),rt=/*#__PURE__*/be(Z),nt=/*#__PURE__*/be(Y),at=/*#__PURE__*/be(G),it=/*#__PURE__*/be(J),ot=/*#__PURE__*/be(Q),st=/*#__PURE__*/be(X),lt=/*#__PURE__*/be(ee),ct=/*#__PURE__*/be(te),dt=/*#__PURE__*/be(re),ut=/*#__PURE__*/be(ne),ht=/*#__PURE__*/be(ae),pt=/*#__PURE__*/be(ie),yt=/*#__PURE__*/be(oe),mt=/*#__PURE__*/be(se),gt=/*#__PURE__*/be(le),ft=/*#__PURE__*/be(ue),wt=/*#__PURE__*/be(he),vt=/*#__PURE__*/be(pe),xt=/*#__PURE__*/be(ye),Ct=/*#__PURE__*/be(me),bt=/*#__PURE__*/be(ge),jt=/*#__PURE__*/be(fe),Et=/*#__PURE__*/be(we),kt=/*#__PURE__*/be(ve),Tt=/*#__PURE__*/be(xe),At=/*#__PURE__*/be(Ce);function It(e){return e?{"privy-ui":"t"}:void 0}class St{async authenticate(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new o.PrivyClientError("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(o.passwordlessAuthenticatePath,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw o.formatApiError(e)}}async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new o.PrivyClientError("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(o.passwordlessLinkPath,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw o.formatApiError(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:r}){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new o.PrivyClientError("Email must be set when initialzing authentication.");let n=It(r);try{return await this.api.post(o.passwordlessInitPath,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...n}})}catch(e){throw o.formatApiError(e)}}constructor({email:e,captchaToken:t,disableSignup:r}){this.meta={email:e,captchaToken:t,disableSignup:r??!1}}}class Pt extends St{async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new o.PrivyClientError("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(o.updateEmailPath,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw o.formatApiError(e)}}constructor(e,t,r){super({email:t,captchaToken:r}),this.meta={email:t,captchaToken:r,oldAddress:e,disableSignup:!1}}}class _t{get(e){let t=localStorage.getItem(e);return null===t?void 0:JSON.parse(t)}put(e,t){void 0!==t?localStorage.setItem(e,JSON.stringify(t)):this.del(e)}del(e){localStorage.removeItem(e)}getKeys(){return Object.entries(localStorage).map((([e])=>e))}}function Nt(){try{let e="privy:__session_storage__test",t=new _t;return t.put(e,"blobby"),t.del(e),!0}catch(e){return!1}}var Mt="undefined"!=typeof window&&window.localStorage?new _t:new class{get(e){return this._cache[e]}put(e,t){void 0!==t?this._cache[e]=t:this.del(e)}del(e){delete this._cache[e]}getKeys(){return Object.keys(this._cache)}constructor(){this._cache={}}};const Wt=e=>e.isApexWallet?"Apex Wallet":e.isAvalanche?"Core Wallet":e.isBackpack?"Backpack":e.isBifrost?"Bifrost Wallet":e.isBitKeep?"BitKeep":e.isBitski?"Bitski":e.isBlockWallet?"BlockWallet":e.isBraveWallet?"Brave Wallet":e.isClover?"Clover":e.isCoin98?"Coin98 Wallet":e.isCoinbaseWallet?"Coinbase Wallet":e.isDawn?"Dawn Wallet":e.isDefiant?"Defiant":e.isDesig?"Desig Wallet":e.isEnkrypt?"Enkrypt":e.isExodus?"Exodus":e.isFordefi?"Fordefi":e.isFrame?"Frame":e.isFrontier?"Frontier Wallet":e.isGamestop?"GameStop Wallet":e.isHaqqWallet?"HAQQ Wallet":e.isHyperPay?"HyperPay Wallet":e.isImToken?"ImToken":e.isHaloWallet?"Halo Wallet":e.isKuCoinWallet?"KuCoin Wallet":e.isMathWallet?"MathWallet":e.isNovaWallet?"Nova Wallet":e.isOkxWallet||e.isOKExWallet?"OKX Wallet":e.isOneInchIOSWallet||e.isOneInchAndroidWallet?"1inch Wallet":e.isOneKey?"OneKey Wallet":e.isOpera?"Opera":e.isPhantom||"isPhantom"in e?"Phantom":e.isPortal?"Ripio Portal":e.isRabby?"Rabby Wallet":e.isRainbow?"Rainbow":e.isSafePal?"SafePal Wallet":e.isStatus?"Status":e.isSubWallet?"SubWallet":e.isTalisman?"Talisman":e.isTally||e.isTaho?"Taho":e.isTokenPocket?"TokenPocket":e.isTokenary?"Tokenary":e.isTrust||e.isTrustWallet?"Trust Wallet":e.isTTWallet?"TTWallet":e.isXDEFI?"XDEFI Wallet":e.isZeal?"Zeal":e.isZerion?"Zerion":e.isMetaMask?"MetaMask":void 0,Ut=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||"MetaMask"!==Wt(e))return!1;if(e.providers)for(let t of e.providers)if(!Ut(t))return!1;return!0},Ot=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers)for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0;return!1},Ft=(e,t,r,n)=>{let a=Number(e),i=t.find((e=>e.id===a));if(!i)throw new o.PrivyConnectorError(`Unsupported chainId ${e}`,4901);return l.createPublicClient({transport:l.http(Rt(i,r,n.appId)),chain:i})},Rt=(e,t,r)=>{let n,a=e.id,i=Number(e.id);if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])n=e.rpcUrls.privyWalletOverride.http[0];else if(t.rpcUrls&&t.rpcUrls[i])n=t.rpcUrls[i];else if(e.rpcUrls.privy?.http[0]){let t=new URL(e.rpcUrls.privy.http[0]);t.searchParams.append("privyAppId",r),n=t.toString()}else n=e.rpcUrls.public?.http[0]?e.rpcUrls.public.http[0]:e.rpcUrls.default?.http[0];if(!n)throw new o.PrivyConnectorError(`No RPC url found for ${a}`);return n},Lt=e=>!!String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),Dt=(e,t=3,r=4,n="ethereum")=>{if(!e)return"";let a="ethereum"===n?2:0;return t+r+a+3>=e.length?e:`${e.slice(0,a+t)}...${e.slice(e.length-r,e.length)}`},Bt=(e,t=3,r=4)=>Dt(e,t,r,"solana"),zt=e=>new Promise((t=>setTimeout(t,e)));const $t=(e,t={})=>{let r=t.delayMs||150,n=t.maxAttempts||270;return new Promise((async(a,i)=>{let o=!1,s=0;for(;!o&&s<n;){if(t.abortSignal?.aborted)return;e().then((e=>{o=!0,a(e)}),((...e)=>{o=!0,i(...e)})),s+=1,await zt(r)}o||i(Error("Exceeded max attempts before resolving function"))}))},qt=(e,t,r={},n={})=>{let a=new URL(t,e);for(let[e,t]of Object.entries(r))void 0!==t&&a.searchParams.set(e,t);let i=Object.entries(n);if(i.length>0){let e=new URLSearchParams;for(let[t,r]of i)e.append(t,r);a.hash=e.toString()}return a.href},Vt=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),Ht=e=>"string"==typeof e?e:"0x"+e.toString(16);async function Kt({store:e,walletList:t,externalWalletConfig:r,walletChainType:n,timeout:a=3e3}){let i=!1,o=window;return new Promise((s=>{function l(){if(i)return;i=!0,window.removeEventListener("ethereum#initialized",l);let a=e.getProviders();console.debug("Detected injected providers:",a.map((e=>e.info)));let o=[];for(let e of a)t.includes("coinbase_wallet")&&"com.coinbase.wallet"===e.info.rdns||"solana-only"===n&&"app.phantom"===e.info.rdns||o.push({type:e.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:e});if("solana-only"!==n)for(let e of function(){let e=window,t=e.ethereum;if(!t)return[];let r=[];if(t.providers?.length)for(let e of t.providers)e&&r.push(e);return r.push(e.ethereum),r}()){let t=Wt(e);if(!a.some((e=>e.info.name===t))){if(Ut(e,!0)&&!o.find((e=>"metamask"===e.type))){o.push({type:"metamask",legacyInjectedProvider:e});continue}if("Phantom"===t&&!o.find((e=>"phantom"===e.type))){o.push({type:"phantom",legacyInjectedProvider:e});continue}if("Coinbase Wallet"===t&&!o.find((e=>"coinbase_wallet"===e.type&&"smartWalletOnly"!==r.coinbaseWallet?.config?.preference?.options))){o.push({type:"coinbase_wallet",legacyInjectedProvider:e});continue}o.find((e=>"unknown_browser_extension"===e.type))||o.push({type:"unknown_browser_extension",legacyInjectedProvider:e})}}s(o)}o.ethereum?l():(window.addEventListener("ethereum#initialized",l,{once:!0}),setTimeout((()=>{l()}),a))}))}function Zt(e){return`eip155:${String(Number(e))}`}const Yt=(e,t,r,n)=>{let a=Number(e),i=t.find((e=>e.id===a));if(!i)throw new o.PrivyConnectorError(`Unsupported chainId ${e}`,4901);return Rt(i,r,n)},Gt=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},r=e.types.EIP712Domain??Object.entries(e.domain).map((([e,r])=>{if(null!=r&&"string"==typeof e&&e in t)return{name:e,type:t[e]}})).filter((e=>void 0!==e));return{...e,types:{...e.types,EIP712Domain:r}}};const Jt=["c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96","4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0","225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f","1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369","c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a","ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18","bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6","74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d","afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7","f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d","84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04","0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150","38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662","9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0","c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576","8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4","e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4","f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2","138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98","47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83","7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26","8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3","031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa","2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568","dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd","2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01","b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f","0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92","719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3","942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef","8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2","07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80","8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819","bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a","cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e","94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43","2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715","14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc","576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd","49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd","19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b","5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b","d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b","50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b","9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8","6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa","41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071","14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd","a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1","971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709","18388be9ac2d02726dbac9777c96efaac06d744b2f6d580fccdd4127a6d01fd1","15c8b91ade1a4e58f3ce4e7a0dd7f42b47db0c8df7e0d84f63eb39bcb96c4e0f","541d5dcd4ede02f3afaf75bf8e3e4c4f1fb09edb5fa6c4377ebf31c2785d9adf"];function Qt(e){return{name:e.metadata?.shortName||e.name||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}let Xt="WALLETCONNECT_DEEPLINK_CHOICE";function er(e){return e.startsWith("http://")||e.startsWith("https://")}function tr(e,t){if(er(e))return rr(e,t);let r=e;return r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),{redirect:`${r}wc?uri=${encodeURIComponent(t)}`,href:r}}function rr(e,t){if(!er(e))return tr(e,t);let r=e;return r.endsWith("/")||(r=`${r}/`),{redirect:`${r}wc?uri=${encodeURIComponent(t)}`,href:r}}function nr(e,t){window.open(e,t,"noreferrer noopener")}class ar{execute(e){return null===this.promise&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}constructor(e){this.promise=null,this.fn=e}}class ir{get meta(){return this._meta}async authenticate(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.channelToken)throw new o.PrivyClientError("Auth flow must be initialized first");try{let e=await this.api.post(o.farcasterAuthenticatePath,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});if(!e)throw new o.PrivyClientError("No response from authentication");return e}catch(e){throw o.formatApiError(e)}}async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(o.farcasterLinkPath,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw o.formatApiError(e)}}async _startChannelOnce(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");let e=await this.api.post(o.farcasterInitPath,{token:this.captchaToken});n.isMobile&&!n.isIOS&&e.connect_uri&&nr(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.channelToken)throw new o.PrivyClientError("Auth flow must be initialized first");let e=await this.api.get(o.farcasterStatusPath,{headers:{"farcaster-channel-token":this.meta.channelToken}});return"completed"===e.state&&(this.message=e.message,this.signature=e.signature,this.fid=e.fid,!0)}constructor(e,t=!1){this._meta={disableSignup:!1},this.captchaToken=e,this.startChannelOnce=new ar(this._startChannelOnce.bind(this)),this.pollForReady=new ar(this._pollForReady.bind(this)),this._meta.disableSignup=t}}const or="https://auth.privy.io",sr=1400,lr=2500,cr=4e3,dr="2.15.0",ur="privy:token",hr="privy-token",pr="privy:refresh_token",yr="privy:pat",mr="privy:id_token",gr="privy-id-token",fr="privy-session",wr="privy:caid",vr=e=>`privy:guest:${e}`,xr=e=>`privy:cross-app:${e}`,Cr="privy:state_code",br="privy:code_verifier",jr="privy:headless_oauth",Er="privy:oauth_disable_signup",kr=e=>`privy:wallet:${e}`,Tr="privy:connectors",Ar="privy:connections",Ir=12e4,Sr=3e4,Pr="https://api.moonpay.com/v1",_r="https://api.moonpay.com/v1",Nr="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Mr="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI";function Wr(e){return crypto.getRandomValues(new Uint8Array(e))}function Ur(){return d.base64url.encode(Wr(36))}function Or(){return Ur()}async function Fr(e,t="S256"){if("S256"!=t)return e;{let t=await async function(e){let t=(new TextEncoder).encode(e);return new Uint8Array(await crypto.subtle.digest("SHA-256",t))}(e);return d.base64url.encode(t)}}class Rr{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new o.PrivyClientError("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new o.PrivyClientError("User denied confirmation during OAuth flow");let e=function(){let e=Mt.get(br);if(!e)throw new o.PrivyClientError("Authentication error.");return e}();try{let t=await this.api.post(o.oAuthAuthenticatePath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return Mt.del(br),Mt.del(jr),Mt.del(Er),t}catch(e){let t=o.formatApiError(e);if(t.privyErrorCode)throw new o.PrivyClientError(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new o.PrivyClientError("Invalid code during oauth flow.",void 0,o.PrivyErrorCode.OAUTH_USER_DENIED);throw new o.PrivyClientError("Invalid code during OAuth flow.",void 0,o.PrivyErrorCode.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new o.PrivyClientError("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new o.PrivyClientError("User denied confirmation during OAuth flow");let e=Mt.get(br);if(!e)throw new o.PrivyClientError("Authentication error.");try{let t=await this.api.post(o.oAuthLinkPath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return Mt.del(br),t}catch(e){throw o.formatApiError(e)}}async getAuthorizationUrl(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.provider)throw new o.PrivyClientError("Provider must be set when initializing OAuth authentication.");let e=Ur();Mt.put(br,e);let t=Or();Mt.put(Cr,t);let r=await Fr(e);this.meta.withPrivyUi||Mt.put(jr,!0),this.meta.disableSignup?Mt.put(Er,!0):Mt.del(Er);let n=It(this.meta.withPrivyUi);try{return await this.api.post(o.oAuthInitPath,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:r,state_code:t},{headers:{...n}})}catch(e){throw o.formatApiError(e)}}constructor(e){this.meta=e}}function Lr(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Dr=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",style:{height:"24px",...t},...r,children:[/*#__PURE__*/e.jsx("path",{d:"M17.0722 11.6888C17.0471 8.90571 19.3263 7.56847 19.429 7.50274C18.1466 5.60938 16.153 5.35154 15.4417 5.3212C13.7461 5.14678 12.1306 6.32982 11.269 6.32982C10.4074 6.32982 9.08004 5.34648 7.67246 5.37429C5.82158 5.40209 4.11595 6.45874 3.16171 8.13218C1.24068 11.4942 2.6708 16.4817 4.54423 19.2143C5.46091 20.549 6.55041 22.0531 7.98554 21.9975C9.36803 21.9419 9.88905 21.095 11.5571 21.095C13.2251 21.095 13.696 21.9975 15.1537 21.9697C16.6389 21.9393 17.5806 20.6046 18.4897 19.2648C19.5392 17.7153 19.9725 16.2137 19.9975 16.1354C19.965 16.1228 17.1022 15.0155 17.0722 11.6888Z",fill:"currentColor"}),/*#__PURE__*/e.jsx("path",{d:"M14.3295 3.51373C15.0909 2.58347 15.6043 1.28921 15.4641 0C14.3671 0.0455014 13.0396 0.738135 12.2532 1.66838C11.5494 2.48994 10.9307 3.80695 11.0986 5.07089C12.3183 5.16694 13.5681 4.44145 14.3295 3.51373Z",fill:"currentColor"})]}),Br=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...t},...r,children:[/*#__PURE__*/e.jsx("g",{clipPath:"url(#clip0)",children:/*#__PURE__*/e.jsx("path",{d:"M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z",fill:"#5865F2"})}),/*#__PURE__*/e.jsx("defs",{children:/*#__PURE__*/e.jsx("clipPath",{id:"clip0",children:/*#__PURE__*/e.jsx("rect",{width:"71",height:"55",fill:"white"})})})]}),zr=({style:t,...r})=>/*#__PURE__*/e.jsx("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"24",y:"24",viewBox:"0 0 98 96",style:{height:"24px",...t},...r,children:/*#__PURE__*/e.jsx("path",{d:"M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z",fill:"currentColor"})}),$r=({style:t})=>/*#__PURE__*/e.jsx(gt.default,{style:{color:"var(--privy-color-error)",...t}}),qr=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...t},...r,children:[/*#__PURE__*/e.jsx("path",{d:"M22.56 12.25C22.56 11.47 22.49 10.72 22.36 10H12V14.255H17.92C17.665 15.63 16.89 16.795 15.725 17.575V20.335H19.28C21.36 18.42 22.56 15.6 22.56 12.25Z",fill:"#4285F4"}),/*#__PURE__*/e.jsx("path",{d:"M12 23C14.97 23 17.46 22.015 19.28 20.335L15.725 17.575C14.74 18.235 13.48 18.625 12 18.625C9.13504 18.625 6.71004 16.69 5.84504 14.09H2.17004V16.94C3.98004 20.535 7.70004 23 12 23Z",fill:"#34A853"}),/*#__PURE__*/e.jsx("path",{d:"M5.845 14.09C5.625 13.43 5.5 12.725 5.5 12C5.5 11.275 5.625 10.57 5.845 9.91V7.06H2.17C1.4 8.59286 0.999321 10.2846 1 12C1 13.775 1.425 15.455 2.17 16.94L5.845 14.09Z",fill:"#FBBC05"}),/*#__PURE__*/e.jsx("path",{d:"M12 5.375C13.615 5.375 15.065 5.93 16.205 7.02L19.36 3.865C17.455 2.09 14.965 1 12 1C7.70004 1 3.98004 3.465 2.17004 7.06L5.84504 9.91C6.71004 7.31 9.13504 5.375 12 5.375Z",fill:"#EA4335"})]});function Vr(t){/*#__PURE__*/return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:26,height:26,viewBox:"0 0 140 140",x:"0px",y:"0px",fill:"none",...t,children:[/*#__PURE__*/e.jsxs("defs",{children:[/*#__PURE__*/e.jsxs("linearGradient",{id:"b",children:[/*#__PURE__*/e.jsx("stop",{offset:"0",stopColor:"#3771c8"}),/*#__PURE__*/e.jsx("stop",{stopColor:"#3771c8",offset:".128"}),/*#__PURE__*/e.jsx("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),/*#__PURE__*/e.jsxs("linearGradient",{id:"a",children:[/*#__PURE__*/e.jsx("stop",{offset:"0",stopColor:"#fd5"}),/*#__PURE__*/e.jsx("stop",{offset:".1",stopColor:"#fd5"}),/*#__PURE__*/e.jsx("stop",{offset:".5",stopColor:"#ff543e"}),/*#__PURE__*/e.jsx("stop",{offset:"1",stopColor:"#c837ab"})]}),/*#__PURE__*/e.jsx("radialGradient",{id:"c",cx:"158.429",cy:"578.088",r:"65",xlinkHref:"#a",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(0 -1.98198 1.8439 0 -1031.402 454.004)",fx:"158.429",fy:"578.088"}),/*#__PURE__*/e.jsx("radialGradient",{id:"d",cx:"147.694",cy:"473.455",r:"65",xlinkHref:"#b",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(.17394 .86872 -3.5818 .71718 1648.348 -458.493)",fx:"147.694",fy:"473.455"})]}),/*#__PURE__*/e.jsx("path",{fill:"url(#c)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),/*#__PURE__*/e.jsx("path",{fill:"url(#d)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),/*#__PURE__*/e.jsx("path",{fill:"#fff",d:"M66.004 18c-13.036 0-14.672.057-19.792.29-5.11.234-8.598 1.043-11.65 2.23-3.157 1.226-5.835 2.866-8.503 5.535-2.67 2.668-4.31 5.346-5.54 8.502-1.19 3.053-2 6.542-2.23 11.65C18.06 51.327 18 52.964 18 66s.058 14.667.29 19.787c.235 5.11 1.044 8.598 2.23 11.65 1.227 3.157 2.867 5.835 5.536 8.503 2.667 2.67 5.345 4.314 8.5 5.54 3.054 1.187 6.543 1.996 11.652 2.23 5.12.233 6.755.29 19.79.29 13.037 0 14.668-.057 19.788-.29 5.11-.234 8.602-1.043 11.656-2.23 3.156-1.226 5.83-2.87 8.497-5.54 2.67-2.668 4.31-5.346 5.54-8.502 1.18-3.053 1.99-6.542 2.23-11.65.23-5.12.29-6.752.29-19.788 0-13.036-.06-14.672-.29-19.792-.24-5.11-1.05-8.598-2.23-11.65-1.23-3.157-2.87-5.835-5.54-8.503-2.67-2.67-5.34-4.31-8.5-5.535-3.06-1.187-6.55-1.996-11.66-2.23-5.12-.233-6.75-.29-19.79-.29zm-4.306 8.65c1.278-.002 2.704 0 4.306 0 12.816 0 14.335.046 19.396.276 4.68.214 7.22.996 8.912 1.653 2.24.87 3.837 1.91 5.516 3.59 1.68 1.68 2.72 3.28 3.592 5.52.657 1.69 1.44 4.23 1.653 8.91.23 5.06.28 6.58.28 19.39s-.05 14.33-.28 19.39c-.214 4.68-.996 7.22-1.653 8.91-.87 2.24-1.912 3.835-3.592 5.514-1.68 1.68-3.275 2.72-5.516 3.59-1.69.66-4.232 1.44-8.912 1.654-5.06.23-6.58.28-19.396.28-12.817 0-14.336-.05-19.396-.28-4.68-.216-7.22-.998-8.913-1.655-2.24-.87-3.84-1.91-5.52-3.59-1.68-1.68-2.72-3.276-3.592-5.517-.657-1.69-1.44-4.23-1.653-8.91-.23-5.06-.276-6.58-.276-19.398s.046-14.33.276-19.39c.214-4.68.996-7.22 1.653-8.912.87-2.24 1.912-3.84 3.592-5.52 1.68-1.68 3.28-2.72 5.52-3.592 1.692-.66 4.233-1.44 8.913-1.655 4.428-.2 6.144-.26 15.09-.27zm29.928 7.97c-3.18 0-5.76 2.577-5.76 5.758 0 3.18 2.58 5.76 5.76 5.76 3.18 0 5.76-2.58 5.76-5.76 0-3.18-2.58-5.76-5.76-5.76zm-25.622 6.73c-13.613 0-24.65 11.037-24.65 24.65 0 13.613 11.037 24.645 24.65 24.645C79.617 90.645 90.65 79.613 90.65 66S79.616 41.35 66.003 41.35zm0 8.65c8.836 0 16 7.163 16 16 0 8.836-7.164 16-16 16-8.837 0-16-7.164-16-16 0-8.837 7.163-16 16-16z"})]})}function Hr({style:t,...r}){/*#__PURE__*/return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0,0,256,256",style:{height:"26px",width:"26px",...t},...r,children:/*#__PURE__*/e.jsx("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:/*#__PURE__*/e.jsx("g",{transform:"scale(5.12,5.12)",children:/*#__PURE__*/e.jsx("path",{d:"M41,4h-32c-2.76,0 -5,2.24 -5,5v32c0,2.76 2.24,5 5,5h32c2.76,0 5,-2.24 5,-5v-32c0,-2.76 -2.24,-5 -5,-5zM17,20v19h-6v-19zM11,14.47c0,-1.4 1.2,-2.47 3,-2.47c1.8,0 2.93,1.07 3,2.47c0,1.4 -1.12,2.53 -3,2.53c-1.8,0 -3,-1.13 -3,-2.53zM39,39h-6c0,0 0,-9.26 0,-10c0,-2 -1,-4 -3.5,-4.04h-0.08c-2.42,0 -3.42,2.06 -3.42,4.04c0,0.91 0,10 0,10h-6v-19h6v2.56c0,0 1.93,-2.56 5.81,-2.56c3.97,0 7.19,2.73 7.19,8.26z"})})})})}function Kr(t){/*#__PURE__*/return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...t,children:[/*#__PURE__*/e.jsx("path",{fill:"#1ed760",d:"M248 8C111.1 8 0 119.1 0 256s111.1 248 248 248 248-111.1 248-248S384.9 8 248 8Z"}),/*#__PURE__*/e.jsx("path",{d:"M406.6 231.1c-5.2 0-8.4-1.3-12.9-3.9-71.2-42.5-198.5-52.7-280.9-29.7-3.6 1-8.1 2.6-12.9 2.6-13.2 0-23.3-10.3-23.3-23.6 0-13.6 8.4-21.3 17.4-23.9 35.2-10.3 74.6-15.2 117.5-15.2 73 0 149.5 15.2 205.4 47.8 7.8 4.5 12.9 10.7 12.9 22.6 0 13.6-11 23.3-23.2 23.3zm-31 76.2c-5.2 0-8.7-2.3-12.3-4.2-62.5-37-155.7-51.9-238.6-29.4-4.8 1.3-7.4 2.6-11.9 2.6-10.7 0-19.4-8.7-19.4-19.4s5.2-17.8 15.5-20.7c27.8-7.8 56.2-13.6 97.8-13.6 64.9 0 127.6 16.1 177 45.5 8.1 4.8 11.3 11 11.3 19.7-.1 10.8-8.5 19.5-19.4 19.5zm-26.9 65.6c-4.2 0-6.8-1.3-10.7-3.6-62.4-37.6-135-39.2-206.7-24.5-3.9 1-9 2.6-11.9 2.6-9.7 0-15.8-7.7-15.8-15.8 0-10.3 6.1-15.2 13.6-16.8 81.9-18.1 165.6-16.5 237 26.2 6.1 3.9 9.7 7.4 9.7 16.5s-7.1 15.4-15.2 15.4z"})]})}function Zr(t){/*#__PURE__*/return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",imageRendering:"optimizeQuality",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",viewBox:"0 0 293768 333327",width:24,height:24,...t,children:[/*#__PURE__*/e.jsx("path",{fill:"#26f4ee",d:"M204958 0c5369 45832 32829 78170 77253 81022v43471l-287 27V87593c-44424-2850-69965-30183-75333-76015l-47060-1v192819c6791 86790-60835 89368-86703 56462 30342 18977 79608 6642 73766-68039V0h58365zM78515 319644c-26591-5471-50770-21358-64969-44588-34496-56437-3401-148418 96651-157884v54345l-164 27v-40773C17274 145544 7961 245185 33650 286633c9906 15984 26169 27227 44864 33011z"}),/*#__PURE__*/e.jsx("path",{fill:"#fb2c53",d:"M218434 11587c3505 29920 15609 55386 35948 70259-27522-10602-43651-34934-47791-70262l11843 3zm63489 82463c3786 804 7734 1348 11844 1611v51530c-25770 2537-48321-5946-74600-21749l4034 88251c0 28460 106 41467-15166 67648-34260 58734-95927 63376-137628 35401 54529 22502 137077-4810 136916-103049v-96320c26279 15803 48830 24286 74600 21748V94050zm-171890 37247c5390-1122 11048-1985 16998-2548v54345c-21666 3569-35427 10222-41862 22528-20267 38754 5827 69491 35017 74111-33931 5638-73721-28750-49999-74111 6434-12304 18180-18959 39846-22528v-51797zm64479-119719h1808-1808z"}),/*#__PURE__*/e.jsx("path",{d:"M206590 11578c5369 45832 30910 73164 75333 76015v51528c-25770 2539-48321-5945-74600-21748v96320c206 125717-135035 135283-173673 72939-25688-41449-16376-141089 76383-155862v52323c-21666 3569-33412 10224-39846 22528-39762 76035 98926 121273 89342-1225V11577l47060 1z",fill:"#000000"})]})}const Yr=({style:t,...r})=>/*#__PURE__*/e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",width:"24px",...t},...r,children:/*#__PURE__*/e.jsx("path",{d:"M 14.285156 10.171875 L 23.222656 0 L 21.105469 0 L 13.34375 8.832031 L 7.148438 0 L 0 0 L 9.371094 13.355469 L 0 24.019531 L 2.117188 24.019531 L 10.308594 14.691406 L 16.851562 24.019531 L 24 24.019531 M 2.878906 1.5625 L 6.132812 1.5625 L 21.101562 22.535156 L 17.851562 22.535156",fill:"currentColor"})});let Gr={google:{name:"Google",component:qr},discord:{name:"Discord",component:Br},github:{name:"Github",component:zr},linkedin:{name:"LinkedIn",component:Hr},twitter:{name:"Twitter",component:Yr},spotify:{name:"Spotify",component:Kr},instagram:{name:"Instagram",component:Vr},tiktok:{name:"Tiktok",component:Zr},apple:{name:"Apple",component:Dr}};const Jr=e=>e in Gr?Gr[e]:{name:"Unknown",component:$r};function Qr(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),r=e.get("privy_oauth_state"),n=e.get("privy_oauth_provider");if(!t||!r||!n)return{inProgress:!1};let a=!1;try{a=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:r,provider:n,withPrivyUi:!Mt.get(jr),popupFlow:null!==window.opener&&a,disableSignup:!!Mt.get(Er)}}function Xr(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),Mt.del(Cr),window.history.replaceState({},"",e)}class en{async initRegisterFlow(e){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");this.authenticateForRegistration=!0,this.meta.initRegisterResponse=await this.initRegisterOnce.execute(e)}async initAuthenticationFlow(e){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async register(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new o.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initRegisterResponse||(this.meta.initRegisterResponse=await this.initRegisterOnce.execute());try{let t=this.meta.initRegisterResponse.options,r=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(o.passkeyRegisterPath,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new o.PrivyClientError("Passkey request timed out or rejected by user.",void 0,o.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw o.formatApiError(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new o.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());let t=this.meta.allowedCredentialsIds?.map((e=>({type:"public-key",id:e})))??this.meta.initAuthenticateResponse.options.allow_credentials;try{let r=await e.startAuthentication(this._transformInitAuthenticateOptionsToCamelCase({...this.meta.initAuthenticateResponse.options,allow_credentials:t}));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(o.passkeyAuthenticatePath,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new o.PrivyClientError("Passkey request timed out or rejected by user.",void 0,o.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw o.formatApiError(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new o.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let t=this.meta.initLinkResponse.options,r=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(o.passkeyLinkPath,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new o.PrivyClientError("Passkey request timed out or rejected by user.",void 0,o.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw o.formatApiError(e)}}async _initRegisterOnce(e){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");let t=It(e);return await this.api.post(o.passkeyInitRegisterPath,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");let t=It(e);return await this.api.post(o.passkeyInitAuthenticatePath,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");return await this.api.post(o.passkeyInitLinkPath,{})}_transformInitLinkOptionsToCamelCase(e){return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params.map((e=>({type:e.type,alg:e.alg}))),timeout:e.timeout,excludeCredentials:e.exclude_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports}))),authenticatorSelection:{authenticatorAttachment:e.authenticator_selection?.authenticator_attachment,requireResidentKey:e.authenticator_selection?.require_resident_key,residentKey:e.authenticator_selection?.resident_key,userVerification:e.authenticator_selection?.user_verification},attestation:e.attestation,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props?.rk,hmacCreateSecret:e.extensions?.hmac_create_secret}}}_transformRegistrationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,attestation_object:e.response.attestationObject,authenticator_data:e.response.authenticatorData},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}_transformInitAuthenticateOptionsToCamelCase(e){return{rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}}_transformAuthenticationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}constructor({captchaToken:e,setPasskeyAuthState:t}){this.authenticateForRegistration=!1,this.initRegisterOnce=new ar(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new ar(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new ar(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t}}}const tn=({address:e,chainId:t,nonce:r})=>`${window.location.host} wants you to sign in with your Ethereum account:\n${e}\n\nBy signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: ${t}\nNonce: ${r}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`;class rn{get meta(){return{connectorType:this.wallet?.connectorType,walletClientType:this.wallet?.walletClientType,chainId:this.wallet?.chainId,address:this.wallet?.address,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new o.PrivyClientError("SiweFlow has no client instance");try{if(this.preparedMessage&&this.signature)return await this.client.authenticateWithSiweInternal({message:this.preparedMessage,signature:this.signature,chainId:this.wallet?.chainId,walletClientType:this.wallet?.walletClientType,connectorType:this.wallet?.connectorType,mode:this._meta.disableSignup?"no-signup":"login-or-sign-up"});if(!this.wallet)throw new o.PrivyClientError("SiweFlow has no wallet instance");let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw o.formatApiError(e)}}async link(){if(!this.client)throw new o.PrivyClientError("SiweFlow has no client instance");try{if(!this.wallet)throw new o.PrivyClientError("SiweFlow has no wallet instance");let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw o.formatApiError(e)}}async sign(){if(!this.client)throw new o.PrivyClientError("SiweFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new o.PrivyClientError("Could not prepare SIWE message");if(!this.wallet)throw new o.PrivyClientError("SiweFlow has no wallet instance");let e=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:e}}async _getNonceOnce(){if(!this.client)throw new o.PrivyClientError("SiweFlow has no client instance");if(!this.wallet)throw new o.PrivyClientError("UI SiweFlow has no wallet instance");return await this.client.generateSiweNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new o.PrivyClientError("SiweFlow has no client instance");if(!this.wallet)throw new o.PrivyClientError("SiweFlow has no wallet instance");let e=this.wallet.address,t=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=tn({address:e,chainId:t,nonce:this.nonce}),this.preparedMessage}constructor(e,t,r,n=!1,a){this._meta={disableSignup:!1},this.getNonceOnce=new ar(this._getNonceOnce.bind(this)),this.wallet=t,this.captchaToken=r,this.client=e,this._meta.disableSignup=n,this.preparedMessage=a?.message,this.signature=a?.signature}}const nn=(...e)=>{if("undefined"==typeof Buffer)throw new o.PrivyClientError("Buffer is not defined.",void 0,o.PrivyErrorCode.BUFFER_NOT_DEFINED);return Buffer.from(...e)},an=({address:e,nonce:t})=>`${window.location.host} wants you to sign in with your Solana account:\n${e}\n\n${`You are proving you own ${e}.`}\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: mainnet\nNonce: ${t}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`;class on{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,disableSignup:this._meta.disableSignup,messageType:this._meta.messageType}}set messageType(e){this._meta.messageType=e}async authenticate(){if(!this.client)throw new o.PrivyClientError("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up",messageType:this.meta.messageType})}catch(e){throw o.formatApiError(e)}}async link(){if(!this.client)throw new o.PrivyClientError("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,messageType:this.meta.messageType})}catch(e){throw o.formatApiError(e)}}async sign(){let e,t;if(!this.client)throw new o.PrivyClientError("SiwsFlow has no client instance");await this.buildMessage();let r="transaction"===this.meta.messageType;if(!this.preparedMessage)throw new o.PrivyClientError("Could not prepare SIWS message");if(!r&&!this.wallet.signMessage||r&&!this.wallet.signTransaction)throw new o.PrivyClientError("Wallet does not support the necessary signing methods");if(r&&this._siwsTransactionMethods){let r=await this.wallet.signTransaction(this._siwsTransactionMethods.deserializeTransactionFromB64String(this.preparedMessage));e=r.serialize().toString("base64"),t=nn(r.signatures[0]?.signature??Buffer.from("missing signature")).toString("base64")}else e=this.preparedMessage,t=nn(await this.wallet.signMessage(nn(this.preparedMessage))).toString("base64");return{message:e,signature:t}}async _getNonceOnce(){if(!this.client)throw new o.PrivyClientError("SiwsFlow has no client instance");return await this.client.generateSiwsNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new o.PrivyClientError("SiwsFlow has no client instance");let e=this.wallet.address;return this.nonce||(this.nonce=await this.getNonceOnce.execute()),"transaction"===this.meta.messageType&&this._siwsTransactionMethods?this.preparedMessage=this._siwsTransactionMethods.prepareSiwsTransactionWithMemo({address:e,nonce:this.nonce}):this.preparedMessage=an({address:e,nonce:this.nonce}),this.preparedMessage}constructor(e,t,r,n=!1,a="plain",i){this._meta={disableSignup:!1,messageType:"plain"},this.getNonceOnce=new ar(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=r,this.client=t,this._meta.disableSignup=n,this._meta.messageType=a,this._siwsTransactionMethods=i}}class sn{async authenticate(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new o.PrivyClientError("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(o.passwordlessSmsAuthenticatePath,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw o.formatApiError(e)}}async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new o.PrivyClientError("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(o.passwordlessSmsLinkPath,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw o.formatApiError(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:r}){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new o.PrivyClientError("phone nNumber must be set when initialzing authentication.");let n=It(r);try{return await this.api.post(o.passwordlessSmsInitPath,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...n}})}catch(e){throw o.formatApiError(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:r}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:r??!1}}}class ln extends sn{async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new o.PrivyClientError("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(o.updatePhonePath,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw o.formatApiError(e)}}constructor(e,t,r){super({phoneNumber:t,captchaToken:r}),this.meta={phoneNumber:t,captchaToken:r,oldPhoneNumber:e,disableSignup:!1}}}const cn=/*#__PURE__*/r.createContext({siteKey:"",enabled:!1,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:s.notImplemented,setError:s.notImplemented,setExecuting:s.notImplemented,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:s.notImplemented,reset:s.notImplemented,execute:s.notImplemented});class dn extends o.PrivyError{constructor(e,t,r){super(e||"Captcha failed"),this.type="Captcha",t instanceof Error&&(this.cause=t),this.privyErrorCode=r}}const un=({children:t,id:n,captchaSiteKey:a,captchaEnabled:i})=>{let s=r.useRef(null),[l,c]=r.useState(),[d,u]=r.useState(),[h,p]=r.useState(!1),y=r.useMemo((()=>i?h||l||d?!h||l||d?l&&!d?{status:"success",token:l}:d?{status:"error",error:d}:{status:"ready"}:{status:"loading"}:{status:"ready"}:{status:"disabled"}),[i,l,d,h]);/*#__PURE__*/return e.jsx(cn.Provider,{value:{...y,ref:s,enabled:i,siteKey:a,appId:n,setToken:c,setError:u,setExecuting:p,remove(){i&&(s.current?.remove(),p(!1),u(void 0),c(void 0))},reset(){i&&(s.current?.reset(),p(!1),u(void 0),c(void 0))},execute(){i&&(p(!0),s.current?.execute())},async waitForResult(){if(!i)return"";try{return await function(e,{interval:t=100,timeout:r=5e3}={}){return new Promise(((n,a)=>{let i,o=0,s=()=>{o>=r?a("Max attempts reached without result"):(i=e(),o+=t,null==i?setTimeout(s,t):n(i))};s()}))}((()=>s.current?.getResponse()),{interval:200,timeout:2e4})}catch(e){throw new dn("Captcha failed",null,o.PrivyErrorCode.CAPTCHA_TIMEOUT)}}},children:t})},hn=()=>r.useContext(cn);class pn{async authenticate(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(o.telegramAccountAuthenticatePath,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw o.formatApiError(e)}}async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(o.telegramAccountLinkPath,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw o.formatApiError(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function yn(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===o.PrivyErrorCode.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===o.PrivyErrorCode.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===o.PrivyErrorCode.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===o.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===o.PrivyErrorCode.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===o.PrivyErrorCode.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===o.PrivyErrorCode.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof dn&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t}function mn(e){return Object.fromEntries(decodeURIComponent(e).split("&").map((e=>e.split("=").map(decodeURIComponent))))}function gn(){let e=new URL(window.location.href);e.searchParams.delete("id"),e.searchParams.delete("hash"),e.searchParams.delete("auth_date"),e.searchParams.delete("first_name"),e.searchParams.delete("last_name"),e.searchParams.delete("username"),e.searchParams.delete("photo_url"),e.hash="",window.history.replaceState({},"",e)}class fn{static parse(e){try{return new fn(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return Ae.decodeJwt(e),e}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){return Date.now()>=1e3*(this.expiration-e)}constructor(e){this.value=e,this._decoded=Ae.decodeJwt(e)}}class wn extends fn{static parse(e){try{return new wn(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}let vn=e=>{if("ethereum"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier"};if("solana"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"solana-address-verifier"};throw Error("Failed to get account entropy details")};const xn=(e,t)=>{if(t?.imported)return vn(t);let r=u.getPrivyPrimaryWallet(e);if(!r)throw Error("Failed to find primary wallet");return vn(r)},Cn=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});class bn extends o.PrivyConnectorError{constructor(){super("Wallet timeout"),this.type="wallet_error"}}class jn extends o.PrivyConnectorError{constructor(){super("User rejected connection"),this.type="wallet_error"}}const En=e=>e instanceof o.PrivyConnectorError?e:e?.code?new Tn(e):new o.PrivyConnectorError("Unknown connector error",e);class kn extends o.PrivyError{constructor(e,t,r){super(e),this.type="provider_error",this.code=t,this.data=r}}class Tn extends kn{constructor(e){super(e.message,e.code,e.data);let t=Object.values(i.ProviderErrors).find((t=>t.eipCode===e.code));this.details=t||i.ProviderErrors.UNKNOWN_ERROR,-32002===e.code&&(e.message?.includes("already pending for origin")?e.message?.includes("wallet_requestPermissions")?this.details=i.ProviderErrors.E32002_CONNECTION_ALREADY_PENDING:this.details=i.ProviderErrors.E32002_REQUEST_ALREADY_PENDING:e.message?.includes("Already processing")&&e.message.includes("eth_requestAccounts")&&(this.details=i.ProviderErrors.E32002_WALLET_LOCKED))}}const An={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0},ERROR_USER_LIMIT_REACHED:{message:"Unable to link",detail:"You've reached the maximum number of linked wallets.",retryable:!1},...i.ProviderErrors};function In(e){return"ethereum"===e.type}function Sn(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){let n=e[r],a=t[r];if(n?.address!==a?.address||n&&a&&In(n)&&In(a)&&n?.chainId!==a?.chainId||n?.connectorType!==a?.connectorType||n?.connectedAt!==a?.connectedAt||n?.walletClientType!==a?.walletClientType||n?.isConnected!==a?.isConnected||n?.linked!==a?.linked)return!1}return!0}class Pn extends Ie.default{constructor(e){super(),this.walletClientType=e,this.connected=!1,this.initialized=!1}}const _n=(e,t)=>e.rpcTimeouts&&e.rpcTimeouts[t]||Ir;let Nn;function Mn(e){return"ethereum"===e.chainType}class Wn extends Pn{buildConnectedWallet(e,t,r,n){let i=async()=>!!this.wallets.find((t=>a.getAddress(t.address)===a.getAddress(e)));return{type:"ethereum",address:a.getAddress(e),chainId:t,meta:r,imported:n,switchChain:async r=>{let n,s;if(!i)throw new o.PrivyConnectorError("Wallet is not currently connected.");let l=this.wallets.find((t=>a.getAddress(t.address)===a.getAddress(e)))?.chainId;if(!l)throw new o.PrivyConnectorError("Unable to determine current chainId.");if("number"==typeof r?(n=`0x${r.toString(16)}`,s=r):(n=r,s=Number(r)),l===Zt(n))return;let c=this.chains.find((e=>e.id===s));if(!c)throw new o.PrivyConnectorError(`Unsupported chainId: ${r}`);let d=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:n}]})};try{return await d()}catch(e){if(((e,t)=>{switch(t){case"coinbase_wallet":return e.message.includes("addEthereumChain");case"rabby_wallet":return e.message.includes("Unrecognized chain ID");default:return 4902===e.code||e.message?.includes("4902")}})(e,this.walletClientType))return"rabby_wallet"===this.walletClientType&&await zt(300),await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:n,chainName:c.name,nativeCurrency:c.nativeCurrency,rpcUrls:[c.rpcUrls.default?.http[0]??""],blockExplorerUrls:[c.blockExplorers?.default.url??""]}]}),d();if("rainbow"===this.walletClientType&&e.message?.includes("wallet_switchEthereumChain"))throw new o.PrivyConnectorError(`Rainbow does not support the chainId ${t}`);throw e}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:i,getEthereumProvider:async()=>{if(!await i())throw new o.PrivyConnectorError("Wallet is not currently connected.");return this.proxyProvider},sign:async e=>{if(!await i())throw new o.PrivyConnectorError("Wallet is not currently connected.");return await this.sign(e)},disconnect:()=>{this.disconnect()}}}async syncAccounts(e){let t,r=e;try{if(void 0===r){let e=await $t((()=>this.proxyProvider.request({method:"eth_accounts"})),{maxAttempts:10,delayMs:500});console.debug(`eth_accounts for ${this.walletClientType}:`,e),Array.isArray(e)&&(r=e)}}catch(e){console.debug("Wallet did not respond to eth_accounts. Defaulting to prefetched accounts.",e)}if(!r||!Array.isArray(r)||r.length<=0||!r[0])return;let n=r[0],i=a.getAddress(n),o=[];if("privy"===this.walletClientType){let e=Mt.get(kr(i));this.chains.find((t=>t.id===Number(e)))||(Mt.del(kr(i)),e=null),t=e||`0x${this.defaultChain.id.toString(16)}`;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:t}]})}catch(e){console.warn(`Unable to switch embedded wallet to chain ID ${t} on initialization`)}}else try{let e=await $t((()=>this.proxyProvider.request({method:"eth_chainId"})),{maxAttempts:10,delayMs:500});if(console.debug(`eth_chainId for ${this.walletClientType}:`,e),"string"==typeof e)t=e;else{if("number"!=typeof e)throw Error("Invalid chainId returned from provider");t=`0x${e.toString(16)}`}}catch(e){console.warn("Failed to get chainId from provider, defaulting to 0x1",e),t="0x1"}let s=Zt(t);if(!o.find((e=>a.getAddress(e.address)===i))){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};o.push(this.buildConnectedWallet(a.getAddress(n),s,e,"embedded_imported"===this.connectorType))}Sn(o,this.wallets)||(this.wallets=o,this.emit("walletsUpdated"))}async getConnectedWallet(){let e=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt)).find((t=>e.find((e=>a.getAddress(e)===a.getAddress(t.address)))))||null}async isConnected(){let e=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(e)&&e.length>0}async sign(e){return await this.connect({showPrompt:!1}),this.proxyProvider.request({method:"personal_sign",params:[a.toHex(e),this.wallets[0]?.address]})}subscribeListeners(){this.proxyProvider.on("accountsChanged",this.onAccountsChanged),this.proxyProvider.on("chainChanged",this.onChainChanged),this.proxyProvider.on("disconnect",this.onDisconnect),this.proxyProvider.on("connect",this.onConnect)}unsubscribeListeners(){this.proxyProvider.removeListener("accountsChanged",this.onAccountsChanged),this.proxyProvider.removeListener("chainChanged",this.onChainChanged),this.proxyProvider.removeListener("disconnect",this.onDisconnect),this.proxyProvider.removeListener("connect",this.onConnect)}constructor(e,t,r,n){super(e),this.chainType="ethereum",this.onAccountsChanged=e=>{0===e.length?this.onDisconnect():this.syncAccounts(e)},this.onChainChanged=e=>{this.wallets.forEach((t=>{t.chainId=Zt(e),"privy"===this.walletClientType&&Mt.put(kr(t.address),e)})),this.emit("walletsUpdated")},this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")},this.onConnect=async()=>{this.connected=!0,"coinbase_wallet"===this.connectorType&&await zt(500),this.syncAccounts()},this.wallets=[],this.walletClientType=e,this.chains=t,this.defaultChain=r,this.rpcConfig=n,this.rpcTimeoutDuration=_n(n,e),this.connected=!1,this.initialized=!1}}class Un{on(e,t){if(this.walletProvider)return this.walletProvider.on(e,t);this._subscriptions.push({eventName:e,listener:t})}async request(e){if(!this.walletProvider)throw new o.PrivyConnectorError(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),this.walletTimeout()]).catch((e=>{throw En(e)}))}constructor(e,t){this.removeListener=(e,t)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(e,t)}catch(e){console.warn("Unable to remove wallet provider listener")}},this.walletTimeout=(e=new bn,t=this.rpcTimeoutDuration)=>new Promise(((r,n)=>setTimeout((()=>{n(e)}),t))),this.setWalletProvider=e=>{this.walletProvider&&this._subscriptions.forEach((e=>{this.removeListener(e.eventName,e.listener)})),this.walletProvider=e,this._subscriptions.forEach((e=>{this.walletProvider?.on(e.eventName,e.listener)}))},this.walletProvider=e,this.rpcTimeoutDuration=t||Ir,this._subscriptions=[]}}let On=[1,11155111,137,10,8453,84532,42161,7777777,43114,56];class Fn extends Wn{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PScwIDAgMTAyNCAxMDI0JyBmaWxsPSdub25lJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHN0eWxlPSdoZWlnaHQ6MjhweDt3aWR0aDoyOHB4Jz48cmVjdCB3aWR0aD0nMTAyNCcgaGVpZ2h0PScxMDI0JyBmaWxsPScjMDA1MkZGJyByeD0nMTAwJyByeT0nMTAwJz48L3JlY3Q+PHBhdGggZmlsbC1ydWxlPSdldmVub2RkJyBjbGlwLXJ1bGU9J2V2ZW5vZGQnIGQ9J00xNTIgNTEyQzE1MiA3MTAuODIzIDMxMy4xNzcgODcyIDUxMiA4NzJDNzEwLjgyMyA4NzIgODcyIDcxMC44MjMgODcyIDUxMkM4NzIgMzEzLjE3NyA3MTAuODIzIDE1MiA1MTIgMTUyQzMxMy4xNzcgMTUyIDE1MiAzMTMuMTc3IDE1MiA1MTJaTTQyMCAzOTZDNDA2Ljc0NSAzOTYgMzk2IDQwNi43NDUgMzk2IDQyMFY2MDRDMzk2IDYxNy4yNTUgNDA2Ljc0NSA2MjggNDIwIDYyOEg2MDRDNjE3LjI1NSA2MjggNjI4IDYxNy4yNTUgNjI4IDYwNFY0MjBDNjI4IDQwNi43NDUgNjE3LjI1NSAzOTYgNjA0IDM5Nkg0MjBaJyBmaWxsPSd3aGl0ZSc+PC9wYXRoPjwvc3ZnPg==",id:"com.coinbase.wallet"}}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new o.PrivyConnectorError("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw En(e)}}updateConnectionPreference(e){this.coinbaseWalletConfig={...this.coinbaseWalletConfig,preference:{...this.coinbaseWalletConfig.preference,options:e}},this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",Nn=p.createCoinbaseWalletSDK({...this.coinbaseWalletConfig}),this.proxyProvider.setWalletProvider(Nn.getProvider())}constructor(e,t,r,n){if(super("coinbase_wallet",e,t,r),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new Un(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.coinbaseWalletConfig={...n,appChainIds:[t.id].concat(e.map((e=>e.id)))},this.walletClientType="smartWalletOnly"===this.coinbaseWalletConfig.preference?.options?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!Nn){let e="eoaOnly"!==this.coinbaseWalletConfig.preference?.options?(this.coinbaseWalletConfig.appChainIds??[]).filter((e=>!On.includes(e))):[];e.length>0&&!e.every((e=>i.DEFAULT_SUPPORTED_CHAIN_IDS.has(e)))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${e.join(", ")}`),Nn=p.createCoinbaseWalletSDK(this.coinbaseWalletConfig)}this.proxyProvider.setWalletProvider(Nn.getProvider())}}const Rn=({...t})=>/*#__PURE__*/e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.37126 11.0323C2.37126 12.696 3.90598 13.4421 5.40654 13.4468C8.91753 13.4468 12.8021 11.2897 12.7819 7.67984C12.7673 5.07728 10.3748 2.86167 7.54357 2.88296C4.8495 2.88296 2.21821 4.6411 2.21803 7.03628C2.21803 7.67951 2.58722 8.30178 3.55231 8.37184C2.74763 9.16826 2.37126 10.1225 2.37126 11.0323ZM7.55283 8.68012C8.11562 8.68012 8.57186 8.13217 8.57186 7.45624C8.57186 6.78032 8.11562 6.23237 7.55283 6.23237C6.99003 6.23237 6.53379 6.78032 6.53379 7.45624C6.53379 8.13217 6.99003 8.68012 7.55283 8.68012ZM10.4747 8.68012C11.0375 8.68012 11.4937 8.13217 11.4937 7.45625C11.4937 6.78032 11.0375 6.23237 10.4747 6.23237C9.91186 6.23237 9.45562 6.78032 9.45562 7.45625C9.45562 8.13217 9.91186 8.68012 10.4747 8.68012Z",fill:t.color||"var(--privy-color-foreground-3)"})});class Ln extends Wn{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[Ht(e?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Rn,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}constructor({provider:e,chains:t,defaultChain:r,rpcConfig:n,imported:a,walletIndex:i}){super("privy",t,r,n),this.connectorType="embedded",this.proxyProvider=e,this.walletIndex=i,a&&(this.connectorType="embedded_imported"),this.subscribeListeners()}}const Dn=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];class Bn extends Error{constructor(e,t,r){super(e),this.code=t,this.data=r}}class zn extends Ie.default{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new Bn(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await yv()||!this.address)throw new Bn("Disconnected",4900);let{hash:r}=await wv(t,{address:this.address});return r}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new Bn(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await yv()||!this.address)throw new Bn("Disconnected",4900);let{signature:r}=await fv(t,{address:this.address});return r}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new Bn(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new Bn(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=Ft(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",t)}async handlePersonalSign(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for personal_sign");let t=e.params[0],r=e.params[1],{signature:n}=await mv({message:t},{address:r});return n}async handleSignedTypedData(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_signTypedData_v4");let t=e.params[0],r="string"==typeof e.params[1]?JSON.parse(e.params[1]):e.params[1],{signature:n}=await gv(Gt(r),{address:t});return n}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");delete e.params[0].gasPrice,delete e.params[0].maxFeePerGas,delete e.params[0].maxPriorityFeePerGas;let t={...e.params[0],chainId:Ht(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...y.toViemTransactionSerializable(t)})}async request(e){switch(console.debug("Embedded1193Provider.request() called with args",e),e.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return Ht(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_sendTransaction":return this.handleSendTransaction(e);case"eth_signTransaction":return this.handleSignTransaction(e);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"personal_sign":return this.handlePersonalSign(e);case"eth_signTypedData_v4":return this.handleSignedTypedData(e)}if(!(e=>Dn.includes(e))(e.method))return this.publicClient.request({method:e.method,params:e.params});{let t=await yv();if(await vv({address:this.address}),!t||!this.address)throw new Bn("Disconnected",4900);try{let r={method:e.method,params:e.params},n=this.walletAccount;return n&&u.getIsUnifiedWallet(n)?this.handleWalletApiRequest(r,n,t):(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:r})).response.data}catch(e){throw console.error(e),new Bn("Disconnected",4900)}}}async handleWalletApiRequest(e,t,r){let n=this.privyClient;if(!n)throw new Bn("Disconnected",4900);if("secp256k1_sign"===e.method){let a=await i.rpc(n,(async({message:e})=>this.walletProxy.signWithUserSigner({accessToken:r,message:e})),{chain_type:"ethereum",method:"secp256k1_sign",wallet_id:t.id,params:{hash:e.params[0]}});if("secp256k1_sign"!==a.method)throw new Bn(`Invalid params for ${e.method}`,4200);return a.data.signature}throw new Bn(`Method not supported: ${e.method}`,4200)}constructor({walletProxy:e,address:t,entropyId:r,entropyIdVerifier:n,rpcConfig:a,chains:i,appId:o,chainId:s=1,walletIndex:l,privyClient:c,walletAccount:d}){super(),this.walletProxy=e,this.address=t,this.entropyId=r,this.entropyIdVerifier=n,this.chainId=s,this.rpcConfig=a,this.chains=i,this.publicClient=Ft(s,this.chains,a,{appId:o}),this.rpcTimeoutDuration=_n(a,"privy"),this.appId=o,this.walletIndex=l,this.privyClient=c,this.walletAccount=d}}class $n extends Wn{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the EthereumNullConnector")}disconnect(){throw Error("disconnect called for an uninstalled wallet via the EthereumNullConnector")}promptConnection(e){throw Error(`promptConnection called for an uninstalled wallet via the EthereumNullConnector for ${e}`)}constructor({id:e,name:t,icon:r,walletClientType:n,defaultChain:a}){super(n,[],a,{}),this.connectorType="null",this.proxyProvider=new Un(void 0,Ir),this.id=e,this.name=t,this.icon=r,this.connectorType=n}}const qn=({style:t,...r})=>/*#__PURE__*/e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...t},...r,children:/*#__PURE__*/e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0V12a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 12V5.25"})}),Vn=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",x:0,y:0,viewBox:"0 0 318.6 318.6",width:"28",height:"28",style:{height:"28px",width:"28px",...t},...r,children:[/*#__PURE__*/e.jsx("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),/*#__PURE__*/e.jsx("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),/*#__PURE__*/e.jsx("path",{d:"m44.4 35.5 98.7 74.6-17.5-44.3zm193.9 171.3-26.5 40.6 56.7 15.6 16.3-55.3zm-204.4.9L50.1 263l56.7-15.6-26.5-40.6z",className:"s1 s2"}),/*#__PURE__*/e.jsx("path",{d:"m103.6 138.2-15.8 23.9 56.3 2.5-2-60.5zm111.3 0-39-34.8-1.3 61.2 56.2-2.5zM106.8 247.4l33.8-16.5-29.2-22.8zm71.1-16.5 33.9 16.5-4.7-39.3z",className:"s1 s2"}),/*#__PURE__*/e.jsx("path",{fill:"#d7c1b3",stroke:"#d7c1b3",className:"s1",d:"m211.8 247.4-33.9-16.5 2.7 22.1-.3 9.3zm-105 0 31.5 14.9-.2-9.3 2.5-22.1z"}),/*#__PURE__*/e.jsx("path",{fill:"#233447",stroke:"#233447",className:"s1",d:"m138.8 193.5-28.2-8.3 19.9-9.1zm40.9 0 8.3-17.4 20 9.1z"}),/*#__PURE__*/e.jsx("path",{fill:"#cd6116",stroke:"#cd6116",className:"s1",d:"m106.8 247.4 4.8-40.6-31.3.9zM207 206.8l4.8 40.6 26.5-39.7zm23.8-44.7-56.2 2.5 5.2 28.9 8.3-17.4 20 9.1zm-120.2 23.1 20-9.1 8.2 17.4 5.3-28.9-56.3-2.5z"}),/*#__PURE__*/e.jsx("path",{fill:"#e4751f",stroke:"#e4751f",className:"s1",d:"m87.8 162.1 23.6 46-.8-22.9zm120.3 23.1-1 22.9 23.7-46zm-64-20.6-5.3 28.9 6.6 34.1 1.5-44.9zm30.5 0-2.7 18 1.2 45 6.7-34.1z"}),/*#__PURE__*/e.jsx("path",{d:"m179.8 193.5-6.7 34.1 4.8 3.3 29.2-22.8 1-22.9zm-69.2-8.3.8 22.9 29.2 22.8 4.8-3.3-6.6-34.1z",className:"s3"}),/*#__PURE__*/e.jsx("path",{fill:"#c0ad9e",stroke:"#c0ad9e",className:"s1",d:"m180.3 262.3.3-9.3-2.5-2.2h-37.7l-2.3 2.2.2 9.3-31.5-14.9 11 9 22.3 15.5h38.3l22.4-15.5 11-9z"}),/*#__PURE__*/e.jsx("path",{fill:"#161616",stroke:"#161616",className:"s1",d:"m177.9 230.9-4.8-3.3h-27.7l-4.8 3.3-2.5 22.1 2.3-2.2h37.7l2.5 2.2z"}),/*#__PURE__*/e.jsx("path",{fill:"#763d16",stroke:"#763d16",className:"s1",d:"m278.3 114.2 8.5-40.8-12.7-37.9-96.2 71.4 37 31.3 52.3 15.3 11.6-13.5-5-3.6 8-7.3-6.2-4.8 8-6.1zM31.8 73.4l8.5 40.8-5.4 4 8 6.1-6.1 4.8 8 7.3-5 3.6 11.5 13.5 52.3-15.3 37-31.3-96.2-71.4z"}),/*#__PURE__*/e.jsx("path",{d:"m267.2 153.5-52.3-15.3 15.9 23.9-23.7 46 31.2-.4h46.5zm-163.6-15.3-52.3 15.3-17.4 54.2h46.4l31.1.4-23.6-46zm71 26.4 3.3-57.7 15.2-41.1h-67.5l15 41.1 3.5 57.7 1.2 18.2.1 44.8h27.7l.2-44.8z",className:"s3"})]}),Hn=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M46.5267 69.9229C42.0054 76.8509 34.4292 85.6182 24.348 85.6182C19.5824 85.6182 15 83.6563 15 75.1342C15 53.4305 44.6326 19.8327 72.1268 19.8327C87.768 19.8327 94 30.6846 94 43.0079C94 58.8258 83.7355 76.9122 73.5321 76.9122C70.2939 76.9122 68.7053 75.1342 68.7053 72.314C68.7053 71.5783 68.8275 70.7812 69.0719 69.9229C65.5893 75.8699 58.8685 81.3878 52.5754 81.3878C47.993 81.3878 45.6713 78.5063 45.6713 74.4598C45.6713 72.9884 45.9768 71.4556 46.5267 69.9229ZM83.6761 42.5794C83.6761 46.1704 81.5575 47.9658 79.1875 47.9658C76.7816 47.9658 74.6989 46.1704 74.6989 42.5794C74.6989 38.9885 76.7816 37.1931 79.1875 37.1931C81.5575 37.1931 83.6761 38.9885 83.6761 42.5794ZM70.2103 42.5795C70.2103 46.1704 68.0916 47.9658 65.7216 47.9658C63.3157 47.9658 61.233 46.1704 61.233 42.5795C61.233 38.9885 63.3157 37.1931 65.7216 37.1931C68.0916 37.1931 70.2103 38.9885 70.2103 42.5795Z",fill:"#FFFDF8"})]});function Kn(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var Zn=0;class Yn extends Wn{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:this.providerDetail.info.name,icon:this.providerDetail.info.icon,id:this.providerDetail.info.rdns}}disconnect(){console.warn(`Programmatic disconnect with ${this.providerDetail.info.name} is not yet supported.`)}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new o.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw En(e)}}constructor(e,t,r,n,a){super(a||"unknown",e,t,r),this.connectorType="injected",this.proxyProvider=new Un(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=n;let i=n.provider;this.proxyProvider.setWalletProvider(i)}}var Gn="__private_"+Zn+++"__walletBranding";class Jn extends Wn{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return Kn(this,Gn)[Gn]??{name:"Browser Extension",icon:qn,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new o.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw En(e)}}constructor(e,t,r,n,a){super(a??"unknown",e,t,r),Object.defineProperty(this,Gn,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new Un(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(n),"metamask"===a?Kn(this,Gn)[Gn]={name:"MetaMask",icon:Vn,id:"io.metamask"}:"phantom"===a&&(Kn(this,Gn)[Gn]={name:"Phantom",icon:Hn,id:"phantom"})}}class Qn extends Yn{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{n.isMobile||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new o.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw En(e)}}}const Xn=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","crypto.com_wallet_extension","crypto.com_onchain","binance","coinbase_wallet","coinbase_smart_wallet","metamask","trust","safe","rainbow","uniswap","zerion","argent","spot","omni","cryptocom","blockchain","safepal","bitkeep","zengo","1inch","binance","exodus","mew_wallet","alphawallet","keyring_pro","mathwallet","unstoppable","obvious","ambire","internet_money_wallet","coin98","abc_wallet","arculus_wallet","haha","cling_wallet","broearn","copiosa","burrito_wallet","enjin_wallet","plasma_wallet","avacus","bee","pitaka","pltwallet","minerva","kryptogo","prema","slingshot","kriptonio","timeless","secux","bitizen","blocto","okx_wallet","safemoon","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","privy","unknown","phantom","solflare","glow","backpack"],ea=Object.freeze({phantom:{client:"phantom",name:"Phantom",installLink:ke.isFirefox?"https://addons.mozilla.org/en-US/firefox/addon/phantom-app/":"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en",chainTypes:["ethereum","solana"],get isInstalled(){if("phantom"in window){let e=window;if(e?.phantom?.ethereum?.isPhantom&&e?.phantom?.ethereum?.chainId||e?.phantom?.solana?.isPhantom)return!0}return!1},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=ra({client:this.client,isSolana:t,connectOnly:r});return`${e?"phantom://":"https://phantom.app/ul/"}browse/${n}?ref=${n}`}},solflare:{client:"solflare",name:"Solflare",installLink:ke.isFirefox?"https://addons.mozilla.org/es/firefox/addon/solflare-wallet/":"https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic",chainTypes:["solana"],get isInstalled(){return"solflare"in window&&!!window?.solflare?.isSolflare},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=ra({client:this.client,isSolana:t,connectOnly:r});return`${e?"solflare://ul/v1/":"https://solflare.com/ul/v1/"}browse/${n}?ref=${n}`}},backpack:{client:"backpack",name:"Backpack",installLink:"https://chromewebstore.google.com/detail/backpack/aflkmfhebedbjioipglgcbcmnbpgliof",chainTypes:["ethereum","solana"],get isInstalled(){return!(!("backpack"in window)||!window?.backpack?.ethereum?.isBackpack&&!window?.backpack?.solana?.isBackpack)},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=ra({client:this.client,isSolana:t,connectOnly:r});return`${e?"backpack://ul/v1/":"https://backpack.com/ul/v1/"}browse/${n}?ref=${n}`}},okx_wallet:{client:"okx_wallet",name:"OKX Wallet",installLink:"https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",chainTypes:["solana"],get isInstalled(){return"okxwallet"in window&&!!window?.okxwallet?.isOkxWallet},getMobileRedirect({isSolana:e,connectOnly:t}){return"https://www.okx.com/download?deeplink="+encodeURIComponent("okx://wallet/dapp/url?dappUrl="+ra({client:this.client,isSolana:e,connectOnly:t}))}}});function ta({connectorType:e,walletClientType:t}){for(let r of Xn)if(e===r||t===r)return ea[r]}function ra({client:e,isSolana:t,connectOnly:r}){let n=new URL(window.location.href);return n.searchParams.set("privy_connector",t?"solana_adapter":"injected"),n.searchParams.set("privy_wallet_client",e),n.searchParams.set("privy_connect_only",String(r)),encodeURIComponent(n.href.replace(/\/$/g,""))}const na=()=>{let e=Mt.get(Ar);return e&&Array.isArray(e)&&e.map((e=>(e=>e&&"string"==typeof e.address&&"string"==typeof e.connectorType&&"string"==typeof e.walletClientType&&"number"==typeof e.connectedAt)(e))).every(Boolean)?e:[]};let aa=["phantom","glow","solflare","backpack","okx_wallet","walletconnect"];function ia(e){return"solana"===e.chainType}function oa(e){return"solana"===e.type}class sa extends Pn{get isInstalled(){return"Installed"===this.adapter.readyState}get wallet(){return this.adapter.wallet}buildConnectedWallet(e,t){let r,n,a,i;if("Installed"!==e.readyState||!e.publicKey)throw Error("Wallet is not connected.");return"signMessage"in e&&(r=async(...t)=>{if(!e.connected)throw Error("Wallet is not connected.");return await e.signMessage(t[0])}),"sendTransaction"in e&&(n=async(...t)=>await e.sendTransaction(t[0],t[1],t[2])),"signTransaction"in e&&(a=async t=>await e.signTransaction(t)),"signAllTransactions"in e&&(i=async t=>await e.signAllTransactions(t)),{type:"solana",address:e.publicKey.toBase58(),meta:t,imported:!1,connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:async()=>e.connected,disconnect:()=>{try{e.disconnect()}catch(e){console.error("Wallet does not support programmatic disconnect")}},getProvider:s.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'getProvider'`),signMessage:r??s.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'signMessage'`),sendTransaction:n??s.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'sendTransaction'`),signTransaction:a??s.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'signTransaction'`),signAllTransactions:i??s.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'signAllTransactions'`)}}async syncAccounts(){if("Installed"===this.adapter.readyState&&this.adapter.publicKey){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};this.wallets.find((e=>this.adapter.publicKey&&e.address===this.adapter.publicKey.toBase58()))||(this.wallets=[this.buildConnectedWallet(this.adapter,e)],this.emit("walletsUpdated"))}else this.wallets.length>0&&(this.wallets=[],this.emit("walletsUpdated"))}get walletBranding(){return{id:this.adapter.name,name:this.adapter.name,icon:this.adapter.icon}}async initialize(){this.subscribeListeners(),await this.syncAccounts(),this.shouldAttemptAutoConnect()&&await this.adapter.autoConnect().catch((()=>{})),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}async getConnectedWallet(){return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt))[0]||null}async isConnected(){return this.adapter.connected&&["Installed"].includes(this.adapter.readyState)}subscribeListeners(){this.adapter.addListener("disconnect",this.onDisconnect),this.adapter.addListener("connect",this.onConnect),this.adapter.addListener("error",this.onError),this.adapter.addListener("readyStateChange",this.onReadyStateChange)}unsubscribeListeners(){this.adapter.removeAllListeners()}shouldAttemptAutoConnect(){return!(!this.autoConnectEnabled||!aa.includes(this.walletClientType))&&("phantom"!==this.walletClientType||na().some((({walletClientType:e})=>"phantom"===e)))}constructor(e,t){super(function(e){return e.name.toLowerCase().split(" ").join("_")}(e)),this.chainType="solana",this.connectorType="solana_adapter",this.disconnect=()=>{this.adapter.disconnect().then((()=>this.onDisconnect())).catch((e=>console.error("Error disconnecting",e)))},this.promptConnection=async()=>{try{await this.adapter.connect()}catch(e){throw En(e)}},this.onDisconnect=()=>{this.syncAccounts()},this.onConnect=e=>{this.syncAccounts()},this.onError=e=>{this.syncAccounts()},this.onReadyStateChange=e=>{"Installed"!==e&&(this.connected=!1),this.syncAccounts()},this.adapter=e,this.autoConnectEnabled=t,this.wallets=[]}}class la extends sa{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the SolanaNullConnector")}constructor({id:e,name:t,icon:r}){super({name:t},!1),this.connectorType="null",this.proxyProvider=new Un(void 0,Ir),this.disconnect=async()=>{throw Error("disconnect called for an uninstalled wallet via the SolanaNullConnector")},this.promptConnection=async()=>{throw Error("promptConnection called for an uninstalled wallet via the SolanaNullConnector")},this.id=e,this.name=t,this.icon=r}}const ca=P.create((()=>({listings:[]}))),da=ca.setState,ua=e=>{let t;try{t=new URL(e).hostname}catch(e){return}return ca.getState().listings.find((({homepage:e})=>{let r;try{r=new URL(e).hostname}catch(e){return!1}return t.includes(r)}))},ha=e=>ca((({listings:t})=>t.find((({slug:t})=>pa(t)===pa(e)))));function pa(e){return"cryptocom"===e?"cryptocom-defi":"binance"===e?"binance-defi":e.replace(/[-_]wallet$/,"")}function ya({src:t,...r}){/*#__PURE__*/return e.jsx("img",{src:t,...r,style:{display:"none"}})}const ma={appearance:{landingHeader:"Log in or sign up",theme:"light",accentColor:"#676FFF",walletList:["detected_wallets","metamask","coinbase_wallet","rainbow","wallet_connect"]},walletConnectCloudProjectId:"34357d3c125c2bcf2ce2bc3309d98715",externalWallets:{coinbaseWallet:{connectionOptions:"all"}},embeddedWallets:{extendedCalldataDecoding:!1},captchaEnabled:!1,_render:{standalone:!1},fundingMethodConfig:{moonpay:{useSandbox:!1}}};let ga=new Set(["coinbase_wallet","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","universal_profile","bybit_wallet","ronin_wallet","haha_wallet","wallet_connect","detected_wallets","detected_solana_wallets","detected_ethereum_wallets","rabby_wallet","safe","solflare","backpack","binance"]),fa=e=>ga.has(e),wa=(e,t,r)=>r.indexOf(e)===t;const va=792703809,xa="11111111111111111111111111111111";function Ca(e){return e.includes("testnet")?"testnet":e.includes("devnet")?"devnet":"mainnet-beta"}function ba(e,t){return`https://explorer.solana.com/account/${e}?cluster=${t}`}let ja="#FFFFFF";function Ea(e,t){let r=Math.max(0,Math.min(1,e.toHsl().l+t));return Se.default({...e.toHsl(),l:r})}function ka({backgroundTheme:e,accentHex:t}){let r;switch(e){case"light":r=ja;break;case"dark":r="#1E1E1D";break;default:r=e}let n=Se.default(r),a=Se.default(t),i=Se.default("#51BA81"),o=Se.default("#FFB74D"),s=Se.default("#EC6351"),l=function(e){return e<.8&&e>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),e>.5?"light":"dark"}(n.getLuminance()),c=Ea(n,"light"===l?-.04:.11),d=Ea(n,"light"===l?-.08:.16),u=Ea(n,"light"===l?-.88:.87),h=Ea(n,"light"===l?-.7:.75),p=Ea(n,"light"===l?-.43:.45).desaturate("light"===l?60:20),y=Ea(n,"light"===l?-.08:.25).desaturate("light"===l?60:20),m=Ea(a,.15),g=Ea(a,.25),f=Ea(a,-.06),w=Ea(a,-.6),v=Ea(s,.3),x=Ea(o,.3),C=Se.default(a.getLuminance()>.5?"#040217":ja),b=Ea(i,-.16),j=Ea(i,.4);return{colorScheme:l,background:n.toHslString(),background2:c.toHslString(),background3:d.toHslString(),foreground:u.toHslString(),foreground2:h.toHslString(),foreground3:p.toHslString(),foreground4:y.toHslString(),accent:a.toHslString(),accentLight:m.toHslString(),accentLightest:g.toHslString(),accentDark:f.toHslString(),accentDarkest:w.toHslString(),foregroundAccent:C.toHslString(),success:i.toHslString(),successDark:b.toHslString(),successLight:j.toHslString(),error:s.toHslString(),errorLight:v.toHslString(),warn:o.toHslString(),warnLight:x.toHslString()}}function Ta(e,t,r,n){let a,o,s,l,c,d,u,h,p,y,m,g,f,w,v,x=r?console.warn:()=>{};t?.loginMethods?(a=t.loginMethods.includes("email"),o=t.loginMethods.includes("sms"),l=t.loginMethods.includes("wallet"),c=t.loginMethods.includes("google"),d=t.loginMethods.includes("twitter"),u=t.loginMethods.includes("discord"),p=t.loginMethods.includes("spotify"),y=t.loginMethods.includes("instagram"),h=t.loginMethods.includes("tiktok"),g=t.loginMethods.includes("github"),m=t.loginMethods.includes("linkedin"),f=t.loginMethods.includes("apple"),w=t.loginMethods.includes("farcaster"),v=t.loginMethods.includes("telegram"),s=t.loginMethods.includes("passkey")):(a=e.email_auth,o=e.sms_auth,l=e.wallet_auth||e.solana_wallet_auth,c=e.google_oauth,d=e.twitter_oauth,u=e.discord_oauth,g=e.github_oauth,p=e.spotify_oauth,y=e.instagram_oauth,h=e.tiktok_oauth,m=e.linkedin_oauth,f=e.apple_oauth,w=e.farcaster_auth,v=e.telegram_auth,s=e.passkey_auth),e.passkey_auth&&(s=!0),"undefined"!=typeof window&&"function"!=typeof window.PublicKeyCredential&&(s=!1);let C=[a,o].filter(Boolean),b=[c,d,u,g,p,y,h,m,f,w,v].filter(Boolean),j=[l].filter(Boolean),E=t?.loginMethods?.includes("passkey")??!1,k=e.passkeys_for_signup_enabled??!1,T=[s&&(k||E)].filter(Boolean);if(C.length+b.length+j.length+T.length===0)throw Error("You must enable at least one login method");let A=void 0!==t?.appearance?.showWalletLoginFirst?t?.appearance?.showWalletLoginFirst:e.show_wallet_login_first;A&&0===j.length?(x("You should only enable `showWalletLoginFirst` when `wallet` logins are also enabled. `showWalletLoginFirst` has been set to false"),A=!1):A||b.length+C.length!==0||(x("You should only disable `showWalletLoginFirst` when `email`, `sms`, or social logins are also enabled. `showWalletLoginFirst` has been set to true"),A=!0);let I=t?.externalWallets?.walletConnect?.enabled??!0;t?.loginMethods&&t.loginMethodsAndOrder&&x("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let S=(({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(fa).filter(wa):e?e.filter(fa).filter(wa):ma.appearance.walletList)({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),P=(({input:e})=>{if(!e||!e.primary[0])return;let t=[e.primary[0]],r=[];for(let r of(e.primary.length>4&&console.warn("You should not specify greater than 4 login methods in `loginMethodsAndOrder.primary`"),e.primary.slice(1)))t.includes(r)?console.warn(`Duplicated login method: ${r}`):t.push(r);for(let n of e.overflow??[])t.includes(n)||r.includes(n)?console.warn(`Duplicated login method: ${n}`):r.push(n);return{primary:t,overflow:r}})({input:t?.loginMethodsAndOrder}),_=t?.intl?.defaultCountry??"US",{chains:N,defaultChain:M}=function({supportedChains:e,defaultChainFromConfig:t}){let r;if(e){if(0===e.length)throw Error("`supportedChains` must contain at least one chain");r=i.dedupeSupportedChains(e)}else r=[...i.DEFAULT_SUPPORTED_CHAINS];let n=e?r[0]:i.mainnet,a=t??n;if(!r.find((e=>e.id===a.id)))throw Error("`defaultChain` must be included in `supportedChains`");return{chains:r,defaultChain:a}}({supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain}),W=!!t?.defaultChain,U=t?.customAuth?.getCustomAccessToken&&!1!==t?.customAuth?.enabled,O=t?.embeddedWallets?.requireUserPasswordOnCreate,F=t?.embeddedWallets?.createOnLogin,R=U?"all-users":e.embedded_wallet_config.ethereum.create_on_login,L=e.embedded_wallet_config.solana.create_on_login,D={"mainnet-beta":{rpcUrl:"https://api.mainnet-beta.solana.com",blockExplorerUrl:"https://explorer.solana.com"},testnet:{rpcUrl:"https://api.testnet.solana.com",blockExplorerUrl:"https://explorer.solana.com/?cluster=testnet"},devnet:{rpcUrl:"https://api.devnet.solana.com",blockExplorerUrl:"https://explorer.solana.com/?cluster=devnet"}};if(t?.solanaClusters)for(let e of t.solanaClusters){let{name:t,rpcUrl:r,blockExplorerUrl:n}=e;D[t]={rpcUrl:r??D[t].rpcUrl,blockExplorerUrl:n??D[t].blockExplorerUrl}}e.solana_wallet_auth&&!t?.externalWallets?.solana?.connectors&&console.warn("App configuration has Solana wallet login enabled, but no Solana wallet connectors have been passed to Privy. Make sure to pass Solana connectors to the `config.externalWallets.solana.connectors` field of the `PrivyProvider`");let B=e.telegram_auth_config?{botId:e.telegram_auth_config.bot_id,botName:e.telegram_auth_config.bot_name,linkEnabled:e.telegram_auth_config.link_enabled,seamlessAuthEnabled:e.telegram_auth_config.seamless_auth_enabled}:void 0,z=e.funding_config?{methods:e.funding_config.methods,options:e.funding_config.options,defaultRecommendedAmount:e.funding_config.default_recommended_amount,defaultRecommendedCurrency:e.funding_config.default_recommended_currency,promptFundingOnWalletCreation:e.funding_config.prompt_funding_on_wallet_creation,crossChainBridgingEnabled:e.funding_config.cross_chain_bridging_enabled}:void 0;return{id:e.id,name:e.name,allowlistConfig:{errorTitle:e.allowlist_config.error_title,errorDetail:e.allowlist_config.error_detail,errorCtaText:e.allowlist_config.cta_text,errorCtaLink:e.allowlist_config.cta_link},legacyWalletUiConfig:e.legacy_wallet_ui_config,appearance:{logo:t?.appearance?.logo??e.logo_url??void 0,landingHeader:t?.appearance?.landingHeader??ma.appearance.landingHeader,loginMessage:"string"==typeof t?.appearance?.loginMessage?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,footerLogo:t?.appearance?.footerLogo,palette:ka({backgroundTheme:t?.appearance?.theme??ma.appearance.theme,accentHex:t?.appearance?.accentColor??e.accent_color??ma.appearance.accentColor}),loginGroupPriority:A?"web3-first":"web2-first",hideDirectWeb2Inputs:!!t?.appearance?.hideDirectWeb2Inputs,walletList:S,walletChainType:t?.appearance?.walletChainType??(({evmWalletAuth:e,solanaWalletAuth:t})=>e&&t?"ethereum-and-solana":e?"ethereum-only":t?"solana-only":"ethereum-only")({evmWalletAuth:e.wallet_auth??!1,solanaWalletAuth:e.solana_wallet_auth??!1})},loginMethods:{wallet:l,email:a,sms:o,passkey:s,google:c,twitter:d,discord:u,github:g,spotify:p,instagram:y,tiktok:h,linkedin:m,apple:f,farcaster:w,telegram:v},disablePlusEmails:e.disable_plus_emails,loginMethodsAndOrder:P,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.terms_and_conditions_url,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacy_policy_url,requireUsersAcceptTerms:e.require_users_accept_terms??!1},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.wallet_connect_cloud_project_id??ma.walletConnectCloudProjectId,rpcConfig:{rpcUrls:{},rpcTimeouts:t?.externalWallets?.signatureRequestTimeouts??{}},chains:N,solanaClusters:D,defaultChain:M,intl:{defaultCountry:_},shouldEnforceDefaultChainOnConnect:W,captchaEnabled:e.captcha_enabled??ma.captchaEnabled,captchaSiteKey:e.captcha_site_key,externalWallets:{coinbaseWallet:{config:{appName:e.name,appLogoUrl:e.logo_url,preference:{options:t?.externalWallets?.coinbaseWallet?.connectionOptions??ma.externalWallets.coinbaseWallet.connectionOptions,...t?.externalWallets?.coinbaseWallet?.config?.preference},...t?.externalWallets?.coinbaseWallet?.config}},walletConnect:{enabled:I,appKit:t?.externalWallets?.walletConnect?.appKit},solana:{connectors:t?.externalWallets?.solana?.connectors},disableAllExternalWallets:t?.externalWallets?.disableAllExternalWallets??!1},embeddedWallets:{requireUserOwnedRecoveryOnCreate:O??(!U&&(e.embedded_wallet_config.require_user_owned_recovery_on_create??!1)),userOwnedRecoveryOptions:U?["user-passcode"]:e.embedded_wallet_config.user_owned_recovery_options,priceDisplay:t?.embeddedWallets?.priceDisplay??{primary:"fiat-currency",secondary:"native-token"},ethereum:{createOnLogin:F??t?.embeddedWallets?.ethereum?.createOnLogin??R},solana:{createOnLogin:t?.embeddedWallets?.solana?.createOnLogin??L},mode:e.embedded_wallet_config.mode,showWalletUIs:t?.embeddedWallets?.showWalletUIs??e.enforce_wallet_uis??!0,extendedCalldataDecoding:t?.embeddedWallets?.extendedCalldataDecoding??!1,transactionScanning:{enabled:t?.embeddedWallets?.transactionScanning?.enabled??!1,domain:t?.embeddedWallets?.transactionScanning?.domain??n??"https://auth.privy.io"}},mfa:{methods:e.mfa_methods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},passkeys:{shouldUnlinkOnUnenrollMfa:t?.passkeys?.shouldUnlinkOnUnenrollMfa,shouldUnenrollMfaOnUnlink:t?.passkeys?.shouldUnenrollMfaOnUnlink},customAuth:U?{enabled:!0,...t.customAuth}:void 0,loginConfig:{telegramAuthConfiguration:B,passkeysForSignupEnabled:e.passkeys_for_signup_enabled},headless:!!t?.headless,render:{standalone:t?._render?.standalone??ma._render.standalone},fundingConfig:z,fundingMethodConfig:{...t?.fundingMethodConfig??ma.fundingMethodConfig,moonpay:{...t?.fundingMethodConfig?.moonpay??ma.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??t?.fiatOnRamp?.useSandbox??ma.fundingMethodConfig.moonpay.useSandbox}},whatsAppEnabled:!!e.whatsapp_enabled}}const Aa={show_wallet_login_first:!0,allowlist_config:{error_title:null,error_detail:null,cta_text:null,cta_link:null},wallet_auth:!0,email_auth:!0,sms_auth:!1,google_oauth:!1,twitter_oauth:!1,discord_oauth:!1,github_oauth:!1,linkedin_oauth:!1,apple_oauth:!1,disable_plus_emails:!1,terms_and_conditions_url:null,privacy_policy_url:null,embedded_wallet_config:{create_on_login:"off",ethereum:{create_on_login:"off"},solana:{create_on_login:"off"},require_user_owned_recovery_on_create:!1,user_owned_recovery_options:["user-passcode"],mode:"user-controlled-server-wallets-only"},fiat_on_ramp_enabled:!1,captcha_enabled:!1,captcha_site_key:"",enforce_wallet_uis:!1,legacy_wallet_ui_config:!1,id:"",name:"",passkeys_for_signup_enabled:!1,whatsapp_enabled:!1},Ia=Ta(Aa,void 0,!1);let Sa=/*#__PURE__*/r.createContext({appConfig:Ia,isServerConfigLoaded:!1});const Pa=({children:t,client:n,legacyClient:a,clientConfig:i})=>{let[o,s]=r.useState(null),l=r.useMemo((()=>Ta(o??Aa,i,!!o,"undefined"!=typeof window?window.location.origin:void 0)),[o,i]);return r.useEffect((()=>{if(!o)return;let e=function(e){if(!e)return{};let{appearance:t,supportedChains:r,defaultChain:n,externalWallets:a,...i}=e;return{...i,...r?{supportedChains:r.map((e=>e.id))}:void 0,...n?{defaultChain:n.id}:void 0,...a?{walletConnect:a.walletConnect?{enabled:a.walletConnect.enabled}:void 0,coinbaseWallet:a.coinbaseWallet,solana:{connectors:a.solana?.connectors?.get().map((e=>e.walletClientType))}}:void 0}}(i),t=function(e,t=0){let r=3735928559^t,n=1103547991^t;for(let t,a=0;a<e.length;a++)r=Math.imul(r^(t=e.charCodeAt(a)),2654435761),n=Math.imul(n^t,1597334677);return r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),4294967296*(2097151&(n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909)))+(r>>>0)}(JSON.stringify(e)).toString(),r=`privy:sent:${o.id}:${t}`;localStorage.getItem(r)||(a.createAnalyticsEvent({eventName:"sdk_initialize",payload:e}),localStorage.setItem(r,"t"))}),[i,o]),r.useEffect((()=>{o||(async()=>{try{await n.initialize();let e=n.app.getConfig();e.custom_api_url&&a.updateApiUrl(e.custom_api_url),s(e)}catch(e){console.warn("Error generating app config: ",e)}})()}),[]),/*#__PURE__*/e.jsx(Sa.Provider,{value:{appConfig:l,isServerConfigLoaded:!!o},children:t})},_a=()=>{let{appConfig:e}=r.useContext(Sa);return e},Na=()=>{let{isServerConfigLoaded:e}=r.useContext(Sa);return e},Ma=/*#__PURE__*/r.createContext({app:Ia,currentScreen:null,lastScreen:null,navigate:s.notImplemented,navigateBack:s.notImplemented,resetNavigation:s.notImplemented,setModalData:s.notImplemented,onUserCloseViaDialogOrKeybindRef:void 0}),Wa=t=>{let n=_a(),a=t.authenticated,[i,o]=r.useState(t.initialScreen);r.useEffect((()=>{a||!t.initialScreen||t.initialScreen.isUnauthenticatedScreem||t.setInitialScreen(null)}),[a]);let s=r.useRef(null);r.useEffect((()=>{t.open||(s.current=null)}),[t.open]),r.useEffect((()=>{s.current=null}),[t.initialScreen]);let l={app:n,data:t.data,setModalData:t.setModalData,currentScreen:t.initialScreen,lastScreen:i,navigate:(e,r=!0)=>{t.setInitialScreen(e),r&&o(t.initialScreen)},navigateBack:()=>{t.setInitialScreen(i)},resetNavigation:()=>{t.setInitialScreen(null),o(null)},onUserCloseViaDialogOrKeybindRef:s};/*#__PURE__*/return e.jsxs(Ma.Provider,{value:l,children:[("string"==typeof n.appearance.logo||"img"===n.appearance.logo?.type)&&/*#__PURE__*/e.jsx(ya,{src:"string"==typeof n.appearance.logo?n.appearance.logo:n.appearance.logo.props.src}),t.children]})},Ua=()=>r.useContext(Ma);class Oa extends Wn{async initialize(){let e=await this.createProvider();this.provider=e,this.proxyProvider.setWalletProvider(e),this.subscribeListeners(),e.session&&(this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=ua(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown"),this.connected=!0,await this.syncAccounts()),this.initialized=!0,this.emit("initialized");let{createAppKit:t}=await import("@reown/appkit");this.modal??=t({projectId:this.walletConnectCloudProjectId,themeVariables:{"--w3m-z-index":1e6},networks:this.chains,includeWalletIds:Jt,allowUnsupportedChain:!0}),this.modal.subscribeState((e=>{e.open||this.walletProvider?.session||!this.onQrModalClosed||this.onQrModalClosed()}))}async connect(e){return e.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return!!this.walletProvider?.connected}get walletBranding(){let e=this.walletProvider?.session?.peer.metadata.icons?.[0];return{name:Vt(this.walletProvider?.session?.peer.metadata.name||"")||"WalletConnect",icon:"string"==typeof e?e:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAHdElNRQfoDAIVODUC+w+GAAAGsUlEQVRYw6WXbYwWVxXHf+fOLAtCXYS2QJdIaClipGCTknXXNqBQMVHbfmhItH4Aral+IAEaG03UxJgYKQJGTUxtDWjaxDSNtcZqIGDwpRuW1oYiVqpdpZSlpC3qysu+PHPP3w/3mXnmeXZbPzjJZO7cefn/z/mfe865xlscq3dGDIguGiHLaMQVLja4s87FShcLo5jtApdddnHexUmHIy475JmdUkPRAQMu7gzT4ljnxJpdk0QPmMFkyAKN2OfOFpc2uuh1J3MZDrjAvXmVEQUuoosRxw642FcEG7IoDxiFxNiu8NYE+vcUYIFYRKKs113bXWx2Z34CoQZsVHOiCZ7mopdzdsFhv8NexEgRDHMxUSNREbh1bwNZwBsFblmfu/a4a6AEENYO5i3AOoEWeEUCF4MOOxBDMQAOk99OJALA2u80sBCwWGBZWG/yRwMaCAbBIAsQTJT3gea1OWfNeaPzvjoHEI85rA8ObtB1v7cIdJkIHgkh9AXpocy0LJjIKvB2wPpZB0v3wkrw5jdNEjeYeMhFX3BAyfn2ke9NUrgB9LrrcZcGJFCld4fWNddXbvbWfWzGR6xJFZsBGh0cBh3bBIxIEGTQ3W0h4NuDaSAzyAxCmGq11Vzf5uaa1aG8p+WFtrEYQGwvjICJkAEqvC+YNmcmMlMNvEaCdrcbyUvQAWDTjVuESHObM6cPGWHmzDwLaEtmzG9Z3qF1zUpXmuuZBb1z4bqeNC6f0WE1NtUTwHzEloiy3BvFisy0sYoLlQtT6XW15md2Qf9SY+2Ngfdca/TMSm/9ewz+/Boc/It45h/i4kSTsKw90SQJsPTvjSZbkWemDW7qTRZ0JEYJWSKxZJ7xmf6M224MzMzbX1s8F1YugjtvMg6eErt/4/z1jUrz1rXUKxnZC2zIg2mdBTK1mFUOKC1fOt/48kdzVixIz86Nij+eEacvpJWyZJ5xy7th8VzjjpuMJfMCW58QL73ekXPVlhsyE+vyzFiplJyauEIyrGIquruMq7qTxk+dcB495rzyTzFepCUWLIFv/kBg081Gd55WUk1IDGFTS89K++TDYxddzKnWcbluHd450xgdh7EGrOo1rr868PMTzqWJRGZ2d8oB/xpL33Xnxl2rjeNn4blXRXduzJ4B5y+28kWscAwXl+yeR654FFZPHoUb710YuPeDOUdPO48di1xptKpeEeHqOcYXNwQKGd88EDk3mqxtxPSfGRlsXRtYt8z4ytPOH/7eqpg1Aso7fYKgK4NPrMpYvsC4/poMA34yVJIQC3sCD9yecdsNyaV5yPj6ryJnR1PAvSNP4J+/1cgDfLbfePaMGGtM7Qdyl12WmKOmXgKKAp54vmBRTxfLrjE+tSYjBPjRM5FrrzIeuD2jf2lLzw8vN4JlfPVp581LsO1DgXv7jSzAiXPw/d+JiYLpjsu26Yfjf5O0rF5WoxsNT9G/bX0XKxakmPjlSee6HlizJJXSX7/oRDc+vjKR+f2wODcKd78/gR8/C9uedF44myJxmhh4OY/ipMQyqaWxmjn95TfEroMFOzbkvG+RceeqViPx1Aln1yEnOow1AnffHCpJAJ5/Vex4UvzptZRdY/O/1dJIS/NkcNmR6MTYah6qzseA4TfFtw4UvHBW1bc/O+7sPhwZHYf/jMODh5yfPudVbXj2TAJ/8XxrOZagNamj4Ei2/GNfuyRxh8t6BG2l15up+MIVODEiFr8rcPS0+O6RBF6mrrEGHHtFzOo2Lo7Dl37hvPQ6mNV6R9JYKgnYWcE37K5HlE2OT/5A0udaPUBHH+BQOMzuNsYLuDyZflTW+fTcmJFDHhJhaZqewMuewXDxcDR9IYyPN6Jj+6K4MF2vV8qBtZJScqVRNi6lpGONVJis5mpKi1WbgwsY+zIsBpcR8mzIZfuTRVZrtdu9odrptR/Xx5XONXJqBmCN0P6YMUQq9WJiwt0Je102WHdbpxSqydMObBWYdwDWLVcqcIMYe3NPjg0Ht84od0Ajju1w2XCr9e6QoqM9V23ZtnmI6cfAMMb9AY0YEHdb6oobEh4y3H3Ize6LsmGvN5IdUnhttdQ9UVrfLk/ljWEZ9wXsqAdQk1EA+O22GcgdZTke/bAs3OPY4HSdcB20HhvVtTMu0jmI8ekAhz2IICj2hKpNqI60NcuIRUHEej1quzubXa2tmZhenrfZmv3YYQ9ipDAIgvHptmblccuDjdRcmjFpWbDi/9ycZjZkRbk5jYztai/AUwiUx+qdEQB/m+25i9lxyvbcjrg45Lmd0uT/3p7/Fw6ODf+WO019AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDI0LTEyLTAyVDIxOjU2OjQ4KzAwOjAwMVpslgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyNC0xMi0wMlQyMTo1Njo0OCswMDowMEAH1CoAAAAodEVYdGRhdGU6dGltZXN0YW1wADIwMjQtMTItMDJUMjE6NTY6NTMrMDA6MDDZv6GRAAAAAElFTkSuQmCC",id:this.walletProvider?.session?.peer.metadata.name.toLowerCase()||"wallet_connect_v2"}}async resetConnection(e){this.walletProvider&&this.walletProvider.connected&&(await this.walletProvider.disconnect(),this.walletProvider.signer.session=void 0,this.walletClientType=e,this.redirectUri=void 0,this.fallbackUniversalRedirectUri=void 0,function(){try{localStorage.removeItem(Xt)}catch{}}(),this.onDisconnect())}async promptConnection(){if(this.provider)return new Promise(((e,t)=>{this.onQrModalClosed=()=>{t(new jn)},(async()=>{let t="",r=await Promise.race([this.walletProvider?.enable(),this.proxyProvider.walletTimeout()]);if(r?.length&&(t=r[0]),!t||""===t)throw new o.PrivyConnectorError("Unable to retrieve address");this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=ua(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown",this.proxyProvider.rpcTimeoutDuration=_n(this.rpcConfig,this.walletClientType)),this.connected=!0,await this.syncAccounts(r),e()})().catch((e=>{t(e?En(e):new o.PrivyConnectorError("Unknown error during connection"))})).finally((()=>this.modal?.close()))}))}disconnect(){this.walletProvider?.disconnect().then((()=>this.onDisconnect())).catch((()=>console.warn("Unable to disconnect Wallet Connect provider")))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(e){this.proxyProvider.setWalletProvider(e)}async createProvider(){let e={};for(let t of this.chains){let r=Yt(t.id,this.chains,this.rpcConfig,this.privyAppId);r&&(e[t.id]=r)}let t=this.shouldEnforceDefaultChainOnConnect?[this.defaultChain.id]:[],r=this.chains.map((e=>e.id)),a=await S.EthereumProvider.init({projectId:this.walletConnectCloudProjectId,chains:t,optionalChains:r,optionalEvents:S.OPTIONAL_EVENTS,optionalMethods:S.OPTIONAL_METHODS,rpcMap:e,showQrModal:!1,metadata:{description:this.privyAppName,name:this.privyAppName,url:window.location.toString(),icons:[]}});return a.on("display_uri",(e=>{if(a.signer.abortPairingAttempt(),this.walletEntry){let{redirect:t,href:r}=function(e,t){let r=Qt(t);if(r.deepLink)return tr(r.deepLink,e);if(r.universalLink)return rr(r.universalLink,e);throw new o.PrivyClientError(`Unsupported wallet ${t.id}`)}(e,this.walletEntry);(function({href:e,name:t}){try{localStorage.setItem(Xt,JSON.stringify({href:e,name:t}))}catch{}})({href:r,name:this.walletEntry.metadata?.shortName||this.walletEntry.name}),this.redirectUri=t;let a=function(e,t){let r=Qt(t);if(r.universalLink)return rr(r.universalLink,e)}(e,this.walletEntry);a?.redirect&&(this.fallbackUniversalRedirectUri=a.redirect),n.isMobile?(nr(t,"_self"),this.showPrivyQrModal?.({native:t,universal:this.fallbackUniversalRedirectUri})):this.showPrivyQrModal?this.showPrivyQrModal?.({native:t,universal:this.fallbackUniversalRedirectUri}):this.modal?.open({uri:e})}else this.modal?.open({uri:e})})),a.on("connect",(()=>{this.modal?.close(),a.session?.peer.metadata.url&&(this.walletEntry=ua(a.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown")})),a}async enableProvider(){return this.walletProvider?.connected?Promise.resolve(this.walletProvider.accounts):await(this.walletProvider?.enable())}setWalletEntry(e,t){this.walletEntry=e,this.showPrivyQrModal=t}constructor({walletConnectCloudProjectId:e,rpcConfig:t,chains:r,defaultChain:n,shouldEnforceDefaultChainOnConnect:a,privyAppId:i,privyAppName:o,walletClientType:s,appKit:l}){super(s||"unknown",r,n,t),this.connectorType="wallet_connect_v2",this.privyAppId=i,this.privyAppName=o,this.walletConnectCloudProjectId=e,this.rpcConfig=t,this.shouldEnforceDefaultChainOnConnect=a,this.proxyProvider=new Un(void 0,this.rpcTimeoutDuration),this.modal=l,s&&(this.walletEntry=(e=>ca.getState().listings.find((({slug:t})=>pa(t)===pa(e))))(s),this.walletClientType=s)}}class Fa extends Ie.default{get wallets(){let e=new Set,t=this.walletConnectors.flatMap((e=>e.wallets)).sort(((e,t)=>e.connectedAt&&t.connectedAt?t.connectedAt-e.connectedAt:0)).filter((t=>{let r=`${t.address}${t.walletClientType}${t.connectorType}${t.meta.id}`;return!e.has(r)&&(e.add(r),!0)})),r=t.findIndex((e=>e.address===(this.activeWallet?this.activeWallet:"unknown")));return r>=0&&t.unshift(t.splice(r,1)[0]),t}async initialize(e){if(this.initialized&&!e||(e&&this.removeAllConnectors(),Mt.get(Tr)&&(Mt.getKeys().forEach((e=>{e.startsWith("walletconnect")&&Mt.del(e)})),Mt.del(Tr)),this.externalWalletConfig.disableAllExternalWallets))return;let t=Kt({store:this.store,walletList:this.walletList,externalWalletConfig:this.externalWalletConfig,walletChainType:this.walletChainType}).then((e=>{e.forEach((({type:e,eip6963InjectedProvider:t,legacyInjectedProvider:r})=>{this.createEthereumWalletConnector({connectorType:"injected",walletClientType:e,providers:{eip6963InjectedProvider:t,legacyInjectedProvider:r}})}))}));for(let e of(this.walletList.includes("coinbase_wallet")&&this.createEthereumWalletConnector({connectorType:"coinbase_wallet",walletClientType:"coinbase_wallet"}),Object.values(ea)))!e.isInstalled&&this.walletList.includes(e.client)&&(["ethereum-only","ethereum-and-solana"].includes(this.walletChainType)&&e.chainTypes.includes("ethereum")&&this.createEthereumWalletConnector({connectorType:"null",walletClientType:e.client,walletConfig:e}),["ethereum-and-solana","solana-only"].includes(this.walletChainType)&&e.chainTypes.includes("solana")&&this.addSolanaWalletConnector(new la({id:e.client,name:e.name})));this.externalWalletConfig.walletConnect.enabled&&this.createEthereumWalletConnector({connectorType:"wallet_connect_v2",walletClientType:"unknown"}),this.externalWalletConfig.solana.connectors?.get().forEach(this.addSolanaWalletConnector),this.externalWalletConfig.solana.connectors?._setOnConnectorsUpdated?.((e=>{e?.forEach(this.addSolanaWalletConnector)})),await t,this.initialized=!0}findWalletConnector(e,t){return"wallet_connect_v2"===e?this.walletConnectors.filter(Mn).find((t=>t.connectorType===e))??null:this.walletConnectors.filter(Mn).find((r=>r.connectorType===e&&r.walletClientType===t))??null}findSolanaWalletConnector(e){return this.walletConnectors.filter(ia).find((t=>"unknown"===t.walletClientType?t.walletBranding.id===e:t.walletClientType===e))??null}findEmbeddedWalletConnectors(){return this.walletConnectors.filter((e=>"embedded"===e.connectorType))}onInitialized(e){e.wallets.forEach((e=>{let t=this.storedConnections.find((t=>t.address===e.address&&t.connectorType===e.connectorType&&("solana"===e.type&&"unknown"===t.walletClientType&&"unknown"===e.walletClientType?e.meta.id===t.id:t.walletClientType===e.walletClientType)));t&&(e.connectedAt=t.connectedAt)})),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(e){e.initialized&&this.emit("walletsUpdated")}addEmbeddedWalletConnectors({walletProxy:e,user:t,embeddedWallets:r,defaultChain:n,appId:a,privyClient:i}){let{entropyId:o,entropyIdVerifier:s}=xn(t);for(let t of r){let r=this.findEmbeddedWalletConnectors().find((e=>e.walletIndex===t.walletIndex));if(r&&Mn(r))r.proxyProvider.walletProxy=e;else{let r=new Ln({provider:new zn({walletProxy:e,address:t.address,entropyId:o,entropyIdVerifier:s,rpcConfig:this.rpcConfig,chains:this.chains,appId:a,chainId:n.id,walletIndex:t.walletIndex,privyClient:i,walletAccount:t}),chains:this.chains,defaultChain:n,rpcConfig:this.rpcConfig,imported:!1,walletIndex:t.walletIndex});this.addWalletConnector(r)}}}addImportedWalletConnector(e,t,r,n){let a=this.findWalletConnector("embedded_imported","privy");if(a&&Mn(a))a.proxyProvider.walletProxy=e;else{let a=new Ln({provider:new zn({walletProxy:e,address:t,entropyId:t,entropyIdVerifier:"ethereum-address-verifier",walletIndex:0,rpcConfig:this.rpcConfig,chains:this.chains,appId:n,chainId:r.id}),chains:this.chains,walletIndex:0,defaultChain:r,rpcConfig:this.rpcConfig,imported:!0});this.addWalletConnector(a)}}removeEmbeddedWalletConnectors(){this.walletConnectors=this.walletConnectors.filter((e=>"embedded"!==e.connectorType)),this.storedConnections=na(),this.emit("walletsUpdated")}removeImportedWalletConnector(){let e=this.findWalletConnector("embedded_imported","privy");if(e){let t=this.walletConnectors.indexOf(e);this.walletConnectors.splice(t,1),this.storedConnections=na(),this.emit("walletsUpdated")}}async createEthereumWalletConnector({connectorType:e,walletClientType:t,providers:r,walletConfig:n}){let a=this.findWalletConnector(e,t);if(a&&Mn(a))return a instanceof Oa&&a.resetConnection(t),a;let i=(()=>"injected"!==e?"coinbase_wallet"===e?new Fn(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig.coinbaseWallet.config):"null"!==e?new Oa({walletConnectCloudProjectId:this.walletConnectCloudProjectId,rpcConfig:this.rpcConfig,chains:this.chains,defaultChain:this.defaultChain,shouldEnforceDefaultChainOnConnect:this.shouldEnforceDefaultChainOnConnect,privyAppId:this.privyAppId,privyAppName:this.privyAppName,walletClientType:t,appKit:this.appKit}):n?new $n({id:n.client,name:n.name,defaultChain:this.defaultChain,walletClientType:n.client}):null:"metamask"===t&&r?.eip6963InjectedProvider?new Qn(this.chains,this.defaultChain,this.rpcConfig,r?.eip6963InjectedProvider,"metamask"):"metamask"===t&&r?.legacyInjectedProvider?new Jn(this.chains,this.defaultChain,this.rpcConfig,r?.legacyInjectedProvider,"metamask"):"phantom"===t&&r?.legacyInjectedProvider?new Jn(this.chains,this.defaultChain,this.rpcConfig,r?.legacyInjectedProvider,"phantom"):r?.legacyInjectedProvider&&"unknown_browser_extension"===t?new Jn(this.chains,this.defaultChain,this.rpcConfig,r?.legacyInjectedProvider):r?.eip6963InjectedProvider?new Yn(this.chains,this.defaultChain,this.rpcConfig,r?.eip6963InjectedProvider,t):void 0)();return i&&this.addWalletConnector(i),i||null}addWalletConnector(e){this.walletConnectors.push(e),e.on("initialized",(()=>this.onInitialized(e))),e.on("walletsUpdated",(()=>this.onWalletsUpdated(e))),e.initialize().catch((e=>{console.debug("Failed to initialize connector",e)}))}async activeWalletSign(e){let t=this.wallets,r=t.length>0?t[0]:null;return r&&In(r)?r.sign(e):null}setActiveWallet(e){this.activeWallet=a.getAddress(e),this.emit("walletsUpdated")}setWalletList(e){this.walletList=e,this.initialized&&this.initialize(!0).catch(console.error)}removeAllConnectors(){for(let e of this.walletConnectors)e.removeAllListeners();this.walletConnectors=[]}constructor(e,t,r,n,a,i,o,s,l,c,d,u){super(),this.addSolanaWalletConnector=async e=>{let t=this.findSolanaWalletConnector(e.walletClientType);if(!t||"null"===t.connectorType){if("null"===t?.connectorType){let e=this.walletConnectors.indexOf(t);this.walletConnectors.splice(e,1)}this.addWalletConnector(e)}},this.getEthereumProvider=()=>{let e=this.wallets[0],t=this.walletConnectors.find((t=>t.wallets.find((t=>t.address===e?.address))));return e&&t?t.proxyProvider:new Un},this.privyAppId=e,this.walletConnectCloudProjectId=t,this.rpcConfig=r,this.chains=n,this.defaultChain=a,this.walletConnectors=[],this.initialized=!1,this.store=i,this.walletList=o,this.shouldEnforceDefaultChainOnConnect=s,this.externalWalletConfig=l,this.privyAppName=c,this.walletChainType=d||"ethereum-only",this.appKit=u,this.storedConnections=na()}}let Ra=[o.sessionsRefreshPath,o.sessionsLogoutPath,o.analyticsEventsPath];class La{async get(e,t){try{return await this.baseFetch(e,t)}catch(e){throw o.formatApiError(e)}}async post(e,t,r){try{return await this.baseFetch(e,{method:"POST",...t?{body:t}:{},...r})}catch(e){throw o.formatApiError(e)}}async delete(e,t){try{return await this.baseFetch(e,{method:"DELETE",...t})}catch(e){throw o.formatApiError(e)}}constructor({appId:e,appClientId:t,client:r,defaults:n}){this.appId=e,this.appClientId=t,this.clientAnalyticsId=r.clientAnalyticsId,this.sdkVersion=dr,this.client=r,this.defaults=n,this.fallbackApiUrl=r.fallbackApiUrl,this.baseFetch=ce.ofetch.create({baseURL:this.defaults.baseURL,timeout:this.defaults.timeout,retry:3,retryDelay:500,retryStatusCodes:[408,409,425,500,502,503,504],credentials:"include",onRequest:async({request:e,options:t})=>{let r=new Headers(t.headers);r.set("privy-app-id",this.appId),this.appClientId&&r.set("privy-client-id",this.appClientId),r.set("privy-ca-id",this.clientAnalyticsId||""),r.set("privy-client",`react-auth:${this.sdkVersion}`);let n=Ra.includes(e.toString());if(!r.has("authorization")){let e=await this.client.getAccessToken({disableAutoRefresh:n});null!==e&&r.set("authorization",`Bearer ${e}`)}t.headers=r,t.retryDelay&&"number"==typeof t.retryDelay&&(t.retryDelay=3*t.retryDelay)},onRequestError:({error:e})=>{if(e instanceof DOMException&&"AbortError"===e.name)throw new o.PrivyTimeoutError}})}}let Da=/paymaster\.biconomy\.io\/api/i,Ba={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}};const za=(e,t)=>e&&Da.test(e)?Ba:t&&t.policy_id?{policyId:t.policy_id}:void 0;class $a{async authenticate(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(o.customJwtAccountAuthenticatePath,{token:this.meta.token})}catch(e){throw o.formatApiError(e)}}async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(o.customJwtAccountLinkPath,{token:this.meta.token})}catch(e){throw o.formatApiError(e)}}constructor(e){this.meta={token:e}}}class qa{getOrCreateGuestCredential(e){let t=vr(e);if(Nt()){if(Mt.get(t))return Mt.get(t);{let e=d.base64url.encode(Wr(32));return Mt.put(t,e),e}}return d.base64url.encode(Wr(32))}async authenticate(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(o.guestAccountAuthenticatePath,{guest_credential:this.meta.guestCredential})}catch(e){throw o.formatApiError(e)}}async link(){throw Error("Linking is not supported for the guest flow")}constructor(e){this.meta={guestCredential:this.getOrCreateGuestCredential(e)}}}function Va(){return!(n.isSafari&&window.location.origin.startsWith("http://localhost"))}const Ha=P.create((()=>({identityToken:null})));var Ka,Za=((Ka={}).PRIVY="privy_access_token",Ka.CUSTOMER="customer_access_token",Ka);class Ya{get token(){return this.privyAccessToken||this.customerAccessToken}getToken(e){return"privy_access_token"===e?this.privyAccessToken:this.customerAccessToken}get customerAccessToken(){return this._getToken(ur)}get privyAccessToken(){return this._getToken(yr)}_getToken(e){try{let t=Mt.get(e);return"string"==typeof t?fn.throwIfNotWellFormedJwt(t):null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=Mt.get(pr);return"string"==typeof e?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}getProviderAccessToken(e){try{let t=Mt.get(xr(e));if("string"!=typeof t)return null;{let r=new fn(t);return r.isExpired()?(Mt.del(xr(e)),null):r.value}}catch(e){return console.error(e),null}}get mightHaveServerCookies(){try{let e=At.default.get(fr);return void 0!==e&&e.length>0}catch(e){console.error(e)}return!1}hasRefreshCredentials(e="privy_access_token"){let t="string"==typeof this.getToken(e),r="string"==typeof this.refreshToken&&"deprecated"!==this.refreshToken;return this.mightHaveServerCookies||t&&r}hasActiveAccessToken(e){let t=fn.parse(this.getToken(e));return null!==t&&!t.isExpired(30)}authenticate(e){return this.authenticateOnce.execute(e)}link(e){return this.linkOnce.execute(e)}refresh(){return this.refreshOnce.execute()}destroy(){return this.destroyOnce.execute()}storeProviderAccessToken(e,t){"string"==typeof t?Mt.put(xr(e),t):Mt.del(xr(e))}updateIdentityToken(e){"string"==typeof e?this.storeIdentityToken(e):this.clearIdentityToken()}async _authenticate(e){try{let t=await e.authenticate(),{user:r,is_new_user:n,oauth_tokens:a}=t;this.handleTokenResponse(t);let i=a?{provider:a.provider,accessToken:a.access_token,accessTokenExpiresInSeconds:a.access_token_expires_in_seconds,refreshToken:a.refresh_token,refreshTokenExpiresInSeconds:a.refresh_token_expires_in_seconds,scopes:a.scopes}:void 0;return this._trackAuthenticateEvents(e,n),{user:u.convertUserResponseToUser(r),isNewUser:n,oAuthTokens:i}}catch(e){throw console.warn("Error authenticating session"),o.formatPrivyError(e)}}_trackAuthenticateEvents(e,t){let r=function(e){return e instanceof St?"email":e instanceof sn?"sms":e instanceof rn?"siwe":e instanceof qa?"guest":e instanceof $a?"custom_auth":e instanceof Rr?e.meta.provider:null}(e);r&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:r,isNewUser:t}}),"siwe"===r&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:e.meta.connectorType,walletClientType:e.meta.walletClientType}})}async _link(e){try{let t=await e.link(),r=t.oauth_tokens,n=r?{provider:r.provider,accessToken:r.access_token,accessTokenExpiresInSeconds:r.access_token_expires_in_seconds,refreshToken:r.refresh_token,refreshTokenExpiresInSeconds:r.refresh_token_expires_in_seconds,scopes:r.scopes}:void 0;return{user:u.convertUserResponseToUser(t),oAuthTokens:n}}catch(e){throw console.warn("Error linking account"),o.formatPrivyError(e)}}async _refresh(){if(!this.api)throw new o.PrivyClientError("Session has no API instance");if(!this.client)throw new o.PrivyClientError("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let e=this.token,t=this.refreshToken;if(this.client.useServerCookies&&!this.mightHaveServerCookies&&this.token&&window.location.origin===this.client.apiUrl)return this.destroyLocalState(),null;try{let r;if(!(e&&t||this.mightHaveServerCookies))return null;{let n={};e&&(n.authorization=`Bearer ${e}`),r=await this.api.post(o.sessionsRefreshPath,t?{refresh_token:t}:{},{headers:n})}return this.handleTokenResponse(r),u.convertUserResponseToUser(r.user)}catch(e){if(e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.MISSING_OR_INVALID_TOKEN)return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw o.formatPrivyError(e)}}handleTokenResponse(e){e.session_update_action&&"set"!==e.session_update_action?"clear"===e.session_update_action?this.destroyLocalState():"ignore"===e.session_update_action&&(e.token&&(this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token)),e.identity_token&&this.storeIdentityToken(e.identity_token)):this._storeAllTokens(e)}_storeAllTokens(e){this.storeRefreshToken(e.refresh_token),this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token),e.identity_token&&this.storeIdentityToken(e.identity_token)}async _destroy(){try{await(this.api?.post(o.sessionsLogoutPath,{refresh_token:this.refreshToken}))}catch(e){console.warn("Error destroying session")}this.destroyLocalState()}destroyLocalState(){this.storeRefreshToken(null),this.storeCustomerAccessToken(null),this.storePrivyAccessToken(null),this.clearIdentityToken()}storeCustomerAccessToken(e){if("string"==typeof e){let t=Mt.get(ur);if(Mt.put(ur,e),!this.client?.useServerCookies){let t=fn.parse(e)?.expiration;At.default.set(hr,e,{sameSite:"Strict",secure:Va(),expires:t?new Date(1e3*t):void 0})}t!==e&&this.client?.onStoreCustomerAccessToken?.(e)}else Mt.del(ur),At.default.remove(hr),this.client?.onDeleteCustomerAccessToken?.()}storeRefreshToken(e){"string"==typeof e?(Mt.put(pr,e),this.client?.useServerCookies||At.default.set(fr,"t",{sameSite:"Strict",secure:Va(),expires:30})):(Mt.del(pr),At.default.remove("privy-refresh-token"),At.default.remove(fr))}storePrivyAccessToken(e){"string"==typeof e?Mt.put(yr,e):Mt.del(yr)}storeIdentityToken(e){if(Ha.setState({identityToken:e}),this.client?.useServerCookies)return;Mt.put(mr,e);let t=fn.parse(e)?.expiration;At.default.set(gr,e,{sameSite:"Strict",secure:Va(),expires:t?new Date(1e3*t):void 0})}clearIdentityToken(){Mt.del(mr),Ha.setState({identityToken:null}),At.default.remove(gr)}constructor(){this.authenticateOnce=new ar((async e=>this._authenticate(e))),this.linkOnce=new ar((async e=>this._link(e))),this.refreshOnce=new ar(this._refresh.bind(this)),this.destroyOnce=new ar(this._destroy.bind(this))}}let Ga;var Ja=0,Qa="__private_"+Ja+++"__getOrGenerateClientAnalyticsId";class Xa{getAppId(){return this.appId}initializeConnectorManager({walletConnectCloudProjectId:e,rpcConfig:t,chains:r,defaultChain:n,store:a,walletList:i,shouldEnforceDefaultChainOnConnect:o,externalWalletConfig:s,appName:l,walletChainType:c,appKit:d}){this.connectors||(this.connectors=new Fa(this.appId,e,t,r,n,a,i,o,s,l,c,d))}generateApi(){let e=new La({appId:this.appId,appClientId:this.appClientId,client:this,defaults:{baseURL:this.apiUrl,timeout:this.timeout}});return this.session.api=e,e}updateApiUrl(e){this.apiUrl=e||this.fallbackApiUrl,this.api=this.generateApi(),e&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new o.PrivyClientError("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new o.PrivyClientError("No auth flow in progress.");let{oAuthTokens:e}=await this.session.link(this.authFlow);return{user:await this.getAuthenticatedUser(),oAuthTokens:e}}storeProviderAccessToken(e,t){this.session.storeProviderAccessToken(e,t)}getProviderAccessToken(e){return this.session.getProviderAccessToken(e)}async logout(){await this.session.destroy(),this.authFlow=void 0}clearProviderAcccessTokens(e){e.linkedAccounts.filter((e=>"cross_app"===e.type)).forEach((e=>{this.storeProviderAccessToken(e.providerApp.id,null)}))}startAuthFlow(e){return e.api=this.api,this.authFlow=e,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(o.mfaPasswordlessSmsInitPath,{action:"verify"})}catch(e){throw o.formatApiError(e)}}async initMfaPasskeyVerification(){try{return(e=>({rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}))((await this.api.post(o.mfaPasskeyInitPath,{})).options)}catch(e){throw o.formatApiError(e)}}async getCrossAppProviderDetails(e){try{return this._cachedProviderAppDetails[e]||(this._cachedProviderAppDetails[e]=await this.api.get(`/api/v1/apps/${e}/cross-app/details`)),this._cachedProviderAppDetails[e]}catch(e){console.error("Error fetching cross app provider details",e)}}async acceptTerms(){try{let e=await this.api.post(o.acceptTermsPath,{});return u.convertUserResponseToUser(e)}catch(e){throw o.formatPrivyError(e)}}async unlinkEmail(e){try{let t=await this.api.post(o.unlinkEmailPath,{address:e});return await this.getAuthenticatedUser()??u.convertUserResponseToUser(t)}catch(e){throw o.formatPrivyError(e)}}async unlinkPhone(e){try{let t=await this.api.post(o.unlinkPhonePath,{phoneNumber:e});return await this.getAuthenticatedUser()??u.convertUserResponseToUser(t)}catch(e){throw o.formatPrivyError(e)}}async unlinkEthereumWallet(e){try{let t=await this.api.post(o.unlinkWalletPath,{address:e});return await this.getAuthenticatedUser()??u.convertUserResponseToUser(t)}catch(e){throw o.formatPrivyError(e)}}async unlinkSolanaWallet(e){try{let t=await this.api.post(o.siwsUnlinkWalletPath,{address:e});return await this.getAuthenticatedUser()??u.convertUserResponseToUser(t)}catch(e){throw o.formatPrivyError(e)}}async unlinkOAuth(e,t){try{let r=await this.api.post(o.unlinkOAuthPath,{provider:e,subject:t});return await this.getAuthenticatedUser()??u.convertUserResponseToUser(r)}catch(e){throw o.formatPrivyError(e)}}async unlinkFarcaster(e){try{let t=await this.api.post(o.unlinkFarcasterPath,{fid:e});return await this.getAuthenticatedUser()??u.convertUserResponseToUser(t)}catch(e){throw o.formatPrivyError(e)}}async unlinkTelegram(e){try{let t=await this.api.post(o.telegramAccountUnlinkPath,{telegram_user_id:e});return await this.getAuthenticatedUser()??u.convertUserResponseToUser(t)}catch(e){throw o.formatPrivyError(e)}}async revokeDelegatedWallet(){try{await this.api.post(o.delegatedActionsRevokePath,{})}catch(e){throw o.formatPrivyError(e)}}async createAnalyticsEvent({eventName:e,payload:t,timestamp:r,options:n}){if("undefined"!=typeof window)try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(o.analyticsEventsPath,{event_name:e,client_id:this.clientAnalyticsId,payload:{...t||{},clientTimestamp:r?r.toISOString():(new Date).toISOString()}},{retry:-1,keepalive:n?.keepAlive??!1})}catch(e){console.log("Unable to submit event. This is not an issue.")}}async signMoonpayOnRampUrl(e){try{return this.api.post(o.moonpayPluginOnRampPath,e)}catch(e){throw o.formatPrivyError(e)}}async initCoinbaseOnRamp(e){try{return this.api.post(o.coinbaseOnRampInitPath,e)}catch(e){throw o.formatPrivyError(e)}}async getCoinbaseOnRampStatus({partnerUserId:e}){try{return this.api.get(`${o.coinbaseOnRampStatusPath}?partnerUserId=${e}`)}catch(e){throw o.formatPrivyError(e)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()?this.session.refresh():null}async getAccessToken(e){return await this.getPrivyAccessToken(e)||await this.getCustomerAccessToken(e)}async getCustomerAccessToken(e){return await this._getToken(Za.CUSTOMER,e)}async getPrivyAccessToken(e){return await this._getToken(Za.PRIVY,e)}async _getToken(e,t){return this.session.getToken(e)?this.session.hasActiveAccessToken(e)?this.session.hasRefreshCredentials(e)?wn.parse(this.session.getToken(e))?.appId!==this.appId?(await this.logout(),null):this.session.getToken(e):(this.session.destroyLocalState(),null):!t?.disableAutoRefresh&&this.session.hasRefreshCredentials(e)?(await this.session.refresh(),this.session.getToken(e)):null:null}async getSmartWalletsConfig(){try{let e={},t=this.session.token;t&&(e.authorization=`Bearer ${t}`);let r=await this.api.get(`/api/v1/apps/${this.appId}/smart_wallets`,{baseURL:this.fallbackApiUrl,headers:e});return r.enabled?{enabled:r.enabled,smartWalletType:r.smart_wallet_type,configuredNetworks:r.configured_networks.map((e=>({chainId:e.chain_id,bundlerUrl:e.bundler_url,paymasterUrl:e.paymaster_url,paymasterContext:za(e.paymaster_url,e.paymaster_context)})))}:{enabled:r.enabled}}catch(e){throw o.formatPrivyError(e)}}async getUsdTokenPrice(e){try{return(await this.api.get(`/api/v1/token_price?chainId=${e.id}&tokenSymbol=${e.nativeCurrency.symbol}`)).usd}catch(t){return void console.error(`Unable to fetch token price for chain with id ${e.id}`)}}async getUsdPriceForSol(){try{return(await this.api.get("/api/v1/token_price?chainId=0&tokenSymbol=SOL")).usd}catch(e){return void console.error("Unable to fetch token price for SOL")}}async getSplTokenMetadata({mintAddress:e,cluster:t}){try{return await this.api.get(`/api/v1/spl_token_info?mint_address=${e}&cluster=${t}`)}catch(r){return void console.error(`Unable to fetch token metadata for ${t}:${e}`)}}async requestFarcasterSignerStatus(e){try{return await this.api.post("/api/v1/farcaster/signer/status",{ed25519_public_key:e})}catch(e){throw console.error("Unable to fetch Farcaster signer status"),e}}async generateSiweNonce({address:e,captchaToken:t}){try{return(await this.api.post(o.siweInitPath,{address:e,token:t})).nonce}catch(e){throw o.formatPrivyError(e)}}async authenticateWithSiweInternal({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a,mode:i}){return await this.api.post(o.siweAuthenticatePath,{message:e,signature:t,chainId:r,walletClientType:n,connectorType:a,mode:i})}async linkWithSiweInternal({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a}){return await this.api.post(o.siweLinkPath,{message:e,signature:t,chainId:r,walletClientType:n,connectorType:a})}async linkSmartWallet({message:e,signature:t,smartWalletType:r}){try{let n=await this.api.post(o.smartWalletLinkPath,{message:e,signature:t,smart_wallet_type:r});return u.convertUserResponseToUser(n)}catch(e){throw o.formatPrivyError(e)}}async linkWithSiwe({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a}){try{let i=await this.linkWithSiweInternal({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a});return u.convertUserResponseToUser(i)}catch(e){throw o.formatPrivyError(e)}}async generateSiwsNonce({address:e,captchaToken:t}){try{return(await this.api.post(o.siwsInitPath,{address:e,token:t})).nonce}catch(e){throw o.formatPrivyError(e)}}async authenticateWithSiwsInternal({message:e,signature:t,walletClientType:r,connectorType:n,mode:a,messageType:i="plain"}){return await this.api.post(o.siwsAuthenticatePath,{message:e,signature:t,walletClientType:r,connectorType:n,mode:a,message_type:i})}async sendAccountTransferRequest({nonce:e,account:t,accountType:r,externalWalletMetadata:n,telegramAuthResult:a,telegramWebAppData:i,farcasterEmbeddedAddress:s,oAuthUserInfo:l}){try{let c,d;switch(r){case"email":c=o.transferEmailPath,d={nonce:e,email:t};break;case"sms":c=o.transferPhonePath,d={nonce:e,phoneNumber:t};break;case"siwe":if(c=o.transferWalletPath,!n)throw Error("Wallet parameters must be defined");d={nonce:e,address:t,...n};break;case"farcaster":c=o.transferFarcasterPath,d={nonce:e,farcaster_id:t,farcaster_embedded_address:s};break;case"telegram":c=o.telegramAccountTransferPath,d={nonce:e,telegram_auth_result:a,telegram_web_app_data:i};break;case"custom":case"guest":case"passkey":throw Error("Invalid transfer account type");default:c=o.transferOAuthPath,d={nonce:e,userInfo:l}}let h=await this.api.post(c,d);return await this.getAuthenticatedUser()??u.convertUserResponseToUser(h)}catch(e){throw o.formatPrivyError(e)}}async linkWithSiwsInternal({message:e,signature:t,walletClientType:r,connectorType:n,messageType:a="plain"}){return await this.api.post(o.siwsLinkPath,{message:e,signature:t,walletClientType:r,connectorType:n,message_type:a})}async linkWithSiws({message:e,signature:t,walletClientType:r,connectorType:n,messageType:a="plain"}){try{let i=await this.linkWithSiwsInternal({message:e,signature:t,walletClientType:r,connectorType:n,messageType:a});return u.convertUserResponseToUser(i)}catch(e){throw o.formatPrivyError(e)}}async updateUserAndIdToken(){try{let e=await this.api.get(o.usersMePath);return this.session.updateIdentityToken(e.identity_token),u.convertUserResponseToUser(e.user)}catch(e){throw o.formatPrivyError(e)}}async scanTransaction(e){try{return await this.api.post(o.transactionScanningPath,e)}catch(e){throw o.formatPrivyError(e)}}constructor({apiUrl:e=or,appId:t,appClientId:r,timeout:n=2e4}){Object.defineProperty(this,Qa,{value:ei}),this._cachedProviderAppDetails={},this.apiUrl=e,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=e!==or&&e.startsWith("https://privy."),this.timeout=n,this.appId=t,this.appClientId=r,this.clientAnalyticsId=function(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}(this,Qa)[Qa](),Ga||(Ga=new Ya),this.session=Ga,this.api=this.generateApi(),this.session.client=this}}function ei(){if("undefined"==typeof window)return null;try{let e=Mt.get(wr);if("string"==typeof e&&e.length>0)return e}catch(e){}let e=c.v4();try{return Mt.put(wr,e),e}catch(t){return e}}const ti=({delayedExecution:t,...n})=>{let{enabled:a,siteKey:i,appId:o,setError:s,setToken:l,setExecuting:c,ref:d}=hn(),[,u]=r.useMemo((()=>i?.split("t:")||[]),[i]);if(r.useEffect((()=>d.current?.remove),[]),!a)return null;if(!u)throw Error("Unsupported captcha site key");/*#__PURE__*/return e.jsx("div",{className:"hidden h-0 w-0",children:/*#__PURE__*/e.jsx(m.Turnstile,{...n,ref:d,siteKey:u,options:{action:o,size:"invisible",...t?{appearance:"execute",execution:"execute"}:{appearance:"always",execution:"render"}},onUnsupported:()=>{n.onUnsupported?.(),console.warn("Browser does not support Turnstile.")},onError:()=>{n.onError?.(),s("Captcha failed"),c(!1)},onSuccess:e=>{n.onSuccess?.(e),l(e),c(!1)},onExpire:()=>{n.onExpire?.();try{d.current?.reset(),s(void 0),l(void 0)}catch(e){s("expired_and_failed_reset")}}})})},ri=e=>{let[t,n]=r.useState("auto");return r.useEffect((()=>{let t=new ResizeObserver((e=>{n(e[0]?.contentRect.height??"auto")}));return e.current&&t.observe(e.current),()=>{e.current&&t.unobserve(e.current)}}),[e.current]),t},ni={login:{onComplete:[],onError:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]},connectOrCreateWallet:{onSuccess:[],onError:[]},createWallet:{onSuccess:[],onError:[]},linkAccount:{onSuccess:[],onError:[]},update:{onSuccess:[],onError:[]},configureMfa:{onMfaRequired:[]},setWalletPassword:{onSuccess:[],onError:[]},setWalletRecovery:{onSuccess:[],onError:[]},signMessage:{onSuccess:[],onError:[]},signTypedData:{onSuccess:[],onError:[]},sendTransaction:{onSuccess:[],onError:[]},signTransaction:{onSuccess:[],onError:[]},signSolanaTransaction:{onSuccess:[],onError:[]},signSolanaMessage:{onSuccess:[],onError:[]},sendSolanaTransaction:{onSuccess:[],onError:[]},accessToken:{onAccessTokenGranted:[],onAccessTokenRemoved:[]},oAuthAuthorization:{onOAuthTokenGrant:[]},fundWallet:{onUserExited:[]},fundSolanaWallet:{onUserExited:[]},customAuth:{onAuthenticated:[],onUnauthenticated:[]}},ai=/*#__PURE__*/r.createContext(void 0);let ii=()=>r.useContext(ai);function oi(e,t){if(!t)return;let n=ii().current[e];return r.useEffect((()=>{for(let[r,a]of Object.entries(t))Object.prototype.hasOwnProperty.call(n,r)||console.warn(`Invalid event type "${r}" for action "${e}"`),n[r]?.push(a);return()=>{for(let[r,a]of Object.entries(t))Object.prototype.hasOwnProperty.call(n,r)||console.warn(`Invalid event type "${r}" for action "${e}"`),n[r]=n[r]?.filter((e=>e!==a))}}),[t])}function si(e,t,r,...n){for(let a of e.current[t][r])a(...n)}function li(){let e=ii();return(t,r,...n)=>si(e,t,r,...n)}function ci(e){oi("configureMfa",e)}const di=/*#__PURE__*/g.styled.div.withConfig({displayName:"Grow",componentId:"sc-ddbf22b4-0"})(["text-align:left;flex-grow:1;"]),ui=/*#__PURE__*/g.styled.div.withConfig({displayName:"AlignBottom",componentId:"sc-ddbf22b4-1"})(["display:flex;flex-direction:column;justify-content:flex-end;flex-grow:1;"]),hi=/*#__PURE__*/g.styled.div.withConfig({displayName:"LoginMethodContainer",componentId:"sc-ddbf22b4-2"})(["display:flex;flex-direction:column;gap:12px;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}"]),pi=/*#__PURE__*/g.styled(hi).withConfig({displayName:"LoginMethodContainerWithScrollShadows",componentId:"sc-ddbf22b4-3"})([""," background-repeat:no-repeat;background-size:100% 32px,100% 16px;background-attachment:local,scroll;max-height:400px;overflow-y:auto;scrollbar-width:none;padding:2px;"],(e=>"light"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.06)) bottom;":"dark"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.06)) bottom;":void 0));let yi=/*#__PURE__*/g.css(["&&{width:100%;font-size:16px;line-height:24px;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;align-items:center;padding:12px 16px;border:1px solid var(--privy-color-foreground-4) !important;border-radius:var(--privy-border-radius-mdlg);transition:background-color 200ms ease;cursor:pointer;&:hover{background-color:var(--privy-color-background-2);}&:disabled{cursor:pointer;background-color:var(--privy-color-background-2);}svg{height:24px;max-height:24px;max-width:24px;}}"]);const mi=/*#__PURE__*/g.styled.div.withConfig({displayName:"Subtitle",componentId:"sc-ddbf22b4-4"})(["text-align:center;font-size:14px;margin-bottom:24px;"]),gi=/*#__PURE__*/g.styled.button.attrs({className:"login-method-button"}).withConfig({displayName:"LoginMethodButton",componentId:"sc-ddbf22b4-5"})(["",""],yi),fi=/*#__PURE__*/g.styled.a.withConfig({displayName:"LoginMethodButtonLink",componentId:"sc-ddbf22b4-6"})(["",""],yi),wi=/*#__PURE__*/g.styled.div.withConfig({displayName:"Hide",componentId:"sc-ddbf22b4-7"})(["width:100%;height:100%;min-height:inherit;display:flex;flex-direction:column;",""],(e=>e.$if?"display: none;":"")),vi=/*#__PURE__*/g.styled.div.withConfig({displayName:"EmptyWalletState",componentId:"sc-ddbf22b4-8"})(["width:100%;height:100%;padding:",";"],(e=>e.$withPadding?"64px 0px":"0px")),xi=/*#__PURE__*/g.styled.div.withConfig({displayName:"Header",componentId:"sc-ddbf22b4-9"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-bottom:32px;gap:12px;& h3{font-size:18px;font-style:normal;font-weight:600;line-height:24px;}& p{max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;}"]),Ci=({success:t,fail:r})=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(bi,{className:t?"success":r?"fail":""}),/*#__PURE__*/e.jsx(ji,{className:t?"success":r?"fail":""})]}),bi=/*#__PURE__*/g.styled.span.withConfig({displayName:"Loader",componentId:"sc-ce7792e2-0"})(["&&{width:82px;height:82px;border-width:4px;border-style:solid;border-color:",";border-bottom-color:transparent;border-radius:50%;display:inline-block;box-sizing:border-box;animation:rotation 1.2s linear infinite;transition:border-color 800ms;}@keyframes rotation{0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}}&&&.success{border-color:var(--privy-color-success);border-bottom-color:var(--privy-color-success);}&&&.fail{border-color:var(--privy-color-error);border-bottom-color:var(--privy-color-error);}"],(e=>e.color??"var(--privy-color-accent)")),ji=/*#__PURE__*/g.styled(bi).withConfig({displayName:"LoaderFaint",componentId:"sc-ce7792e2-1"})(["&&{border-bottom-color:",";animation:none;opacity:0.5;}"],(e=>e.color??"var(--privy-color-accent)")),Ei=t=>/*#__PURE__*/e.jsx(ki,{color:t.color||"var(--privy-color-foreground-3)"});let ki=/*#__PURE__*/g.styled(bi).withConfig({displayName:"StyledButtonLoader",componentId:"sc-ce7792e2-2"})(["&&{height:1rem;width:1rem;margin:2px 0;border-width:1.5px;transition:border-color 200ms ease;}"]);const Ti=/*#__PURE__*/g.styled.button.withConfig({displayName:"Button",componentId:"sc-b2dfb420-0"})(["display:flex;flex-direction:row;align-items:center;justify-content:center;user-select:none;&{width:100%;cursor:pointer;border-radius:var(--privy-border-radius-md);font-size:1rem;font-style:normal;font-weight:500;line-height:22px;letter-spacing:-0.016px;}&&{padding:12px 16px;}"]),Ai=({children:t,loading:r,disabled:n,success:a,loadingText:i="Loading...",...o})=>/*#__PURE__*/e.jsx(_i,{disabled:r||n,$success:a,...o,children:r?/*#__PURE__*/e.jsxs("span",{children:[/*#__PURE__*/e.jsx(Ei,{}),i?/*#__PURE__*/e.jsx("span",{children:i}):null]}):t}),Ii=({children:t,loading:r,disabled:n,...a})=>/*#__PURE__*/e.jsx(Si,{disabled:n,...a,children:r?/*#__PURE__*/e.jsx(Ei,{color:"var(--privy-color-foreground-accent)"}):t});let Si=/*#__PURE__*/g.styled(Ti).withConfig({displayName:"StyledPrimaryButtonWithoutGray",componentId:"sc-b2dfb420-1"})(["position:relative;&&{background-color:var(--privy-color-accent);color:var(--privy-color-foreground-accent);transition:background-color 200ms ease;}&:hover{background-color:var(--privy-color-accent-dark);}&:active{background-color:var(--privy-color-accent-dark);}&:disabled,&:hover:disabled,&:active:disabled{cursor:not-allowed;pointer-events:none;color:var(--privy-color-foreground-accent);background-color:var(--privy-color-accent-dark);}"]);const Pi=({children:t,loading:r,disabled:n,loadingText:a="Loading...",...i})=>/*#__PURE__*/e.jsx(_i,{as:"a",disabled:r||n,...i,children:r?/*#__PURE__*/e.jsxs("span",{children:[/*#__PURE__*/e.jsx(Ei,{}),a?/*#__PURE__*/e.jsx("span",{children:a}):null]}):t});let _i=/*#__PURE__*/g.styled(Ti).withConfig({displayName:"StyledPrimaryButton",componentId:"sc-b2dfb420-2"})(["position:relative;&&{background-color:",";color:var(--privy-color-foreground-accent);transition:background-color 200ms ease;}&:hover{background-color:",";}&:active{background-color:",";}&:hover:disabled,&:active:disabled{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;}"," > span{display:flex;align-items:center;gap:8px;opacity:1;animation:fadein 200ms ease;}"],(e=>e.$warn?"var(--privy-color-error)":e.$success?"var(--privy-color-success)":"var(--privy-color-accent)"),(e=>e.$warn?"var(--privy-color-error)":e.$success?"var(--privy-color-success)":"var(--privy-color-accent-dark)"),(e=>e.$warn?"var(--privy-color-error)":e.$success?"var(--privy-color-success)":"var(--privy-color-accent-dark)"),(e=>e.disabled?/*#__PURE__*/g.css(["&&&,&&&:hover,&&&:active{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;pointer-events:none;}"]):""));const Ni=({children:t,loading:r,disabled:n,loadingText:a="Loading...",...i})=>/*#__PURE__*/e.jsx(Mi,{disabled:r||n,...i,children:r?/*#__PURE__*/e.jsxs("span",{children:[/*#__PURE__*/e.jsx(Ei,{}),a?/*#__PURE__*/e.jsx("span",{children:a}):null]}):t});let Mi=/*#__PURE__*/g.styled(Ti).withConfig({displayName:"StyledSecondaryButton",componentId:"sc-b2dfb420-3"})(["&&{border-width:1px;border-color:",";color:var(--privy-color-foreground);transition:border-color 200ms ease;}&:hover,&:active{border-color:",";}&:hover:disabled,&:active:disabled{border-color:var(--privy-color-foreground-accent);color:var(--privy-color-foreground-3);cursor:not-allowed;}> span{display:flex;align-items:center;gap:8px;opacity:1;animation:fadein 200ms ease;}"],(e=>e.$warn?"var(--privy-color-error)":"var(--privy-color-foreground-4)"),(e=>e.$warn?"var(--privy-color-error)":"var(--privy-color-foreground-3)"));const Wi=/*#__PURE__*/g.styled.button.withConfig({displayName:"SoftCtaButton",componentId:"sc-b2dfb420-4"})(["&&{padding:12px 16px;font-weight:500;text-align:center;color:var(--privy-color-foreground-accent);background-color:var(--privy-color-accent);border-radius:var(--privy-border-radius-sm);min-width:144px;opacity:",";transition:opacity 200ms ease,background-color 200ms ease,color 200ms ease;user-select:none;"," &:hover{background-color:var(--privy-color-accent-dark);}&:active{background-color:var(--privy-color-accent-dark);}&:hover:disabled,&:active:disabled{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;}}"],(e=>e.invisible?"0":"1"),(e=>e.invisible&&/*#__PURE__*/g.css(["pointer-events:none;"]))),Ui=({children:t,onClick:r,disabled:n,isSubmitting:a,...i})=>/*#__PURE__*/e.jsxs(Oi,{$isSubmitting:a,onClick:r,disabled:n,...i,children:[/*#__PURE__*/e.jsx("span",{children:t}),
1
+ "use strict";var e=require("react/jsx-runtime"),t=require("mipd"),r=require("react"),n=require("react-device-detect"),a=require("viem/utils"),i=require("@privy-io/js-sdk-core"),o=require("./paths-CdRs2pll.js"),s=require("./internal-context-CrTqNb_c.js"),l=require("viem"),c=require("uuid"),d=require("jose"),u=require("./use-sign-with-user-signer-h5JGn1CY.js"),h=require("eventemitter3"),p=require("@coinbase/wallet-sdk"),y=require("@privy-io/ethereum"),m=require("@marsidev/react-turnstile"),g=require("styled-components"),f=require("tinycolor2"),w=require("@heroicons/react/24/outline/DevicePhoneMobileIcon"),v=require("@heroicons/react/24/outline/FingerPrintIcon"),x=require("@heroicons/react/24/outline/PhoneIcon"),C=require("@heroicons/react/24/outline/ShieldCheckIcon"),b=require("@heroicons/react/24/outline/ArrowLeftIcon");require("@heroicons/react/24/outline/ArrowRightIcon");var j=require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),E=require("@heroicons/react/24/outline/XMarkIcon"),k=require("@heroicons/react/24/outline/ChevronDownIcon"),T=require("@heroicons/react/24/outline/CalendarIcon"),A=require("@heroicons/react/24/outline/ExclamationTriangleIcon"),I=require("@headlessui/react"),S=require("@walletconnect/ethereum-provider"),P=require("zustand"),_=require("fast-password-entropy"),N=require("secure-password-utilities"),M=require("secure-password-utilities/wordlists"),W=require("@heroicons/react/24/outline/UserCircleIcon"),U=require("@heroicons/react/24/outline/EnvelopeIcon"),O=require("@heroicons/react/20/solid/CheckIcon"),F=require("@heroicons/react/24/outline/WalletIcon"),R=require("@heroicons/react/24/outline/CheckIcon"),L=require("@heroicons/react/24/outline/Square2StackIcon"),D=require("@heroicons/react/24/outline/ExclamationCircleIcon"),B=require("@heroicons/react/24/outline/ArrowTopRightOnSquareIcon"),z=require("@heroicons/react/24/solid/DocumentCheckIcon"),$=require("@heroicons/react/24/solid/XCircleIcon"),q=require("@heroicons/react/24/solid/CheckCircleIcon"),V=require("qrcode"),H=require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),K=require("@heroicons/react/24/outline/ChevronRightIcon"),Z=require("@heroicons/react/24/outline/LockClosedIcon"),Y=require("@heroicons/react/24/outline/PencilSquareIcon"),G=require("@heroicons/react/24/outline/ArrowPathIcon"),J=require("@heroicons/react/24/outline/EyeIcon"),Q=require("@heroicons/react/24/outline/EyeSlashIcon"),X=require("@heroicons/react/24/outline/KeyIcon"),ee=require("@heroicons/react/24/outline/ArrowDownTrayIcon"),te=require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),re=require("@heroicons/react/24/outline/DocumentDuplicateIcon"),ne=require("@heroicons/react/24/solid/LockClosedIcon"),ae=require("@heroicons/react/24/outline/CheckCircleIcon"),ie=require("@heroicons/react/24/outline/InformationCircleIcon"),oe=require("@heroicons/react/24/outline/CreditCardIcon"),se=require("@heroicons/react/24/outline/QrCodeIcon"),le=require("@heroicons/react/24/outline/GlobeAltIcon"),ce=require("ofetch"),de=require("@heroicons/react/24/outline"),ue=require("@heroicons/react/24/outline/ClipboardDocumentIcon"),he=require("@heroicons/react/24/outline/CloudArrowUpIcon"),pe=require("@heroicons/react/24/outline/NoSymbolIcon"),ye=require("@heroicons/react/24/outline/ClockIcon"),me=require("@heroicons/react/24/outline/TrashIcon"),ge=require("@heroicons/react/24/solid/CheckBadgeIcon"),fe=require("@heroicons/react/24/solid/IdentificationIcon"),we=require("@heroicons/react/24/outline/MinusCircleIcon"),ve=require("@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon"),xe=require("@heroicons/react/24/solid/ShieldCheckIcon"),Ce=require("js-cookie");function be(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function je(e){if(e&&"object"==typeof e&&"default"in e)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var Ee=/*#__PURE__*/be(r),ke=/*#__PURE__*/je(n),Te=/*#__PURE__*/be(i),Ae=/*#__PURE__*/je(d),Ie=/*#__PURE__*/be(h),Se=/*#__PURE__*/be(f),Pe=/*#__PURE__*/be(w),_e=/*#__PURE__*/be(v),Ne=/*#__PURE__*/be(x),Me=/*#__PURE__*/be(C),We=/*#__PURE__*/be(b),Ue=/*#__PURE__*/be(j),Oe=/*#__PURE__*/be(E),Fe=/*#__PURE__*/be(k),Re=/*#__PURE__*/be(T),Le=/*#__PURE__*/be(A),De=/*#__PURE__*/be(_),Be=/*#__PURE__*/je(N),ze=/*#__PURE__*/be(W),$e=/*#__PURE__*/be(U),qe=/*#__PURE__*/be(O),Ve=/*#__PURE__*/be(F),He=/*#__PURE__*/be(R),Ke=/*#__PURE__*/be(L),Ze=/*#__PURE__*/be(D),Ye=/*#__PURE__*/be(B),Ge=/*#__PURE__*/be(z),Je=/*#__PURE__*/be($),Qe=/*#__PURE__*/be(q),Xe=/*#__PURE__*/be(V),et=/*#__PURE__*/be(H),tt=/*#__PURE__*/be(K),rt=/*#__PURE__*/be(Z),nt=/*#__PURE__*/be(Y),at=/*#__PURE__*/be(G),it=/*#__PURE__*/be(J),ot=/*#__PURE__*/be(Q),st=/*#__PURE__*/be(X),lt=/*#__PURE__*/be(ee),ct=/*#__PURE__*/be(te),dt=/*#__PURE__*/be(re),ut=/*#__PURE__*/be(ne),ht=/*#__PURE__*/be(ae),pt=/*#__PURE__*/be(ie),yt=/*#__PURE__*/be(oe),mt=/*#__PURE__*/be(se),gt=/*#__PURE__*/be(le),ft=/*#__PURE__*/be(ue),wt=/*#__PURE__*/be(he),vt=/*#__PURE__*/be(pe),xt=/*#__PURE__*/be(ye),Ct=/*#__PURE__*/be(me),bt=/*#__PURE__*/be(ge),jt=/*#__PURE__*/be(fe),Et=/*#__PURE__*/be(we),kt=/*#__PURE__*/be(ve),Tt=/*#__PURE__*/be(xe),At=/*#__PURE__*/be(Ce);function It(e){return e?{"privy-ui":"t"}:void 0}class St{async authenticate(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new o.PrivyClientError("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(o.passwordlessAuthenticatePath,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw o.formatApiError(e)}}async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new o.PrivyClientError("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(o.passwordlessLinkPath,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw o.formatApiError(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:r}){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new o.PrivyClientError("Email must be set when initialzing authentication.");let n=It(r);try{return await this.api.post(o.passwordlessInitPath,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...n}})}catch(e){throw o.formatApiError(e)}}constructor({email:e,captchaToken:t,disableSignup:r}){this.meta={email:e,captchaToken:t,disableSignup:r??!1}}}class Pt extends St{async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new o.PrivyClientError("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(o.updateEmailPath,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw o.formatApiError(e)}}constructor(e,t,r){super({email:t,captchaToken:r}),this.meta={email:t,captchaToken:r,oldAddress:e,disableSignup:!1}}}class _t{get(e){let t=localStorage.getItem(e);return null===t?void 0:JSON.parse(t)}put(e,t){void 0!==t?localStorage.setItem(e,JSON.stringify(t)):this.del(e)}del(e){localStorage.removeItem(e)}getKeys(){return Object.entries(localStorage).map((([e])=>e))}}function Nt(){try{let e="privy:__session_storage__test",t=new _t;return t.put(e,"blobby"),t.del(e),!0}catch(e){return!1}}var Mt="undefined"!=typeof window&&window.localStorage?new _t:new class{get(e){return this._cache[e]}put(e,t){void 0!==t?this._cache[e]=t:this.del(e)}del(e){delete this._cache[e]}getKeys(){return Object.keys(this._cache)}constructor(){this._cache={}}};const Wt=e=>e.isApexWallet?"Apex Wallet":e.isAvalanche?"Core Wallet":e.isBackpack?"Backpack":e.isBifrost?"Bifrost Wallet":e.isBitKeep?"BitKeep":e.isBitski?"Bitski":e.isBlockWallet?"BlockWallet":e.isBraveWallet?"Brave Wallet":e.isClover?"Clover":e.isCoin98?"Coin98 Wallet":e.isCoinbaseWallet?"Coinbase Wallet":e.isDawn?"Dawn Wallet":e.isDefiant?"Defiant":e.isDesig?"Desig Wallet":e.isEnkrypt?"Enkrypt":e.isExodus?"Exodus":e.isFordefi?"Fordefi":e.isFrame?"Frame":e.isFrontier?"Frontier Wallet":e.isGamestop?"GameStop Wallet":e.isHaqqWallet?"HAQQ Wallet":e.isHyperPay?"HyperPay Wallet":e.isImToken?"ImToken":e.isHaloWallet?"Halo Wallet":e.isKuCoinWallet?"KuCoin Wallet":e.isMathWallet?"MathWallet":e.isNovaWallet?"Nova Wallet":e.isOkxWallet||e.isOKExWallet?"OKX Wallet":e.isOneInchIOSWallet||e.isOneInchAndroidWallet?"1inch Wallet":e.isOneKey?"OneKey Wallet":e.isOpera?"Opera":e.isPhantom||"isPhantom"in e?"Phantom":e.isPortal?"Ripio Portal":e.isRabby?"Rabby Wallet":e.isRainbow?"Rainbow":e.isSafePal?"SafePal Wallet":e.isStatus?"Status":e.isSubWallet?"SubWallet":e.isTalisman?"Talisman":e.isTally||e.isTaho?"Taho":e.isTokenPocket?"TokenPocket":e.isTokenary?"Tokenary":e.isTrust||e.isTrustWallet?"Trust Wallet":e.isTTWallet?"TTWallet":e.isXDEFI?"XDEFI Wallet":e.isZeal?"Zeal":e.isZerion?"Zerion":e.isMetaMask?"MetaMask":void 0,Ut=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||"MetaMask"!==Wt(e))return!1;if(e.providers)for(let t of e.providers)if(!Ut(t))return!1;return!0},Ot=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers)for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0;return!1},Ft=(e,t,r,n)=>{let a=Number(e),i=t.find((e=>e.id===a));if(!i)throw new o.PrivyConnectorError(`Unsupported chainId ${e}`,4901);return l.createPublicClient({transport:l.http(Rt(i,r,n.appId)),chain:i})},Rt=(e,t,r)=>{let n,a=e.id,i=Number(e.id);if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])n=e.rpcUrls.privyWalletOverride.http[0];else if(t.rpcUrls&&t.rpcUrls[i])n=t.rpcUrls[i];else if(e.rpcUrls.privy?.http[0]){let t=new URL(e.rpcUrls.privy.http[0]);t.searchParams.append("privyAppId",r),n=t.toString()}else n=e.rpcUrls.public?.http[0]?e.rpcUrls.public.http[0]:e.rpcUrls.default?.http[0];if(!n)throw new o.PrivyConnectorError(`No RPC url found for ${a}`);return n},Lt=e=>!!String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),Dt=(e,t=3,r=4,n="ethereum")=>{if(!e)return"";let a="ethereum"===n?2:0;return t+r+a+3>=e.length?e:`${e.slice(0,a+t)}...${e.slice(e.length-r,e.length)}`},Bt=(e,t=3,r=4)=>Dt(e,t,r,"solana"),zt=e=>new Promise((t=>setTimeout(t,e)));const $t=(e,t={})=>{let r=t.delayMs||150,n=t.maxAttempts||270;return new Promise((async(a,i)=>{let o=!1,s=0;for(;!o&&s<n;){if(t.abortSignal?.aborted)return;e().then((e=>{o=!0,a(e)}),((...e)=>{o=!0,i(...e)})),s+=1,await zt(r)}o||i(Error("Exceeded max attempts before resolving function"))}))},qt=(e,t,r={},n={})=>{let a=new URL(t,e);for(let[e,t]of Object.entries(r))void 0!==t&&a.searchParams.set(e,t);let i=Object.entries(n);if(i.length>0){let e=new URLSearchParams;for(let[t,r]of i)e.append(t,r);a.hash=e.toString()}return a.href},Vt=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),Ht=e=>"string"==typeof e?e:"0x"+e.toString(16);async function Kt({store:e,walletList:t,externalWalletConfig:r,walletChainType:n,timeout:a=3e3}){let i=!1,o=window;return new Promise((s=>{function l(){if(i)return;i=!0,window.removeEventListener("ethereum#initialized",l);let a=e.getProviders();console.debug("Detected injected providers:",a.map((e=>e.info)));let o=[];for(let e of a)t.includes("coinbase_wallet")&&"com.coinbase.wallet"===e.info.rdns||"solana-only"===n&&"app.phantom"===e.info.rdns||o.push({type:e.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:e});if("solana-only"!==n)for(let e of function(){let e=window,t=e.ethereum;if(!t)return[];let r=[];if(t.providers?.length)for(let e of t.providers)e&&r.push(e);return r.push(e.ethereum),r}()){let t=Wt(e);if(!a.some((e=>e.info.name===t))){if(Ut(e,!0)&&!o.find((e=>"metamask"===e.type))){o.push({type:"metamask",legacyInjectedProvider:e});continue}if("Phantom"===t&&!o.find((e=>"phantom"===e.type))){o.push({type:"phantom",legacyInjectedProvider:e});continue}if("Coinbase Wallet"===t&&!o.find((e=>"coinbase_wallet"===e.type&&"smartWalletOnly"!==r.coinbaseWallet?.config?.preference?.options))){o.push({type:"coinbase_wallet",legacyInjectedProvider:e});continue}o.find((e=>"unknown_browser_extension"===e.type))||o.push({type:"unknown_browser_extension",legacyInjectedProvider:e})}}s(o)}o.ethereum?l():(window.addEventListener("ethereum#initialized",l,{once:!0}),setTimeout((()=>{l()}),a))}))}function Zt(e){return`eip155:${String(Number(e))}`}const Yt=(e,t,r,n)=>{let a=Number(e),i=t.find((e=>e.id===a));if(!i)throw new o.PrivyConnectorError(`Unsupported chainId ${e}`,4901);return Rt(i,r,n)},Gt=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},r=e.types.EIP712Domain??Object.entries(e.domain).map((([e,r])=>{if(null!=r&&"string"==typeof e&&e in t)return{name:e,type:t[e]}})).filter((e=>void 0!==e));return{...e,types:{...e.types,EIP712Domain:r}}};const Jt=["c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96","4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0","225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f","1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369","c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a","ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18","bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6","74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d","afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7","f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d","84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04","0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150","38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662","9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0","c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576","8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4","e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4","f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2","138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98","47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83","7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26","8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3","031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa","2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568","dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd","2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01","b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f","0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92","719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3","942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef","8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2","07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80","8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819","bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a","cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e","94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43","2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715","14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc","576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd","49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd","19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b","5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b","d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b","50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b","9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8","6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa","41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071","14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd","a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1","971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709","18388be9ac2d02726dbac9777c96efaac06d744b2f6d580fccdd4127a6d01fd1","15c8b91ade1a4e58f3ce4e7a0dd7f42b47db0c8df7e0d84f63eb39bcb96c4e0f","541d5dcd4ede02f3afaf75bf8e3e4c4f1fb09edb5fa6c4377ebf31c2785d9adf"];function Qt(e){return{name:e.metadata?.shortName||e.name||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}let Xt="WALLETCONNECT_DEEPLINK_CHOICE";function er(e){return e.startsWith("http://")||e.startsWith("https://")}function tr(e,t){if(er(e))return rr(e,t);let r=e;return r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),{redirect:`${r}wc?uri=${encodeURIComponent(t)}`,href:r}}function rr(e,t){if(!er(e))return tr(e,t);let r=e;return r.endsWith("/")||(r=`${r}/`),{redirect:`${r}wc?uri=${encodeURIComponent(t)}`,href:r}}function nr(e,t){window.open(e,t,"noreferrer noopener")}class ar{execute(e){return null===this.promise&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}constructor(e){this.promise=null,this.fn=e}}class ir{get meta(){return this._meta}async authenticate(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.channelToken)throw new o.PrivyClientError("Auth flow must be initialized first");try{let e=await this.api.post(o.farcasterAuthenticatePath,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});if(!e)throw new o.PrivyClientError("No response from authentication");return e}catch(e){throw o.formatApiError(e)}}async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(o.farcasterLinkPath,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw o.formatApiError(e)}}async _startChannelOnce(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");let e=await this.api.post(o.farcasterInitPath,{token:this.captchaToken});n.isMobile&&!n.isIOS&&e.connect_uri&&nr(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.channelToken)throw new o.PrivyClientError("Auth flow must be initialized first");let e=await this.api.get(o.farcasterStatusPath,{headers:{"farcaster-channel-token":this.meta.channelToken}});return"completed"===e.state&&(this.message=e.message,this.signature=e.signature,this.fid=e.fid,!0)}constructor(e,t=!1){this._meta={disableSignup:!1},this.captchaToken=e,this.startChannelOnce=new ar(this._startChannelOnce.bind(this)),this.pollForReady=new ar(this._pollForReady.bind(this)),this._meta.disableSignup=t}}const or="https://auth.privy.io",sr=1400,lr=2500,cr=4e3,dr="2.15.1",ur="privy:token",hr="privy-token",pr="privy:refresh_token",yr="privy:pat",mr="privy:id_token",gr="privy-id-token",fr="privy-session",wr="privy:caid",vr=e=>`privy:guest:${e}`,xr=e=>`privy:cross-app:${e}`,Cr="privy:state_code",br="privy:code_verifier",jr="privy:headless_oauth",Er="privy:oauth_disable_signup",kr=e=>`privy:wallet:${e}`,Tr="privy:connectors",Ar="privy:connections",Ir=12e4,Sr=3e4,Pr="https://api.moonpay.com/v1",_r="https://api.moonpay.com/v1",Nr="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Mr="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI";function Wr(e){return crypto.getRandomValues(new Uint8Array(e))}function Ur(){return d.base64url.encode(Wr(36))}function Or(){return Ur()}async function Fr(e,t="S256"){if("S256"!=t)return e;{let t=await async function(e){let t=(new TextEncoder).encode(e);return new Uint8Array(await crypto.subtle.digest("SHA-256",t))}(e);return d.base64url.encode(t)}}class Rr{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new o.PrivyClientError("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new o.PrivyClientError("User denied confirmation during OAuth flow");let e=function(){let e=Mt.get(br);if(!e)throw new o.PrivyClientError("Authentication error.");return e}();try{let t=await this.api.post(o.oAuthAuthenticatePath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return Mt.del(br),Mt.del(jr),Mt.del(Er),t}catch(e){let t=o.formatApiError(e);if(t.privyErrorCode)throw new o.PrivyClientError(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new o.PrivyClientError("Invalid code during oauth flow.",void 0,o.PrivyErrorCode.OAUTH_USER_DENIED);throw new o.PrivyClientError("Invalid code during OAuth flow.",void 0,o.PrivyErrorCode.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new o.PrivyClientError("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new o.PrivyClientError("User denied confirmation during OAuth flow");let e=Mt.get(br);if(!e)throw new o.PrivyClientError("Authentication error.");try{let t=await this.api.post(o.oAuthLinkPath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return Mt.del(br),t}catch(e){throw o.formatApiError(e)}}async getAuthorizationUrl(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.provider)throw new o.PrivyClientError("Provider must be set when initializing OAuth authentication.");let e=Ur();Mt.put(br,e);let t=Or();Mt.put(Cr,t);let r=await Fr(e);this.meta.withPrivyUi||Mt.put(jr,!0),this.meta.disableSignup?Mt.put(Er,!0):Mt.del(Er);let n=It(this.meta.withPrivyUi);try{return await this.api.post(o.oAuthInitPath,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:r,state_code:t},{headers:{...n}})}catch(e){throw o.formatApiError(e)}}constructor(e){this.meta=e}}function Lr(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Dr=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",style:{height:"24px",...t},...r,children:[/*#__PURE__*/e.jsx("path",{d:"M17.0722 11.6888C17.0471 8.90571 19.3263 7.56847 19.429 7.50274C18.1466 5.60938 16.153 5.35154 15.4417 5.3212C13.7461 5.14678 12.1306 6.32982 11.269 6.32982C10.4074 6.32982 9.08004 5.34648 7.67246 5.37429C5.82158 5.40209 4.11595 6.45874 3.16171 8.13218C1.24068 11.4942 2.6708 16.4817 4.54423 19.2143C5.46091 20.549 6.55041 22.0531 7.98554 21.9975C9.36803 21.9419 9.88905 21.095 11.5571 21.095C13.2251 21.095 13.696 21.9975 15.1537 21.9697C16.6389 21.9393 17.5806 20.6046 18.4897 19.2648C19.5392 17.7153 19.9725 16.2137 19.9975 16.1354C19.965 16.1228 17.1022 15.0155 17.0722 11.6888Z",fill:"currentColor"}),/*#__PURE__*/e.jsx("path",{d:"M14.3295 3.51373C15.0909 2.58347 15.6043 1.28921 15.4641 0C14.3671 0.0455014 13.0396 0.738135 12.2532 1.66838C11.5494 2.48994 10.9307 3.80695 11.0986 5.07089C12.3183 5.16694 13.5681 4.44145 14.3295 3.51373Z",fill:"currentColor"})]}),Br=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...t},...r,children:[/*#__PURE__*/e.jsx("g",{clipPath:"url(#clip0)",children:/*#__PURE__*/e.jsx("path",{d:"M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z",fill:"#5865F2"})}),/*#__PURE__*/e.jsx("defs",{children:/*#__PURE__*/e.jsx("clipPath",{id:"clip0",children:/*#__PURE__*/e.jsx("rect",{width:"71",height:"55",fill:"white"})})})]}),zr=({style:t,...r})=>/*#__PURE__*/e.jsx("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"24",y:"24",viewBox:"0 0 98 96",style:{height:"24px",...t},...r,children:/*#__PURE__*/e.jsx("path",{d:"M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z",fill:"currentColor"})}),$r=({style:t})=>/*#__PURE__*/e.jsx(gt.default,{style:{color:"var(--privy-color-error)",...t}}),qr=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...t},...r,children:[/*#__PURE__*/e.jsx("path",{d:"M22.56 12.25C22.56 11.47 22.49 10.72 22.36 10H12V14.255H17.92C17.665 15.63 16.89 16.795 15.725 17.575V20.335H19.28C21.36 18.42 22.56 15.6 22.56 12.25Z",fill:"#4285F4"}),/*#__PURE__*/e.jsx("path",{d:"M12 23C14.97 23 17.46 22.015 19.28 20.335L15.725 17.575C14.74 18.235 13.48 18.625 12 18.625C9.13504 18.625 6.71004 16.69 5.84504 14.09H2.17004V16.94C3.98004 20.535 7.70004 23 12 23Z",fill:"#34A853"}),/*#__PURE__*/e.jsx("path",{d:"M5.845 14.09C5.625 13.43 5.5 12.725 5.5 12C5.5 11.275 5.625 10.57 5.845 9.91V7.06H2.17C1.4 8.59286 0.999321 10.2846 1 12C1 13.775 1.425 15.455 2.17 16.94L5.845 14.09Z",fill:"#FBBC05"}),/*#__PURE__*/e.jsx("path",{d:"M12 5.375C13.615 5.375 15.065 5.93 16.205 7.02L19.36 3.865C17.455 2.09 14.965 1 12 1C7.70004 1 3.98004 3.465 2.17004 7.06L5.84504 9.91C6.71004 7.31 9.13504 5.375 12 5.375Z",fill:"#EA4335"})]});function Vr(t){/*#__PURE__*/return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:26,height:26,viewBox:"0 0 140 140",x:"0px",y:"0px",fill:"none",...t,children:[/*#__PURE__*/e.jsxs("defs",{children:[/*#__PURE__*/e.jsxs("linearGradient",{id:"b",children:[/*#__PURE__*/e.jsx("stop",{offset:"0",stopColor:"#3771c8"}),/*#__PURE__*/e.jsx("stop",{stopColor:"#3771c8",offset:".128"}),/*#__PURE__*/e.jsx("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),/*#__PURE__*/e.jsxs("linearGradient",{id:"a",children:[/*#__PURE__*/e.jsx("stop",{offset:"0",stopColor:"#fd5"}),/*#__PURE__*/e.jsx("stop",{offset:".1",stopColor:"#fd5"}),/*#__PURE__*/e.jsx("stop",{offset:".5",stopColor:"#ff543e"}),/*#__PURE__*/e.jsx("stop",{offset:"1",stopColor:"#c837ab"})]}),/*#__PURE__*/e.jsx("radialGradient",{id:"c",cx:"158.429",cy:"578.088",r:"65",xlinkHref:"#a",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(0 -1.98198 1.8439 0 -1031.402 454.004)",fx:"158.429",fy:"578.088"}),/*#__PURE__*/e.jsx("radialGradient",{id:"d",cx:"147.694",cy:"473.455",r:"65",xlinkHref:"#b",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(.17394 .86872 -3.5818 .71718 1648.348 -458.493)",fx:"147.694",fy:"473.455"})]}),/*#__PURE__*/e.jsx("path",{fill:"url(#c)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),/*#__PURE__*/e.jsx("path",{fill:"url(#d)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),/*#__PURE__*/e.jsx("path",{fill:"#fff",d:"M66.004 18c-13.036 0-14.672.057-19.792.29-5.11.234-8.598 1.043-11.65 2.23-3.157 1.226-5.835 2.866-8.503 5.535-2.67 2.668-4.31 5.346-5.54 8.502-1.19 3.053-2 6.542-2.23 11.65C18.06 51.327 18 52.964 18 66s.058 14.667.29 19.787c.235 5.11 1.044 8.598 2.23 11.65 1.227 3.157 2.867 5.835 5.536 8.503 2.667 2.67 5.345 4.314 8.5 5.54 3.054 1.187 6.543 1.996 11.652 2.23 5.12.233 6.755.29 19.79.29 13.037 0 14.668-.057 19.788-.29 5.11-.234 8.602-1.043 11.656-2.23 3.156-1.226 5.83-2.87 8.497-5.54 2.67-2.668 4.31-5.346 5.54-8.502 1.18-3.053 1.99-6.542 2.23-11.65.23-5.12.29-6.752.29-19.788 0-13.036-.06-14.672-.29-19.792-.24-5.11-1.05-8.598-2.23-11.65-1.23-3.157-2.87-5.835-5.54-8.503-2.67-2.67-5.34-4.31-8.5-5.535-3.06-1.187-6.55-1.996-11.66-2.23-5.12-.233-6.75-.29-19.79-.29zm-4.306 8.65c1.278-.002 2.704 0 4.306 0 12.816 0 14.335.046 19.396.276 4.68.214 7.22.996 8.912 1.653 2.24.87 3.837 1.91 5.516 3.59 1.68 1.68 2.72 3.28 3.592 5.52.657 1.69 1.44 4.23 1.653 8.91.23 5.06.28 6.58.28 19.39s-.05 14.33-.28 19.39c-.214 4.68-.996 7.22-1.653 8.91-.87 2.24-1.912 3.835-3.592 5.514-1.68 1.68-3.275 2.72-5.516 3.59-1.69.66-4.232 1.44-8.912 1.654-5.06.23-6.58.28-19.396.28-12.817 0-14.336-.05-19.396-.28-4.68-.216-7.22-.998-8.913-1.655-2.24-.87-3.84-1.91-5.52-3.59-1.68-1.68-2.72-3.276-3.592-5.517-.657-1.69-1.44-4.23-1.653-8.91-.23-5.06-.276-6.58-.276-19.398s.046-14.33.276-19.39c.214-4.68.996-7.22 1.653-8.912.87-2.24 1.912-3.84 3.592-5.52 1.68-1.68 3.28-2.72 5.52-3.592 1.692-.66 4.233-1.44 8.913-1.655 4.428-.2 6.144-.26 15.09-.27zm29.928 7.97c-3.18 0-5.76 2.577-5.76 5.758 0 3.18 2.58 5.76 5.76 5.76 3.18 0 5.76-2.58 5.76-5.76 0-3.18-2.58-5.76-5.76-5.76zm-25.622 6.73c-13.613 0-24.65 11.037-24.65 24.65 0 13.613 11.037 24.645 24.65 24.645C79.617 90.645 90.65 79.613 90.65 66S79.616 41.35 66.003 41.35zm0 8.65c8.836 0 16 7.163 16 16 0 8.836-7.164 16-16 16-8.837 0-16-7.164-16-16 0-8.837 7.163-16 16-16z"})]})}function Hr({style:t,...r}){/*#__PURE__*/return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0,0,256,256",style:{height:"26px",width:"26px",...t},...r,children:/*#__PURE__*/e.jsx("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:/*#__PURE__*/e.jsx("g",{transform:"scale(5.12,5.12)",children:/*#__PURE__*/e.jsx("path",{d:"M41,4h-32c-2.76,0 -5,2.24 -5,5v32c0,2.76 2.24,5 5,5h32c2.76,0 5,-2.24 5,-5v-32c0,-2.76 -2.24,-5 -5,-5zM17,20v19h-6v-19zM11,14.47c0,-1.4 1.2,-2.47 3,-2.47c1.8,0 2.93,1.07 3,2.47c0,1.4 -1.12,2.53 -3,2.53c-1.8,0 -3,-1.13 -3,-2.53zM39,39h-6c0,0 0,-9.26 0,-10c0,-2 -1,-4 -3.5,-4.04h-0.08c-2.42,0 -3.42,2.06 -3.42,4.04c0,0.91 0,10 0,10h-6v-19h6v2.56c0,0 1.93,-2.56 5.81,-2.56c3.97,0 7.19,2.73 7.19,8.26z"})})})})}function Kr(t){/*#__PURE__*/return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...t,children:[/*#__PURE__*/e.jsx("path",{fill:"#1ed760",d:"M248 8C111.1 8 0 119.1 0 256s111.1 248 248 248 248-111.1 248-248S384.9 8 248 8Z"}),/*#__PURE__*/e.jsx("path",{d:"M406.6 231.1c-5.2 0-8.4-1.3-12.9-3.9-71.2-42.5-198.5-52.7-280.9-29.7-3.6 1-8.1 2.6-12.9 2.6-13.2 0-23.3-10.3-23.3-23.6 0-13.6 8.4-21.3 17.4-23.9 35.2-10.3 74.6-15.2 117.5-15.2 73 0 149.5 15.2 205.4 47.8 7.8 4.5 12.9 10.7 12.9 22.6 0 13.6-11 23.3-23.2 23.3zm-31 76.2c-5.2 0-8.7-2.3-12.3-4.2-62.5-37-155.7-51.9-238.6-29.4-4.8 1.3-7.4 2.6-11.9 2.6-10.7 0-19.4-8.7-19.4-19.4s5.2-17.8 15.5-20.7c27.8-7.8 56.2-13.6 97.8-13.6 64.9 0 127.6 16.1 177 45.5 8.1 4.8 11.3 11 11.3 19.7-.1 10.8-8.5 19.5-19.4 19.5zm-26.9 65.6c-4.2 0-6.8-1.3-10.7-3.6-62.4-37.6-135-39.2-206.7-24.5-3.9 1-9 2.6-11.9 2.6-9.7 0-15.8-7.7-15.8-15.8 0-10.3 6.1-15.2 13.6-16.8 81.9-18.1 165.6-16.5 237 26.2 6.1 3.9 9.7 7.4 9.7 16.5s-7.1 15.4-15.2 15.4z"})]})}function Zr(t){/*#__PURE__*/return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",imageRendering:"optimizeQuality",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",viewBox:"0 0 293768 333327",width:24,height:24,...t,children:[/*#__PURE__*/e.jsx("path",{fill:"#26f4ee",d:"M204958 0c5369 45832 32829 78170 77253 81022v43471l-287 27V87593c-44424-2850-69965-30183-75333-76015l-47060-1v192819c6791 86790-60835 89368-86703 56462 30342 18977 79608 6642 73766-68039V0h58365zM78515 319644c-26591-5471-50770-21358-64969-44588-34496-56437-3401-148418 96651-157884v54345l-164 27v-40773C17274 145544 7961 245185 33650 286633c9906 15984 26169 27227 44864 33011z"}),/*#__PURE__*/e.jsx("path",{fill:"#fb2c53",d:"M218434 11587c3505 29920 15609 55386 35948 70259-27522-10602-43651-34934-47791-70262l11843 3zm63489 82463c3786 804 7734 1348 11844 1611v51530c-25770 2537-48321-5946-74600-21749l4034 88251c0 28460 106 41467-15166 67648-34260 58734-95927 63376-137628 35401 54529 22502 137077-4810 136916-103049v-96320c26279 15803 48830 24286 74600 21748V94050zm-171890 37247c5390-1122 11048-1985 16998-2548v54345c-21666 3569-35427 10222-41862 22528-20267 38754 5827 69491 35017 74111-33931 5638-73721-28750-49999-74111 6434-12304 18180-18959 39846-22528v-51797zm64479-119719h1808-1808z"}),/*#__PURE__*/e.jsx("path",{d:"M206590 11578c5369 45832 30910 73164 75333 76015v51528c-25770 2539-48321-5945-74600-21748v96320c206 125717-135035 135283-173673 72939-25688-41449-16376-141089 76383-155862v52323c-21666 3569-33412 10224-39846 22528-39762 76035 98926 121273 89342-1225V11577l47060 1z",fill:"#000000"})]})}const Yr=({style:t,...r})=>/*#__PURE__*/e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",width:"24px",...t},...r,children:/*#__PURE__*/e.jsx("path",{d:"M 14.285156 10.171875 L 23.222656 0 L 21.105469 0 L 13.34375 8.832031 L 7.148438 0 L 0 0 L 9.371094 13.355469 L 0 24.019531 L 2.117188 24.019531 L 10.308594 14.691406 L 16.851562 24.019531 L 24 24.019531 M 2.878906 1.5625 L 6.132812 1.5625 L 21.101562 22.535156 L 17.851562 22.535156",fill:"currentColor"})});let Gr={google:{name:"Google",component:qr},discord:{name:"Discord",component:Br},github:{name:"Github",component:zr},linkedin:{name:"LinkedIn",component:Hr},twitter:{name:"Twitter",component:Yr},spotify:{name:"Spotify",component:Kr},instagram:{name:"Instagram",component:Vr},tiktok:{name:"Tiktok",component:Zr},apple:{name:"Apple",component:Dr}};const Jr=e=>e in Gr?Gr[e]:{name:"Unknown",component:$r};function Qr(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),r=e.get("privy_oauth_state"),n=e.get("privy_oauth_provider");if(!t||!r||!n)return{inProgress:!1};let a=!1;try{a=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:r,provider:n,withPrivyUi:!Mt.get(jr),popupFlow:null!==window.opener&&a,disableSignup:!!Mt.get(Er)}}function Xr(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),Mt.del(Cr),window.history.replaceState({},"",e)}class en{async initRegisterFlow(e){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");this.authenticateForRegistration=!0,this.meta.initRegisterResponse=await this.initRegisterOnce.execute(e)}async initAuthenticationFlow(e){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async register(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new o.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initRegisterResponse||(this.meta.initRegisterResponse=await this.initRegisterOnce.execute());try{let t=this.meta.initRegisterResponse.options,r=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(o.passkeyRegisterPath,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new o.PrivyClientError("Passkey request timed out or rejected by user.",void 0,o.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw o.formatApiError(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new o.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());let t=this.meta.allowedCredentialsIds?.map((e=>({type:"public-key",id:e})))??this.meta.initAuthenticateResponse.options.allow_credentials;try{let r=await e.startAuthentication(this._transformInitAuthenticateOptionsToCamelCase({...this.meta.initAuthenticateResponse.options,allow_credentials:t}));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(o.passkeyAuthenticatePath,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new o.PrivyClientError("Passkey request timed out or rejected by user.",void 0,o.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw o.formatApiError(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new o.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let t=this.meta.initLinkResponse.options,r=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(o.passkeyLinkPath,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new o.PrivyClientError("Passkey request timed out or rejected by user.",void 0,o.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw o.formatApiError(e)}}async _initRegisterOnce(e){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");let t=It(e);return await this.api.post(o.passkeyInitRegisterPath,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");let t=It(e);return await this.api.post(o.passkeyInitAuthenticatePath,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");return await this.api.post(o.passkeyInitLinkPath,{})}_transformInitLinkOptionsToCamelCase(e){return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params.map((e=>({type:e.type,alg:e.alg}))),timeout:e.timeout,excludeCredentials:e.exclude_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports}))),authenticatorSelection:{authenticatorAttachment:e.authenticator_selection?.authenticator_attachment,requireResidentKey:e.authenticator_selection?.require_resident_key,residentKey:e.authenticator_selection?.resident_key,userVerification:e.authenticator_selection?.user_verification},attestation:e.attestation,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props?.rk,hmacCreateSecret:e.extensions?.hmac_create_secret}}}_transformRegistrationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,attestation_object:e.response.attestationObject,authenticator_data:e.response.authenticatorData},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}_transformInitAuthenticateOptionsToCamelCase(e){return{rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}}_transformAuthenticationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}constructor({captchaToken:e,setPasskeyAuthState:t}){this.authenticateForRegistration=!1,this.initRegisterOnce=new ar(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new ar(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new ar(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t}}}const tn=({address:e,chainId:t,nonce:r})=>`${window.location.host} wants you to sign in with your Ethereum account:\n${e}\n\nBy signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: ${t}\nNonce: ${r}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`;class rn{get meta(){return{connectorType:this.wallet?.connectorType,walletClientType:this.wallet?.walletClientType,chainId:this.wallet?.chainId,address:this.wallet?.address,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new o.PrivyClientError("SiweFlow has no client instance");try{if(this.preparedMessage&&this.signature)return await this.client.authenticateWithSiweInternal({message:this.preparedMessage,signature:this.signature,chainId:this.wallet?.chainId,walletClientType:this.wallet?.walletClientType,connectorType:this.wallet?.connectorType,mode:this._meta.disableSignup?"no-signup":"login-or-sign-up"});if(!this.wallet)throw new o.PrivyClientError("SiweFlow has no wallet instance");let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw o.formatApiError(e)}}async link(){if(!this.client)throw new o.PrivyClientError("SiweFlow has no client instance");try{if(!this.wallet)throw new o.PrivyClientError("SiweFlow has no wallet instance");let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw o.formatApiError(e)}}async sign(){if(!this.client)throw new o.PrivyClientError("SiweFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new o.PrivyClientError("Could not prepare SIWE message");if(!this.wallet)throw new o.PrivyClientError("SiweFlow has no wallet instance");let e=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:e}}async _getNonceOnce(){if(!this.client)throw new o.PrivyClientError("SiweFlow has no client instance");if(!this.wallet)throw new o.PrivyClientError("UI SiweFlow has no wallet instance");return await this.client.generateSiweNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new o.PrivyClientError("SiweFlow has no client instance");if(!this.wallet)throw new o.PrivyClientError("SiweFlow has no wallet instance");let e=this.wallet.address,t=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=tn({address:e,chainId:t,nonce:this.nonce}),this.preparedMessage}constructor(e,t,r,n=!1,a){this._meta={disableSignup:!1},this.getNonceOnce=new ar(this._getNonceOnce.bind(this)),this.wallet=t,this.captchaToken=r,this.client=e,this._meta.disableSignup=n,this.preparedMessage=a?.message,this.signature=a?.signature}}const nn=(...e)=>{if("undefined"==typeof Buffer)throw new o.PrivyClientError("Buffer is not defined.",void 0,o.PrivyErrorCode.BUFFER_NOT_DEFINED);return Buffer.from(...e)},an=({address:e,nonce:t})=>`${window.location.host} wants you to sign in with your Solana account:\n${e}\n\n${`You are proving you own ${e}.`}\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: mainnet\nNonce: ${t}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`;class on{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,disableSignup:this._meta.disableSignup,messageType:this._meta.messageType}}set messageType(e){this._meta.messageType=e}async authenticate(){if(!this.client)throw new o.PrivyClientError("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up",messageType:this.meta.messageType})}catch(e){throw o.formatApiError(e)}}async link(){if(!this.client)throw new o.PrivyClientError("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,messageType:this.meta.messageType})}catch(e){throw o.formatApiError(e)}}async sign(){let e,t;if(!this.client)throw new o.PrivyClientError("SiwsFlow has no client instance");await this.buildMessage();let r="transaction"===this.meta.messageType;if(!this.preparedMessage)throw new o.PrivyClientError("Could not prepare SIWS message");if(!r&&!this.wallet.signMessage||r&&!this.wallet.signTransaction)throw new o.PrivyClientError("Wallet does not support the necessary signing methods");if(r&&this._siwsTransactionMethods){let r=await this.wallet.signTransaction(this._siwsTransactionMethods.deserializeTransactionFromB64String(this.preparedMessage));e=r.serialize().toString("base64"),t=nn(r.signatures[0]?.signature??Buffer.from("missing signature")).toString("base64")}else e=this.preparedMessage,t=nn(await this.wallet.signMessage(nn(this.preparedMessage))).toString("base64");return{message:e,signature:t}}async _getNonceOnce(){if(!this.client)throw new o.PrivyClientError("SiwsFlow has no client instance");return await this.client.generateSiwsNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new o.PrivyClientError("SiwsFlow has no client instance");let e=this.wallet.address;return this.nonce||(this.nonce=await this.getNonceOnce.execute()),"transaction"===this.meta.messageType&&this._siwsTransactionMethods?this.preparedMessage=this._siwsTransactionMethods.prepareSiwsTransactionWithMemo({address:e,nonce:this.nonce}):this.preparedMessage=an({address:e,nonce:this.nonce}),this.preparedMessage}constructor(e,t,r,n=!1,a="plain",i){this._meta={disableSignup:!1,messageType:"plain"},this.getNonceOnce=new ar(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=r,this.client=t,this._meta.disableSignup=n,this._meta.messageType=a,this._siwsTransactionMethods=i}}class sn{async authenticate(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new o.PrivyClientError("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(o.passwordlessSmsAuthenticatePath,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw o.formatApiError(e)}}async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new o.PrivyClientError("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(o.passwordlessSmsLinkPath,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw o.formatApiError(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:r}){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new o.PrivyClientError("phone nNumber must be set when initialzing authentication.");let n=It(r);try{return await this.api.post(o.passwordlessSmsInitPath,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...n}})}catch(e){throw o.formatApiError(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:r}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:r??!1}}}class ln extends sn{async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new o.PrivyClientError("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(o.updatePhonePath,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw o.formatApiError(e)}}constructor(e,t,r){super({phoneNumber:t,captchaToken:r}),this.meta={phoneNumber:t,captchaToken:r,oldPhoneNumber:e,disableSignup:!1}}}const cn=/*#__PURE__*/r.createContext({siteKey:"",enabled:!1,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:s.notImplemented,setError:s.notImplemented,setExecuting:s.notImplemented,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:s.notImplemented,reset:s.notImplemented,execute:s.notImplemented});class dn extends o.PrivyError{constructor(e,t,r){super(e||"Captcha failed"),this.type="Captcha",t instanceof Error&&(this.cause=t),this.privyErrorCode=r}}const un=({children:t,id:n,captchaSiteKey:a,captchaEnabled:i})=>{let s=r.useRef(null),[l,c]=r.useState(),[d,u]=r.useState(),[h,p]=r.useState(!1),y=r.useMemo((()=>i?h||l||d?!h||l||d?l&&!d?{status:"success",token:l}:d?{status:"error",error:d}:{status:"ready"}:{status:"loading"}:{status:"ready"}:{status:"disabled"}),[i,l,d,h]);/*#__PURE__*/return e.jsx(cn.Provider,{value:{...y,ref:s,enabled:i,siteKey:a,appId:n,setToken:c,setError:u,setExecuting:p,remove(){i&&(s.current?.remove(),p(!1),u(void 0),c(void 0))},reset(){i&&(s.current?.reset(),p(!1),u(void 0),c(void 0))},execute(){i&&(p(!0),s.current?.execute())},async waitForResult(){if(!i)return"";try{return await function(e,{interval:t=100,timeout:r=5e3}={}){return new Promise(((n,a)=>{let i,o=0,s=()=>{o>=r?a("Max attempts reached without result"):(i=e(),o+=t,null==i?setTimeout(s,t):n(i))};s()}))}((()=>s.current?.getResponse()),{interval:200,timeout:2e4})}catch(e){throw new dn("Captcha failed",null,o.PrivyErrorCode.CAPTCHA_TIMEOUT)}}},children:t})},hn=()=>r.useContext(cn);class pn{async authenticate(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(o.telegramAccountAuthenticatePath,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw o.formatApiError(e)}}async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(o.telegramAccountLinkPath,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw o.formatApiError(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function yn(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===o.PrivyErrorCode.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===o.PrivyErrorCode.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===o.PrivyErrorCode.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===o.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===o.PrivyErrorCode.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===o.PrivyErrorCode.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===o.PrivyErrorCode.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof dn&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t}function mn(e){return Object.fromEntries(decodeURIComponent(e).split("&").map((e=>e.split("=").map(decodeURIComponent))))}function gn(){let e=new URL(window.location.href);e.searchParams.delete("id"),e.searchParams.delete("hash"),e.searchParams.delete("auth_date"),e.searchParams.delete("first_name"),e.searchParams.delete("last_name"),e.searchParams.delete("username"),e.searchParams.delete("photo_url"),e.hash="",window.history.replaceState({},"",e)}class fn{static parse(e){try{return new fn(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return Ae.decodeJwt(e),e}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){return Date.now()>=1e3*(this.expiration-e)}constructor(e){this.value=e,this._decoded=Ae.decodeJwt(e)}}class wn extends fn{static parse(e){try{return new wn(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}let vn=e=>{if("ethereum"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier"};if("solana"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"solana-address-verifier"};throw Error("Failed to get account entropy details")};const xn=(e,t)=>{if(t?.imported)return vn(t);let r=u.getPrivyPrimaryWallet(e);if(!r)throw Error("Failed to find primary wallet");return vn(r)},Cn=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});class bn extends o.PrivyConnectorError{constructor(){super("Wallet timeout"),this.type="wallet_error"}}class jn extends o.PrivyConnectorError{constructor(){super("User rejected connection"),this.type="wallet_error"}}const En=e=>e instanceof o.PrivyConnectorError?e:e?.code?new Tn(e):new o.PrivyConnectorError("Unknown connector error",e);class kn extends o.PrivyError{constructor(e,t,r){super(e),this.type="provider_error",this.code=t,this.data=r}}class Tn extends kn{constructor(e){super(e.message,e.code,e.data);let t=Object.values(i.ProviderErrors).find((t=>t.eipCode===e.code));this.details=t||i.ProviderErrors.UNKNOWN_ERROR,-32002===e.code&&(e.message?.includes("already pending for origin")?e.message?.includes("wallet_requestPermissions")?this.details=i.ProviderErrors.E32002_CONNECTION_ALREADY_PENDING:this.details=i.ProviderErrors.E32002_REQUEST_ALREADY_PENDING:e.message?.includes("Already processing")&&e.message.includes("eth_requestAccounts")&&(this.details=i.ProviderErrors.E32002_WALLET_LOCKED))}}const An={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0},ERROR_USER_LIMIT_REACHED:{message:"Unable to link",detail:"You've reached the maximum number of linked wallets.",retryable:!1},...i.ProviderErrors};function In(e){return"ethereum"===e.type}function Sn(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){let n=e[r],a=t[r];if(n?.address!==a?.address||n&&a&&In(n)&&In(a)&&n?.chainId!==a?.chainId||n?.connectorType!==a?.connectorType||n?.connectedAt!==a?.connectedAt||n?.walletClientType!==a?.walletClientType||n?.isConnected!==a?.isConnected||n?.linked!==a?.linked)return!1}return!0}class Pn extends Ie.default{constructor(e){super(),this.walletClientType=e,this.connected=!1,this.initialized=!1}}const _n=(e,t)=>e.rpcTimeouts&&e.rpcTimeouts[t]||Ir;let Nn;function Mn(e){return"ethereum"===e.chainType}class Wn extends Pn{buildConnectedWallet(e,t,r,n){let i=async()=>!!this.wallets.find((t=>a.getAddress(t.address)===a.getAddress(e)));return{type:"ethereum",address:a.getAddress(e),chainId:t,meta:r,imported:n,switchChain:async r=>{let n,s;if(!i)throw new o.PrivyConnectorError("Wallet is not currently connected.");let l=this.wallets.find((t=>a.getAddress(t.address)===a.getAddress(e)))?.chainId;if(!l)throw new o.PrivyConnectorError("Unable to determine current chainId.");if("number"==typeof r?(n=`0x${r.toString(16)}`,s=r):(n=r,s=Number(r)),l===Zt(n))return;let c=this.chains.find((e=>e.id===s));if(!c)throw new o.PrivyConnectorError(`Unsupported chainId: ${r}`);let d=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:n}]})};try{return await d()}catch(e){if(((e,t)=>{switch(t){case"coinbase_wallet":return e.message.includes("addEthereumChain");case"rabby_wallet":return e.message.includes("Unrecognized chain ID");default:return 4902===e.code||e.message?.includes("4902")}})(e,this.walletClientType))return"rabby_wallet"===this.walletClientType&&await zt(300),await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:n,chainName:c.name,nativeCurrency:c.nativeCurrency,rpcUrls:[c.rpcUrls.default?.http[0]??""],blockExplorerUrls:[c.blockExplorers?.default.url??""]}]}),d();if("rainbow"===this.walletClientType&&e.message?.includes("wallet_switchEthereumChain"))throw new o.PrivyConnectorError(`Rainbow does not support the chainId ${t}`);throw e}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:i,getEthereumProvider:async()=>{if(!await i())throw new o.PrivyConnectorError("Wallet is not currently connected.");return this.proxyProvider},sign:async e=>{if(!await i())throw new o.PrivyConnectorError("Wallet is not currently connected.");return await this.sign(e)},disconnect:()=>{this.disconnect()}}}async syncAccounts(e){let t,r=e;try{if(void 0===r){let e=await $t((()=>this.proxyProvider.request({method:"eth_accounts"})),{maxAttempts:10,delayMs:500});console.debug(`eth_accounts for ${this.walletClientType}:`,e),Array.isArray(e)&&(r=e)}}catch(e){console.debug("Wallet did not respond to eth_accounts. Defaulting to prefetched accounts.",e)}if(!r||!Array.isArray(r)||r.length<=0||!r[0])return;let n=r[0],i=a.getAddress(n),o=[];if("privy"===this.walletClientType){let e=Mt.get(kr(i));this.chains.find((t=>t.id===Number(e)))||(Mt.del(kr(i)),e=null),t=e||`0x${this.defaultChain.id.toString(16)}`;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:t}]})}catch(e){console.warn(`Unable to switch embedded wallet to chain ID ${t} on initialization`)}}else try{let e=await $t((()=>this.proxyProvider.request({method:"eth_chainId"})),{maxAttempts:10,delayMs:500});if(console.debug(`eth_chainId for ${this.walletClientType}:`,e),"string"==typeof e)t=e;else{if("number"!=typeof e)throw Error("Invalid chainId returned from provider");t=`0x${e.toString(16)}`}}catch(e){console.warn("Failed to get chainId from provider, defaulting to 0x1",e),t="0x1"}let s=Zt(t);if(!o.find((e=>a.getAddress(e.address)===i))){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};o.push(this.buildConnectedWallet(a.getAddress(n),s,e,"embedded_imported"===this.connectorType))}Sn(o,this.wallets)||(this.wallets=o,this.emit("walletsUpdated"))}async getConnectedWallet(){let e=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt)).find((t=>e.find((e=>a.getAddress(e)===a.getAddress(t.address)))))||null}async isConnected(){let e=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(e)&&e.length>0}async sign(e){return await this.connect({showPrompt:!1}),this.proxyProvider.request({method:"personal_sign",params:[a.toHex(e),this.wallets[0]?.address]})}subscribeListeners(){this.proxyProvider.on("accountsChanged",this.onAccountsChanged),this.proxyProvider.on("chainChanged",this.onChainChanged),this.proxyProvider.on("disconnect",this.onDisconnect),this.proxyProvider.on("connect",this.onConnect)}unsubscribeListeners(){this.proxyProvider.removeListener("accountsChanged",this.onAccountsChanged),this.proxyProvider.removeListener("chainChanged",this.onChainChanged),this.proxyProvider.removeListener("disconnect",this.onDisconnect),this.proxyProvider.removeListener("connect",this.onConnect)}constructor(e,t,r,n){super(e),this.chainType="ethereum",this.onAccountsChanged=e=>{0===e.length?this.onDisconnect():this.syncAccounts(e)},this.onChainChanged=e=>{this.wallets.forEach((t=>{t.chainId=Zt(e),"privy"===this.walletClientType&&Mt.put(kr(t.address),e)})),this.emit("walletsUpdated")},this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")},this.onConnect=async()=>{this.connected=!0,"coinbase_wallet"===this.connectorType&&await zt(500),this.syncAccounts()},this.wallets=[],this.walletClientType=e,this.chains=t,this.defaultChain=r,this.rpcConfig=n,this.rpcTimeoutDuration=_n(n,e),this.connected=!1,this.initialized=!1}}class Un{on(e,t){if(this.walletProvider)return this.walletProvider.on(e,t);this._subscriptions.push({eventName:e,listener:t})}async request(e){if(!this.walletProvider)throw new o.PrivyConnectorError(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),this.walletTimeout()]).catch((e=>{throw En(e)}))}constructor(e,t){this.removeListener=(e,t)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(e,t)}catch(e){console.warn("Unable to remove wallet provider listener")}},this.walletTimeout=(e=new bn,t=this.rpcTimeoutDuration)=>new Promise(((r,n)=>setTimeout((()=>{n(e)}),t))),this.setWalletProvider=e=>{this.walletProvider&&this._subscriptions.forEach((e=>{this.removeListener(e.eventName,e.listener)})),this.walletProvider=e,this._subscriptions.forEach((e=>{this.walletProvider?.on(e.eventName,e.listener)}))},this.walletProvider=e,this.rpcTimeoutDuration=t||Ir,this._subscriptions=[]}}let On=[1,11155111,137,10,8453,84532,42161,7777777,43114,56];class Fn extends Wn{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PScwIDAgMTAyNCAxMDI0JyBmaWxsPSdub25lJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHN0eWxlPSdoZWlnaHQ6MjhweDt3aWR0aDoyOHB4Jz48cmVjdCB3aWR0aD0nMTAyNCcgaGVpZ2h0PScxMDI0JyBmaWxsPScjMDA1MkZGJyByeD0nMTAwJyByeT0nMTAwJz48L3JlY3Q+PHBhdGggZmlsbC1ydWxlPSdldmVub2RkJyBjbGlwLXJ1bGU9J2V2ZW5vZGQnIGQ9J00xNTIgNTEyQzE1MiA3MTAuODIzIDMxMy4xNzcgODcyIDUxMiA4NzJDNzEwLjgyMyA4NzIgODcyIDcxMC44MjMgODcyIDUxMkM4NzIgMzEzLjE3NyA3MTAuODIzIDE1MiA1MTIgMTUyQzMxMy4xNzcgMTUyIDE1MiAzMTMuMTc3IDE1MiA1MTJaTTQyMCAzOTZDNDA2Ljc0NSAzOTYgMzk2IDQwNi43NDUgMzk2IDQyMFY2MDRDMzk2IDYxNy4yNTUgNDA2Ljc0NSA2MjggNDIwIDYyOEg2MDRDNjE3LjI1NSA2MjggNjI4IDYxNy4yNTUgNjI4IDYwNFY0MjBDNjI4IDQwNi43NDUgNjE3LjI1NSAzOTYgNjA0IDM5Nkg0MjBaJyBmaWxsPSd3aGl0ZSc+PC9wYXRoPjwvc3ZnPg==",id:"com.coinbase.wallet"}}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new o.PrivyConnectorError("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw En(e)}}updateConnectionPreference(e){this.coinbaseWalletConfig={...this.coinbaseWalletConfig,preference:{...this.coinbaseWalletConfig.preference,options:e}},this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",Nn=p.createCoinbaseWalletSDK({...this.coinbaseWalletConfig}),this.proxyProvider.setWalletProvider(Nn.getProvider())}constructor(e,t,r,n){if(super("coinbase_wallet",e,t,r),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new Un(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.coinbaseWalletConfig={...n,appChainIds:[t.id].concat(e.map((e=>e.id)))},this.walletClientType="smartWalletOnly"===this.coinbaseWalletConfig.preference?.options?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!Nn){let e="eoaOnly"!==this.coinbaseWalletConfig.preference?.options?(this.coinbaseWalletConfig.appChainIds??[]).filter((e=>!On.includes(e))):[];e.length>0&&!e.every((e=>i.DEFAULT_SUPPORTED_CHAIN_IDS.has(e)))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${e.join(", ")}`),Nn=p.createCoinbaseWalletSDK(this.coinbaseWalletConfig)}this.proxyProvider.setWalletProvider(Nn.getProvider())}}const Rn=({...t})=>/*#__PURE__*/e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.37126 11.0323C2.37126 12.696 3.90598 13.4421 5.40654 13.4468C8.91753 13.4468 12.8021 11.2897 12.7819 7.67984C12.7673 5.07728 10.3748 2.86167 7.54357 2.88296C4.8495 2.88296 2.21821 4.6411 2.21803 7.03628C2.21803 7.67951 2.58722 8.30178 3.55231 8.37184C2.74763 9.16826 2.37126 10.1225 2.37126 11.0323ZM7.55283 8.68012C8.11562 8.68012 8.57186 8.13217 8.57186 7.45624C8.57186 6.78032 8.11562 6.23237 7.55283 6.23237C6.99003 6.23237 6.53379 6.78032 6.53379 7.45624C6.53379 8.13217 6.99003 8.68012 7.55283 8.68012ZM10.4747 8.68012C11.0375 8.68012 11.4937 8.13217 11.4937 7.45625C11.4937 6.78032 11.0375 6.23237 10.4747 6.23237C9.91186 6.23237 9.45562 6.78032 9.45562 7.45625C9.45562 8.13217 9.91186 8.68012 10.4747 8.68012Z",fill:t.color||"var(--privy-color-foreground-3)"})});class Ln extends Wn{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[Ht(e?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Rn,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}constructor({provider:e,chains:t,defaultChain:r,rpcConfig:n,imported:a,walletIndex:i}){super("privy",t,r,n),this.connectorType="embedded",this.proxyProvider=e,this.walletIndex=i,a&&(this.connectorType="embedded_imported"),this.subscribeListeners()}}const Dn=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];class Bn extends Error{constructor(e,t,r){super(e),this.code=t,this.data=r}}class zn extends Ie.default{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new Bn(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await yv()||!this.address)throw new Bn("Disconnected",4900);let{hash:r}=await wv(t,{address:this.address});return r}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new Bn(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await yv()||!this.address)throw new Bn("Disconnected",4900);let{signature:r}=await fv(t,{address:this.address});return r}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new Bn(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new Bn(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=Ft(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",t)}async handlePersonalSign(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for personal_sign");let t=e.params[0],r=e.params[1],{signature:n}=await mv({message:t},{address:r});return n}async handleSignedTypedData(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_signTypedData_v4");let t=e.params[0],r="string"==typeof e.params[1]?JSON.parse(e.params[1]):e.params[1],{signature:n}=await gv(Gt(r),{address:t});return n}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");delete e.params[0].gasPrice,delete e.params[0].maxFeePerGas,delete e.params[0].maxPriorityFeePerGas;let t={...e.params[0],chainId:Ht(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...y.toViemTransactionSerializable(t)})}async request(e){switch(console.debug("Embedded1193Provider.request() called with args",e),e.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return Ht(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_sendTransaction":return this.handleSendTransaction(e);case"eth_signTransaction":return this.handleSignTransaction(e);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"personal_sign":return this.handlePersonalSign(e);case"eth_signTypedData_v4":return this.handleSignedTypedData(e)}if(!(e=>Dn.includes(e))(e.method))return this.publicClient.request({method:e.method,params:e.params});{let t=await yv();if(await vv({address:this.address}),!t||!this.address)throw new Bn("Disconnected",4900);try{let r={method:e.method,params:e.params},n=this.walletAccount;return n&&u.getIsUnifiedWallet(n)?this.handleWalletApiRequest(r,n,t):(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:r})).response.data}catch(e){throw console.error(e),new Bn("Disconnected",4900)}}}async handleWalletApiRequest(e,t,r){let n=this.privyClient;if(!n)throw new Bn("Disconnected",4900);if("secp256k1_sign"===e.method){let a=await i.rpc(n,(async({message:e})=>this.walletProxy.signWithUserSigner({accessToken:r,message:e})),{chain_type:"ethereum",method:"secp256k1_sign",wallet_id:t.id,params:{hash:e.params[0]}});if("secp256k1_sign"!==a.method)throw new Bn(`Invalid params for ${e.method}`,4200);return a.data.signature}throw new Bn(`Method not supported: ${e.method}`,4200)}constructor({walletProxy:e,address:t,entropyId:r,entropyIdVerifier:n,rpcConfig:a,chains:i,appId:o,chainId:s=1,walletIndex:l,privyClient:c,walletAccount:d}){super(),this.walletProxy=e,this.address=t,this.entropyId=r,this.entropyIdVerifier=n,this.chainId=s,this.rpcConfig=a,this.chains=i,this.publicClient=Ft(s,this.chains,a,{appId:o}),this.rpcTimeoutDuration=_n(a,"privy"),this.appId=o,this.walletIndex=l,this.privyClient=c,this.walletAccount=d}}class $n extends Wn{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the EthereumNullConnector")}disconnect(){throw Error("disconnect called for an uninstalled wallet via the EthereumNullConnector")}promptConnection(e){throw Error(`promptConnection called for an uninstalled wallet via the EthereumNullConnector for ${e}`)}constructor({id:e,name:t,icon:r,walletClientType:n,defaultChain:a}){super(n,[],a,{}),this.connectorType="null",this.proxyProvider=new Un(void 0,Ir),this.id=e,this.name=t,this.icon=r,this.connectorType=n}}const qn=({style:t,...r})=>/*#__PURE__*/e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...t},...r,children:/*#__PURE__*/e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0V12a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 12V5.25"})}),Vn=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",x:0,y:0,viewBox:"0 0 318.6 318.6",width:"28",height:"28",style:{height:"28px",width:"28px",...t},...r,children:[/*#__PURE__*/e.jsx("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),/*#__PURE__*/e.jsx("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),/*#__PURE__*/e.jsx("path",{d:"m44.4 35.5 98.7 74.6-17.5-44.3zm193.9 171.3-26.5 40.6 56.7 15.6 16.3-55.3zm-204.4.9L50.1 263l56.7-15.6-26.5-40.6z",className:"s1 s2"}),/*#__PURE__*/e.jsx("path",{d:"m103.6 138.2-15.8 23.9 56.3 2.5-2-60.5zm111.3 0-39-34.8-1.3 61.2 56.2-2.5zM106.8 247.4l33.8-16.5-29.2-22.8zm71.1-16.5 33.9 16.5-4.7-39.3z",className:"s1 s2"}),/*#__PURE__*/e.jsx("path",{fill:"#d7c1b3",stroke:"#d7c1b3",className:"s1",d:"m211.8 247.4-33.9-16.5 2.7 22.1-.3 9.3zm-105 0 31.5 14.9-.2-9.3 2.5-22.1z"}),/*#__PURE__*/e.jsx("path",{fill:"#233447",stroke:"#233447",className:"s1",d:"m138.8 193.5-28.2-8.3 19.9-9.1zm40.9 0 8.3-17.4 20 9.1z"}),/*#__PURE__*/e.jsx("path",{fill:"#cd6116",stroke:"#cd6116",className:"s1",d:"m106.8 247.4 4.8-40.6-31.3.9zM207 206.8l4.8 40.6 26.5-39.7zm23.8-44.7-56.2 2.5 5.2 28.9 8.3-17.4 20 9.1zm-120.2 23.1 20-9.1 8.2 17.4 5.3-28.9-56.3-2.5z"}),/*#__PURE__*/e.jsx("path",{fill:"#e4751f",stroke:"#e4751f",className:"s1",d:"m87.8 162.1 23.6 46-.8-22.9zm120.3 23.1-1 22.9 23.7-46zm-64-20.6-5.3 28.9 6.6 34.1 1.5-44.9zm30.5 0-2.7 18 1.2 45 6.7-34.1z"}),/*#__PURE__*/e.jsx("path",{d:"m179.8 193.5-6.7 34.1 4.8 3.3 29.2-22.8 1-22.9zm-69.2-8.3.8 22.9 29.2 22.8 4.8-3.3-6.6-34.1z",className:"s3"}),/*#__PURE__*/e.jsx("path",{fill:"#c0ad9e",stroke:"#c0ad9e",className:"s1",d:"m180.3 262.3.3-9.3-2.5-2.2h-37.7l-2.3 2.2.2 9.3-31.5-14.9 11 9 22.3 15.5h38.3l22.4-15.5 11-9z"}),/*#__PURE__*/e.jsx("path",{fill:"#161616",stroke:"#161616",className:"s1",d:"m177.9 230.9-4.8-3.3h-27.7l-4.8 3.3-2.5 22.1 2.3-2.2h37.7l2.5 2.2z"}),/*#__PURE__*/e.jsx("path",{fill:"#763d16",stroke:"#763d16",className:"s1",d:"m278.3 114.2 8.5-40.8-12.7-37.9-96.2 71.4 37 31.3 52.3 15.3 11.6-13.5-5-3.6 8-7.3-6.2-4.8 8-6.1zM31.8 73.4l8.5 40.8-5.4 4 8 6.1-6.1 4.8 8 7.3-5 3.6 11.5 13.5 52.3-15.3 37-31.3-96.2-71.4z"}),/*#__PURE__*/e.jsx("path",{d:"m267.2 153.5-52.3-15.3 15.9 23.9-23.7 46 31.2-.4h46.5zm-163.6-15.3-52.3 15.3-17.4 54.2h46.4l31.1.4-23.6-46zm71 26.4 3.3-57.7 15.2-41.1h-67.5l15 41.1 3.5 57.7 1.2 18.2.1 44.8h27.7l.2-44.8z",className:"s3"})]}),Hn=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M46.5267 69.9229C42.0054 76.8509 34.4292 85.6182 24.348 85.6182C19.5824 85.6182 15 83.6563 15 75.1342C15 53.4305 44.6326 19.8327 72.1268 19.8327C87.768 19.8327 94 30.6846 94 43.0079C94 58.8258 83.7355 76.9122 73.5321 76.9122C70.2939 76.9122 68.7053 75.1342 68.7053 72.314C68.7053 71.5783 68.8275 70.7812 69.0719 69.9229C65.5893 75.8699 58.8685 81.3878 52.5754 81.3878C47.993 81.3878 45.6713 78.5063 45.6713 74.4598C45.6713 72.9884 45.9768 71.4556 46.5267 69.9229ZM83.6761 42.5794C83.6761 46.1704 81.5575 47.9658 79.1875 47.9658C76.7816 47.9658 74.6989 46.1704 74.6989 42.5794C74.6989 38.9885 76.7816 37.1931 79.1875 37.1931C81.5575 37.1931 83.6761 38.9885 83.6761 42.5794ZM70.2103 42.5795C70.2103 46.1704 68.0916 47.9658 65.7216 47.9658C63.3157 47.9658 61.233 46.1704 61.233 42.5795C61.233 38.9885 63.3157 37.1931 65.7216 37.1931C68.0916 37.1931 70.2103 38.9885 70.2103 42.5795Z",fill:"#FFFDF8"})]});function Kn(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var Zn=0;class Yn extends Wn{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:this.providerDetail.info.name,icon:this.providerDetail.info.icon,id:this.providerDetail.info.rdns}}disconnect(){console.warn(`Programmatic disconnect with ${this.providerDetail.info.name} is not yet supported.`)}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new o.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw En(e)}}constructor(e,t,r,n,a){super(a||"unknown",e,t,r),this.connectorType="injected",this.proxyProvider=new Un(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=n;let i=n.provider;this.proxyProvider.setWalletProvider(i)}}var Gn="__private_"+Zn+++"__walletBranding";class Jn extends Wn{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return Kn(this,Gn)[Gn]??{name:"Browser Extension",icon:qn,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new o.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw En(e)}}constructor(e,t,r,n,a){super(a??"unknown",e,t,r),Object.defineProperty(this,Gn,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new Un(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(n),"metamask"===a?Kn(this,Gn)[Gn]={name:"MetaMask",icon:Vn,id:"io.metamask"}:"phantom"===a&&(Kn(this,Gn)[Gn]={name:"Phantom",icon:Hn,id:"phantom"})}}class Qn extends Yn{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{n.isMobile||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new o.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw En(e)}}}const Xn=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","crypto.com_wallet_extension","crypto.com_onchain","binance","coinbase_wallet","coinbase_smart_wallet","metamask","trust","safe","rainbow","uniswap","zerion","argent","spot","omni","cryptocom","blockchain","safepal","bitkeep","zengo","1inch","binance","exodus","mew_wallet","alphawallet","keyring_pro","mathwallet","unstoppable","obvious","ambire","internet_money_wallet","coin98","abc_wallet","arculus_wallet","haha","cling_wallet","broearn","copiosa","burrito_wallet","enjin_wallet","plasma_wallet","avacus","bee","pitaka","pltwallet","minerva","kryptogo","prema","slingshot","kriptonio","timeless","secux","bitizen","blocto","okx_wallet","safemoon","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","privy","unknown","phantom","solflare","glow","backpack"],ea=Object.freeze({phantom:{client:"phantom",name:"Phantom",installLink:ke.isFirefox?"https://addons.mozilla.org/en-US/firefox/addon/phantom-app/":"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en",chainTypes:["ethereum","solana"],get isInstalled(){if("phantom"in window){let e=window;if(e?.phantom?.ethereum?.isPhantom&&e?.phantom?.ethereum?.chainId||e?.phantom?.solana?.isPhantom)return!0}return!1},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=ra({client:this.client,isSolana:t,connectOnly:r});return`${e?"phantom://":"https://phantom.app/ul/"}browse/${n}?ref=${n}`}},solflare:{client:"solflare",name:"Solflare",installLink:ke.isFirefox?"https://addons.mozilla.org/es/firefox/addon/solflare-wallet/":"https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic",chainTypes:["solana"],get isInstalled(){return"solflare"in window&&!!window?.solflare?.isSolflare},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=ra({client:this.client,isSolana:t,connectOnly:r});return`${e?"solflare://ul/v1/":"https://solflare.com/ul/v1/"}browse/${n}?ref=${n}`}},backpack:{client:"backpack",name:"Backpack",installLink:"https://chromewebstore.google.com/detail/backpack/aflkmfhebedbjioipglgcbcmnbpgliof",chainTypes:["ethereum","solana"],get isInstalled(){return!(!("backpack"in window)||!window?.backpack?.ethereum?.isBackpack&&!window?.backpack?.solana?.isBackpack)},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=ra({client:this.client,isSolana:t,connectOnly:r});return`${e?"backpack://ul/v1/":"https://backpack.com/ul/v1/"}browse/${n}?ref=${n}`}},okx_wallet:{client:"okx_wallet",name:"OKX Wallet",installLink:"https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",chainTypes:["solana"],get isInstalled(){return"okxwallet"in window&&!!window?.okxwallet?.isOkxWallet},getMobileRedirect({isSolana:e,connectOnly:t}){return"https://www.okx.com/download?deeplink="+encodeURIComponent("okx://wallet/dapp/url?dappUrl="+ra({client:this.client,isSolana:e,connectOnly:t}))}}});function ta({connectorType:e,walletClientType:t}){for(let r of Xn)if(e===r||t===r)return ea[r]}function ra({client:e,isSolana:t,connectOnly:r}){let n=new URL(window.location.href);return n.searchParams.set("privy_connector",t?"solana_adapter":"injected"),n.searchParams.set("privy_wallet_client",e),n.searchParams.set("privy_connect_only",String(r)),encodeURIComponent(n.href.replace(/\/$/g,""))}const na=()=>{let e=Mt.get(Ar);return e&&Array.isArray(e)&&e.map((e=>(e=>e&&"string"==typeof e.address&&"string"==typeof e.connectorType&&"string"==typeof e.walletClientType&&"number"==typeof e.connectedAt)(e))).every(Boolean)?e:[]};let aa=["phantom","glow","solflare","backpack","okx_wallet","walletconnect"];function ia(e){return"solana"===e.chainType}function oa(e){return"solana"===e.type}class sa extends Pn{get isInstalled(){return"Installed"===this.adapter.readyState}get wallet(){return this.adapter.wallet}buildConnectedWallet(e,t){let r,n,a,i;if("Installed"!==e.readyState||!e.publicKey)throw Error("Wallet is not connected.");return"signMessage"in e&&(r=async(...t)=>{if(!e.connected)throw Error("Wallet is not connected.");return await e.signMessage(t[0])}),"sendTransaction"in e&&(n=async(...t)=>await e.sendTransaction(t[0],t[1],t[2])),"signTransaction"in e&&(a=async t=>await e.signTransaction(t)),"signAllTransactions"in e&&(i=async t=>await e.signAllTransactions(t)),{type:"solana",address:e.publicKey.toBase58(),meta:t,imported:!1,connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:async()=>e.connected,disconnect:()=>{try{e.disconnect()}catch(e){console.error("Wallet does not support programmatic disconnect")}},getProvider:s.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'getProvider'`),signMessage:r??s.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'signMessage'`),sendTransaction:n??s.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'sendTransaction'`),signTransaction:a??s.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'signTransaction'`),signAllTransactions:i??s.notImplementedWithMessage(`${this.walletClientType||""} wallet does not support 'signAllTransactions'`)}}async syncAccounts(){if("Installed"===this.adapter.readyState&&this.adapter.publicKey){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};this.wallets.find((e=>this.adapter.publicKey&&e.address===this.adapter.publicKey.toBase58()))||(this.wallets=[this.buildConnectedWallet(this.adapter,e)],this.emit("walletsUpdated"))}else this.wallets.length>0&&(this.wallets=[],this.emit("walletsUpdated"))}get walletBranding(){return{id:this.adapter.name,name:this.adapter.name,icon:this.adapter.icon}}async initialize(){this.subscribeListeners(),await this.syncAccounts(),this.shouldAttemptAutoConnect()&&await this.adapter.autoConnect().catch((()=>{})),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}async getConnectedWallet(){return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt))[0]||null}async isConnected(){return this.adapter.connected&&["Installed"].includes(this.adapter.readyState)}subscribeListeners(){this.adapter.addListener("disconnect",this.onDisconnect),this.adapter.addListener("connect",this.onConnect),this.adapter.addListener("error",this.onError),this.adapter.addListener("readyStateChange",this.onReadyStateChange)}unsubscribeListeners(){this.adapter.removeAllListeners()}shouldAttemptAutoConnect(){return!(!this.autoConnectEnabled||!aa.includes(this.walletClientType))&&("phantom"!==this.walletClientType||na().some((({walletClientType:e})=>"phantom"===e)))}constructor(e,t){super(function(e){return e.name.toLowerCase().split(" ").join("_")}(e)),this.chainType="solana",this.connectorType="solana_adapter",this.disconnect=()=>{this.adapter.disconnect().then((()=>this.onDisconnect())).catch((e=>console.error("Error disconnecting",e)))},this.promptConnection=async()=>{try{await this.adapter.connect()}catch(e){throw En(e)}},this.onDisconnect=()=>{this.syncAccounts()},this.onConnect=e=>{this.syncAccounts()},this.onError=e=>{this.syncAccounts()},this.onReadyStateChange=e=>{"Installed"!==e&&(this.connected=!1),this.syncAccounts()},this.adapter=e,this.autoConnectEnabled=t,this.wallets=[]}}class la extends sa{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the SolanaNullConnector")}constructor({id:e,name:t,icon:r}){super({name:t},!1),this.connectorType="null",this.proxyProvider=new Un(void 0,Ir),this.disconnect=async()=>{throw Error("disconnect called for an uninstalled wallet via the SolanaNullConnector")},this.promptConnection=async()=>{throw Error("promptConnection called for an uninstalled wallet via the SolanaNullConnector")},this.id=e,this.name=t,this.icon=r}}const ca=P.create((()=>({listings:[]}))),da=ca.setState,ua=e=>{let t;try{t=new URL(e).hostname}catch(e){return}return ca.getState().listings.find((({homepage:e})=>{let r;try{r=new URL(e).hostname}catch(e){return!1}return t.includes(r)}))},ha=e=>ca((({listings:t})=>t.find((({slug:t})=>pa(t)===pa(e)))));function pa(e){return"cryptocom"===e?"cryptocom-defi":"binance"===e?"binance-defi":e.replace(/[-_]wallet$/,"")}function ya({src:t,...r}){/*#__PURE__*/return e.jsx("img",{src:t,...r,style:{display:"none"}})}const ma={appearance:{landingHeader:"Log in or sign up",theme:"light",accentColor:"#676FFF",walletList:["detected_wallets","metamask","coinbase_wallet","rainbow","wallet_connect"]},walletConnectCloudProjectId:"34357d3c125c2bcf2ce2bc3309d98715",externalWallets:{coinbaseWallet:{connectionOptions:"all"}},embeddedWallets:{extendedCalldataDecoding:!1},captchaEnabled:!1,_render:{standalone:!1},fundingMethodConfig:{moonpay:{useSandbox:!1}}};let ga=new Set(["coinbase_wallet","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","universal_profile","bybit_wallet","ronin_wallet","haha_wallet","wallet_connect","detected_wallets","detected_solana_wallets","detected_ethereum_wallets","rabby_wallet","safe","solflare","backpack","binance"]),fa=e=>ga.has(e),wa=(e,t,r)=>r.indexOf(e)===t;const va=792703809,xa="11111111111111111111111111111111";function Ca(e){return e.includes("testnet")?"testnet":e.includes("devnet")?"devnet":"mainnet-beta"}function ba(e,t){return`https://explorer.solana.com/account/${e}?cluster=${t}`}let ja="#FFFFFF";function Ea(e,t){let r=Math.max(0,Math.min(1,e.toHsl().l+t));return Se.default({...e.toHsl(),l:r})}function ka({backgroundTheme:e,accentHex:t}){let r;switch(e){case"light":r=ja;break;case"dark":r="#1E1E1D";break;default:r=e}let n=Se.default(r),a=Se.default(t),i=Se.default("#51BA81"),o=Se.default("#FFB74D"),s=Se.default("#EC6351"),l=function(e){return e<.8&&e>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),e>.5?"light":"dark"}(n.getLuminance()),c=Ea(n,"light"===l?-.04:.11),d=Ea(n,"light"===l?-.08:.16),u=Ea(n,"light"===l?-.88:.87),h=Ea(n,"light"===l?-.7:.75),p=Ea(n,"light"===l?-.43:.45).desaturate("light"===l?60:20),y=Ea(n,"light"===l?-.08:.25).desaturate("light"===l?60:20),m=Ea(a,.15),g=Ea(a,.25),f=Ea(a,-.06),w=Ea(a,-.6),v=Ea(s,.3),x=Ea(o,.3),C=Se.default(a.getLuminance()>.5?"#040217":ja),b=Ea(i,-.16),j=Ea(i,.4);return{colorScheme:l,background:n.toHslString(),background2:c.toHslString(),background3:d.toHslString(),foreground:u.toHslString(),foreground2:h.toHslString(),foreground3:p.toHslString(),foreground4:y.toHslString(),accent:a.toHslString(),accentLight:m.toHslString(),accentLightest:g.toHslString(),accentDark:f.toHslString(),accentDarkest:w.toHslString(),foregroundAccent:C.toHslString(),success:i.toHslString(),successDark:b.toHslString(),successLight:j.toHslString(),error:s.toHslString(),errorLight:v.toHslString(),warn:o.toHslString(),warnLight:x.toHslString()}}function Ta(e,t,r,n){let a,o,s,l,c,d,u,h,p,y,m,g,f,w,v,x=r?console.warn:()=>{};t?.loginMethods?(a=t.loginMethods.includes("email"),o=t.loginMethods.includes("sms"),l=t.loginMethods.includes("wallet"),c=t.loginMethods.includes("google"),d=t.loginMethods.includes("twitter"),u=t.loginMethods.includes("discord"),p=t.loginMethods.includes("spotify"),y=t.loginMethods.includes("instagram"),h=t.loginMethods.includes("tiktok"),g=t.loginMethods.includes("github"),m=t.loginMethods.includes("linkedin"),f=t.loginMethods.includes("apple"),w=t.loginMethods.includes("farcaster"),v=t.loginMethods.includes("telegram"),s=t.loginMethods.includes("passkey")):(a=e.email_auth,o=e.sms_auth,l=e.wallet_auth||e.solana_wallet_auth,c=e.google_oauth,d=e.twitter_oauth,u=e.discord_oauth,g=e.github_oauth,p=e.spotify_oauth,y=e.instagram_oauth,h=e.tiktok_oauth,m=e.linkedin_oauth,f=e.apple_oauth,w=e.farcaster_auth,v=e.telegram_auth,s=e.passkey_auth),e.passkey_auth&&(s=!0),"undefined"!=typeof window&&"function"!=typeof window.PublicKeyCredential&&(s=!1);let C=[a,o].filter(Boolean),b=[c,d,u,g,p,y,h,m,f,w,v].filter(Boolean),j=[l].filter(Boolean),E=t?.loginMethods?.includes("passkey")??!1,k=e.passkeys_for_signup_enabled??!1,T=[s&&(k||E)].filter(Boolean);if(C.length+b.length+j.length+T.length===0)throw Error("You must enable at least one login method");let A=void 0!==t?.appearance?.showWalletLoginFirst?t?.appearance?.showWalletLoginFirst:e.show_wallet_login_first;A&&0===j.length?(x("You should only enable `showWalletLoginFirst` when `wallet` logins are also enabled. `showWalletLoginFirst` has been set to false"),A=!1):A||b.length+C.length!==0||(x("You should only disable `showWalletLoginFirst` when `email`, `sms`, or social logins are also enabled. `showWalletLoginFirst` has been set to true"),A=!0);let I=t?.externalWallets?.walletConnect?.enabled??!0;t?.loginMethods&&t.loginMethodsAndOrder&&x("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let S=(({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(fa).filter(wa):e?e.filter(fa).filter(wa):ma.appearance.walletList)({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),P=(({input:e})=>{if(!e||!e.primary[0])return;let t=[e.primary[0]],r=[];for(let r of(e.primary.length>4&&console.warn("You should not specify greater than 4 login methods in `loginMethodsAndOrder.primary`"),e.primary.slice(1)))t.includes(r)?console.warn(`Duplicated login method: ${r}`):t.push(r);for(let n of e.overflow??[])t.includes(n)||r.includes(n)?console.warn(`Duplicated login method: ${n}`):r.push(n);return{primary:t,overflow:r}})({input:t?.loginMethodsAndOrder}),_=t?.intl?.defaultCountry??"US",{chains:N,defaultChain:M}=function({supportedChains:e,defaultChainFromConfig:t}){let r;if(e){if(0===e.length)throw Error("`supportedChains` must contain at least one chain");r=i.dedupeSupportedChains(e)}else r=[...i.DEFAULT_SUPPORTED_CHAINS];let n=e?r[0]:i.mainnet,a=t??n;if(!r.find((e=>e.id===a.id)))throw Error("`defaultChain` must be included in `supportedChains`");return{chains:r,defaultChain:a}}({supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain}),W=!!t?.defaultChain,U=t?.customAuth?.getCustomAccessToken&&!1!==t?.customAuth?.enabled,O=t?.embeddedWallets?.requireUserPasswordOnCreate,F=t?.embeddedWallets?.createOnLogin,R=U?"all-users":e.embedded_wallet_config.ethereum.create_on_login,L=e.embedded_wallet_config.solana.create_on_login,D={"mainnet-beta":{rpcUrl:"https://api.mainnet-beta.solana.com",blockExplorerUrl:"https://explorer.solana.com"},testnet:{rpcUrl:"https://api.testnet.solana.com",blockExplorerUrl:"https://explorer.solana.com/?cluster=testnet"},devnet:{rpcUrl:"https://api.devnet.solana.com",blockExplorerUrl:"https://explorer.solana.com/?cluster=devnet"}};if(t?.solanaClusters)for(let e of t.solanaClusters){let{name:t,rpcUrl:r,blockExplorerUrl:n}=e;D[t]={rpcUrl:r??D[t].rpcUrl,blockExplorerUrl:n??D[t].blockExplorerUrl}}e.solana_wallet_auth&&!t?.externalWallets?.solana?.connectors&&console.warn("App configuration has Solana wallet login enabled, but no Solana wallet connectors have been passed to Privy. Make sure to pass Solana connectors to the `config.externalWallets.solana.connectors` field of the `PrivyProvider`");let B=e.telegram_auth_config?{botId:e.telegram_auth_config.bot_id,botName:e.telegram_auth_config.bot_name,linkEnabled:e.telegram_auth_config.link_enabled,seamlessAuthEnabled:e.telegram_auth_config.seamless_auth_enabled}:void 0,z=e.funding_config?{methods:e.funding_config.methods,options:e.funding_config.options,defaultRecommendedAmount:e.funding_config.default_recommended_amount,defaultRecommendedCurrency:e.funding_config.default_recommended_currency,promptFundingOnWalletCreation:e.funding_config.prompt_funding_on_wallet_creation,crossChainBridgingEnabled:e.funding_config.cross_chain_bridging_enabled}:void 0;return{id:e.id,name:e.name,allowlistConfig:{errorTitle:e.allowlist_config.error_title,errorDetail:e.allowlist_config.error_detail,errorCtaText:e.allowlist_config.cta_text,errorCtaLink:e.allowlist_config.cta_link},legacyWalletUiConfig:e.legacy_wallet_ui_config,appearance:{logo:t?.appearance?.logo??e.logo_url??void 0,landingHeader:t?.appearance?.landingHeader??ma.appearance.landingHeader,loginMessage:"string"==typeof t?.appearance?.loginMessage?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,footerLogo:t?.appearance?.footerLogo,palette:ka({backgroundTheme:t?.appearance?.theme??ma.appearance.theme,accentHex:t?.appearance?.accentColor??e.accent_color??ma.appearance.accentColor}),loginGroupPriority:A?"web3-first":"web2-first",hideDirectWeb2Inputs:!!t?.appearance?.hideDirectWeb2Inputs,walletList:S,walletChainType:t?.appearance?.walletChainType??(({evmWalletAuth:e,solanaWalletAuth:t})=>e&&t?"ethereum-and-solana":e?"ethereum-only":t?"solana-only":"ethereum-only")({evmWalletAuth:e.wallet_auth??!1,solanaWalletAuth:e.solana_wallet_auth??!1})},loginMethods:{wallet:l,email:a,sms:o,passkey:s,google:c,twitter:d,discord:u,github:g,spotify:p,instagram:y,tiktok:h,linkedin:m,apple:f,farcaster:w,telegram:v},disablePlusEmails:e.disable_plus_emails,loginMethodsAndOrder:P,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.terms_and_conditions_url,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacy_policy_url,requireUsersAcceptTerms:e.require_users_accept_terms??!1},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.wallet_connect_cloud_project_id??ma.walletConnectCloudProjectId,rpcConfig:{rpcUrls:{},rpcTimeouts:t?.externalWallets?.signatureRequestTimeouts??{}},chains:N,solanaClusters:D,defaultChain:M,intl:{defaultCountry:_},shouldEnforceDefaultChainOnConnect:W,captchaEnabled:e.captcha_enabled??ma.captchaEnabled,captchaSiteKey:e.captcha_site_key,externalWallets:{coinbaseWallet:{config:{appName:e.name,appLogoUrl:e.logo_url,preference:{options:t?.externalWallets?.coinbaseWallet?.connectionOptions??ma.externalWallets.coinbaseWallet.connectionOptions,...t?.externalWallets?.coinbaseWallet?.config?.preference},...t?.externalWallets?.coinbaseWallet?.config}},walletConnect:{enabled:I,appKit:t?.externalWallets?.walletConnect?.appKit},solana:{connectors:t?.externalWallets?.solana?.connectors},disableAllExternalWallets:t?.externalWallets?.disableAllExternalWallets??!1},embeddedWallets:{requireUserOwnedRecoveryOnCreate:O??(!U&&(e.embedded_wallet_config.require_user_owned_recovery_on_create??!1)),userOwnedRecoveryOptions:U?["user-passcode"]:e.embedded_wallet_config.user_owned_recovery_options,priceDisplay:t?.embeddedWallets?.priceDisplay??{primary:"fiat-currency",secondary:"native-token"},ethereum:{createOnLogin:F??t?.embeddedWallets?.ethereum?.createOnLogin??R},solana:{createOnLogin:t?.embeddedWallets?.solana?.createOnLogin??L},mode:e.embedded_wallet_config.mode,showWalletUIs:t?.embeddedWallets?.showWalletUIs??e.enforce_wallet_uis??!0,extendedCalldataDecoding:t?.embeddedWallets?.extendedCalldataDecoding??!1,transactionScanning:{enabled:t?.embeddedWallets?.transactionScanning?.enabled??!1,domain:t?.embeddedWallets?.transactionScanning?.domain??n??"https://auth.privy.io"}},mfa:{methods:e.mfa_methods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},passkeys:{shouldUnlinkOnUnenrollMfa:t?.passkeys?.shouldUnlinkOnUnenrollMfa,shouldUnenrollMfaOnUnlink:t?.passkeys?.shouldUnenrollMfaOnUnlink},customAuth:U?{enabled:!0,...t.customAuth}:void 0,loginConfig:{telegramAuthConfiguration:B,passkeysForSignupEnabled:e.passkeys_for_signup_enabled},headless:!!t?.headless,render:{standalone:t?._render?.standalone??ma._render.standalone},fundingConfig:z,fundingMethodConfig:{...t?.fundingMethodConfig??ma.fundingMethodConfig,moonpay:{...t?.fundingMethodConfig?.moonpay??ma.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??t?.fiatOnRamp?.useSandbox??ma.fundingMethodConfig.moonpay.useSandbox}},whatsAppEnabled:!!e.whatsapp_enabled}}const Aa={show_wallet_login_first:!0,allowlist_config:{error_title:null,error_detail:null,cta_text:null,cta_link:null},wallet_auth:!0,email_auth:!0,sms_auth:!1,google_oauth:!1,twitter_oauth:!1,discord_oauth:!1,github_oauth:!1,linkedin_oauth:!1,apple_oauth:!1,disable_plus_emails:!1,terms_and_conditions_url:null,privacy_policy_url:null,embedded_wallet_config:{create_on_login:"off",ethereum:{create_on_login:"off"},solana:{create_on_login:"off"},require_user_owned_recovery_on_create:!1,user_owned_recovery_options:["user-passcode"],mode:"user-controlled-server-wallets-only"},fiat_on_ramp_enabled:!1,captcha_enabled:!1,captcha_site_key:"",enforce_wallet_uis:!1,legacy_wallet_ui_config:!1,id:"",name:"",passkeys_for_signup_enabled:!1,whatsapp_enabled:!1},Ia=Ta(Aa,void 0,!1);let Sa=/*#__PURE__*/r.createContext({appConfig:Ia,isServerConfigLoaded:!1});const Pa=({children:t,client:n,legacyClient:a,clientConfig:i})=>{let[o,s]=r.useState(null),l=r.useMemo((()=>Ta(o??Aa,i,!!o,"undefined"!=typeof window?window.location.origin:void 0)),[o,i]);return r.useEffect((()=>{if(!o)return;let e=function(e){if(!e)return{};let{appearance:t,supportedChains:r,defaultChain:n,externalWallets:a,...i}=e;return{...i,...r?{supportedChains:r.map((e=>e.id))}:void 0,...n?{defaultChain:n.id}:void 0,...a?{walletConnect:a.walletConnect?{enabled:a.walletConnect.enabled}:void 0,coinbaseWallet:a.coinbaseWallet,solana:{connectors:a.solana?.connectors?.get().map((e=>e.walletClientType))}}:void 0}}(i),t=function(e,t=0){let r=3735928559^t,n=1103547991^t;for(let t,a=0;a<e.length;a++)r=Math.imul(r^(t=e.charCodeAt(a)),2654435761),n=Math.imul(n^t,1597334677);return r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),4294967296*(2097151&(n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909)))+(r>>>0)}(JSON.stringify(e)).toString(),r=`privy:sent:${o.id}:${t}`;localStorage.getItem(r)||(a.createAnalyticsEvent({eventName:"sdk_initialize",payload:e}),localStorage.setItem(r,"t"))}),[i,o]),r.useEffect((()=>{o||(async()=>{try{await n.initialize();let e=n.app.getConfig();e.custom_api_url&&a.updateApiUrl(e.custom_api_url),s(e)}catch(e){console.warn("Error generating app config: ",e)}})()}),[]),/*#__PURE__*/e.jsx(Sa.Provider,{value:{appConfig:l,isServerConfigLoaded:!!o},children:t})},_a=()=>{let{appConfig:e}=r.useContext(Sa);return e},Na=()=>{let{isServerConfigLoaded:e}=r.useContext(Sa);return e},Ma=/*#__PURE__*/r.createContext({app:Ia,currentScreen:null,lastScreen:null,navigate:s.notImplemented,navigateBack:s.notImplemented,resetNavigation:s.notImplemented,setModalData:s.notImplemented,onUserCloseViaDialogOrKeybindRef:void 0}),Wa=t=>{let n=_a(),a=t.authenticated,[i,o]=r.useState(t.initialScreen);r.useEffect((()=>{a||!t.initialScreen||t.initialScreen.isUnauthenticatedScreem||t.setInitialScreen(null)}),[a]);let s=r.useRef(null);r.useEffect((()=>{t.open||(s.current=null)}),[t.open]),r.useEffect((()=>{s.current=null}),[t.initialScreen]);let l={app:n,data:t.data,setModalData:t.setModalData,currentScreen:t.initialScreen,lastScreen:i,navigate:(e,r=!0)=>{t.setInitialScreen(e),r&&o(t.initialScreen)},navigateBack:()=>{t.setInitialScreen(i)},resetNavigation:()=>{t.setInitialScreen(null),o(null)},onUserCloseViaDialogOrKeybindRef:s};/*#__PURE__*/return e.jsxs(Ma.Provider,{value:l,children:[("string"==typeof n.appearance.logo||"img"===n.appearance.logo?.type)&&/*#__PURE__*/e.jsx(ya,{src:"string"==typeof n.appearance.logo?n.appearance.logo:n.appearance.logo.props.src}),t.children]})},Ua=()=>r.useContext(Ma);class Oa extends Wn{async initialize(){let e=await this.createProvider();this.provider=e,this.proxyProvider.setWalletProvider(e),this.subscribeListeners(),e.session&&(this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=ua(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown"),this.connected=!0,await this.syncAccounts()),this.initialized=!0,this.emit("initialized");let{createAppKit:t}=await import("@reown/appkit");this.modal??=t({projectId:this.walletConnectCloudProjectId,themeVariables:{"--w3m-z-index":1e6},networks:this.chains,includeWalletIds:Jt,allowUnsupportedChain:!0}),this.modal.subscribeState((e=>{e.open||this.walletProvider?.session||!this.onQrModalClosed||this.onQrModalClosed()}))}async connect(e){return e.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return!!this.walletProvider?.connected}get walletBranding(){let e=this.walletProvider?.session?.peer.metadata.icons?.[0];return{name:Vt(this.walletProvider?.session?.peer.metadata.name||"")||"WalletConnect",icon:"string"==typeof e?e:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAHdElNRQfoDAIVODUC+w+GAAAGsUlEQVRYw6WXbYwWVxXHf+fOLAtCXYS2QJdIaClipGCTknXXNqBQMVHbfmhItH4Aral+IAEaG03UxJgYKQJGTUxtDWjaxDSNtcZqIGDwpRuW1oYiVqpdpZSlpC3qysu+PHPP3w/3mXnmeXZbPzjJZO7cefn/z/mfe865xlscq3dGDIguGiHLaMQVLja4s87FShcLo5jtApdddnHexUmHIy475JmdUkPRAQMu7gzT4ljnxJpdk0QPmMFkyAKN2OfOFpc2uuh1J3MZDrjAvXmVEQUuoosRxw642FcEG7IoDxiFxNiu8NYE+vcUYIFYRKKs113bXWx2Z34CoQZsVHOiCZ7mopdzdsFhv8NexEgRDHMxUSNREbh1bwNZwBsFblmfu/a4a6AEENYO5i3AOoEWeEUCF4MOOxBDMQAOk99OJALA2u80sBCwWGBZWG/yRwMaCAbBIAsQTJT3gea1OWfNeaPzvjoHEI85rA8ObtB1v7cIdJkIHgkh9AXpocy0LJjIKvB2wPpZB0v3wkrw5jdNEjeYeMhFX3BAyfn2ke9NUrgB9LrrcZcGJFCld4fWNddXbvbWfWzGR6xJFZsBGh0cBh3bBIxIEGTQ3W0h4NuDaSAzyAxCmGq11Vzf5uaa1aG8p+WFtrEYQGwvjICJkAEqvC+YNmcmMlMNvEaCdrcbyUvQAWDTjVuESHObM6cPGWHmzDwLaEtmzG9Z3qF1zUpXmuuZBb1z4bqeNC6f0WE1NtUTwHzEloiy3BvFisy0sYoLlQtT6XW15md2Qf9SY+2Ngfdca/TMSm/9ewz+/Boc/It45h/i4kSTsKw90SQJsPTvjSZbkWemDW7qTRZ0JEYJWSKxZJ7xmf6M224MzMzbX1s8F1YugjtvMg6eErt/4/z1jUrz1rXUKxnZC2zIg2mdBTK1mFUOKC1fOt/48kdzVixIz86Nij+eEacvpJWyZJ5xy7th8VzjjpuMJfMCW58QL73ekXPVlhsyE+vyzFiplJyauEIyrGIquruMq7qTxk+dcB495rzyTzFepCUWLIFv/kBg081Gd55WUk1IDGFTS89K++TDYxddzKnWcbluHd450xgdh7EGrOo1rr868PMTzqWJRGZ2d8oB/xpL33Xnxl2rjeNn4blXRXduzJ4B5y+28kWscAwXl+yeR654FFZPHoUb710YuPeDOUdPO48di1xptKpeEeHqOcYXNwQKGd88EDk3mqxtxPSfGRlsXRtYt8z4ytPOH/7eqpg1Aso7fYKgK4NPrMpYvsC4/poMA34yVJIQC3sCD9yecdsNyaV5yPj6ryJnR1PAvSNP4J+/1cgDfLbfePaMGGtM7Qdyl12WmKOmXgKKAp54vmBRTxfLrjE+tSYjBPjRM5FrrzIeuD2jf2lLzw8vN4JlfPVp581LsO1DgXv7jSzAiXPw/d+JiYLpjsu26Yfjf5O0rF5WoxsNT9G/bX0XKxakmPjlSee6HlizJJXSX7/oRDc+vjKR+f2wODcKd78/gR8/C9uedF44myJxmhh4OY/ipMQyqaWxmjn95TfEroMFOzbkvG+RceeqViPx1Aln1yEnOow1AnffHCpJAJ5/Vex4UvzptZRdY/O/1dJIS/NkcNmR6MTYah6qzseA4TfFtw4UvHBW1bc/O+7sPhwZHYf/jMODh5yfPudVbXj2TAJ/8XxrOZagNamj4Ei2/GNfuyRxh8t6BG2l15up+MIVODEiFr8rcPS0+O6RBF6mrrEGHHtFzOo2Lo7Dl37hvPQ6mNV6R9JYKgnYWcE37K5HlE2OT/5A0udaPUBHH+BQOMzuNsYLuDyZflTW+fTcmJFDHhJhaZqewMuewXDxcDR9IYyPN6Jj+6K4MF2vV8qBtZJScqVRNi6lpGONVJis5mpKi1WbgwsY+zIsBpcR8mzIZfuTRVZrtdu9odrptR/Xx5XONXJqBmCN0P6YMUQq9WJiwt0Je102WHdbpxSqydMObBWYdwDWLVcqcIMYe3NPjg0Ht84od0Ajju1w2XCr9e6QoqM9V23ZtnmI6cfAMMb9AY0YEHdb6oobEh4y3H3Ize6LsmGvN5IdUnhttdQ9UVrfLk/ljWEZ9wXsqAdQk1EA+O22GcgdZTke/bAs3OPY4HSdcB20HhvVtTMu0jmI8ekAhz2IICj2hKpNqI60NcuIRUHEej1quzubXa2tmZhenrfZmv3YYQ9ipDAIgvHptmblccuDjdRcmjFpWbDi/9ycZjZkRbk5jYztai/AUwiUx+qdEQB/m+25i9lxyvbcjrg45Lmd0uT/3p7/Fw6ODf+WO019AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDI0LTEyLTAyVDIxOjU2OjQ4KzAwOjAwMVpslgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyNC0xMi0wMlQyMTo1Njo0OCswMDowMEAH1CoAAAAodEVYdGRhdGU6dGltZXN0YW1wADIwMjQtMTItMDJUMjE6NTY6NTMrMDA6MDDZv6GRAAAAAElFTkSuQmCC",id:this.walletProvider?.session?.peer.metadata.name.toLowerCase()||"wallet_connect_v2"}}async resetConnection(e){this.walletProvider&&this.walletProvider.connected&&(await this.walletProvider.disconnect(),this.walletProvider.signer.session=void 0,this.walletClientType=e,this.redirectUri=void 0,this.fallbackUniversalRedirectUri=void 0,function(){try{localStorage.removeItem(Xt)}catch{}}(),this.onDisconnect())}async promptConnection(){if(this.provider)return new Promise(((e,t)=>{this.onQrModalClosed=()=>{t(new jn)},(async()=>{let t="",r=await Promise.race([this.walletProvider?.enable(),this.proxyProvider.walletTimeout()]);if(r?.length&&(t=r[0]),!t||""===t)throw new o.PrivyConnectorError("Unable to retrieve address");this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=ua(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown",this.proxyProvider.rpcTimeoutDuration=_n(this.rpcConfig,this.walletClientType)),this.connected=!0,await this.syncAccounts(r),e()})().catch((e=>{t(e?En(e):new o.PrivyConnectorError("Unknown error during connection"))})).finally((()=>this.modal?.close()))}))}disconnect(){this.walletProvider?.disconnect().then((()=>this.onDisconnect())).catch((()=>console.warn("Unable to disconnect Wallet Connect provider")))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(e){this.proxyProvider.setWalletProvider(e)}async createProvider(){let e={};for(let t of this.chains){let r=Yt(t.id,this.chains,this.rpcConfig,this.privyAppId);r&&(e[t.id]=r)}let t=this.shouldEnforceDefaultChainOnConnect?[this.defaultChain.id]:[],r=this.chains.map((e=>e.id)),a=await S.EthereumProvider.init({projectId:this.walletConnectCloudProjectId,chains:t,optionalChains:r,optionalEvents:S.OPTIONAL_EVENTS,optionalMethods:S.OPTIONAL_METHODS,rpcMap:e,showQrModal:!1,metadata:{description:this.privyAppName,name:this.privyAppName,url:window.location.toString(),icons:[]}});return a.on("display_uri",(e=>{if(a.signer.abortPairingAttempt(),this.walletEntry){let{redirect:t,href:r}=function(e,t){let r=Qt(t);if(r.deepLink)return tr(r.deepLink,e);if(r.universalLink)return rr(r.universalLink,e);throw new o.PrivyClientError(`Unsupported wallet ${t.id}`)}(e,this.walletEntry);(function({href:e,name:t}){try{localStorage.setItem(Xt,JSON.stringify({href:e,name:t}))}catch{}})({href:r,name:this.walletEntry.metadata?.shortName||this.walletEntry.name}),this.redirectUri=t;let a=function(e,t){let r=Qt(t);if(r.universalLink)return rr(r.universalLink,e)}(e,this.walletEntry);a?.redirect&&(this.fallbackUniversalRedirectUri=a.redirect),n.isMobile?(nr(t,"_self"),this.showPrivyQrModal?.({native:t,universal:this.fallbackUniversalRedirectUri})):this.showPrivyQrModal?this.showPrivyQrModal?.({native:t,universal:this.fallbackUniversalRedirectUri}):this.modal?.open({uri:e})}else this.modal?.open({uri:e})})),a.on("connect",(()=>{this.modal?.close(),a.session?.peer.metadata.url&&(this.walletEntry=ua(a.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown")})),a}async enableProvider(){return this.walletProvider?.connected?Promise.resolve(this.walletProvider.accounts):await(this.walletProvider?.enable())}setWalletEntry(e,t){this.walletEntry=e,this.showPrivyQrModal=t}constructor({walletConnectCloudProjectId:e,rpcConfig:t,chains:r,defaultChain:n,shouldEnforceDefaultChainOnConnect:a,privyAppId:i,privyAppName:o,walletClientType:s,appKit:l}){super(s||"unknown",r,n,t),this.connectorType="wallet_connect_v2",this.privyAppId=i,this.privyAppName=o,this.walletConnectCloudProjectId=e,this.rpcConfig=t,this.shouldEnforceDefaultChainOnConnect=a,this.proxyProvider=new Un(void 0,this.rpcTimeoutDuration),this.modal=l,s&&(this.walletEntry=(e=>ca.getState().listings.find((({slug:t})=>pa(t)===pa(e))))(s),this.walletClientType=s)}}class Fa extends Ie.default{get wallets(){let e=new Set,t=this.walletConnectors.flatMap((e=>e.wallets)).sort(((e,t)=>e.connectedAt&&t.connectedAt?t.connectedAt-e.connectedAt:0)).filter((t=>{let r=`${t.address}${t.walletClientType}${t.connectorType}${t.meta.id}`;return!e.has(r)&&(e.add(r),!0)})),r=t.findIndex((e=>e.address===(this.activeWallet?this.activeWallet:"unknown")));return r>=0&&t.unshift(t.splice(r,1)[0]),t}async initialize(e){if(this.initialized&&!e||(e&&this.removeAllConnectors(),Mt.get(Tr)&&(Mt.getKeys().forEach((e=>{e.startsWith("walletconnect")&&Mt.del(e)})),Mt.del(Tr)),this.externalWalletConfig.disableAllExternalWallets))return;let t=Kt({store:this.store,walletList:this.walletList,externalWalletConfig:this.externalWalletConfig,walletChainType:this.walletChainType}).then((e=>{e.forEach((({type:e,eip6963InjectedProvider:t,legacyInjectedProvider:r})=>{this.createEthereumWalletConnector({connectorType:"injected",walletClientType:e,providers:{eip6963InjectedProvider:t,legacyInjectedProvider:r}})}))}));for(let e of(this.walletList.includes("coinbase_wallet")&&this.createEthereumWalletConnector({connectorType:"coinbase_wallet",walletClientType:"coinbase_wallet"}),Object.values(ea)))!e.isInstalled&&this.walletList.includes(e.client)&&(["ethereum-only","ethereum-and-solana"].includes(this.walletChainType)&&e.chainTypes.includes("ethereum")&&this.createEthereumWalletConnector({connectorType:"null",walletClientType:e.client,walletConfig:e}),["ethereum-and-solana","solana-only"].includes(this.walletChainType)&&e.chainTypes.includes("solana")&&this.addSolanaWalletConnector(new la({id:e.client,name:e.name})));this.externalWalletConfig.walletConnect.enabled&&this.createEthereumWalletConnector({connectorType:"wallet_connect_v2",walletClientType:"unknown"}),this.externalWalletConfig.solana.connectors?.get().forEach(this.addSolanaWalletConnector),this.externalWalletConfig.solana.connectors?._setOnConnectorsUpdated?.((e=>{e?.forEach(this.addSolanaWalletConnector)})),await t,this.initialized=!0}findWalletConnector(e,t){return"wallet_connect_v2"===e?this.walletConnectors.filter(Mn).find((t=>t.connectorType===e))??null:this.walletConnectors.filter(Mn).find((r=>r.connectorType===e&&r.walletClientType===t))??null}findSolanaWalletConnector(e){return this.walletConnectors.filter(ia).find((t=>"unknown"===t.walletClientType?t.walletBranding.id===e:t.walletClientType===e))??null}findEmbeddedWalletConnectors(){return this.walletConnectors.filter((e=>"embedded"===e.connectorType))}onInitialized(e){e.wallets.forEach((e=>{let t=this.storedConnections.find((t=>t.address===e.address&&t.connectorType===e.connectorType&&("solana"===e.type&&"unknown"===t.walletClientType&&"unknown"===e.walletClientType?e.meta.id===t.id:t.walletClientType===e.walletClientType)));t&&(e.connectedAt=t.connectedAt)})),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(e){e.initialized&&this.emit("walletsUpdated")}addEmbeddedWalletConnectors({walletProxy:e,user:t,embeddedWallets:r,defaultChain:n,appId:a,privyClient:i}){let{entropyId:o,entropyIdVerifier:s}=xn(t);for(let t of r){let r=this.findEmbeddedWalletConnectors().find((e=>e.walletIndex===t.walletIndex));if(r&&Mn(r))r.proxyProvider.walletProxy=e;else{let r=new Ln({provider:new zn({walletProxy:e,address:t.address,entropyId:o,entropyIdVerifier:s,rpcConfig:this.rpcConfig,chains:this.chains,appId:a,chainId:n.id,walletIndex:t.walletIndex,privyClient:i,walletAccount:t}),chains:this.chains,defaultChain:n,rpcConfig:this.rpcConfig,imported:!1,walletIndex:t.walletIndex});this.addWalletConnector(r)}}}addImportedWalletConnector(e,t,r,n){let a=this.findWalletConnector("embedded_imported","privy");if(a&&Mn(a))a.proxyProvider.walletProxy=e;else{let a=new Ln({provider:new zn({walletProxy:e,address:t,entropyId:t,entropyIdVerifier:"ethereum-address-verifier",walletIndex:0,rpcConfig:this.rpcConfig,chains:this.chains,appId:n,chainId:r.id}),chains:this.chains,walletIndex:0,defaultChain:r,rpcConfig:this.rpcConfig,imported:!0});this.addWalletConnector(a)}}removeEmbeddedWalletConnectors(){this.walletConnectors=this.walletConnectors.filter((e=>"embedded"!==e.connectorType)),this.storedConnections=na(),this.emit("walletsUpdated")}removeImportedWalletConnector(){let e=this.findWalletConnector("embedded_imported","privy");if(e){let t=this.walletConnectors.indexOf(e);this.walletConnectors.splice(t,1),this.storedConnections=na(),this.emit("walletsUpdated")}}async createEthereumWalletConnector({connectorType:e,walletClientType:t,providers:r,walletConfig:n}){let a=this.findWalletConnector(e,t);if(a&&Mn(a))return a instanceof Oa&&a.resetConnection(t),a;let i=(()=>"injected"!==e?"coinbase_wallet"===e?new Fn(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig.coinbaseWallet.config):"null"!==e?new Oa({walletConnectCloudProjectId:this.walletConnectCloudProjectId,rpcConfig:this.rpcConfig,chains:this.chains,defaultChain:this.defaultChain,shouldEnforceDefaultChainOnConnect:this.shouldEnforceDefaultChainOnConnect,privyAppId:this.privyAppId,privyAppName:this.privyAppName,walletClientType:t,appKit:this.appKit}):n?new $n({id:n.client,name:n.name,defaultChain:this.defaultChain,walletClientType:n.client}):null:"metamask"===t&&r?.eip6963InjectedProvider?new Qn(this.chains,this.defaultChain,this.rpcConfig,r?.eip6963InjectedProvider,"metamask"):"metamask"===t&&r?.legacyInjectedProvider?new Jn(this.chains,this.defaultChain,this.rpcConfig,r?.legacyInjectedProvider,"metamask"):"phantom"===t&&r?.legacyInjectedProvider?new Jn(this.chains,this.defaultChain,this.rpcConfig,r?.legacyInjectedProvider,"phantom"):r?.legacyInjectedProvider&&"unknown_browser_extension"===t?new Jn(this.chains,this.defaultChain,this.rpcConfig,r?.legacyInjectedProvider):r?.eip6963InjectedProvider?new Yn(this.chains,this.defaultChain,this.rpcConfig,r?.eip6963InjectedProvider,t):void 0)();return i&&this.addWalletConnector(i),i||null}addWalletConnector(e){this.walletConnectors.push(e),e.on("initialized",(()=>this.onInitialized(e))),e.on("walletsUpdated",(()=>this.onWalletsUpdated(e))),e.initialize().catch((e=>{console.debug("Failed to initialize connector",e)}))}async activeWalletSign(e){let t=this.wallets,r=t.length>0?t[0]:null;return r&&In(r)?r.sign(e):null}setActiveWallet(e){this.activeWallet=a.getAddress(e),this.emit("walletsUpdated")}setWalletList(e){this.walletList=e,this.initialized&&this.initialize(!0).catch(console.error)}removeAllConnectors(){for(let e of this.walletConnectors)e.removeAllListeners();this.walletConnectors=[]}constructor(e,t,r,n,a,i,o,s,l,c,d,u){super(),this.addSolanaWalletConnector=async e=>{let t=this.findSolanaWalletConnector(e.walletClientType);if(!t||"null"===t.connectorType){if("null"===t?.connectorType){let e=this.walletConnectors.indexOf(t);this.walletConnectors.splice(e,1)}this.addWalletConnector(e)}},this.getEthereumProvider=()=>{let e=this.wallets[0],t=this.walletConnectors.find((t=>t.wallets.find((t=>t.address===e?.address))));return e&&t?t.proxyProvider:new Un},this.privyAppId=e,this.walletConnectCloudProjectId=t,this.rpcConfig=r,this.chains=n,this.defaultChain=a,this.walletConnectors=[],this.initialized=!1,this.store=i,this.walletList=o,this.shouldEnforceDefaultChainOnConnect=s,this.externalWalletConfig=l,this.privyAppName=c,this.walletChainType=d||"ethereum-only",this.appKit=u,this.storedConnections=na()}}let Ra=[o.sessionsRefreshPath,o.sessionsLogoutPath,o.analyticsEventsPath];class La{async get(e,t){try{return await this.baseFetch(e,t)}catch(e){throw o.formatApiError(e)}}async post(e,t,r){try{return await this.baseFetch(e,{method:"POST",...t?{body:t}:{},...r})}catch(e){throw o.formatApiError(e)}}async delete(e,t){try{return await this.baseFetch(e,{method:"DELETE",...t})}catch(e){throw o.formatApiError(e)}}constructor({appId:e,appClientId:t,client:r,defaults:n}){this.appId=e,this.appClientId=t,this.clientAnalyticsId=r.clientAnalyticsId,this.sdkVersion=dr,this.client=r,this.defaults=n,this.fallbackApiUrl=r.fallbackApiUrl,this.baseFetch=ce.ofetch.create({baseURL:this.defaults.baseURL,timeout:this.defaults.timeout,retry:3,retryDelay:500,retryStatusCodes:[408,409,425,500,502,503,504],credentials:"include",onRequest:async({request:e,options:t})=>{let r=new Headers(t.headers);r.set("privy-app-id",this.appId),this.appClientId&&r.set("privy-client-id",this.appClientId),r.set("privy-ca-id",this.clientAnalyticsId||""),r.set("privy-client",`react-auth:${this.sdkVersion}`);let n=Ra.includes(e.toString());if(!r.has("authorization")){let e=await this.client.getAccessToken({disableAutoRefresh:n});null!==e&&r.set("authorization",`Bearer ${e}`)}t.headers=r,t.retryDelay&&"number"==typeof t.retryDelay&&(t.retryDelay=3*t.retryDelay)},onRequestError:({error:e})=>{if(e instanceof DOMException&&"AbortError"===e.name)throw new o.PrivyTimeoutError}})}}let Da=/paymaster\.biconomy\.io\/api/i,Ba={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}};const za=(e,t)=>e&&Da.test(e)?Ba:t&&t.policy_id?{policyId:t.policy_id}:void 0;class $a{async authenticate(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(o.customJwtAccountAuthenticatePath,{token:this.meta.token})}catch(e){throw o.formatApiError(e)}}async link(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(o.customJwtAccountLinkPath,{token:this.meta.token})}catch(e){throw o.formatApiError(e)}}constructor(e){this.meta={token:e}}}class qa{getOrCreateGuestCredential(e){let t=vr(e);if(Nt()){if(Mt.get(t))return Mt.get(t);{let e=d.base64url.encode(Wr(32));return Mt.put(t,e),e}}return d.base64url.encode(Wr(32))}async authenticate(){if(!this.api)throw new o.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(o.guestAccountAuthenticatePath,{guest_credential:this.meta.guestCredential})}catch(e){throw o.formatApiError(e)}}async link(){throw Error("Linking is not supported for the guest flow")}constructor(e){this.meta={guestCredential:this.getOrCreateGuestCredential(e)}}}function Va(){return!(n.isSafari&&window.location.origin.startsWith("http://localhost"))}const Ha=P.create((()=>({identityToken:null})));var Ka,Za=((Ka={}).PRIVY="privy_access_token",Ka.CUSTOMER="customer_access_token",Ka);class Ya{get token(){return this.privyAccessToken||this.customerAccessToken}getToken(e){return"privy_access_token"===e?this.privyAccessToken:this.customerAccessToken}get customerAccessToken(){return this._getToken(ur)}get privyAccessToken(){return this._getToken(yr)}_getToken(e){try{let t=Mt.get(e);return"string"==typeof t?fn.throwIfNotWellFormedJwt(t):null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=Mt.get(pr);return"string"==typeof e?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}getProviderAccessToken(e){try{let t=Mt.get(xr(e));if("string"!=typeof t)return null;{let r=new fn(t);return r.isExpired()?(Mt.del(xr(e)),null):r.value}}catch(e){return console.error(e),null}}get mightHaveServerCookies(){try{let e=At.default.get(fr);return void 0!==e&&e.length>0}catch(e){console.error(e)}return!1}hasRefreshCredentials(e="privy_access_token"){let t="string"==typeof this.getToken(e),r="string"==typeof this.refreshToken&&"deprecated"!==this.refreshToken;return this.mightHaveServerCookies||t&&r}hasActiveAccessToken(e){let t=fn.parse(this.getToken(e));return null!==t&&!t.isExpired(30)}authenticate(e){return this.authenticateOnce.execute(e)}link(e){return this.linkOnce.execute(e)}refresh(){return this.refreshOnce.execute()}destroy(){return this.destroyOnce.execute()}storeProviderAccessToken(e,t){"string"==typeof t?Mt.put(xr(e),t):Mt.del(xr(e))}updateIdentityToken(e){"string"==typeof e?this.storeIdentityToken(e):this.clearIdentityToken()}async _authenticate(e){try{let t=await e.authenticate(),{user:r,is_new_user:n,oauth_tokens:a}=t;this.handleTokenResponse(t);let i=a?{provider:a.provider,accessToken:a.access_token,accessTokenExpiresInSeconds:a.access_token_expires_in_seconds,refreshToken:a.refresh_token,refreshTokenExpiresInSeconds:a.refresh_token_expires_in_seconds,scopes:a.scopes}:void 0;return this._trackAuthenticateEvents(e,n),{user:u.convertUserResponseToUser(r),isNewUser:n,oAuthTokens:i}}catch(e){throw console.warn("Error authenticating session"),o.formatPrivyError(e)}}_trackAuthenticateEvents(e,t){let r=function(e){return e instanceof St?"email":e instanceof sn?"sms":e instanceof rn?"siwe":e instanceof qa?"guest":e instanceof $a?"custom_auth":e instanceof Rr?e.meta.provider:null}(e);r&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:r,isNewUser:t}}),"siwe"===r&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:e.meta.connectorType,walletClientType:e.meta.walletClientType}})}async _link(e){try{let t=await e.link(),r=t.oauth_tokens,n=r?{provider:r.provider,accessToken:r.access_token,accessTokenExpiresInSeconds:r.access_token_expires_in_seconds,refreshToken:r.refresh_token,refreshTokenExpiresInSeconds:r.refresh_token_expires_in_seconds,scopes:r.scopes}:void 0;return{user:u.convertUserResponseToUser(t),oAuthTokens:n}}catch(e){throw console.warn("Error linking account"),o.formatPrivyError(e)}}async _refresh(){if(!this.api)throw new o.PrivyClientError("Session has no API instance");if(!this.client)throw new o.PrivyClientError("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let e=this.token,t=this.refreshToken;if(this.client.useServerCookies&&!this.mightHaveServerCookies&&this.token&&window.location.origin===this.client.apiUrl)return this.destroyLocalState(),null;try{let r;if(!(e&&t||this.mightHaveServerCookies))return null;{let n={};e&&(n.authorization=`Bearer ${e}`),r=await this.api.post(o.sessionsRefreshPath,t?{refresh_token:t}:{},{headers:n})}return this.handleTokenResponse(r),u.convertUserResponseToUser(r.user)}catch(e){if(e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.MISSING_OR_INVALID_TOKEN)return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw o.formatPrivyError(e)}}handleTokenResponse(e){e.session_update_action&&"set"!==e.session_update_action?"clear"===e.session_update_action?this.destroyLocalState():"ignore"===e.session_update_action&&(e.token&&(this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token)),e.identity_token&&this.storeIdentityToken(e.identity_token)):this._storeAllTokens(e)}_storeAllTokens(e){this.storeRefreshToken(e.refresh_token),this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token),e.identity_token&&this.storeIdentityToken(e.identity_token)}async _destroy(){try{await(this.api?.post(o.sessionsLogoutPath,{refresh_token:this.refreshToken}))}catch(e){console.warn("Error destroying session")}this.destroyLocalState()}destroyLocalState(){this.storeRefreshToken(null),this.storeCustomerAccessToken(null),this.storePrivyAccessToken(null),this.clearIdentityToken()}storeCustomerAccessToken(e){if("string"==typeof e){let t=Mt.get(ur);if(Mt.put(ur,e),!this.client?.useServerCookies){let t=fn.parse(e)?.expiration;At.default.set(hr,e,{sameSite:"Strict",secure:Va(),expires:t?new Date(1e3*t):void 0})}t!==e&&this.client?.onStoreCustomerAccessToken?.(e)}else Mt.del(ur),At.default.remove(hr),this.client?.onDeleteCustomerAccessToken?.()}storeRefreshToken(e){"string"==typeof e?(Mt.put(pr,e),this.client?.useServerCookies||At.default.set(fr,"t",{sameSite:"Strict",secure:Va(),expires:30})):(Mt.del(pr),At.default.remove("privy-refresh-token"),At.default.remove(fr))}storePrivyAccessToken(e){"string"==typeof e?Mt.put(yr,e):Mt.del(yr)}storeIdentityToken(e){if(Ha.setState({identityToken:e}),this.client?.useServerCookies)return;Mt.put(mr,e);let t=fn.parse(e)?.expiration;At.default.set(gr,e,{sameSite:"Strict",secure:Va(),expires:t?new Date(1e3*t):void 0})}clearIdentityToken(){Mt.del(mr),Ha.setState({identityToken:null}),At.default.remove(gr)}constructor(){this.authenticateOnce=new ar((async e=>this._authenticate(e))),this.linkOnce=new ar((async e=>this._link(e))),this.refreshOnce=new ar(this._refresh.bind(this)),this.destroyOnce=new ar(this._destroy.bind(this))}}let Ga;var Ja=0,Qa="__private_"+Ja+++"__getOrGenerateClientAnalyticsId";class Xa{getAppId(){return this.appId}initializeConnectorManager({walletConnectCloudProjectId:e,rpcConfig:t,chains:r,defaultChain:n,store:a,walletList:i,shouldEnforceDefaultChainOnConnect:o,externalWalletConfig:s,appName:l,walletChainType:c,appKit:d}){this.connectors||(this.connectors=new Fa(this.appId,e,t,r,n,a,i,o,s,l,c,d))}generateApi(){let e=new La({appId:this.appId,appClientId:this.appClientId,client:this,defaults:{baseURL:this.apiUrl,timeout:this.timeout}});return this.session.api=e,e}updateApiUrl(e){this.apiUrl=e||this.fallbackApiUrl,this.api=this.generateApi(),e&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new o.PrivyClientError("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new o.PrivyClientError("No auth flow in progress.");let{oAuthTokens:e}=await this.session.link(this.authFlow);return{user:await this.getAuthenticatedUser(),oAuthTokens:e}}storeProviderAccessToken(e,t){this.session.storeProviderAccessToken(e,t)}getProviderAccessToken(e){return this.session.getProviderAccessToken(e)}async logout(){await this.session.destroy(),this.authFlow=void 0}clearProviderAcccessTokens(e){e.linkedAccounts.filter((e=>"cross_app"===e.type)).forEach((e=>{this.storeProviderAccessToken(e.providerApp.id,null)}))}startAuthFlow(e){return e.api=this.api,this.authFlow=e,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(o.mfaPasswordlessSmsInitPath,{action:"verify"})}catch(e){throw o.formatApiError(e)}}async initMfaPasskeyVerification(){try{return(e=>({rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}))((await this.api.post(o.mfaPasskeyInitPath,{})).options)}catch(e){throw o.formatApiError(e)}}async getCrossAppProviderDetails(e){try{return this._cachedProviderAppDetails[e]||(this._cachedProviderAppDetails[e]=await this.api.get(`/api/v1/apps/${e}/cross-app/details`)),this._cachedProviderAppDetails[e]}catch(e){console.error("Error fetching cross app provider details",e)}}async acceptTerms(){try{let e=await this.api.post(o.acceptTermsPath,{});return u.convertUserResponseToUser(e)}catch(e){throw o.formatPrivyError(e)}}async unlinkEmail(e){try{let t=await this.api.post(o.unlinkEmailPath,{address:e});return await this.getAuthenticatedUser()??u.convertUserResponseToUser(t)}catch(e){throw o.formatPrivyError(e)}}async unlinkPhone(e){try{let t=await this.api.post(o.unlinkPhonePath,{phoneNumber:e});return await this.getAuthenticatedUser()??u.convertUserResponseToUser(t)}catch(e){throw o.formatPrivyError(e)}}async unlinkEthereumWallet(e){try{let t=await this.api.post(o.unlinkWalletPath,{address:e});return await this.getAuthenticatedUser()??u.convertUserResponseToUser(t)}catch(e){throw o.formatPrivyError(e)}}async unlinkSolanaWallet(e){try{let t=await this.api.post(o.siwsUnlinkWalletPath,{address:e});return await this.getAuthenticatedUser()??u.convertUserResponseToUser(t)}catch(e){throw o.formatPrivyError(e)}}async unlinkOAuth(e,t){try{let r=await this.api.post(o.unlinkOAuthPath,{provider:e,subject:t});return await this.getAuthenticatedUser()??u.convertUserResponseToUser(r)}catch(e){throw o.formatPrivyError(e)}}async unlinkFarcaster(e){try{let t=await this.api.post(o.unlinkFarcasterPath,{fid:e});return await this.getAuthenticatedUser()??u.convertUserResponseToUser(t)}catch(e){throw o.formatPrivyError(e)}}async unlinkTelegram(e){try{let t=await this.api.post(o.telegramAccountUnlinkPath,{telegram_user_id:e});return await this.getAuthenticatedUser()??u.convertUserResponseToUser(t)}catch(e){throw o.formatPrivyError(e)}}async revokeDelegatedWallet(){try{await this.api.post(o.delegatedActionsRevokePath,{})}catch(e){throw o.formatPrivyError(e)}}async createAnalyticsEvent({eventName:e,payload:t,timestamp:r,options:n}){if("undefined"!=typeof window)try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(o.analyticsEventsPath,{event_name:e,client_id:this.clientAnalyticsId,payload:{...t||{},clientTimestamp:r?r.toISOString():(new Date).toISOString()}},{retry:-1,keepalive:n?.keepAlive??!1})}catch(e){console.log("Unable to submit event. This is not an issue.")}}async signMoonpayOnRampUrl(e){try{return this.api.post(o.moonpayPluginOnRampPath,e)}catch(e){throw o.formatPrivyError(e)}}async initCoinbaseOnRamp(e){try{return this.api.post(o.coinbaseOnRampInitPath,e)}catch(e){throw o.formatPrivyError(e)}}async getCoinbaseOnRampStatus({partnerUserId:e}){try{return this.api.get(`${o.coinbaseOnRampStatusPath}?partnerUserId=${e}`)}catch(e){throw o.formatPrivyError(e)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()?this.session.refresh():null}async getAccessToken(e){return await this.getPrivyAccessToken(e)||await this.getCustomerAccessToken(e)}async getCustomerAccessToken(e){return await this._getToken(Za.CUSTOMER,e)}async getPrivyAccessToken(e){return await this._getToken(Za.PRIVY,e)}async _getToken(e,t){return this.session.getToken(e)?this.session.hasActiveAccessToken(e)?this.session.hasRefreshCredentials(e)?wn.parse(this.session.getToken(e))?.appId!==this.appId?(await this.logout(),null):this.session.getToken(e):(this.session.destroyLocalState(),null):!t?.disableAutoRefresh&&this.session.hasRefreshCredentials(e)?(await this.session.refresh(),this.session.getToken(e)):null:null}async getSmartWalletsConfig(){try{let e={},t=this.session.token;t&&(e.authorization=`Bearer ${t}`);let r=await this.api.get(`/api/v1/apps/${this.appId}/smart_wallets`,{baseURL:this.fallbackApiUrl,headers:e});return r.enabled?{enabled:r.enabled,smartWalletType:r.smart_wallet_type,configuredNetworks:r.configured_networks.map((e=>({chainId:e.chain_id,bundlerUrl:e.bundler_url,paymasterUrl:e.paymaster_url,paymasterContext:za(e.paymaster_url,e.paymaster_context)})))}:{enabled:r.enabled}}catch(e){throw o.formatPrivyError(e)}}async getUsdTokenPrice(e){try{return(await this.api.get(`/api/v1/token_price?chainId=${e.id}&tokenSymbol=${e.nativeCurrency.symbol}`)).usd}catch(t){return void console.error(`Unable to fetch token price for chain with id ${e.id}`)}}async getUsdPriceForSol(){try{return(await this.api.get("/api/v1/token_price?chainId=0&tokenSymbol=SOL")).usd}catch(e){return void console.error("Unable to fetch token price for SOL")}}async getSplTokenMetadata({mintAddress:e,cluster:t}){try{return await this.api.get(`/api/v1/spl_token_info?mint_address=${e}&cluster=${t}`)}catch(r){return void console.error(`Unable to fetch token metadata for ${t}:${e}`)}}async requestFarcasterSignerStatus(e){try{return await this.api.post("/api/v1/farcaster/signer/status",{ed25519_public_key:e})}catch(e){throw console.error("Unable to fetch Farcaster signer status"),e}}async generateSiweNonce({address:e,captchaToken:t}){try{return(await this.api.post(o.siweInitPath,{address:e,token:t})).nonce}catch(e){throw o.formatPrivyError(e)}}async authenticateWithSiweInternal({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a,mode:i}){return await this.api.post(o.siweAuthenticatePath,{message:e,signature:t,chainId:r,walletClientType:n,connectorType:a,mode:i})}async linkWithSiweInternal({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a}){return await this.api.post(o.siweLinkPath,{message:e,signature:t,chainId:r,walletClientType:n,connectorType:a})}async linkSmartWallet({message:e,signature:t,smartWalletType:r}){try{let n=await this.api.post(o.smartWalletLinkPath,{message:e,signature:t,smart_wallet_type:r});return u.convertUserResponseToUser(n)}catch(e){throw o.formatPrivyError(e)}}async linkWithSiwe({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a}){try{let i=await this.linkWithSiweInternal({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a});return u.convertUserResponseToUser(i)}catch(e){throw o.formatPrivyError(e)}}async generateSiwsNonce({address:e,captchaToken:t}){try{return(await this.api.post(o.siwsInitPath,{address:e,token:t})).nonce}catch(e){throw o.formatPrivyError(e)}}async authenticateWithSiwsInternal({message:e,signature:t,walletClientType:r,connectorType:n,mode:a,messageType:i="plain"}){return await this.api.post(o.siwsAuthenticatePath,{message:e,signature:t,walletClientType:r,connectorType:n,mode:a,message_type:i})}async sendAccountTransferRequest({nonce:e,account:t,accountType:r,externalWalletMetadata:n,telegramAuthResult:a,telegramWebAppData:i,farcasterEmbeddedAddress:s,oAuthUserInfo:l}){try{let c,d;switch(r){case"email":c=o.transferEmailPath,d={nonce:e,email:t};break;case"sms":c=o.transferPhonePath,d={nonce:e,phoneNumber:t};break;case"siwe":if(c=o.transferWalletPath,!n)throw Error("Wallet parameters must be defined");d={nonce:e,address:t,...n};break;case"farcaster":c=o.transferFarcasterPath,d={nonce:e,farcaster_id:t,farcaster_embedded_address:s};break;case"telegram":c=o.telegramAccountTransferPath,d={nonce:e,telegram_auth_result:a,telegram_web_app_data:i};break;case"custom":case"guest":case"passkey":throw Error("Invalid transfer account type");default:c=o.transferOAuthPath,d={nonce:e,userInfo:l}}let h=await this.api.post(c,d);return await this.getAuthenticatedUser()??u.convertUserResponseToUser(h)}catch(e){throw o.formatPrivyError(e)}}async linkWithSiwsInternal({message:e,signature:t,walletClientType:r,connectorType:n,messageType:a="plain"}){return await this.api.post(o.siwsLinkPath,{message:e,signature:t,walletClientType:r,connectorType:n,message_type:a})}async linkWithSiws({message:e,signature:t,walletClientType:r,connectorType:n,messageType:a="plain"}){try{let i=await this.linkWithSiwsInternal({message:e,signature:t,walletClientType:r,connectorType:n,messageType:a});return u.convertUserResponseToUser(i)}catch(e){throw o.formatPrivyError(e)}}async updateUserAndIdToken(){try{let e=await this.api.get(o.usersMePath);return this.session.updateIdentityToken(e.identity_token),u.convertUserResponseToUser(e.user)}catch(e){throw o.formatPrivyError(e)}}async scanTransaction(e){try{return await this.api.post(o.transactionScanningPath,e)}catch(e){throw o.formatPrivyError(e)}}constructor({apiUrl:e=or,appId:t,appClientId:r,timeout:n=2e4}){Object.defineProperty(this,Qa,{value:ei}),this._cachedProviderAppDetails={},this.apiUrl=e,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=e!==or&&e.startsWith("https://privy."),this.timeout=n,this.appId=t,this.appClientId=r,this.clientAnalyticsId=function(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}(this,Qa)[Qa](),Ga||(Ga=new Ya),this.session=Ga,this.api=this.generateApi(),this.session.client=this}}function ei(){if("undefined"==typeof window)return null;try{let e=Mt.get(wr);if("string"==typeof e&&e.length>0)return e}catch(e){}let e=c.v4();try{return Mt.put(wr,e),e}catch(t){return e}}const ti=({delayedExecution:t,...n})=>{let{enabled:a,siteKey:i,appId:o,setError:s,setToken:l,setExecuting:c,ref:d}=hn(),[,u]=r.useMemo((()=>i?.split("t:")||[]),[i]);if(r.useEffect((()=>d.current?.remove),[]),!a)return null;if(!u)throw Error("Unsupported captcha site key");/*#__PURE__*/return e.jsx("div",{className:"hidden h-0 w-0",children:/*#__PURE__*/e.jsx(m.Turnstile,{...n,ref:d,siteKey:u,options:{action:o,size:"invisible",...t?{appearance:"execute",execution:"execute"}:{appearance:"always",execution:"render"}},onUnsupported:()=>{n.onUnsupported?.(),console.warn("Browser does not support Turnstile.")},onError:()=>{n.onError?.(),s("Captcha failed"),c(!1)},onSuccess:e=>{n.onSuccess?.(e),l(e),c(!1)},onExpire:()=>{n.onExpire?.();try{d.current?.reset(),s(void 0),l(void 0)}catch(e){s("expired_and_failed_reset")}}})})},ri=e=>{let[t,n]=r.useState("auto");return r.useEffect((()=>{let t=new ResizeObserver((e=>{n(e[0]?.contentRect.height??"auto")}));return e.current&&t.observe(e.current),()=>{e.current&&t.unobserve(e.current)}}),[e.current]),t},ni={login:{onComplete:[],onError:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]},connectOrCreateWallet:{onSuccess:[],onError:[]},createWallet:{onSuccess:[],onError:[]},linkAccount:{onSuccess:[],onError:[]},update:{onSuccess:[],onError:[]},configureMfa:{onMfaRequired:[]},setWalletPassword:{onSuccess:[],onError:[]},setWalletRecovery:{onSuccess:[],onError:[]},signMessage:{onSuccess:[],onError:[]},signTypedData:{onSuccess:[],onError:[]},sendTransaction:{onSuccess:[],onError:[]},signTransaction:{onSuccess:[],onError:[]},signSolanaTransaction:{onSuccess:[],onError:[]},signSolanaMessage:{onSuccess:[],onError:[]},sendSolanaTransaction:{onSuccess:[],onError:[]},accessToken:{onAccessTokenGranted:[],onAccessTokenRemoved:[]},oAuthAuthorization:{onOAuthTokenGrant:[]},fundWallet:{onUserExited:[]},fundSolanaWallet:{onUserExited:[]},customAuth:{onAuthenticated:[],onUnauthenticated:[]}},ai=/*#__PURE__*/r.createContext(void 0);let ii=()=>r.useContext(ai);function oi(e,t){if(!t)return;let n=ii().current[e];return r.useEffect((()=>{for(let[r,a]of Object.entries(t))Object.prototype.hasOwnProperty.call(n,r)||console.warn(`Invalid event type "${r}" for action "${e}"`),n[r]?.push(a);return()=>{for(let[r,a]of Object.entries(t))Object.prototype.hasOwnProperty.call(n,r)||console.warn(`Invalid event type "${r}" for action "${e}"`),n[r]=n[r]?.filter((e=>e!==a))}}),[t])}function si(e,t,r,...n){for(let a of e.current[t][r])a(...n)}function li(){let e=ii();return(t,r,...n)=>si(e,t,r,...n)}function ci(e){oi("configureMfa",e)}const di=/*#__PURE__*/g.styled.div.withConfig({displayName:"Grow",componentId:"sc-ddbf22b4-0"})(["text-align:left;flex-grow:1;"]),ui=/*#__PURE__*/g.styled.div.withConfig({displayName:"AlignBottom",componentId:"sc-ddbf22b4-1"})(["display:flex;flex-direction:column;justify-content:flex-end;flex-grow:1;"]),hi=/*#__PURE__*/g.styled.div.withConfig({displayName:"LoginMethodContainer",componentId:"sc-ddbf22b4-2"})(["display:flex;flex-direction:column;gap:12px;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}"]),pi=/*#__PURE__*/g.styled(hi).withConfig({displayName:"LoginMethodContainerWithScrollShadows",componentId:"sc-ddbf22b4-3"})([""," background-repeat:no-repeat;background-size:100% 32px,100% 16px;background-attachment:local,scroll;max-height:400px;overflow-y:auto;scrollbar-width:none;padding:2px;"],(e=>"light"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.06)) bottom;":"dark"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.06)) bottom;":void 0));let yi=/*#__PURE__*/g.css(["&&{width:100%;font-size:16px;line-height:24px;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;align-items:center;padding:12px 16px;border:1px solid var(--privy-color-foreground-4) !important;border-radius:var(--privy-border-radius-mdlg);transition:background-color 200ms ease;cursor:pointer;&:hover{background-color:var(--privy-color-background-2);}&:disabled{cursor:pointer;background-color:var(--privy-color-background-2);}svg{height:24px;max-height:24px;max-width:24px;}}"]);const mi=/*#__PURE__*/g.styled.div.withConfig({displayName:"Subtitle",componentId:"sc-ddbf22b4-4"})(["text-align:center;font-size:14px;margin-bottom:24px;"]),gi=/*#__PURE__*/g.styled.button.attrs({className:"login-method-button"}).withConfig({displayName:"LoginMethodButton",componentId:"sc-ddbf22b4-5"})(["",""],yi),fi=/*#__PURE__*/g.styled.a.withConfig({displayName:"LoginMethodButtonLink",componentId:"sc-ddbf22b4-6"})(["",""],yi),wi=/*#__PURE__*/g.styled.div.withConfig({displayName:"Hide",componentId:"sc-ddbf22b4-7"})(["width:100%;height:100%;min-height:inherit;display:flex;flex-direction:column;",""],(e=>e.$if?"display: none;":"")),vi=/*#__PURE__*/g.styled.div.withConfig({displayName:"EmptyWalletState",componentId:"sc-ddbf22b4-8"})(["width:100%;height:100%;padding:",";"],(e=>e.$withPadding?"64px 0px":"0px")),xi=/*#__PURE__*/g.styled.div.withConfig({displayName:"Header",componentId:"sc-ddbf22b4-9"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-bottom:32px;gap:12px;& h3{font-size:18px;font-style:normal;font-weight:600;line-height:24px;}& p{max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;}"]),Ci=({success:t,fail:r})=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(bi,{className:t?"success":r?"fail":""}),/*#__PURE__*/e.jsx(ji,{className:t?"success":r?"fail":""})]}),bi=/*#__PURE__*/g.styled.span.withConfig({displayName:"Loader",componentId:"sc-ce7792e2-0"})(["&&{width:82px;height:82px;border-width:4px;border-style:solid;border-color:",";border-bottom-color:transparent;border-radius:50%;display:inline-block;box-sizing:border-box;animation:rotation 1.2s linear infinite;transition:border-color 800ms;}@keyframes rotation{0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}}&&&.success{border-color:var(--privy-color-success);border-bottom-color:var(--privy-color-success);}&&&.fail{border-color:var(--privy-color-error);border-bottom-color:var(--privy-color-error);}"],(e=>e.color??"var(--privy-color-accent)")),ji=/*#__PURE__*/g.styled(bi).withConfig({displayName:"LoaderFaint",componentId:"sc-ce7792e2-1"})(["&&{border-bottom-color:",";animation:none;opacity:0.5;}"],(e=>e.color??"var(--privy-color-accent)")),Ei=t=>/*#__PURE__*/e.jsx(ki,{color:t.color||"var(--privy-color-foreground-3)"});let ki=/*#__PURE__*/g.styled(bi).withConfig({displayName:"StyledButtonLoader",componentId:"sc-ce7792e2-2"})(["&&{height:1rem;width:1rem;margin:2px 0;border-width:1.5px;transition:border-color 200ms ease;}"]);const Ti=/*#__PURE__*/g.styled.button.withConfig({displayName:"Button",componentId:"sc-b2dfb420-0"})(["display:flex;flex-direction:row;align-items:center;justify-content:center;user-select:none;&{width:100%;cursor:pointer;border-radius:var(--privy-border-radius-md);font-size:1rem;font-style:normal;font-weight:500;line-height:22px;letter-spacing:-0.016px;}&&{padding:12px 16px;}"]),Ai=({children:t,loading:r,disabled:n,success:a,loadingText:i="Loading...",...o})=>/*#__PURE__*/e.jsx(_i,{disabled:r||n,$success:a,...o,children:r?/*#__PURE__*/e.jsxs("span",{children:[/*#__PURE__*/e.jsx(Ei,{}),i?/*#__PURE__*/e.jsx("span",{children:i}):null]}):t}),Ii=({children:t,loading:r,disabled:n,...a})=>/*#__PURE__*/e.jsx(Si,{disabled:n,...a,children:r?/*#__PURE__*/e.jsx(Ei,{color:"var(--privy-color-foreground-accent)"}):t});let Si=/*#__PURE__*/g.styled(Ti).withConfig({displayName:"StyledPrimaryButtonWithoutGray",componentId:"sc-b2dfb420-1"})(["position:relative;&&{background-color:var(--privy-color-accent);color:var(--privy-color-foreground-accent);transition:background-color 200ms ease;}&:hover{background-color:var(--privy-color-accent-dark);}&:active{background-color:var(--privy-color-accent-dark);}&:disabled,&:hover:disabled,&:active:disabled{cursor:not-allowed;pointer-events:none;color:var(--privy-color-foreground-accent);background-color:var(--privy-color-accent-dark);}"]);const Pi=({children:t,loading:r,disabled:n,loadingText:a="Loading...",...i})=>/*#__PURE__*/e.jsx(_i,{as:"a",disabled:r||n,...i,children:r?/*#__PURE__*/e.jsxs("span",{children:[/*#__PURE__*/e.jsx(Ei,{}),a?/*#__PURE__*/e.jsx("span",{children:a}):null]}):t});let _i=/*#__PURE__*/g.styled(Ti).withConfig({displayName:"StyledPrimaryButton",componentId:"sc-b2dfb420-2"})(["position:relative;&&{background-color:",";color:var(--privy-color-foreground-accent);transition:background-color 200ms ease;}&:hover{background-color:",";}&:active{background-color:",";}&:hover:disabled,&:active:disabled{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;}"," > span{display:flex;align-items:center;gap:8px;opacity:1;animation:fadein 200ms ease;}"],(e=>e.$warn?"var(--privy-color-error)":e.$success?"var(--privy-color-success)":"var(--privy-color-accent)"),(e=>e.$warn?"var(--privy-color-error)":e.$success?"var(--privy-color-success)":"var(--privy-color-accent-dark)"),(e=>e.$warn?"var(--privy-color-error)":e.$success?"var(--privy-color-success)":"var(--privy-color-accent-dark)"),(e=>e.disabled?/*#__PURE__*/g.css(["&&&,&&&:hover,&&&:active{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;pointer-events:none;}"]):""));const Ni=({children:t,loading:r,disabled:n,loadingText:a="Loading...",...i})=>/*#__PURE__*/e.jsx(Mi,{disabled:r||n,...i,children:r?/*#__PURE__*/e.jsxs("span",{children:[/*#__PURE__*/e.jsx(Ei,{}),a?/*#__PURE__*/e.jsx("span",{children:a}):null]}):t});let Mi=/*#__PURE__*/g.styled(Ti).withConfig({displayName:"StyledSecondaryButton",componentId:"sc-b2dfb420-3"})(["&&{border-width:1px;border-color:",";color:var(--privy-color-foreground);transition:border-color 200ms ease;}&:hover,&:active{border-color:",";}&:hover:disabled,&:active:disabled{border-color:var(--privy-color-foreground-accent);color:var(--privy-color-foreground-3);cursor:not-allowed;}> span{display:flex;align-items:center;gap:8px;opacity:1;animation:fadein 200ms ease;}"],(e=>e.$warn?"var(--privy-color-error)":"var(--privy-color-foreground-4)"),(e=>e.$warn?"var(--privy-color-error)":"var(--privy-color-foreground-3)"));const Wi=/*#__PURE__*/g.styled.button.withConfig({displayName:"SoftCtaButton",componentId:"sc-b2dfb420-4"})(["&&{padding:12px 16px;font-weight:500;text-align:center;color:var(--privy-color-foreground-accent);background-color:var(--privy-color-accent);border-radius:var(--privy-border-radius-sm);min-width:144px;opacity:",";transition:opacity 200ms ease,background-color 200ms ease,color 200ms ease;user-select:none;"," &:hover{background-color:var(--privy-color-accent-dark);}&:active{background-color:var(--privy-color-accent-dark);}&:hover:disabled,&:active:disabled{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;}}"],(e=>e.invisible?"0":"1"),(e=>e.invisible&&/*#__PURE__*/g.css(["pointer-events:none;"]))),Ui=({children:t,onClick:r,disabled:n,isSubmitting:a,...i})=>/*#__PURE__*/e.jsxs(Oi,{$isSubmitting:a,onClick:r,disabled:n,...i,children:[/*#__PURE__*/e.jsx("span",{children:t}),
2
2
  /*#__PURE__*/e.jsx("span",{children:/*#__PURE__*/e.jsx(Ei,{})})]});let Oi=/*#__PURE__*/g.styled.button.withConfig({displayName:"StyledEmbeddedButton",componentId:"sc-b2dfb420-6"})(["&&{color:var(--privy-color-accent);font-size:16px;font-style:normal;font-weight:500;line-height:24px;cursor:pointer;border-radius:0px var(--privy-border-radius-mdlg) var(--privy-border-radius-mdlg) 0px;border:none;transition:color 200ms ease;@media (min-width:441px){font-size:14px;}:hover{color:var(--privy-color-accent-dark);}&& > :first-child{opacity:",";}&& > :last-child{position:absolute;display:flex;top:50%;left:50%;transform:translate3d(-50%,-50%,0);opacity:",";}:disabled,:hover:disabled{color:var(--privy-color-foreground-3);cursor:not-allowed;}}"],(e=>e.$isSubmitting?0:1),(e=>e.$isSubmitting?1:0));function Fi(t){/*#__PURE__*/return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 460 40",...t,children:/*#__PURE__*/e.jsx("g",{fill:t.color||"var(--privy-color-foreground)",children:/*#__PURE__*/e.jsx("path",{d:"M0 15.4v15.38h4.64V19.96h3.58c2.47 0 3.63-.01 3.77-.02 1-.08 1.49-.15 2.18-.3a9.45 9.45 0 0 0 4.6-2.37c1.66-1.57 2.64-3.87 2.81-6.56.02-.3.02-1.19 0-1.49-.1-1.77-.56-3.35-1.36-4.72A8.84 8.84 0 0 0 15.14.57c-.93-.3-1.75-.43-3.09-.54C11.9.02 10.2 0 5.93 0H0ZM10.85 4c1.85.05 3.1.45 4.16 1.3.22.17.54.49.69.68a5.97 5.97 0 0 1 1.19 3.13c.04.35.04 1.36 0 1.71-.08.68-.23 1.3-.44 1.85a4.8 4.8 0 0 1-1.09 1.68A5.63 5.63 0 0 1 12 15.92c-.6.08-.4.08-4.01.09H4.64V3.98h2.9c1.6 0 3.08 0 3.31.02ZM187.65 5.71v5.72h-.27l-.09-.14a15.9 15.9 0 0 0-1.21-1.73c-.43-.5-1-.95-1.7-1.36-.54-.3-1.05-.5-1.73-.63a8.98 8.98 0 0 0-1.7-.17 8.84 8.84 0 0 0-7.8 4.03 12.95 12.95 0 0 0-2.03 6.39c-.07.98-.06 2.15.02 3.13.2 2.47.87 4.53 2.02 6.25a8.98 8.98 0 0 0 10.22 3.65 6.5 6.5 0 0 0 2.8-1.93c.41-.51.84-1.1 1.1-1.55l.1-.17h.37v3.58h4.38V0h-4.48Zm-5.24 5.54c1.3.14 2.3.6 3.17 1.48.9.9 1.5 2.09 1.85 3.64.36 1.6.39 3.72.06 5.43a8.13 8.13 0 0 1-1.54 3.62 5.1 5.1 0 0 1-3.93 1.96 6.13 6.13 0 0 1-2.32-.31 5.87 5.87 0 0 1-3.33-3.5c-.39-1-.62-2.05-.72-3.32-.03-.32-.04-1.35-.02-1.73.08-1.56.4-2.91.96-4.05a6.2 6.2 0 0 1 1.06-1.58 5.08 5.08 0 0 1 3.6-1.66c.25-.02.9 0 1.16.02ZM210.07 15.39l.01 15.38h4.38l.01-3.57h.37l.09.15c.24.44.84 1.26 1.21 1.7a6.79 6.79 0 0 0 2.57 1.75 9.3 9.3 0 0 0 6.86-.49 9.28 9.28 0 0 0 4.05-4.07A13.05 13.05 0 0 0 231 21.6c.21-1.73.18-3.7-.09-5.32a13.03 13.03 0 0 0-1.5-4.3 9.1 9.1 0 0 0-3.75-3.63 9.15 9.15 0 0 0-4.43-.96 7.46 7.46 0 0 0-2.8.5A7.07 7.07 0 0 0 216 9.7c-.4.52-.82 1.12-1.1 1.59l-.07.14h-.27V0h-4.5Zm11.13-4.14c1.07.1 1.94.44 2.7 1.04a6.1 6.1 0 0 1 1.64 1.98c.43.84.78 2 .94 3.11.15 1.16.16 2.4.02 3.54a9.34 9.34 0 0 1-1.39 4.03 5.33 5.33 0 0 1-2.69 2.15c-.9.3-2.04.38-3.06.2a5.14 5.14 0 0 1-3.45-2.37 6.03 6.03 0 0 1-.45-.8c-.5-1.03-.8-2.2-.92-3.58-.04-.49-.06-.89-.05-1.53.01-.76.05-1.23.13-1.85.38-2.53 1.47-4.38 3.15-5.31a5.46 5.46 0 0 1 2.3-.63 10 10 0 0 1 1.13.02ZM69.05 2.17l-.01 2.77V7.7h-3.36v3.6h3.36v6.8l.01 7.15c.06 1.4.4 2.44 1.1 3.37a5.8 5.8 0 0 0 2.97 2.07c.91.3 1.83.42 2.9.38a8.71 8.71 0 0 0 2.66-.48l-.8-3.7-.38.06a4.96 4.96 0 0 1-2.43-.06c-.33-.1-.56-.25-.8-.49-.4-.41-.6-.88-.7-1.67-.02-.2-.02-.62-.03-6.82v-6.6h4.73V7.7h-4.73V2.16h-4.49ZM133.34 2.17V7.7h-3.39v3.6h3.38v6.9l.01 7.17a5.66 5.66 0 0 0 2.36 4.49c.85.6 2.03 1.03 3.26 1.17.85.1 2.03.05 2.81-.1.3-.06.75-.18 1-.26l.2-.06v-.05l-.81-3.67-.37.06a4.99 4.99 0 0 1-1.8.09c-.85-.13-1.32-.4-1.7-.97a2.63 2.63 0 0 1-.39-1.04c-.06-.4-.06 0-.06-7.1V11.3h4.7V7.7h-4.7l-.01-2.77V2.16h-4.49ZM293.41 2.36a14.56 14.56 0 0 0-13.7 16.07 14.59 14.59 0 0 0 21.86 11.08 14.5 14.5 0 0 0 7.11-14.07 14.61 14.61 0 0 0-6.53-10.73 14.49 14.49 0 0 0-8.74-2.35ZM350.8 2.36a10.17 10.17 0 0 0-7.56 4.2c-.16.2-.45.63-.58.83l-.05.1h-.47l-.01-4.36h-7.36v36.4h7.82V27.27h.49l.05.07a11.3 11.3 0 0 0 7.49 4.15 10.52 10.52 0 0 0 9.38-4.1c1.66-2.1 2.73-4.9 3.07-8.06.1-.87.13-1.4.13-2.37 0-.8 0-1.1-.07-1.76a15.95 15.95 0 0 0-3.23-8.72 12.8 12.8 0 0 0-1.85-1.84 10.49 10.49 0 0 0-7.26-2.28Zm-.94 6.05c1.27.15 2.33.65 3.2 1.5.98.96 1.67 2.31 2.03 4 .34 1.57.38 3.68.12 5.39a9.78 9.78 0 0 1-1.04 3.25c-.14.25-.44.69-.6.89a5.35 5.35 0 0 1-4.31 2.07 5.25 5.25 0 0 1-4.41-1.9 7.35 7.35 0 0 1-1.26-2.32 14.09 14.09 0 0 1-.62-4.83c.05-1.98.38-3.53 1.02-4.85a5.63 5.63 0 0 1 2.5-2.65c.66-.34 1.3-.5 2.14-.58.18-.02 1.04 0 1.23.03ZM363.63 3.1l-.01 3.2v3.16h1.43c1.26.01 1.44.02 1.54.04.42.09.66.28.79.62.08.23.08.08.08 2.96a911.57 911.57 0 0 1 .03 10.18v7.54h7.82v-7.4l.01-7.83c.03-.94.11-1.63.27-2.28.46-1.9 1.54-2.93 3.35-3.23.52-.08.2-.08 5-.08h4.4V3.08h-3.1c-3.48 0-3.91.01-4.67.1-1.83.2-3.04.79-3.96 1.88-.5.6-.9 1.32-1.26 2.26l-.06.17h-.46V3.09h-5.6c-4.46 0-5.6 0-5.6.02ZM390.8 16.95V30.8h3.87l3.86-.01V3.09h-7.73ZM400.6 3.1l-.01.4v.38l4.66 13.4 4.69 13.47.02.05h10.3l.03-.05 4.67-13.45 4.67-13.4V3.1h-7.43l-6.7 19.26h-.5l-3.28-9.5-3.31-9.64-.05-.12h-3.88l-3.88.01ZM430.98 3.1c-.01 0-.02.19-.02.4v.39l5.08 14.59c2.8 8.02 5.08 14.6 5.08 14.61.01.02-.22.02-4.8.02h-4.82v6.42h4.95c5.09 0 5.23 0 5.87-.06 3.15-.28 5.29-1.63 6.63-4.15.28-.55.44-.95.87-2.16L459 6.78l1-2.89v-.8h-7.43l-6.69 19.26h-.5l-3.27-9.46-3.31-9.64-.06-.16h-3.88l-3.88.01ZM36.57 7.36c-1.36.1-2.6.6-3.62 1.45a5.65 5.65 0 0 0-1.67 2.42l-.05.13H31V7.7h-4.35v23.08h4.5v-7.3c0-8 0-7.34.08-7.82a4.89 4.89 0 0 1 2.06-3.18c.83-.58 1.74-.89 2.87-.98a11.87 11.87 0 0 1 2.8.25H39v-4.3l-.21-.02c-.61-.07-1.74-.1-2.22-.07ZM51.08 7.41c-2.33.12-4.3.84-5.95 2.16a9.89 9.89 0 0 0-2.03 2.2 12.5 12.5 0 0 0-2 5.78 18.04 18.04 0 0 0 0 3.65 12.13 12.13 0 0 0 2.26 6.05 9.74 9.74 0 0 0 5 3.52c2.11.64 4.7.64 6.8 0a9.78 9.78 0 0 0 4.88-3.37c1.38-1.78 2.19-4 2.4-6.58.13-1.46.06-3.06-.18-4.42a11.24 11.24 0 0 0-3.58-6.6 10 10 0 0 0-5.75-2.35c-.56-.06-1.31-.07-1.85-.04Zm1.42 3.78c.88.1 1.62.34 2.28.75a6.13 6.13 0 0 1 1.99 2.15 10.31 10.31 0 0 1 1.2 5c.02 1.23-.12 2.44-.42 3.51a7.14 7.14 0 0 1-1.81 3.32c-.61.6-1.2.98-1.95 1.24a6 6 0 0 1-2 .3 5.7 5.7 0 0 1-2.72-.6 5 5 0 0 1-1.28-.94A7.1 7.1 0 0 1 46 22.73c-.57-1.99-.6-4.46-.08-6.5a7.24 7.24 0 0 1 2.03-3.67 5.13 5.13 0 0 1 3.35-1.4 11 11 0 0 1 1.2.03ZM92.05 7.4c-.96.06-1.56.15-2.3.33a9.62 9.62 0 0 0-6.09 4.66 13.5 13.5 0 0 0-1.71 7c0 .83 0 1.04.06 1.6.16 1.77.58 3.32 1.29 4.7A9.72 9.72 0 0 0 90.28 31c1.84.37 4.08.32 5.85-.13a9.07 9.07 0 0 0 5.02-3.1A7.64 7.64 0 0 0 102.5 25l-2.11-.39-2.11-.38-.08.13a4.72 4.72 0 0 1-2.35 2.55 6.3 6.3 0 0 1-2.23.58c-.29.03-1.13.03-1.44 0a6.35 6.35 0 0 1-3.02-1.04 5.93 5.93 0 0 1-2.02-2.43 8.44 8.44 0 0 1-.72-3.18v-.26h16.38v-.81c0-1.83-.06-2.76-.25-3.87-.2-1.22-.53-2.24-1.05-3.28a8.9 8.9 0 0 0-2.66-3.26 10.1 10.1 0 0 0-5.34-1.94 18.3 18.3 0 0 0-1.46-.03Zm1.3 3.75c1.2.13 2.19.55 3.05 1.3a5.8 5.8 0 0 1 1.78 2.96c.13.51.21 1.17.21 1.66v.15H86.43v-.12c.08-.97.3-1.78.72-2.61.5-1 1.2-1.8 2.14-2.42a5.32 5.32 0 0 1 2.9-.95c.2-.01.97 0 1.17.03ZM116.79 7.41c-2 .1-3.73.65-5.22 1.65a10.7 10.7 0 0 0-4.25 6.06 16.1 16.1 0 0 0-.5 5.8c.2 2.17.84 4.13 1.88 5.76.58.9 1.32 1.73 2.15 2.4a9.37 9.37 0 0 0 3.6 1.8 12.06 12.06 0 0 0 3.92.34 10.2 10.2 0 0 0 3.84-.95 8.31 8.31 0 0 0 4.76-6.75l.01-.04h-4.37l-.05.16a4.87 4.87 0 0 1-4.24 3.75c-.59.07-1.32.06-1.93-.05a5.47 5.47 0 0 1-3.5-2.27c-.56-.75-1-1.73-1.26-2.79a13.8 13.8 0 0 1-.16-5.24 7.77 7.77 0 0 1 2.1-4.3 5.48 5.48 0 0 1 2.15-1.3 6.4 6.4 0 0 1 3.89.1c.59.21 1.03.5 1.5.96a5.32 5.32 0 0 1 1.46 2.5l.04.15h4.37v-.06a8.22 8.22 0 0 0-5.31-6.94 10.98 10.98 0 0 0-4.88-.74ZM156.2 7.41a9.87 9.87 0 0 0-6 2.29 11.02 11.02 0 0 0-3.41 5.43c-.52 1.78-.68 3.9-.48 5.97.17 1.8.63 3.38 1.37 4.8a9.68 9.68 0 0 0 5.91 4.86c1.65.48 3.63.61 5.53.36 3.72-.49 6.55-2.62 7.56-5.69.12-.39.13-.42.1-.43-.02 0-4.13-.75-4.19-.75-.03 0-.04 0-.1.16-.18.42-.45.9-.72 1.22-.16.2-.49.53-.7.7-.67.54-1.5.9-2.43 1.08-.48.08-.83.11-1.41.11-.64 0-1.07-.04-1.6-.15a5.76 5.76 0 0 1-3.93-2.83 8 8 0 0 1-.99-3.79v-.16h16.38v-1.11l-.02-1.43c-.1-2.25-.53-4-1.35-5.59a9.24 9.24 0 0 0-6.18-4.75c-1.04-.26-2.2-.36-3.33-.3Zm1.45 3.74a5.35 5.35 0 0 1 3.66 1.94 6.1 6.1 0 0 1 1.38 4.01v.12h-11.97v-.06c0-.02 0-.14.02-.25a6.6 6.6 0 0 1 2.15-4.32 5.73 5.73 0 0 1 3.5-1.46c.25-.02 1 0 1.26.02ZM233.58 7.82l8.37 23.22a49.22 49.22 0 0 1-.67 1.9 5.36 5.36 0 0 1-1.14 1.8c-.41.4-.82.58-1.48.69-.27.04-1.03.03-1.35 0a8.05 8.05 0 0 1-1.1-.23l-1.08 3.67c0 .02.32.14.66.22.83.21 1.57.29 2.56.28.56-.01.8-.03 1.24-.1 2.71-.4 4.66-2.09 5.86-5.08l9.64-26.44c0-.02-4.82-.06-4.83-.05l-2.93 8.96-2.91 8.94h-.24l-.22-.65-2.91-8.95-2.7-8.3H233.53ZM293.05 35.8c-1.18.04-1.93.09-2.8.16-2.52.24-4.53.69-5.43 1.23-.7.41-.76.86-.2 1.28.88.66 3.29 1.19 6.36 1.4a48.55 48.55 0 0 0 5.75.05c3.47-.19 6.24-.78 7.11-1.5.22-.19.3-.34.3-.53 0-.1 0-.12-.04-.22-.35-.69-2.32-1.3-5.25-1.63a41.09 41.09 0 0 0-5.8-.24Zm0 0"})})})}let Ri=/*#__PURE__*/g.styled.div.withConfig({displayName:"TermsAndConditionsContainer",componentId:"sc-bdb69ecc-0"})(["margin-top:16px;font-size:13px;text-align:center;color:var(--privy-color-foreground-3);&& > a{color:var(--privy-color-accent);}"]);function Li({app:{legal:{privacyPolicyUrl:t,termsAndConditionsUrl:r,requireUsersAcceptTerms:n}},alwaysShowImplicitConsent:a}){let i=!(!t||!r);return n&&!a||!r&&!t?
3
3
  /*#__PURE__*/e.jsx(Ri,{}):
4
4
  /*#__PURE__*/ /*#__PURE__*/e.jsxs(Ri,{children:["By logging in I agree to the"," ",r&&/*#__PURE__*/e.jsx("a",{href:r,target:"_blank",children:i?"Terms":"Terms of Service"}),i&&" & ",t&&/*#__PURE__*/e.jsx("a",{href:t,target:"_blank",children:"Privacy Policy"})]})}const Di=()=>{let{appearance:t}=_a();/*#__PURE__*/return e.jsx(Bi,{children:t.footerLogo??/*#__PURE__*/e.jsx("a",{href:"https://www.privy.io/",target:"_blank",id:"protected-by-privy",children:/*#__PURE__*/e.jsx(Fi,{height:13,width:150})})})},Bi=/*#__PURE__*/g.styled.div.withConfig({displayName:"ModalFooter",componentId:"sc-bdb69ecc-1"})(["display:flex;align-items:center;justify-content:center;padding-top:8px;padding-bottom:12px;gap:8px;font-size:13px;&& a{padding:0.5rem 0;&:hover{text-decoration:none;}}@media all and (display-mode:standalone){padding-bottom:30px;}"]),zi=({backFn:t})=>/*#__PURE__*/e.jsx("div",{children:/*#__PURE__*/e.jsx(Hi,{onClick:t,children:/*#__PURE__*/e.jsx(We.default,{height:"16px",width:"16px",strokeWidth:2})})}),$i=({infoFn:t})=>/*#__PURE__*/e.jsx("div",{children:/*#__PURE__*/e.jsx(Ki,{"aria-label":"info",onClick:t,children:/*#__PURE__*/e.jsx(Ue.default,{height:"22px",width:"22px",strokeWidth:2})})}),qi=t=>/*#__PURE__*/e.jsx("div",{children:/*#__PURE__*/e.jsx(Hi,{"aria-label":"close modal",onClick:t.onClose,children:/*#__PURE__*/e.jsx(Oe.default,{height:"16px",width:"16px",strokeWidth:2})})}),Vi=({backFn:t,infoFn:r,onClose:n,title:a,closeable:i=!0})=>{let{closePrivyModal:o}=s.usePrivyInternal(),l=_a();/*#__PURE__*/return e.jsxs(Zi,{children:[/*#__PURE__*/e.jsxs(Yi,{children:[t&&/*#__PURE__*/e.jsx(zi,{backFn:t}),r&&/*#__PURE__*/e.jsx($i,{infoFn:r})]}),a&&/*#__PURE__*/e.jsx(Ji,{id:"privy-dialog-title",children:a}),/*#__PURE__*/e.jsx(Gi,{children:!l.render.standalone&&i&&/*#__PURE__*/e.jsx(qi,{onClose:n||(()=>o())})})]})};let Hi=/*#__PURE__*/g.styled.button.withConfig({displayName:"StyledButton",componentId:"sc-f295093d-0"})(["&&{cursor:pointer;display:flex;opacity:0.6;background-color:var(--privy-color-background-2);border-radius:var(--privy-border-radius-full);padding:4px;> svg{margin:auto;color:var(--privy-color-foreground);}:hover{opacity:1;}}"]),Ki=/*#__PURE__*/g.styled(Hi).withConfig({displayName:"TransparentStyledButton",componentId:"sc-f295093d-1"})(["&&{background-color:transparent;}"]),Zi=/*#__PURE__*/g.styled.div.withConfig({displayName:"StyledHeader",componentId:"sc-f295093d-2"})(["padding:16px 0;display:flex;align-items:center;justify-content:space-between;h2{font-size:16px;line-height:24px;font-weight:600;color:var(--privy-color-foreground);}"]),Yi=/*#__PURE__*/g.styled.div.withConfig({displayName:"LeftActionContainer",componentId:"sc-f295093d-3"})(["flex:1;align-items:center;display:flex;gap:8px;"]),Gi=/*#__PURE__*/g.styled.div.withConfig({displayName:"RightActionContainer",componentId:"sc-f295093d-4"})(["flex:1;display:flex;justify-content:flex-end;"]),Ji=/*#__PURE__*/g.styled.div.withConfig({displayName:"TitleContainer",componentId:"sc-f295093d-5"})(["overflow:hidden;white-space:nowrap;max-width:100%;text-overflow:ellipsis;text-align:center;color:var(--privy-color-foreground-2);"]),Qi=Array(6).fill("");var Xi,eo=((Xi=eo||{})[Xi.RESET_AFTER_DELAY=0]="RESET_AFTER_DELAY",Xi[Xi.CLEAR_ON_NEXT_VALID_INPUT=1]="CLEAR_ON_NEXT_VALID_INPUT",Xi);function to(e){return/^[0-9]{1}$/.test(e)}function ro(e){return 6===e.length&&e.every(to)}const no=({onChange:t,disabled:a,errorReasonOverride:i,success:o})=>{let[s,l]=r.useState(Qi),[c,d]=r.useState(null),[u,h]=r.useState(null),p=async e=>{e.preventDefault();let r=e.currentTarget.value.replace(/\s+/g,"");if(""===r)return;let n=s.reduce(((e,t)=>e+Number(to(t))),0),a=r.split(""),i=!a.every(to),o=a.length+n>6;if(i)return d("Passcode can only be numbers"),void h(1);if(o)return d("Passcode must be exactly 6 numbers"),void h(1);d(null),h(null);let c=Number(e.currentTarget.name?.charAt(4)),u=[...r||[""]].slice(0,6-c),p=[...s.slice(0,c),...u,...s.slice(c+u.length)];l(p);let y=Math.min(Math.max(c+u.length,0),5),m=document.querySelector(`input[name=pin-${y}]`);if(m?.focus(),ro(p))try{await t(p.join(""));let e=document.querySelector(`input[name=pin-${y}]`);e?.blur()}catch(e){h(1),d(e.message)}else try{await t(null)}catch(e){h(1),d(e.message)}},y=o?"success":!(!i&&!c)?"fail":"";/*#__PURE__*/return e.jsx(e.Fragment,{children:/*#__PURE__*/e.jsxs(ao,{children:[/*#__PURE__*/e.jsx("div",{children:s.map(((r,i)=>/*#__PURE__*/e.jsx("input",{name:`pin-${i}`,type:"text",value:s[i],onChange:p,onKeyUp:e=>{"Backspace"===e.key&&(e=>{1===u&&(d(null),h(null));let r=[...s.slice(0,e),"",...s.slice(e+1)];if(l(r),e>0){let t=document.querySelector(`input[name=pin-${e-1}]`);t?.focus()}ro(r)?t(r.join("")):t(null)})(i)},inputMode:"numeric",autoFocus:0===i,pattern:"[0-9]",className:y,autoComplete:n.isMobile?"one-time-code":"off",disabled:a},i)))}),/*#__PURE__*/e.jsx("div",{children:/*#__PURE__*/e.jsx(io,{$fail:!!i||!!c,children:i||c})})]})})};let ao=/*#__PURE__*/g.styled.div.withConfig({displayName:"PinInputContainer",componentId:"sc-7a171f6-0"})(["display:flex;flex-direction:column;width:100%;gap:8px;@media (max-width:440px){margin-top:8px;margin-bottom:8px;}> div:nth-child(1){display:flex;justify-content:center;gap:0.5rem;width:100%;border-radius:var(--privy-border-radius-md);> input{border:1px solid var(--privy-color-foreground-4);background:var(--privy-color-background);border-radius:var(--privy-border-radius-md);padding:8px 10px;height:58px;width:46px;text-align:center;font-size:18px;}> input:disabled{background:var(--privy-color-background-2);}> input:focus{border:1px solid var(--privy-color-accent);}> input:invalid{border:1px solid var(--privy-color-error);}> input.success{border:1px solid var(--privy-color-success);}> input.fail{border:1px solid var(--privy-color-error);animation:shake 180ms;animation-iteration-count:2;}}@keyframes shake{0%{transform:translate(1px,0px);}33%{transform:translate(-1px,0px);}67%{transform:translate(-1px,0px);}100%{transform:translate(1px,0px);}}"]),io=/*#__PURE__*/g.styled.div.withConfig({displayName:"InputHelp",componentId:"sc-7a171f6-1"})(["line-height:20px;font-size:13px;display:flex;justify-content:flex-start;width:100%;color:",";"],(e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)"));const oo=({label:t,children:r,valueStyles:n})=>/*#__PURE__*/e.jsxs(so,{children:[/*#__PURE__*/e.jsx("div",{children:t}),/*#__PURE__*/e.jsx(lo,{style:{...n},children:r})]});let so=/*#__PURE__*/g.styled.div.withConfig({displayName:"StyledDetailsRow",componentId:"sc-4ebfdd45-0"})(["display:flex;align-items:center;justify-content:space-between;width:100%;> :first-child{color:var(--privy-color-foreground-3);text-align:left;}> :last-child{color:var(--privy-color-foreground-2);text-align:right;}"]),lo=/*#__PURE__*/g.styled.div.withConfig({displayName:"ValueWrapper",componentId:"sc-4ebfdd45-1"})(["font-size:14px;line-height:100%;display:flex;align-items:center;justify-content:center;border-radius:var(--privy-border-radius-full);background-color:var(--privy-color-background-2);padding:4px 8px;"]),co=new Intl.NumberFormat(void 0,{style:"currency",currency:"USD",maximumFractionDigits:2}),uo=e=>co.format(e);const ho=(e,t)=>{let r=uo(t*parseFloat(e));return"$0.00"!==r?r:"<$0.01"},po=(e,t)=>{let r=uo(t*parseFloat(l.formatEther(e)));return"$0.00"===r?"<$0.01":r},yo=(e,t,r=6,n=!1)=>`${mo(e,r,n)} ${t}`,mo=(e,t=6,r=!1)=>{let n=parseFloat(l.formatEther(e)).toFixed(t).replace(/0+$/,"").replace(/\.$/,"");return r?n:`${"0"===n?"<0.001":n}`},go=e=>e.reduce(((e,t)=>e+t),0n),fo=(e,t)=>{let{chains:r}=s.usePrivyInternal(),n=`https://etherscan.io/address/${t}`,a=`${((e,t)=>{let r=Number(e),n=t.find((e=>e.id===r));if(!n)throw new o.PrivyConnectorError(`Unsupported chainId ${e}`,4901);return n.blockExplorers?.default.url})(e,r)}/address/${t}`;if(!a)return n;try{new URL(a)}catch{return n}return a};async function wo(e,t){try{return await e}catch{return t}}const vo="11111111111111111111111111111111",xo=["CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C","CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW"],Co=["JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"];let bo=new Intl.NumberFormat(void 0,{style:"currency",currency:"USD",maximumFractionDigits:2});function jo(e,t=6,r=!1,n=!1){let a=(parseFloat(e.toString())/1e9).toFixed(t).replace(/0+$/,"").replace(/\.$/,""),i=n?"":" SOL";return r?`${a}${i}`:`${"0"===a?"<0.001":a}${i}`}function Eo(e,t){let r=parseFloat(e.toString())/1e9,n=bo.format(t*r);return"$0.00"===n?"<$0.01":n}function ko({amount:e,fee:t,tokenPrice:r,isUsdc:n}){let a=BigInt(Math.floor(parseFloat(e)*10**(n?6:9))),i=n?a:a+t;return{fundingAmountInBaseUnit:a,fundingAmountInUsd:r?Eo(a,r):void 0,totalPriceInUsd:r?Eo(i,r):void 0,totalPriceInNativeCurrency:jo(i),feePriceInNativeCurrency:jo(t),feePriceInUsd:r?Eo(t,r):void 0}}let To={"mainnet-beta":{EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:{symbol:"USDC",decimals:6,address:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"},Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:{symbol:"USDT",decimals:6,address:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"},So11111111111111111111111111111111111111112:{symbol:"SOL",decimals:9,address:"So11111111111111111111111111111111111111112"}},devnet:{"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU":{symbol:"USDC",decimals:6,address:"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"},EJwZgeZrdC8TXTQbQBoL6bfuAnFUUy1PVCMB4DYPzVaS:{symbol:"USDT",decimals:6,address:"EJwZgeZrdC8TXTQbQBoL6bfuAnFUUy1PVCMB4DYPzVaS"},So11111111111111111111111111111111111111112:{symbol:"SOL",decimals:9,address:"So11111111111111111111111111111111111111112"}},testnet:{}};async function Ao(e,t,r){let n=To[e];if(!n[r]){let a=await t.getSplTokenMetadata({mintAddress:r,cluster:e});a&&(n[r]={address:r,symbol:a.symbol,decimals:a.decimals})}return n[r]}function Io(e){return"version"in e}function So(e,t){let r=(Io(e)?e.message:e.compileMessage()).staticAccountKeys.find((e=>e.toBase58()===t));if(!r)throw Error(`Transaction does not contain public key ${t}`);return r}function Po(e,t,r){return{signature:e,parsedTransaction:r??null,signedTransaction:t,fees:BigInt(r?.meta?.fee||0)}}async function _o(e,t){let{value:r}=await t.simulateTransaction(e);if("BlockhashNotFound"===r.err)throw Error("Simulation failed: Blockhash not found");return null==r.err&&r.logs?.every((e=>!/insufficient funds/gi.test(e)))}async function No({tx:e,connection:t,client:r,checkFunds:n}){let a=Io(e)?e.message:e.compileMessage(),i=a.staticAccountKeys[0]?.toBase58()??"",o=await async function(e,t){return BigInt((Io(e)?(await t.getFeeForMessage(e.message)).value:await e.getEstimatedFee(t))??0)}(e,t),s=!n||await wo(_o(e,t),!0),l={},c=[],d=await async function(e,t){return[...e.staticAccountKeys.map((e=>e)),...(await Promise.all(e.addressTableLookups.map((async e=>t.getAddressLookupTable(e.accountKey).then((({value:e})=>e)))))).map(((t,r)=>[...e.addressTableLookups[r]?.writableIndexes.map((e=>{let n=t?.state.addresses[e];if(n)return{key:n,isWritable:!0,altIdx:r}}))??[],...e.addressTableLookups[r]?.readonlyIndexes.map((e=>{let n=t?.state.addresses[e];if(n)return{key:n,isWritable:!1,altIdx:r}}))??[]])).flat().filter((e=>!!e)).sort(((e,t)=>e.isWritable!==t.isWritable?e.isWritable?-1:1:e.altIdx-t.altIdx)).map((({key:e})=>e))]}(a,t);for(let e of a.compiledInstructions){let n=a.staticAccountKeys[e.programIdIndex]?.toBase58()||"";if("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"!==n&&"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"!==n)if(n!==vo){if("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"===n){let t=await wo(function(e,t,r){let[n,a,i,o]=e.accountKeyIndexes.map((e=>t[e]));return{type:"ata-creation",program:r,payer:n?.toBase58(),ata:a?.toBase58(),owner:i?.toBase58(),mint:o?.toBase58()}}(e,d,n));if(!t){c.push({type:"unknown",program:n,discriminator:e.data[0]});continue}if(c.push(t),t.ata&&t.owner&&t.mint){l[t.ata]={owner:t.owner,mint:t.mint};continue}}if(xo.includes(n)){let a=await wo(Oo(e,d,t,r,n));if(!a){c.push({type:"unknown",program:n,discriminator:e.data[0]});continue}c.push(a)}else if(Co.includes(n)){let a=await wo(Fo(e,d,t,r,n));if(!a){c.push({type:"unknown",program:n,discriminator:e.data[0]});continue}c.push(a)}else c.push({type:"unknown",program:n,discriminator:e.data[0]})}else{let t=await wo(Uo(e,d));if(!t){c.push({type:"unknown",program:n,discriminator:e.data[0]});continue}c.push(t)}else{let a=await wo(Wo(e,d,t,r,l,n));if(!a){c.push({type:"unknown",program:n,discriminator:e.data[0]});continue}c.push(a),"spl-transfer"===a.type&&(a.fromAta&&a.fromAccount&&a.token.address&&(l[a.fromAta]??={owner:a.fromAccount,mint:a.token.address}),a.toAta&&a.toAccount&&a.token.address&&(l[a.toAta]??={owner:a.toAccount,mint:a.token.address}))}}return{spender:i,fee:o,instructions:c,hasFunds:!!s}}function Mo(e,t=0){try{return function(e,t=0){let r=0n;for(let n=0;n<8;n++)r|=BigInt(e[t+n])<<BigInt(8*n);return r}(e,t)}catch{}try{return e.readBigInt64LE(t)}catch{}let r=nn(e);try{return((e,t=0)=>{let r=e[t],n=e[t+7];if(!r||!n)throw Error(`Buffer offset out of range: first: ${r}, last: ${n}.`);return(BigInt(e[t+4]+256*e[t+5]+65536*e[t+6]+(n<<24))<<32n)+BigInt(r+256*e[++t]+65536*e[++t]+16777216*e[++t])})(r)}catch{}try{return r.subarray(t).readBigInt64LE()}catch{}try{return r.readBigInt64LE(t)}catch{}return 0n}async function Wo(e,t,r,n,a,i){let o=e.data[0],s=e.accountKeyIndexes.map((e=>t[e]));if(1===o){let[e,t,r]=s;return{type:"spl-init-account",program:i,account:e?.toBase58(),mint:t?.toBase58(),owner:r?.toBase58()}}if(3===o){let t,o,[l,c,d]=s,u="",h=c?a[c.toBase58()]:void 0;if(h)t=h.owner,u=h.mint;else if(c){let e=await r.getParsedAccountInfo(c,"confirmed"),n=e.value?.data;t=n?.parsed?.info?.owner,u=n?.parsed?.info?.mint??"",o=n?.parsed?.info?.tokenAmount?.decimals}if(!u&&l){let e=await r.getParsedAccountInfo(l,"confirmed"),t=e.value?.data;u=t?.parsed?.info?.mint??""}let p=Ca(r.rpcEndpoint),y=await Ao(p,n,u),m=y?.symbol??"";return o??=y?.decimals??9,{type:"spl-transfer",program:i,fromAta:l?.toBase58(),fromAccount:d?.toBase58(),toAta:c?.toBase58(),toAccount:t,value:Mo(e.data,1),token:{symbol:m,decimals:o,address:u}}}if(9===o){let[e,t,r]=s;return{type:"spl-close-account",program:i,source:e?.toBase58(),destination:t?.toBase58(),owner:r?.toBase58()}}if(17===o)return{type:"spl-sync-native",program:i};throw Error(`Token program instruction type ${o} not supported`)}async function Uo(e,t){let r=e.data[0],n=e.accountKeyIndexes.map((e=>t[e]));if(0===r){let[,t]=n;return{type:"create-account",program:vo,account:t?.toBase58(),value:Mo(e.data,4),withSeed:!1}}if(2===r){let[t,r]=n;return{type:"sol-transfer",program:vo,fromAccount:t?.toBase58(),toAccount:r?.toBase58(),token:{symbol:"SOL",decimals:9},value:Mo(e.data,4),withSeed:!1}}if(3===r){let[,t]=n,r=Mo(e.data.slice(e.data.length-32-8-8));return{type:"create-account",program:vo,account:t?.toBase58(),withSeed:!0,value:r}}if(11===r){let[t,r]=n;return{type:"sol-transfer",program:vo,fromAccount:t?.toBase58(),toAccount:r?.toBase58(),value:Mo(e.data,4),token:{symbol:"SOL",decimals:9},withSeed:!0}}throw Error(`System program instruction type ${r} not supported`)}async function Oo(e,t,r,n,a){let i=e.accountKeyIndexes.map((e=>t[e]?.toBase58())),o=e.data[0],s=Ca(r.rpcEndpoint);if(143===o){let t=i[10],r=i[11];return{type:"raydium-swap-base-input",program:a,mintIn:t,mintOut:r,tokenIn:t?await Ao(s,n,t):void 0,tokenOut:r?await Ao(s,n,r):void 0,amountIn:Mo(e.data,8),minimumAmountOut:Mo(e.data,16)}}if(55===o){let t=i[10],r=i[11];return{type:"raydium-swap-base-output",program:a,mintIn:t,mintOut:r,tokenIn:t?await Ao(s,n,t):void 0,tokenOut:r?await Ao(s,n,r):void 0,maxAmountIn:Mo(e.data,8),amountOut:Mo(e.data,16)}}throw Error(`Raydium swap program instruction type ${o} not supported`)}async function Fo(e,t,r,n,a){let i=e.data[0],o=e.accountKeyIndexes.map((e=>t[e])),s=Ca(r.rpcEndpoint);if([208,51,239,151,123,43,237,92].includes(i)){let t=o[5]?.toBase58(),r=o[6]?.toBase58();return{type:"jupiter-swap-exact-out-route",program:a,mintIn:t,mintOut:r,tokenIn:t?await Ao(s,n,t):void 0,tokenOut:r?await Ao(s,n,r):void 0,outAmount:Mo(e.data,e.data.length-1-2-8-8),quotedInAmount:Mo(e.data,e.data.length-1-2-8)}}if([176,209,105,168,154,125,69,62].includes(i)){let t=o[7]?.toBase58(),r=o[8]?.toBase58();return{type:"jupiter-swap-exact-out-route",program:a,mintIn:t,mintOut:r,tokenIn:t?await Ao(s,n,t):void 0,tokenOut:r?await Ao(s,n,r):void 0,outAmount:Mo(e.data,e.data.length-1-2-8-8),quotedInAmount:Mo(e.data,e.data.length-1-2-8)}}if([193,32,155,51,65,214,156,129].includes(i)){let t=o[7]?.toBase58(),r=o[8]?.toBase58();return{type:"jupiter-swap-shared-accounts-route",program:a,mintIn:t,mintOut:r,tokenIn:t?await Ao(s,n,t):void 0,tokenOut:r?await Ao(s,n,r):void 0,inAmount:Mo(e.data,e.data.length-1-2-8-8),quotedOutAmount:Mo(e.data,e.data.length-1-2-8)}}throw[62,198,214,193,213,159,108,210].includes(i)&&console.warn("Jupiter swap program instruction 'claim' not implemented"),[116,206,27,191,166,19,0,73].includes(i)&&console.warn("Jupiter swap program instruction 'claim_token' not implemented"),[26,74,236,151,104,64,183,249].includes(i)&&console.warn("Jupiter swap program instruction 'close_token' not implemented"),[229,194,212,172,8,10,134,147].includes(i)&&console.warn("Jupiter swap program instruction 'create_open_orders' not implemented"),[28,226,32,148,188,136,113,171].includes(i)&&console.warn("Jupiter swap program instruction 'create_program_open_orders' not implemented"),[232,242,197,253,240,143,129,52].includes(i)&&console.warn("Jupiter swap program instruction 'create_token_ledger' not implemented"),[147,241,123,100,244,132,174,118].includes(i)&&console.warn("Jupiter swap program instruction 'create_token_account' not implemented"),[229,23,203,151,122,227,173,42].includes(i)&&console.warn("Jupiter swap program instruction 'route' not implemented"),[150,86,71,116,167,93,14,104].includes(i)&&console.warn("Jupiter swap program instruction 'route_with_token_ledger' not implemented"),[228,85,185,112,78,79,77,2].includes(i)&&console.warn("Jupiter swap program instruction 'set_token_ledger' not implemented"),[230,121,143,80,119,159,106,170].includes(i)&&console.warn("Jupiter swap program instruction 'shared_accounts_route_with_token_ledger' not implemented"),Error(`Jupiter swap program instruction type ${i} not supported`)}const Ro=({weiQuantities:t,tokenPrice:r,tokenSymbol:n})=>{let a=go(t),i=r?po(a,r):void 0,o=yo(a,n);/*#__PURE__*/return e.jsx(Bo,{children:i||o})},Lo=({weiQuantities:t,tokenPrice:r,tokenSymbol:n})=>{let a=go(t),i=r?po(a,r):void 0,o=yo(a,n);/*#__PURE__*/return e.jsx(Bo,{children:i?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(zo,{children:"USD"}),"<$0.01"===i?
@@ -24,5 +24,5 @@ return e.jsx(us,{..._a().render.standalone?{defaultValue:"details"}:{},children:
24
24
  /*#__PURE__*/e.jsx(Lp,{style:{marginTop:"2rem"},children:a.shortMessage??Gg}):null,/*#__PURE__*/e.jsx($g,{variant:N,preventMaliciousTransaction:U,setPreventMaliciousTransaction:O}),/*#__PURE__*/e.jsx(Zg,{$useSmallMargins:!(!a&&!n&&"warn"!==N&&"error"!==N),title:Number(c)>0?void 0:!1!==j?"Your wallet":void 0,address:m,balance:k,isLoading:x||C,errMsg:x||a||n||!p?void 0:`Add funds on ${w?.name??_} to complete transaction.`}),/*#__PURE__*/e.jsx(Ai,{style:{marginTop:"1rem"},loading:v,disabled:f||x,onClick:T,children:g}),D&&/*#__PURE__*/e.jsx(Ui,{style:{marginTop:"1rem"},onClick:i,isSubmitting:!1,children:"Not now"}),/*#__PURE__*/e.jsx(Di,{})]})},Kg=({img:t,title:n,subtitle:a,cta:o,instructions:s,network:l,blockExplorerUrl:c,isMissingFunds:d,submitError:u,parseError:h,total:p,swap:y,transactingWalletAddress:m,fee:g,balance:f,disabled:w,isSubmitting:v,isPreparing:x,isTokenPriceLoading:C,onClick:b,onClose:j,onBack:E})=>{let k=x||C,[T,A]=r.useState(!1);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{onClose:j,backFn:E}),t&&/*#__PURE__*/e.jsx(Jg,{children:t}),/*#__PURE__*/e.jsx(ly,{style:{marginTop:t?"1.5rem":0},children:n}),/*#__PURE__*/e.jsx(sy,{children:a}),/*#__PURE__*/e.jsxs(Gy,{style:{marginTop:"2rem",marginBottom:".5rem"},children:[(p||k)&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Amount"}),/*#__PURE__*/e.jsx(em,{$isLoading:k,children:p})]}),y&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Swap"}),/*#__PURE__*/e.jsx(em,{children:y})]}),l&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Network"}),/*#__PURE__*/e.jsx(em,{children:l})]}),(g||k)&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Estimated fee"}),/*#__PURE__*/e.jsx(em,{$isLoading:k,children:g})]})]}),/*#__PURE__*/e.jsx(Jy,{children:/*#__PURE__*/e.jsxs(Ug,{onClick:()=>A((e=>!e)),children:[/*#__PURE__*/e.jsx("span",{children:"Advanced"}),/*#__PURE__*/e.jsx(de.ChevronDownIcon,{height:"16px",width:"16px",strokeWidth:"2",style:{transition:"all 300ms",transform:T?"rotate(180deg)":void 0}})]})}),T&&/*#__PURE__*/e.jsx(e.Fragment,{children:s.map(((t,r)=>"sol-transfer"===t.type?/*#__PURE__*/e.jsxs(Yg,{children:[/*#__PURE__*/e.jsx(Jy,{children:/*#__PURE__*/e.jsxs(gy,{children:["Transfer ",t.withSeed?"with seed":""]})}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Amount"}),/*#__PURE__*/e.jsxs(em,{children:[i.formatTokenAmount({amount:t.value,decimals:t.token.decimals})," ",t.token.symbol]})]}),!!t.toAccount&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Destination"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.toAccount,url:c})})]})]},r):"spl-transfer"===t.type?/*#__PURE__*/e.jsxs(Yg,{children:[/*#__PURE__*/e.jsx(Jy,{children:/*#__PURE__*/e.jsxs(gy,{children:["Transfer ",t.token.symbol]})}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Amount"}),/*#__PURE__*/e.jsx(em,{children:t.value.toString()})]}),!!t.fromAta&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Source"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.fromAta,url:c})})]}),!!t.toAta&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Destination"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.toAta,url:c})})]}),!!t.token.address&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Token"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.token.address,url:c})})]})]},r):"ata-creation"===t.type?/*#__PURE__*/e.jsxs(Yg,{children:[/*#__PURE__*/e.jsx(Jy,{children:/*#__PURE__*/e.jsx(gy,{children:"Create token account"})}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Program ID"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.program,url:c})})]}),!!t.owner&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Owner"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.owner,url:c})})]})]},r):"create-account"===t.type?/*#__PURE__*/e.jsxs(Yg,{children:[/*#__PURE__*/e.jsx(Jy,{children:/*#__PURE__*/e.jsxs(gy,{children:["Create account ",t.withSeed?"with seed":""]})}),!!t.account&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Account"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.account,url:c})})]}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Amount"}),/*#__PURE__*/e.jsxs(em,{children:[i.formatTokenAmount({amount:t.value,decimals:9})," SOL"]})]})]},r):"spl-init-account"===t.type?/*#__PURE__*/e.jsxs(Yg,{children:[/*#__PURE__*/e.jsx(Jy,{children:/*#__PURE__*/e.jsx(gy,{children:"Initialize token account"})}),!!t.account&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Account"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.account,url:c})})]}),!!t.mint&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Mint"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.mint,url:c})})]}),!!t.owner&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Owner"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.owner,url:c})})]})]},r):"spl-close-account"===t.type?/*#__PURE__*/e.jsxs(Yg,{children:[/*#__PURE__*/e.jsx(Jy,{children:/*#__PURE__*/e.jsx(gy,{children:"Close token account"})}),!!t.source&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Source"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.source,url:c})})]}),!!t.destination&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Destination"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.destination,url:c})})]}),!!t.owner&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Owner"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.owner,url:c})})]})]},r):"spl-sync-native"===t.type?/*#__PURE__*/e.jsxs(Yg,{children:[/*#__PURE__*/e.jsx(Jy,{children:/*#__PURE__*/e.jsx(gy,{children:"Sync native"})}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Program ID"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.program,url:c})})]})]},r):"raydium-swap-base-input"===t.type?/*#__PURE__*/e.jsxs(Yg,{children:[/*#__PURE__*/e.jsx(Jy,{children:/*#__PURE__*/e.jsxs(gy,{children:["Raydium swap"," ",t.tokenIn&&t.tokenOut?`${t.tokenIn.symbol} → ${t.tokenOut.symbol}`:""]})}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Amount in"}),/*#__PURE__*/e.jsx(em,{children:t.amountIn.toString()})]}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Minimum amount out"}),/*#__PURE__*/e.jsx(em,{children:t.minimumAmountOut.toString()})]}),t.mintIn&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Token in"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.mintIn,url:c})})]}),t.mintOut&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Token out"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.mintOut,url:c})})]})]},r):"raydium-swap-base-output"===t.type?/*#__PURE__*/e.jsxs(Yg,{children:[/*#__PURE__*/e.jsx(Jy,{children:/*#__PURE__*/e.jsxs(gy,{children:["Raydium swap"," ",t.tokenIn&&t.tokenOut?`${t.tokenIn.symbol} → ${t.tokenOut.symbol}`:""]})}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Max amount in"}),/*#__PURE__*/e.jsx(em,{children:t.maxAmountIn.toString()})]}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Amount out"}),/*#__PURE__*/e.jsx(em,{children:t.amountOut.toString()})]}),t.mintIn&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Token in"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.mintIn,url:c})})]}),t.mintOut&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Token out"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.mintOut,url:c})})]})]},r):"jupiter-swap-shared-accounts-route"===t.type?/*#__PURE__*/e.jsxs(Yg,{children:[/*#__PURE__*/e.jsx(Jy,{children:/*#__PURE__*/e.jsxs(gy,{children:["Jupiter swap"," ",t.tokenIn&&t.tokenOut?`${t.tokenIn.symbol} → ${t.tokenOut.symbol}`:""]})}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"In amount"}),/*#__PURE__*/e.jsx(em,{children:t.inAmount.toString()})]}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Quoted out amount"}),/*#__PURE__*/e.jsx(em,{children:t.quotedOutAmount.toString()})]}),t.mintIn&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Token in"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.mintIn,url:c})})]}),t.mintOut&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Token out"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.mintOut,url:c})})]})]},r):"jupiter-swap-exact-out-route"===t.type?/*#__PURE__*/e.jsxs(Yg,{children:[/*#__PURE__*/e.jsx(Jy,{children:/*#__PURE__*/e.jsxs(gy,{children:["Jupiter swap"," ",t.tokenIn&&t.tokenOut?`${t.tokenIn.symbol} → ${t.tokenOut.symbol}`:""]})}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Quoted in amount"}),/*#__PURE__*/e.jsx(em,{children:t.quotedInAmount.toString()})]}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Amount out"}),/*#__PURE__*/e.jsx(em,{children:t.outAmount.toString()})]}),t.mintIn&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Token in"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.mintIn,url:c})})]}),t.mintOut&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Token out"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.mintOut,url:c})})]})]},r):/*#__PURE__*/e.jsxs(Yg,{children:[/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Program ID"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Od,{address:t.program,url:c})})]}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Data"}),/*#__PURE__*/e.jsx(em,{children:t.discriminator})]})]},r)))}),/*#__PURE__*/e.jsx(di,{}),u?/*#__PURE__*/e.jsx(Lp,{style:{marginTop:"2rem"},children:u.message}):h?/*#__PURE__*/e.jsx(Lp,{style:{marginTop:"2rem"},children:Gg}):null,/*#__PURE__*/e.jsx(Zg,{$useSmallMargins:!(!h&&!u),title:"Your wallet",address:m,balance:f,isLoading:x||C,errMsg:x||h||u||!d?void 0:"Add funds on Solana to complete transaction."}),/*#__PURE__*/e.jsx(Ai,{style:{marginTop:"1rem"},loading:v,disabled:w||x,onClick:b,children:o}),/*#__PURE__*/e.jsx(Di,{})]})};let Zg=/*#__PURE__*/g.styled(vy).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-c5b70898-0"})(["",""],(e=>e.$useSmallMargins?"margin-top: 0.5rem;":"margin-top: 2rem;")),Yg=/*#__PURE__*/g.styled(Gy).withConfig({displayName:"InstructionRows",componentId:"sc-c5b70898-1"})(["margin-top:0.5rem;border:1px solid var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-sm);padding:0.5rem;"]),Gg="There was an error preparing your transaction. Your transaction request will likely fail.",Jg=/*#__PURE__*/g.styled.div.withConfig({displayName:"ImageContainer",componentId:"sc-c5b70898-2"})(["display:flex;width:100%;justify-content:center;max-height:40px;> img{object-fit:contain;border-radius:var(--privy-border-radius-sm);}"]),Qg=()=>/*#__PURE__*/e.jsxs(nf,{children:[/*#__PURE__*/e.jsx(of,{}),/*#__PURE__*/e.jsx(af,{})]});const Xg=({transactionError:t,chainId:n,onClose:a,onRetry:i,network:o,connection:l,transactionHash:c})=>{let{chains:d}=s.usePrivyInternal(),[u,h]=r.useState(!1),{errorCode:p,errorMessage:y}=((e,t)=>{if("ethereum"===t)return{errorCode:e.details??e.message,errorMessage:e.shortMessage};let r=e.txSignature,n=e?.transactionMessage||"Something went wrong.";if(Array.isArray(e.logs)){let t=e.logs.find((e=>/insufficient (lamports|funds)/gi.test(e)));t&&(n=t)}return{transactionHash:r,errorMessage:n}})(t,o),m=(({chains:e,chainId:t,network:r,connection:n,transactionHash:a})=>"ethereum"===r?e.find((e=>e.id===t))?.blockExplorers?.default.url??"https://etherscan.io":function(e,t){return`https://explorer.solana.com/tx/${e}?cluster=${t}`}(a||"",Ca(n?.rpcEndpoint||"")))({chains:d,chainId:n,network:o,connection:l,transactionHash:c});/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{onClose:a}),/*#__PURE__*/e.jsxs(ef,{children:[/*#__PURE__*/e.jsx(Qg,{}),/*#__PURE__*/e.jsx(tf,{children:p}),/*#__PURE__*/e.jsx(rf,{children:"Please try again."}),/*#__PURE__*/e.jsxs(cf,{children:[/*#__PURE__*/e.jsx(lf,{children:"Error message"}),/*#__PURE__*/e.jsx(uf,{$clickable:!1,children:y})]}),c&&/*#__PURE__*/e.jsxs(cf,{children:[/*#__PURE__*/e.jsx(lf,{children:"Transaction hash"}),/*#__PURE__*/e.jsxs(df,{children:["Copy this hash to view details about the transaction on a"," ",/*#__PURE__*/e.jsx("u",{children:/*#__PURE__*/e.jsx("a",{href:m,children:"block explorer"})}),"."]}),/*#__PURE__*/e.jsxs(uf,{$clickable:!0,onClick:async()=>{await navigator.clipboard.writeText(c),h(!0)},children:[c,/*#__PURE__*/e.jsx(yf,{clicked:u})]})]}),/*#__PURE__*/e.jsx(sf,{onClick:()=>i({resetNonce:!!c}),children:"Retry transaction"})]}),/*#__PURE__*/e.jsx(Bi,{})]})};let ef=/*#__PURE__*/g.styled.div.withConfig({displayName:"TransactionErrorScreenContainer",componentId:"sc-92716bea-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;"]),tf=/*#__PURE__*/g.styled.span.withConfig({displayName:"ErrorCode",componentId:"sc-92716bea-1"})(["color:var(--privy-color-foreground);text-align:center;font-size:1.125rem;font-weight:500;line-height:1.25rem;text-align:center;margin:10px;"]),rf=/*#__PURE__*/g.styled.span.withConfig({displayName:"Subtitle",componentId:"sc-92716bea-2"})(["margin-top:4px;margin-bottom:10px;color:var(--privy-color-foreground-3);text-align:center;font-size:0.875rem;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;"]),nf=/*#__PURE__*/g.styled.div.withConfig({displayName:"CircleContainer",componentId:"sc-92716bea-3"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]),af=/*#__PURE__*/g.styled(Ze.default).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-92716bea-4"})(["position:absolute;width:35px;height:35px;color:var(--privy-color-error);"]),of=/*#__PURE__*/g.styled.div.withConfig({displayName:"StyledRedCircle",componentId:"sc-92716bea-5"})(["position:absolute;width:60px;height:60px;border-radius:50%;background-color:var(--privy-color-error);opacity:0.1;"]),sf=/*#__PURE__*/g.styled(Ai).withConfig({displayName:"RetryButton",componentId:"sc-92716bea-6"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]),lf=/*#__PURE__*/g.styled.span.withConfig({displayName:"TextBoxTitle",componentId:"sc-92716bea-7"})(["width:100%;text-align:left;font-size:0.825rem;color:var(--privy-color-foreground);padding:4px;"]),cf=/*#__PURE__*/g.styled.div.withConfig({displayName:"TextBoxContainer",componentId:"sc-92716bea-8"})(["width:100%;margin:5px;display:flex;flex-direction:column;justify-content:center;align-items:center;"]),df=/*#__PURE__*/g.styled.text.withConfig({displayName:"HelperText",componentId:"sc-92716bea-9"})(["position:relative;width:100%;padding:5px;font-size:0.8rem;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;"]),uf=/*#__PURE__*/g.styled.span.withConfig({displayName:"TextBox",componentId:"sc-92716bea-10"})(["position:relative;width:100%;background-color:var(--privy-color-background-2);padding:8px 12px;border-radius:10px;margin-top:5px;font-size:14px;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;",""],(e=>e.$clickable&&"cursor: pointer;\n transition: background-color 0.3s;\n padding-right: 45px;\n\n &:hover {\n background-color: var(--privy-color-foreground-4);\n }")),hf=/*#__PURE__*/g.styled(ft.default).withConfig({displayName:"StyledClipboardIcon",componentId:"sc-92716bea-11"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),pf=/*#__PURE__*/g.styled(ct.default).withConfig({displayName:"StyledClipboardCheckIcon",componentId:"sc-92716bea-12"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),yf=({clicked:t})=>t?/*#__PURE__*/e.jsx(pf,{}):/*#__PURE__*/e.jsx(hf,{});const mf=({instruction:t,fees:r,transactionInfo:n,solPrice:a,rpcEndpoint:i})=>/*#__PURE__*/e.jsxs(Gy,{children:[n?.action&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Action"}),/*#__PURE__*/e.jsx(em,{children:n.action})]}),null!=t?.total&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Total"}),/*#__PURE__*/e.jsx(em,{children:t.total})]}),!t?.total&&null!=t?.amount&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Total"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Do,{quantities:[t.amount,r],tokenPrice:a})})]}),/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"Fees"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Do,{quantities:[r],tokenPrice:a})})]}),t?.to&&/*#__PURE__*/e.jsxs(Jy,{children:[/*#__PURE__*/e.jsx(Qy,{children:"To"}),/*#__PURE__*/e.jsx(em,{children:/*#__PURE__*/e.jsx(Es,{walletAddress:t.to,rpcEndpoint:i,network:"solana"})})]})]}),gf=({fees:t,onClose:r,receiptHeader:n,receiptDescription:a,transactionInfo:i,solPrice:o,rpcEndpoint:s,signOnly:l,instruction:c})=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{onClose:r}),/*#__PURE__*/e.jsx(dl,{style:{marginBottom:"16px"},children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(_d,{color:"var(--privy-color-success-light)"}),/*#__PURE__*/e.jsx(ht.default,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-success)"})]})}),/*#__PURE__*/e.jsx(nc,{title:n??`Transaction ${l?"signed":"complete"}!`,description:a??"You're all set."}),/*#__PURE__*/e.jsx(mf,{solPrice:o,instruction:c,fees:t,transactionInfo:i,rpcEndpoint:s}),/*#__PURE__*/e.jsx(di,{}),/*#__PURE__*/e.jsx(ff,{loading:!1,onClick:r,children:"Close"}),/*#__PURE__*/e.jsx(es,{}),/*#__PURE__*/e.jsx(Di,{})]});let ff=/*#__PURE__*/g.styled(Ai).withConfig({displayName:"SubmitButton",componentId:"sc-df6d4eec-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);const wf={component:()=>{let{data:t,onUserCloseViaDialogOrKeybindRef:n,setModalData:a,navigate:o}=Ua(),{client:l,closePrivyModal:c,walletProxy:d,showFiatPrices:h}=s.usePrivyInternal(),p=_a(),{user:y}=u.usePrivyContext(),[m,g]=r.useState(t?.sendSolanaTransaction?.transactionRequest),[f,w]=r.useState(),[v,x]=r.useState(),[C,b]=r.useState({value:0n,isLoading:!1}),[j,E]=r.useState(!1),[k,T]=r.useState(),[A,I]=r.useState(),S=t?.sendSolanaTransaction?.connection,P=t?.sendSolanaTransaction?.transactingWallet,_=!!t?.sendSolanaTransaction?.signOnly,N=P?.imported?u.getImportedPrivySolanaWallet(y):u.getPrivyPrimaryWallet(y),M=Ca(S?.rpcEndpoint||""),{solPrice:W,isSolPriceLoading:U}=Ss({enabled:h}),O=r.useMemo((()=>{if(!f)return;let e=f.spender,t=jo(f.fee),r=jo(C.value,3,!0),n=f.instructions.filter((e=>["sol-transfer","spl-transfer","raydium-swap-base-input","raydium-swap-base-output","jupiter-swap-shared-accounts-route","jupiter-swap-exact-out-route"].includes(e.type))),a=n.at(0);if(!a||n.length>1)return{fee:t,spender:e,balance:r};if("sol-transfer"===a.type)return{fee:t,spender:e,balance:r,total:jo(a.value)};if("spl-transfer"===a.type)return{fee:t,spender:e,balance:r,total:`${i.formatTokenAmount({amount:a.value,decimals:a.token.decimals})} ${a.token.symbol}`};if("raydium-swap-base-input"===a.type&&a.tokenIn&&a.tokenOut){return{fee:t,spender:e,balance:r,swap:`${`${i.formatTokenAmount({amount:a.amountIn,decimals:a.tokenIn.decimals})} ${a.tokenIn.symbol}`} → ${`${i.formatTokenAmount({amount:a.minimumAmountOut,decimals:a.tokenOut.decimals})} ${a.tokenOut.symbol}`}`}}if("raydium-swap-base-output"===a.type&&a.tokenIn&&a.tokenOut){return{fee:t,spender:e,balance:r,swap:`${`${i.formatTokenAmount({amount:a.maxAmountIn,decimals:a.tokenIn.decimals})} ${a.tokenIn.symbol}`} → ${`${i.formatTokenAmount({amount:a.amountOut,decimals:a.tokenOut.decimals})} ${a.tokenOut.symbol}`}`}}if("jupiter-swap-shared-accounts-route"===a.type&&a.tokenIn&&a.tokenOut){return{fee:t,spender:e,balance:r,swap:`${`${i.formatTokenAmount({amount:a.inAmount,decimals:a.tokenIn.decimals})} ${a.tokenIn.symbol}`} → ${`${i.formatTokenAmount({amount:a.quotedOutAmount,decimals:a.tokenOut.decimals})} ${a.tokenOut.symbol}`}`}}if("jupiter-swap-exact-out-route"===a.type&&a.tokenIn&&a.tokenOut){return{fee:t,spender:e,balance:r,swap:`${`${i.formatTokenAmount({amount:a.quotedInAmount,decimals:a.tokenIn.decimals})} ${a.tokenIn.symbol}`} → ${`${i.formatTokenAmount({amount:a.outAmount,decimals:a.tokenOut.decimals})} ${a.tokenOut.symbol}`}`}}return{fee:t,spender:e,balance:r}}),[f,P?.address,C]),F=r.useMemo((()=>{let e;if(!f||!h||!W||U)return;function t(...e){return Eo(e.reduce(((e,t)=>e+t),0n),W??0)}P?.address===f.spender&&(e=t(f.fee));let r=t(C.value),n=f.instructions.filter((e=>"sol-transfer"===e.type||"spl-transfer"===e.type)).at(0);return!n||f.instructions.length>1?{fee:e,balance:r}:"sol-transfer"===n.type?{fee:e,balance:r,total:t(n.value,P?.address===f.spender?f.fee:0n)}:"spl-transfer"===n.type?{fee:e,balance:r,total:`${i.formatTokenAmount({amount:n.value,decimals:n.token.decimals})} ${n.token.symbol}`}:{fee:e,balance:r}}),[f,h,W,U,P?.address,C]);if(r.useEffect((()=>{!async function(){if(m&&S&&l)try{x(void 0);let e=await No({tx:m,connection:S,client:l,checkFunds:!_});w(e)}catch(e){console.error("Failed to prepare transaction",e),x(e)}}()}),[m,S,l,_]),r.useEffect((()=>{(async function(){if(!P||!S)return;b({value:C.value,isLoading:!0});let e=new i.SolanaClient({name:"mainnet-beta",rpcUrl:S.rpcEndpoint});b({value:await e.getBalance(P.address).catch((()=>0n))??0n,isLoading:!1})})().catch(console.error)}),[f,S]),!(m&&t?.sendSolanaTransaction&&P&&S)){let r=Error("Invalid transaction request");/*#__PURE__*/return e.jsx(Gd,{error:r,onClick:()=>{t?.sendSolanaTransaction?.onFailure(r),c({shouldCallAuthOnSuccess:!1})}})}let R=()=>{if(!j)return k?t?.sendSolanaTransaction?.onSuccess(k):t?.sendSolanaTransaction?.onFailure(A??v??Error("User exited the modal before submitting the transaction")),c({shouldCallAuthOnSuccess:!1})};n.current=R;let L=t.sendSolanaTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?/*#__PURE__*/e.jsx("img",{src:t.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:t.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,D=!!(t.funding&&t.funding.supportedOptions.length>0),B=!f?.hasFunds&&D;if(k){let r=f?.instructions.filter((e=>"sol-transfer"===e.type||"spl-transfer"===e.type)),n=1===r?.length?r?.at(0):void 0;/*#__PURE__*/return e.jsx(gf,{fees:k.fees,onClose:R,transactionInfo:t.sendSolanaTransaction?.uiOptions.transactionInfo,solPrice:W,receiptHeader:t.sendSolanaTransaction?.uiOptions.successHeader,receiptDescription:t.sendSolanaTransaction?.uiOptions.successDescription,rpcEndpoint:S.rpcEndpoint,signOnly:_,instruction:"sol-transfer"===n?.type?{to:n.toAccount,amount:n.value}:{to:n?.toAccount||n?.toAta,total:O?.total}})}return A?/*#__PURE__*/e.jsx(Xg,{transactionError:A,connection:S,onClose:R,network:"solana",onRetry:async()=>{I(void 0);let{blockhash:e}=await S.getLatestBlockhash();Io(m)?m.message.recentBlockhash=e:m.recentBlockhash=e,g(m)}}):/*#__PURE__*/e.jsx(Kg,{img:L,title:t.sendSolanaTransaction?.uiOptions?.transactionInfo?.title||"Confirm transaction",subtitle:t.sendSolanaTransaction?.uiOptions?.description||`${p.name} wants your permission to approve the following transaction.`,cta:B?"Add funds":t.sendSolanaTransaction?.uiOptions?.buttonText||"Approve",instructions:f?.instructions??[],network:"mainnet-beta"==M?"Solana":M,blockExplorerUrl:p.solanaClusters[M].blockExplorerUrl,total:h?F?.total:O?.total,fee:h?F?.fee:O?.fee,balance:h?F?.balance:O?.balance,swap:O?.swap,transactingWalletAddress:P.address,disabled:!f?.hasFunds&&!D,isSubmitting:j,isPreparing:!f||C.isLoading,isTokenPriceLoading:h&&U,isMissingFunds:!f?.hasFunds,submitError:A??void 0,parseError:v,onClick:B?async()=>{if(P){if(!D)throw Error("Funding wallet is not enabled");a({...t,funding:{...t.funding,methodScreen:wg}}),o(wg)}}:async()=>{try{if(E(!0),j||!P||!d||!y||!N)return;let e=await t.sendSolanaTransaction.onConfirm();T(e)}catch(e){console.warn({transaction:m,error:e}),I(e)}finally{E(!1)}},onClose:R})}},vf=({privy:e,appConfig:t,getAccessToken:r,isHeadlessSigning:n,emitPrivyEvent:a,setModalData:s,openModal:l,walletProxy:c,user:d,signWithUserSigner:h,recoverEmbeddedWallet:p},{transaction:y,connection:m,transactionOptions:g,fundWalletConfig:f,uiOptions:w,address:v,signOnly:x})=>new Promise((async(C,b)=>{let{requesterAppId:j}=w||{},E=x?"signSolanaTransaction":"sendSolanaTransaction";if(!d)return a(E,"onError",o.PrivyErrorCode.MUST_BE_AUTHENTICATED),void b(new o.PrivyClientError("User must be authenticated before signing with a Privy wallet",o.PrivyErrorCode.MUST_BE_AUTHENTICATED));let k=v?u.getPrivyWalletWithAddress(d,v):u.getPrivySolanaWallet(d);if(!k)return a(E,"onError",o.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void b(new o.PrivyClientError("Must have a Privy wallet before signing",o.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND));let T=u.getIsUnifiedWallet(k);if(!await p({address:k.address}).catch((()=>!1)))throw a(E,"onError",o.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),new o.PrivyClientError(`Cannot sendSolanaTransaction before embedded wallet ${k.address} is connected`,o.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND);let A=async()=>{let t=await r();if(!t||!c)throw a(E,"onError",o.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),b(new o.PrivyClientError("Must have valid access token and Privy wallet to send transaction",o.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND)),new o.PrivyClientError("Must have valid access token and Privy wallet to send transaction",o.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND);try{let r,s;if(!await p({address:k.address}))throw a(E,"onError",o.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),b(new o.PrivyClientError("Unable to connect to wallet",o.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR)),new o.PrivyClientError("Unable to connect to wallet",o.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR);if(n({showWalletUIs:w?.showWalletUIs})&&!x)try{if(!await _o(y,m))throw a(E,"onError",o.PrivyErrorCode.INSUFFICIENT_BALANCE),b(new o.PrivyClientError("Solana wallet has insufficient funds for this transaction.",o.PrivyErrorCode.INSUFFICIENT_BALANCE)),new o.PrivyClientError("Solana wallet has insufficient funds for this transaction.",o.PrivyErrorCode.INSUFFICIENT_BALANCE)}catch(e){throw console.error(e),a(E,"onError",o.PrivyErrorCode.TRANSACTION_FAILURE),b(new o.PrivyClientError(e instanceof Error?e.message:"Transaction failed.",o.PrivyErrorCode.TRANSACTION_FAILURE)),new o.PrivyClientError(e instanceof Error?e.message:"Transaction failed.",o.PrivyErrorCode.TRANSACTION_FAILURE)}let{entropyId:l,entropyIdVerifier:u}=xn(d);if(T){let t=Io(y)?nn(y.message.serialize()):y.serializeMessage(),n=await i.rpc(e,h,{chain_type:"solana",method:"signMessage",params:{message:t.toString("base64"),encoding:"base64"},wallet_id:k.id});if(!n.data||!("signature"in n.data))throw Error("Failed to sign transaction");y.addSignature(So(y,k.address),nn(n.data.signature,"base64")),r=y}else r=await Ay({accessToken:t,tx:y,walletProxy:c,entropyId:l,entropyIdVerifier:u,transactingWalletAddress:k.address,transactingWalletIndex:k.walletIndex??0});if(x)return s=Po("",r,null),a("signSolanaTransaction","onSuccess",{signedTransaction:r}),s;{let{signature:e,receipt:t}=await async function({tx:e,connection:t,transactionOptions:r}){let n;try{let a=e.serialize();n=await t.sendRawTransaction(a,r);let i=await t.confirmTransaction(n);if(i.value.err||i.value.err){let e=i.value.err||i.value.err;if("string"==typeof e)throw Error(e);throw e}return{signature:n,signedTransaction:e,receipt:await t.getParsedTransaction(n,{maxSupportedTransactionVersion:0})}}catch(e){throw e.txSignature=n,e}}({tx:r,connection:m,transactionOptions:g});s=Po(e,y,t),a("sendSolanaTransaction","onSuccess",{response:s})}return C(s),s}catch(e){throw a(E,"onError",o.PrivyErrorCode.TRANSACTION_FAILURE),b(e),e}};if(n({showWalletUIs:w?.showWalletUIs}))A();else{let{entropyId:e,entropyIdVerifier:r}=xn(d,k),n={recoveryMethod:k.recoveryMethod,connectingWalletAddress:k.address,entropyId:e,entropyIdVerifier:r,isUnifiedWallet:T,onCompleteNavigateTo:wf,onFailure:e=>{a(E,"onError",o.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),b(e)}},i=Oy(t)?kg({address:k.address,appConfig:t,methodScreen:wg,fundWalletConfig:f,comingFromSendTransactionScreen:!0}):void 0;s({connectWallet:n,sendSolanaTransaction:{transactionRequest:y,connection:m,transactionOptions:g,transactingWallet:k,onConfirm:A,onSuccess:e=>{x?a("signSolanaTransaction","onSuccess",{signedTransaction:e.signedTransaction}):a("sendSolanaTransaction","onSuccess",{response:e}),C(e)},onFailure:e=>{a(E,"onError",o.PrivyErrorCode.TRANSACTION_FAILURE),b(e)},uiOptions:w||{},requesterAppId:j,signOnly:x},funding:i}),l(Mg)}}));function xf(e){let t=_a(),{getAccessToken:r,user:n}=Wy(),{setModalData:a}=Ua(),{isHeadlessSigning:i,openModal:o,walletProxy:l,recoverEmbeddedWallet:c,privy:d}=s.usePrivyInternal(),h=li(),{signWithUserSigner:p}=u.useSignWithUserSigner();return oi("sendSolanaTransaction",e),{sendTransaction:async({transaction:e,connection:s,uiOptions:u,transactionOptions:y,fundWalletConfig:m,address:g})=>await vf({privy:d,appConfig:t,getAccessToken:r,isHeadlessSigning:i,emitPrivyEvent:h,setModalData:a,openModal:o,walletProxy:l,user:n,signWithUserSigner:p,recoverEmbeddedWallet:c},{transaction:e,connection:s,transactionOptions:y,uiOptions:u,fundWalletConfig:m,address:g,signOnly:!1})}}const Cf=/*#__PURE__*/g.styled.img.withConfig({displayName:"StyledLogo",componentId:"sc-68c1b1ea-0"})(["&&{height:",";width:",";border-radius:16px;margin-bottom:12px;}"],(e=>"sm"===e.size?"65px":"140px"),(e=>"sm"===e.size?"65px":"140px"));let bf=({data:t})=>{let r=t=>"object"==typeof t&&null!==t?/*#__PURE__*/e.jsx(Ef,{children:Object.entries(t).map((([t,n])=>/*#__PURE__*/e.jsxs("li",{children:[/*#__PURE__*/e.jsxs("strong",{children:[t,":"]})," ",r(n)]},t)))}):/*#__PURE__*/e.jsx("span",{children:String(t)});/*#__PURE__*/return e.jsx("div",{children:r(t)})};const jf=/*#__PURE__*/g.styled.div.withConfig({displayName:"Message",componentId:"sc-ccf49562-0"})(["margin-top:1.5rem;background-color:var(--privy-color-background-2);border-radius:var(--privy-border-radius-md);padding:12px;text-align:left;max-height:310px;overflow:scroll;white-space:pre-wrap;width:100%;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}"]);let Ef=/*#__PURE__*/g.styled.ul.withConfig({displayName:"MessageList",componentId:"sc-ccf49562-1"})(["margin-left:12px !important;white-space:nowrap;&:first-child{margin-left:0 !important;}strong{font-weight:500 !important;}"]);const kf=({data:t})=>/*#__PURE__*/e.jsx(jf,{children:/*#__PURE__*/e.jsx(bf,{data:t})});let Tf=e=>{if(!l.isHex(e))return e;try{let t=l.hexToString(e);return t.includes("�")?e:t}catch{return e}},Af=e=>JSON.stringify(e,null,2),If=t=>{let{types:r,primaryType:n,...a}=t.typedData;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(kf,{data:a}),/*#__PURE__*/e.jsx(Fu,{text:Af(t.typedData),itemName:"full payload to clipboard"})," "]})};const Sf={component:()=>{let{authenticated:t}=u.usePrivyContext(),{initializeWalletProxy:n,closePrivyModal:a}=s.usePrivyInternal(),{navigate:o,data:l,onUserCloseViaDialogOrKeybindRef:c}=Ua(),[d,h]=r.useState(!0),[p,y]=r.useState(""),[m,g]=r.useState(),[f,w]=r.useState(null),[v,x]=r.useState(!1),C=null!==f;r.useEffect((()=>{t||o(Jp)}),[t]),r.useEffect((()=>{n(Sr).then((e=>{h(!1),e||(y("An error has occurred, please try again."),g(new Tn(new kn(p,i.ProviderErrors.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))}))}),[]);let{method:b,data:j,confirmAndSign:E,onSuccess:k,onFailure:T,uiOptions:A}=l.signMessage,I={title:A?.title||"Sign message",description:A?.description||"Signing this message will not cost you any fees.",buttonText:A?.buttonText||"Sign and continue"},S=e=>{e?k(e):T(m||new Tn(new kn("The user rejected the request.",i.ProviderErrors.E4001_USER_REJECTED_REQUEST.eipCode))),a({shouldCallAuthOnSuccess:!1}),setTimeout((()=>{w(null),y(""),g(void 0)}),200)};return c.current=()=>{S(f)},/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{onClose:()=>S(f)}),/*#__PURE__*/e.jsx(Xo,{}),A?.iconUrl&&"string"==typeof A.iconUrl?/*#__PURE__*/e.jsx(Nf,{children:/*#__PURE__*/e.jsx(Cf,{size:"sm",src:A.iconUrl,alt:"app image"})}):null,/*#__PURE__*/e.jsx(ly,{children:I.title}),/*#__PURE__*/e.jsx(sy,{children:I.description}),"personal_sign"===b&&/*#__PURE__*/e.jsx(jf,{children:Tf(j)}),"eth_signTypedData_v4"===b&&/*#__PURE__*/e.jsx(If,{typedData:j}),"solana_signMessage"===b&&/*#__PURE__*/e.jsx(jf,{children:j}),/*#__PURE__*/e.jsx(Mf,{}),/*#__PURE__*/e.jsx(Pf,{$fail:!0,children:p}),/*#__PURE__*/e.jsx(Ii,{disabled:v||C||d,loading:v,onClick:async()=>{x(!0),y("");try{let e=await E();w(e),x(!1),setTimeout((()=>{S(e)}),sr)}catch(e){console.error(e),y("An error has occurred, please try again."),g(new Tn(new kn(p,i.ProviderErrors.E32603_DEFAULT_INTERNAL_ERROR.eipCode))),x(!1)}},children:v?"Signing...":C?/*#__PURE__*/e.jsxs(_f,{children:[/*#__PURE__*/e.jsx(Uu,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",/*#__PURE__*/e.jsx("span",{children:"Success"})]}):I.buttonText}),A?.isCancellable&&/*#__PURE__*/e.jsx(Ui,{style:{marginTop:"1rem"},onClick:()=>S(null),isSubmitting:!1,children:"Not now"}),/*#__PURE__*/e.jsx(es,{}),/*#__PURE__*/e.jsx(Di,{})]})}};let Pf=/*#__PURE__*/g.styled.div.withConfig({displayName:"InputHelp",componentId:"sc-af56055-0"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-start;width:100%;margin-top:16px;margin-bottom:4px;"],(e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)")),_f=/*#__PURE__*/g.styled.span.withConfig({displayName:"ContentWithIcon",componentId:"sc-af56055-1"})(["display:flex;align-items:center;gap:8px;"]),Nf=/*#__PURE__*/g.styled.div.withConfig({displayName:"IconContainer",componentId:"sc-af56055-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;"]),Mf=/*#__PURE__*/g.styled.div.withConfig({displayName:"Grow",componentId:"sc-af56055-3"})(["flex-grow:1;"]);function Wf(e){let{isHeadlessSigning:t,walletProxy:r,initializeWalletProxy:n,recoverEmbeddedWallet:a,openModal:l,privy:c}=s.usePrivyInternal(),{user:d,getAccessToken:h}=Wy(),p=li(),{setModalData:y}=Ua(),{signWithUserSigner:m}=u.useSignWithUserSigner();return oi("signSolanaMessage",e),{signMessage:({message:e,options:s})=>new Promise((async(g,f)=>{if(!d)return p("signSolanaMessage","onError",o.PrivyErrorCode.MUST_BE_AUTHENTICATED),void f(Error("User must be authenticated before signing with a Privy wallet"));let w=s?.address?u.getPrivyWalletWithAddress(d,s.address):u.getPrivySolanaWallet(d);if(!w)return p("signSolanaMessage","onError",o.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void f(Error("Must have a Privy wallet before signing"));let{entropyId:v,entropyIdVerifier:x}=xn(d,w),C=u.getIsUnifiedWallet(w),b=nn(e).toString("base64");if(b.length<1)return p("signMessage","onError",o.PrivyErrorCode.INVALID_MESSAGE),void f(Error("Message must be a non-empty string"));let j=async()=>{let e;if(!d)throw Error("User must be authenticated before signing with a Privy wallet");let t=await h();if(!t)throw Error("User must be authenticated to use their embedded wallet.");let o=r??await n(15e3);if(!o)throw Error("Failed to initialize embedded wallet proxy.");if(!await a({address:w.address}))throw Error("Unable to connect to wallet");if(C){let t=await i.rpc(c,m,{chain_type:"solana",method:"signMessage",params:{message:b,encoding:"base64"},wallet_id:w.id});if(!t.data||!("signature"in t.data))throw Error("Failed to sign message");e=t.data.signature}else{let{response:r}=await o.rpc({accessToken:t,entropyId:v,entropyIdVerifier:x,chainType:"solana",hdWalletIndex:w.walletIndex??0,request:{method:"signMessage",params:{message:b}}});e=r.data.signature}return e};if(t({showWalletUIs:s?.uiOptions?.showWalletUIs}))try{let e=await j(),t=new Uint8Array(nn(e,"base64"));p("signSolanaMessage","onSuccess",{signature:t}),g(t)}catch(e){f(e)}else y({signMessage:{method:"solana_signMessage",data:b,confirmAndSign:j,onSuccess:e=>{let t=new Uint8Array(nn(e,"base64"));p("signSolanaMessage","onSuccess",{signature:t}),g(t)},onFailure:e=>{f(e)},uiOptions:s?.uiOptions},connectWallet:{recoveryMethod:w.recoveryMethod,connectingWalletAddress:w.address,entropyId:v,entropyIdVerifier:x,isUnifiedWallet:C,onCompleteNavigateTo:Sf,onFailure:e=>{p("signSolanaMessage","onError",o.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),f(e)}}}),l(Mg)}))}}const Uf=()=>{let{exportSolanaWallet:e,solanaWallets:t,walletProxy:n,recoverEmbeddedWallet:a,privy:l}=s.usePrivyInternal(),{sendTransaction:c}=xf(),{signMessage:d}=Wf(),{create:h}=_y(),{signWithUserSigner:p}=u.useSignWithUserSigner(),{user:y,getAccessToken:m}=Wy(),{ready:g}=Ns(),f=r.useMemo((()=>{if(!n)return t;let e=[...u.getPrivySolanaHDWallets(y),u.getImportedPrivySolanaWallet(y)].filter((e=>!!e)).map((e=>({type:"solana",imported:e.imported,address:e.address,connectedAt:Date.now(),walletClientType:"privy",connectorType:"embedded",walletIndex:e.walletIndex??void 0,meta:{name:"Privy Wallet",icon:void 0,id:"io.privy.solana.wallet"},linked:!0,fund(){throw new o.PrivyClientError("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:()=>{throw new o.PrivyClientError("Cannot unlink an embedded Solana wallet")},async getProvider(){return new Ty(n,e.address,this.signMessage)},signMessage:async t=>await d({message:t,options:{address:e.address,uiOptions:{showWalletUIs:!1}}}),async sendTransaction(t,r,n){let{signature:a}=await c({transaction:t,connection:r,transactionOptions:n,address:e.address});return a},async signTransaction(t){let r=await m();if(!r||!n)throw new o.PrivyClientError("Must have valid access token and Privy wallet to send transaction",o.PrivyErrorCode.MUST_BE_AUTHENTICATED);if(!await a({address:e.address}).catch((()=>!1)))throw new o.PrivyClientError("Wallet couldn't be connected",o.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR);let{entropyId:s,entropyIdVerifier:c}=xn(y,e);if(u.getIsUnifiedWallet(e)){let r=Io(t)?nn(t.message.serialize()):t.serializeMessage(),n=await i.rpc(l,p,{chain_type:"solana",method:"signMessage",params:{message:r.toString("base64"),encoding:"base64"},wallet_id:e.id});if(n.data&&"signature"in n.data)return t.addSignature(So(t,e.address),nn(n.data.signature,"base64")),t;throw Error("Failed to sign transaction")}return await Ay({tx:t,accessToken:r,walletProxy:n,entropyId:s,entropyIdVerifier:c,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0})},async signAllTransactions(t){let r=await m();if(!r||!n)throw new o.PrivyClientError("Must have valid access token and Privy wallet to send transaction",o.PrivyErrorCode.MUST_BE_AUTHENTICATED);if(!await a({address:e.address}).catch((()=>!1)))throw new o.PrivyClientError("Wallet couldn't be connected",o.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR);let{entropyId:s,entropyIdVerifier:c}=xn(y,e);if(u.getIsUnifiedWallet(e))return await Promise.all(t.map((async t=>{let r=Io(t)?nn(t.message.serialize()):t.serializeMessage(),n=await i.rpc(l,p,{chain_type:"solana",method:"signMessage",params:{message:r.toString("base64"),encoding:"base64"},wallet_id:e.id});if(n.data&&"signature"in n.data)return t.addSignature(So(t,e.address),nn(n.data.signature,"base64")),t;throw Error("Failed to sign transaction")})));for(let a of t)await Ay({tx:a,accessToken:r,walletProxy:n,entropyId:s,entropyIdVerifier:c,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0});return t},loginOrLink:async()=>{throw new o.PrivyClientError("Cannot login or link with an embedded Solana wallet")},disconnect:()=>{},isConnected:async()=>!0})));return t.concat(e)}),[y,n,m,t]);return{ready:!(!g||!n),createWallet:async e=>{e&&"target"in e&&e&&(e=void 0);let{account:t}=await h({chainType:"solana",options:e});return t},exportWallet:e,wallets:f}},Of={component:()=>{let{wallets:t}=Ns(),{wallets:n}=Uf(),{data:a,setModalData:o,navigate:c,lastScreen:d}=Ua(),{rpcConfig:u,appId:h,createAnalyticsEvent:p,closePrivyModal:y}=s.usePrivyInternal(),m=_a(),[g,f]=r.useState(void 0),[w,v]=r.useState(!1),x=Oh(),C=a?.funding,{reloadBalance:b}=xy({rpcConfig:u,appId:h,address:"ethereum"===C.chainType?C.address:void 0,chain:"ethereum"===C.chainType?C.chain:void 0}),j="solana"===C.chainType,E=j?C.isUSDC?"USDC":"SOL":C.erc20Address?C.erc20ContractInfo?.symbol:C.chain.nativeCurrency.symbol,k=j?n.find((({address:e})=>e===C.address)):t.find((({address:e})=>Dt(e)===Dt(C.address)));if(!C)return o({errorModalData:{error:Error("Couldn't find funding config"),previousScreen:d||wg},funding:a?.funding,sendTransaction:a?.sendTransaction}),c(Yd),/*#__PURE__*/e.jsx(e.Fragment,{});r.useEffect((()=>{let e=j?async function(){if("solana"!==C.chainType)return;let e=x(Ey);e?(C.isUSDC?e.getTokenBalance({address:C.address,cluster:C.cluster,mintAddress:i.SolanaUsdcAddressMap[C.cluster.name]}).then((({amount:e})=>e)):e.getBalance({address:C.address,cluster:C.cluster})).then((e=>{let t=BigInt(e);g&&t>g&&(v(!0),p({eventName:Cy,payload:{provider:"manual",status:"success",chainType:"solana",address:k?.address,value:C.isUSDC?l.formatUnits(t-g,6):l.formatUnits(t-g,9),token:C.isUSDC?"USDC":"SOL"}})),f(t)})):console.warn("Unable to load solana plugin, skipping balance")}:async function(){"ethereum"===C.chainType&&(async()=>{if(!C.erc20Address)return await b()??BigInt(0);{let{balance:e}=await by({chain:C.chain,address:C.address,erc20Address:C.erc20Address,rpcConfig:u,appId:h});return e}})().then((e=>{g&&e>g&&(v(!0),p({eventName:Cy,payload:{provider:"manual",status:"success",chainType:"ethereum",address:k?.address,chainId:C.chain.id,value:l.formatUnits(e-g,C.erc20ContractInfo?.decimals??18),token:C.erc20ContractInfo?.symbol??C.erc20Address??"ETH"}})),f(e)})).catch((()=>f(void 0)))},t=setInterval(e,2e3);return e(),()=>clearInterval(t)}),[g]);let T=r.useMemo((()=>void 0!==g&&g>=parseFloat(C.amount)),[g,C.amount]),A=r.useMemo((()=>null==g?"":C.isUSDC?i.formatTokenAmount({amount:g,decimals:6}):j?jo(g,3,!0,!0):null!=C.erc20ContractInfo?.decimals?i.formatTokenAmount({amount:g,decimals:C.erc20ContractInfo.decimals}):i.formatWeiAmount({wei:g})),[g,j,C]),I="ethereum"===C.chainType?C.chain.name:Rf[C.cluster.name],S=r.useMemo((()=>""===C.uiConfig?.receiveFundsTitle?null:/*#__PURE__*/e.jsx(ly,{children:C.uiConfig?.receiveFundsTitle??`Receive ${C.amount} ${E??""}`.trim()})),[C.uiConfig?.receiveFundsTitle,C.amount,E]),P=r.useMemo((()=>""===C.uiConfig?.receiveFundsSubtitle?null:/*#__PURE__*/e.jsx(sy,{children:C.uiConfig?.receiveFundsSubtitle??`Scan this code or copy your wallet address to receive funds on ${I}.`})),[C.uiConfig?.receiveFundsSubtitle,I]),_="solana"===C.chainType&&C.isUSDC&&i.SolanaUsdcAddressMap[C.cluster.name]?`?spl-token=${i.SolanaUsdcAddressMap[C.cluster.name]}`:"";/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(sw,{}),S,P,/*#__PURE__*/e.jsxs(Go,{style:{gap:"1rem",margin:S||P?"1rem 0":"0"},children:[/*#__PURE__*/e.jsx(Yu,{url:`${C.chainType}:${C.address}${_}`,size:200,squareLogoElement:Ff}),/*#__PURE__*/e.jsxs(py,{theme:m.appearance.palette.colorScheme,children:["Make sure to send funds on ",I,"."]}),/*#__PURE__*/e.jsx(vy,{title:"Your wallet",errMsg:void 0,showIcon:!0,isLoading:!C||void 0===g,isPulsing:!T,balance:`${A} ${E}`,address:C.address,statusColor:T?"green":"gray"}),w&&/*#__PURE__*/e.jsx(Ai,{onClick:()=>y({shouldCallAuthOnSuccess:!1,isSuccess:!0}),children:"Continue"})]}),/*#__PURE__*/e.jsx(Di,{})]})}};let Ff=({...t})=>/*#__PURE__*/e.jsx(Rn,{color:"black",...t}),Rf={devnet:"Devnet","mainnet-beta":"Solana",testnet:"Testnet"},Lf=/*#__PURE__*/g.styled.div.withConfig({displayName:"Container",componentId:"sc-b3a607dd-0"})(["display:flex;flex-direction:column;min-height:72px;"]);var Df=({onBack:t,details:r})=>/*#__PURE__*/e.jsxs(Lf,{children:[/*#__PURE__*/e.jsx(Vi,{backFn:t}),/*#__PURE__*/e.jsx(kf,{data:r}),/*#__PURE__*/e.jsx(Di,{})]});let Bf=({gasUsed:e,effectiveGasPrice:t})=>{if(e&&t)try{return l.toHex(e*t)}catch(e){return}};const zf=({txn:t,receipt:r,transactionInfo:n,onClose:a,tokenPrice:i,tokenSymbol:o,receiptHeader:s,receiptDescription:l})=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{onClose:a}),/*#__PURE__*/e.jsx(tc,{title:s??"Transaction complete!",description:l??"You're all set."}),/*#__PURE__*/e.jsx(Ts,{tokenPrice:i,from:r.from,to:r.to,gas:Bf(r),txn:t,transactionInfo:n,tokenSymbol:o}),/*#__PURE__*/e.jsx(di,{}),/*#__PURE__*/e.jsx($f,{loading:!1,onClick:a,children:"All Done"}),/*#__PURE__*/e.jsx(es,{}),/*#__PURE__*/e.jsx(Di,{})]});let $f=/*#__PURE__*/g.styled(Ai).withConfig({displayName:"SubmitButton",componentId:"sc-f70d0f7a-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);const qf=[{constant:!1,inputs:[{name:"_salt",type:"bytes32"},{name:"_initializer",type:"bytes"}],name:"deployAccount",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Vf=[{name:"from",type:"address"},{name:"param2",type:"address"},{name:"param3",type:"bytes"},{name:"param4",type:"tuple",components:[]},{type:"tuple",components:[{name:"param5",type:"address"},{name:"param6",type:"uint256"},{name:"param7",type:"uint256"},{name:"encodedInitData",type:"bytes"}]}],Hf=[{constant:!1,inputs:[{name:"spender",type:"address"},{name:"value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Kf=[{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"quantity",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"quantity",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"},{internalType:"uint256[]",name:"quantities",type:"uint256[]"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mintBatch",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"},{internalType:"uint256[]",name:"quantities",type:"uint256[]"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mintBatch",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"quantity",type:"uint256"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"quantity",type:"uint256"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"batchMint",outputs:[],stateMutability:"payable",type:"function"}],Zf=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Yf=[{constant:!1,inputs:[{name:"_operator",type:"address"},{name:"_approved",type:"bool"}],name:"setApprovalForAll",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Gf=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Jf=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenIds",type:"uint256[]"},{name:"_amounts",type:"uint256[]"},{name:"_data",type:"bytes"}],name:"safeBatchTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Qf=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"},{name:"_amount",type:"uint256"},{name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Xf=(e,t)=>{let r=ew(Hf,e);if(r)return{action:"approve",functionName:"approve",isErc20Ish:!0,isNFTIsh:!1,spender:r.args[0],amount:r.args[1]};let n=ew(sm,e);if(n)return{action:"transfer",functionName:"transfer",isErc20Ish:!0,isNFTIsh:!1,transferTo:n.args[0],amount:n.args[1]};if(!t)return{action:"transaction",functionName:"",isErc20Ish:!1,isNFTIsh:!1};let a=ew(qf,e);if(a&&"string"==typeof a.args[1]){let e=tw(a.args[1]);if(e&&e[4].encodedInitData)return Xf(e[4].encodedInitData,t)}let i=ew(Yf,e);if(i)return{action:"approve",functionName:"setApprovalForAll",isNFTIsh:!0,isErc20Ish:!1,operator:i.args[0],approved:i.args[1]};let o=ew(Gf,e);if(o)return{action:"transfer",functionName:"transferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:o.args[0],transferTo:o.args[1],tokenId:o.args[2]};let s=ew(Zf,e);if(s)return{action:"transfer",functionName:"safeTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:s.args[0],transferTo:s.args[1],tokenId:s.args[2]};let l=ew(Qf,e);if(l)return{action:"transfer",functionName:"safeTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:l.args[0],transferTo:l.args[1],tokenId:l.args[2],amount:l.args[3]};let c=ew(Jf,e);if(c)return{action:"batch transfer",functionName:"safeBatchTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:c.args[0],transferTo:c.args[1],tokenIds:c.args[2],amounts:c.args[3]};let d=ew(Kf,e);return d?{action:"mint",functionName:d.functionName,isNFTIsh:!0,isErc20Ish:!1,args:d.args}:{action:"transaction",isErc20Ish:!1,isNFTIsh:!1}};let ew=(e,t)=>{try{let r=l.decodeFunctionData({abi:e,data:t});return{functionName:r.functionName,args:r.args||[]}}catch(e){return null}},tw=e=>{try{if("string"==typeof e)return l.decodeAbiParameters(Vf,`0x${e.slice(10)}`)}catch(e){return null}},rw=e=>`${parseFloat(e).toFixed(2)}`;const nw=(e,t,n,a)=>{let[i,o]=r.useState(null),{getAccessToken:l}=u.usePrivyContext(),{walletProxy:c}=s.usePrivyInternal();return r.useEffect((()=>{i&&o(null),(async()=>{if(!await l()||!c||!t)return null;let r=[],i=!0,o=await Ms(e,n,t,a).catch((t=>(t.message.includes("Insufficient balance for transaction")||t.details.includes("insufficient funds")?i=!1:r.push(t),e)));return{tx:o,totalGasEstimate:o.gas,hasFunds:i,errors:r}})().then(o)}),[e]),i};let aw=new Tn(new kn("There was an issue preparing your transaction",i.ProviderErrors.E32603_DEFAULT_INTERNAL_ERROR.eipCode)),iw=(e,t)=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?e.sendTransaction.transactionRequest:e.sendTransaction.transactionRequests[t]:void 0;const ow={component:()=>{let{data:t,onUserCloseViaDialogOrKeybindRef:n,setModalData:a,navigate:o}=Ua(),{rpcConfig:c,chains:d,closePrivyModal:h,walletProxy:p,showFiatPrices:y}=s.usePrivyInternal(),{getAccessToken:m,user:g}=u.usePrivyContext(),f=_a(),[w,v]=r.useState(0),[x,C]=r.useState(0),[b,j]=r.useState(iw(t,w)),[E,k]=r.useState(null),[T,A]=r.useState(),[I,S]=r.useState(!1),[P,_]=r.useState(null),[N,M]=r.useState(null),[W,U]=r.useState(null),[O,F]=r.useState(void 0),[R,L]=r.useState(void 0),[D,B]=r.useState(!1),[z,$]=r.useState(!1),[q,V]=r.useState([]),[H,K]=r.useState([]),[Z,Y]=r.useState("uninitiated"),[G,J]=r.useState(void 0);if(!b||!t?.sendTransaction||!t?.sendTransaction)/*#__PURE__*/return e.jsx(Gd,{error:Error("Invalid transaction request"),onClick:()=>{t?.sendTransaction?.onFailure(aw),h({shouldCallAuthOnSuccess:!1})}});let{entropyId:Q,entropyIdVerifier:X,transactingWalletIndex:ee,transactingWalletAddress:te}=t.sendTransaction,re=r.useMemo((()=>d.find((e=>Number(e.id)===Number(b.chainId)))),[b.chainId]),ne=re?.nativeCurrency.symbol??"ETH",ae=r.useMemo((()=>Xf(b.data,!!f.embeddedWallets.extendedCalldataDecoding)),[b.data]),{action:ie,isErc20Ish:oe,isNFTIsh:se}=ae,{toAddress:le,tokenAddress:ce}=r.useMemo((()=>({toAddress:ae.isErc20Ish?ae.transferTo:b.to??void 0,tokenAddress:ae.isErc20Ish?b.to:void 0})),[ae]);r.useEffect((()=>{b.to&&re&&oe&&$y({address:b.to,chain:re,rpcConfig:f.rpcConfig,privyAppId:f.id}).then(k).catch(console.error)}),[b.to,re]);let{tokenPrice:de,isTokenPriceLoading:ue}=Ps(b.chainId),{balance:he}=xy({rpcConfig:f.rpcConfig,appId:f.id,address:te,chain:re}),pe=r.useMemo((()=>Ft(Number(b.chainId),d,c,{appId:f.id})),[b.chainId,c]),ye=nw(b,te,pe,t?.sendTransaction?.prepareTransactionRequest);r.useEffect((()=>{j(iw(t,w))}),[w]),r.useEffect((()=>{t.sendTransaction?.getIsSponsored?t.sendTransaction.getIsSponsored().then(A).catch(console.error):A(!1)}),[t.sendTransaction.getIsSponsored]);let me=()=>{if(!I)return P?t?.sendTransaction?.onSuccess({hash:P}):W||ye?.errors[0]?t?.sendTransaction?.onFailure(W??ye?.errors[0]??aw):t?.sendTransaction?.onFailure(new Tn(new kn("The user rejected the request",i.ProviderErrors.E4001_USER_REJECTED_REQUEST.eipCode))),h({shouldCallAuthOnSuccess:!1})};n.current=me;let ge=!!(t.funding&&t.funding.supportedOptions.length>0),fe=yo(BigInt(ye?.totalGasEstimate??0n),ne),we=y&&de?po(BigInt(ye?.totalGasEstimate??0n),de):void 0,ve=yo(he??0n,ne,void 0,!0),xe=y&&de?po(he??0n,de):void 0,Ce=t.sendTransaction?.uiOptions?.transactionInfo?.title;Ce||(Ce="approve"===ie?oe?"Confirm address":"Confirm action":`Approve ${ie}`);let be=t.sendTransaction?.uiOptions?.description||(oe&&"approve"===ie?`${f.name} would like your permission for ${Dt(ae.spender)} to spend tokens on your behalf.`:`${f.name} wants your permission to approve the following transaction.`),je=t.sendTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?/*#__PURE__*/e.jsx("img",{src:t.sendTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:t.sendTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,Ee=!(!ye||ye.errors[0]||ye.hasFunds||!1!==T),ke=Ee&&ge,Te=ke?"Add funds":t.sendTransaction?.uiOptions?.buttonText||(w<x?"Continue":"Approve"),Ae=e=>{if(!e)throw Error("Transaction scan failed");if("Success"===e.validation.status&&("Benign"===e.validation.result_type?L("safe"):"Warning"===e.validation.result_type?L("warn"):"Malicious"===e.validation.result_type&&(L("error"),$(!0))),"Success"!==e.simulation.status)throw Error("Simulation failed");{F(e.simulation.params);let{assetsIn:t,assetsOut:r}=function(e,t){let r=[],n=[];if(e)for(let t of e)if(t.in[0]){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.in[0].value?{nftName:t.asset.name,nftCount:t.in.length}:{iconUrl:t.asset.logo_url,value:t.in[0].value,symbol:t.asset.symbol,usdValue:t.in[0].usd_price?rw(t.in[0].usd_price):void 0},r.push(e)}else if(t.out[0]?.value){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.out[0].value?{nftName:t.asset.name}:{iconUrl:t.asset.logo_url,value:t.out[0].value,symbol:t.asset.symbol,usdValue:t.out[0].usd_price?rw(t.out[0].usd_price):void 0},n.push(e)}for(let e of t)for(let t of Object.keys(e.spenders)){let r;r="ERC721"===e.asset.type||"approve_for_all"===e.spenders[t]?.value?{nftName:e.asset.name}:{iconUrl:e.asset.logo_url,value:e.spenders[t]?.value,symbol:e.asset.symbol,usdValue:e.spenders[t]?.usd_price?rw(e.spenders[t]?.usd_price):void 0},n.push(r)}return{assetsIn:r,assetsOut:n}}(e.simulation.assets_diffs,e.simulation.exposures);if(0===r.length&&0===t.length)throw Error("No tokens found");V(r),K(t)}};if(r.useEffect((()=>{t.sendTransaction?.scanTransaction&&f.embeddedWallets.transactionScanning.enabled&&"uninitiated"===Z&&(Y("in progress"),t.sendTransaction.scanTransaction().then((e=>{Ae(e),Y("completed")})).catch((()=>Y("failed"))))}),[!!t.sendTransaction?.scanTransaction]),r.useEffect((()=>{t.sendTransaction?.scanTransaction&&"failed"!==Z||((e,r,n)=>{if(C((e=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?0:e.sendTransaction.transactionRequests.length-1:0)(t)),r.isErc20Ish&&r.amount&&n){let e=cm({amount:r.amount,decimals:n.decimals});J(e),V([{value:e,symbol:n?.symbol}])}else if(e.value){let t=BigInt(e.value),r=de&&po(t,de);V(y&&r?[{value:r}]:[{value:mo(t),symbol:ne}])}else V(y?[{value:"$0"}]:[{value:"0",symbol:ne}])})(ye?.tx??b,ae,E)}),[b,ye?.tx,ae,E,Z]),N/*#__PURE__*/)return e.jsx(zf,{txn:ye?.tx??b,onClose:me,receipt:N,transactionInfo:t.sendTransaction?.uiOptions.transactionInfo,tokenPrice:de,tokenSymbol:ne,receiptHeader:t.sendTransaction?.uiOptions.successHeader,receiptDescription:t.sendTransaction?.uiOptions.successDescription});if(W)/*#__PURE__*/return e.jsx(Xg,{transactionError:W,transactionHash:P??void 0,network:"ethereum",chainId:ye?.tx.chainId??b.chainId,onClose:me,onRetry:({resetNonce:e})=>{U(null);let t={...ye?.tx??b};e&&(t.nonce=void 0),j(t)}});let Ie=0!==x&&"number"==typeof w&&0!==w?()=>{v(w-1)}:void 0;return D&&O?/*#__PURE__*/e.jsx(Df,{details:O,onBack:()=>B(!1)}):/*#__PURE__*/e.jsx(Hg,{transactionIndex:w,onBack:Ie,maxIndex:x,disabled:Ee&&!ge||z,isSubmitting:I,submitError:W,isPreparing:!ye,isTokenPriceLoading:ue,isTokenContractInfoLoading:!se&&!E,prepareError:ye?.errors[0],symbol:E?.symbol,chain:re,img:je,title:Ce,subtitle:be,txValue:b.value,fee:we??fe,isSponsored:T,from:te??"",to:le,tokenAddress:ce??void 0,network:f.chains.find((e=>e.id===b.chainId))?.name??"",transactionDetails:{...ae,formattedAmount:G},cta:Te,missingFunds:Ee,action:ie,balance:xe??ve,onClose:me,onClick:ke?async()=>{if(te){if(!ge)throw Error("Funding wallet is not enabled");a({...t,funding:{...t.funding,methodScreen:wg,chainType:"ethereum",amount:l.formatEther(BigInt(ye?.tx.value??0)+BigInt(ye?.totalGasEstimate?.toString()??0)),chain:re}}),o(wg)}}:async()=>{if(w<x)v(w+1);else{S(!0);try{let e=await m();if(I||!e||!p||!g)return;let r=t?.sendTransaction?.onConfirm?await t.sendTransaction.onConfirm():await async function({accessToken:e,entropyId:t,entropyIdVerifier:r,transactingWalletIndex:n,walletProxy:a,transactionRequest:i,publicClient:o,requesterAppId:s}){let l=await $l({accessToken:e,entropyId:t,entropyIdVerifier:r,transactingWalletIndex:n,walletProxy:a,transactionRequest:i,requesterAppId:s});return await o.sendRawTransaction({serializedTransaction:l})}({accessToken:e,transactingWalletIndex:ee,entropyId:Q,entropyIdVerifier:X,walletProxy:p,transactionRequest:ye?.tx??b,publicClient:pe,requesterAppId:t.sendTransaction?.requesterAppId});if(_(r),t.sendTransaction?.signOnly)return await new Promise((e=>setTimeout(e,sr))),t?.sendTransaction?.onSuccess({hash:r}),h({shouldCallAuthOnSuccess:!1});let n=await pe.waitForTransactionReceipt({hash:r});if("reverted"===n.status)throw Error("Transaction failed");M(n)}catch(e){console.warn({transaction:ye?.tx??b,error:e}),U(e)}finally{S(!1)}}},validation:R,hasScanDetails:!!O,setIsScanDetailsOpen:B,preventMaliciousTransaction:z,setPreventMaliciousTransaction:$,tokensSent:q,tokensReceived:H,isScanning:"in progress"===Z,isCancellable:t.sendTransaction?.uiOptions?.isCancellable??!1})}};function sw({title:t}){let{currentScreen:r,navigateBack:n,navigate:a,data:i,setModalData:o}=Ua();/*#__PURE__*/return e.jsx(Vi,{title:t,backFn:r===Of?n:r===i?.funding?.methodScreen?i.funding.comingFromSendTransactionScreen?()=>a(ow):void 0:i?.funding?.methodScreen?()=>{let e=i.funding;e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),o({funding:e}),a(e.methodScreen)}:void 0})}const lw={component:()=>{let{rpcConfig:t,appId:n,closePrivyModal:a,createAnalyticsEvent:c}=s.usePrivyInternal(),{navigate:d,setModalData:u,app:h,data:p}=Ua(),{wallets:y}=Ns(),m=Oh(),[g,f]=r.useState(null),[w,v]=r.useState(null),[x,C]=r.useState([]),[b,j]=r.useState(0),[E,k]=r.useState(!1),[T,A]=r.useState(!1),[I,S]=r.useState(!1),[P,_]=r.useState(!1),[N,M]=r.useState(),[W,U]=r.useState();if(!p?.funding||"solana"!==p.funding.chainType)throw Error("Invalid funding data");let{address:O,cluster:F,connectedWalletAddress:R}=p.funding,[L,D]=r.useState(p.funding.amount),B=R?y.find((({address:e})=>e===R)):y[0],z=ha(B?.walletClientType||"unknown"),$=z?.name||"wallet",[q,V]=r.useState(null);r.useEffect((()=>{(async()=>{if(!B)return;let e=await B.getEthereumProvider();V(l.createWalletClient({account:B.address,transport:l.custom(e)}).extend(l.publicActions))})().catch(console.error)}),[B]);let[H,K]=r.useState(0n),Z=jo(H);r.useEffect((()=>{let e=m(Ey);e?e.getBalance({address:O,cluster:F}).then((e=>K(BigInt(e)))):console.warn("Unable to load solana plugin, skipping balance")}),[]);let[Y,G]=r.useState(),{tokenPrice:J}=Ps("solana"),{fundingAmountInBaseUnit:Q,fundingAmountInUsd:X}=ko({amount:L,fee:0n,tokenPrice:J,isUsdc:p.funding.isUSDC});if(r.useEffect((()=>{(async()=>{if(!q||!B)return;let e=["testnet","devnet"].includes(F.name);e&&console.warn("Solana testnets are not supported for bridging");let r=i.addToDefaultChains(h.chains).filter((({testnet:t})=>!!t===e)),a=(await dm({chains:r,address:B.address,appId:n,rpcConfig:t})).filter((e=>e.balance>0n));if(a.length<1)return void f(new o.PrivyClientError(`Wallet ${Dt(B.address)} does not have enough funds.`,void 0,o.PrivyErrorCode.INSUFFICIENT_BALANCE));a.sort(((e,t)=>Number(t.balance-e.balance)));let s=(await Promise.allSettled(a.map((async e=>({...e,quote:await qd({isTestnet:!1,input:Bd({amount:Q.toString(),user:B.address,recipient:O,destinationChainId:va,destinationCurrency:xa,originChainId:e.chain.id})})}))))).filter((e=>"fulfilled"===e.status)).map((e=>e.value));if(s.length<1)return void f(new o.PrivyClientError(`Unable to fetch quotes for bridging. Wallet ${Dt(B.address)} does not have enough funds.`,void 0,o.PrivyErrorCode.INSUFFICIENT_BALANCE));let l=s.map((({quote:e,balance:t,chain:r})=>({bridgeTx:Vd(e),balance:t,chain:r,isErc20Quote:!1}))).filter((({bridgeTx:e})=>!!e));if(l.length>1)return void C(l);let c=l.at(0);c?(A(!0),G({data:c.bridgeTx.data,to:c.bridgeTx.to,value:c.bridgeTx.value,chain:c.chain})):f(new o.PrivyClientError(`Unable to select bridge option from quotes. Wallet ${Dt(B.address)} does not have enough funds.`,void 0,o.PrivyErrorCode.INSUFFICIENT_BALANCE))})().catch(console.error)}),[q]),r.useEffect((()=>{(async()=>{let e,r;if(!q||!B||E||I||!Y)return;k(!0);let a=l.createPublicClient({chain:Y.chain,transport:l.http(Rt(Y.chain,t,n))});try{e=await a.prepareTransactionRequest({account:B.address,to:Y.to,chain:Y.chain,data:Y.data,value:BigInt(Y.value??0)})}catch(e){console.error(e),x.length>1&&v(e.shortMessage??"Something went wrong")}if(e){k(!1),S(!0);try{await q.switchChain({id:Y.chain.id})}catch(e){await q.addChain({chain:Y.chain}),await q.switchChain({id:Y.chain.id})}try{r=await q.sendTransaction(e)}catch(e){console.error(e),"TransactionExecutionError"===e.name&&(x.length<1?f(new o.PrivyClientError(e.shortMessage,void 0,o.PrivyErrorCode.TRANSACTION_FAILURE)):v(e.shortMessage??"Something went wrong"))}if(r)return await q.waitForTransactionReceipt({hash:r}),T?(U("pending"),void M(r)):(S(!1),_(!0),void c({eventName:Cy,payload:{provider:"external",status:"success",txHash:r,address:B.address,chainId:Y.chain.id,chainType:"ethereum",value:Y.value?l.formatUnits(BigInt(Y.value),18):void 0,token:"ETH",destination:O,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:l.formatUnits(Q,9),destinationToken:"SOL"}}));S(!1)}else k(!1)})().catch(console.error)}),[q,Y]),Hd({transactionHash:N,wallet:B,isTestnet:!1,bridgingStatus:W,setBridgingStatus:U,onSuccess({transactionHash:e,wallet:t}){A(!1),_(!0),c({eventName:Cy,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainId:Y?.chain.id,chainType:"ethereum",value:Y?.value?l.formatUnits(BigInt(Y.value),18):void 0,token:"ETH",destination:O,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:l.formatUnits(Q,9),destinationToken:"SOL"}})},onFailure({error:e}){A(!1),f(e)}}),r.useEffect((()=>{g&&(u({funding:p?.funding,sendTransaction:p?.sendTransaction,errorModalData:{error:g,previousScreen:Xm}}),d(Yd,!1))}),[g]),r.useEffect((()=>{if(!P)return;let e=setTimeout(a,cr);return()=>clearTimeout(e)}),[P]),P/*#__PURE__*/)return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(sw,{}),/*#__PURE__*/e.jsx(Xo,{}),/*#__PURE__*/e.jsxs(Yo,{children:[/*#__PURE__*/e.jsx(ht.default,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/e.jsx(nc,{title:"Success!",description:`You’ve successfully added ${L} SOL to your ${h.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/e.jsx(es,{}),/*#__PURE__*/e.jsx(Di,{})]});let ee=x[b];return x.length>1&&ee?/*#__PURE__*/e.jsx(Ym,{displayName:$,configuredFundingChain:F,formattedBalance:Z,fundingAmount:L,fundingCurrency:"SOL",fundingAmountInUsd:X,options:x,selectedOption:ee,isPreparing:E,isSubmitting:I,addressToFund:O,fundingWalletAddress:B?.address||"",errorMessage:w,onSubmit:()=>{p.funding?.amount!==L?async function(){if(B&&ee)try{let e=await qd({isTestnet:!1,input:Bd({amount:Q.toString(),user:B.address,recipient:O,destinationChainId:va,destinationCurrency:xa,originChainId:ee.chain.id})}),t=Vd(e);if(!t)throw Error("Invalid transaction request");A(!0),G({data:t.data,to:t.to,value:t.value,chain:ee.chain})}catch(e){console.error(e),f(new o.PrivyClientError("Unable to fetch quotes for bridging",e,o.PrivyErrorCode.INSUFFICIENT_BALANCE))}}().catch(console.error):G({to:ee.bridgeTx.to,data:ee.bridgeTx.data,value:ee.bridgeTx.value,chain:ee.chain})},onSelect:e=>{e!==b&&(v(null),j(e))},onAmountChange:D}):I&&B?/*#__PURE__*/e.jsx(am,{wallet:B,displayName:$,addressToFund:O,isBridging:T,isErc20Flow:!1,chainId:"solana",chainName:F.name,totalPriceInUsd:void 0,totalPriceInNativeCurrency:void 0,gasPriceInUsd:void 0,gasPriceInNativeCurrency:void 0}):
25
25
  /*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(sw,{}),/*#__PURE__*/e.jsx(Vy,{}),/*#__PURE__*/e.jsx("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/e.jsx(Di,{})]})}},cw=new Map([[wg,null],[Xm,"external"],[Gm,"external"],[om,"external"],[lw,"external"],[Jm,"external"],[Of,"manual"],[cg,"moonpay"]]);const dw=()=>((()=>{let e=_a(),{user:t,getAccessToken:n}=u.usePrivyContext(),{refreshSessionAndUser:a,walletProxy:i}=s.usePrivyInternal();r.useEffect((()=>{(async()=>{if("legacy-embedded-wallets-only"===e.embeddedWallets.mode||!t)return;let r=u.getPrivyPrimaryWallet(t);if(!r||u.getIsUnifiedWallet(r)||!Ll(r)||!i)return;let o=await n();if(!o)return;let s=r.imported?[r]:t.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported)).filter(Ll),{entropyId:l,entropyIdVerifier:c}=xn(t,r);try{await i.connect({accessToken:o,entropyId:l,entropyIdVerifier:c})}catch(e){if(!Ls(e)||"privy"!==r.recoveryMethod)return void console.debug("Unable to migrate wallet: ",e);await i.recover({accessToken:o,entropyId:l,entropyIdVerifier:c})}try{await i.createDelegatedAction({accessToken:o,rootWallet:{address:r.address,chainType:r.chainType,imported:r.imported},delegatedWallets:s}),await a()}catch(r){console.debug("Unable to migrate wallet: ",r)}})()}),[t,i,e])})(),null),uw={component:()=>{let{app:t,data:r}=Ua(),n=_a(),a=r?.externalConnectWallet?.suggestedAddress,i=a?`Connect the wallet with address ${Dt(a)} ${t?.name?`to ${t.name}.`:"."}`:`Connect a wallet to ${t?.name}`,{connectors:o}=s.usePrivyInternal(),l=gp({walletList:r?.externalConnectWallet?.walletList??t.appearance.walletList,walletChainType:r?.externalConnectWallet?.walletChainType??t.appearance.walletChainType,connectors:o,connectOnly:!0,ignore:t.appearance.walletList,walletConnectEnabled:t.externalWallets.walletConnect.enabled});/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{},"header"),l.length>0&&/*#__PURE__*/e.jsx(rc,{title:"Connect your wallet",description:i}),/*#__PURE__*/e.jsx(pi,{$colorScheme:n.appearance.palette.colorScheme,children:/*#__PURE__*/e.jsx(mp,{wallets:l})}),/*#__PURE__*/e.jsx(Di,{})]})}},hw={component:()=>{let{app:t,data:r}=Ua(),n=_a(),a=r?.externalConnectWallet?.suggestedAddress,i=a?/*#__PURE__*/e.jsxs("span",{children:["Connect the wallet with address ",/*#__PURE__*/e.jsx(Od,{showCopyIcon:!1,address:a})," ",t?.name?`to ${t.name}.`:"."]}):`Connect a wallet to your ${t?.name} account`,{connectors:o}=s.usePrivyInternal(),l=gp({walletList:r?.externalConnectWallet?.walletList??t.appearance.walletList,walletChainType:r?.externalConnectWallet?.walletChainType??t.appearance.walletChainType,connectors:o,connectOnly:!0,ignore:t.appearance.walletList,walletConnectEnabled:t.externalWallets.walletConnect.enabled});/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{},"header"),l.length>0&&/*#__PURE__*/e.jsx(tc,{title:"Connect your wallet",description:i}),/*#__PURE__*/e.jsx(pi,{$colorScheme:n.appearance.palette.colorScheme,children:/*#__PURE__*/e.jsx(mp,{wallets:l})}),t&&/*#__PURE__*/e.jsx(Li,{app:t,alwaysShowImplicitConsent:!0}),/*#__PURE__*/e.jsx(Di,{})]})},isUnauthenticatedScreem:!0};function pw(e){let{logout:t}=r.useContext(u.PrivyContext);return oi("logout",e),{logout:t}}const yw={component:()=>{let t=_a(),{data:n,navigate:a,setModalData:i,onUserCloseViaDialogOrKeybindRef:l}=Ua(),{crossAppAuthFlow:c,updateWallets:d,closePrivyModal:u,createAnalyticsEvent:h}=s.usePrivyInternal(),{logout:p}=pw(),[y,m]=r.useState({}),g=n?.crossAppAuth,f={id:g.appId,name:g.name,logoUrl:g.logoUrl},w=new o.PrivyClientError(`There was an issue connecting your ${f.name} account. Please try again.`),v=new ar((async e=>{if(g.popup)try{let t=await c({appId:e,popup:g.popup,action:g.action});m({data:t})}catch(e){e instanceof o.PrivyClientError?m({error:e}):(e instanceof o.PrivyApiError&&g.popup&&g.popup.close(),m({error:w}))}else m({error:w})})),x=()=>{y.data&&(d(),g.onSuccess(y.data),u({shouldCallAuthOnSuccess:!0,isSuccess:!0})),g.onError(y.error??new o.PrivyClientError("User canceled flow")),u({shouldCallAuthOnSuccess:!1,isSuccess:!1})};l.current=x,r.useEffect((()=>{f.id.length&&v.execute(f.id)}),[f.id]),r.useEffect((()=>{if(!y.data)return;let e=y.data;if(t.legal.requireUsersAcceptTerms&&!e.hasAcceptedTerms){let e=setTimeout((()=>{a(Cu)}),sr);return()=>clearTimeout(e)}if(Pd(e,t.embeddedWallets)){let e=setTimeout((()=>{i({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),h({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:`privy:${f.id}`,screen:"CrossAppAuthScreen"}}),p()},callAuthOnSuccessOnClose:!0}}),a(vu)}),sr);return()=>clearTimeout(e)}let r=setTimeout(x,sr);return()=>clearTimeout(r)}),[y.data]);let{title:C,subtitle:b}=r.useMemo((()=>y.data?{title:`Successfully connected with ${f.name}`,subtitle:"You're good to go!"}:y.error?{title:"Authentication failed",subtitle:y.error.message}:{title:`Connecting to ${f.name}`,subtitle:`Please check the pop-up from ${f.name} to continue`}),[y,f.name]);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{onClose:x}),/*#__PURE__*/e.jsx(Xo,{}),/*#__PURE__*/e.jsxs(mw,{children:[/*#__PURE__*/e.jsx(dl,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(Ci,{success:!!y.data,fail:!!y.error}),/*#__PURE__*/e.jsx(Ed,{name:f.name,logoUrl:f.logoUrl})]})}),/*#__PURE__*/e.jsxs(Jo,{children:[/*#__PURE__*/e.jsx("h3",{children:C}),/*#__PURE__*/e.jsx("p",{children:b})]})]}),/*#__PURE__*/e.jsx(es,{}),/*#__PURE__*/e.jsx(Bi,{})]})}};let mw=/*#__PURE__*/g.styled.div.withConfig({displayName:"ConnectContainer",componentId:"sc-33c02367-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const gw={component:()=>{let{app:t,data:n}=Ua(),{closePrivyModal:a}=s.usePrivyInternal(),[i,l]=r.useState(!1),[c,d]=r.useState(),{address:u,onDelegate:h,onSuccess:p,onError:y}=n.delegatedActions.consent,m=async()=>{i?p():y(c??new o.PrivyClientError("User declined delegating actions.")),a({shouldCallAuthOnSuccess:!1})};return r.useEffect((()=>{if(!i&&!c)return;let e=setTimeout(m,lr);return()=>clearTimeout(e)}),[i,c]),i||c?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{onClose:m}),/*#__PURE__*/e.jsx(Xo,{}),/*#__PURE__*/e.jsxs(Ko,{children:[c?/*#__PURE__*/e.jsx(Ze.default,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/e.jsx(ht.default,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/e.jsx(rs,{height:20}),/*#__PURE__*/e.jsx(nc,{title:c?"Something went wrong":"Success!",description:c?"Please try again.":`You’ve successfully granted delegated action permissions to ${t.name}.`})]}),/*#__PURE__*/e.jsx(es,{}),/*#__PURE__*/e.jsx(Di,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{closeable:!0,onClose:m}),/*#__PURE__*/e.jsx(wt.default,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/e.jsx(Ks,{style:{marginTop:24,color:"var(--privy-color-foreground)"},children:"Enable offline access"}),/*#__PURE__*/e.jsxs(Zs,{style:{marginBottom:24,textWrap:"pretty"},children:["By confirming, ",t.name," will be able to use your wallet for you even when you're not around. You can revoke this later."]}),/*#__PURE__*/e.jsx(ww,{showIcon:!0,address:u,title:"Wallet",isLoading:!1}),/*#__PURE__*/e.jsxs(fw,{style:{marginTop:24},children:[/*#__PURE__*/e.jsx(Ni,{onClick:m,children:"Not now"}),/*#__PURE__*/e.jsx(Ai,{onClick:async()=>{try{await h(),l(!0)}catch(e){d(e)}},children:"Accept"})]}),/*#__PURE__*/e.jsx(Di,{})]})}};let fw=/*#__PURE__*/g.styled.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-bdb7bc51-0"})(["display:flex;gap:10px;"]),ww=/*#__PURE__*/g.styled(vy).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-bdb7bc51-1"})(["margin-top:1.5rem;"]);const vw={component:()=>{let{app:t,data:n}=Ua(),{closePrivyModal:a}=s.usePrivyInternal(),[i,l]=r.useState(!1),[c,d]=r.useState(),{onRevoke:u,onSuccess:h,onError:p}=n.delegatedActions.revoke,y=async()=>{i?h():p(c??new o.PrivyClientError("User declined revoking access to their delegated wallet.")),a({shouldCallAuthOnSuccess:!1})};return r.useEffect((()=>{if(!i&&!c)return;let e=setTimeout(y,lr);return()=>clearTimeout(e)}),[i,c]),i||c?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{onClose:y}),/*#__PURE__*/e.jsx(Xo,{}),/*#__PURE__*/e.jsxs(Ko,{children:[c?/*#__PURE__*/e.jsx(Ze.default,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/e.jsx(ht.default,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/e.jsx(rs,{height:20}),/*#__PURE__*/e.jsx(nc,{title:c?"Something went wrong":"Success!",description:c?"Please try again.":"You've successfully revoked permissions."})]}),/*#__PURE__*/e.jsx(es,{}),/*#__PURE__*/e.jsx(Di,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{closeable:!0,onClose:y}),/*#__PURE__*/e.jsx(vt.default,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/e.jsx(Ks,{style:{marginTop:24},children:"Revoke offline access to wallet"}),/*#__PURE__*/e.jsxs(Zs,{children:["By confirming, ",t.name," will no longer be able to use this wallet on your behalf when you are not online."]}),/*#__PURE__*/e.jsxs(xw,{style:{marginTop:24},children:[/*#__PURE__*/e.jsx(Ni,{onClick:y,children:"Deny"}),/*#__PURE__*/e.jsx(Ai,{onClick:async()=>{try{await u(),l(!0)}catch(e){d(e)}},children:"Confirm"})]}),/*#__PURE__*/e.jsx(Di,{})]})}};let xw=/*#__PURE__*/g.styled.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-993a839-0"})(["display:flex;gap:10px;"]),Cw="#8a63d2";const bw={component:()=>{let{lastScreen:t,navigateBack:a,data:i,app:o}=Ua(),{requestFarcasterSignerStatus:l,closePrivyModal:c}=s.usePrivyInternal(),[d,u]=r.useState(void 0),[h,p]=r.useState(!1),[y,m]=r.useState(!1),g=r.useRef([]),f=i?.farcasterSigner;r.useEffect((()=>{let e=Date.now(),t=setInterval((async()=>{if(!f?.public_key)return clearInterval(t),void u({retryable:!0,message:"Connect failed",detail:"Something went wrong. Please try again."});"approved"===f.status&&(clearInterval(t),p(!1),m(!0),g.current.push(setTimeout((()=>c({shouldCallAuthOnSuccess:!1,isSuccess:!0})),sr)));let r=await l(f?.public_key),n=Date.now()-e;"approved"===r.status?(clearInterval(t),p(!1),m(!0),g.current.push(setTimeout((()=>c({shouldCallAuthOnSuccess:!1,isSuccess:!0})),sr))):n>3e5?(clearInterval(t),u({retryable:!0,message:"Connect failed",detail:"The request timed out. Try again."})):"revoked"===r.status&&(clearInterval(t),u({retryable:!0,message:"Request rejected",detail:"The request was rejected. Please try again."}))}),2e3);return()=>{clearInterval(t),g.current.forEach((e=>clearTimeout(e)))}}),[]);let w="pending_approval"===f?.status?f.signer_approval_url:void 0;return n.isMobile||h?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{backFn:t?a:void 0,onClose:c},"header"),/*#__PURE__*/e.jsx(Xo,{}),n.isIOS?
26
26
  /*#__PURE__*/e.jsx(e.Fragment,{children:/*#__PURE__*/e.jsxs(Ew,{children:[/*#__PURE__*/e.jsx(dl,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(Ci,{success:y,fail:!!d}),/*#__PURE__*/e.jsx(Pu,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e.jsxs(Jo,{children:[/*#__PURE__*/e.jsx(Ks,{children:d?d.message:"Add a signer to Farcaster"}),/*#__PURE__*/e.jsx(Zs,{children:d?d.detail:"This will allow "+o.name+" to add casts, likes, follows, and more on your behalf."})]}),w&&/*#__PURE__*/e.jsx(Ai,{onClick:e=>{e.preventDefault(),window.location.href=w},children:"Open Warpcast app"})]})}):/*#__PURE__*/e.jsx(e.Fragment,{children:/*#__PURE__*/e.jsxs(jw,{children:[/*#__PURE__*/e.jsx(dl,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(Ci,{success:y,fail:!!d}),/*#__PURE__*/e.jsx(Pu,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e.jsxs(Jo,{children:[/*#__PURE__*/e.jsx(Ks,{children:d?d.message:"Requesting signer from Farcaster"}),/*#__PURE__*/e.jsx(Zs,{children:d?d.detail:"This should only take a moment"}),/*#__PURE__*/e.jsx(Ho,{children:w&&n.isMobile&&/*#__PURE__*/e.jsx(Lu,{text:"Take me to Warpcast",url:w,color:Cw})})]})]})}),/*#__PURE__*/e.jsx(Bi,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{backFn:t?a:void 0,onClose:c},"header"),/*#__PURE__*/e.jsx(Xo,{}),/*#__PURE__*/e.jsx(jw,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(Ks,{children:"Add a signer to Farcaster"}),/*#__PURE__*/e.jsxs(Zs,{children:["This will allow ",o.name," to add casts, likes, follows, and more on your behalf."]}),/*#__PURE__*/e.jsx(Zo,{children:"pending_approval"===f?.status?/*#__PURE__*/e.jsx(Yu,{url:f.signer_approval_url,size:275,squareLogoElement:Pu}):/*#__PURE__*/e.jsx(bi,{})}),/*#__PURE__*/e.jsxs(Ho,{children:[/*#__PURE__*/e.jsx(Zs,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),"pending_approval"===f?.status&&/*#__PURE__*/e.jsx(Fu,{text:f.signer_approval_url,itemName:"link",color:Cw})]})]})}),/*#__PURE__*/e.jsx(Bi,{})]})}};let jw=/*#__PURE__*/g.styled.div.withConfig({displayName:"ConnectContainer",componentId:"sc-6e8f76e5-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),Ew=/*#__PURE__*/g.styled.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-6e8f76e5-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const kw={component:()=>{let{closePrivyModal:t}=s.usePrivyInternal();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{},"header"),/*#__PURE__*/e.jsx(Tw,{children:/*#__PURE__*/e.jsx(Ye.default,{style:{width:32,height:32}})}),/*#__PURE__*/e.jsx(rc,{title:"Could not log in with provider",description:"It looks like you're using an in-app browser. To log in, please try again using an external browser.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),/*#__PURE__*/e.jsx(Vo,{children:/*#__PURE__*/e.jsx(Ai,{onClick:()=>t(),children:"Close"})}),/*#__PURE__*/e.jsx(es,{}),/*#__PURE__*/e.jsx(Di,{})]})}};let Tw=/*#__PURE__*/g.styled.div.withConfig({displayName:"StyledCircle",componentId:"sc-7bde5742-0"})(["border-radius:50%;height:68px;width:68px;display:flex;align-items:center;justify-content:center;background-color:var(--privy-color-accent);color:white;margin:0 auto 24px auto;"]);const Aw={component:()=>{let{app:t}=Ua();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{},"header"),/*#__PURE__*/e.jsx(Xo,{}),/*#__PURE__*/e.jsx(nc,{title:"Connect your email",description:`Add your email to your ${t?.name} account`,icon:/*#__PURE__*/e.jsx($e.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/e.jsx(Vo,{children:/*#__PURE__*/e.jsx(qp,{stacked:!0})}),/*#__PURE__*/e.jsx(es,{}),/*#__PURE__*/e.jsx(Di,{})]})}},Iw={component:()=>{let{app:t,currentScreen:r,data:n,navigate:a,setModalData:i}=Ua(),{initLoginWithSms:o}=s.usePrivyInternal();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{},"header"),/*#__PURE__*/e.jsx(Xo,{}),/*#__PURE__*/e.jsx(nc,{title:"Connect your phone",description:`Add your number to your ${t?.name} account`,icon:/*#__PURE__*/e.jsx(Ne.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"})}),/*#__PURE__*/e.jsx(Vo,{children:/*#__PURE__*/e.jsx(vh,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{await o({phoneNumber:e,withPrivyUi:!0}),a(_p)}catch(e){i({errorModalData:{error:e,previousScreen:n?.errorModalData?.previousScreen||r||Iw}}),a(Yd)}},hideRecent:!0})}),/*#__PURE__*/e.jsx(es,{}),/*#__PURE__*/e.jsx(Di,{})]})}},Sw={component:()=>{let{app:t,data:r}=Ua(),n=r?.externalConnectWallet?.suggestedAddress,a=n?/*#__PURE__*/e.jsxs("span",{children:["Link the wallet with address ",/*#__PURE__*/e.jsx(Od,{showCopyIcon:!1,address:n})," ",t?.name?`to ${t.name}.`:"."]}):`Link a wallet to your ${t?.name} account`,{connectors:i}=s.usePrivyInternal(),o=gp({walletList:r?.externalConnectWallet?.walletList??t.appearance.walletList,walletChainType:r?.externalConnectWallet?.walletChainType??t.appearance.walletChainType,connectors:i,connectOnly:!1,ignore:t.appearance.walletList,walletConnectEnabled:t.externalWallets.walletConnect.enabled});/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{},"header"),o.length>0&&/*#__PURE__*/e.jsx(rc,{title:"Link your wallet",description:a}),/*#__PURE__*/e.jsx(hi,{children:/*#__PURE__*/e.jsx(mp,{wallets:o})}),/*#__PURE__*/e.jsx(Di,{})]})}},Pw=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{width:"164",height:"164",viewBox:"0 0 164 164",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...t},...r,children:[/*#__PURE__*/e.jsx("circle",{cx:"82",cy:"82",r:"80",stroke:"#EC6351","stroke-width":"4","stroke-linecap":"round"}),/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M81.9999 100.788C93.3288 100.788 102.513 91.6043 102.513 80.2754C102.513 68.9465 93.3288 59.7626 81.9999 59.7626C70.671 59.7626 61.4871 68.9465 61.4871 80.2754C61.4871 91.6043 70.671 100.788 81.9999 100.788ZM88.3236 71.8304C88.9093 71.2446 89.8591 71.2446 90.4449 71.8304C91.0307 72.4161 91.0307 73.3659 90.4449 73.9517L84.121 80.2756L90.445 86.5996C91.0308 87.1854 91.0308 88.1351 90.445 88.7209C89.8592 89.3067 88.9095 89.3067 88.3237 88.7209L81.9997 82.3969L75.6756 88.7209C75.0899 89.3067 74.1401 89.3067 73.5543 88.7209C72.9685 88.1351 72.9685 87.1854 73.5543 86.5996L79.8783 80.2756L73.5544 73.9517C72.9686 73.3659 72.9686 72.4161 73.5544 71.8304C74.1402 71.2446 75.09 71.2446 75.6758 71.8304L81.9997 78.1543L88.3236 71.8304Z",fill:"#EC6351"})]}),_w={component:()=>{let{closePrivyModal:t}=s.usePrivyInternal(),{navigate:r}=Ua();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{},"header"),/*#__PURE__*/e.jsx(Xo,{}),/*#__PURE__*/e.jsx(Pw,{style:{width:"160px",height:"160px",margin:"0 auto 20px"}}),/*#__PURE__*/e.jsx(rc,{title:"Could not connect with wallet",description:"Please check that Phantom multichain is enabled and try again.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),/*#__PURE__*/e.jsxs(Vo,{children:[/*#__PURE__*/e.jsx(Ai,{onClick:()=>r(Jp),children:"Try again"}),/*#__PURE__*/e.jsx(Ni,{onClick:()=>t(),children:"Cancel"})]}),/*#__PURE__*/e.jsx(es,{}),/*#__PURE__*/e.jsx(Di,{})]})}};function Nw(){let{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:a,submitEnrollmentWithTotp:i,submitEnrollmentWithPasskey:o,unenroll:s,enrollInMfa:l}=r.useContext(u.PrivyContext);return{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:a,submitEnrollmentWithTotp:i,submitEnrollmentWithPasskey:o,unenrollWithSms:()=>s("sms"),unenrollWithTotp:()=>s("totp"),unenrollWithPasskey:e=>s("passkey",e),showMfaEnrollmentModal:()=>l(!0),closeMfaEnrollmentModal:()=>l(!1)}}const Mw=t=>/*#__PURE__*/e.jsxs(Ww,{xmlns:"http://www.w3.org/2000/svg",fill:"none",width:"88",height:"89",viewBox:"0 0 88 89",...t,children:[/*#__PURE__*/e.jsx("rect",{y:"0.666016",width:"88",height:"88",rx:"44"}),/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M45.2463 20.9106C44.5473 20.2486 43.4527 20.2486 42.7537 20.9106C37.8798 25.5263 31.3034 28.3546 24.0625 28.3546C23.9473 28.3546 23.8323 28.3539 23.7174 28.3525C22.9263 28.3427 22.2202 28.8471 21.9731 29.5987C20.9761 32.6311 20.4375 35.8693 20.4375 39.2297C20.4375 53.5896 30.259 65.651 43.5482 69.0714C43.8446 69.1477 44.1554 69.1477 44.4518 69.0714C57.741 65.651 67.5625 53.5896 67.5625 39.2297C67.5625 35.8693 67.0239 32.6311 66.0269 29.5987C65.7798 28.8471 65.0737 28.3427 64.2826 28.3525C64.1677 28.3539 64.0527 28.3546 63.9375 28.3546C56.6966 28.3546 50.1202 25.5263 45.2463 20.9106ZM52.7249 40.2829C53.3067 39.4683 53.1181 38.3363 52.3035 37.7545C51.4889 37.1726 50.3569 37.3613 49.7751 38.1759L41.9562 49.1223L38.0316 45.1977C37.3238 44.4899 36.1762 44.4899 35.4684 45.1977C34.7605 45.9056 34.7605 47.0532 35.4684 47.761L40.9059 53.1985C41.2826 53.5752 41.806 53.7671 42.337 53.7232C42.868 53.6792 43.3527 53.4039 43.6624 52.9704L52.7249 40.2829Z"})]});let Ww=/*#__PURE__*/g.styled.svg.withConfig({displayName:"StyledSvg",componentId:"sc-59fa943f-0"})(["height:90px;width:90px;> rect{","}> path{fill:white;}"],(e=>"success"===e.color?"fill: var(--privy-color-success);":"fill: var(--privy-color-accent);"));const Uw=({showIntro:t,userMfaMethods:r,appMfaMethods:n,userHasAuthSms:a,isTotpLoading:i,isPasskeyLoading:o,error:s,onClose:l,onBackToIntro:c,handleSelectMethod:d,setRemovingMfaMethod:u})=>{let h=r.reduce(((e,t)=>({...e,[t]:!0})),{}),p=n.reduce(((e,t)=>({...e,[t]:!0})),{});/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{backFn:t?c:void 0,onClose:l},"header"),/*#__PURE__*/e.jsx(ll,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Me.default,{})}),/*#__PURE__*/e.jsx(Ks,{children:"Choose a verification method"}),r.length>0?/*#__PURE__*/e.jsx(Zs,{children:"To add or delete verification methods, verification is required."}):/*#__PURE__*/e.jsx(Zs,{children:"How would you like to verify your identity? You can change this later."}),s&&/*#__PURE__*/e.jsx(cl,{style:{marginTop:"1.25rem"},children:s.message}),/*#__PURE__*/e.jsxs(el,{children:[(p.totp||h.totp)&&/*#__PURE__*/e.jsxs(tl,{children:[/*#__PURE__*/e.jsx(gi,{style:{justifyContent:"center"},disabled:h.totp||i,onClick:()=>d("totp"),children:i?/*#__PURE__*/e.jsx(bi,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e.jsxs(il,{children:[/*#__PURE__*/e.jsxs(nl,{children:[/*#__PURE__*/e.jsx(Pe.default,{}),"Authenticator app"]}),h.totp?/*#__PURE__*/e.jsx(Ow,{color:"green",children:"Enabled"}):/*#__PURE__*/e.jsx(al,{children:"Recommended"})]})}),h.totp&&/*#__PURE__*/e.jsx(rl,{style:{position:"absolute",right:0},onClick:()=>u("totp"),children:/*#__PURE__*/e.jsx(Et.default,{})})]},"totp"),(p.sms||h.sms)&&/*#__PURE__*/e.jsxs(tl,{children:[/*#__PURE__*/e.jsx(gi,{disabled:h.sms||a,onClick:()=>d("sms"),children:/*#__PURE__*/e.jsxs(il,{children:[/*#__PURE__*/e.jsxs(nl,{children:[/*#__PURE__*/e.jsx(Ne.default,{}),"SMS"]}),h.sms&&/*#__PURE__*/e.jsx(Ow,{color:"green",children:"Enabled"}),a&&/*#__PURE__*/e.jsx(al,{children:"Disabled"})]})}),h.sms&&/*#__PURE__*/e.jsx(rl,{style:{position:"absolute",right:0},onClick:()=>u("sms"),children:/*#__PURE__*/e.jsx(Et.default,{})})]},"sms"),(p.passkey||h.passkey)&&/*#__PURE__*/e.jsxs(tl,{children:[/*#__PURE__*/e.jsx(gi,{style:{justifyContent:"center"},onClick:()=>d("passkey"),disabled:h.passkey||o,children:o?/*#__PURE__*/e.jsx(bi,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e.jsxs(il,{children:[/*#__PURE__*/e.jsxs(nl,{children:[/*#__PURE__*/e.jsx(_e.default,{}),"Passkey"]}),h.passkey?/*#__PURE__*/e.jsx(Ow,{color:"green",children:"Enabled"}):/*#__PURE__*/e.jsx(al,{isAccent:!0,children:/*#__PURE__*/e.jsx(tt.default,{})})]})}),h.passkey&&/*#__PURE__*/e.jsx(rl,{style:{position:"absolute",right:0},onClick:()=>u("passkey"),children:/*#__PURE__*/e.jsx(Et.default,{})})]},"passkey")]}),/*#__PURE__*/e.jsx(Bi,{})]})};let Ow=/*#__PURE__*/g.styled(Iu).withConfig({displayName:"StyledChip",componentId:"sc-998ca5bc-0"})(["margin-right:1.5rem;"]);const Fw=({appName:t,onComplete:n,onClose:a,onReset:i})=>{let{user:o}=u.usePrivyContext(),{data:l}=Ua(),{initLinkWithPasskey:c,linkWithPasskey:d}=s.usePrivyInternal(),{initEnrollmentWithPasskey:h,submitEnrollmentWithPasskey:p}=Nw(),[y,m]=r.useState(!1),[g,f]=r.useState(!1),[w,v]=r.useState(!1),[x,C]=r.useState(null),b=r.useMemo((()=>o?.linkedAccounts.filter((e=>"passkey"===e.type))??[]),[o]),j=()=>{l?.mfaEnrollmentFlow?.onSuccess(),n()},E=async e=>{m(!0);try{await h(),await p({credentialIds:e},{removeForLogin:l?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa}),v(!0)}catch(e){C(e)}finally{m(!1)}},k=async()=>{f(!0),C(null);try{await c();let e=await d(),t=e?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];await E(t)}catch(e){C(e)}finally{f(!1)}};return 0===b.length||g?/*#__PURE__*/e.jsx(Rw,{onReset:i,onClose:a,onClick:k,isCreating:g}):w?/*#__PURE__*/e.jsx(Dw,{appName:t,onClick:j,onClose:j}):x?/*#__PURE__*/e.jsx(Gd,{error:x,backFn:()=>C(null),onClick:()=>C(null)}):/*#__PURE__*/e.jsx(Lw,{passkeys:b,isSubmitting:y,isCreating:g,onReset:i,onClose:a,onSubmitEnrollment:()=>E(b.map((e=>e.credentialId))),onAddPasskey:k})};let Rw=({onReset:t,onClose:r,onClick:n,isCreating:a})=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{backFn:t,onClose:r},"header"),/*#__PURE__*/e.jsx(Hs,{children:/*#__PURE__*/e.jsxs(km,{children:[/*#__PURE__*/e.jsx(ul,{}),/*#__PURE__*/e.jsx(dh,{})]})}),/*#__PURE__*/e.jsx(Ks,{children:"Set up passkey verification"}),/*#__PURE__*/e.jsxs(Gs,{children:[/*#__PURE__*/e.jsxs(Qs,{children:[/*#__PURE__*/e.jsx(Js,{children:/*#__PURE__*/e.jsx(Me.default,{})}),"Verify with Touch ID, Face ID, PIN, or hardware key"]}),/*#__PURE__*/e.jsxs(Qs,{children:[/*#__PURE__*/e.jsx(Js,{children:/*#__PURE__*/e.jsx(xt.default,{})}),"Takes seconds to set up and use"]}),/*#__PURE__*/e.jsxs(Qs,{children:[/*#__PURE__*/e.jsx(Js,{children:/*#__PURE__*/e.jsx(kt.default,{})}),"Use your passkey to verify transactions and login to your account"]})]}),/*#__PURE__*/e.jsx(Ai,{style:{marginTop:"2.25rem"},onClick:n,loading:a,children:"Add a new passkey"}),/*#__PURE__*/e.jsx(Bi,{})]}),Lw=({onReset:t,onClose:n,onAddPasskey:a,onSubmitEnrollment:i,passkeys:o,isSubmitting:s,isCreating:l})=>{let[c,d]=r.useState(!1),u=c?o.length:o.length>3?2:3;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{backFn:c?()=>d(!1):t,onClose:n},"header"),!c&&/*#__PURE__*/e.jsx(Hs,{children:/*#__PURE__*/e.jsxs(km,{children:[/*#__PURE__*/e.jsx(ul,{}),/*#__PURE__*/e.jsx(dh,{})]})}),/*#__PURE__*/e.jsx(Ks,{children:"Enable your passkeys for verification"}),/*#__PURE__*/e.jsxs(Gs,{children:[o.slice(0,u).map((t=>/*#__PURE__*/e.jsxs(Bw,{children:[/*#__PURE__*/e.jsx(zw,{children:qw(t)}),/*#__PURE__*/e.jsxs($w,{children:["Last used: ",t.latestVerifiedAt?.toLocaleString()]})]},t.credentialId))),!c&&o.length>3&&/*#__PURE__*/e.jsx(Vw,{onClick:()=>d(!0),children:"View All"})]}),/*#__PURE__*/e.jsx(Ai,{style:{marginTop:"1.5rem"},onClick:i,loading:s,children:"Enable passkeys"}),o.length<5&&/*#__PURE__*/e.jsx(Vw,{style:{marginTop:"0.5rem"},onClick:a,disabled:l,children:l?/*#__PURE__*/e.jsx(bi,{style:{height:"1rem",width:"1rem",borderWidth:2}}):"Add new passkey"}),/*#__PURE__*/e.jsx(Bi,{})]})},Dw=({appName:t,onClick:r,onClose:n})=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{onClose:n},"header"),/*#__PURE__*/e.jsx(ll,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(ht.default,{})}),/*#__PURE__*/e.jsx(Ks,{children:"Passkey verification added"}),/*#__PURE__*/e.jsxs(Zs,{children:["From now on, you'll use the passkey whenever you use your ",t," wallet."]}),/*#__PURE__*/e.jsx(Xs,{children:/*#__PURE__*/e.jsx(Ai,{onClick:r,children:"Done"})}),/*#__PURE__*/e.jsx(Bi,{})]}),Bw=/*#__PURE__*/g.styled.div.withConfig({displayName:"PasskeyItem",componentId:"sc-d5b2bf9c-0"})(["&&{padding:0.75rem 1rem;text-align:left;border-radius:0.5rem;border:1px solid var(--privy-color-foreground-4);width:100%;}"]),zw=/*#__PURE__*/g.styled.div.withConfig({displayName:"PasskeyItemTitle",componentId:"sc-d5b2bf9c-1"})(["font-size:0.875rem;line-height:1.375rem;font-weight:500;color:var(--privy-color-foreground-1);"]),$w=/*#__PURE__*/g.styled.div.withConfig({displayName:"PasskeyItemSubtitle",componentId:"sc-d5b2bf9c-2"})(["font-size:0.75rem;font-weight:400;line-height:1.125rem;color:var(--privy-color-foreground-2);"]),qw=e=>e.authenticatorName?e.createdWithBrowser?`${e.authenticatorName} on ${e.createdWithBrowser}`:e.authenticatorName:e.createdWithBrowser?e.createdWithOs?`${e.createdWithBrowser} on ${e.createdWithOs}`:`${e.createdWithBrowser}`:"Unknown device";const Vw=/*#__PURE__*/g.styled.button.withConfig({displayName:"StyledLink",componentId:"sc-d5b2bf9c-3"})(["&&{width:100%;font-size:0.875rem;line-height:1rem;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;justify-content:center;padding:0.75rem 1rem;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent);:focus{outline:none;box-shadow:none;}}"]),Hw=({appName:t,onComplete:n,onReset:a,onClose:o})=>{let[s,l]=r.useState(""),[c,d]=r.useState(!1),[u,h]=r.useState(null),[p,y]=r.useState("enroll"),{initEnrollmentWithSms:m,submitEnrollmentWithSms:g}=Nw(),{app:f,data:w}=Ua();function v(){w?.mfaEnrollmentFlow?.onSuccess(),n()}return u?/*#__PURE__*/e.jsx(Gd,{error:u,backFn:()=>h(null),onClick:()=>h(null)}):"enroll"===p?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{backFn:a,onClose:o},"header"),/*#__PURE__*/e.jsx(ll,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Ne.default,{})}),/*#__PURE__*/e.jsx(Ks,{children:"Set up SMS verification"}),/*#__PURE__*/e.jsxs(Zs,{children:["We'll text a verification code to this mobile device whenever you use your ",t," ","wallet."]}),/*#__PURE__*/e.jsxs(Ys,{children:[/*#__PURE__*/e.jsx(vh,{onSubmit:async function({qualifiedPhoneNumber:e}){try{await m({phoneNumber:e}),l(e),y("verify")}catch(e){h(e)}},hideRecent:!0}),/*#__PURE__*/e.jsxs(ol,{children:["By providing your mobile number, you agree to receive text messages from ",f?.name,". Some carrier charges may apply"]})]}),/*#__PURE__*/e.jsx(Bi,{})]}):c?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{onClose:v},"header"),/*#__PURE__*/e.jsx(ll,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(ht.default,{})}),/*#__PURE__*/e.jsx(Ks,{children:"SMS verification added"}),/*#__PURE__*/e.jsxs(Zs,{children:["From now on, you'll enter the verification code sent to your mobile device whenever you use your ",t," wallet."]}),/*#__PURE__*/e.jsx(Xs,{children:/*#__PURE__*/e.jsx(Ai,{onClick:v,children:"Done"})}),/*#__PURE__*/e.jsx(Bi,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{backFn:function(){"verify"===p?y("enroll"):a()},onClose:o},"header"),/*#__PURE__*/e.jsx(ll,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Ne.default,{})}),/*#__PURE__*/e.jsx(Ks,{children:"Enter enrollment code"}),/*#__PURE__*/e.jsxs(Ys,{children:[/*#__PURE__*/e.jsx(no,{onChange:async function(e){try{if(!e)return;await g({phoneNumber:s,mfaCode:e}),d(!0)}catch(e){if($s(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Bs(e))throw Error("The code you entered is not valid");if(Ds(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw qs(e)?Error("Verification canceled"):Error("Unknown error")}}}),/*#__PURE__*/e.jsxs(Zs,{children:["To continue, enter the 6-digit code sent to ",/*#__PURE__*/e.jsx("strong",{children:i.lastFourDigits(s)})]})]}),/*#__PURE__*/e.jsx(Bi,{})]})},Kw=({size:t,authUrl:r})=>/*#__PURE__*/e.jsx(Yu,{url:r,squareLogoElement:Tt.default,size:t,fgColor:"#1F1F1F"}),Zw=({onComplete:t,onClose:n,onReset:a,totpInfo:i})=>{let[o,s]=r.useState("enroll"),[l,c]=r.useState(!1),{submitEnrollmentWithTotp:d}=Nw(),{data:u}=Ua();function h(){u?.mfaEnrollmentFlow?.onSuccess(),t()}return"enroll"===o?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{backFn:a,onClose:n},"header"),/*#__PURE__*/e.jsx(Ks,{children:"Scan QR code"}),/*#__PURE__*/e.jsx(Zs,{children:"Open your authenticator app and scan the QR code to continue."}),/*#__PURE__*/e.jsx(Zo,{children:/*#__PURE__*/e.jsx(Kw,{authUrl:i.authUrl,size:200})}),/*#__PURE__*/e.jsxs(Xs,{children:[/*#__PURE__*/e.jsx(Ho,{children:/*#__PURE__*/e.jsx(Fu,{itemName:"setup key",text:i.secret})}),/*#__PURE__*/e.jsx(Ai,{onClick:function(){s("verify")},children:"Continue"})]}),/*#__PURE__*/e.jsx(Bi,{})]}):l?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{onClose:h},"header"),/*#__PURE__*/e.jsx(ll,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(ht.default,{})}),/*#__PURE__*/e.jsx(Ks,{children:"Authenticator app verification added"}),/*#__PURE__*/e.jsxs(Zs,{children:["From now on, you'll enter the verification code generated by your authenticator app whenever you use your ",i.appName," wallet."]}),/*#__PURE__*/e.jsx(Xs,{children:/*#__PURE__*/e.jsx(Ai,{onClick:h,children:"Done"})}),/*#__PURE__*/e.jsx(Bi,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{backFn:function(){"verify"===o?s("enroll"):a()},onClose:n},"header"),/*#__PURE__*/e.jsx(ll,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Pe.default,{})}),/*#__PURE__*/e.jsx(Ks,{children:"Enter enrollment code"}),/*#__PURE__*/e.jsx(Ys,{children:/*#__PURE__*/e.jsx(no,{onChange:async function(e){try{if(!e)return;await d({mfaCode:e}),c(!0)}catch(e){if($s(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Bs(e))throw Error("The code you entered is not valid");if(Ds(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw qs(e)?Error("Verification canceled"):Error("Unknown error")}}})}),/*#__PURE__*/e.jsxs(Zs,{children:["To continue, enter the 6-digit code generated from your ",/*#__PURE__*/e.jsx("strong",{children:"authenticator app"})]}),/*#__PURE__*/e.jsx(Bi,{})]})},Yw={component:()=>{let{user:t,enrollInMfa:n,ready:a}=u.usePrivyContext(),[i,o]=r.useState(null),{unenrollWithSms:l,unenrollWithTotp:c,unenrollWithPasskey:d}=Nw(),{app:h,data:p,onUserCloseViaDialogOrKeybindRef:y}=Ua(),{closePrivyModal:m}=s.usePrivyInternal(),{promptMfa:g}=Vs(),{initEnrollmentWithTotp:f}=Nw(),[w,v]=r.useState(!1),[x,C]=r.useState(null),[b,j]=r.useState(null),E=()=>{m({shouldCallAuthOnSuccess:!0}),n(!1),setTimeout((()=>{o(null),C(null)}),500)},{initEnrollmentWithPasskey:k,submitEnrollmentWithPasskey:T}=Nw(),[A,I]=r.useState(!1),[S,P]=r.useState(null);y.current=E;let _=t?.mfaMethods.includes("sms"),N=!!t?.phone,M=t?.mfaMethods.includes("totp"),W=t?.mfaMethods.includes("passkey"),U=_||M||W,O=t?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function F(){o(null),C(null)}if(r.useEffect((()=>{U&&v(!0)}),[U]),!a||!t||!h/*#__PURE__*/)return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{onClose:E},"header"),/*#__PURE__*/e.jsx(Hs,{children:/*#__PURE__*/e.jsx(Mw,{})}),/*#__PURE__*/e.jsx(Ys,{children:/*#__PURE__*/e.jsx(bi,{})}),/*#__PURE__*/e.jsx(Bi,{})]});if("sms"===i)/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{backFn:F,onClose:E},"header"),/*#__PURE__*/e.jsx(ll,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Ue.default,{})}),/*#__PURE__*/e.jsx(Ks,{children:"Remove SMS verification?"}),/*#__PURE__*/e.jsxs(Zs,{children:["MFA adds an extra layer of security to your ",h?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/e.jsx(Xs,{children:/*#__PURE__*/e.jsx(Ai,{warn:!0,onClick:async function(){o(null);try{await l()}catch(e){o(null)}},children:"Remove SMS for MFA"})}),/*#__PURE__*/e.jsx(Bi,{})]});if("totp"===i)/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{backFn:F,onClose:E},"header"),/*#__PURE__*/e.jsx(ll,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Ue.default,{})}),/*#__PURE__*/e.jsx(Ks,{children:"Remove Authenticator App verification?"}),/*#__PURE__*/e.jsxs(Zs,{children:["MFA adds an extra layer of security to your ",h?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/e.jsx(Xs,{children:/*#__PURE__*/e.jsx(Ai,{warn:!0,onClick:async function(){o(null);try{await c()}catch(e){o(null)}},children:"Remove Authenticator App for MFA"})}),/*#__PURE__*/e.jsx(Bi,{})]});if("passkey"===i){let t=p?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{backFn:F,onClose:E},"header"),/*#__PURE__*/e.jsx(ll,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Ue.default,{})}),/*#__PURE__*/e.jsx(Ks,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/e.jsx(Zs,{children:t?"Removing your passkey will remove as both a verification method and a login method.":"Removing your passkey will remove as a verification method."}),/*#__PURE__*/e.jsx(Xs,{children:/*#__PURE__*/e.jsx(Ai,{warn:!0,onClick:async function(){o(null);try{await d({removeForLogin:p?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){o(null)}},children:"Yes, remove"})}),/*#__PURE__*/e.jsx(Bi,{})]})}if(0===p.mfaEnrollmentFlow.mfaMethods.length&&!U)/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{onClose:E},"header"),/*#__PURE__*/e.jsx(ll,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Me.default,{})}),/*#__PURE__*/e.jsx(Ks,{children:"Add more security"}),/*#__PURE__*/e.jsxs(Zs,{children:[h?.name," does not have any verification methods enabled."]}),/*#__PURE__*/e.jsx(Xs,{children:/*#__PURE__*/e.jsx(Ai,{onClick:E,children:"Close"})}),/*#__PURE__*/e.jsx(Bi,{})]});let R=!U&&!w;return R?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{onClose:E},"header"),/*#__PURE__*/e.jsx(ll,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/e.jsx(Me.default,{})}),/*#__PURE__*/e.jsx(Ks,{children:"Transaction Protection"}),/*#__PURE__*/e.jsx(Zs,{children:"Set up transaction protection to add an extra layer of security to your account"}),/*#__PURE__*/e.jsxs(Gs,{children:[/*#__PURE__*/e.jsxs(Qs,{children:[/*#__PURE__*/e.jsx(Js,{children:/*#__PURE__*/e.jsx(bt.default,{})}),"Enable 2-Step verification for your ",h?.name," wallet."]}),/*#__PURE__*/e.jsxs(Qs,{children:[/*#__PURE__*/e.jsx(Js,{children:/*#__PURE__*/e.jsx(jt.default,{})}),"You'll be prompted to authenticate to complete transactions."]})]}),/*#__PURE__*/e.jsxs(Xs,{children:[/*#__PURE__*/e.jsx(Ai,{onClick:()=>v(!0),children:"Continue"}),/*#__PURE__*/e.jsx(Ni,{onClick:E,children:"Not now"})]}),/*#__PURE__*/e.jsx(Bi,{})]}):"sms"===x?/*#__PURE__*/e.jsx(Hw,{appName:h?.name||"Privy",onComplete:E,onReset:F,onClose:E}):"totp"===x&&b?/*#__PURE__*/e.jsx(Zw,{onComplete:E,onClose:E,onReset:F,totpInfo:{...b,appName:h?.name||"Privy"}}):"passkey"===x?/*#__PURE__*/e.jsx(Fw,{appName:h?.name||"Privy",onComplete:E,onReset:F,onClose:E}):/*#__PURE__*/e.jsx(Uw,{showIntro:R,userMfaMethods:t.mfaMethods,appMfaMethods:h.mfa.methods,userHasAuthSms:N,onBackToIntro:function(){v(!1)},handleSelectMethod:async function(e){return await g().catch(P),"totp"===e?(C(e),j(null),void f().then((e=>{j(e)})).catch((()=>{j(null),F()}))):"passkey"===e&&1===O.length?await async function(){I(!0);try{await k(),await T({credentialIds:O},{removeForLogin:p?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){P(e)}finally{I(!1)}}():void C(e)},isTotpLoading:"totp"===x&&!b,isPasskeyLoading:A,error:S,onClose:E,setRemovingMfaMethod:async e=>{await g().catch(P),o(e)}})}},Gw={component:()=>{let{authenticated:t,logout:n,ready:a,user:i}=u.usePrivyContext(),{app:l,setModalData:c,navigate:d,resetNavigation:h}=Ua(),{getAuthMeta:p,initLoginWithOAuth:y,loginWithOAuth:m,updateWallets:g,setReadyToTrue:f,closePrivyModal:w,createAnalyticsEvent:v}=s.usePrivyInternal(),[x,C]=r.useState(!1),[b,j]=r.useState(void 0),E=p()?.provider||"google",{name:k,component:T}=Jr(E);r.useEffect((()=>{m(E).then((()=>{C(!0),f(!0)})).catch((e=>{if(f(!1),e?.privyErrorCode===o.PrivyErrorCode.ALLOWLIST_REJECTED)return j(void 0),h(),void d(Gu);if(e?.privyErrorCode===o.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new o.PrivyUserLimitReachedError(e).toString()),j(void 0),h(),void d(eh);if(e?.privyErrorCode===o.PrivyErrorCode.USER_DOES_NOT_EXIST)return j(void 0),h(),void d(Nd);if(e?.privyErrorCode===o.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return j(void 0),h(),c({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:p()?.provider,embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,oAuthUserInfo:e.data?.data?.otherUser?.oAuthUserInfo}}),void d(uu);let{retryable:t,detail:r}=function(e,t){let r={detail:"",retryable:!1},n=Lr(t);if(e?.privyErrorCode===o.PrivyErrorCode.LINKED_TO_ANOTHER_USER&&(r.detail="This account has already been linked to another user."),e?.privyErrorCode===o.PrivyErrorCode.INVALID_CREDENTIALS&&(r.retryable=!0,r.detail="Something went wrong. Try again."),e.privyErrorCode===o.PrivyErrorCode.OAUTH_USER_DENIED&&(r.detail=`Retry and check ${n} to finish connecting your account.`,r.retryable=!0),e?.privyErrorCode===o.PrivyErrorCode.TOO_MANY_REQUESTS&&(r.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===o.PrivyErrorCode.TOO_MANY_REQUESTS&&e.message.includes("provider rate limit")){let e=Jr(t).name;r.detail=`Request limit reached for ${e}. Please wait a moment and try again.`}if(e?.privyErrorCode===o.PrivyErrorCode.OAUTH_ACCOUNT_SUSPENDED){let e=Jr(t).name;r.detail=`Your ${e} account is suspended. Please try another login method.`}return e?.privyErrorCode===o.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE&&(r.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode===o.PrivyErrorCode.OAUTH_UNEXPECTED&&t.startsWith("privy:")&&(r.detail="Something went wrong. Please try again."),r}(e,E);j({retryable:t,detail:r,message:"Authentication failed"})})).finally((()=>{Xr()}))}),[k,E]),r.useEffect((()=>{if(a&&t&&x&&i){if(l?.legal.requireUsersAcceptTerms&&!i.hasAcceptedTerms){let e=setTimeout((()=>{d(Cu)}),sr);return()=>clearTimeout(e)}if(Pd(i,l.embeddedWallets)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),v({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:E,screen:"OAuthStatusScreen"}}),n()},callAuthOnSuccessOnClose:!0}}),d(vu)}),sr);return()=>clearTimeout(e)}{let e=setTimeout((()=>w({shouldCallAuthOnSuccess:!0,isSuccess:!0})),sr);return g(),()=>clearTimeout(e)}}}),[a,t,x,i]);let A=x?`Successfully connected with ${k}`:b?b.message:`Verifying connection to ${k}`,I="";return I=x?"You’re good to go!":b?b.detail:"Just a few moments more",/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{}),/*#__PURE__*/e.jsx(Xo,{}),/*#__PURE__*/e.jsxs(Jw,{children:[/*#__PURE__*/e.jsx(dl,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsx(Ci,{success:x,fail:!!b}),/*#__PURE__*/e.jsx(T,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e.jsxs(Jo,{children:[/*#__PURE__*/e.jsx("h3",{children:A}),/*#__PURE__*/e.jsx("p",{children:I})]}),b&&b?.retryable?/*#__PURE__*/e.jsx(Wi,{onClick:()=>{Xr(),y(E),j(void 0)},disabled:!x&&!b?.retryable,children:"Retry"}):null]}),/*#__PURE__*/e.jsx(es,{}),/*#__PURE__*/e.jsx(Bi,{})]})}};let Jw=/*#__PURE__*/g.styled.div.withConfig({displayName:"ConnectContainer",componentId:"sc-89bb91a9-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const Qw=/*#__PURE__*/r.forwardRef(((t,n)=>{let[a,i]=r.useState(""),[o,l]=r.useState(""),[c,d]=r.useState(!1),{authenticated:h,user:p}=u.usePrivyContext(),{initUpdateEmail:y}=s.usePrivyInternal(),{navigate:m,setModalData:g,currentScreen:f}=Ua(),{enabled:w,token:v}=hn(),x=_a(),C=Lt(a)&&(x.disablePlusEmails&&a.includes("+")?(o||l("Please enter a valid email address without a '+'."),!1):(o&&l(""),!0)),b=c||!C,j=()=>{!w||v||h?(async e=>{if(!p?.email)throw Error("User is required to have an email address to update it.");d(!0);try{await y(p.email.address,a,e),m(_p)}catch(e){g({errorModalData:{error:e,previousScreen:f||Jp}})}d(!1)})(v):(g({captchaModalData:{callback:e=>{if(!p?.email)throw Error("User is required to have an email address to update it.");return y(p.email.address,a,e)},userIntentRequired:!1,onSuccessNavigateTo:_p,onErrorNavigateTo:Yd}}),m(Mu))};/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsxs(Xw,{children:[o&&/*#__PURE__*/e.jsx(Lp,{style:{marginTop:"0.25rem",textAlign:"left"},children:o}),/*#__PURE__*/e.jsxs(ev,{$error:!!o,children:[/*#__PURE__*/e.jsx($e.default,{}),/*#__PURE__*/e.jsx("input",{ref:n,id:"email-input",type:"email",placeholder:"your@email.com",onChange:e=>i(e.target.value),onKeyUp:e=>{"Enter"===e.key&&j()},value:a,autoComplete:"email"}),t.stacked?null:/*#__PURE__*/e.jsx(Ui,{isSubmitting:c,onClick:j,disabled:b,children:"Submit"})]})]}),t.stacked?/*#__PURE__*/e.jsx(Ai,{loadingText:null,loading:c,disabled:b,onClick:j,children:"Submit"}):null]})}));let Xw=$p,ev=Bp;const tv={component:()=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{},"header"),/*#__PURE__*/e.jsx(Xo,{}),/*#__PURE__*/e.jsx(nc,{title:"Update your email",description:"Add the email address you'd like to use going forward. We'll send you a confirmation code",icon:/*#__PURE__*/e.jsx($e.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/e.jsx(Vo,{children:/*#__PURE__*/e.jsx(Qw,{stacked:!0})}),/*#__PURE__*/e.jsx(es,{}),/*#__PURE__*/e.jsx(Di,{})]})},rv={component:()=>{let{currentScreen:t,data:r,navigate:n,setModalData:a}=Ua(),{user:i}=u.usePrivyContext(),{initUpdatePhone:o}=s.usePrivyInternal();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vi,{},"header"),/*#__PURE__*/e.jsx(Xo,{}),/*#__PURE__*/e.jsx(nc,{title:"Update your phone number",description:"Add the phone number you'd like to use going forward. We'll send you a confirmation code",icon:/*#__PURE__*/e.jsx(Ne.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/e.jsx(Vo,{children:/*#__PURE__*/e.jsx(vh,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{if(!i?.phone?.number)throw Error("User is required to have an phone number to update it.");await o(i?.phone?.number,e),n(_p)}catch(e){a({errorModalData:{error:e,previousScreen:r?.errorModalData?.previousScreen||t||Iw}}),n(Yd)}},hideRecent:!0})}),/*#__PURE__*/e.jsx(es,{}),/*#__PURE__*/e.jsx(Di,{})]})}};function nv({subscribe:e,getExternalJwt:t,enabled:n=!0,onAuthenticated:a,onUnauthenticated:i,onError:l}){let{client:c,onCustomAuthAuthenticated:d}=s.usePrivyInternal(),{logout:u,authenticated:h,ready:p}=Wy();if(!c)throw new o.PrivyClientError("`useSyncJwtBasedAuthState` must be used within a `PrivyProvider`");let[y,m]=r.useState({status:"initial"}),g=r.useRef(),f=r.useRef(!1),w=r.useRef(t);r.useEffect((()=>{w.current=t}),[t]);let v=r.useRef(a);r.useEffect((()=>{v.current=a}),[a]);let x=r.useRef(i);r.useEffect((()=>{x.current=i}),[i]);let C=r.useRef(l);return r.useEffect((()=>{C.current=l}),[l]),r.useEffect((()=>{if(!n||!p)return;let t=async()=>{if(!f.current){f.current=!0;try{m({status:"loading"});let e=await w.current();if(void 0!==g.current&&g.current===e)return void m({status:"done"});if(!e)return h&&(await u(),x.current?.()),g.current=e,void m({status:"done"});c.startAuthFlow(new $a(e));let{user:t,isNewUser:r=!1}=await c.authenticate();if(!t)throw new o.PrivyClientError("Failed to sync with custom auth provider");v.current?.({user:t,isNewUser:r}),d(t,r),g.current=e,m({status:"done"})}catch(e){if(console.warn(e),await u().catch((()=>{})),x.current?.(),e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.LINKED_TO_ANOTHER_USER)return m({status:"initial"}),void setTimeout((()=>{t()}),0);C.current?.(e),m({status:"error",error:e})}finally{f.current=!1}}};return t(),e(t)}),[e,c,d,h,u,n,p]),n?{state:y}:{state:{status:"not-enabled"}}}let av=P.create((()=>({jwtAuthFlowState:{status:"not-enabled"}})));function iv({customAuth:e}){let{jwtAuthFlowState:t}=function({customAuth:e}){let t=li(),n=r.useRef(),a=r.useCallback((e=>(n.current=e,()=>{n.current=void 0})),[]),i=e?.getCustomAccessToken??(()=>Promise.resolve(void 0)),{state:s}=nv({enabled:!0===e?.enabled,subscribe:a,getExternalJwt:i,onAuthenticated:({user:e,isNewUser:r})=>{t("login","onComplete",{user:e,isNewUser:r,wasAlreadyAuthenticated:!1,loginMethod:"custom",loginAccount:null}),t("customAuth","onAuthenticated",{user:e})},onUnauthenticated:()=>{t("customAuth","onUnauthenticated")},onError:e=>{t("login","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR)}});return r.useEffect((()=>{(async()=>{e&&!e.isLoading&&n.current?.()})()}),[e?.enabled,e?.getCustomAccessToken,e?.isLoading]),{jwtAuthFlowState:s}}({customAuth:e});return r.useEffect((()=>{av.setState({jwtAuthFlowState:t})}),[t]),null}const ov=/*#__PURE__*/r.createContext(!1);let sv,lv,cv,dv,uv,hv,pv;async function yv(){return sv?sv.getAccessToken():Promise.resolve(Mt.get(yr)||Mt.get(ur)||null)}const mv=(e,t)=>lv(e,t),gv=(e,t)=>cv(e,t),fv=(e,t)=>dv(e,t),wv=(e,t)=>uv(e,t),vv=e=>hv(e),xv=e=>pv(e);let Cv=l=>{let c=l.client,d=l.privy,h=Oh();ql();let[p,y]=r.useState(!1),[m,g]=r.useState(!1),[f,w]=r.useState(!1),[v,x]=r.useState(null),[C,b]=r.useState([]),[j,E]=r.useState([]),[k,T]=r.useState(!1),[A,I]=r.useState(null),[S,P]=r.useState(!1),[_,N]=r.useState({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:s.notImplemented}),[M,W]=r.useState({status:"initial"}),[U,O]=r.useState({status:"initial"}),[F,R]=r.useState({status:"initial"}),[L,D]=r.useState({status:"initial"}),[B,z]=r.useState({status:"initial"}),[$,q]=r.useState({status:"initial"}),[V,H]=r.useState(null),K=_a(),Z=Na(),[Y,G]=r.useState({}),[J,Q]=r.useState(null),X=r.useRef(null),[ee,te]=r.useState(!1),[re,ne]=r.useState(!1),ae=r.useRef(null),ie=r.useRef(null),oe=r.useRef(ni),[se,le]=r.useState(!1);c.onStoreCustomerAccessToken=e=>{e&&si(oe,"accessToken","onAccessTokenGranted",{accessToken:e})},c.onDeleteCustomerAccessToken=()=>{x(null),w(!1),si(oe,"accessToken","onAccessTokenRemoved")};let ce=r.useRef(null),de=r.useRef(null),ue=r.useRef(!1),he=({showWalletUIs:e})=>ue.current?ue.current:void 0!==e?!e:!K.embeddedWallets.showWalletUIs,pe=e=>{I(e),setTimeout((()=>{y(!0)}),15)};r.useEffect((()=>{if(!v)return void c.connectors?.removeEmbeddedWalletConnectors();let e=u.getPrivyEthereumWallet(v),t=u.getPrivyEthereumHDWallets(v),r=u.getImportedPrivyEthereumWallet(v);e&&t.length||c.connectors?.removeEmbeddedWalletConnectors(),r||c.connectors?.removeImportedWalletConnector(),c.connectors?V?(e&&c.connectors.addEmbeddedWalletConnectors({walletProxy:V,user:v,embeddedWallets:t,defaultChain:K.defaultChain,appId:l.appId,privyClient:d}),r&&c.connectors.addImportedWalletConnector(V,r.address,K.defaultChain,l.appId)):console.debug("Failed to add embedded wallet connector: Wallet proxy not initialized"):console.debug("Failed to add embedded wallet connector: Client connectors not initialized")}),[V,v]),r.useEffect((()=>{V&&X.current?.(V)}),[V]);let ye=r.useCallback(((e,t)=>{x(e),T(t),w(!0),ne(!0)}),[]);r.useEffect((()=>{re&&V&&v&&(async()=>{let e=Td(v,K.embeddedWallets.ethereum.createOnLogin),t=Id(v,K.embeddedWallets.solana.createOnLogin),r=await yv();if(r){if(e&&t){let e=await V.create({accessToken:r});return await V.createSolana({accessToken:r,ethereumAddress:e?.address}),void ne(!1)}if(t)return await V.createSolana({accessToken:r,ethereumAddress:u.getPrivyEthereumWallet(v)?.address}),await Me.refreshSessionAndUser(),void ne(!1);if(e)return await V.create({accessToken:r}),void ne(!1)}})().catch(console.error)}),[re&&V&&v]),r.useEffect((()=>{if(K.externalWallets.solana.connectors)return K.externalWallets.solana.connectors.onMount(),()=>K.externalWallets.solana.connectors?.onUnmount()}),[K.externalWallets.solana.connectors]),r.useEffect((()=>{!m&&Z&&async function(){let e,r=me(),n=ge(),a=t.createStore();c.initializeConnectorManager({walletConnectCloudProjectId:K.walletConnectCloudProjectId,rpcConfig:K.rpcConfig,chains:K.chains,defaultChain:K.defaultChain,store:a,walletList:K.appearance.walletList,shouldEnforceDefaultChainOnConnect:K.shouldEnforceDefaultChainOnConnect,externalWalletConfig:K.externalWallets,appName:K.name??"Privy",walletChainType:K.appearance.walletChainType,appKit:K.externalWallets.walletConnect.appKit}),c.connectors?.on("connectorInitialized",(()=>{e&&clearTimeout(e);let t=c.connectors.walletConnectors.length,r=c.connectors.walletConnectors.reduce(((e,t)=>e+(t.initialized?1:0)),0);r===t?le(!0):e=setTimeout((()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:r,expected:t}),le(!0)}),1500)})),c.connectors?.initialize().then((()=>{Ce()}));let i=await c.getAuthenticatedUser(),o=!!i;K.legal.requireUsersAcceptTerms&&i&&!i.hasAcceptedTerms?(await c.logout(),Me.setReadyToTrue(!0),si(oe,"logout","onSuccess")):(K.customAuth?.enabled||(w(!!i),i&&si(oe,"login","onComplete",{user:i,isNewUser:!1,wasAlreadyAuthenticated:!0,loginMethod:null,loginAccount:null}),x(i)),r?de.current=o?"link":"login":n&&!o?(de.current="login",G({telegramAuthModalData:{seamlessAuth:!0}}),pe(Ah)):Me.setReadyToTrue(!!i))}()}),[c,J,m,Z]),r.useEffect((()=>{if(m){if(!v||!v.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType)))return void te(!!V);if([...C].some((e=>"privy"===e.walletClientType)))return void te(!0);te(!!V)}}),[m,v,C,V]),r.useEffect((()=>{c.connectors?.setWalletList(K.appearance.walletList)}),[K.appearance.walletList.join()]);let me=()=>{let e=Qr();return e.inProgress&&e.popupFlow?window.opener.location.origin!==window.location.origin?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Origins between parent and child windows do not match."}):"error"===e.authorizationCode?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Something went wrong. Try again."}):void window.opener.postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}):(e.inProgress&&function(e){return e.startsWith("privy:")}(e.provider)&&!e.popupFlow&&(new BroadcastChannel(Hl).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}),window.close()),!!e.inProgress&&!!e.withPrivyUi&&(c.startAuthFlow(new Rr(e)),pe(Gw),!0))},ge=()=>{let e=function(){let e;return(e=function(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),r=e.get("hash"),n=Number(e.get("auth_date")||""),a=e.get("first_name");if(t&&a&&n&&r)return Object.fromEntries(e.entries())}())?(gn(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=mn(e.replace("#tgWebAppData=","")),{user:r,auth_date:n,hash:a}=t;return r&&n&&a?t:void 0}())?(gn(),{flowType:"web-app",authData:e}):void 0}();if(!e||!K.loginMethods.telegram||!K.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let t=new pn;return c.startAuthFlow(t),"login-url"===e.flowType&&(t.meta.telegramWebAppData=void 0,t.meta.telegramAuthResult=e.authData),"web-app"===e.flowType&&(t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=e.authData),!0},fe=async(e,t,r,n)=>{if("solana_adapter"!==e)we(await(c.connectors?.createEthereumWalletConnector({connectorType:e,walletClientType:t}))||null,t,r,n);else{let e=c.connectors?.findSolanaWalletConnector(t);if(!e)return;we(e,t,r,n)}};async function we(e,t,r,n){if(!e)return N({status:"disconnected",connectedWallet:null,connectError:new o.PrivyConnectorError("Unable to connect to wallet."),connector:null,connectRetry:s.notImplemented}),n?.(null,r);N({status:"disconnected",connectedWallet:null,connectError:null,connector:e,connectRetry:s.notImplemented}),e instanceof Oa&&t&&await e.resetConnection(t),N({connector:e,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>we(e,t,r,n)});try{let t=await e.connect({showPrompt:!0});if((!t||In(t))&&K.shouldEnforceDefaultChainOnConnect&&!K.chains.find((e=>e.id===Number(t?.chainId.replace("eip155:",""))))&&("wallet_connect_v2"!==t?.connectorType||"metamask"!==t?.walletClientType)){N((t=>({...t,connector:e,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:s.notImplemented})));try{await(t?.switchChain(K.defaultChain.id)),t&&(t.chainId=Zt(a.toHex(K.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${K.defaultChain.id}`)}}return N((e=>({...e,status:"connected",connectedWallet:t,connectError:null,connectRetry:s.notImplemented}))),t&&si(oe,"connectWallet","onSuccess",{wallet:t}),n?.(t,r)}catch(e){return e instanceof o.PrivyError?(console.warn(e.cause?e.cause:e.message),si(oe,"connectWallet","onError",e.privyErrorCode||o.PrivyErrorCode.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),si(oe,"connectWallet","onError",o.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR)),N((t=>({...t,status:"disconnected",connectedWallet:null,connectError:e}))),n?.(null,r)}}let ve=async(e,t,r)=>{if(null===e||!In(e))return;let n=new rn(c,e,t,r);c.startAuthFlow(n)},xe=async(e,t,r,n="plain")=>{let a=h(Fh);if("transaction"===n&&!a)throw new o.PrivyClientError("useSolanaLedger plugin hook must be mounted");if(null===e||!oa(e))return;let i=new on(e,c,t,r,n,a?{deserializeTransactionFromB64String:a.deserializeTransactionFromB64String,prepareSiwsTransactionWithMemo:a.prepareSiwsTransactionWithMemo}:void 0);c.startAuthFlow(i)},Ce=()=>{let e=new URLSearchParams(window.location.search),t=e.get("privy_connector"),r=e.get("privy_wallet_client"),n="true"===e.get("privy_connect_only");if(!t||!r)return;let a=ta({connectorType:t,walletClientType:r});if(!a||!a.isInstalled)return pe(_w);if(!c.connectors)throw new o.PrivyClientError("Connector not initialized");pe(n?Jh:Kh);let i=new URL(window.location.href);i.searchParams.delete("privy_connector"),i.searchParams.delete("privy_wallet_client"),i.searchParams.delete("privy_connect_only"),window.history.pushState({},"",i),fe(t,r,void 0,n?void 0:"solana_adapter"===t?xe:ve)};r.useEffect((()=>{m&&f&&null===v&&c.getAuthenticatedUser().then(x)}),[m,f,v,c]);let be=e=>{if(!f)throw si(oe,"linkAccount","onError",o.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:e}),new o.PrivyClientError("User must be authenticated before linking an account.")},je=e=>{if(!f||!v)return!1;if("privy"===e.walletClientType)return!0;for(let t of v.linkedAccounts)if("wallet"===t.type&&t.address===e.address&&"privy"!==t.walletClientType)return!0;return!1},Ee=async e=>{let t;if(!c.connectors)throw new o.PrivyClientError("Connector not initialized");t="ethereum"===e.type?c.connectors.findWalletConnector(e.connectorType,e.walletClientType)||null:c.connectors.findSolanaWalletConnector(e.walletClientType)||null,N((r=>({...r,connector:t,status:"connected",connectedWallet:e,connectError:null,connectRetry:s.notImplemented}))),K.captchaEnabled&&!f?(G({captchaModalData:{callback:t=>In(e)?ve(e,t):xe(e,t),userIntentRequired:!1,onSuccessNavigateTo:Kh,onErrorNavigateTo:Yd}}),pe(Mu)):(In(e)?await ve(e):await xe(e),pe(Kh))},ke=()=>{b((e=>{let t=c.connectors?.wallets.filter(In).map((e=>({...e,linked:je(e),loginOrLink:async()=>{if(!await e.isConnected())throw new o.PrivyClientError("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new o.PrivyClientError("Cannot link or login with embedded wallet");Ee(e)},fund:async t=>{await Me.fundWallet(e.address,t)},unlink:async()=>{if(!f)throw new o.PrivyClientError("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new o.PrivyClientError("Cannot unlink an embedded wallet");x(await c.unlinkEthereumWallet(e.address))}})))||[];return Sn(e,t)?e:t})),E((e=>{let t=(c.connectors?.wallets??[]).filter(oa).map((e=>({...e,linked:je(e),loginOrLink:async()=>{if(!await e.isConnected())throw new o.PrivyClientError("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new o.PrivyClientError("Cannot link or login with embedded wallet");Ee(e)},fund:async()=>{throw new o.PrivyClientError("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:async()=>{if(!f)throw new o.PrivyClientError("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new o.PrivyClientError("Cannot unlink an embedded wallet");x(await c.unlinkSolanaWallet(e.address))}})));return Sn(e,t)?e:t}))};r.useEffect((()=>{ke()}),[v?.linkedAccounts,f,m]),r.useEffect((()=>{if(m){if(!c.connectors)throw new o.PrivyClientError("Connector not initialized");ke(),c.connectors.on("walletsUpdated",ke)}}),[m]),r.useEffect((()=>{[...K.loginMethodsAndOrder?.primary??[],...K.loginMethodsAndOrder?.overflow??[]].filter((e=>e.startsWith("privy:"))).forEach((e=>c.getCrossAppProviderDetails(e.replace("privy:",""))))}),[!!c]);let Te=({transaction:e,uiOptions:t,fundWalletConfig:r,address:n,signOnly:s})=>new Promise((async(h,p)=>{let{requesterAppId:y}=t||{},m=s?"signTransaction":"sendTransaction",g=n?u.getPrivyWalletWithAddress(v,n):u.getPrivyEthereumWallet(v);if(!g&&n){let t=u.getConnectedWalletWithAddress(C,n);if(t)try{let r=await t.getEthereumProvider(),i={...e,from:n,chainId:e.chainId||Number(t.chainId.replace("eip155:","")),value:void 0!==e.value?a.toHex(e.value):void 0},o=await r.request({method:"sendTransaction"===m?"eth_sendTransaction":"eth_signTransaction",params:[i]});return si(oe,m,"onSuccess",{hash:o}),void h({hash:o})}catch(e){return si(oe,m,"onError",o.PrivyErrorCode.TRANSACTION_FAILURE),void p(e??new Tn("Unable to "+m+e))}}if(!g)return si(oe,m,"onError",o.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void p(new o.PrivyClientError("No embedded or connected wallet found for address."));if(!f||!v)return si(oe,m,"onError",o.PrivyErrorCode.MUST_BE_AUTHENTICATED),void p(Error("User must be authenticated before signing with a Privy wallet"));let w=g.address,x=g.walletIndex??0,{entropyId:b,entropyIdVerifier:j}=xn(v,g),E=We.wallets.find((e=>"privy"===e.walletClientType&&a.getAddress(e.address)===a.getAddress(w)));if(!E)return si(oe,m,"onError",o.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void p(Error("Must have a Privy wallet before signing"));let k=await E.getEthereumProvider(),T=await k.request({method:"eth_chainId"}),A=e.chainId?Number(e.chainId):Vl(T);(e=>{if(!K.chains.map((e=>e.id)).includes(e))throw new o.PrivyConnectorError(`Chain ID ${e} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,o.PrivyErrorCode.UNSUPPORTED_CHAIN_ID)})(A);let I={...e,from:e.from??w,chainId:A},S=await yv();if(!S||!V)return si(oe,m,"onError",o.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void p(Error("Must have valid access token and Privy wallet to send transaction"));let P=Ft(I.chainId,K.chains,K.rpcConfig,{appId:l.appId}),_=u.getIsUnifiedWallet(g),N=async()=>{try{let e;if(!await Me.recoverEmbeddedWallet({address:w}))throw si(oe,m,"onError",o.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),p(Error("Unable to connect to wallet")),Error("Unable to connect to wallet");let t=s?I:await Ms(I,P,I.from);if(_){let r=e=>null==e?void 0:a.toHex(e),n=await i.rpc(d,(async({message:e})=>await V.signWithUserSigner({accessToken:S,requesterAppId:y,message:e})),{chain_type:"ethereum",method:"eth_signTransaction",params:{transaction:{from:t.from,to:t.to,nonce:r(t.nonce),chain_id:r(t.chainId),data:a.isHex(t.data)?t.data?t.data:a.toHex(Uint8Array.from(t.data)):void 0,value:r(t.value),type:t.type,gas_limit:r(t.gasLimit??t.gas),gas_price:r(t.gasPrice??t.gas),max_fee_per_gas:r(t.maxFeePerGas),max_priority_fee_per_gas:r(t.maxPriorityFeePerGas)}},wallet_id:g.id});if(!n.data||!("signed_transaction"in n.data))throw new Tn("Unable to sign transaction");e=n.data.signed_transaction}else e=await $l({accessToken:S,entropyId:b,entropyIdVerifier:j,transactingWalletIndex:x,walletProxy:V,transactionRequest:t,requesterAppId:y});if(s)return si(oe,"signTransaction","onSuccess",{signature:e}),e;{let t=await P.sendRawTransaction({serializedTransaction:e});return si(oe,"sendTransaction","onSuccess",{hash:t}),t}}catch(e){throw si(oe,m,"onError",o.PrivyErrorCode.TRANSACTION_FAILURE),e}};if(he({showWalletUIs:t?.showWalletUIs}))N().then((e=>{s?si(oe,"signTransaction","onSuccess",{signature:e}):si(oe,"sendTransaction","onSuccess",{hash:e}),h({hash:e})})).catch((e=>{si(oe,m,"onError",o.PrivyErrorCode.TRANSACTION_FAILURE),p(e)}));else{let e={connectingWalletAddress:w,recoveryMethod:g.recoveryMethod,entropyId:b,entropyIdVerifier:j,onCompleteNavigateTo:ow,isUnifiedWallet:_,onFailure:e=>{si(oe,m,"onError",o.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),p(e)}},n=Oy(K)?Eg({address:w,appConfig:K,fundWalletConfig:r,methodScreen:wg,chainIdOverride:I.chainId,comingFromSendTransactionScreen:!0}):void 0;G({connectWallet:e,sendTransaction:{transactionRequest:I,transactingWalletIndex:x,transactingWalletAddress:w,entropyId:b,entropyIdVerifier:j,signOnly:s,scanTransaction:async()=>{let e=await Ms(I,P,I.from);return await c.scanTransaction({metadata:{domain:K.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:e.from,to:e.to,value:e.value?.toString(),gas:e.gas?.toString(),gasPrice:e.gasPrice?.toString(),nonce:e.nonce?.toString(),data:e.data}]}})},onConfirm:()=>N(),onSuccess:e=>{s?si(oe,"signTransaction","onSuccess",{signature:e.hash}):si(oe,"sendTransaction","onSuccess",{hash:e.hash}),h(e)},onFailure:e=>{si(oe,m,"onError",o.PrivyErrorCode.TRANSACTION_FAILURE),p(e)},uiOptions:t||{},fundWalletConfig:r,requesterAppId:y},funding:n}),pe(Mg)}}));function Ae(){return new Promise((async(e,t)=>{let r=await yv();if(!r||!V)throw Error("Must have valid access token to enroll in MFA");try{await V.verifyMfa({accessToken:r}),e()}catch(e){t(e)}}))}let Ie=e=>e?.linkedAccounts.filter((e=>null!==e.latestVerifiedAt&&!("wallet"===e.type&&"privy"===e.walletClientType))).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0],Se=e=>{let t=v?.linkedAccounts.filter((t=>t.type===e)).length??0,{displayName:r,loginMethod:n}=yd(e);if("passkey"===e&&t>=5||"passkey"!==e&&t>=1)throw si(oe,"linkAccount","onError",o.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE,{linkMethod:n}),new o.PrivyClientError(`User already has an account of type ${r} linked.`)};async function Pe({showAutomaticRecovery:e=!1,legacySetWalletPasswordFlow:t=!1}){I(null);let r=t?"setWalletPassword":"setWalletRecovery";if(!f||!v)throw si(oe,r,"onError",o.PrivyErrorCode.MUST_BE_AUTHENTICATED),Error("User must be authenticated before adding recovery method to Privy wallet");let n=u.getPrivyPrimaryWallet(v);if(!n||!V)throw si(oe,r,"onError",o.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),Error("Must have a Privy wallet to add a recovery method");let a=u.getIsUnifiedWallet(n);if(a)throw si(oe,r,"onError",o.PrivyErrorCode.UNSUPPORTED_WALLET_TYPE),new o.PrivyClientError("User owned wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");try{await Ae()}catch(e){throw si(oe,r,"onError",o.PrivyErrorCode.MISSING_MFA_CREDENTIALS),e}return new Promise(((i,s)=>{let l="user-passcode"===n.recoveryMethod,c=uy({walletAction:"update",availableRecoveryMethods:K.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:t,isResettingPassword:l,showAutomaticRecovery:e}),{entropyId:d,entropyIdVerifier:u}=xn(v),h={recoveryMethod:n.recoveryMethod,connectingWalletAddress:n.address,onCompleteNavigateTo:c,shouldForceMFA:!1,entropyId:d,isUnifiedWallet:a,entropyIdVerifier:u,onFailure:e=>{si(oe,r,"onError",o.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),s(e)}};G({setWalletPassword:{onSuccess:e=>{si(oe,r,"onSuccess",{method:"user-passcode",wallet:e}),i(e)},onFailure:e=>{si(oe,r,"onError",o.PrivyErrorCode.USER_EXITED_SET_PASSWORD_FLOW),s(e)},callAuthOnSuccessOnClose:!1},recoverWallet:{entropyId:d,entropyIdVerifier:u,onFailure:s},connectWallet:h,recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:l,shouldCreateEth:!1,shouldCreateSol:!1}}),pe(Mg)}))}async function _e({appId:e,action:t}){let r=await yv();if("link"===t&&!r)throw si(oe,"linkAccount","onError",o.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:`privy:${e}`}),new o.PrivyClientError("User must be authenticated before linking an account.");if("login"===t&&r)throw si(oe,"login","onError",o.PrivyErrorCode.UNKNOWN_AUTH_ERROR),new o.PrivyClientError("Attempted to log in, but user is already logged in. Use a `link` helper instead.");ce.current=`privy:${e}`,de.current=t;let n=Gl();return c.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:e}}),new Promise((async(r,a)=>{let{name:i,logoUrl:o}=await Yl({api:c.api,providerAppId:e,requesterAppId:K.id});G({crossAppAuth:{appId:e,name:i,logoUrl:o,action:t,popup:n,onSuccess:r,onError:a}}),pe(yw)}))}let Ne={ready:m,authenticated:f,user:v,walletConnectors:c.connectors||null,connectWallet:e=>{e&&"target"in e&&e&&(e=void 0),G({externalConnectWallet:{walletList:e?.walletList&&e?.walletList.length>0?e.walletList:void 0,suggestedAddress:e?.suggestedAddress,walletChainType:e?.walletChainType}}),pe(f?uw:hw)},linkWallet:e=>{e&&"target"in e&&e&&(e=void 0),be("siwe"),ce.current="siwe",de.current="link",G({...Y,externalConnectWallet:{...Y.externalConnectWallet,suggestedAddress:e?.suggestedAddress,walletList:e?.walletList,walletChainType:e?.walletChainType}}),pe(Sw)},startCrossAppAuthFlow:_e,linkEmail:()=>{be("email"),Se("email"),ce.current="email",de.current="link",pe(Aw)},linkPhone:()=>{be("sms"),Se("phone"),ce.current="sms",de.current="link",pe(Iw)},linkGoogle:async()=>{be("google"),Se("google_oauth"),de.current="link",await Me.initLoginWithOAuth("google")},linkTwitter:async()=>{be("twitter"),Se("twitter_oauth"),de.current="link",await Me.initLoginWithOAuth("twitter")},linkDiscord:async()=>{be("discord"),Se("discord_oauth"),de.current="link",await Me.initLoginWithOAuth("discord")},linkGithub:async()=>{be("github"),Se("github_oauth"),de.current="link",await Me.initLoginWithOAuth("github")},linkSpotify:async()=>{be("spotify"),Se("spotify_oauth"),de.current="link",await Me.initLoginWithOAuth("spotify")},linkInstagram:async()=>{be("instagram"),Se("instagram_oauth"),de.current="link",await Me.initLoginWithOAuth("instagram")},linkTiktok:async()=>{be("tiktok"),Se("tiktok_oauth"),de.current="link",await Me.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{be("linkedin"),Se("linkedin_oauth"),de.current="link",await Me.initLoginWithOAuth("linkedin")},linkApple:async()=>{be("apple"),Se("apple_oauth"),de.current="link",await Me.initLoginWithOAuth("apple")},linkPasskey:async()=>{be("passkey"),Se("passkey"),await Me.initLinkWithPasskey(),pe(Em)},linkTelegram:async e=>{if(be("telegram"),Se("telegram"),de.current="link",ce.current="telegram",e?.launchParams)if(e.launchParams.initDataRaw){let t=new pn;c.startAuthFlow(t),t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=mn(e.launchParams.initDataRaw),G({telegramAuthModalData:{seamlessAuth:!0}}),pe(Ah)}else si(oe,"linkAccount","onError",o.PrivyErrorCode.INVALID_DATA,{linkMethod:"telegram"});else await Me.initLoginWithTelegram();pe(Ah)},linkFarcaster:async()=>{be("farcaster"),Se("farcaster"),await Me.initLoginWithFarcaster(),de.current="link",ce.current="farcaster",pe(ih)},updateEmail:()=>{if(be("email"),!v?.email)throw new o.PrivyClientError("User does not have an email linked to their account.");de.current="update",ce.current="email",pe(tv)},updatePhone:()=>{if(be("sms"),!v?.phone)throw new o.PrivyClientError("User does not have a phone number linked to their account.");de.current="update",ce.current="sms",pe(rv)},login:async e=>{e&&"target"in e&&e&&(e=void 0);let t="Attempted to log in, but user is already logged in. Use a `link` helper instead.";if(!m){let e=await new Promise((e=>{Q((t=>e.bind(t)))}));if(Q(null),e)return void console.warn(t)}!v||v.isGuest?(de.current="login",G({login:e}),pe(Jp)):console.warn(t)},connectOrCreateWallet:async()=>{m||(await new Promise((e=>{Q((()=>e))})),Q(null)),f?console.warn("User must be unauthenticated to `connectOrCreateWallet`"):(de.current="connect-or-create",pe(kp))},logout:async()=>{if(de.current=null,ce.current=null,v&&c.clearProviderAcccessTokens(v),I(null),await c.logout(),v&&V)try{await V.clearMfa({userId:v.id})}catch(e){}x(null),w(!1),si(oe,"logout","onSuccess"),y(!1),Mt.del(wr),Mt.del(vr(K.id))},getAccessToken:r.useCallback((()=>c.getCustomerAccessToken()),[c]),unlinkWallet:async e=>{let t;return x(t=e.startsWith("0x")?await c.unlinkEthereumWallet(e):await c.unlinkSolanaWallet(e)),t},unlinkEmail:async e=>{let t=await c.unlinkEmail(e);return x(t),t},unlinkPhone:async e=>{let t=await c.unlinkPhone(e);return x(t),t},unlinkGoogle:async e=>{let t=await c.unlinkOAuth("google",e);return x(t),t},unlinkTwitter:async e=>{let t=await c.unlinkOAuth("twitter",e);return x(t),t},unlinkDiscord:async e=>{let t=await c.unlinkOAuth("discord",e);return x(t),t},unlinkGithub:async e=>{let t=await c.unlinkOAuth("github",e);return x(t),t},unlinkSpotify:async e=>{let t=await c.unlinkOAuth("spotify",e);return x(t),t},unlinkInstagram:async e=>{let t=await c.unlinkOAuth("instagram",e);return x(t),t},unlinkTiktok:async e=>{let t=await c.unlinkOAuth("tiktok",e);return x(t),t},unlinkLinkedIn:async e=>{let t=await c.unlinkOAuth("linkedin",e);return x(t),t},unlinkApple:async e=>{let t=await c.unlinkOAuth("apple",e);return x(t),t},unlinkFarcaster:async e=>{let t=await c.unlinkFarcaster(e);return x(t),t},unlinkTelegram:async e=>{let t=await c.unlinkTelegram(e);return x(t),t},unlinkPasskey:async e=>{let t=await yv();if(!t)throw Error("Must have valid access token to enroll in MFA");if(!V)throw Error("Wallet proxy not initialized.");let r=K.passkeys.shouldUnenrollMfaOnUnlink;await V.unlinkPasskeyAccount({credentialId:e,accessToken:t,removeAsMfa:r});let n=await c.getAuthenticatedUser();return x(n),n},unlinkCrossAppAccount:async({subject:e})=>{let t=v?.linkedAccounts.find((t=>"cross_app"===t.type&&t.subject===e))?.providerApp;if(!t)throw new o.PrivyClientError("Invalid subject");c.storeProviderAccessToken(t.id,null);let r=await c.unlinkOAuth(`privy:${t.id}`,e);return x(r),r},setWalletRecovery:async e=>Pe({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:e?.showAutomaticRecovery??!1}),setWalletPassword:async()=>Pe({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(e,t)=>new Promise((async(r,n)=>{let{requesterAppId:s}=t?.uiOptions||{},l=e.message,h=t?.address?u.getPrivyWalletWithAddress(v,t.address):u.getPrivyEthereumWallet(v);if(!h&&void 0!==t?.address){let e=u.getConnectedWalletWithAddress(C,t.address);if(e)try{let t=await e.getEthereumProvider(),n=await t.request({method:"personal_sign",params:[l,e.address]});return si(oe,"signMessage","onSuccess",{signature:n}),void r({signature:n})}catch(e){return si(oe,"signMessage","onError",o.PrivyErrorCode.UNABLE_TO_SIGN),void n(e??new Tn("Unable to sign message"))}}if(!h)throw new o.PrivyClientError("No embedded or connected wallet found for address.");if(!f||!v)return si(oe,"signMessage","onError",o.PrivyErrorCode.MUST_BE_AUTHENTICATED),void n(Error("User must be authenticated before signing with a Privy wallet"));let p=h.address,y=h.walletIndex??0,{entropyId:m,entropyIdVerifier:g}=xn(v,h),w=u.getIsUnifiedWallet(h);if("string"!=typeof l||l.length<1)return si(oe,"signMessage","onError",o.PrivyErrorCode.INVALID_MESSAGE),void n(Error("Message must be a non-empty string"));let x=async()=>{let t;if(!f)throw Error("User must be authenticated before signing with a Privy wallet");let r=await yv();if(!V||!r||!await Me.recoverEmbeddedWallet({address:p}))throw Error("Unable to connect to wallet");if(c.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:p,requesterAppId:s}}),w){let n=a.isHex(e.message,{strict:!0}),o=await i.rpc(d,(async({message:e})=>await V.signWithUserSigner({accessToken:r,requesterAppId:s,message:e})),{chain_type:"ethereum",method:"personal_sign",params:n?{message:l.slice(2),encoding:"hex"}:{message:l,encoding:"utf-8"},wallet_id:h.id});if(!o.data||!("signature"in o.data))throw new Tn("Unable to sign message");t=o.data.signature}else{let{response:e}=await V.rpc({accessToken:r,entropyId:m,entropyIdVerifier:g,chainType:"ethereum",hdWalletIndex:y,requesterAppId:s,request:{method:"personal_sign",params:[l,p]}});t=e.data}return c.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:p,requesterAppId:s}}),t};if(he({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await x();si(oe,"signMessage","onSuccess",{signature:e}),r({signature:e})}catch(e){si(oe,"signMessage","onError",o.PrivyErrorCode.UNABLE_TO_SIGN),n(e??new Tn("Unable to sign message"))}else G({signMessage:{method:"personal_sign",data:l,confirmAndSign:x,onSuccess:e=>{si(oe,"signMessage","onSuccess",{signature:e}),r({signature:e})},onFailure:e=>{si(oe,"signMessage","onError",o.PrivyErrorCode.UNABLE_TO_SIGN),n(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:h.recoveryMethod,connectingWalletAddress:p,entropyId:m,entropyIdVerifier:g,onCompleteNavigateTo:Sf,isUnifiedWallet:w,onFailure:e=>{si(oe,"signMessage","onError",o.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),n(e)}}}),pe(Mg)})),signTypedData:(e,t)=>new Promise((async(r,n)=>{let{requesterAppId:a}=t?.uiOptions||{},s=t?.address?u.getPrivyWalletWithAddress(v,t.address):u.getPrivyEthereumWallet(v);if(!s&&t?.address){let a=u.getConnectedWalletWithAddress(C,t.address);if(a)try{let t=await a.getEthereumProvider(),n=Gt(e),i=await t.request({method:"eth_signTypedData_v4",params:[a.address,n]});return si(oe,"signTypedData","onSuccess",{signature:i}),void r({signature:i})}catch(e){return si(oe,"signTypedData","onError",o.PrivyErrorCode.UNABLE_TO_SIGN),void n(e??new Tn("Unable to sign typed data "+e))}}if(!s)throw new o.PrivyClientError("No embedded or connected wallet found for address.");if(!f||!v)return si(oe,"signTypedData","onError",o.PrivyErrorCode.MUST_BE_AUTHENTICATED),void n(Error("User must be authenticated before signing with a Privy wallet"));let l=s.address,h=s.walletIndex??0,{entropyId:p,entropyIdVerifier:y}=xn(v,s),m=u.getIsUnifiedWallet(s),g=Gt(e),w=async()=>{let e;if(!f)throw Error("User must be authenticated before signing with a Privy wallet");let t=await yv();if(!V||!t||!await Me.recoverEmbeddedWallet({address:l}))throw Error("Unable to connect to wallet");if(c.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:l,requesterAppId:a}}),m){let{domain:r,types:n,primaryType:o,message:l}=g,c=await i.rpc(d,(async({message:e})=>await V.signWithUserSigner({accessToken:t,requesterAppId:a,message:e})),{chain_type:"ethereum",method:"eth_signTypedData_v4",params:{typed_data:{domain:r,types:n,primary_type:o,message:l}},wallet_id:s.id});if(!c.data||!("signature"in c.data))throw new Tn("Unable to sign message");e=c.data.signature}else{let{response:r}=await V.rpc({accessToken:t,entropyId:p,entropyIdVerifier:y,chainType:"ethereum",hdWalletIndex:h,requesterAppId:a,request:{method:"eth_signTypedData_v4",params:[l,g]}});e=r.data}return c.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:l,requesterAppId:a}}),e};if(he({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await w();si(oe,"signTypedData","onSuccess",{signature:e}),r({signature:e})}catch(e){si(oe,"signTypedData","onError",o.PrivyErrorCode.UNABLE_TO_SIGN),n(e??new Tn("Unable to sign message"))}else G({signMessage:{method:"eth_signTypedData_v4",data:g,confirmAndSign:w,onSuccess:e=>{si(oe,"signTypedData","onSuccess",{signature:e}),r({signature:e})},onFailure:e=>{si(oe,"signTypedData","onError",o.PrivyErrorCode.UNABLE_TO_SIGN),n(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:s.recoveryMethod,connectingWalletAddress:s.address,entropyId:p,isUnifiedWallet:m,entropyIdVerifier:y,onCompleteNavigateTo:Sf,onFailure:e=>{si(oe,"signMessage","onError",o.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),n(e)}}}),pe(Mg)})),sendTransaction:async(e,t)=>await Te({transaction:e,uiOptions:t?.uiOptions,fundWalletConfig:t?.fundWalletConfig,address:t?.address,signOnly:!1}),signTransaction:async(e,t)=>({signature:(await Te({transaction:e,uiOptions:t?.uiOptions,address:t?.address,signOnly:!0})).hash}),exportWallet:e=>new Promise((async(t,r)=>{if(!f||!v)return void r(Error("User must be authenticated before exporting their Privy wallet"));e&&"target"in e&&e&&(e=void 0);let n=e?.address?u.getPrivyWalletWithAddress(v,e.address):u.getPrivyEthereumWallet(v),i=u.getPrivyPrimaryWallet(v);if(!n||!i)return void r(new o.PrivyClientError("User must have an embedded wallet."));let s=n.address,{entropyId:d,entropyIdVerifier:h}=xn(v,n),p=u.getIsUnifiedWallet(n);if(!s)return void r(Error("User does not have an HD Ethereum wallet. To export an imported wallet, pass the `address` of the wallet to `exportWallet`."));if(!a.isAddress(s))return void r(Error("Must provide a valid Ethereum address."));let y={recoveryMethod:n.recoveryMethod,connectingWalletAddress:n.address,isUnifiedWallet:p,entropyId:d,entropyIdVerifier:h,onCompleteNavigateTo:Sg,onFailure:r,shouldForceMFA:!0};G(Y),await yv()&&V?V?Ll(n)?(G({keyExport:{appId:l.appId,appClientId:l.clientId,origin:c.apiUrl,address:n.address,entropyId:d,entropyIdVerifier:h,hdWalletIndex:n.walletIndex,chainType:n.chainType,walletId:n.id,isUnifiedWallet:p,imported:n.imported,onSuccess:t,onFailure:r},connectWallet:y}),pe(Mg)):r(Error(`Export is not supported for ${n.chainType} wallets`)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),promptMfa:Ae,async init(e){switch(e){case"sms":return void await c.initMfaSmsVerification();case"passkey":return await c.initMfaPasskeyVerification();case"totp":return;default:throw Error(`Unsupported MFA method: ${e}`)}},async submit(e,t){switch(e){case"totp":case"sms":if("string"!=typeof t)throw new o.PrivyClientError("Invalid MFA code");ae.current?.resolve({mfaMethod:e,mfaCode:t,relyingParty:window.origin}),await new Promise(((e,t)=>{ie.current={resolve:e,reject:t}}));break;case"passkey":if("string"==typeof t)throw new o.PrivyClientError("Invalid authenticator response");let r=await import("@simplewebauthn/browser"),n=(e=>({id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}))(await r.startAuthentication(t));ae.current?.resolve({mfaMethod:e,mfaCode:n,relyingParty:window.origin}),await new Promise(((e,t)=>{ie.current={resolve:e,reject:t}}));break;default:throw ae.current?.reject(new o.PrivyClientError("Unsupported MFA method")),new o.PrivyClientError(`Unsupported MFA method: ${e}`)}},cancel(){ae.current?.reject(new o.PrivyClientError("MFA canceled"))},async initEnrollmentWithSms(e){let t=await yv();if(!t||!V)throw Error("Must have valid access token to enroll in MFA");await V.initEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber})},enrollInMfa:e=>new Promise(((t,r)=>{if(!e)return Me.closePrivyModal(),void t();K.mfa.noPromptOnMfaRequired&&console.warn("[Privy Warning] Triggering the 'showMfaEnrollmentModal' function when 'noPromptOnMfaRequired' is set to true is unexpected. If this is intentional, ensure that you are building custom UIs for MFA verification."),G({mfaEnrollmentFlow:{mfaMethods:K.mfa.methods,shouldUnlinkOnUnenrollMfa:K.passkeys.shouldUnlinkOnUnenrollMfa,onSuccess:t,onFailure:r}}),pe(Yw)})),async initEnrollmentWithTotp(){let e=await yv();if(!e||!V)throw Error("Must have valid access token to enroll in MFA");let t=await V.initEnrollMfa({method:"totp",accessToken:e});return{secret:t.secret,authUrl:t.authUrl}},async submitEnrollmentWithSms(e){let t=await yv();if(!t||!V)throw Error("Must have valid access token to enroll in MFA");await V.submitEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber,code:e.mfaCode}),x(await c.getAuthenticatedUser())},async submitEnrollmentWithTotp(e){let t=await yv();if(!t||!V)throw Error("Must have valid access token to enroll in MFA");await V.submitEnrollMfa({method:"totp",accessToken:t,code:e.mfaCode}),x(await c.getAuthenticatedUser())},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:e},t={}){let r=await yv();if(!r||!V)throw Error("Must have valid access token to enroll in MFA");await V.submitEnrollMfa({method:"passkey",accessToken:r,credentialIds:e,removeForLogin:t.removeForLogin}),x(await c.getAuthenticatedUser())},async unenroll(e,t={}){let r=await yv();if(!r||!V)throw Error("Must have valid access token to remove MFA");"passkey"===e?await V.submitEnrollMfa({method:"passkey",accessToken:r,credentialIds:[],removeForLogin:t.removeForLogin}):await V.unenrollMfa({method:e,accessToken:r}),x(await c.getAuthenticatedUser())},requestFarcasterSignerFromWarpcast:async()=>{let e=await yv(),t=v?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!e)throw Error("Must have valid access token to connect with Farcaster");if(!V||!t)throw Error("Must have an embedded wallet to use Farcaster signers");if(u.getIsUnifiedWallet(t))throw new o.PrivyClientError("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!v?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Me.recoverEmbeddedWallet({address:t.address}))throw Error("Unable to connect to wallet");let r=await V.initFarcasterSigner({address:t.address,hdWalletIndex:null,accessToken:e,mfaCode:null,mfaMethod:null,relyingParty:window.origin});"approved"===r.status&&x(await c.getAuthenticatedUser()||v||null),G({farcasterSigner:r}),pe(bw)},getFarcasterSignerPublicKey:async()=>{let e,t=await yv(),r=v?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!V||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(u.getIsUnifiedWallet(r))throw new o.PrivyClientError("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!v?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Me.recoverEmbeddedWallet({address:r.address}))throw Error("Unable to connect to wallet");if(!v.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");return e=v.farcaster.signerPublicKey.slice(2),Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))},signFarcasterMessage:async e=>{let t=await yv(),r=v?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!V||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(u.getIsUnifiedWallet(r))throw new o.PrivyClientError("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!v?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Me.recoverEmbeddedWallet({address:r.address}))throw Error("Unable to connect to wallet");if(!v.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");let n=await import("@simplewebauthn/browser"),a=await V.signFarcasterMessage({address:r.address,hdWalletIndex:null,accessToken:t,mfaCode:null,mfaMethod:null,payload:{hash:n.bufferToBase64URLString(e)},fid:BigInt(v.farcaster.fid),relyingParty:window.origin});return new Uint8Array(n.base64URLStringToBuffer(a.signature))},signMessageWithCrossAppWallet(e,{address:t,chainId:r}){let n=v?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Ql({user:v,client:c,address:t,requesterAppId:K.id,request:{method:n?"privy_signSmartWalletMessage":"personal_sign",params:[e,t],chainId:r},reconnect:_e})},signTypedDataWithCrossAppWallet(e,{address:t,chainId:r}){let n=v?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t)))),a=Gt(e);return Ql({user:v,client:c,address:t,requesterAppId:K.id,request:{method:n?"privy_signSmartWalletTypedData":"eth_signTypedData_v4",params:[t,a],chainId:r},reconnect:_e})},sendTransactionWithCrossAppWallet(e,{address:t}){let r=v?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Ql({user:v,client:c,address:t,requesterAppId:K.id,request:{method:r?"privy_sendSmartWalletTx":"eth_sendTransaction",params:[e],chainId:e.chainId},reconnect:_e})},isModalOpen:p,mfaMethods:K.mfa.methods};lv=Ne.signMessage,cv=Ne.signTypedData,uv=async(e,t)=>await Te({transaction:e,...t,signOnly:!1}),dv=async(e,t)=>({signature:(await Te({transaction:e,...t,signOnly:!0})).hash});let Me={privy:d,setAuthenticated:w,setUser:x,setIsNewUser:T,isNewUserThisSession:k,pendingTransaction:null,walletConnectionStatus:_,connectors:c.connectors?.walletConnectors??[],solanaWallets:j,rpcConfig:K.rpcConfig,chains:K.chains,appId:l.appId,showFiatPrices:"native-token"!==K.embeddedWallets.priceDisplay.primary,clientAnalyticsId:c.clientAnalyticsId,onCustomAuthAuthenticated:ye,hideWalletUIs:ue,isHeadlessSigning:r.useCallback(he,[K.embeddedWallets.showWalletUIs]),emailOtpState:U,setEmailOtpState:O,smsOtpState:F,setSmsOtpState:R,oAuthState:B,setOAuthState:z,telegramAuthState:$,setTelegramAuthState:q,siweState:L,setSiweState:D,isHeadlessOAuthLoading:S,nativeTokenSymbolForChainId:e=>K.chains.find((t=>t.id===Number(e)))?.nativeCurrency.symbol,initializeWalletProxy:async e=>{if(V)return V;let t=new Promise((e=>{X.current=e})),r=new Promise((t=>setTimeout((()=>t(null)),e))),n=await Promise.race([t,r]);return X.current=null,n},getAuthFlow:()=>c.authFlow,getAuthMeta:()=>c.authFlow?.meta,client:c,closePrivyModal:async(e={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let t,r=m&&f&&v;r&&ce.current&&(t=Ie(v)),"login"===de.current?e.shouldCallAuthOnSuccess&&r&&ce.current?si(oe,"login","onComplete",{user:v,isNewUser:k,wasAlreadyAuthenticated:!1,loginMethod:ce.current,loginAccount:t??null}):si(oe,"login","onError",o.PrivyErrorCode.USER_EXITED_AUTH_FLOW):"link"===de.current&&t?e.isSuccess&&r&&ce.current?si(oe,"linkAccount","onSuccess",{user:v,linkMethod:ce.current,linkedAccount:t}):ce.current&&si(oe,"linkAccount","onError",o.PrivyErrorCode.USER_EXITED_LINK_FLOW,{linkMethod:ce.current}):"update"===de.current&&t?e.isSuccess&&r&&ce.current?si(oe,"update","onSuccess",{user:v,updateMethod:ce.current,updatedAccount:t}):ce.current&&si(oe,"update","onError",o.PrivyErrorCode.USER_EXITED_UPDATE_FLOW,{linkMethod:ce.current}):"connect-or-create"===de.current&&(C[0]?si(oe,"connectOrCreateWallet","onSuccess",{wallet:C[0]}):si(oe,"connectOrCreateWallet","onError",o.PrivyErrorCode.USER_EXITED_AUTH_FLOW));let n=A&&cw.has(A),a=A===Yd&&Y.errorModalData&&cw.has(Y.errorModalData.previousScreen);if((n||a)&&Y.funding){let e,t=cw.get(A)??null;if("solana"===Y.funding.chainType){let r=h(Ey);if(r)try{e=BigInt(await r.getBalance({address:Y.funding.address,cluster:Y.funding.cluster}))}catch{console.error("Unable to pull wallet balance")}else console.warn("Unable to load solana plugin, skipping balance");si(oe,"fundSolanaWallet","onUserExited",{address:Y.funding.address,cluster:Y.funding.cluster,fundingMethod:t,balance:e})}else{let r=Ft(Y.funding.chain.id,K.chains,K.rpcConfig,{appId:l.appId});try{e=await r.getBalance({address:Y.funding.address})}catch{console.error("Unable to pull wallet balance")}si(oe,"fundWallet","onUserExited",{address:Y.funding.address,chain:Y.funding.chain,fundingMethod:t,balance:e})}}G({...Y,externalConnectWallet:{suggestedAddress:void 0}}),de.current=null,ce.current=null,T(!1),y(!1),setTimeout((()=>{c.authFlow=void 0}),200)},openPrivyModal:pe,connectWallet:we,initLoginWithWallet:async(e,t,r,n)=>{In(e)?(ce.current="siwe",ve(e,t,r)):(ce.current="siws",xe(e,t,r,n))},loginWithWallet:async()=>{let e,t,r;if(!m)throw new o.PrivyNotReadyError;if(c.authFlow instanceof rn?e="siwe":c.authFlow instanceof on&&(e="siws"),!e)throw new o.PrivyClientError("Must initialize SIWE/SIWS flow first.");if(null!==await c.getAccessToken())try{({user:t}=await c.link()),ce.current=e}catch(t){throw si(oe,"linkAccount","onError",t.privyErrorCode||o.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{({user:t,isNewUser:r}=await c.authenticate()),ce.current=e}catch(e){throw si(oe,"login","onError",e.privyErrorCode||o.PrivyErrorCode.GENERIC_CONNECT_WALLET_ERROR),e}x(t||v||null),T(r||!1),w(!0)},delegateWallet:async({address:e,chainType:t,showDelegationUIs:r})=>new Promise((async(n,a)=>{let i=await yv();if(!f||!v||!i)throw new o.PrivyClientError("User must be authenticated and have an embedded wallet to delegate actions.");if("solana"!==t&&"ethereum"!==t)throw new o.PrivyClientError("Only Solana and Ethereum embedded wallets are supported for delegation and revocation.");let s=Me.walletProxy??await Me.initializeWalletProxy(15e3);if(!s)throw new o.PrivyClientError("Wallet proxy not initialized.");if((({address:e,user:t})=>!!zl(t).find((t=>t.address===e)))({address:e,user:v}))return n();let l=u.getPrivyWalletWithAddress(v,e);if(!l)throw new o.PrivyClientError("Address to delegate is not associated with current user.");if(u.getIsUnifiedWallet(l))throw new o.PrivyClientError("useDelegatedActions is only supported for on-device execution and this app uses TEE execution. Use the useSessionSigners hook to provision server side access on behalf of your users. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");let c=Dl({address:e,user:v}),d=Bl({address:e,user:v}),h=async()=>{await s.createDelegatedAction({accessToken:i,rootWallet:d,delegatedWallets:[c]}),await Me.refreshSessionAndUser()};if(await Me.recoverEmbeddedWallet({address:e}),r)G({delegatedActions:{consent:{address:e,onDelegate:h,onSuccess:async()=>{n()},onError:async e=>{a(e)}}}}),pe(gw);else try{await h(),n()}catch(e){a(e)}})),revokeDelegatedWallets:async({showDelegationUIs:e})=>new Promise((async(t,r)=>{if(!f||!v)throw new o.PrivyClientError("User must be authenticated and have an embedded wallet to revoke a delegated wallet.");let n=zl(v);if(0===n.length)throw new o.PrivyClientError("User has no delegated wallets to revoke.");if(n.some(u.getIsUnifiedWallet))throw new o.PrivyClientError("useDelegatedActions is only supported for on-device execution and this app uses TEE execution. Use the useSessionSigners hook to provision server side access on behalf of your users. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");let a=async()=>{await c.revokeDelegatedWallet(),await Me.refreshSessionAndUser()};if(e)G({delegatedActions:{revoke:{onRevoke:a,onSuccess:async()=>{t()},onError:async e=>{r(e)}}}}),pe(vw);else try{await a(),t()}catch(e){r(e)}})),initLoginWithFarcaster:async(e,t)=>{let r=new ir(e,t);c.startAuthFlow(r);try{ce.current="farcaster",await r.initializeFarcasterConnect()}catch(e){throw"login"===de.current?si(oe,"login","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===de.current&&si(oe,"linkAccount","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"farcaster"}),e}},loginWithFarcaster:async()=>{let e,t;if(!m)throw new o.PrivyNotReadyError;if(!(c.authFlow instanceof ir))throw new o.PrivyClientError("Must initialize Farcaster flow first.");if(null!==await c.getAccessToken())try{({user:e}=await c.link()),ce.current="farcaster"}catch(e){throw si(oe,"linkAccount","onError",e.privyErrorCode||o.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"farcaster"}),e}else try{({user:e,isNewUser:t}=await c.authenticate()),ce.current="farcaster"}catch(e){throw si(oe,"login","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}x(e||null),T(t||!1),w(!0)},async crossAppAuthFlow({appId:e,popup:t,action:r}){let n=`privy:${e}`;ce.current=n;let{url:a,stateCode:i,codeVerifier:s}=await async function({api:e,appId:t}){let r=Ur(),n=Or(),a=await Fr(r);try{let{url:i}=await e.post(o.oAuthInitPath,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:a,state_code:n});return{url:i,stateCode:n,codeVerifier:r}}catch(e){throw o.formatApiError(e)}}({api:c.api,appId:e});if(!a)throw c.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:"Unable to open cross-app auth popup",appId:e}}),new o.PrivyClientError("No authorization URL returned for cross-app auth.");try{let l=await async function({url:e,popup:t}){return t.location=e,new Promise(((e,r)=>{let n,a=setTimeout((()=>{r(new o.PrivyClientError("Authorization request timed out after 2 minutes.")),i()}),12e4);function i(){t?.close(),window.removeEventListener("message",l)}let s=setInterval((()=>{t?.closed&&!n&&(i(),clearInterval(s),clearTimeout(a),r(new o.PrivyClientError("User rejected request")))}),300);function l(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(clearTimeout(a),e(t.data),i()),"PRIVY_OAUTH_ERROR"===t.data.type&&(clearTimeout(a),r(new o.PrivyClientError(t.data.error)),i()),t.data.type===Kl&&((n=new BroadcastChannel(Hl)).onmessage=l))}window.addEventListener("message",l)}))}({url:a,popup:t,provider:n}),d=l.stateCode,u=l.authorizationCode;if(d!==i)throw c.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:n,storedStateCode:i??"",returnedStateCode:d??""}}),new o.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,o.PrivyErrorCode.OAUTH_UNEXPECTED);let h=await async function({appId:e,stateCode:t,codeVerifier:r,authorizationCode:n,action:a,client:i}){if(!n||!t)throw new o.PrivyClientError("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===n)throw new o.PrivyClientError("User denied confirmation during cross-app auth flow");try{let o=new Zl({authorizationCode:n,stateCode:t,codeVerifier:r,provider:`privy:${e}`});i.startAuthFlow(o);let s="link"===a?await i.link():await i.authenticate(),l=s.oAuthTokens?.accessToken;return console.debug(),l}catch(e){let t=o.formatApiError(e);if(t.privyErrorCode)throw new o.PrivyClientError(t.message||"Invalid code during cross-app auth flow.",void 0,t.privyErrorCode);if("User denied confirmation during cross-app auth flow"===t.message)throw new o.PrivyClientError("Invalid code during cross-app auth flow.",void 0,o.PrivyErrorCode.OAUTH_USER_DENIED);throw new o.PrivyClientError("Invalid code during cross-app auth flow.",void 0,o.PrivyErrorCode.UNKNOWN_AUTH_ERROR)}}({appId:e,codeVerifier:s,stateCode:d,authorizationCode:u,action:r,client:c});h&&c.storeProviderAccessToken(e,h);let p=await Me.refreshSessionAndUser();if(!p)throw new o.PrivyClientError("Unable to update user");return c.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:e}}),p}catch(e){throw c.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:e.toString(),provider:n}}),e}},async initLoginWithOAuth(e,t,r){if(ce.current=e,!Nt())return void pe(kw);if("google"===e&&Nh(window.navigator.userAgent))return void pe(kw);"twitter"===e&&window.opener&&window.opener.postMessage({type:Kl},"*"),Mt.del(jr),Mt.del(Er);let a=new Rr({provider:e,disableSignup:!!r,withPrivyUi:!0});t&&a.addCaptchaToken(t),c.startAuthFlow(a);let i=await c.authFlow.getAuthorizationUrl();i&&i.url&&("twitter"===e&&n.isAndroid&&(i.url=i.url.replace("x.com","twitter.com")),window.location.assign(i.url))},async initLoginWithTelegram(e,t){if(!m)throw new o.PrivyNotReadyError;ce.current="telegram";let r=new pn(e,t);c.startAuthFlow(r),q({status:"loading"}),r.meta.telegramWebAppData=void 0,r.meta.telegramAuthResult=await new Promise(((e,t)=>K.loginConfig.telegramAuthConfiguration?window.Telegram?void window.Telegram.Login.auth({bot_id:K.loginConfig.telegramAuthConfiguration.botId,request_access:!0},(r=>r?e(r):t(new o.PrivyClientError("Telegram auth failed or was canceled by the client")))):t(new o.PrivyClientError("Telegram was not initialized")):t(new o.PrivyClientError("Telegram Auth configuration is not loaded"))))},async loginWithTelegram(e){let t,r;if(!(c.authFlow instanceof pn))throw new o.PrivyClientError("Must initialize Telegram flow before calling loginWithTelegram");c.authFlow.meta.captchaToken||=e?.captchaToken;let n=await yv(),a=e?.intent||de.current;if("login"===a)try{let e=await c.authenticate();t=e.user,r=e.isNewUser,ce.current="telegram"}catch(e){throw si(oe,"login","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}else{if("link"!==a)throw new o.PrivyClientError("Unknown auth intent");try{t=(await c.link()).user,ce.current="telegram"}catch(e){throw si(oe,"linkAccount","onError",e.privyErrorCode||o.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}),e}}x(t),T(r||!1),w(!0),q({status:"done"});let i=t?.linkedAccounts.find((({type:e})=>"telegram"===e))||null;return{user:t,isNewUser:r||!1,wasAlreadyAuthenticated:!!n,loginAccount:i}},async loginWithOAuth(e){let t,r,n;if(!(c.authFlow instanceof Rr))throw new o.PrivyClientError("Must initialize OAuth flow before calling loginWithOAuth");let a=Mt.get(Cr),i=c.authFlow.meta.stateCode;if(a!==i)throw c.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:a??"",returnedStateCode:i??""}}),new o.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,o.PrivyErrorCode.OAUTH_UNEXPECTED);if(null!==await c.getAccessToken())try{let r=await c.link();t=r.user,n=r.oAuthTokens,ce.current=e}catch(t){throw si(oe,"linkAccount","onError",t.privyErrorCode||o.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{let a=await c.authenticate();t=a.user,r=a.isNewUser,n=a.oAuthTokens,ce.current=e}catch(t){throw"login"===de.current?si(oe,"login","onError",t.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===de.current&&si(oe,"linkAccount","onError",t.privyErrorCode||o.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}return x(t),T(r||!1),w(!0),n&&t&&si(oe,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:n,user:t}),n},passkeyAuthState:M,setPasskeyAuthState:W,async initSignupWithPasskey({captchaToken:e,withPrivyUi:t}){let r=new en({captchaToken:e,setPasskeyAuthState:W});c.startAuthFlow(r),de.current="login";try{ce.current="passkey",W({status:"generating-challenge"}),await r.initRegisterFlow(t),W({status:"awaiting-passkey"})}catch(e){throw W({status:"error",error:e}),si(oe,"login","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}},async signupWithPasskey(){let e,t;if(!m)throw new o.PrivyNotReadyError;if(!(c.authFlow instanceof en))throw new o.PrivyClientError("Must initialize Passkey flow first.");if("passkey"!==ce.current){let e=new o.PrivyClientError("Must init login with Passkey flow first.");throw W({status:"error",error:e}),e}let r=await yv();try{ce.current="passkey",W({status:"awaiting-passkey"}),({user:e,isNewUser:t}=await c.authenticate())}catch(e){throw W({status:"error",error:e}),si(oe,"login","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}x(e),T(t||!1),w(!0),W({status:"done"});let n=e?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:e,isNewUser:t||!1,wasAlreadyAuthenticated:!!r,loginAccount:n}},async initLoginWithPasskey({captchaToken:e,withPrivyUi:t}){let r=new en({captchaToken:e,setPasskeyAuthState:W});c.startAuthFlow(r),de.current="login";try{ce.current="passkey",W({status:"generating-challenge"}),await r.initAuthenticationFlow(t),W({status:"awaiting-passkey"})}catch(e){throw W({status:"error",error:e}),si(oe,"login","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}},async loginWithPasskey(e){let t,r;if(!m)throw new o.PrivyNotReadyError;if(!(c.authFlow instanceof en))throw new o.PrivyClientError("Must initialize Passkey flow first.");if(e?.credentialIds&&(c.authFlow.meta.allowedCredentialsIds=e.credentialIds),"passkey"!==ce.current){let e=new o.PrivyClientError("Must init login with Passkey flow first.");throw W({status:"error",error:e}),e}let n=await yv();try{ce.current="passkey",W({status:"awaiting-passkey"}),({user:t,isNewUser:r}=await c.authenticate())}catch(e){throw W({status:"error",error:e}),si(oe,"login","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}x(t),T(r||!1),w(!0),W({status:"done"});let a=t?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:t,isNewUser:r||!1,wasAlreadyAuthenticated:!!n,loginAccount:a}},async initLinkWithPasskey(e){let t=new en({captchaToken:e});c.startAuthFlow(t),de.current="link",ce.current="passkey",W({status:"generating-challenge"});try{await t.initLinkFlow(),W({status:"awaiting-passkey"})}catch(e){throw si(oe,"linkAccount","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),W({status:"error",error:e}),e}},async linkWithPasskey(){let e;if(!m)throw new o.PrivyNotReadyError;if(!(c.authFlow instanceof en))throw new o.PrivyClientError("Must initialize Passkey flow first.");if("passkey"!==ce.current)throw new o.PrivyClientError("Must init login with Passkey flow first.");try{ce.current="passkey",({user:e}=await c.link())}catch(e){throw si(oe,"linkAccount","onError",e.privyErrorCode||o.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"passkey"}),e}return x(e||v||null),W({status:"done"}),e},async initLoginWithHeadlessOAuth(e,t,r){if(!Nt())throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");if("google"===e&&Nh(window.navigator.userAgent))throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");let n=new Rr({provider:e,withPrivyUi:!1,disableSignup:r??!1});t&&n.addCaptchaToken(t),z({status:"loading"});let a=await c.startAuthFlow(n).getAuthorizationUrl();a?.url&&window.location.assign(a.url)},async loginWithHeadlessOAuth(e){let t,r,n;P(!0),z({status:"loading"}),c.startAuthFlow(new Rr(e));let a=Mt.get(Cr),i=e.stateCode;if(a!==i)throw c.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e.provider,storedStateCode:a??"",returnedStateCode:i??""}}),P(!1),new o.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,o.PrivyErrorCode.OAUTH_UNEXPECTED);if(null!==await c.getAccessToken())try{({user:t,oAuthTokens:n}=await c.link()),ce.current=e.provider;let r=Ie(t);t&&r&&si(oe,"linkAccount","onSuccess",{user:t,linkMethod:ce.current,linkedAccount:r})}catch(t){throw P(!1),si(oe,"linkAccount","onError",t.privyErrorCode||o.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e.provider}),t}else try{({user:t,isNewUser:r,oAuthTokens:n}=await c.authenticate()),ce.current=e.provider;let a=Ie(t);t&&a&&void 0!==r&&si(oe,"login","onComplete",{user:t,isNewUser:r,wasAlreadyAuthenticated:!1,loginMethod:ce.current,loginAccount:a})}catch(e){throw P(!1),z({status:"error",error:e}),si(oe,"login","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}return x(t),T(r||!1),w(!0),P(!1),z({status:"done"}),n&&t&&si(oe,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:n,user:t}),t??void 0},initLoginWithEmail:async({email:e,captchaToken:t,disableSignup:r,withPrivyUi:n})=>{let a=new St({email:e,captchaToken:t,disableSignup:r});c.startAuthFlow(a);try{ce.current="email",O({status:"sending-code"}),await a.sendCodeEmail({withPrivyUi:n}),O({status:"awaiting-code-input"})}catch(e){throw O({status:"error",error:e}),"login"===de.current?si(oe,"login","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===de.current&&si(oe,"linkAccount","onError",e.privyErrorCode||o.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"email"}),e}},initUpdateEmail:async(e,t,r)=>{let n=new Pt(e,t,r);c.startAuthFlow(n);try{await n.sendCodeEmail({withPrivyUi:!0})}catch(e){si(oe,"update","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:ce.current})}},initUpdatePhone:async(e,t,r)=>{let n=new ln(e,t,r);c.startAuthFlow(n);try{await n.sendSmsCode({withPrivyUi:!0})}catch(e){si(oe,"update","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:ce.current})}},initLoginWithSms:async({phoneNumber:e,captchaToken:t,disableSignup:r,withPrivyUi:n})=>{R({status:"sending-code"});let a=new sn({phoneNumber:e,captchaToken:t,disableSignup:r});c.startAuthFlow(a);try{ce.current="sms",await a.sendSmsCode({withPrivyUi:n}),R({status:"awaiting-code-input"})}catch(e){throw R({status:"error",error:e}),"login"===de.current?si(oe,"login","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===de.current&&si(oe,"linkAccount","onError",e.privyErrorCode||o.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"sms"}),e}},resendEmailCode:async()=>{await(c.authFlow?.sendCodeEmail({withPrivyUi:!0}))},resendSmsCode:async()=>{await(c.authFlow?.sendSmsCode({withPrivyUi:!0}))},loginWithCode:async e=>{let t,r;function n(e){c.authFlow instanceof St?O(e):c.authFlow instanceof sn&&R(e)}if(n({status:"submitting-code"}),!m){let e=new o.PrivyNotReadyError;throw n({status:"error",error:e}),e}if(c.authFlow instanceof St)c.authFlow.meta.emailCode=e.trim();else{if(!(c.authFlow instanceof sn)){let e=new o.PrivyClientError("Must initialize a passwordless code flow first");throw n({status:"error",error:e}),e}c.authFlow.meta.smsCode=e.trim()}let a=await yv();if("link"===de.current)try{({user:t}=await c.link())}catch(e){throw n({status:"error",error:e}),si(oe,"linkAccount","onError",e.privyErrorCode||o.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:ce.current}),e}else if("update"===de.current)try{({user:t}=await c.link())}catch(e){throw n({status:"error",error:e}),si(oe,"update","onError",e.privyErrorCode||o.PrivyErrorCode.FAILED_TO_UPDATE_ACCOUNT,{linkMethod:ce.current}),e}else try{({user:t,isNewUser:r}=await c.authenticate())}catch(e){throw n({status:"error",error:e}),si(oe,"login","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}let i=t||v;x(i||null),T(r||!1),w(!0),n({status:"done"});let s=null;return c.authFlow instanceof St?s=i?.linkedAccounts.find((({type:e})=>"email"===e))||null:c.authFlow instanceof sn&&(s=i?.linkedAccounts.find((({type:e})=>"phone"===e))||null),{user:i,isNewUser:r||!1,wasAlreadyAuthenticated:!!a,linkedAccount:s}},generateSiweMessage:async({address:e,chainId:t,captchaToken:r})=>{de.current=f?"link":"login",ce.current="siwe",D({status:"generating-message"});let n=await c.generateSiweNonce({address:e,captchaToken:r});return D({status:"awaiting-signature"}),tn({address:e,chainId:t.replace("eip155:",""),nonce:n})},generateSiweMessageForSmartWallet:async({address:e,chainId:t})=>{let r=await c.generateSiweNonce({address:e});return tn({address:e,chainId:t.replace("eip155:",""),nonce:r})},linkSmartWallet:async({message:e,signature:t,smartWalletType:r})=>{let n;n=await c.linkSmartWallet({message:e,signature:t,smartWalletType:r}),x((n=await Me.refreshSessionAndUser()??n)||v||null)},loginWithSiwe:async({message:e,signature:t,captchaToken:r,disableSignup:n})=>{let a,i=null;try{if(v)throw Error("User already authenticated");let o=new rn(c,void 0,r,n,{message:e,signature:t});c.startAuthFlow(o),ce.current="siwe",de.current="login",D({status:"submitting-signature"});let s=await c.authenticate();if(({user:i,isNewUser:a}=s),!i)throw Error("Authentication failed - no user returned")}catch(e){throw si(oe,"login","onError",e.privyErrorCode||o.PrivyErrorCode.UNKNOWN_AUTH_ERROR),D({status:"error",error:e}),e}return x(i),T(a||!1),w(!0),D({status:"done"}),de.current=null,ce.current=null,i},linkWithSiwe:async({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a})=>{let i;be("siwe");let s=null;try{D({status:"submitting-signature"}),i=await c.linkWithSiwe({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a}),i=await Me.refreshSessionAndUser()??i,D({status:"done"}),(s=Ie(i)||null)&&si(oe,"linkAccount","onSuccess",{user:i,linkMethod:"siwe",linkedAccount:s})}catch(e){throw si(oe,"linkAccount","onError",e.privyErrorCode||o.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"siwe"}),de.current=null,ce.current=null,D({status:"error",error:e}),e}let l=i||v;return x(l||null),de.current=null,ce.current=null,{user:l,linkedAccount:s}},refreshSessionAndUser:async()=>{let e=await c.getAuthenticatedUser();return w(!!e),x(e),e},walletProxy:V,createAnalyticsEvent:({eventName:e,payload:t,timestamp:r})=>c.createAnalyticsEvent({eventName:e,payload:t,timestamp:r}),acceptTerms:async()=>{let e=await c.acceptTerms();return x(e),e},getUsdTokenPrice:e=>c.getUsdTokenPrice(e),getUsdPriceForSol:()=>c.getUsdPriceForSol(),getSplTokenMetadata:e=>c.getSplTokenMetadata(e),recoverEmbeddedWallet:async e=>new Promise((async(t,r)=>{if(!v)return void t(!0);let n=e?.address?u.getPrivyWalletWithAddress(v,e.address):u.getPrivyPrimaryWallet(v)||u.getImportedPrivyEthereumWallet(v)||u.getImportedPrivySolanaWallet(v);if(!n||u.getIsUnifiedWallet(n))return void t(!0);let a=await yv();if(!a||!V||!n)return void r(Error("Must have valid access token and Privy wallet to recover wallet"));let{entropyId:i,entropyIdVerifier:o}=xn(v,n);try{await V.connect({accessToken:a,entropyId:i,entropyIdVerifier:o}),t(!0)}catch(e){if(Ls(e)&&"privy"===n.recoveryMethod){let e;c.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:n.address}});try{e=await V.recover({entropyId:i,entropyIdVerifier:o,accessToken:a})}catch(e){return void r(e)}e.entropyId||r(Error("Unable to recover wallet")),c.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:n.address}}),t(!0)}else Ls(e)&&"privy"!==n.recoveryMethod&&"privy-v2"!==n.recoveryMethod?(G({recoverWallet:{entropyId:i,entropyIdVerifier:o,onFailure:r,onSuccess:()=>t(!0)},recoveryOAuthStatus:{provider:n.recoveryMethod,action:"recover",shouldCreateEth:!1,shouldCreateSol:!1}}),pe(hy(n.recoveryMethod))):r(e)}})),exportSolanaWallet:e=>new Promise((async(t,r)=>{if(!f||!v)return void r(Error("User must be authenticated before exporting their Privy wallet"));let n=e?.address?u.getPrivyWalletWithAddress(v,e.address):u.getPrivySolanaWallet(v),a=u.getPrivyPrimaryWallet(v);if(!n||!a)return void r(new o.PrivyClientError("User must have an embedded wallet."));let{entropyId:i,entropyIdVerifier:s}=xn(v,n);if(!n||!a)return void r(Error("Must have a Privy wallet before exporting"));let d=u.getIsUnifiedWallet(n);if(!await yv()||!V)return void r(Error("Must have valid access token to enroll in MFA"));if(!V)return void r(Error("Must have a Privy wallet before exporting"));let h={recoveryMethod:n.recoveryMethod,connectingWalletAddress:n.address,isUnifiedWallet:d,entropyId:i,entropyIdVerifier:s,onCompleteNavigateTo:Sg,onFailure:r,shouldForceMFA:!0};Ll(n)?(G({connectWallet:h,keyExport:{appId:l.appId,appClientId:l.clientId,origin:c.apiUrl,address:n.address,entropyId:i,entropyIdVerifier:s,hdWalletIndex:n.walletIndex,chainType:n.chainType,walletId:n.id,isUnifiedWallet:d,imported:n.imported,onSuccess:t,onFailure:r}}),pe(Mg)):r(Error(`Export is not supported for ${n.chainType} wallets`))})),setReadyToTrue:e=>{g(!0),J?.(e)},updateWallets:()=>ke(),fundWallet:async(e,t)=>{G({funding:Eg({address:e,appConfig:K,fundWalletConfig:t,methodScreen:wg})}),pe(wg)},openModal:pe,requestFarcasterSignerStatus:async e=>{let t=await yv(),r=v?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!V||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(!v?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");let n=await c.requestFarcasterSignerStatus(e);return"approved"===n.status&&x(await c.getAuthenticatedUser()||v||null),n},connectCoinbaseSmartWallet:async()=>{K.externalWallets.coinbaseWallet.config.preference={...K.externalWallets.coinbaseWallet.config.preference,options:"smartWalletOnly"};let e=c.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||c.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(e)return e.updateConnectionPreference("smartWalletOnly"),we(e);await fe("coinbase_wallet","coinbase_smart_wallet")},initiateAccountTransfer:async({nonce:e,account:t,accountType:r,externalWalletMetadata:n,telegramAuthResult:a,telegramWebAppData:i,farcasterEmbeddedAddress:o,oAuthUserInfo:s})=>{let l=await c.sendAccountTransferRequest({nonce:e,account:t,accountType:r,externalWalletMetadata:n,telegramAuthResult:a,telegramWebAppData:i,farcasterEmbeddedAddress:o,oAuthUserInfo:s});return x(l),l}};hv=Me.recoverEmbeddedWallet,pv=Me.recoverEmbeddedWallet;let We=r.useMemo((()=>({wallets:C,ready:ee&&se})),[C,ee,se]),Ue=c.authFlow instanceof pn,Oe=!K.headless&&K.captchaEnabled&&!f&&(m||Ue);/*#__PURE__*/return e.jsx(ov.Provider,{value:!0,children:/*#__PURE__*/e.jsx(u.PrivyContext.Provider,{value:Ne,children:/*#__PURE__*/e.jsx(ai.Provider,{value:oe,children:/*#__PURE__*/e.jsx(_s.Provider,{value:We,children:/*#__PURE__*/e.jsx(un,{...K,children:/*#__PURE__*/e.jsxs(s.InternalPrivyContext.Provider,{value:Me,children:[/*#__PURE__*/e.jsx(gd,{children:/*#__PURE__*/e.jsxs(Wa,{data:Y,setModalData:G,setInitialScreen:I,initialScreen:A,authenticated:f,open:p,children:[l.children,/*#__PURE__*/e.jsx(iv,{customAuth:K.customAuth}),Oe&&/*#__PURE__*/e.jsx(ti,{delayedExecution:!1}),/*#__PURE__*/e.jsx(Sl,{}),/*#__PURE__*/e.jsx(dw,{}),/*#__PURE__*/e.jsx(ml,{theme:{...K.appearance.palette||{}}}),!K.render.standalone&&/*#__PURE__*/e.jsx(kl,{open:p})]})}),/*#__PURE__*/e.jsx(Rl,{appId:l.appId,appClientId:l.clientId,clientAnalyticsId:c.clientAnalyticsId,origin:c.apiUrl,mfaMethods:v?.mfaMethods,mfaPromise:ae,mfaSubmitPromise:ie,onLoad:H,onLoadFailed:()=>null}),K.loginConfig.telegramAuthConfiguration&&
27
- /*#__PURE__*/e.jsx(wi,{$if:!0,children:/*#__PURE__*/e.jsx(Il,{scriptHost:l.apiUrl||or,botUsername:K.loginConfig.telegramAuthConfiguration.botName})})]})})})})})})};exports.Address=Od,exports.BlobbyFooter=Di,exports.ButtonLoader=Ei,exports.Captcha=ti,exports.CaptchaError=dn,exports.Column=my,exports.ConnectorManager=Fa,exports.Copy=Ou,exports.CustomJwtAccountFlow=$a,exports.DEFAULT_SUCCESS_SCREEN_DURATION_MS=sr,exports.EmailUpdateForm=Bp,exports.EmbeddedWalletConnectingScreen=Mg,exports.EthereumWalletConnector=Wn,exports.FundingMethodSelectionScreen=wg,exports.GuestFlow=qa,exports.LoginModal=kl,exports.NetworkIcon=nm,exports.PrimaryButton=Ai,exports.PrivyClient=Xa,exports.PrivyProvider=({config:t,...n})=>{var a;if((()=>{if(r.useContext(ov))throw new o.PrivyClientError("Multiple PrivyProvider instances found","Found multiple instances of PrivyProvider, ensure there is only one mounted in your application tree.")})(),"undefined"!=typeof window&&0>["localhost","127.0.0.1"].indexOf(window.location.hostname)&&"https:"!==window.location.protocol)throw new o.PrivyClientError("Embedded wallet is only available over HTTPS");if("string"!=typeof(a=n.appId)||25!==a.length)throw new o.PrivyClientError("Cannot initialize the Privy provider with an invalid Privy app ID");sv||(sv=new Xa({appId:n.appId,appClientId:n.clientId,apiUrl:n.apiUrl}));let i=Object.assign({},t),s=r.useMemo((()=>new Te.default({appId:n.appId,clientId:n.clientId,storage:Mt,baseUrl:n.apiUrl,sdkVersion:"react-auth:2.15.0"})),[]);/*#__PURE__*/
27
+ /*#__PURE__*/e.jsx(wi,{$if:!0,children:/*#__PURE__*/e.jsx(Il,{scriptHost:l.apiUrl||or,botUsername:K.loginConfig.telegramAuthConfiguration.botName})})]})})})})})})};exports.Address=Od,exports.BlobbyFooter=Di,exports.ButtonLoader=Ei,exports.Captcha=ti,exports.CaptchaError=dn,exports.Column=my,exports.ConnectorManager=Fa,exports.Copy=Ou,exports.CustomJwtAccountFlow=$a,exports.DEFAULT_SUCCESS_SCREEN_DURATION_MS=sr,exports.EmailUpdateForm=Bp,exports.EmbeddedWalletConnectingScreen=Mg,exports.EthereumWalletConnector=Wn,exports.FundingMethodSelectionScreen=wg,exports.GuestFlow=qa,exports.LoginModal=kl,exports.NetworkIcon=nm,exports.PrimaryButton=Ai,exports.PrivyClient=Xa,exports.PrivyProvider=({config:t,...n})=>{var a;if((()=>{if(r.useContext(ov))throw new o.PrivyClientError("Multiple PrivyProvider instances found","Found multiple instances of PrivyProvider, ensure there is only one mounted in your application tree.")})(),"undefined"!=typeof window&&0>["localhost","127.0.0.1"].indexOf(window.location.hostname)&&"https:"!==window.location.protocol)throw new o.PrivyClientError("Embedded wallet is only available over HTTPS");if("string"!=typeof(a=n.appId)||25!==a.length)throw new o.PrivyClientError("Cannot initialize the Privy provider with an invalid Privy app ID");sv||(sv=new Xa({appId:n.appId,appClientId:n.clientId,apiUrl:n.apiUrl}));let i=Object.assign({},t),s=r.useMemo((()=>new Te.default({appId:n.appId,clientId:n.clientId,storage:Mt,baseUrl:n.apiUrl,sdkVersion:"react-auth:2.15.1"})),[]);/*#__PURE__*/
28
28
  return e.jsx(Pa,{client:s,legacyClient:sv,clientConfig:i,children:/*#__PURE__*/e.jsx(Uh,{children:/*#__PURE__*/e.jsx(Cv,{...n,client:sv,privy:s})})})},exports.QrCode=Yu,exports.Row=Jy,exports.Rows=Gy,exports.SOLANA_FUNDING_PLUGIN_ID=Ey,exports.SOLANA_LEDGER_PLUGIN_ID=Fh,exports.SendTransactionScreen=ow,exports.SignRequestScreen=Sf,exports.SolanaWalletConnector=sa,exports.Subtitle=sy,exports.Title=ly,exports.VERSION=dr,exports.WALLET_PROXY_TIMEOUT=Sr,exports.WalletCards=zy,exports.WalletConnect=({style:t,...r})=>{let{app:n}=Ua();/*#__PURE__*/return e.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"28",height:"28",rx:"3",fill:"dark"===n?.appearance.palette.colorScheme?"#3396ff":"#141414"}),/*#__PURE__*/e.jsx("g",{clipPath:"url(#clip0_1765_9946)",children:/*#__PURE__*/e.jsx("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),/*#__PURE__*/e.jsx("defs",{children:/*#__PURE__*/e.jsx("clipPath",{id:"clip0_1765_9946",children:/*#__PURE__*/e.jsx("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})},exports.WalletConnector=Pn,exports.WalletInfoCard=vy,exports.WalletLoading=Gh,exports.bufferFrom=nn,exports.detectCompletingOAuthFlow=Qr,exports.errorIndicatesMaxMfaRetries=zs,exports.errorIndicatesMfaTimeout=Ds,exports.errorIndicatesMfaVerificationFailed=Bs,exports.extractChainIdFromCAIP2=Vl,exports.formatErc20TokenAmount=cm,exports.formatWalletAddress=Dt,exports.getAccessToken=yv,exports.getCustomerAccessToken=function(){return sv?sv.getCustomerAccessToken():Promise.resolve(Mt.get(ur)||null)},exports.getDelegatedWalletsData=Dl,exports.getEntropyDetailsForUser=xn,exports.getErc20Balance=by,exports.getErc20TokenInfo=$y,exports.getJsonRpcEndpointFromChain=Rt,exports.getNativeCurrencyFromWei=yo,exports.getRootWalletDataForDelegation=Bl,exports.importWallet=ky,exports.isBaseConnectedEthereumWallet=In,exports.isBaseConnectedSolanaWallet=oa,exports.isVersionedTransaction=Io,exports.parseAdditionalSigners=e=>e?.map((e=>({signer_id:e.signerId,override_policy_ids:e.policyIds}))),exports.prepareSiwsMessageWithNonce=an,exports.prepareSolanaFundingModalData=kg,exports.s=Mt,exports.shouldCreateEmbeddedEthWallet=Td,exports.shouldCreateEmbeddedSolWallet=Id,exports.signOrSendSolanaTransactionInternal=vf,exports.stripUrlOAuthParamsAndRemoveStateCode=Xr,exports.useAppConfig=_a,exports.useCaptcha=hn,exports.useCreateWallet=Ny,exports.useCreateWalletInternal=_y,exports.useElementHeight=ri,exports.useEmitPrivyEvent=li,exports.useExternalWalletState=ca,exports.useIdentityToken=function(){let{identityToken:e}=Ha();return{identityToken:e}},exports.useImportWallet=My,exports.useIsServerConfigLoaded=Na,exports.useJwtAuthFlowState=()=>av((e=>e.jwtAuthFlowState)),exports.useLogout=pw,exports.useMfa=Vs,exports.useMfaEnrollment=Nw,exports.usePrivy=Wy,exports.usePrivyEventSubscription=oi,exports.usePrivyModal=Ua,exports.useRecentlyUsedLogin=xd,exports.useRegisterMfaListener=ci,exports.useRegisterPlugin=(...e)=>{let{plugins:t}=r.useContext(Wh);r.useEffect((()=>{for(let r of e)t.current[r.id]=r;return()=>{for(let r of e)delete t.current[r.id]}}),[t])},exports.useSendTransaction=xf,exports.useSignMessage=Wf,exports.useSolanaWallets=Uf,exports.useSyncJwtBasedAuthState=nv,exports.useWalletBalance=xy,exports.useWallets=Ns;