@privy-io/react-auth 3.3.0-beta-20251010144542 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{SignRequestScreen-CP2KA7ya.js → SignRequestScreen-CvBcoZRA.js} +1 -1
- package/dist/cjs/abstract-smart-wallets.js +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/{smart-wallets-DeRINaJe.js → smart-wallets-Cgmp6lBz.js} +1 -1
- package/dist/cjs/smart-wallets.js +1 -1
- package/dist/cjs/solana.js +1 -1
- package/dist/cjs/ui.js +1 -1
- package/dist/cjs/{use-export-wallet-BP0lPnqm.js → use-export-wallet-Crjmwv6E.js} +1 -1
- package/dist/cjs/{useActiveWallet-LAFaOocp.js → useActiveWallet-DAK4USsc.js} +1 -1
- package/dist/cjs/{usePrivy-qD6wnoRL.js → usePrivy-BQiDRA6a.js} +1 -1
- package/dist/esm/{SignRequestScreen-CGlP3Q5r.mjs → SignRequestScreen-Dnn_x6kV.mjs} +1 -1
- package/dist/esm/abstract-smart-wallets.mjs +1 -1
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/{smart-wallets-CdEONzDF.mjs → smart-wallets-D86YXRN5.mjs} +1 -1
- package/dist/esm/smart-wallets.mjs +1 -1
- package/dist/esm/solana.mjs +1 -1
- package/dist/esm/ui.mjs +1 -1
- package/dist/esm/{use-export-wallet-CaBSW_2U.mjs → use-export-wallet-DVZxxj2x.mjs} +1 -1
- package/dist/esm/{useActiveWallet-CiDNzxEx.mjs → useActiveWallet-YrSgEFNG.mjs} +1 -1
- package/dist/esm/{usePrivy-DQW-BUcn.mjs → usePrivy-CYAVrCyA.mjs} +1 -1
- package/package.json +4 -4
|
@@ -24,4 +24,4 @@ return e.jsx(da,{...Gn().render.standalone?{defaultValue:"details"}:{},children:
|
|
|
24
24
|
/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(mu,{}),/*#__PURE__*/e.jsx(Qr,{}),/*#__PURE__*/e.jsx("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/e.jsx(vr,{})]})}},bp={component:()=>{let{data:t,setModalData:r}=Jn(),i=t?.funding,a="solana"===i.chainType,o=n.useRef(null),{tokenPrice:s}=Pa(a?"solana":i.chain.id),l=a?void 0:i,c=!(!l?.erc20Address||l?.erc20ContractInfo),d=a?i.isUSDC?"USDC":"SOL":i.erc20Address?i.erc20ContractInfo?.symbol:i.chain.nativeCurrency.symbol||"ETH",u=parseFloat(i.amount),p=!isNaN(u)&&u>0,h=s?Ii(i.amount,s):void 0;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(mu,{}),/*#__PURE__*/e.jsx(kc,{children:"Confirm or edit amount"}),/*#__PURE__*/e.jsxs(Qi,{style:{marginTop:"32px"},children:[/*#__PURE__*/e.jsx(sp,{children:c?/*#__PURE__*/e.jsx(Qr,{size:"50px"}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsxs(lp,{onClick:()=>o.current?.focus(),children:[/*#__PURE__*/e.jsx(dp,{ref:o,value:i.amount,onChange:e=>{let n=e.target.value;/^[0-9.]*$/.test(n)&&n.split(".").length-1<=1&&r({...t,funding:{...i,amount:n},solanaFundingData:t?.solanaFundingData?{...t.solanaFundingData,amount:n}:void 0})}}),/*#__PURE__*/e.jsx(up,{children:d})]}),!l?.erc20Address&&/*#__PURE__*/e.jsx(pp,{children:h&&p?`${h} USD`:""})]})}),/*#__PURE__*/e.jsx(_r,{style:{marginTop:"1rem"},disabled:!p,onClick:i.onContinueWithExternalWallet,children:"Continue"})]}),/*#__PURE__*/e.jsx(vr,{})]})}},jp={component:()=>{let t,{connectors:i}=r.usePrivyInternal(),{setModalData:a,data:o,navigate:s}=Jn(),l=Gn(),{wallets:c}=_a(),d=i.filter(En).flatMap((e=>e.wallets)),[u,p]=n.useState("default"),h="solana"===o?.funding?.chainType,g=!!o?.funding?.crossChainBridgingEnabled;t="ethereum"===o?.funding?.chainType?o.funding.erc20Address&&!o.funding.isUSDC?"ethereum-only":g&&!o.funding.chain.testnet?"ethereum-and-solana":"ethereum-only":g&&!o.funding?.isUSDC?"ethereum-and-solana":"solana-only";let m=c.filter((e=>"privy"!==e.walletClientType)),y=m.map((e=>e.walletClientType)),f=d.filter((e=>"privy"!==e.walletClientType)),x=f.map((e=>e.walletClientType)),v=[],w={...o.funding};w.usingDefaultFundingMethod&&(w.usingDefaultFundingMethod=!1);let C=({address:e,walletChainType:t,walletClientType:n})=>{a({...o,funding:{...w,connectedWalletAddress:e,onContinueWithExternalWallet:()=>s(j({destChainType:h?"solana":"ethereum",sourceChainType:t}))},solanaFundingData:o?.solanaFundingData?{...o.solanaFundingData,sourceWalletData:{address:e,walletClientType:n}}:void 0}),s(bp)};"solana-only"!==t&&v.push(...m.map(((t,n)=>/*#__PURE__*/e.jsx(kp,{onClick:()=>C({address:t.address,walletChainType:"ethereum",walletClientType:t.walletClientType}),icon:t.meta.icon,name:t.meta.name,chainType:t.type},n)))),"ethereum-only"!==t&&v.push(...f.map(((t,n)=>/*#__PURE__*/e.jsx(kp,{onClick:()=>C({address:t.address,walletChainType:"solana",walletClientType:t.walletClientType}),icon:t.meta.icon,name:t.meta.name,chainType:t.type},n)))),v.push(...Hu({walletList:l.appearance.walletList.filter((e=>!m.some((t=>t.walletClientType===e))&&!f.some((t=>t.walletClientType===e)))),walletChainType:t,connectors:i,connectOnly:!0,ignore:[...l.appearance.walletList,...y,...x],walletConnectEnabled:l.externalWallets.walletConnect.enabled}));let b=/*#__PURE__*/e.jsx(Cu,{text:"More wallets",onClick:()=>p("overflow")}),j=({sourceChainType:e,destChainType:t})=>"ethereum"===e&&"solana"===t?xp:"ethereum"===e&&"ethereum"===t?vp:"solana"===e&&"ethereum"===t?Cp:w.externalSolanaFundingScreen;return n.useEffect((()=>{a({...o,externalConnectWallet:{onCompleteNavigateTo:({address:e,walletClientType:t,walletChainType:n})=>(a({...o,funding:{...w,connectedWalletAddress:e,onContinueWithExternalWallet:()=>{s(j({destChainType:h?"solana":"ethereum",sourceChainType:n??"ethereum"}))}},solanaFundingData:o?.solanaFundingData?{...o.solanaFundingData,sourceWalletData:{address:e||"",walletClientType:t||""}}:void 0}),bp)}})}),[]),"overflow"===u?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vr,{backFn:()=>p("default")},"header"),/*#__PURE__*/e.jsxs(sr,{children:[/*#__PURE__*/e.jsx(jc,{style:{color:"var(--privy-color-foreground-3)",textAlign:"left"},children:"More wallets"}),v]}),/*#__PURE__*/e.jsx(vr,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(mu,{}),/*#__PURE__*/e.jsx(za,{title:"Transfer from wallet",description:"Connect a wallet to deposit funds or send funds manually to your wallet address."}),/*#__PURE__*/e.jsxs(sr,{children:[v.length>4?v.slice(0,3):v,v.length>4&&b]}),/*#__PURE__*/e.jsx(vr,{})]})}};let kp=({onClick:t,icon:n,name:r,chainType:i})=>/*#__PURE__*/e.jsxs(ur,{onClick:t,children:[/*#__PURE__*/e.jsx(op,{style:{width:20},children:/*#__PURE__*/e.jsx("img",{src:n})}),r,/*#__PURE__*/e.jsx(vu,{color:"gray",style:{marginLeft:"auto"},children:"Connected"}),"solana"===i&&/*#__PURE__*/e.jsx(vu,{color:"gray",children:"Solana"})]});const Tp={component:()=>{let{data:t,setModalData:i,navigate:a,navigateBack:o}=Jn(),{closePrivyModal:s,createAnalyticsEvent:l,client:c}=r.usePrivyInternal(),[d,u]=n.useState("pending-in-flow"),p=n.useRef(0),h={...t?.funding,showAlternateFundingMethod:!0};h.usingDefaultFundingMethod&&(h.usingDefaultFundingMethod=!1);let{partnerUserId:g,popup:m}=t?.coinbaseOnrampStatus??{};return n.useEffect((()=>{if("pending-in-flow"===d||"pending-after-flow"===d){let e=setInterval((async()=>{if(g)try{let{status:e}=await c.getCoinbaseOnRampStatus({partnerUserId:g});if("success"===e)return void u("success");if("failure"===e)throw Error("There was an error completing Coinbase Onramp flow.");if(p.current>=3)return i({funding:h,solanaFundingData:t?.solanaFundingData}),void a($p);m?.closed&&(p.current=p.current+1,u("pending-after-flow"))}catch(e){console.error(e),u("error"),l({eventName:Dc,payload:{status:"failure",provider:"coinbase-onramp",error:e.message}}),i({funding:{...h,errorMessage:"Something went wrong adding funds. Please try again or use another method."},solanaFundingData:t?.solanaFundingData}),a($p)}}),1500);return()=>clearInterval(e)}}),[g,m,d]),/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vr,{title:"Fund account",backFn:()=>{i({funding:h,solanaFundingData:t?.solanaFundingData}),o()}},"header"),/*#__PURE__*/e.jsx(Ap,{status:d,onClickCta:s}),/*#__PURE__*/e.jsx(vr,{})]})}};let Ap=({status:t,onClickCta:r})=>{let{title:i,body:a,cta:o}=n.useMemo((()=>(e=>{switch(e){case"success":return{title:"You've funded your account!",body:"It may take a few minutes for the assets to appear.",cta:"Continue"};case"pending-after-flow":return{title:"In Progress",body:"Almost done. Retrieving transaction status from Coinbase",cta:""};case"error":case"pending-in-flow":return{title:"In Progress",body:"Go back to Coinbase Onramp to finish funding your account.",cta:""}}})(t)),[t]);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsxs(Ip,{children:[/*#__PURE__*/e.jsx(Sp,{isSucccess:"success"===t}),/*#__PURE__*/e.jsxs(Xi,{children:[/*#__PURE__*/e.jsx("h3",{children:i}),/*#__PURE__*/e.jsx(Ep,{children:a})]})]}),o&&/*#__PURE__*/e.jsx(Nr,{onClick:r,children:o})]})},Sp=({isSucccess:t})=>{if(!t){let t="var(--privy-color-foreground-4)";/*#__PURE__*/return e.jsxs("div",{style:{position:"relative"},children:[/*#__PURE__*/e.jsx(Tr,{color:t,style:{position:"absolute"}}),/*#__PURE__*/e.jsx(Ar,{color:t}),/*#__PURE__*/e.jsx(Jt,{style:{position:"absolute",width:"2.8rem",height:"2.8rem",top:"1.2rem",left:"1.2rem"}})]})}let n=(t=>t?Pe.default:()=>/*#__PURE__*/e.jsx(Ue.default,{width:"3rem",height:"3rem",style:{backgroundColor:"var(--privy-color-foreground-4)",color:"var(--privy-color-background)",borderRadius:"100%",padding:"0.5rem",margin:"0.5rem"}}))(t),r=(e=>e?"var(--privy-color-success)":"var(--privy-color-foreground-4)")(t);/*#__PURE__*/return e.jsx("div",{style:{borderColor:r,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:n&&/*#__PURE__*/e.jsx(n,{width:"4rem",height:"4rem",color:r})})},Ep=/*#__PURE__*/a.styled.p.withConfig({displayName:"StatusBody",componentId:"sc-8428a551-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),Ip=/*#__PURE__*/a.styled.div.withConfig({displayName:"ConnectContainer",componentId:"sc-8428a551-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]);let Pp={[c.mainnet.id]:"ethereum",[c.base.id]:"base",[c.optimism.id]:"optimism",[c.polygon.id]:"polygon",[c.arbitrum.id]:"arbitrum",[c.avalanche.id]:"avacchain"};const Np=(e,t,n,r,i,a)=>new Promise((async(o,s)=>{let l=Oa();if(!l)return void s(Error("Unable to initialize flow"));let u="ethereum"===t.chainType?function(e){let t=Pp[e];if(!t)throw new d.PrivyClientError(`Unsupported chainId: ${e} for Coinbase Onramp`);return t}(t.chain.id):"solana",p=t.isUSDC?"USDC":"ethereum"===t.chainType?c.toCoinbaseAssetId(t.chain.id,"native-currency"):"SOL",h=await e.initCoinbaseOnRamp({addresses:[{address:t.address,blockchains:[u]}],assets:[p]}),{url:g}=c.getCoinbaseOnRampUrl({appId:e.getAppId(),input:h,amount:t.amount,blockchain:u,asset:p,experience:a});l.location=g.toString();let m={...i?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(m.usingDefaultFundingMethod=!1),n({funding:m,solanaFundingData:i?.solanaFundingData,coinbaseOnrampStatus:{popup:l}}),r(Tp),e.createAnalyticsEvent({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"coinbase-onramp",value:t.amount,chainType:t.chainType,chainId:"ethereum"===t.chainType?t.chain.id:t.chain}}),setTimeout((()=>{n({funding:m,solanaFundingData:i?.solanaFundingData,coinbaseOnrampStatus:{partnerUserId:h.partner_user_id,popup:l}})}),5e3),o()})),_p="moonpay";function Mp(e){return parseFloat(e)}function Fp(e,t=!1){let[i,a]=n.useState(null),{createAnalyticsEvent:o}=r.usePrivyInternal(),{data:s,navigate:l,setModalData:c}=Jn(),d=s?.funding,u=n.useRef(0);return n.useEffect((()=>{let n=setInterval((async()=>{if(e)try{let[r]=await async function(e,t){return ie.ofetch(`https://api.moonpay.com/v1/transactions/ext/${e}`,{query:{apiKey:t?"pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI":"pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL"}})}(e,t),i="waitingAuthorization"===r.status&&"credit_debit_card"===r.paymentMethod?"pending":r.status;if(["failed","completed","awaitingAuthorization"].includes(i)&&(o({eventName:Dc,payload:{status:i,provider:_p,paymentMethod:r.paymentMethod,cardPaymentType:r.cardPaymentType,currency:r.currency?.code,baseCurrencyAmount:r.baseCurrencyAmount,quoteCurrencyAmount:r.quoteCurrencyAmount,feeAmount:r.feeAmount,extraFeeAmount:r.extraFeeAmount,networkFeeAmount:r.networkFeeAmount,isSandbox:t}}),clearInterval(n)),"failed"===i||"serviceFailure"===i)return c({funding:{...d,errorMessage:"Something went wrong adding funds from Moonpay. Please try again or use another method to fund your wallet."},solanaFundingData:s?.solanaFundingData}),void l($p);a(i)}catch(e){404!==e.response?.status&&(u.current+=1),u.current>=3&&(o({eventName:Dc,payload:{status:"serviceFailure",provider:_p}}),clearInterval(n),c({funding:{...d,errorMessage:"Something went wrong adding funds from Moonpay. Please try again or use another method to fund your wallet."},solanaFundingData:s?.solanaFundingData}),l($p))}}),3e3);return()=>clearInterval(n)}),[e,u]),i}const Lp=({size:t=61,...n})=>/*#__PURE__*/e.jsx("svg",{width:t,height:t,viewBox:"0 0 61 61",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:/*#__PURE__*/e.jsxs("g",{id:"moonpay_symbol_wht 2",children:[/*#__PURE__*/e.jsx("rect",{x:"1.3374",y:"1",width:"59",height:"59",rx:"11.5",fill:"#7715F5"}),/*#__PURE__*/e.jsx("path",{id:"Vector",d:"M43.8884 23.3258C45.0203 23.3258 46.1268 22.9901 47.068 22.3613C48.0091 21.7324 48.7427 20.8386 49.1759 19.7928C49.6091 18.747 49.7224 17.5962 49.5016 16.4861C49.2807 15.3759 48.7357 14.3561 47.9353 13.5557C47.1349 12.7553 46.1151 12.2102 45.0049 11.9893C43.8947 11.7685 42.7439 11.8819 41.6982 12.3151C40.6524 12.7482 39.7585 13.4818 39.1297 14.423C38.5008 15.3641 38.1651 16.4707 38.1651 17.6026C38.165 18.3542 38.3131 19.0985 38.6007 19.7929C38.8883 20.4873 39.3098 21.1182 39.8413 21.6496C40.3728 22.1811 41.0037 22.6027 41.6981 22.8903C42.3925 23.1778 43.1367 23.3259 43.8884 23.3258ZM26.3395 49.1017C23.5804 49.1017 20.8832 48.2836 18.5891 46.7507C16.295 45.2178 14.5069 43.039 13.4511 40.49C12.3952 37.9409 12.1189 35.1359 12.6572 32.4298C13.1955 29.7237 14.5241 27.238 16.4751 25.287C18.4262 23.336 20.9118 22.0074 23.6179 21.4691C26.324 20.9308 29.129 21.2071 31.6781 22.2629C34.2272 23.3189 36.406 25.1069 37.9389 27.401C39.4717 29.6952 40.2899 32.3923 40.2899 35.1514C40.2899 36.9835 39.9291 38.7975 39.2281 40.49C38.527 42.1826 37.4994 43.7205 36.204 45.0159C34.9086 46.3113 33.3707 47.3389 31.6781 48.04C29.9856 48.741 28.1715 49.1018 26.3395 49.1017Z",fill:"white"})]})});const Wp={component:()=>{let{data:t,setModalData:n,navigateBack:i}=Jn(),a=Gn(),{closePrivyModal:o}=r.usePrivyInternal(),{externalTransactionId:s}=t?.moonpayStatus,l=Fp(s||null,a.fundingMethodConfig.moonpay.useSandbox??!1);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vr,{title:"Fund account",backFn:()=>{let e={...t?.funding,showAlternateFundingMethod:!0};e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),n({funding:e,solanaFundingData:t?.solanaFundingData}),i()}}),/*#__PURE__*/e.jsx(Dp,{status:l,onClickCta:o}),/*#__PURE__*/e.jsx(vr,{})]})}};let Dp=({status:t,onClickCta:r})=>{let{title:i,body:a,cta:o}=n.useMemo((()=>(e=>{switch(e){case"completed":return{title:"You've funded your account!",body:"It may take a few minutes for the assets to appear.",cta:"Continue"};case"waitingAuthorization":return{title:"Processing payment",body:"This may take up to a few hours. You will receive an email when the purchase is complete.",cta:"Continue"};default:return{title:"In Progress",body:"Go back to MoonPay to finish funding your account.",cta:""}}})(t)),[t]);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsxs(Bp,{children:[/*#__PURE__*/e.jsx(Rp,{status:t}),/*#__PURE__*/e.jsxs(Xi,{children:[/*#__PURE__*/e.jsx("h3",{children:i}),/*#__PURE__*/e.jsx(Op,{children:a})]})]}),o&&/*#__PURE__*/e.jsx(Nr,{onClick:r,children:o})]})},Rp=({status:t})=>{if(!t||"pending"===t){let t="var(--privy-color-foreground-4)";/*#__PURE__*/return e.jsxs("div",{style:{position:"relative"},children:[/*#__PURE__*/e.jsx(Tr,{color:t,style:{position:"absolute"}}),/*#__PURE__*/e.jsx(Ar,{color:t}),/*#__PURE__*/e.jsx(Lp,{size:"3rem",style:{position:"absolute",top:"1rem",left:"1rem"}})]})}let n=(t=>{switch(t){case"completed":return Pe.default;case"waitingAuthorization":return()=>/*#__PURE__*/e.jsx(Ue.default,{width:"3rem",height:"3rem",style:{backgroundColor:"var(--privy-color-foreground-4)",color:"var(--privy-color-background)",borderRadius:"100%",padding:"0.5rem",margin:"0.5rem"}});default:return}})(t),r=(e=>e?{completed:"var(--privy-color-success)",failed:"var(--privy-color-error)",serviceFailure:"var(--privy-color-error)",waitingAuthorization:"var(--privy-color-accent)",pending:"var(--privy-color-foreground-4)"}[e]:"var(--privy-color-foreground-4)")(t);/*#__PURE__*/return e.jsx("div",{style:{borderColor:r,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:n&&/*#__PURE__*/e.jsx(n,{width:"4rem",height:"4rem",color:r})})},Op=/*#__PURE__*/a.styled.p.withConfig({displayName:"StatusBody",componentId:"sc-727a5a8d-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),Bp=/*#__PURE__*/a.styled.div.withConfig({displayName:"ConnectContainer",componentId:"sc-727a5a8d-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]);const Up=async(e,t,n,r,i,a,o,s)=>{let l=Oa();if(!l)throw Error("Unable to initialize flow");let d="ethereum"===t.chainType?c.chainToMoonpayCurrency(t.chain.id,r):t.isUSDC?"USDC_SOL":"SOL",{signedUrl:u,externalTransactionId:p}=await e.signMoonpayOnRampUrl({address:t.address,useSandbox:n.fundingMethodConfig.moonpay.useSandbox??!1,config:{uiConfig:{accentColor:n.appearance.palette.accent,theme:n.appearance.palette.colorScheme},paymentMethod:s,currencyCode:d,quoteCurrencyAmount:Mp(t.amount)}});e.createAnalyticsEvent({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"moonpay",value:t.amount,chainType:t.chainType,chainId:"ethereum"===t.chainType?t.chain.id:t.chain}}),l.location=u;let h={...o?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(h.usingDefaultFundingMethod=!1),i({moonpayStatus:{},funding:h,solanaFundingData:o?.solanaFundingData}),a(Wp),setTimeout((()=>{i({moonpayStatus:{externalTransactionId:p},funding:h,solanaFundingData:o?.solanaFundingData})}),8e3)};let zp=async e=>"undefined"!=typeof window&&"PaymentRequest"in window&&await new window.PaymentRequest([{supportedMethods:e}],{id:"0",total:{label:"Item",amount:{currency:"USD",value:"1.00"}}}).canMakePayment();const Hp=()=>zp("https://apple.com/apple-pay"),Vp=()=>zp("https://google.com/pay"),$p={component:()=>{let{wallets:t}=_a(),{connectors:i}=r.usePrivyInternal(),a=i.filter(En).flatMap((e=>e.wallets)),{navigate:o,data:s,setModalData:l}=Jn(),{client:d}=r.usePrivyInternal(),u=Gn(),p=s?.funding,h=xu(Hp),g=xu(Vp),m="solana"===p.chainType,y=m?void 0:p,f=n.useMemo((()=>((e,t,n,r,i,a)=>{let o,s,l="solana"===n.chainType,d=l?void 0:n,u=n.isUSDC?"USDC":d?.erc20Address?void 0:"native-currency",p=!!l||u&&c.isSupportedChainIdForMoonpay(Number(n.chain.id),u),h=!!l||u&&c.isSupportedChainIdForCoinbaseOnramp(Number(n.chain.id),u),g=[];for(let o of(n.preferredCardProvider&&n.supportedOptions.sort((e=>e.provider===n.preferredCardProvider?-1:1)),n.supportedOptions))"card"===o.method&&"coinbase"===o.provider&&h&&g.push((()=>Np(t,n,r,i,a,"buy"))),"card"===o.method&&"moonpay"===o.provider&&p&&u&&g.push((()=>Up(t,n,e,u,r,i,a,"credit_debit_card")));for(let e of n.supportedOptions)"exchange"===e.method&&"coinbase"===e.provider&&h&&(o=()=>Np(t,n,r,i,a,"buy"));for(let e of a?.funding?.supportedOptions??[])"wallets"===e.method&&(s=()=>i(jp));return{onFundWithCard:g,onFundWithExchange:o,onFundWithWallet:s}})(u,d,p,l,o,s)),[u,d,p,s,l,o]),x=m?a.find((({address:e})=>e===p.address)):t.find((({address:e})=>V.getAddress(e)===V.getAddress(p.address))),v=_n(x?.walletClientType||"unknown"),w=v?.name||"wallet",C=x&&"privy"!==x.walletClientType?w:u.name,b=n.useMemo((()=>p.uiConfig?.landing?.title?p.uiConfig?.landing?.title:`Add funds to your ${C?.toLowerCase().endsWith("wallet")?C:C+" wallet"}`),[p.uiConfig?.landing?.title,C]);n.useEffect((()=>{if(p?.defaultFundingMethod&&p.usingDefaultFundingMethod)switch(l({funding:{...p,usingDefaultFundingMethod:!1},solanaFundingData:s?.solanaFundingData}),p?.defaultFundingMethod){case"card":f.onFundWithCard[0]&&f.onFundWithCard[0]();break;case"exchange":f.onFundWithExchange&&f.onFundWithExchange();break;case"wallet":f.onFundWithWallet&&f.onFundWithWallet();break;case"manual":o(Hc)}}),[]),n.useEffect((()=>{y?.erc20Address&&!y.erc20ContractInfo&&qc({address:y.erc20Address,chain:y.chain,rpcConfig:u.rpcConfig,privyAppId:u.id}).then((e=>{l({...s,funding:{...y,erc20ContractInfo:e?{symbol:e.symbol,decimals:e.decimals}:void 0}})})).catch(console.error)}),[y?.erc20Address,y?.chain]);let j=!(!y?.erc20Address||y?.erc20ContractInfo);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(mu,{}),/*#__PURE__*/e.jsx("h3",{children:b}),/*#__PURE__*/e.jsxs(ap,{children:[p.errorMessage&&/*#__PURE__*/e.jsx(md,{theme:u.appearance.palette.colorScheme,children:p.errorMessage}),f.onFundWithCard?.[0]&&/*#__PURE__*/e.jsxs(ur,{disabled:j,onClick:f.onFundWithCard[0],children:[/*#__PURE__*/e.jsx(op,{children:/*#__PURE__*/e.jsx(Oe.default,{style:{width:24}})}),"Pay with card",h?/*#__PURE__*/e.jsx(yu,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):g?/*#__PURE__*/e.jsx(fu,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):null]}),f.onFundWithExchange&&/*#__PURE__*/e.jsxs(ur,{disabled:j,onClick:f.onFundWithExchange,children:[/*#__PURE__*/e.jsx(op,{children:/*#__PURE__*/e.jsx(Ue.default,{style:{width:24}})}),"Transfer from an exchange"]}),f.onFundWithWallet&&/*#__PURE__*/e.jsxs(ur,{disabled:j,onClick:f.onFundWithWallet,children:[/*#__PURE__*/e.jsx(op,{children:/*#__PURE__*/e.jsx(Al,{style:{width:24}})}),"Transfer from wallet"]}),/*#__PURE__*/e.jsxs(ur,{disabled:j,onClick:()=>o(Hc),children:[/*#__PURE__*/e.jsx(op,{children:/*#__PURE__*/e.jsx(Be.default,{style:{width:24}})}),"Receive funds"]}),p?.showAlternateFundingMethod&&f.onFundWithCard?.[1]&&/*#__PURE__*/e.jsx(wc,{theme:u.appearance.palette.colorScheme,children:/*#__PURE__*/e.jsxs(hp,{children:["Having trouble or facing location restrictions?"," ",/*#__PURE__*/e.jsx(gp,{onClick:f.onFundWithCard[1],children:"Try a different provider."})]})})]}),/*#__PURE__*/e.jsx(vr,{})]})}},qp={component:()=>{let{closePrivyModal:t}=r.usePrivyInternal(),{data:i,navigate:a}=Jn(),o=Gn(),s=ir(),l=i?.externalConnectWallet?.description,c=n.useRef(i?.externalConnectWallet?.walletList??o.appearance.walletList),u=n.useRef(i?.externalConnectWallet?.walletChainType??o.appearance.walletChainType);/*#__PURE__*/return e.jsx(Vl,{walletList:c.current,walletChainType:u.current,preSelectedWalletId:i?.externalConnectWallet?.preSelectedWalletId,onBack:i?.funding?()=>a($p):void 0,onClose:()=>{s("connectWallet","onError",d.PrivyErrorCode.GENERIC_CONNECT_WALLET_ERROR),t()},onConnect:({connector:e,wallet:n})=>{s("connectWallet","onSuccess",{wallet:n});let r=i?.externalConnectWallet?.onCompleteNavigateTo;r?a(r({address:n.address,walletClientType:e?.walletClientType,walletChainType:e?.chainType})):t()},onConnectError:e=>{e instanceof d.PrivyError?(console.warn(e.cause?e.cause:e.message),s("connectWallet","onError",e.privyErrorCode||d.PrivyErrorCode.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),s("connectWallet","onError",d.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR))},customDescription:l,app:o})},isUnauthenticatedScreem:!0},Gp=t=>/*#__PURE__*/e.jsxs("svg",{width:"33",height:"32",viewBox:"0 0 33 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[/*#__PURE__*/e.jsx("rect",{x:"0.5",width:"32",height:"32",rx:"4",fill:"#855DCD"}),/*#__PURE__*/e.jsxs("g",{"clip-path":"url(#clip0_1715_1960)",children:[/*#__PURE__*/e.jsx("path",{d:"M4.5 4H28.5V28H4.5V4Z",fill:"#855DCD"}),/*#__PURE__*/e.jsx("path",{d:"M11.1072 8.42105H21.6983V23.5789H20.1437V16.6357H20.1284C19.9566 14.7167 18.3542 13.2129 16.4028 13.2129C14.4514 13.2129 12.849 14.7167 12.6771 16.6357H12.6619V23.5789H11.1072V8.42105Z",fill:"white"}),/*#__PURE__*/e.jsx("path",{d:"M8.28943 10.5725L8.92101 12.7239H9.45542V21.4275C9.1871 21.4275 8.96959 21.6464 8.96959 21.9165V22.5032H8.87242C8.60411 22.5032 8.38659 22.7221 8.38659 22.9922V23.5789H13.8279V22.9922C13.8279 22.7221 13.6104 22.5032 13.3421 22.5032H13.2449V21.9165C13.2449 21.6464 13.0274 21.4275 12.7591 21.4275H12.1761V10.5725H8.28943Z",fill:"white"}),/*#__PURE__*/e.jsx("path",{d:"M20.2408 21.4275C19.9725 21.4275 19.755 21.6464 19.755 21.9165V22.5032H19.6579C19.3895 22.5032 19.172 22.7221 19.172 22.9922V23.5789H24.6133V22.9922C24.6133 22.7221 24.3958 22.5032 24.1275 22.5032H24.0303V21.9165C24.0303 21.6464 23.8128 21.4275 23.5445 21.4275V12.7239H24.0789L24.7105 10.5725H20.8238V21.4275H20.2408Z",fill:"white"})]}),/*#__PURE__*/e.jsx("defs",{children:/*#__PURE__*/e.jsx("clipPath",{id:"clip0_1715_1960",children:/*#__PURE__*/e.jsx("rect",{width:"24",height:"24",fill:"white",transform:"translate(4.5 4)"})})})]}),Yp=t=>{let[r,i]=n.useState(!1);/*#__PURE__*/return e.jsx(Zp,{color:t.color,href:t.url,target:"_blank",rel:"noreferrer noopener",onClick:()=>{i(!0),setTimeout((()=>i(!1)),1500)},justOpened:r,children:t.text})};let Zp=/*#__PURE__*/a.styled.a.withConfig({displayName:"StyledOpenLinkButton",componentId:"sc-4e695c83-0"})(["display:flex;align-items:center;gap:6px;&&{margin:8px 2px;font-size:14px;color:",";font-weight:",";transition:color 350ms ease;:focus,:active{background-color:transparent;border:none;outline:none;box-shadow:none;}:hover{color:",";}:active{color:'var(--privy-color-foreground)';font-weight:medium;}@media (max-width:440px){margin:12px 2px;}}svg{width:14px;height:14px;}"],(e=>e.justOpened?"var(--privy-color-foreground)":e.color||"var(--privy-color-foreground-3)"),(e=>e.justOpened?"medium":"normal"),(e=>e.justOpened?"var(--privy-color-foreground)":"var(--privy-color-foreground-2)")),Kp=/*#__PURE__*/a.styled.div.withConfig({displayName:"Container",componentId:"sc-913deead-0"})(["width:100%;"]),Qp=/*#__PURE__*/a.styled.div.withConfig({displayName:"InputContainer",componentId:"sc-913deead-1"})(["display:flex;align-items:center;justify-content:space-between;gap:0.75rem;padding:0.75rem;height:56px;background:",";border:1px solid var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);&:hover{border-color:",";}"],(e=>e.$disabled?"var(--privy-color-background-2)":"var(--privy-color-background)"),(e=>e.$disabled?"var(--privy-color-foreground-4)":"var(--privy-color-foreground-3)")),Xp=/*#__PURE__*/a.styled.div.withConfig({displayName:"TextContainer",componentId:"sc-913deead-2"})(["flex:1;min-width:0;display:flex;align-items:center;"]),Jp=/*#__PURE__*/a.styled.span.withConfig({displayName:"Text",componentId:"sc-913deead-3"})(["display:block;font-size:16px;line-height:24px;color:",";overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;word-break:break-all;@media (min-width:441px){font-size:14px;line-height:20px;}"],(e=>e.$disabled?"var(--privy-color-foreground-2)":"var(--privy-color-foreground)")),eh=/*#__PURE__*/a.styled(Jp).withConfig({displayName:"PlaceholderText",componentId:"sc-913deead-4"})(["color:var(--privy-color-foreground-3);font-style:italic;"]),th=/*#__PURE__*/a.styled(Tc).withConfig({displayName:"TitleLabel",componentId:"sc-913deead-5"})(["margin-bottom:0.5rem;"]),nh=/*#__PURE__*/a.styled(Lr).withConfig({displayName:"CopyButton",componentId:"sc-913deead-6"})(["&&{gap:0.375rem;font-size:14px;flex-shrink:0;}"]);const rh=({value:r,title:i,placeholder:a,className:o,showCopyButton:s=!0,truncate:l,maxLength:c=40,disabled:d=!1})=>{let[u,p]=n.useState(!1),h=l&&r?((e,t,n)=>{if((e=e.startsWith("https://")?e.slice(8):e).length<=n)return e;if("middle"===t){let t=Math.ceil(n/2)-2,r=Math.floor(n/2)-1;return`${e.slice(0,t)}...${e.slice(-r)}`}return`${e.slice(0,n-3)}...`})(r,l,c):r;return n.useEffect((()=>{if(u){let e=setTimeout((()=>p(!1)),3e3);return()=>clearTimeout(e)}}),[u]),/*#__PURE__*/e.jsxs(Kp,{className:o,children:[i&&/*#__PURE__*/e.jsx(th,{children:i}),/*#__PURE__*/e.jsxs(Qp,{$disabled:d,children:[/*#__PURE__*/e.jsx(Xp,{children:r?/*#__PURE__*/e.jsx(Jp,{$disabled:d,title:r,children:h}):/*#__PURE__*/e.jsx(eh,{$disabled:d,children:a||"No value"})}),s&&r&&/*#__PURE__*/e.jsx(nh,{onClick:function(e){e.stopPropagation(),navigator.clipboard.writeText(r).then((()=>p(!0))).catch(console.error)},size:"sm",children:u?/*#__PURE__*/e.jsxs(e.Fragment,{children:["Copied",/*#__PURE__*/e.jsx(t.Check,{size:14})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:["Copy",/*#__PURE__*/e.jsx(t.Copy,{size:14})]})})]})]})},ih=({connectUri:t,loading:n,success:r,errorMessage:i,onBack:a,onClose:o,onOpenFarcaster:s})=>v.isMobile||n?v.isIOS?/*#__PURE__*/e.jsx(ji,{title:i?i.message:"Sign in with Farcaster",subtitle:i?i.detail:"To sign in with Farcaster, please open the Farcaster app.",icon:Gp,iconVariant:"loading",iconLoadingStatus:{success:r,fail:!!i},primaryCta:t&&s?{label:"Open Farcaster app",onClick:s}:void 0,onBack:a,onClose:o,watermark:!0}):/*#__PURE__*/e.jsx(ji,{title:i?i.message:"Signing in with Farcaster",subtitle:i?i.detail:"This should only take a moment",icon:Gp,iconVariant:"loading",iconLoadingStatus:{success:r,fail:!!i},onBack:a,onClose:o,watermark:!0,children:t&&v.isMobile&&/*#__PURE__*/e.jsx(oh,{children:/*#__PURE__*/e.jsx(Yp,{text:"Take me to Farcaster",url:t,color:"#8a63d2"})})}):
|
|
25
25
|
/*#__PURE__*/e.jsx(ji,{title:"Sign in with Farcaster",subtitle:"Scan with your phone's camera to continue.",onBack:a,onClose:o,watermark:!0,children:/*#__PURE__*/e.jsxs(sh,{children:[/*#__PURE__*/e.jsx(lh,{children:t?/*#__PURE__*/e.jsx(wl,{url:t,size:275,squareLogoElement:Gp}):/*#__PURE__*/e.jsx(uh,{children:/*#__PURE__*/e.jsx(Tr,{})})}),/*#__PURE__*/e.jsxs(ch,{children:[/*#__PURE__*/e.jsx(dh,{children:"Or copy this link and paste it into a phone browser to open the Farcaster app."}),t&&/*#__PURE__*/e.jsx(rh,{value:t,truncate:"end",maxLength:30,showCopyButton:!0,disabled:!0})]})]})}),ah={component:()=>{let{authenticated:t,logout:a,ready:o,user:s}=i.usePrivyContext(),{lastScreen:l,navigate:c,navigateBack:u,setModalData:p}=Jn(),h=Gn(),{getAuthFlow:g,loginWithFarcaster:m,closePrivyModal:y,createAnalyticsEvent:f}=r.usePrivyInternal(),[x,v]=n.useState(void 0),[w,C]=n.useState(!1),[b,j]=n.useState(!1),k=n.useRef([]),T=g(),A=T?.meta.connectUri;return n.useEffect((()=>{let e=Date.now(),t=setInterval((async()=>{let n=await T.pollForReady.execute(),r=Date.now()-e;if(n){clearInterval(t),C(!0);try{await m(),j(!0)}catch(e){let t={retryable:!1,message:"Authentication failed"};if(e?.privyErrorCode===d.PrivyErrorCode.ALLOWLIST_REJECTED)return void c(ic);if(e?.privyErrorCode===d.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new d.PrivyUserLimitReachedError(e).toString()),void c(gc);if(e?.privyErrorCode===d.PrivyErrorCode.USER_DOES_NOT_EXIST)return void c(ws);if(e?.privyErrorCode===d.PrivyErrorCode.LINKED_TO_ANOTHER_USER)t.detail=e.message??"This account has already been linked to another user.";else{if(e?.privyErrorCode===d.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return p({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:"farcaster",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,farcasterEmbeddedAddress:e.data?.data?.otherUser?.farcasterEmbeddedAddress}}),void c(Xs);e?.privyErrorCode===d.PrivyErrorCode.INVALID_CREDENTIALS?(t.retryable=!0,t.detail="Something went wrong. Try again."):e?.privyErrorCode===d.PrivyErrorCode.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again.")}v(t)}}else r>12e4&&(clearInterval(t),v({retryable:!0,message:"Authentication failed",detail:"The request timed out. Try again."}))}),2e3);return()=>{clearInterval(t),k.current.forEach((e=>clearTimeout(e)))}}),[]),n.useEffect((()=>{if(o&&t&&b&&s){if(h?.legal.requireUsersAcceptTerms&&!s.hasAcceptedTerms){let e=setTimeout((()=>{c(rl)}),it);return()=>clearTimeout(e)}b&&(xs(s,h.embeddedWallets)?k.current.push(setTimeout((()=>{p({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),f({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"FarcasterConnectStatusScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),c(nl)}),it)):k.current.push(setTimeout((()=>y({shouldCallAuthOnSuccess:!0,isSuccess:!0})),it)))}}),[b,o,t,s]),/*#__PURE__*/e.jsx(ih,{connectUri:A,loading:w,success:b,errorMessage:x,onBack:l?u:void 0,onClose:y,onOpenFarcaster:()=>{A&&(window.location.href=A)}})}};let oh=/*#__PURE__*/a.styled.div.withConfig({displayName:"MobileLinkContainer",componentId:"sc-6e4b180b-0"})(["margin-top:24px;"]),sh=/*#__PURE__*/a.styled.div.withConfig({displayName:"ContentContainer",componentId:"sc-6e4b180b-1"})(["display:flex;flex-direction:column;align-items:center;gap:24px;"]),lh=/*#__PURE__*/a.styled.div.withConfig({displayName:"QrContainer",componentId:"sc-6e4b180b-2"})(["display:flex;align-items:center;justify-content:center;min-height:275px;"]),ch=/*#__PURE__*/a.styled.div.withConfig({displayName:"InstructionsContainer",componentId:"sc-6e4b180b-3"})(["display:flex;flex-direction:column;align-items:center;gap:16px;"]),dh=/*#__PURE__*/a.styled.div.withConfig({displayName:"InstructionText",componentId:"sc-6e4b180b-4"})(["font-size:0.875rem;text-align:center;color:var(--privy-color-foreground-2);"]),uh=/*#__PURE__*/a.styled.div.withConfig({displayName:"LoaderWrapper",componentId:"sc-6e4b180b-5"})(["position:relative;width:82px;height:82px;"]);const ph=()=>{let[t,i]=n.useState(!1),{currentScreen:a,navigate:o,setModalData:s,data:l}=Jn(),{enabled:c,token:d}=Gt(),{initLoginWithFarcaster:u}=r.usePrivyInternal(),{accountType:p}=os();/*#__PURE__*/return e.jsxs(ur,{onClick:async()=>{i(!0);try{c&&!d?(s({captchaModalData:{callback:e=>u(e,l?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:ah,onErrorNavigateTo:Os}}),o(oc)):(await u(d,l?.login?.disableSignup),o(ah))}catch(e){s({errorModalData:{error:e,previousScreen:a||dg}}),o(Os)}finally{i(!1)}},disabled:!1,children:[/*#__PURE__*/e.jsx(Gp,{width:32,height:32})," Farcaster",t&&/*#__PURE__*/e.jsx(Sr,{}),"farcaster"===p&&/*#__PURE__*/e.jsx(hh,{color:"gray",children:"Recent"})]})};let hh=/*#__PURE__*/a.styled(vu).withConfig({displayName:"StyledChip",componentId:"sc-c6317ff9-0"})(["margin-left:auto;"]);const gh=({status:n,passkeySignupFlow:r=!1,error:i,onRetry:a})=>/*#__PURE__*/e.jsx(ji,{title:(()=>{switch(n){case"loading":return"Waiting for passkey";case"success":return"Success";case"error":return"Something went wrong"}})(),subtitle:/*#__PURE__*/e.jsx(yh,{children:(()=>{switch(n){case"loading":return r?"Please follow prompts to register your passkey.":"Please follow prompts to verify your passkey.\nYou will have to sign up with another method first to register a passkey for your account.";case"success":return"You've successfully logged in with your passkey.";case"error":if(i instanceof d.PrivyError){if(i.privyErrorCode===d.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE)return"Cannot link more passkeys to account.";if(i.privyErrorCode===d.PrivyErrorCode.PASSKEY_NOT_ALLOWED)return"Passkey request timed out or rejected by user.\nYou will have to sign up with another method first to register a passkey for your account."}return"An unknown error occurred.\nYou will have to sign up with another method first to register a passkey for your account."}})()}),icon:t.FingerprintIcon,iconVariant:"loading",iconLoadingStatus:{success:"success"===n,fail:"error"===n},primaryCta:"error"===n&&a?{label:"Retry",onClick:a}:"success"===n?{label:"Continue",disabled:!0}:void 0,watermark:!0}),mh={component:()=>{let{data:t,setModalData:a,navigate:o}=Jn(),s=Gn(),{loginWithPasskey:l,signupWithPasskey:c,closePrivyModal:d,createAnalyticsEvent:u}=r.usePrivyInternal(),{user:p,logout:h}=i.usePrivyContext(),{passkeySignupFlow:g}=t?.passkeyAuthModalData??{},[m,y]=n.useState("loading"),[f,x]=n.useState(null),v=n.useRef([]),w=e=>{v.current=[e,...v.current]};n.useEffect((()=>()=>{v.current.forEach((e=>clearTimeout(e))),v.current=[]}),[]);let C=async()=>{y("loading");try{g?await c():await l(),y("success")}catch(e){x(e),y("error")}};return n.useEffect((()=>{if("success"===m&&p){if(s?.legal.requireUsersAcceptTerms&&!p.hasAcceptedTerms)return void w(setTimeout((()=>{o(rl)}),900));if(!xs(p,s?.embeddedWallets))return void w(setTimeout((()=>{d({shouldCallAuthOnSuccess:!0,isSuccess:!0})}),it));w(setTimeout((()=>{a({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),u({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"PasskeyStatusScreen"}}),h()},callAuthOnSuccessOnClose:!0}}),o(nl)}),900))}}),[p,m]),n.useEffect((()=>{C()}),[]),/*#__PURE__*/e.jsx(gh,{status:m,passkeySignupFlow:g,error:f,onRetry:C})}};let yh=/*#__PURE__*/a.styled.span.withConfig({displayName:"SubtitleText",componentId:"sc-7ff4a13e-0"})(["white-space:pre-wrap;"]);const fh=({title:n="Log in or create a new account?",subtitle:r="Create a new account with a passkey or use a passkey to log in to an existing account.",onSignup:i,onLogin:a})=>/*#__PURE__*/e.jsx(ji,{title:n,subtitle:r,icon:t.FingerprintIcon,primaryCta:{label:"Create new account",onClick:i},secondaryCta:{label:"Log in with a passkey",onClick:a},watermark:!0}),xh={component:()=>{let{enabled:t,token:n}=Gt(),{navigate:i,setModalData:a}=Jn(),{initSignupWithPasskey:o,initLoginWithPasskey:s}=r.usePrivyInternal();/*#__PURE__*/return e.jsx(fh,{onSignup:async()=>{t&&!n?(a({passkeyAuthModalData:{passkeySignupFlow:!0},captchaModalData:{callback:e=>o({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:mh,onErrorNavigateTo:Os}}),i(oc)):(await o({withPrivyUi:!0}),a({passkeyAuthModalData:{passkeySignupFlow:!0}}),i(mh))},onLogin:async()=>{t&&!n?(a({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>s({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:mh,onErrorNavigateTo:Os}}),i(oc)):(await s({withPrivyUi:!0}),a({passkeyAuthModalData:{passkeySignupFlow:!1}}),i(mh))}})}},vh=()=>{let{enabled:t,token:i}=Gt(),{navigate:a,setModalData:o,data:s}=Jn(),l=Gn(),{initLoginWithPasskey:c}=r.usePrivyInternal(),d=()=>{l.loginConfig.passkeysForSignupEnabled?a(xh):(async()=>{t&&!i?(o({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>c({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:mh,onErrorNavigateTo:Os}}),a(oc)):(await c({withPrivyUi:!0}),o({passkeyAuthModalData:{passkeySignupFlow:!1}}),a(mh))})()};return 0===n.useMemo((()=>{let e=s?.login?.loginMethods;return e?e.filter((e=>"passkey"!==e)).length:Object.entries(l.loginMethods).filter((([e,t])=>t)).filter((([e])=>"passkey"!==e)).length}),[l.loginMethods,s?.login])?/*#__PURE__*/e.jsxs(ur,{onClick:d,children:[/*#__PURE__*/e.jsx(Ge.default,{})," Continue with passkey"]}):/*#__PURE__*/e.jsx(hs,{as:"button",onClick:d,size:"sm",variant:"navigation",style:{width:"100%",justifyContent:"center"},children:"I have a passkey"})},wh=({value:t,onChange:n})=>/*#__PURE__*/e.jsx("select",{value:t,onChange:n,children:c.countryCodesAndNumbers.map((t=>/*#__PURE__*/e.jsxs("option",{value:t.code,children:[t.code," +",t.callCode]},t.code)))}),Ch=/*#__PURE__*/n.forwardRef(((t,r)=>{let i=Gn(),[a,o]=n.useState(!1),{accountType:s}=os(),[l,d]=n.useState(""),[u,p]=n.useState(i?.intl.defaultCountry??"US"),h=c.validatePhoneNumber(l,u),g=c.phoneNumberTypingFormatter(u),m=c.getPlaceholderPhoneNumber(u),y=c.getCountryCallingCode(u),f=!h,[x,v]=n.useState(!1),w=y.length,C=e=>{let n=e.target.value;p(n),d(""),t.onChange&&t.onChange({rawPhoneNumber:l,qualifiedPhoneNumber:c.formatPhoneNumber(l,n),countryCode:n,isValid:c.validatePhoneNumber(l,u)})},b=(e,n)=>{try{let r=e.replace(/\D/g,"")===l.replace(/\D/g,"")?e:g.input(e);d(r),t.onChange&&t.onChange({rawPhoneNumber:r,qualifiedPhoneNumber:c.formatPhoneNumber(e,n),countryCode:n,isValid:c.validatePhoneNumber(e,n)})}catch(e){console.error("Error processing phone number:",e)}},j=()=>{v(!0);let e=c.formatPhoneNumber(l,u);t.onSubmit({rawPhoneNumber:l,qualifiedPhoneNumber:e,countryCode:u,isValid:c.validatePhoneNumber(l,u)}).finally((()=>v(!1)))};return n.useEffect((()=>{if(t.defaultValue){let e=c.getPhoneCountryCodeAndNumber(t.defaultValue);g.reset(),C({target:{value:e.countryCode}}),b(e.phone,e.countryCode)}}),[t.defaultValue]),/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(bh,{children:/*#__PURE__*/e.jsxs(jh,{$callingCodeLength:w,$stacked:t.stacked,children:[/*#__PURE__*/e.jsx(wh,{value:u,onChange:C}),/*#__PURE__*/e.jsx("input",{ref:r,id:"phone-number-input",className:"login-method-button",type:"tel",placeholder:m,onFocus:()=>o(!0),onChange:e=>{b(e.target.value,u)},onKeyUp:e=>{"Enter"===e.key&&j()},value:l,autoComplete:"tel"}),"phone"!==s||a||t.hideRecent?t.stacked||t.noIncludeSubmitButton?/*#__PURE__*/e.jsx("span",{}):/*#__PURE__*/e.jsx(Or,{isSubmitting:x,onClick:j,disabled:f,children:"Submit"}):/*#__PURE__*/e.jsx(vu,{color:"gray",children:"Recent"})]})}),t.stacked&&!t.noIncludeSubmitButton?/*#__PURE__*/e.jsx(Nr,{loading:x,loadingText:null,onClick:j,disabled:f,children:"Submit"}):null]})}));let bh=/*#__PURE__*/a.styled.div.withConfig({displayName:"InputContainer",componentId:"sc-545daacd-0"})(["width:100%;"]),jh=/*#__PURE__*/a.styled.label.withConfig({displayName:"PhoneNumberInput",componentId:"sc-545daacd-1"})(["--country-code-dropdown-width:calc(54px + calc(12 * ","px));--phone-input-extra-padding-left:calc(12px + calc(3 * ","px));display:block;position:relative;width:100%;@media (min-width:441px){--country-code-dropdown-width:calc(52px + calc(10 * ","px));}&& > select{font-size:16px;height:24px;position:absolute;margin:13px calc(var(--country-code-dropdown-width) / 4);line-height:24px;width:var(--country-code-dropdown-width);background-color:var(--privy-color-background);background-size:auto;background-position-x:right;cursor:pointer;@media (min-width:441px){font-size:14px;width:var(--country-code-dropdown-width);}:focus{outline:none;box-shadow:none;}}&& > input{font-size:16px;line-height:24px;color:var(--privy-color-foreground);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;width:calc(100% - var(--country-code-dropdown-width));padding:12px 88px 12px calc(var(--country-code-dropdown-width) + var(--phone-input-extra-padding-left));padding-right:",";flex-grow:1;background:var(--privy-color-background);border:1px solid var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);width:100%;:focus{outline:none;border-color:var(--privy-color-accent);}:autofill,:-webkit-autofill{background:var(--privy-color-background);}@media (min-width:441px){font-size:14px;padding-right:78px;}}&& > :last-child{right:16px;position:absolute;top:50%;transform:translate(0,-50%);}&& > button:last-child{right:0px;line-height:24px;padding:13px 17px;:focus{outline:none;border-color:var(--privy-color-accent);}}&& > input::placeholder{color:var(--privy-color-foreground-3);}"],(e=>e.$callingCodeLength),(e=>e.$callingCodeLength),(e=>e.$callingCodeLength),(e=>e.$stacked?"16px":"88px"));const kh=({isEditable:a,setIsEditable:o,defaultValue:s})=>{let l=n.useRef(null),{authenticated:c}=i.usePrivyContext(),{navigate:d,setModalData:u,currentScreen:p,data:h}=Jn(),{initLoginWithSms:g}=r.usePrivyInternal(),{enabled:m,token:y}=Gt(),{whatsAppEnabled:f}=Gn();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(hr,{$if:!a,children:/*#__PURE__*/e.jsx(Ch,{ref:l,onSubmit:async function({qualifiedPhoneNumber:e}){if(!m||y||c)try{await g({phoneNumber:e,captchaToken:y,withPrivyUi:!0,disableSignup:h?.login?.disableSignup}),d(Zh)}catch(e){u({errorModalData:{error:e,previousScreen:p||dg}}),d(Os)}else u({captchaModalData:{callback:t=>g({phoneNumber:e,captchaToken:t,withPrivyUi:!0,disableSignup:h?.login?.disableSignup}),userIntentRequired:!1,onSuccessNavigateTo:Zh,onErrorNavigateTo:Os}}),d(oc)},defaultValue:s})}),/*#__PURE__*/e.jsx(hr,{$if:a,children:/*#__PURE__*/e.jsxs(ur,{onClick:()=>{o(),setTimeout((()=>{l.current?.focus()}),0)},children:[/*#__PURE__*/e.jsx(pr,{children:/*#__PURE__*/e.jsx(t.Smartphone,{})}),"Continue with ",f?"WhatsApp":"SMS"]})})]})};let Th={apple:{logo:yt,displayName:"Apple"},discord:{logo:ft,displayName:"Discord"},github:{logo:xt,displayName:"GitHub"},google:{logo:vt,displayName:"Google"},linkedin:{logo:bt,displayName:"LinkedIn"},spotify:{logo:jt,displayName:"Spotify"},instagram:{logo:wt,displayName:"Instagram"},twitter:{logo:At,displayName:"Twitter"},tiktok:{logo:kt,displayName:"TikTok"},line:{logo:Ct,displayName:"LINE"},twitch:{logo:Tt,displayName:"Twitch"}};const Ah=({provider:t})=>{let{enabled:a,token:o}=Gt(),{navigate:s,setModalData:l,data:c}=Jn(),[d,u]=n.useState(!1),p=Gn(),{initLoginWithOAuth:h}=r.usePrivyInternal(),{accountType:g}=os(),m=n.useMemo((()=>g&&"guest"!==g&&"authorization_key"!==g&&"cross_app"!==g?ts(g):null),[g]),{displayName:y,logo:f}=n.useMemo((()=>{if(i.isCustomOAuthProvider(t)){let n=p.customOAuthProviders.find((e=>e.provider===t)),r=n.provider_icon_url,i=n.provider_display_name;return{displayName:i,logo:({style:t})=>/*#__PURE__*/e.jsx("img",{alt:`${i} logo`,src:r,style:t})}}return Th[t]}),[t,p.customOAuthProviders]);/*#__PURE__*/return e.jsxs(ur,{onClick:()=>{u(!0),setTimeout((()=>{u(!1)}),2e3),a&&!o?(l({captchaModalData:{callback:e=>h(t,e,c?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:Os}}),s(oc)):h(t,void 0,c?.login?.disableSignup)},disabled:d,children:[/*#__PURE__*/e.jsx(pr,{$fullSize:!0,children:/*#__PURE__*/e.jsx(f,{style:{width:"32px",height:"32px"}})}),y,m?.loginMethod===t&&/*#__PURE__*/e.jsx(Sh,{color:"gray",children:"Recent"})]})};let Sh=/*#__PURE__*/a.styled(vu).withConfig({displayName:"StyledChip",componentId:"sc-45a4e2df-0"})(["margin-left:auto;"]);function Eh(t){/*#__PURE__*/return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",...t,children:[/*#__PURE__*/e.jsx("rect",{width:"512",height:"512",rx:"15%",fill:"#37aee2"}),/*#__PURE__*/e.jsx("path",{fill:"#c8daea",d:"M199 404c-11 0-10-4-13-14l-32-105 245-144"}),/*#__PURE__*/e.jsx("path",{fill:"#a9c9dd",d:"M199 404c7 0 11-4 16-8l45-43-56-34"}),/*#__PURE__*/e.jsx("path",{fill:"#f6fbfe",d:"M204 319l135 99c14 9 26 4 30-14l55-258c5-22-9-32-24-25L79 245c-21 8-21 21-4 26l83 26 190-121c9-5 17-3 11 4"})]})}const Ih=({success:t,errorMessage:n,onRetry:r})=>{let i=t?"Successfully connected with Telegram":n?n.message:"Verifying connection to Telegram";/*#__PURE__*/return e.jsx(ji,{title:i,subtitle:t?"You're good to go!":n?n.detail:"Just a few moments more",icon:Eh,iconVariant:"loading",iconLoadingStatus:{success:t,fail:!!n},secondaryCta:n?.retryable&&r?{label:"Retry",onClick:r}:void 0,watermark:!0})},Ph={component:()=>{let{authenticated:t,logout:a,ready:o,user:s}=i.usePrivyContext(),{setModalData:l,navigate:c,resetNavigation:u,data:p}=Jn(),h=Gn(),{initLoginWithTelegram:g,loginWithTelegram:m,updateWallets:y,setReadyToTrue:f,closePrivyModal:x,createAnalyticsEvent:v,getAuthMeta:w}=r.usePrivyInternal(),[C,b]=n.useState(!1),[j,k]=n.useState(void 0),T=Gt();async function A(){try{let e=await async function(){let e;if(!t){if(T.enabled&&"error"===T.status)throw new qt(T.error,null,d.PrivyErrorCode.CAPTCHA_FAILURE);return T.enabled&&"success"!==T.status&&(T.execute(),e=await T.waitForResult()),e}}();await m({captchaToken:e}),b(!0),f(!0)}catch(e){if(e?.privyErrorCode===d.PrivyErrorCode.ALLOWLIST_REJECTED)return k(void 0),u(),void c(ic);if(e?.privyErrorCode===d.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new d.PrivyUserLimitReachedError(e).toString()),k(void 0),u(),void c(gc);if(e?.privyErrorCode===d.PrivyErrorCode.USER_DOES_NOT_EXIST)return k(void 0),u(),void c(ws);if(e?.privyErrorCode===d.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return k(void 0),u(),l({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,telegramAuthResult:w()?.telegramAuthResult,telegramWebAppData:w()?.telegramWebAppData,displayName:e.data?.data?.account?.displayName,linkMethod:"telegram",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void c(Xs);let{retryable:t,detail:n}=Yt(e);k({retryable:t,detail:n,message:"Authentication failed"})}}n.useEffect((()=>{A()}),[]),n.useEffect((()=>{if(!(o&&t&&C&&s))return;if(h?.legal.requireUsersAcceptTerms&&!s.hasAcceptedTerms){let e=setTimeout((()=>{c(rl)}),it);return()=>clearTimeout(e)}if(xs(s,h.embeddedWallets)){let e=setTimeout((()=>{l({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),v({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:"telegram",screen:"TelegramAuthScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),c(nl)}),it);return()=>clearTimeout(e)}y();let e=setTimeout((()=>x({shouldCallAuthOnSuccess:!0,isSuccess:!0})),it);return()=>clearTimeout(e)}),[o,t,C,s]);/*#__PURE__*/return e.jsx(Ih,{success:C,errorMessage:j,onRetry:j?.retryable?async()=>{try{k(void 0),p?.telegramAuthModalData?.seamlessAuth||await g(void 0,p?.login?.disableSignup),await A()}catch(e){let{retryable:t,detail:n}=Yt(e);k({retryable:t,detail:n,message:"Authentication failed"})}}:void 0})},isCaptchaRequired:!0},Nh=()=>{let{enabled:t,token:i}=Gt(),{navigate:a,setModalData:o,data:s}=Jn(),[l,c]=n.useState(!1),{initLoginWithTelegram:d}=r.usePrivyInternal(),{accountType:u}=os();async function p(e){try{await d(e,s?.login?.disableSignup),o({telegramAuthModalData:{seamlessAuth:!1}}),a(Ph)}catch(e){console.error(e),c(!1)}}/*#__PURE__*/return e.jsxs(ur,{onClick:async function(){if(c(!0),t&&!i)return o({captchaModalData:{callback:p,userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:Os}}),void a(oc);await p(i)},disabled:l,children:[/*#__PURE__*/e.jsx(Eh,{width:32,height:32}),"Telegram","telegram"===u&&/*#__PURE__*/e.jsx(_h,{color:"gray",children:"Recent"})]})};let _h=/*#__PURE__*/a.styled(vu).withConfig({displayName:"StyledChip",componentId:"sc-4b233cf1-0"})(["margin-left:auto;"]);const Mh=({onClick:t,text:n,icon:r})=>/*#__PURE__*/e.jsxs(ur,{onClick:t,children:[/*#__PURE__*/e.jsx(pr,{children:r}),/*#__PURE__*/e.jsx(ar,{children:n})]}),Fh=({connectOnly:t})=>{let{closePrivyModal:a}=r.usePrivyInternal(),{data:o,setModalData:s,onUserCloseViaDialogOrKeybindRef:l,navigate:d}=Jn(),u=Gn(),p=o?.login,h=u.appearance.walletList,g=p?.walletChainType??u.appearance.walletChainType,{accountType:m,walletClientType:y,chainType:f}=os(),{wallets:x}=Ul({walletList:h,walletChainType:g}),v=n.useMemo((()=>m&&"guest"!==m&&"authorization_key"!==m&&"cross_app"!==m?ts(m):null),[m]),{email:w,sms:C,google:b,twitter:j,discord:k,github:T,spotify:A,instagram:S,tiktok:E,line:I,twitch:P,linkedin:N,apple:_,wallet:M,farcaster:F,telegram:L}=n.useMemo((()=>p?.loginMethods?c.toObjectKeys(p.loginMethods,!0):null),[p])??u.loginMethods,W=u.customOAuthProviders,{passkey:D}=u.loginMethods,R=[w&&"email",C&&"sms",b&&"google",j&&"twitter",k&&"discord",T&&"github",A&&"spotify",S&&"instagram",E&&"tiktok",I&&"line",P&&"twitch",N&&"linkedin",_&&"apple",F&&"farcaster",L&&"telegram",...W.map((e=>e.provider))].filter((e=>!!e)),O=R.length>0,B=n.useMemo((()=>M&&!O?"web3-first":M&&u?.appearance.loginGroupPriority||"web2-first"),[M,O,u?.appearance.loginGroupPriority]),U=u?.appearance.hideDirectWeb2Inputs,[z,H]=n.useState("default"),[V,$]=n.useState(Bh({mostRecentlyUsedAccountType:m,smsAvailable:C,emailAvailable:w,prefilledType:p?.prefill?.type}));n.useEffect((()=>{$(Bh({mostRecentlyUsedAccountType:m,smsAvailable:C,emailAvailable:w,prefilledType:p?.prefill?.type}))}),[w,C,m]);let q=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{H("default")}),150)};l.current=q;let G=[];y&&M?G.push(y):v?.loginMethod&&R.includes(v.loginMethod)&&G.push(v.loginMethod);let Y=n=>{if("email"===n)/*#__PURE__*/return e.jsx(og,{isEditable:"email"===V,setIsEditable:()=>{$("email")},defaultValue:"email"===p?.prefill?.type?p.prefill.value:void 0},n);if("sms"===n)/*#__PURE__*/return e.jsx(kh,{isEditable:"sms"===V,setIsEditable:()=>{$("sms")},defaultValue:"phone"===p?.prefill?.type?p.prefill.value:void 0},n);if("apple"===n)/*#__PURE__*/return e.jsx(Ah,{provider:"apple"},n);if("discord"===n)/*#__PURE__*/return e.jsx(Ah,{provider:"discord"},n);if("farcaster"===n)/*#__PURE__*/return e.jsx(ph,{},n);if("github"===n)/*#__PURE__*/return e.jsx(Ah,{provider:"github"},n);if("google"===n)/*#__PURE__*/return e.jsx(Ah,{provider:"google"},n);if("linkedin"===n)/*#__PURE__*/return e.jsx(Ah,{provider:"linkedin"},n);if("tiktok"===n)/*#__PURE__*/return e.jsx(Ah,{provider:"tiktok"},n);if("line"===n)/*#__PURE__*/return e.jsx(Ah,{provider:"line"},n);if("twitch"===n)/*#__PURE__*/return e.jsx(Ah,{provider:"twitch"},n);if("spotify"===n)/*#__PURE__*/return e.jsx(Ah,{provider:"spotify"},n);if("instagram"===n)/*#__PURE__*/return e.jsx(Ah,{provider:"instagram"},n);if("twitter"===n)/*#__PURE__*/return e.jsx(Ah,{provider:"twitter"},n);if("telegram"===n)/*#__PURE__*/return e.jsx(Nh,{},n);if(i.isCustomOAuthProvider(n))/*#__PURE__*/return e.jsx(Ah,{provider:n},n);let r=x.findIndex((({id:e})=>e===El.normalize(n))),a="solana"===f?"solana-only":"ethereum-only";/*#__PURE__*/return e.jsx(Hl,{recent:!0,index:r,data:{wallets:x,walletChainType:a,handleWalletClick(e){s((t=>({...t,externalConnectWallet:{walletList:h,walletChainType:a,preSelectedWalletId:e.id}}))),d(t?qp:vc)}}})},Z=x.filter((e=>e.id!==El.normalize(y||""))),K=Z.map(((n,r)=>/*#__PURE__*/e.jsx(Hl,{index:r,data:{walletChainType:g,wallets:Z,handleWalletClick(e){s((t=>({...t,externalConnectWallet:{walletList:h,walletChainType:g,preSelectedWalletId:e.id}}))),d(t?qp:vc)}}},n.id))),Q=R.filter((e=>e!==v?.loginMethod)).flatMap(Y),X=G.flatMap(Y);"web3-first"===B&&"default"===z?K.unshift(...X):"web2-first"===B&&Q.unshift(...X);let J="web2-overflow"===z?()=>H("default"):void 0,ee=R.filter((e=>"email"!==e&&"sms"!==e)),te=Dh({priority:B,email:w,sms:C,social:ee}),ne=Rh({priority:B,email:w,sms:C,social:ee}),re=/*#__PURE__*/e.jsx(Cu,{text:Oh({priority:B}),onClick:()=>{s({...o,externalConnectWallet:{walletChainType:p?.walletChainType??u.appearance.walletChainType}}),d(t?qp:vc)}}),ie=/*#__PURE__*/e.jsx(Mh,{text:te,icon:ne,onClick:()=>H("web2-overflow")}),ae=U?0:1,oe=M&&K.length>0,se=0===Q.length&&M&&0===K.length,le=5-(oe?1:0),ce="default"===z&&u?.appearance.logo,de="default"===z&&u.appearance.loginMessage;/*#__PURE__*/return e.jsxs(ji,{title:u.appearance.landingHeader,icon:ce?/*#__PURE__*/e.jsx(ss,{}):void 0,iconVariant:ce?"logo":void 0,onClose:q,showClose:!0,onBack:J,showBack:!!J,helpText:u||D&&"default"===z?/*#__PURE__*/e.jsxs(e.Fragment,{children:[D&&"default"===z&&/*#__PURE__*/e.jsx(vh,{}),u&&/*#__PURE__*/e.jsx(xr,{app:u})]}):void 0,watermark:!0,children:[de&&("string"==typeof u.appearance.loginMessage?/*#__PURE__*/e.jsx(Lh,{children:u.appearance.loginMessage}):/*#__PURE__*/e.jsx(Wh,{children:u.appearance.loginMessage})),/*#__PURE__*/e.jsx(lr,{$colorScheme:u.appearance.palette.colorScheme,children:"default"===z&&"web2-first"===B?/*#__PURE__*/e.jsxs(e.Fragment,{children:[Q.length>le?Q.slice(0,le-1):Q,Q.length>le&&ie,oe&&re,se&&/*#__PURE__*/e.jsx(bu,{chainType:u.appearance.walletChainType})]}):"default"===z&&"web3-first"===B?/*#__PURE__*/e.jsxs(e.Fragment,{children:[M&&/*#__PURE__*/e.jsxs(e.Fragment,{children:[K.length>le?K.slice(0,le-1):K,K.length>le&&re]}),Q.length>ae&&ie,Q.length===ae&&Q[0],se&&/*#__PURE__*/e.jsx(bu,{chainType:u.appearance.walletChainType})]}):"web2-overflow"===z?/*#__PURE__*/e.jsx(e.Fragment,{children:"web3-first"===B?Q:Q.slice(3)}):null})]})};let Lh=/*#__PURE__*/a.styled.div.withConfig({displayName:"StyledSubtitle",componentId:"sc-b9aad528-0"})(["text-align:center;font-size:14px;margin-bottom:24px;"]),Wh=/*#__PURE__*/a.styled.div.withConfig({displayName:"MessageContainer",componentId:"sc-b9aad528-1"})(["margin-bottom:24px;"]),Dh=({priority:e,email:t,sms:n,social:r})=>"web2-first"===e?"Other socials":t&&n&&r.length>0||t&&r.length>0?"Log in with email or socials":n&&r.length>0?"Log in with sms or socials":t&&n?"Continue with email or sms":t?"Continue with email":n?"Continue with sms":"Log in with a social account",Rh=({priority:n,email:r,sms:i,social:a})=>"web2-first"===n||a.length>0?/*#__PURE__*/e.jsx(t.UserCircle,{}):r&&i?/*#__PURE__*/e.jsx(Xl,{}):r?/*#__PURE__*/e.jsx(t.Mail,{}):i?/*#__PURE__*/e.jsx(t.Smartphone,{}):null,Oh=({priority:e})=>"web2-first"===e?"Continue with a wallet":"Other wallets";const Bh=({mostRecentlyUsedAccountType:e,smsAvailable:t,emailAvailable:n,prefilledType:r})=>n&&("email"===e&&"phone"!==r||"email"===r)||!t||"phone"!==e&&"phone"!==r?"email":"sms",Uh={component:()=>{let t=Gn();return t.loginMethodsAndOrder&&t.loginMethodsAndOrder.primary.length>0?/*#__PURE__*/e.jsx(sg,{connectOnly:!0}):/*#__PURE__*/e.jsx(Fh,{connectOnly:!0})}},zh=({contactMethod:t,authFlow:r,appName:i="Privy",whatsAppEnabled:a=!1,onBack:o,onCodeSubmit:s,onResend:l,errorMessage:c,success:d=!1,resendCountdown:u=0,onInvalidInput:p,onClearError:h})=>{let[g,m]=n.useState(Vh);n.useEffect((()=>{c||m(Vh)}),[c]);let y="email"===r?/*#__PURE__*/e.jsxs("span",{children:["Please check ",/*#__PURE__*/e.jsx(tg,{children:t})," for an email from privy.io and enter your code below."]}):/*#__PURE__*/e.jsxs("span",{children:["Please check ",/*#__PURE__*/e.jsx(tg,{children:t})," for a",a?" WhatsApp":""," message from ",i," and enter your code below."]}),f=/*#__PURE__*/e.jsxs(Jh,{children:[/*#__PURE__*/e.jsxs("span",{children:["Didn't get ","email"===r?"an email":"a message","?"]}),u?/*#__PURE__*/e.jsxs(eg,{children:[/*#__PURE__*/e.jsx(ge.default,{color:"var(--privy-color-foreground)",strokeWidth:1.33,height:"12px",width:"12px"}),/*#__PURE__*/e.jsx("span",{children:"Code sent"})]}):/*#__PURE__*/e.jsx(hs,{as:"button",size:"sm",onClick:l,children:"Resend code"})]}),x=async e=>{e.preventDefault();let t=e.currentTarget.value.replace(" ","");if(""===t)return;if(isNaN(Number(t)))return void p?.("Code should be numeric");h?.();let n=Number(e.currentTarget.name?.charAt(5)),r=[...t||[""]].slice(0,Hh-n),i=[...g.slice(0,n),...r,...g.slice(n+r.length)];m(i);let a=Math.min(Math.max(n+r.length,0),Hh-1);if(!isNaN(Number(e.currentTarget.value))){let e=document.querySelector(`input[name=code-${a}]`);e?.focus()}if(i.every((e=>e&&!isNaN(+e)))){let e=document.querySelector(`input[name=code-${a}]`);e?.blur(),await(s?.(i.join("")))}};/*#__PURE__*/return e.jsx(ji,{title:"Enter confirmation code",subtitle:y,icon:"email"===r?me.default:ye.default,onBack:o,showBack:!0,helpText:f,children:/*#__PURE__*/e.jsx(Kh,{children:/*#__PURE__*/e.jsx(Yi,{children:/*#__PURE__*/e.jsxs(Qh,{children:[/*#__PURE__*/e.jsx("div",{children:g.map(((t,n)=>/*#__PURE__*/e.jsx("input",{name:`code-${n}`,type:"text",value:g[n],onChange:x,onKeyUp:e=>{"Backspace"===e.key&&(e=>{if(h?.(),m([...g.slice(0,e),"",...g.slice(e+1)]),e>0){let t=document.querySelector(`input[name=code-${e-1}]`);t?.focus()}})(n)},inputMode:"numeric",autoFocus:0===n,pattern:"[0-9]",className:`${d?"success":""} ${c?"fail":""}`,autoComplete:v.isMobile?"one-time-code":"off"},n)))}),/*#__PURE__*/e.jsx(Xh,{$fail:!!c,$success:d,children:/*#__PURE__*/e.jsx("span",{children:"Invalid or expired verification code"===c?"Incorrect code":c||(d?"Success!":"")})})]})})})})};let Hh=6,Vh=Array(6).fill("");var $h,qh,Gh=(($h=Gh||{})[$h.RESET_AFTER_DELAY=0]="RESET_AFTER_DELAY",$h[$h.CLEAR_ON_NEXT_VALID_INPUT=1]="CLEAR_ON_NEXT_VALID_INPUT",$h),Yh=((qh=Yh||{})[qh.EMAIL=0]="EMAIL",qh[qh.SMS=1]="SMS",qh);const Zh={component:()=>{let{navigate:t,lastScreen:a,navigateBack:o,setModalData:s,onUserCloseViaDialogOrKeybindRef:l}=Jn(),c=Gn(),{closePrivyModal:u,resendEmailCode:p,resendSmsCode:h,getAuthMeta:g,loginWithCode:m,updateWallets:y,createAnalyticsEvent:f}=r.usePrivyInternal(),{authenticated:x,logout:v,user:w}=i.usePrivyContext(),{whatsAppEnabled:C}=Gn(),[b,j]=n.useState(!1),[k,T]=n.useState(null),[A,S]=n.useState(null),[E,I]=n.useState(0);l.current=()=>null;let P=g()?.email?0:1,N=0===P?g()?.email||"":g()?.phoneNumber||"";n.useEffect((()=>{if(E){let e=setTimeout((()=>{I(E-1)}),1e3);return()=>clearTimeout(e)}}),[E]),n.useEffect((()=>{if(x&&b&&w){if(c?.legal.requireUsersAcceptTerms&&!w.hasAcceptedTerms){let e=setTimeout((()=>{t(rl)}),900);return()=>clearTimeout(e)}if(xs(w,c.embeddedWallets)){let e=setTimeout((()=>{s({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),f({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AwaitingPasswordlessCodeScreen"}}),v()},callAuthOnSuccessOnClose:!0}}),t(nl)}),900);return()=>clearTimeout(e)}{y();let e=setTimeout((()=>u({shouldCallAuthOnSuccess:!0,isSuccess:!0})),it);return()=>clearTimeout(e)}}}),[x,b,w]),n.useEffect((()=>{if(k&&0===A){let e=setTimeout((()=>{T(null),S(null);let e=document.querySelector("input[name=code-0]");e?.focus()}),1400);return()=>clearTimeout(e)}}),[k,A]);/*#__PURE__*/return e.jsx(zh,{contactMethod:N,authFlow:0===P?"email":"sms",appName:c?.name,whatsAppEnabled:C,onBack:()=>o(),onCodeSubmit:async e=>{try{await m(e),j(!0)}catch(e){if(e instanceof d.PrivyApiError&&e.privyErrorCode===d.PrivyErrorCode.INVALID_CREDENTIALS)T("Invalid or expired verification code"),S(0);else if(e instanceof d.PrivyApiError&&e.privyErrorCode===d.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE)T(e.message);else{if(e instanceof d.PrivyApiError&&e.privyErrorCode===d.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new d.PrivyUserLimitReachedError(e).toString()),void t(gc);if(e instanceof d.PrivyApiError&&e.privyErrorCode===d.PrivyErrorCode.USER_DOES_NOT_EXIST)return void t(ws);if(e instanceof d.PrivyApiError&&e.privyErrorCode===d.PrivyErrorCode.LINKED_TO_ANOTHER_USER)return s({errorModalData:{error:e,previousScreen:a??Zh}}),void t(Os,!1);if(e instanceof d.PrivyApiError&&e.privyErrorCode===d.PrivyErrorCode.DISALLOWED_PLUS_EMAIL)return s({inlineError:{error:e}}),void t(Uh,!1);if(e instanceof d.PrivyApiError&&e.privyErrorCode===d.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return s({accountTransfer:{nonce:e.data?.data?.nonce,account:N,displayName:e.data?.data?.account?.displayName,linkMethod:0===P?"email":"sms",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void t(Xs);T("Issue verifying code"),S(0)}}},onResend:async()=>{I(30),0===P?await p():await h()},errorMessage:k||void 0,success:b,resendCountdown:E,onInvalidInput:e=>{T(e),S(1)},onClearError:()=>{1===A&&(T(null),S(null))}})}};let Kh=/*#__PURE__*/a.styled.div.withConfig({displayName:"PasswordlessCodeContainer",componentId:"sc-63a7dae3-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin:auto;gap:16px;flex-grow:1;width:100%;"]),Qh=/*#__PURE__*/a.styled.div.withConfig({displayName:"CodeInput",componentId:"sc-63a7dae3-1"})(["display:flex;flex-direction:column;width:100%;gap:12px;> div:first-child{display:flex;justify-content:center;gap:0.5rem;width:100%;border-radius:var(--privy-border-radius-sm);> input{border:1px solid var(--privy-color-foreground-4);background:var(--privy-color-background);border-radius:var(--privy-border-radius-sm);padding:8px 10px;height:48px;width:40px;text-align:center;font-size:18px;font-weight:600;color:var(--privy-color-foreground);transition:all 0.2s ease;}> input:focus{border:1px solid var(--privy-color-foreground);box-shadow:0 0 0 1px var(--privy-color-foreground);}> input:invalid{border:1px solid var(--privy-color-error);}> input.success{border:1px solid var(--privy-color-border-success);background:var(--privy-color-success-bg);}> input.fail{border:1px solid var(--privy-color-border-error);background:var(--privy-color-error-bg);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);}}"]),Xh=/*#__PURE__*/a.styled.div.withConfig({displayName:"InputHelp",componentId:"sc-63a7dae3-2"})(["line-height:20px;min-height:20px;font-size:14px;font-weight:400;color:",";display:flex;justify-content:center;width:100%;text-align:center;"],(e=>e.$success?"var(--privy-color-success-dark)":e.$fail?"var(--privy-color-error-dark)":"transparent")),Jh=/*#__PURE__*/a.styled.div.withConfig({displayName:"HelpTextContainer",componentId:"sc-63a7dae3-3"})(["display:flex;gap:8px;align-items:center;justify-content:center;width:100%;color:var(--privy-color-foreground-2);"]),eg=/*#__PURE__*/a.styled.div.withConfig({displayName:"Badge",componentId:"sc-63a7dae3-4"})(["display:flex;align-items:center;justify-content:center;border-radius:var(--privy-border-radius-sm);padding:2px 8px;gap:4px;background:var(--privy-color-background-2);color:var(--privy-color-foreground-2);"]),tg=/*#__PURE__*/a.styled.span.withConfig({displayName:"BoldWrappingSpan",componentId:"sc-63a7dae3-5"})(["font-weight:500;word-break:break-all;color:var(--privy-color-foreground);"]);const ng=/*#__PURE__*/n.forwardRef(((a,o)=>{let[s,l]=n.useState(a.defaultValue||""),[c,u]=n.useState(""),[p,h]=n.useState(!1),{authenticated:g}=i.usePrivyContext(),{initLoginWithEmail:m}=r.usePrivyInternal(),{navigate:y,setModalData:f,currentScreen:x,data:v}=Jn(),{enabled:w,token:C}=Gt(),[b,j]=n.useState(!1),{accountType:k}=os(),T=Gn();n.useEffect((()=>{!s&&T.disablePlusEmails&&v?.inlineError?.error instanceof d.PrivyError&&v?.inlineError?.error.privyErrorCode===d.PrivyErrorCode.DISALLOWED_PLUS_EMAIL&&!c&&u("Please enter a valid email address without a '+'."),c&&u("")}),[s]);let A=Dt(s),S=p||!A,E=()=>{f({login:v?.login,inlineError:void 0}),!w||C||g?(e=>{h(!0),m({email:s,captchaToken:e,disableSignup:v?.login?.disableSignup,withPrivyUi:!0}).then((()=>{y(Zh)})).catch((e=>{f({errorModalData:{error:e,previousScreen:x||dg}}),y(Os)})).finally((()=>{h(!1)}))})(C):(f({captchaModalData:{callback:e=>m({email:s,captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:Zh,onErrorNavigateTo:Os}}),y(oc))};/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsxs(rg,{children:[c&&/*#__PURE__*/e.jsx(Cl,{style:{display:"block",marginTop:"0.25rem",textAlign:"left"},children:c}),/*#__PURE__*/e.jsxs(ig,{stacked:a.stacked,$error:!!c,children:[/*#__PURE__*/e.jsx(ag,{children:/*#__PURE__*/e.jsx(t.Mail,{})}),/*#__PURE__*/e.jsx("input",{ref:o,id:"email-input",className:"login-method-button",type:"email",placeholder:"your@email.com",onFocus:()=>j(!0),onChange:e=>l(e.target.value),onKeyUp:e=>{"Enter"===e.key&&E()},value:s,autoComplete:"email"}),"email"!==k||b?a.stacked?/*#__PURE__*/e.jsx("span",{}):/*#__PURE__*/e.jsx(Or,{isSubmitting:p,onClick:E,disabled:S,children:"Submit"}):/*#__PURE__*/e.jsx(vu,{color:"gray",children:"Recent"})]})]}),a.stacked?/*#__PURE__*/e.jsx(Nr,{loadingText:null,loading:p,disabled:S,onClick:E,style:{width:"100%"},children:"Submit"}):null]})}));let rg=Tl,ig=kl,ag=/*#__PURE__*/a.styled(pr).withConfig({displayName:"StyledLoginMethodIconWrapper",componentId:"sc-e33d938a-0"})(["display:inline-flex;"]);const og=({isEditable:r,setIsEditable:i,defaultValue:a})=>{let o=n.useRef(null);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(hr,{$if:!r,children:/*#__PURE__*/e.jsx(ng,{ref:o,defaultValue:a})}),/*#__PURE__*/e.jsx(hr,{$if:r,children:/*#__PURE__*/e.jsxs(ur,{onClick:()=>{i(),setTimeout((()=>{o.current?.focus()}),0)},children:[/*#__PURE__*/e.jsx(pr,{children:/*#__PURE__*/e.jsx(t.Mail,{})}),"Continue with Email"]})})]})},sg=({connectOnly:t})=>{let{closePrivyModal:i,connectors:a}=r.usePrivyInternal(),{onUserCloseViaDialogOrKeybindRef:o,data:s}=Jn(),l=Gn(),{appearance:{palette:{colorScheme:c}}}=Gn(),{accountType:d,walletClientType:u,chainType:p}=os(),h=n.useMemo((()=>d&&"guest"!==d&&"authorization_key"!==d&&"cross_app"!==d?ts(d):null),[d]),g=l.loginMethodsAndOrder?.primary??[],m=l.loginMethodsAndOrder?.overflow??[],y=n.useMemo((()=>[...g,...m]),[g,m]),f=l.loginMethods.passkey,x=s?.login,v=[];u&&y.includes(u)?v.push(u):d&&y.includes(h?.loginMethod)&&v.push(h?.loginMethod);let[w,C]=n.useState("default"),[b,j]=n.useState(Bh({mostRecentlyUsedAccountType:d,smsAvailable:y.includes("sms"),emailAvailable:y.includes("email"),prefilledType:x?.prefill?.type}));n.useEffect((()=>{j(Bh({mostRecentlyUsedAccountType:d,smsAvailable:y.includes("sms"),emailAvailable:y.includes("email"),prefilledType:x?.prefill?.type}))}),[y,d]),n.useEffect((()=>{"phone"===d&&j("sms");let e=y.indexOf("sms"),t=y.indexOf("email");e>-1&&e<t&&j("sms")}),[d,g,m]);let k=()=>{i({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{C("default")}),150)};o.current=k;let T=n=>"email"===n?/*#__PURE__*/e.jsx(og,{isEditable:"email"===b,setIsEditable:()=>{j("email")},defaultValue:"email"===x?.prefill?.type?x.prefill.value:void 0},n):"sms"===n?/*#__PURE__*/e.jsx(kh,{isEditable:"sms"===b,setIsEditable:()=>{j("sms")},defaultValue:"phone"===x?.prefill?.type?x.prefill.value:void 0},n):"apple"===n?/*#__PURE__*/e.jsx(Ah,{provider:"apple"},n):"discord"===n?/*#__PURE__*/e.jsx(Ah,{provider:"discord"},n):"farcaster"===n?/*#__PURE__*/e.jsx(ph,{},n):"github"===n?/*#__PURE__*/e.jsx(Ah,{provider:"github"},n):"google"===n?/*#__PURE__*/e.jsx(Ah,{provider:"google"},n):"linkedin"===n?/*#__PURE__*/e.jsx(Ah,{provider:"linkedin"},n):"spotify"===n?/*#__PURE__*/e.jsx(Ah,{provider:"spotify"},n):"instagram"===n?/*#__PURE__*/e.jsx(Ah,{provider:"instagram"},n):"tiktok"===n?/*#__PURE__*/e.jsx(Ah,{provider:"tiktok"},n):"line"===n?/*#__PURE__*/e.jsx(Ah,{provider:"line"},n):"twitch"===n?/*#__PURE__*/e.jsx(Ah,{provider:"twitch"},n):"twitter"===n?/*#__PURE__*/e.jsx(Ah,{provider:"twitter"},n):"telegram"===n?/*#__PURE__*/e.jsx(Nh,{},n):n.startsWith("privy:")?/*#__PURE__*/e.jsx(us,{appId:n.replace("privy:","")},n):Hu({walletList:l.appearance.walletList,walletChainType:x?.walletChainType??l.appearance.walletChainType,connectors:a,connectOnly:t,ignore:y,walletConnectEnabled:l.externalWallets.walletConnect.enabled,forceWallet:{wallet:n,chainType:p??"ethereum"}}),A=v.flatMap(T),S=g.filter((e=>e!==u&&e!==h?.loginMethod)).flatMap(T),E=m.filter((e=>e!==u&&e!==h?.loginMethod)).flatMap(T),[I,P]=((e,t)=>{let n=[],r=[];for(let[i,a]of e.entries())i<t?n.push(a):r.push(a);return[n,r]})([...A,...S,...E],lg({primary:S.length+A.length,overflow:E.length}));/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vr,{title:l.appearance.landingHeader,onClose:k,backFn:"default"===w?void 0:()=>{C("default")}}),"default"===w&&/*#__PURE__*/e.jsx(cg,{}),"default"===w&&("string"==typeof l.appearance.loginMessage?/*#__PURE__*/e.jsx(dr,{children:l.appearance.loginMessage}):l.appearance.loginMessage),/*#__PURE__*/e.jsx(or,{style:{overflow:"hidden"},children:/*#__PURE__*/e.jsxs(lr,{$colorScheme:c,children:["default"===w&&/*#__PURE__*/e.jsxs(e.Fragment,{children:[I,P.length>0&&/*#__PURE__*/e.jsx(Mh,{text:"More options",icon:/*#__PURE__*/e.jsx(de.default,{}),onClick:()=>C("overflow")})]}),"overflow"===w&&/*#__PURE__*/e.jsx(e.Fragment,{children:P}),f&&"default"===w&&/*#__PURE__*/e.jsx(vh,{})]})}),l&&/*#__PURE__*/e.jsx(xr,{app:l}),/*#__PURE__*/e.jsx(vr,{})]})};let lg=({primary:e,overflow:t})=>e<5?e:5===e&&0===t?5:4,cg=/*#__PURE__*/a.styled(ls).withConfig({displayName:"StyledAppLogoHeader",componentId:"sc-7cdadd41-0"})(["margin-bottom:16px;"]);const dg={component:()=>{let t=Gn();return t.loginMethodsAndOrder&&t.loginMethodsAndOrder.primary.length>0?/*#__PURE__*/e.jsx(sg,{connectOnly:!1}):/*#__PURE__*/e.jsx(Fh,{connectOnly:!1})},isCaptchaRequired:!0,isUnauthenticatedScreem:!0},ug={component:()=>{let[t,a]=n.useState(null),[o,s]=n.useState(!1),[l,c]=n.useState(null),[u,p]=n.useState(""),{authenticated:h,user:g}=i.usePrivyContext(),{client:m,walletProxy:y,refreshSessionAndUser:f,closePrivyModal:x,createAnalyticsEvent:v}=r.usePrivyInternal(),{navigate:w,data:C,onUserCloseViaDialogOrKeybindRef:b}=Jn(),j=Gn(),{onSuccess:k,onFailure:T}=C.setWalletPassword,A=i.getPrivyPrimaryWallet(g),S="user-passcode"===t?.recoveryMethod,E="user-passcode"===A?.recoveryMethod;n.useEffect((()=>{h||(w(dg),T(new d.PrivyUnauthenticatedError("User must be authenticated before setting a password on a Privy wallet")))}),[h]);let I=()=>l?(T(l),void x({shouldCallAuthOnSuccess:!1})):S?(k(t),void x({shouldCallAuthOnSuccess:!1})):(T(new d.PrivyEmbeddedWalletError("Exited before password was added to wallet")),void x({shouldCallAuthOnSuccess:!1}));b.current=I;/*#__PURE__*/return e.jsx(Jo,{appName:j?.name||"privy",config:{initiatedBy:"user",onCancel:I},error:l?"An error has occurred, please try again.":void 0,buttonLoading:o,buttonHideAnimations:!1,password:u,isResettingPassword:E,onPasswordGenerate:()=>p(Ho()),onPasswordChange:p,onSubmit:async()=>{S?(k(t),x({shouldCallAuthOnSuccess:!1})):(s(!0),c(null),await(async()=>{let e=await m.getAccessToken();if(e&&g&&A?.address&&u&&y)try{v({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:E}});let{entropyId:t,entropyIdVerifier:n}=Xt(g);if(!(await y.setRecovery({accessToken:e,entropyId:t,entropyIdVerifier:n,recoveryPassword:u,recoveryMethod:"user-passcode"})).entropyId)return c(new d.PrivyEmbeddedWalletError("Error setting password on privy wallet")),void v({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:E,reason:"error setting password"}});let r=await f(),o=i.getPrivyPrimaryWallet(r);if(!o)return c(new d.PrivyEmbeddedWalletError("Error setting password on privy wallet")),void v({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:E,reason:"wallet disconnected"}});a(o),v({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:E}})}catch(e){console.warn(e),c(e instanceof Error?e:Error("Error setting password on privy wallet")),v({eventName:"embedded_wallet_set_password_failed",payload:{walletAddress:A.address,reason:e}})}})(),s(!1))},onClose:I})}},pg=({onClose:n,onProceed:r})=>/*#__PURE__*/e.jsx(ji,{title:"Secure Your Account",subtitle:/*#__PURE__*/e.jsxs(e.Fragment,{children:["Please set a password to secure your account.",/*#__PURE__*/e.jsx("br",{}),"Losing access to this password and this device will make your account inaccessible."]}),icon:t.Lock,primaryCta:{label:"Add password",onClick:r},onClose:n,watermark:!0}),hg={component:()=>{let{closePrivyModal:t}=r.usePrivyInternal(),{data:n,navigate:i,onUserCloseViaDialogOrKeybindRef:a}=Jn(),{onFailure:o}=n.setWalletPassword,s=()=>{o(new d.PrivyEmbeddedWalletError("Exited before password was added to wallet")),t({shouldCallAuthOnSuccess:!1})};return a.current=s,/*#__PURE__*/e.jsx(pg,{onClose:s,onProceed:()=>{i(ug)}})}},gg={component:()=>{let[t,a]=n.useState(!0),{authenticated:o,user:s}=i.usePrivyContext(),{walletProxy:l,closePrivyModal:c,createAnalyticsEvent:u,client:p}=r.usePrivyInternal(),{navigate:h,data:g,onUserCloseViaDialogOrKeybindRef:m}=Jn(),[y,f]=n.useState(void 0),[x,v]=n.useState(""),[w,C]=n.useState(!1),{entropyId:b,entropyIdVerifier:j,onCompleteNavigateTo:k,onSuccess:T,onFailure:A}=g.recoverWallet,S=(e="User exited before their wallet could be recovered")=>{c({shouldCallAuthOnSuccess:!1}),A("string"==typeof e?new d.PrivyEmbeddedWalletError(e):e)};m.current=S,n.useEffect((()=>{if(!o)return S("User must be authenticated and have a Privy wallet before it can be recovered")}),[o]);/*#__PURE__*/return e.jsxs(yi,{children:[/*#__PURE__*/e.jsx(yi.Header,{icon:Le.default,title:"Enter your password",subtitle:"Please provision your account on this new device. To continue, enter your recovery password.",showClose:!0,onClose:S}),/*#__PURE__*/e.jsx(yi.Body,{children:/*#__PURE__*/e.jsx(mg,{children:/*#__PURE__*/e.jsxs("div",{children:[/*#__PURE__*/e.jsxs(fo,{children:[/*#__PURE__*/e.jsx(mo,{type:t?"password":"text",onChange:e=>(e=>{e&&f(e)})(e.target.value),disabled:w,style:{paddingRight:"2.3rem"}}),/*#__PURE__*/e.jsx(bo,{style:{right:"0.75rem"},children:t?/*#__PURE__*/e.jsx(ko,{onClick:()=>a(!1)}):/*#__PURE__*/e.jsx(To,{onClick:()=>a(!0)})})]}),!!x&&/*#__PURE__*/e.jsx(yg,{children:x})]})})}),/*#__PURE__*/e.jsxs(yi.Footer,{children:[/*#__PURE__*/e.jsx(yi.HelpText,{children:/*#__PURE__*/e.jsxs(Ji,{children:[/*#__PURE__*/e.jsx("h4",{children:"Why is this necessary?"}),/*#__PURE__*/e.jsx("p",{children:"You previously set a password for this wallet. This helps ensure only you can access it"})]})}),/*#__PURE__*/e.jsx(yi.Actions,{children:/*#__PURE__*/e.jsx(fg,{loading:w||!l,disabled:!y,onClick:async()=>{C(!0);let e=await p.getAccessToken(),t=i.getPrivyWalletWithAddress(s,b);if(!e||!t||null===y)return S("User must be authenticated and have a Privy wallet before it can be recovered");try{u({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:t.address}}),await(l?.recover({accessToken:e,entropyId:b,entropyIdVerifier:j,recoveryPassword:y})),v(""),k?h(k):c({shouldCallAuthOnSuccess:!1}),T?.(t),u({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t.address}})}catch(e){!function(e){return Da(e)&&("invalid_recovery_pin"===e.type||"invalid_request_arguments"===e.type)}(e)?v("An error has occurred, please try again."):v("Invalid recovery password, please try again.")}finally{C(!1)}},$hideAnimations:!b&&w,children:"Recover your account"})}),/*#__PURE__*/e.jsx(yi.Watermark,{})]})]})}};let mg=/*#__PURE__*/a.styled.div.withConfig({displayName:"Content",componentId:"sc-f366413c-0"})(["display:flex;flex-direction:column;gap:1.5rem;"]),yg=/*#__PURE__*/a.styled.div.withConfig({displayName:"ErrorMessage",componentId:"sc-f366413c-1"})(["line-height:20px;height:20px;font-size:13px;color:var(--privy-color-error);text-align:left;margin-top:0.5rem;"]),fg=/*#__PURE__*/a.styled(Nr).withConfig({displayName:"NoAnimationPrimaryButton",componentId:"sc-f366413c-2"})(["",""],(({$hideAnimations:e})=>e&&/*#__PURE__*/a.css(["&&{transition:none;}"])));const xg={component:()=>{let{navigate:t,data:a,onUserCloseViaDialogOrKeybindRef:o}=Jn(),s=Gn(),[l,c]=n.useState(""),[u,p]=n.useState(!1),[h,g]=n.useState(),[m,y]=n.useState(null),{create:f}=Xa(),{authenticated:x,user:v}=i.usePrivyContext(),{closePrivyModal:w,isNewUserThisSession:C,initializeWalletProxy:b}=r.usePrivyInternal(),{onSuccess:j,onFailure:k,callAuthOnSuccessOnClose:T,shouldCreateEth:A,shouldCreateSol:S}=a.createWallet,[E,I]=n.useState(null),P=new rt((async()=>{try{let e;if(A&&S)e=await f({recoveryMethod:"user-passcode",recoveryPassword:h,chainType:"ethereum",walletIndex:0,latestUser:v}),e=await f({chainType:"solana",walletIndex:0,latestUser:e.user});else if(S)e=await f({recoveryMethod:"user-passcode",recoveryPassword:h,chainType:"solana",walletIndex:0,latestUser:v});else{if(!A)throw Error("Invalid args to create wallet");e=await f({recoveryMethod:"user-passcode",recoveryPassword:h,chainType:"ethereum",walletIndex:0,latestUser:v})}I(e),C?t(eo):(j(e),w({shouldCallAuthOnSuccess:T}))}catch(e){c(e.message)}}));n.useEffect((()=>{m||b(3e4).then((e=>y(e)))}),[m]),n.useEffect((()=>{if(!x||!v)return t(dg),void k(Error("User must be authenticated before creating a Privy wallet"))}),[x]),o.current=()=>null;/*#__PURE__*/return e.jsx(Jo,{config:{initiatedBy:"automatic"},appName:s?.name||"privy",loading:!m,buttonLoading:u,buttonHideAnimations:!E&&u,isResettingPassword:!1,error:l,password:h||"",onClose:()=>{E&&"user-passcode"!==E.account.recoveryMethod?(k(new d.PrivyEmbeddedWalletError("User created a wallet but failed to set a password for it")),w({shouldCallAuthOnSuccess:!1})):E?(j(E),w({shouldCallAuthOnSuccess:T})):(k(new d.PrivyEmbeddedWalletError("User wallet creation failed")),w({shouldCallAuthOnSuccess:!1}))},onPasswordChange:g,onPasswordGenerate:()=>g(Ho()),onSubmit:async()=>(p(!0),P.execute().then((()=>new Promise((e=>setTimeout(e,250))))).finally((()=>p(!1))))})}},vg=/*#__PURE__*/a.styled.div.withConfig({displayName:"WithCircleBorder",componentId:"sc-e4fc5563-0"})(["&&{border-width:4px;}display:flex;justify-content:center;align-items:center;padding:1rem;aspect-ratio:1;border-style:solid;border-color:",";border-radius:50%;"],(e=>e.$color??"var(--privy-color-accent)")),wg={component:()=>{let{user:t}=i.usePrivyContext(),{client:a,walletProxy:o,refreshSessionAndUser:s,closePrivyModal:l}=r.usePrivyInternal(),c=Jn(),{entropyId:d,entropyIdVerifier:u}=c.data?.recoverWallet,[p,h]=n.useState(!1),[g,m]=n.useState(null),[y,f]=n.useState(null);function x(){if(!p){if(y)return c.data?.setWalletPassword?.onFailure(y),void l();if(!g)return c.data?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),void l()}}c.onUserCloseViaDialogOrKeybindRef.current=x;let v=!(!p&&!g);return y?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vr,{onClose:x},"header"),/*#__PURE__*/e.jsx(vg,{$color:"var(--privy-color-error)",style:{alignSelf:"center"},children:/*#__PURE__*/e.jsx(xe.default,{height:38,width:38,stroke:"var(--privy-color-error)"})}),/*#__PURE__*/e.jsx(kc,{style:{marginTop:"0.5rem"},children:"Something went wrong"}),/*#__PURE__*/e.jsx(ar,{style:{minHeight:"2rem"}}),/*#__PURE__*/e.jsx(_r,{onClick:()=>f(null),children:"Try again"}),/*#__PURE__*/e.jsx(vr,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vr,{onClose:x},"header"),/*#__PURE__*/e.jsx(ke.default,{style:{width:"3rem",height:"3rem",alignSelf:"center"}}),/*#__PURE__*/e.jsx(kc,{style:{marginTop:"0.5rem"},children:"Automatically secure your account"}),/*#__PURE__*/e.jsx(jc,{style:{marginTop:"1rem"},children:"When you log into a new device, you’ll only need to authenticate to access your account. Never get logged out if you forget your password."}),/*#__PURE__*/e.jsx(ar,{style:{minHeight:"2rem"}}),/*#__PURE__*/e.jsx(_r,{loading:p,disabled:v,onClick:()=>async function(){h(!0);try{let e=await a.getAccessToken(),n=i.getPrivyWalletWithAddress(t,d);if(!e||!o||!n)return;if(!(await o.setRecovery({accessToken:e,entropyId:d,entropyIdVerifier:u,existingRecoveryMethod:n.recoveryMethod,recoveryMethod:"privy"})).entropyId)throw Error("Unable to set recovery on wallet");let r=await s();if(!r)throw Error("Unable to set recovery on wallet");let p=i.getPrivyWalletWithAddress(r,n.address);if(!p)throw Error("Unabled to set recovery on wallet");m(!!r),setTimeout((()=>{c.data?.setWalletPassword?.onSuccess(p),l()}),it)}catch(e){f(e)}finally{h(!1)}}(),children:g?"Success":"Confirm"}),/*#__PURE__*/e.jsx(vr,{})]})}};function Cg({isCreatingWallet:e,skipSplashScreen:t}){return e?xg:t?ug:hg}function bg({walletAction:e,availableRecoveryMethods:t,legacySetWalletPasswordFlow:n,isResettingPassword:r,showAutomaticRecovery:i}){return i?wg:n||1===t.length?Cg({isCreatingWallet:"create"===e,skipSplashScreen:r}):lo}function jg(e){switch(e){case"user-passcode":return gg;case"google-drive":case"icloud":return io;default:throw Error("Recovery method not supported")}}const kg=({address:t,accessToken:n,appConfigTheme:r,onClose:i,isLoading:a=!1,exportButtonProps:o})=>/*#__PURE__*/e.jsx(ji,{title:"Export wallet",subtitle:/*#__PURE__*/e.jsxs(e.Fragment,{children:["Copy either your private key or seed phrase to export your wallet."," ",/*#__PURE__*/e.jsx("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),onClose:i,watermark:!0,children:/*#__PURE__*/e.jsxs(Tg,{children:[/*#__PURE__*/e.jsx(xd,{theme:r,children:"Never share your private key or seed phrase with anyone."}),/*#__PURE__*/e.jsx(Lc,{title:"Your wallet",address:t,showCopyButton:!0}),/*#__PURE__*/e.jsx("div",{style:{width:"100%"},children:a?/*#__PURE__*/e.jsx(Ag,{}):n&&o&&/*#__PURE__*/e.jsx(Ig,{accessToken:n,dimensions:{height:"44px"},...o})})]})});let Tg=/*#__PURE__*/a.styled.div.withConfig({displayName:"ContentContainer",componentId:"sc-39a41d8e-0"})(["display:flex;flex-direction:column;gap:1.25rem;text-align:left;"]),Ag=()=>/*#__PURE__*/e.jsx(Sg,{children:/*#__PURE__*/e.jsx(Eg,{children:"Loading..."})}),Sg=/*#__PURE__*/a.styled.div.withConfig({displayName:"PlaceholderContainer",componentId:"sc-39a41d8e-1"})(["display:flex;gap:12px;height:44px;"]),Eg=/*#__PURE__*/a.styled.div.withConfig({displayName:"PlaceholderButton",componentId:"sc-39a41d8e-2"})(["display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:16px;font-weight:500;border-radius:var(--privy-border-radius-md);background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);"]);function Ig(t){let[r,i]=n.useState(t.dimensions.width),[a,s]=n.useState(void 0),l=n.useRef(null);n.useEffect((()=>{if(l.current&&void 0===r){let{width:e}=l.current.getBoundingClientRect();i(e)}let e=getComputedStyle(document.documentElement);s({background:e.getPropertyValue("--privy-color-background"),background2:e.getPropertyValue("--privy-color-background-2"),foreground3:e.getPropertyValue("--privy-color-foreground-3"),foregroundAccent:e.getPropertyValue("--privy-color-foreground-accent"),accent:e.getPropertyValue("--privy-color-accent"),accentDark:e.getPropertyValue("--privy-color-accent-dark"),success:e.getPropertyValue("--privy-color-success"),colorScheme:e.getPropertyValue("color-scheme")})}),[]);let c="ethereum"===t.chainType&&!t.imported&&!t.isUnifiedWallet;/*#__PURE__*/return e.jsx("div",{ref:l,children:r&&
|
|
26
26
|
/*#__PURE__*/e.jsxs(Ng,{children:[/*#__PURE__*/e.jsx("iframe",{style:{position:"absolute",zIndex:1},width:r,height:t.dimensions.height,allow:"clipboard-write self *",src:o.constructURL({origin:t.origin,path:`/apps/${t.appId}/embedded-wallets/export`,query:t.isUnifiedWallet?{v:"1-unified",wallet_id:t.walletId,client_id:t.appClientId,width:`${r}px`,caid:t.clientAnalyticsId,phrase_export:c,...a}:{v:"1",entropy_id:t.entropyId,entropy_id_verifier:t.entropyIdVerifier,hd_wallet_index:t.hdWalletIndex,chain_type:t.chainType,client_id:t.appClientId,width:`${r}px`,caid:t.clientAnalyticsId,phrase_export:c,...a},hash:{token:t.accessToken}})}),/*#__PURE__*/e.jsx(_g,{children:"Loading..."}),c&&/*#__PURE__*/e.jsx(_g,{children:"Loading..."})]})})}const Pg={component:()=>{let[t,a]=n.useState(null),{authenticated:o,user:s}=i.usePrivyContext(),{closePrivyModal:l,createAnalyticsEvent:c,clientAnalyticsId:d,client:u}=r.usePrivyInternal(),p=Gn(),{data:h,onUserCloseViaDialogOrKeybindRef:g}=Jn(),{onFailure:m,onSuccess:y,origin:f,appId:x,appClientId:v,entropyId:w,entropyIdVerifier:C,walletId:b,hdWalletIndex:j,chainType:k,address:T,isUnifiedWallet:A,imported:S}=h.keyExport,E=e=>{l({shouldCallAuthOnSuccess:!1}),m("string"==typeof e?Error(e):e)},I=()=>{l({shouldCallAuthOnSuccess:!1}),y(),c({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:T}})};return n.useEffect((()=>{if(!o)return E("User must be authenticated before exporting their wallet");u.getAccessToken().then(a).catch(E)}),[o,s]),g.current=I,/*#__PURE__*/e.jsx(kg,{address:T,accessToken:t,appConfigTheme:p.appearance.palette.colorScheme,onClose:I,isLoading:!t,exportButtonProps:t?{origin:f,appId:x,appClientId:v,clientAnalyticsId:d,entropyId:w,entropyIdVerifier:C,walletId:b,hdWalletIndex:j,isUnifiedWallet:A,imported:S,chainType:k}:void 0})}};let Ng=/*#__PURE__*/a.styled.div.withConfig({displayName:"ButtonContainer",componentId:"sc-39a41d8e-3"})(["overflow:visible;position:relative;overflow:none;height:44px;display:flex;gap:12px;"]),_g=/*#__PURE__*/a.styled.div.withConfig({displayName:"LoadingButton",componentId:"sc-39a41d8e-4"})(["display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:16px;font-weight:500;border-radius:var(--privy-border-radius-md);background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);"]);const Mg=({connectionFailed:n,onClose:r})=>n?/*#__PURE__*/e.jsx(ji,{title:"Something went wrong",subtitle:"We're on it. Please try again later.",icon:t.XCircle,iconVariant:"error",primaryCta:{label:"Close",onClick:r},watermark:!0}):/*#__PURE__*/e.jsx(ji,{title:"Connecting to your wallet",subtitle:"Please wait...",iconVariant:"loading",showClose:!0,onClose:r,watermark:!1}),Fg={component:()=>{let{authenticated:t,user:a}=i.usePrivyContext(),{client:o,closePrivyModal:s,createAnalyticsEvent:l,walletProxy:c}=r.usePrivyInternal(),{navigate:d,data:u,setModalData:p,onUserCloseViaDialogOrKeybindRef:h}=Jn(),g=n.useMemo((()=>Date.now()),[]),[m,y]=n.useState(!1),{onCompleteNavigateTo:f,onFailure:x,shouldForceMFA:v,entropyId:w,entropyIdVerifier:C,recoveryMethod:b,connectingWalletAddress:j,isUnifiedWallet:k=!1}=u?.connectWallet,T=e=>{m||(y(!0),x("string"==typeof e?Error(e):e))};return n.useEffect((()=>{let e;return t?c?((async()=>{let t=await o.getAccessToken();if(!t)return T("User must be authenticated and have a Privy wallet before it can be connected");try{k||await c.connect({accessToken:t,entropyId:w,entropyIdVerifier:C}),v&&await c.verifyMfa({accessToken:t});let n=(Date.now()-g)/1e3;f===Pg&&n<1?e=setTimeout((()=>{d(f,!1)}),1e3*(1-n)):d(f,!1)}catch(e){if(Ra(e)&&"privy"===b){let e=await o.getAccessToken();if(!e)return T("User must be authenticated and have a Privy wallet before it can be recovered");try{l({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:j}});let t=await(c?.recover({accessToken:e,entropyId:w,entropyIdVerifier:C}));t?.entropyId||T(Error("Unable to recover wallet")),f?d(f):s({shouldCallAuthOnSuccess:!1}),l({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:j}}),d(f)}catch(e){T("An error has occurred, please try again.")}}else Ra(e)&&"privy"!==b&&"privy-v2"!==b?(p({...u,recoverWallet:{entropyId:w,entropyIdVerifier:C,onCompleteNavigateTo:f,onFailure:x},recoveryOAuthStatus:{provider:b,action:"recover",isInAccountCreateFlow:!1,shouldCreateEth:!1,shouldCreateSol:!1}}),d(jg(b))):T(e)}})(),()=>clearTimeout(e)):void 0:T("User must be authenticated and have a Privy wallet before it can be connected")}),[t,a,c]),h.current=()=>{T("User exited before wallet could be connected"),s({shouldCallAuthOnSuccess:!1})},/*#__PURE__*/e.jsx(Mg,{connectionFailed:m,onClose:()=>s({shouldCallAuthOnSuccess:!1})})}},Lg=({style:t,color:n,...r})=>/*#__PURE__*/e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:n||"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...r,children:/*#__PURE__*/e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})}),Wg=t=>{let[r,i]=n.useState(!1);/*#__PURE__*/return e.jsxs(Dg,{color:t.color,onClick:()=>{i(!0),navigator.clipboard.writeText(t.text),setTimeout((()=>i(!1)),1500)},$justCopied:r,children:[r?/*#__PURE__*/e.jsx(Lg,{style:{height:"14px",width:"14px"},strokeWidth:"2"}):/*#__PURE__*/e.jsx(ol,{style:{height:"14px",width:"14px"}}),r?"Copied":"Copy"," ",t.itemName?t.itemName:"to Clipboard"]})};let Dg=/*#__PURE__*/a.styled.button.withConfig({displayName:"StyledCopytoClipboardButton",componentId:"sc-46f4187f-0"})(["display:flex;align-items:center;gap:6px;&&{margin:8px 2px;font-size:14px;color:",";font-weight:",";transition:color 350ms ease;:focus,:active{background-color:transparent;border:none;outline:none;box-shadow:none;}:hover{color:",";}:active{color:'var(--privy-color-foreground)';font-weight:medium;}@media (max-width:440px){margin:12px 2px;}}svg{width:14px;height:14px;}"],(e=>e.$justCopied?"var(--privy-color-foreground)":e.color||"var(--privy-color-foreground-3)"),(e=>e.$justCopied?"medium":"normal"),(e=>e.$justCopied?"var(--privy-color-foreground)":"var(--privy-color-foreground-2)"));const Rg=/*#__PURE__*/a.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 Og=e=>{if(!l.isHex(e))return e;try{let t=l.hexToString(e);return t.includes("�")?e:t}catch{return e}},Bg=e=>{try{let t=s.base64.decode(e),n=(new TextDecoder).decode(t);return n.includes("�")?e:n}catch{return e}},Ug=e=>JSON.stringify(e,null,2),zg=t=>{let{types:n,primaryType:r,...i}=t.typedData;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Gg,{data:i}),/*#__PURE__*/e.jsx(Wg,{text:Ug(t.typedData),itemName:"full payload to clipboard"})," "]})};const Hg=({method:n,messageData:r,copy:i,iconUrl:a,isLoading:o,success:s,walletProxyIsLoading:l,errorMessage:c,isCancellable:d,onSign:u,onCancel:p,onClose:h})=>/*#__PURE__*/e.jsx(ji,{title:i.title,subtitle:i.description,showClose:!0,onClose:h,icon:t.Edit,iconVariant:"subtle",helpText:c?/*#__PURE__*/e.jsx(qg,{children:c}):void 0,primaryCta:{label:i.buttonText,onClick:u,disabled:o||s||l,loading:o},secondaryCta:d?{label:"Not now",onClick:p,disabled:o||s||l}:void 0,watermark:!0,children:/*#__PURE__*/e.jsxs(Xi,{children:[a?/*#__PURE__*/e.jsx(Rg,{style:{alignSelf:"center"},size:"sm",src:a,alt:"app image"}):null,/*#__PURE__*/e.jsxs($g,{children:["personal_sign"===n&&/*#__PURE__*/e.jsx(Yg,{children:Og(r)}),"eth_signTypedData_v4"===n&&/*#__PURE__*/e.jsx(zg,{typedData:r}),"solana_signMessage"===n&&/*#__PURE__*/e.jsx(Yg,{children:Bg(r)})]})]})}),Vg={component:()=>{let{authenticated:t}=i.usePrivyContext(),{initializeWalletProxy:a,closePrivyModal:o}=r.usePrivyInternal(),{navigate:s,data:l,onUserCloseViaDialogOrKeybindRef:d}=Jn(),[u,p]=n.useState(!0),[h,g]=n.useState(""),[m,y]=n.useState(),[f,x]=n.useState(null),[v,w]=n.useState(!1);n.useEffect((()=>{t||s(dg)}),[t]),n.useEffect((()=>{a(3e4).then((e=>{p(!1),e||(g("An error has occurred, please try again."),y(new on(new an(h,c.ProviderErrors.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))}))}),[]);let{method:C,data:b,confirmAndSign:j,onSuccess:k,onFailure:T,uiOptions:A}=l.signMessage,S={title:A?.title||"Sign message",description:A?.description||"Signing this message will not cost you any fees.",buttonText:A?.buttonText||"Sign and continue"},E=e=>{e?k(e):T(m||new on(new an("The user rejected the request.",c.ProviderErrors.E4001_USER_REJECTED_REQUEST.eipCode))),o({shouldCallAuthOnSuccess:!1}),setTimeout((()=>{x(null),g(""),y(void 0)}),200)};d.current=()=>{E(f)};/*#__PURE__*/return e.jsx(Hg,{method:C,messageData:b,copy:S,iconUrl:A?.iconUrl&&"string"==typeof A.iconUrl?A.iconUrl:void 0,isLoading:v,success:null!==f,walletProxyIsLoading:u,errorMessage:h,isCancellable:A?.isCancellable,onSign:async()=>{w(!0),g("");try{let e=await j();x(e),w(!1),setTimeout((()=>{E(e)}),it)}catch(e){console.error(e),g("An error has occurred, please try again."),y(new on(new an(h,c.ProviderErrors.E32603_DEFAULT_INTERNAL_ERROR.eipCode))),w(!1)}},onCancel:()=>E(null),onClose:()=>E(f)})}};let $g=/*#__PURE__*/a.styled.div.withConfig({displayName:"MessageContainer",componentId:"sc-e01d451f-0"})(["flex:1;display:flex;flex-direction:column;gap:16px;"]),qg=/*#__PURE__*/a.styled.p.withConfig({displayName:"ErrorText",componentId:"sc-e01d451f-1"})(["&&{margin:0;width:100%;text-align:center;color:var(--privy-color-error-dark);font-size:14px;line-height:22px;}"]),Gg=/*#__PURE__*/a.styled(Jc).withConfig({displayName:"StyledDisplayJsonTree",componentId:"sc-e01d451f-2"})(["margin-top:0;"]),Yg=/*#__PURE__*/a.styled(Qc).withConfig({displayName:"StyledMessage",componentId:"sc-e01d451f-3"})(["margin-top:0;"]);exports.ASSOCIATED_TOKEN_PROGRAM_ID="ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",exports.AccountNotFoundScreen=ws,exports.Address=bs,exports.AffirmativeConsentScreen=rl,exports.AllowlistRejectionScreen=ic,exports.Apple=yt,exports.AuthenticateWithWalletScreen=vc,exports.AwaitingEvmToSolBridgingScreen=xp,exports.AwaitingExternalTransferScreen=vp,exports.AwaitingPasswordlessCodeScreen=Zh,exports.AwaitingSolToEvmBridgingScreen=Cp,exports.BASE_ACCOUNT_DATA_URI=tn,exports.Blobby=gn,exports.BlobbyFooter=vr,exports.BottomPusherContainer=qi,exports.Box=Sc,exports.BrowserExtensionWallet=yn,exports.ButtonLoader=Sr,exports.CLIENT_ANALYTICS_ID_KEY="privy:caid",exports.CODE_VERIFIER_KEY=st,exports.COINBASE_WALLET_DATA_URI=en,exports.CONNECTIONS_HISTORY_KEY=ct,exports.CUSTOMER_ACCESS_TOKEN_COOKIE_KEY="privy-token",exports.CUSTOMER_ACCESS_TOKEN_STORAGE_KEY="privy:token",exports.CaptchaError=qt,exports.CaptchaProvider=({children:t,id:r,captchaSiteKey:i,captchaEnabled:a})=>{let o=n.useRef(null),[s,l]=n.useState(),[c,u]=n.useState(),[p,h]=n.useState(!1),g=n.useMemo((()=>a?p||s||c?!p||s||c?s&&!c?{status:"success",token:s}:c?{status:"error",error:c}:{status:"ready"}:{status:"loading"}:{status:"ready"}:{status:"disabled"}),[a,s,c,p]);/*#__PURE__*/return e.jsx($t.Provider,{value:{...g,ref:o,enabled:a,siteKey:i,appId:r,setToken:l,setError:u,setExecuting:h,remove(){a&&(o.current?.remove(),h(!1),u(void 0),l(void 0))},reset(){a&&(o.current?.reset(),h(!1),u(void 0),l(void 0))},execute(){a&&(h(!0),o.current?.execute())},async waitForResult(){if(!a)return"";try{return await function(e,{interval:t=100,timeout:n=5e3}={}){return new Promise(((r,i)=>{let a,o=0,s=()=>{o>=n?i("Max attempts reached without result"):(a=e(),o+=t,null==a?setTimeout(s,t):r(a))};s()}))}((()=>o.current?.getResponse()),{interval:200,timeout:2e4})}catch(e){throw new qt("Captcha failed",null,d.PrivyErrorCode.CAPTCHA_TIMEOUT)}}},children:t})},exports.CaptchaScreen=oc,exports.CenteredItem=Gi,exports.CenteredItemWithGap=Ki,exports.CenteredItemWithPadding=Zi,exports.CenteredScreenHeader=za,exports.Chip=vu,exports.Chip$1=Ll,exports.CloseButton=_l,exports.ConnectEmailForm=ng,exports.ConnectOnlyLandingScreen=qp,exports.ConnectOnlyStatusScreen=Au,exports.ConnectOrCreateScreen=Uh,exports.ConnectPhoneNumberForm=Ch,exports.ConnectionLoader=br,exports.ConnectionStatusScreen=fc,exports.CopyableText=ul,exports.CopytoClipboardButton=Wg,exports.DEFAULT_API_TIMEOUT_MS=2e4,exports.DEFAULT_PRIVY_API_URL="https://auth.privy.io",exports.DEFAULT_SUCCESS_SCREEN_DURATION_MS=it,exports.DEFAULT_SUCCESS_SCREEN_EXTRA_LONG_DURATION_MS=at,exports.DEFAULT_SUCCESS_SCREEN_LONG_DURATION_MS=2500,exports.DEFAULT_TOKENS_DATA=Wi,exports.DEPRECATED_REFRESH_TOKEN="deprecated",exports.Discord=ft,exports.EmailUpdateForm=jl,exports.EmbeddedButton=Or,exports.EmbeddedWalletConnectingScreen=Fg,exports.EmbeddedWalletKeyExportScreen=Pg,exports.EmbeddedWalletOnAccountCreateScreen=nl,exports.ErrorMessage=Cl,exports.ErrorScreen=Os,exports.ErrorScreenView=Rs,exports.EthereumNullConnector=mn,exports.EthereumWalletConnector=pn,exports.Farcaster=Gp,exports.FarcasterConnectStatusScreen=ah,exports.FundingMethodSelectionScreen=$p,exports.Github=xt,exports.Google=vt,exports.Grow=ar,exports.HEADLESS_OAUTH_KEY="privy:headless_oauth",exports.Header=Nl,exports.Hide=hr,exports.IDENTITY_TOKEN_COOKIE_KEY="privy-id-token",exports.IDENTITY_TOKEN_STORAGE_KEY="privy:id_token",exports.InjectedWalletIcon=ju,exports.InputContainerForm=Tl,exports.Instagram=wt,exports.JUPITER_SWAP_PROGRAM_IDS=["JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"],exports.LAMPORTS_PER_SOL=Li,exports.LabelSm=nd,exports.LabelXs=Tc,exports.LandingScreen=dg,exports.Line=Ct,exports.LinkConflictScreen=Xs,exports.LinkedIn=bt,exports.Loader=Tr,exports.LoginMethodButton=ur,exports.LoginMethodIconWrapper=pr,exports.ManualTransferScreen=Hc,exports.Metamask=fn,exports.ModalFooter=Cr,exports.ModalHeader=Vr,exports.ModalProvider=t=>{let r=Gn(),i=t.authenticated,[a,o]=n.useState(t.initialScreen);n.useEffect((()=>{i||!t.initialScreen||t.initialScreen.isUnauthenticatedScreem||t.setInitialScreen(null)}),[i]);let s=n.useRef(null);n.useEffect((()=>{t.open||(s.current=null)}),[t.open]),n.useEffect((()=>{s.current=null}),[t.initialScreen]);let l={data:t.data,setModalData:t.setModalData,currentScreen:t.initialScreen,lastScreen:a,navigate:(e,n=!0)=>{t.setInitialScreen(e),n&&o(t.initialScreen)},navigateBack:()=>{t.setInitialScreen(a)},resetNavigation:()=>{t.setInitialScreen(null),o(null)},onUserCloseViaDialogOrKeybindRef:s};/*#__PURE__*/return e.jsxs(Xn.Provider,{value:l,children:[("string"==typeof r.appearance.logo||"img"===r.appearance.logo?.type)&&/*#__PURE__*/e.jsx(Qn,{src:"string"==typeof r.appearance.logo?r.appearance.logo:r.appearance.logo.props.src}),t.children]})},exports.MoonpayStatusScreen=Wp,exports.NetworkIcon=Gu,exports.NeutralSpinner=Qr,exports.OAUTH_DISABLE_SIGNUP_KEY="privy:oauth_disable_signup",exports.ON_RAMP_COMPLETE_ANALYTICS_EVENT=Dc,exports.OpenLinkButton=Yp,exports.PRIVY_ACCESS_TOKEN_STORAGE_KEY="privy:pat",exports.Phantom=xn,exports.PrimaryButton=Nr,exports.PrivyAppConfigProvider=({children:t,client:r,legacyClient:i,clientConfig:a,appClientId:o})=>{let[s,l]=n.useState(null),c=n.useMemo((()=>Hn(s??Vn,a,!!s,"undefined"!=typeof window?window.location.origin:void 0,o)),[s,a,o]);return n.useEffect((()=>{if(!s)return;let e=function(e){if(!e)return{};let{appearance:t,supportedChains:n,defaultChain:r,externalWallets:i,...a}=e;return{...a,...n?{supportedChains:n.map((e=>e.id))}:void 0,...r?{defaultChain:r.id}:void 0,...i?{walletConnect:i.walletConnect?{enabled:i.walletConnect.enabled}:void 0,coinbaseWallet:i.coinbaseWallet,solana:{connectors:i.solana?.connectors?.get().map((e=>e.walletClientType))}}:void 0}}(a),t=function(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t,i=0;i<e.length;i++)n=Math.imul(n^(t=e.charCodeAt(i)),2654435761),r=Math.imul(r^t,1597334677);return n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),4294967296*(2097151&(r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909)))+(n>>>0)}(JSON.stringify(e)).toString(),n=`privy:sent:${s.id}:${t}`;localStorage.getItem(n)||(i.createAnalyticsEvent({eventName:"sdk_initialize",payload:e}),localStorage.setItem(n,"t"))}),[a,s]),n.useEffect((()=>{s||(async()=>{try{await r.initialize();let e=r.app.getConfig();e.custom_api_url&&i.updateApiUrl(e.custom_api_url),l(e)}catch(e){console.warn("Error generating app config: ",e)}})()}),[]),/*#__PURE__*/e.jsx(qn.Provider,{value:{appConfig:c,isServerConfigLoaded:!!s},children:t})},exports.PrivyEventsContext=er,exports.PrivyIframeError=Wa,exports.PrivyPluginProvider=({children:t})=>{let r=n.useRef({});/*#__PURE__*/return e.jsx(ec.Provider,{value:{plugins:r},children:t})},exports.PrivyProviderRpcError=on,exports.PrivyProxyProvider=hn,exports.QrCode=wl,exports.RAYDIUM_SWAP_PROGRAM_IDS=["CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C","CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW"],exports.REFRESH_TOKEN_COOKIE_KEY="privy-refresh-token",exports.REFRESH_TOKEN_STORAGE_KEY="privy:refresh_token",exports.RecentlyUsedAccountProvider=({children:t})=>{let r=Gn(),[i,a]=n.useState({});return nr("login",{onComplete:({loginAccount:e})=>{e&&"passkey"!==e.type&&"cross_app"!==e.type&&("wallet"!==e.type||"privy"!==e.walletClientType)&&(Ze.put(rs(r.id),e.type),"wallet"===e.type?(Ze.put(is(r.id),e.walletClientType),Ze.put(as(r.id),e.chainType),a({accountType:e.type,walletClientType:e.walletClientType,chainType:e.chainType})):(Ze.del(is(r.id)),Ze.del(as(r.id)),a({accountType:e.type})))}}),n.useEffect((()=>{if(!r.id)return;let e=Ze.get(rs(r.id)),t=Ze.get(is(r.id)),n=Ze.get(as(r.id));e&&a("wallet"===e?{accountType:e,walletClientType:t,chainType:n}:{accountType:e})}),[r.id]),/*#__PURE__*/e.jsx(ns.Provider,{value:i,children:t})},exports.RefactorSpacerBottom=ta,exports.RefactorSpacerTop=ea,exports.Row=od,exports.Rows=ad,exports.RunEffectOnce=rt,exports.SESSION_COOKIE_KEY="privy-session",exports.SOLANA_FUNDING_PLUGIN_ID=wp,exports.SOLANA_LEDGER_PLUGIN_ID=nc,exports.STATE_CODE_KEY=ot,exports.SYSTEM_PROGRAM_ID="11111111111111111111111111111111",exports.ScreenLayout=ji,exports.ScrollContainer=Wl,exports.SecondaryButton=Lr,exports.SendSolanaTransactionScreenView=({img:t,title:r,subtitle:i,cta:a,instructions:o,network:s,blockExplorerUrl:l,isMissingFunds:d,submitError:u,parseError:p,total:h,swap:g,transactingWalletAddress:m,fee:y,balance:f,disabled:x,isSubmitting:v,isPreparing:w,isTokenPriceLoading:C,onClick:b,onClose:j,onBack:k})=>{let T=w||C,[A,S]=n.useState(!1);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(Vr,{onClose:j,backFn:k}),t&&/*#__PURE__*/e.jsx(Id,{children:t}),/*#__PURE__*/e.jsx(kc,{style:{marginTop:t?"1.5rem":0},children:r}),/*#__PURE__*/e.jsx(jc,{children:i}),/*#__PURE__*/e.jsxs(ad,{style:{marginTop:"2rem",marginBottom:".5rem"},children:[(h||T)&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Amount"}),/*#__PURE__*/e.jsx(cd,{$isLoading:T,children:h})]}),g&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Swap"}),/*#__PURE__*/e.jsx(cd,{children:g})]}),s&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Network"}),/*#__PURE__*/e.jsx(cd,{children:s})]}),(y||T)&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Estimated fee"}),/*#__PURE__*/e.jsx(cd,{$isLoading:T,children:y})]})]}),/*#__PURE__*/e.jsx(od,{children:/*#__PURE__*/e.jsxs(id,{onClick:()=>S((e=>!e)),children:[/*#__PURE__*/e.jsx("span",{children:"Advanced"}),/*#__PURE__*/e.jsx(B.ChevronDownIcon,{height:"16px",width:"16px",strokeWidth:"2",style:{transition:"all 300ms",transform:A?"rotate(180deg)":void 0}})]})}),A&&/*#__PURE__*/e.jsx(e.Fragment,{children:o.map(((t,n)=>"sol-transfer"===t.type?/*#__PURE__*/e.jsxs(Sd,{children:[/*#__PURE__*/e.jsx(od,{children:/*#__PURE__*/e.jsxs(Tc,{children:["Transfer ",t.withSeed?"with seed":""]})}),/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Amount"}),/*#__PURE__*/e.jsxs(cd,{children:[c.formatTokenAmount({amount:t.value,decimals:t.token.decimals})," ",t.token.symbol]})]}),!!t.toAccount&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Destination"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.toAccount,url:l})})]})]},n):"spl-transfer"===t.type?/*#__PURE__*/e.jsxs(Sd,{children:[/*#__PURE__*/e.jsx(od,{children:/*#__PURE__*/e.jsxs(Tc,{children:["Transfer ",t.token.symbol]})}),/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Amount"}),/*#__PURE__*/e.jsx(cd,{children:t.value.toString()})]}),!!t.fromAta&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Source"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.fromAta,url:l})})]}),!!t.toAta&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Destination"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.toAta,url:l})})]}),!!t.token.address&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Token"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.token.address,url:l})})]})]},n):"ata-creation"===t.type?/*#__PURE__*/e.jsxs(Sd,{children:[/*#__PURE__*/e.jsx(od,{children:/*#__PURE__*/e.jsx(Tc,{children:"Create token account"})}),/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Program ID"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.program,url:l})})]}),!!t.owner&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Owner"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.owner,url:l})})]})]},n):"create-account"===t.type?/*#__PURE__*/e.jsxs(Sd,{children:[/*#__PURE__*/e.jsx(od,{children:/*#__PURE__*/e.jsxs(Tc,{children:["Create account ",t.withSeed?"with seed":""]})}),!!t.account&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Account"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.account,url:l})})]}),/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Amount"}),/*#__PURE__*/e.jsxs(cd,{children:[c.formatTokenAmount({amount:t.value,decimals:9})," SOL"]})]})]},n):"spl-init-account"===t.type?/*#__PURE__*/e.jsxs(Sd,{children:[/*#__PURE__*/e.jsx(od,{children:/*#__PURE__*/e.jsx(Tc,{children:"Initialize token account"})}),!!t.account&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Account"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.account,url:l})})]}),!!t.mint&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Mint"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.mint,url:l})})]}),!!t.owner&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Owner"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.owner,url:l})})]})]},n):"spl-close-account"===t.type?/*#__PURE__*/e.jsxs(Sd,{children:[/*#__PURE__*/e.jsx(od,{children:/*#__PURE__*/e.jsx(Tc,{children:"Close token account"})}),!!t.source&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Source"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.source,url:l})})]}),!!t.destination&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Destination"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.destination,url:l})})]}),!!t.owner&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Owner"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.owner,url:l})})]})]},n):"spl-sync-native"===t.type?/*#__PURE__*/e.jsxs(Sd,{children:[/*#__PURE__*/e.jsx(od,{children:/*#__PURE__*/e.jsx(Tc,{children:"Sync native"})}),/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Program ID"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.program,url:l})})]})]},n):"raydium-swap-base-input"===t.type?/*#__PURE__*/e.jsxs(Sd,{children:[/*#__PURE__*/e.jsx(od,{children:/*#__PURE__*/e.jsxs(Tc,{children:["Raydium swap"," ",t.tokenIn&&t.tokenOut?`${t.tokenIn.symbol} → ${t.tokenOut.symbol}`:""]})}),/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Amount in"}),/*#__PURE__*/e.jsx(cd,{children:t.amountIn.toString()})]}),/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Minimum amount out"}),/*#__PURE__*/e.jsx(cd,{children:t.minimumAmountOut.toString()})]}),t.mintIn&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Token in"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.mintIn,url:l})})]}),t.mintOut&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Token out"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.mintOut,url:l})})]})]},n):"raydium-swap-base-output"===t.type?/*#__PURE__*/e.jsxs(Sd,{children:[/*#__PURE__*/e.jsx(od,{children:/*#__PURE__*/e.jsxs(Tc,{children:["Raydium swap"," ",t.tokenIn&&t.tokenOut?`${t.tokenIn.symbol} → ${t.tokenOut.symbol}`:""]})}),/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Max amount in"}),/*#__PURE__*/e.jsx(cd,{children:t.maxAmountIn.toString()})]}),/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Amount out"}),/*#__PURE__*/e.jsx(cd,{children:t.amountOut.toString()})]}),t.mintIn&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Token in"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.mintIn,url:l})})]}),t.mintOut&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Token out"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.mintOut,url:l})})]})]},n):"jupiter-swap-shared-accounts-route"===t.type?/*#__PURE__*/e.jsxs(Sd,{children:[/*#__PURE__*/e.jsx(od,{children:/*#__PURE__*/e.jsxs(Tc,{children:["Jupiter swap"," ",t.tokenIn&&t.tokenOut?`${t.tokenIn.symbol} → ${t.tokenOut.symbol}`:""]})}),/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"In amount"}),/*#__PURE__*/e.jsx(cd,{children:t.inAmount.toString()})]}),/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Quoted out amount"}),/*#__PURE__*/e.jsx(cd,{children:t.quotedOutAmount.toString()})]}),t.mintIn&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Token in"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.mintIn,url:l})})]}),t.mintOut&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Token out"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.mintOut,url:l})})]})]},n):"jupiter-swap-exact-out-route"===t.type?/*#__PURE__*/e.jsxs(Sd,{children:[/*#__PURE__*/e.jsx(od,{children:/*#__PURE__*/e.jsxs(Tc,{children:["Jupiter swap"," ",t.tokenIn&&t.tokenOut?`${t.tokenIn.symbol} → ${t.tokenOut.symbol}`:""]})}),/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Quoted in amount"}),/*#__PURE__*/e.jsx(cd,{children:t.quotedInAmount.toString()})]}),/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Amount out"}),/*#__PURE__*/e.jsx(cd,{children:t.outAmount.toString()})]}),t.mintIn&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Token in"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.mintIn,url:l})})]}),t.mintOut&&/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Token out"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.mintOut,url:l})})]})]},n):/*#__PURE__*/e.jsxs(Sd,{children:[/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Program ID"}),/*#__PURE__*/e.jsx(cd,{children:/*#__PURE__*/e.jsx(bs,{address:t.program,url:l})})]}),/*#__PURE__*/e.jsxs(od,{children:[/*#__PURE__*/e.jsx(nd,{children:"Data"}),/*#__PURE__*/e.jsx(cd,{children:t.discriminator})]})]},n)))}),/*#__PURE__*/e.jsx(ar,{}),u?/*#__PURE__*/e.jsx(Cl,{style:{marginTop:"2rem"},children:u.message}):p?/*#__PURE__*/e.jsx(Cl,{style:{marginTop:"2rem"},children:Ed}):null,/*#__PURE__*/e.jsx(Ad,{$useSmallMargins:!(!p&&!u),title:"Your wallet",address:m,balance:f,errMsg:w||p||u||!d?void 0:"Add funds on Solana to complete transaction."}),/*#__PURE__*/e.jsx(Nr,{style:{marginTop:"1rem"},loading:v,disabled:x||w,onClick:b,children:a}),/*#__PURE__*/e.jsx(vr,{})]})},exports.SendTransactionScreen=gu,exports.SignRequestScreen=Vg,exports.SiweFlow=It,exports.SiwsFlow=Nt,exports.SolanaNullConnector=Sn,exports.SolanaPriceDisplay=({quantities:t,tokenPrice:n,tokenSymbol:r="SOL",tokenDecimals:i=9})=>{let a=t.reduce(((e,t)=>e+t),0n),o=n&&"SOL"===r&&9===i?Di(a,n):void 0,s="SOL"===r&&9===i?Oi(a):`${l.formatUnits(a,i)} ${r}`;/*#__PURE__*/return e.jsx(zi,{children:o?/*#__PURE__*/e.jsx(e.Fragment,{children:"<$0.01"===o?
|
|
27
|
-
/*#__PURE__*/e.jsxs($i,{children:[/*#__PURE__*/e.jsx(Vi,{children:"<"}),"$0.01"]}):o}):s})},exports.SolanaWalletConnector=An,exports.Spotify=jt,exports.Subtitle=jc,exports.TOKEN_2022_PROGRAM_ID="TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb",exports.TOKEN_PROGRAM_ID="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",exports.TelegramAuthFlow=class{async authenticate(){if(!this.api)throw new d.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(d.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 d.formatApiError(e)}}async link(){if(!this.api)throw new d.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(d.telegramAccountLinkPath,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw d.formatApiError(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}},exports.TelegramAuthScreen=Ph,exports.Tiktok=kt,exports.Title=kc,exports.TodoItem=Eu,exports.TodoList=Su,exports.TransactionDetails=Aa,exports.TransactionErrorView=Md,exports.TransferFromWalletScreen=jp,exports.Twitch=Tt,exports.Twitter=At,exports.UseWalletsContext=Na,exports.UserLimitReachedScreen=gc,exports.VERSION="3.3.0
|
|
27
|
+
/*#__PURE__*/e.jsxs($i,{children:[/*#__PURE__*/e.jsx(Vi,{children:"<"}),"$0.01"]}):o}):s})},exports.SolanaWalletConnector=An,exports.Spotify=jt,exports.Subtitle=jc,exports.TOKEN_2022_PROGRAM_ID="TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb",exports.TOKEN_PROGRAM_ID="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",exports.TelegramAuthFlow=class{async authenticate(){if(!this.api)throw new d.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(d.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 d.formatApiError(e)}}async link(){if(!this.api)throw new d.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(d.telegramAccountLinkPath,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw d.formatApiError(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}},exports.TelegramAuthScreen=Ph,exports.Tiktok=kt,exports.Title=kc,exports.TodoItem=Eu,exports.TodoList=Su,exports.TransactionDetails=Aa,exports.TransactionErrorView=Md,exports.TransferFromWalletScreen=jp,exports.Twitch=Tt,exports.Twitter=At,exports.UseWalletsContext=Na,exports.UserLimitReachedScreen=gc,exports.VERSION="3.3.0",exports.Value=cd,exports.WALLET_PROXY_TIMEOUT=3e4,exports.WalletCards=Al,exports.WalletConnectV2WalletConnector=Kn,exports.WalletConnector=dn,exports.WalletIcon=Fl,exports.WalletInfoCard=Lc,exports.WalletLink=ka,exports.areWalletArraysEqual=cn,exports.close=()=>{let e=Dl.getState().resolvers;e||console.warn("useActiveWalletStore: Called close while modal was not open"),Dl.setState({isModalOpen:!1}),e?.resolve({wallet:Dl.getState().wallet})},exports.convertInitDataRawToTelegramWebAppData=Zt,exports.createCodeVerifier=pt,exports.createStateCode=ht,exports.createWalletAtIndex=Qa,exports.deriveCodeChallengeFromCodeVerifier=gt,exports.detectCompletingTelegramFlow=function(){let e;return(e=function(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),n=e.get("hash"),r=Number(e.get("auth_date")||""),i=e.get("first_name");if(t&&i&&r&&n)return Object.fromEntries(e.entries())}())?(Kt(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=Zt(e.replace("#tgWebAppData=","")),{user:n,auth_date:r,hash:i}=t;return n&&r&&i?t:void 0}())?(Kt(),{flowType:"web-app",authData:e}):void 0},exports.detectInjectedConnectors=async function({store:e,walletList:t,externalWalletConfig:n,walletChainType:r,timeout:i=3e3}){let a=!1,o=window;return new Promise((s=>{function l(){if(a)return;a=!0,window.removeEventListener("ethereum#initialized",l);let i=e.getProviders();console.debug("Detected injected providers:",i.map((e=>e.info)));let o=[];for(let e of i)t.includes("coinbase_wallet")&&"com.coinbase.wallet"===e.info.rdns||"solana-only"===r&&"app.phantom"===e.info.rdns||o.push({type:e.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:e});if("solana-only"!==r)for(let e of function(){let e=window,t=e.ethereum;if(!t)return[];let n=[];if(t.providers?.length)for(let e of t.providers)e&&n.push(e);return n.push(e.ethereum),n}()){let t=_t(e);if(!i.some((e=>e.info.name===t))){if(Mt(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"!==n.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()}),i))}))},exports.e=mt,exports.e$1=function(){try{let e="privy:__session_storage__test",t=new Ye;return t.put(e,"blobby"),t.del(e),!0}catch(e){return!1}},exports.e$2=Fa,exports.e$3=ku,exports.embeddedWalletRecoveryScreen=jg,exports.emitPrivyEvent=rr,exports.errorIndicatesMaxMfaRetries=function(e){return!!Da(e)&&"mfa_verification_max_attempts_reached"===e.type},exports.errorIndicatesMfaCanceled=function(e){return!!function(e){let t=e.type;return"string"==typeof t&&"client_error"===t}(e)&&"MFA canceled"===e.message},exports.errorIndicatesMfaRateLimit=function(e){return!(!Da(e)||!e.message.includes("code 429"))},exports.errorIndicatesMfaTimeout=function(e){return!!Da(e)&&"mfa_timeout"===e.type},exports.errorIndicatesMfaVerificationFailed=function(e){return!!Da(e)&&"missing_or_invalid_mfa"===e.type},exports.errorIndicatesRecoveryIsNeeded=Ra,exports.fetchWalletBalance=Rc,exports.formatChainIdToCAIP2=Ht,exports.formatConnectorError=rn,exports.formatErc20TokenAmount=Zc,exports.formatWalletAddress=Rt,exports.generateTypedDataWithDomainType=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},n=e.types.EIP712Domain??Object.entries(e.domain).map((([e,n])=>{if(null!=n&&"string"==typeof e&&e in t)return{name:e,type:t[e]}})).filter((e=>void 0!==e));return{...e,types:{...e.types,EIP712Domain:n}}},exports.getChainName=Oc,exports.getCodeVerifier=function(){let e=Ze.get(st);if(!e)throw new d.PrivyClientError("Authentication error.");return e},exports.getEntropyDetailsForUser=Xt,exports.getErc20Balance=Uc,exports.getErc20TokenInfo=qc,exports.getFormattedUsdFromLamports=Di,exports.getGuestCredentialStorageKey=e=>`privy:guest:${e}`,exports.getJsonRpcEndpointFromChain=Wt,exports.getNativeCurrencyFromLamports=Oi,exports.getNativeCurrencyFromWei=Ni,exports.getPrivyWalletsWithFilter=Ka,exports.getProviderAccessTokenStorageKey=e=>`privy:cross-app:${e}`,exports.getPublicClient=Lt,exports.getRpcTimeout=un,exports.getUsdcMintAddress=Bc,exports.getWalletConfigForConnector=Cn,exports.i=mu,exports.invokeUntilSettled=Ut,exports.isBaseConnectedEthereumWallet=ln,exports.isBaseConnectedSolanaWallet=function(e){return"solana"===e.type},exports.isEthereumWalletConnector=function(e){return"ethereum"===e.chainType},exports.isSolanaWalletConnector=En,exports.l=Vl,exports.loadConnectionHistory=jn,exports.mobileWalletsConfig=wn,exports.open=async()=>{let e,t,n=new Promise(((n,r)=>{e=n,t=r}));return Rl.setState({}),Dl.setState({isModalOpen:!0,resolvers:{resolve:e,reject:t}}),await n},exports.openHref=nt,exports.parseAdditionalSigners=e=>e?.map((e=>({signer_id:e.signerId,override_policy_ids:e.policyIds}))),exports.prepareSiweMessageWithNonce=Et,exports.prepareSiwsMessageWithNonce=Pt,exports.prepareTransactionRequest=Ma,exports.privyEventsDefault={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:[]},accessToken:{onAccessTokenGranted:[],onAccessTokenRemoved:[]},oAuthAuthorization:{onOAuthTokenGrant:[]},fundWallet:{onUserExited:[]},fundSolanaWallet:{onUserExited:[]},customAuth:{onAuthenticated:[],onUnauthenticated:[]}},exports.randomBytes=ut,exports.s=Ze,exports.setActiveWallet=Ol,exports.setExternalWalletState=Pn,exports.shouldCreateEmbeddedEthWallet=gs,exports.shouldCreateEmbeddedSolWallet=ys,exports.shouldProceedtoEmbeddedWalletCreationFlow=xs,exports.stripUrlOAuthParamsAndRemoveStateCode=St,exports.toActiveWalletKey=Bl,exports.toDisplayFromAccountType=ts,exports.toEmbeddedWalletSetRecoveryScreen=bg,exports.toHex=e=>"string"==typeof e?e:"0x"+e.toString(16),exports.toSolanaWalletClientType=Tn,exports.triggerPopup=Oa,exports.updateBalance=(e,t,n)=>{Rl.setState((r=>({[e]:{...r[e],[t]:n}})))},exports.useActiveWalletStore=Dl,exports.useAppConfig=Gn,exports.useBalance=(e,t)=>Rl((n=>n[e]?.[t])),exports.useCaptcha=Gt,exports.useEmitPrivyEvent=ir,exports.useGetSolPrice=Ia,exports.useGetTokenPrice=Pa,exports.useIsModalOpen=()=>Dl((e=>e.isModalOpen)),exports.useIsServerConfigLoaded=()=>{let{isServerConfigLoaded:e}=n.useContext(qn);return e},exports.usePlugins=tc,exports.usePrivyEventSubscription=nr,exports.usePrivyModal=Jn,exports.useRecentlyUsedLogin=os,exports.useRegisterPlugin=(...e)=>{let{plugins:t}=n.useContext(ec);n.useEffect((()=>{for(let n of e)t.current[n.id]=n;return()=>{for(let n of e)delete t.current[n.id]}}),[t])},exports.useWalletBalance=Wc,exports.useWallets=_a,exports.validateEmail=Dt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@abstract-foundation/agw-client"),r=require("@abstract-foundation/agw-client/actions"),n=require("viem"),t=require("viem/accounts"),a=require("viem/chains"),i=require("./privy-context-NMR-GjnL.js"),o=require("./SignRequestScreen-
|
|
1
|
+
"use strict";var e=require("@abstract-foundation/agw-client"),r=require("@abstract-foundation/agw-client/actions"),n=require("viem"),t=require("viem/accounts"),a=require("viem/chains"),i=require("./privy-context-NMR-GjnL.js"),o=require("./SignRequestScreen-CvBcoZRA.js"),s=require("./internal-context-DNWjSiYq.js"),c=require("./getEmbeddedConnectedWallet-6TsVZJkD.js"),l=require("./smart-wallets-Cgmp6lBz.js");require("react"),require("react/jsx-runtime"),require("lucide-react"),require("styled-components"),require("@privy-io/urls"),require("@scure/base"),require("@privy-io/js-sdk-core"),require("./paths-B00ZrFQm.js"),require("ofetch"),require("tinycolor2"),require("@heroicons/react/24/outline/UserCircleIcon"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("@heroicons/react/20/solid/CheckIcon"),require("@heroicons/react/24/outline/EnvelopeIcon"),require("@heroicons/react/24/outline/PhoneIcon"),require("react-device-detect"),require("@heroicons/react/24/outline/ExclamationTriangleIcon"),require("@heroicons/react/24/outline/WalletIcon"),require("@heroicons/react/24/outline/ExclamationCircleIcon"),require("@heroicons/react/24/outline/Square2StackIcon"),require("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),require("@heroicons/react/24/outline/LockClosedIcon"),require("@heroicons/react/24/outline/PencilSquareIcon"),require("jose"),require("@heroicons/react/24/outline/ArrowPathIcon"),require("@heroicons/react/24/outline/EyeIcon"),require("@heroicons/react/24/outline/EyeSlashIcon"),require("@heroicons/react/24/outline/KeyIcon"),require("@heroicons/react/24/solid/CheckCircleIcon"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("@heroicons/react/24/outline/ShieldCheckIcon"),require("@heroicons/react/24/outline"),require("@tanstack/react-virtual"),require("@heroicons/react/24/outline/CheckIcon"),require("qrcode"),require("viem/utils"),require("eventemitter3"),require("zustand"),require("@walletconnect/ethereum-provider"),require("@heroicons/react/24/outline/CreditCardIcon"),require("@heroicons/react/24/outline/QrCodeIcon"),require("@heroicons/react/24/solid/ArrowsRightLeftIcon"),require("@heroicons/react/24/outline/InformationCircleIcon"),require("@heroicons/react/24/outline/ClipboardDocumentIcon"),require("@heroicons/react/24/outline/ChevronDownIcon"),require("@privy-io/ethereum"),require("@heroicons/react/24/outline/CheckCircleIcon"),require("@heroicons/react/24/outline/GlobeAltIcon"),require("@headlessui/react"),require("@heroicons/react/24/outline/FingerPrintIcon"),require("permissionless"),require("permissionless/accounts"),require("permissionless/clients/pimlico"),require("viem/account-abstraction"),exports.useAbstractSmartWallets=function(){let{user:u}=i.usePrivyContext(),{hideWalletUIs:d,openPrivyModal:p,chains:h,appId:y,rpcConfig:g,client:m}=s.usePrivyInternal(),q=o.useAppConfig(),{wallets:I}=o.useWallets(),{setModalData:v}=o.usePrivyModal(),f=i.getPrivyEthereumWallet(u),T=!!f&&i.getIsUnifiedWallet(f),C=async(r=a.abstractTestnet.id)=>{let i=c.getEmbeddedConnectedWallet(I);if(!i)throw Error("No connected wallet found");let s="string"==typeof r?n.hexToNumber(r):r;if(![a.abstractTestnet.id,2741,a.zksync.id].includes(s))throw Error("Error, only Abstract and ZKSync Era chains are supported");let l=h.find((e=>e.id===s));if(!l)throw Error("Chain not configured");await i.switchChain(l.id);let u=await i.getEthereumProvider(),d=n.createWalletClient({account:i.address,transport:n.custom(u)}),p=t.toAccount({address:i.address,signMessage:d.signMessage,signTransaction:d.signTransaction,signTypedData:d.signTypedData});return await e.createAbstractClient({chain:l,transport:n.http(o.getJsonRpcEndpointFromChain(l,g,y)),publicTransport:n.http(o.getJsonRpcEndpointFromChain(l,g,y)),signer:p})};return{signMessage:async({message:e},r)=>{let n=await C(r);return new Promise((async(r,t)=>{let{entropyId:a,entropyIdVerifier:i}=o.getEntropyDetailsForUser(u);d.current=!0,v({connectWallet:{recoveryMethod:f.recoveryMethod,connectingWalletAddress:f.address,isUnifiedWallet:T,entropyId:a,entropyIdVerifier:i,onCompleteNavigateTo:o.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"personal_sign",data:e,confirmAndSign:()=>n.signMessage({message:e}),onSuccess:e=>r(e),onFailure:t,uiOptions:{isCancellable:!0}}}),p(o.EmbeddedWalletConnectingScreen)})).finally((()=>{d.current=!1}))},signTypedData:async(e,r)=>{let n=await C(r);return new Promise((async(r,t)=>{d.current=!0;let{entropyId:a,entropyIdVerifier:i}=o.getEntropyDetailsForUser(u);v({connectWallet:{recoveryMethod:f.recoveryMethod,connectingWalletAddress:f.address,isUnifiedWallet:T,entropyId:a,entropyIdVerifier:i,onCompleteNavigateTo:o.SignRequestScreen,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>n.signTypedData(e),onSuccess:e=>r(e),onFailure:t,uiOptions:{isCancellable:!0}}}),p(o.EmbeddedWalletConnectingScreen)})).finally((()=>{d.current=!1}))},sendTransaction:async e=>{let n=await C(e.chainId),t=[],a="calls"in e&&void 0!==e.calls;return t=a?[...e.calls]:[e],new Promise((async(i,s)=>{d.current=!0;let{entropyId:c,entropyIdVerifier:h}=o.getEntropyDetailsForUser(u);v({connectWallet:{recoveryMethod:f.recoveryMethod,connectingWalletAddress:f.address,isUnifiedWallet:T,entropyId:c,entropyIdVerifier:h,onCompleteNavigateTo:o.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:l.callsToTransactionRequests({calls:t,chain:n.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),entropyId:c,entropyIdVerifier:h,transactingWalletAddress:n.account.address,transactingWalletIndex:void 0,prepareTransactionRequest:async()=>{let t=a?r.getBatchTransactionObject(n.account.address,e):e;return await n.prepareAbstractTransactionRequest(t)},scanTransaction:async()=>{if(!m)throw Error("Privy client not found");let t=a?r.getBatchTransactionObject(n.account.address,e):e,i=await n.prepareAbstractTransactionRequest(t);return await m.scanTransaction({metadata:{domain:q.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:i.from,to:i.to,value:i.value?.toString(),gas:i.gas?.toString(),gasPrice:i.gasPrice?.toString(),nonce:i.nonce?.toString(),data:i.data,eip_712_meta:{paymaster_params:{paymaster:i.paymaster,paymaster_input:i.paymasterInput}}}]}})},signOnly:!1,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:()=>a?n.sendTransactionBatch(e):n.sendTransaction(e),onSuccess:e=>i(e.hash),onFailure:s,uiOptions:{isCancellable:!0}}}),p(o.EmbeddedWalletConnectingScreen)})).finally((()=>{d.current=!1}))},signTransaction:async e=>{let n=await C(e.chainId),t=[],a="calls"in e&&void 0!==e.calls;return t=a?[...e.calls]:[e],new Promise((async(i,s)=>{d.current=!0;let{entropyId:c,entropyIdVerifier:h}=o.getEntropyDetailsForUser(u);v({connectWallet:{recoveryMethod:f.recoveryMethod,connectingWalletAddress:f.address,isUnifiedWallet:T,entropyId:c,entropyIdVerifier:h,onCompleteNavigateTo:o.SendTransactionScreen,onFailure:()=>{}},sendTransaction:{transactionRequests:l.callsToTransactionRequests({calls:t,chain:n.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),entropyId:c,entropyIdVerifier:h,transactingWalletAddress:n.account.address,transactingWalletIndex:void 0,prepareTransactionRequest:async()=>{let t=a?r.getBatchTransactionObject(n.account.address,e):e;return await n.prepareAbstractTransactionRequest(t)},scanTransaction:async()=>{if(!m)throw Error("Privy client not found");let t=a?r.getBatchTransactionObject(n.account.address,e):e,i=await n.prepareAbstractTransactionRequest(t);return await m.scanTransaction({metadata:{domain:q.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:i.from,to:i.to,value:i.value?.toString(),gas:i.gas?.toString(),gasPrice:i.gasPrice?.toString(),nonce:i.nonce?.toString(),data:i.data,eip_712_meta:{paymaster_params:{paymaster:i.paymaster,paymaster_input:i.paymasterInput}}}]}})},signOnly:!0,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:async()=>{let t=a?r.getBatchTransactionObject(n.account.address,e):e,i=await n.prepareAbstractTransactionRequest(t);return n.signTransaction(i)},onSuccess:e=>i(e.hash),onFailure:s,uiOptions:{isCancellable:!0}}}),p(o.EmbeddedWalletConnectingScreen)})).finally((()=>{d.current=!1}))}}};
|