@privy-io/react-auth
Version:
React client for the Privy Auth API
3 lines (2 loc) • 20.9 kB
JavaScript
import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import a from"@heroicons/react/24/outline/UserCircleIcon";import l,{useState as r,useEffect as n,useRef as o,useMemo as s}from"react";import{styled as c}from"styled-components";import{T as d,M as p,B as h}from"./ModalHeader-BLGC-7ev.mjs";import{u}from"./context-Bycd1SKV.mjs";import{U as g,G as m,H as f,V as y,F as w,W as v,X as C,Y as b,e as k,Z as S,d as T,_ as M,$ as x,a0 as A}from"./useActiveWallet-Bsy5GTCV.mjs";import{u as L}from"./internal-context-e-Eni5bG.mjs";import{u as I,a as W,i as N}from"./get-is-unified-wallet-DvKS5IUO.mjs";import{a as E,t as P}from"./index-CCyaupaz.mjs";import{u as j,c as D,d as O}from"./ConnectWalletView-eQbJO3Pg.mjs";import{Mail as R,Smartphone as _,UserCircle as V}from"lucide-react";import{C as U}from"./ConnectEmailForm--PZXgvw4.mjs";import{C as F}from"./Chip-Bsgj4Yc-.mjs";import{F as $}from"./farcaster-DPlSjvF5.mjs";import{toObjectKeys as z}from"@privy-io/js-sdk-core";import H from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import G from"@heroicons/react/24/outline/FingerPrintIcon";import{L as q}from"./Link-DwjLfHwW.mjs";import{C as B}from"./ConnectPhoneForm-DoYmHBv3.mjs";import{T as K,a as X,I as Z,S as J,L as Q,G as Y,b as ee,D as te,A as ie}from"./twitter-6jomarO4.mjs";import{T as ae,L as le}from"./twitch-5IOe4sIQ.mjs";import{T as re}from"./telegram-B-JqnkqZ.mjs";import{W as ne}from"./WalletOverflowButton-DV9Pe-aq.mjs";import{S as oe}from"./ScreenLayout-CddsD3Of.mjs";const se=()=>{let t=u(),i=t?.appearance?.logo,a=`${t?.name} logo`,r={maxHeight:"90px",maxWidth:"180px"};return i?"string"==typeof i?/*#__PURE__*/e("img",{src:i,alt:a,style:r}):"svg"===i.type||"img"===i.type?/*#__PURE__*/l.cloneElement(i,{alt:a,style:r}):(console.warn("`config.appearance.logo` must be a string, or an SVG / IMG element. Nothing will be rendered."),null):null},ce=t=>{let i=u();return i?.appearance.logo?/*#__PURE__*/e(de,{...t,children:/*#__PURE__*/e(se,{})}):null},de=/*#__PURE__*/c.div.withConfig({displayName:"AppLogoContainer",componentId:"sc-b210074-0"})(["display:flex;flex-direction:column;align-items:center;padding:24px 0;flex-grow:1;justify-content:center;"]),pe=({name:t,logoUrl:i,size:a="38px"})=>"string"==typeof i?/*#__PURE__*/e("img",{src:i,alt:`${t??"Provider app"} logo`,style:{width:a,height:a,maxHeight:"90px",maxWidth:"180px",borderRadius:"8px"}}):
/*#__PURE__*/e("span",{}),he=({appId:a})=>{let[l,o]=r(void 0),{startCrossAppAuthFlow:s,authenticated:c}=I(),{client:d}=L();return n((()=>{(async()=>{d&&o(await d.getCrossAppProviderDetails(a))})()}),[d]),/*#__PURE__*/e(g,{onClick:()=>s({appId:a,action:c?"link":"login"}),disabled:!l,children:l?/*#__PURE__*/t(i,{children:[/*#__PURE__*/e(pe,{name:l.name,logoUrl:l.icon_url||void 0,size:"24px"})," ",l.name]}):/*#__PURE__*/e(m,{})})},ue=({isEditable:a,setIsEditable:l,defaultValue:r})=>{let n=o(null);/*#__PURE__*/return t(i,{children:[/*#__PURE__*/e(f,{$if:!a,children:/*#__PURE__*/e(U,{ref:n,defaultValue:r})}),/*#__PURE__*/e(f,{$if:a,children:/*#__PURE__*/t(g,{onClick:()=>{l(),setTimeout((()=>{n.current?.focus()}),0)},children:[/*#__PURE__*/e(y,{children:/*#__PURE__*/e(R,{})}),"Continue with Email"]})})]})},ge=()=>{let[i,a]=r(!1),{currentScreen:l,navigate:n,setModalData:o,data:s}=W(),{enabled:c,token:d}=E(),{initLoginWithFarcaster:p}=L(),{accountType:h}=w();/*#__PURE__*/return t(g,{onClick:async()=>{a(!0);try{c&&!d?(o({captchaModalData:{callback:e=>p(e,s?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:"FarcasterConnectStatusScreen",onErrorNavigateTo:"ErrorScreen"}}),n("CaptchaScreen")):(await p(d,s?.login?.disableSignup),n("FarcasterConnectStatusScreen"))}catch(e){o({errorModalData:{error:e,previousScreen:l||"LandingScreen"}}),n("ErrorScreen")}finally{a(!1)}},disabled:!1,children:[/*#__PURE__*/e($,{width:32,height:32})," Farcaster",i&&/*#__PURE__*/e(m,{}),"farcaster"===h&&/*#__PURE__*/e(me,{color:"gray",children:"Recent"})]})};let me=/*#__PURE__*/c(F).withConfig({displayName:"StyledChip",componentId:"sc-2f1c7323-0"})(["margin-left:auto;"]);const fe=({...i})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",...i,children:[/*#__PURE__*/t("g",{clipPath:"url(#clip0_2856_1743)",children:[/*#__PURE__*/e("path",{d:"M22.1673 8.24075V16.3642C22.1673 17.3256 21.3421 18.105 20.3241 18.105H17.0028M22.1673 8.24075C22.1673 7.27936 21.3421 6.5 20.3241 6.5H11.5302M22.1673 8.24075V8.42852C22.1673 9.03302 21.8352 9.59423 21.2901 9.91105L15.1463 13.4818C14.5539 13.8261 13.8067 13.8261 13.2143 13.4818L10.1621 11.5401",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),/*#__PURE__*/e("path",{d:"M3.12913 6.64816C0.508085 12.9507 3.49251 20.1847 9.79504 22.8057L11.5068 23.5176C12.4522 23.9108 13.7783 23.2222 14.1714 22.2768L14.6054 21.2333C14.7687 20.8406 14.6438 20.3871 14.3024 20.1334L11.2872 17.8927C10.9878 17.6702 10.5843 17.6488 10.2632 17.8384L9.11575 18.5156C8.78274 18.7121 8.3597 18.6844 8.07552 18.4221C5.94293 16.4542 4.77629 13.6264 4.90096 10.7273C4.91757 10.3409 5.19796 10.023 5.57269 9.92753L6.86381 9.59869C7.22522 9.50664 7.49627 9.20696 7.55169 8.83815L8.10986 5.12321C8.17306 4.70259 7.94188 4.29293 7.54915 4.1296L6.50564 3.69564C5.56026 3.30248 4.23416 3.99103 3.84101 4.9364L3.12913 6.64816Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),/*#__PURE__*/e("defs",{children:/*#__PURE__*/e("clipPath",{id:"clip0_2856_1743",children:/*#__PURE__*/e("rect",{x:"0.5",y:"0.5",width:"24",height:"24",rx:"6",fill:"white"})})})]}),ye=({chainType:i,withPadding:a})=>{let l="";return l="ethereum-only"===i||"ethereum-and-solana"===i?"Rainbow, Phantom, or Coinbase Wallet":"Phantom or Solflare",/*#__PURE__*/e(v,{$withPadding:a,children:/*#__PURE__*/t(C,{children:[/*#__PURE__*/e(H,{style:{color:"var(--privy-color-warn)",height:48,width:48}}),/*#__PURE__*/e("h3",{children:"No wallets available"}),/*#__PURE__*/t("p",{children:["Please download an external wallet provider, like ",l,"."]})]})},"empty-wallet-state")},we=()=>{let{enabled:i,token:a}=E(),{navigate:l,setModalData:r,data:n}=W(),o=u(),{initLoginWithPasskey:c}=L(),d=()=>{o.loginConfig.passkeysForSignupEnabled?l("PasskeySelectSignupOrLogin"):(async()=>{i&&!a?(r({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>c({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:"PasskeyStatusScreen",onErrorNavigateTo:"ErrorScreen"}}),l("CaptchaScreen")):(await c({withPrivyUi:!0,captchaToken:a}),r({passkeyAuthModalData:{passkeySignupFlow:!1}}),l("PasskeyStatusScreen"))})()};return 0===s((()=>{let e=n?.login?.loginMethods;return e?e.filter((e=>"passkey"!==e)).length:Object.entries(o.loginMethods).filter((([e,t])=>t)).filter((([e])=>"passkey"!==e)).length}),[o.loginMethods,n?.login])?/*#__PURE__*/t(g,{onClick:d,children:[/*#__PURE__*/e(G,{})," Continue with passkey"]}):/*#__PURE__*/e(q,{as:"button",onClick:d,size:"sm",variant:"navigation",style:{width:"100%",justifyContent:"center"},children:"I have a passkey"})},ve=({isEditable:a,setIsEditable:l,defaultValue:r})=>{let n=o(null),{authenticated:s}=I(),{navigate:c,setModalData:d,currentScreen:p,data:h}=W(),{initLoginWithSms:m}=L(),{enabled:w,token:v}=E(),{whatsAppEnabled:C}=u();/*#__PURE__*/return t(i,{children:[/*#__PURE__*/e(f,{$if:!a,children:/*#__PURE__*/e(B,{ref:n,onSubmit:async function({qualifiedPhoneNumber:e}){if(!w||v||s)try{await m({phoneNumber:e,captchaToken:v,withPrivyUi:!0,disableSignup:h?.login?.disableSignup}),c("AwaitingPasswordlessCodeScreen")}catch(e){d({errorModalData:{error:e,previousScreen:p||"LandingScreen"}}),c("ErrorScreen")}else d({captchaModalData:{callback:t=>m({phoneNumber:e,captchaToken:t,withPrivyUi:!0,disableSignup:h?.login?.disableSignup}),userIntentRequired:!1,onSuccessNavigateTo:"AwaitingPasswordlessCodeScreen",onErrorNavigateTo:"ErrorScreen"}}),c("CaptchaScreen")},defaultValue:r})}),/*#__PURE__*/e(f,{$if:a,children:/*#__PURE__*/t(g,{onClick:()=>{l(),setTimeout((()=>{n.current?.focus()}),0)},children:[/*#__PURE__*/e(y,{children:/*#__PURE__*/e(_,{})}),"Continue with ",C?"WhatsApp":"SMS"]})})]})};let Ce={apple:{logo:ie,displayName:"Apple"},discord:{logo:te,displayName:"Discord"},github:{logo:ee,displayName:"GitHub"},google:{logo:Y,displayName:"Google"},linkedin:{logo:Q,displayName:"LinkedIn"},spotify:{logo:J,displayName:"Spotify"},instagram:{logo:Z,displayName:"Instagram"},twitter:{logo:X,displayName:"Twitter"},tiktok:{logo:K,displayName:"TikTok"},line:{logo:le,displayName:"LINE"},twitch:{logo:ae,displayName:"Twitch"}};const be=({provider:i})=>{let{enabled:a,token:l}=E(),{navigate:n,setModalData:o,data:c}=W(),[d,p]=r(!1),h=u(),{initLoginWithOAuth:m}=L(),{accountType:f}=w(),v=s((()=>f&&"guest"!==f&&"authorization_key"!==f&&"cross_app"!==f?P(f):null),[f]),{displayName:C,logo:b}=s((()=>{if(N(i)){let t=h.customOAuthProviders.find((e=>e.provider===i)),a=t.provider_icon_url,l=t.provider_display_name;return{displayName:l,logo:({style:t})=>/*#__PURE__*/e("img",{alt:`${l} logo`,src:a,style:t})}}return Ce[i]}),[i,h.customOAuthProviders]);/*#__PURE__*/return t(g,{onClick:()=>{p(!0),setTimeout((()=>{p(!1)}),2e3),a&&!l?(o({captchaModalData:{callback:e=>m(i,e,c?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:"ErrorScreen"}}),n("CaptchaScreen")):m(i,void 0,c?.login?.disableSignup)},disabled:d,children:[/*#__PURE__*/e(y,{$fullSize:!0,children:/*#__PURE__*/e(b,{style:{width:"32px",height:"32px"}})}),C,v?.loginMethod===i&&/*#__PURE__*/e(ke,{color:"gray",children:"Recent"})]})};let ke=/*#__PURE__*/c(F).withConfig({displayName:"StyledChip",componentId:"sc-e74c7091-0"})(["margin-left:auto;"]);const Se=()=>{let{enabled:i,token:a}=E(),{navigate:l,setModalData:n,data:o}=W(),[s,c]=r(!1),{initLoginWithTelegram:d}=L(),{accountType:p}=w();async function h(e){try{await d(e,o?.login?.disableSignup),n({telegramAuthModalData:{seamlessAuth:!1}}),l("TelegramAuthScreen")}catch(e){console.error(e),c(!1)}}/*#__PURE__*/return t(g,{onClick:async function(){if(c(!0),i&&!a)return n({captchaModalData:{callback:h,userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:"ErrorScreen"}}),void l("CaptchaScreen");await h(a)},disabled:s,children:[/*#__PURE__*/e(re,{width:32,height:32}),"Telegram","telegram"===p&&/*#__PURE__*/e(Te,{color:"gray",children:"Recent"})]})};let Te=/*#__PURE__*/c(F).withConfig({displayName:"StyledChip",componentId:"sc-639dd483-0"})(["margin-left:auto;"]);const Me=({onClick:i,text:a,icon:l})=>/*#__PURE__*/t(g,{onClick:i,children:[/*#__PURE__*/e(y,{children:l}),/*#__PURE__*/e(b,{children:a})]}),xe=({connectOnly:a})=>{let{closePrivyModal:l}=L(),{data:o,setModalData:c,onUserCloseViaDialogOrKeybindRef:p,navigate:h}=W(),g=u(),m=o?.login,f=g.appearance.walletList,y=m?.walletChainType??g.appearance.walletChainType,{accountType:v,walletClientType:C,chainType:b}=w(),T=s((()=>v&&"guest"!==v&&"authorization_key"!==v&&"cross_app"!==v?P(v):null),[v]),{email:M,sms:x,google:A,twitter:I,discord:E,github:R,spotify:_,instagram:V,tiktok:U,line:F,twitch:$,linkedin:H,apple:G,wallet:q,farcaster:B,telegram:K}=s((()=>m?.loginMethods?z(m.loginMethods,!0):null),[m])??g.loginMethods,{wallets:X}=j({enabled:k(q?f:[]),walletList:f,walletChainType:y}),Z=g.customOAuthProviders,J=g.crossAppProviders,{passkey:Q}=g.loginMethods,Y=[M&&"email",x&&"sms",A&&"google",I&&"twitter",E&&"discord",R&&"github",_&&"spotify",V&&"instagram",U&&"tiktok",F&&"line",$&&"twitch",H&&"linkedin",G&&"apple",B&&"farcaster",K&&"telegram",...Z.map((e=>e.provider)),...J].filter((e=>!!e)),ee=Y.length>0,te=s((()=>q&&!ee?"web3-first":q&&g?.appearance.loginGroupPriority||"web2-first"),[q,ee,g?.appearance.loginGroupPriority]),ie=g?.appearance.hideDirectWeb2Inputs,[ae,le]=r("default"),[re,ce]=r(Ee({mostRecentlyUsedAccountType:v,smsAvailable:x,emailAvailable:M,prefilledType:m?.prefill?.type}));n((()=>{ce(Ee({mostRecentlyUsedAccountType:v,smsAvailable:x,emailAvailable:M,prefilledType:m?.prefill?.type}))}),[M,x,v]);let de=()=>{l({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{le("default")}),150)};p.current=de;let pe=[];C&&q?pe.push(C):T?.loginMethod&&Y.includes(T.loginMethod)&&pe.push(T.loginMethod);let me=t=>{if("email"===t)/*#__PURE__*/return e(ue,{isEditable:"email"===re,setIsEditable:()=>{ce("email")},defaultValue:"email"===m?.prefill?.type?m.prefill.value:void 0},t);if("sms"===t)/*#__PURE__*/return e(ve,{isEditable:"sms"===re,setIsEditable:()=>{ce("sms")},defaultValue:"phone"===m?.prefill?.type?m.prefill.value:void 0},t);if("apple"===t)/*#__PURE__*/return e(be,{provider:"apple"},t);if("discord"===t)/*#__PURE__*/return e(be,{provider:"discord"},t);if("farcaster"===t)/*#__PURE__*/return e(ge,{},t);if("github"===t)/*#__PURE__*/return e(be,{provider:"github"},t);if("google"===t)/*#__PURE__*/return e(be,{provider:"google"},t);if("linkedin"===t)/*#__PURE__*/return e(be,{provider:"linkedin"},t);if("tiktok"===t)/*#__PURE__*/return e(be,{provider:"tiktok"},t);if("line"===t)/*#__PURE__*/return e(be,{provider:"line"},t);if("twitch"===t)/*#__PURE__*/return e(be,{provider:"twitch"},t);if("spotify"===t)/*#__PURE__*/return e(be,{provider:"spotify"},t);if("instagram"===t)/*#__PURE__*/return e(be,{provider:"instagram"},t);if("twitter"===t)/*#__PURE__*/return e(be,{provider:"twitter"},t);if("telegram"===t)/*#__PURE__*/return e(Se,{},t);if(N(t))/*#__PURE__*/return e(be,{provider:t},t);if(t.startsWith("privy:")){let i=t.split(":")[1];if(!i)throw Error("Invalid cross-app provider format. App ID missing.");/*#__PURE__*/return e(he,{appId:i},t)}let i=X.findIndex((({id:e})=>e===D.normalize(t))),l="solana"===b?"solana-only":"ethereum-only";/*#__PURE__*/return e(O,{recent:!0,index:i,data:{wallets:X,walletChainType:l,handleWalletClick(e){c((t=>({...t,externalConnectWallet:{walletList:f,walletChainType:l,preSelectedWalletId:e.id}}))),h(a?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}})},fe=X.filter((e=>e.id!==D.normalize(C||""))),Ce=fe.map(((t,i)=>/*#__PURE__*/e(O,{index:i,data:{walletChainType:y,wallets:fe,handleWalletClick(e){c((t=>({...t,externalConnectWallet:{walletList:f,walletChainType:y,preSelectedWalletId:e.id}}))),h(a?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}},t.id))),ke=Y.filter((e=>e!==T?.loginMethod)).flatMap(me),Te=pe.flatMap(me);"web3-first"===te&&"default"===ae?Ce.unshift(...Te):"web2-first"===te&&ke.unshift(...Te);let xe="web2-overflow"===ae?()=>le("default"):void 0,Pe=Y.filter((e=>"email"!==e&&"sms"!==e)),je=Ie({priority:te,email:M,sms:x,social:Pe}),De=We({priority:te,email:M,sms:x,social:Pe}),Oe=/*#__PURE__*/e(ne,{text:Ne({priority:te}),onClick:()=>{c({...o,externalConnectWallet:{walletChainType:m?.walletChainType??g.appearance.walletChainType}}),h(a?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}),Re=/*#__PURE__*/e(Me,{text:je,icon:De,onClick:()=>le("web2-overflow")}),_e=ie?0:1,Ve=q&&Ce.length>0,Ue=0===ke.length&&q&&0===Ce.length,Fe=5-(Ve?1:0),$e="default"===ae&&g?.appearance.logo,ze="default"===ae&&g.appearance.loginMessage;/*#__PURE__*/return t(oe,{title:g.appearance.landingHeader,icon:$e?/*#__PURE__*/e(se,{}):void 0,iconVariant:$e?"logo":void 0,onClose:de,showClose:!0,onBack:xe,showBack:!!xe,helpText:g||Q&&"default"===ae?/*#__PURE__*/t(i,{children:[Q&&"default"===ae&&/*#__PURE__*/e(we,{}),g&&/*#__PURE__*/e(d,{app:g})]}):void 0,watermark:!0,children:[ze&&("string"==typeof g.appearance.loginMessage?/*#__PURE__*/e(Ae,{children:g.appearance.loginMessage}):/*#__PURE__*/e(Le,{children:g.appearance.loginMessage})),/*#__PURE__*/e(S,{$colorScheme:g.appearance.palette.colorScheme,children:"default"===ae&&"web2-first"===te?/*#__PURE__*/t(i,{children:[ke.length>Fe?ke.slice(0,Fe-1):ke,ke.length>Fe&&Re,Ve&&Oe,Ue&&/*#__PURE__*/e(ye,{chainType:g.appearance.walletChainType})]}):"default"===ae&&"web3-first"===te?/*#__PURE__*/t(i,{children:[q&&/*#__PURE__*/t(i,{children:[Ce.length>Fe?Ce.slice(0,Fe-1):Ce,Ce.length>Fe&&Oe]}),ke.length>_e&&Re,ke.length===_e&&ke[0],Ue&&/*#__PURE__*/e(ye,{chainType:g.appearance.walletChainType})]}):"web2-overflow"===ae?/*#__PURE__*/e(i,{children:"web3-first"===te?ke:ke.slice(3)}):null})]})};let Ae=/*#__PURE__*/c.div.withConfig({displayName:"StyledSubtitle",componentId:"sc-c85d71fe-0"})(["text-align:center;font-size:14px;margin-bottom:24px;"]),Le=/*#__PURE__*/c.div.withConfig({displayName:"MessageContainer",componentId:"sc-c85d71fe-1"})(["margin-bottom:24px;"]),Ie=({priority:e,email:t,sms:i,social:a})=>"web2-first"===e?"Other socials":t&&i&&a.length>0||t&&a.length>0?"Log in with email or socials":i&&a.length>0?"Log in with sms or socials":t&&i?"Continue with email or sms":t?"Continue with email":i?"Continue with sms":"Log in with a social account",We=({priority:t,email:i,sms:a,social:l})=>"web2-first"===t||l.length>0?/*#__PURE__*/e(V,{}):i&&a?/*#__PURE__*/e(fe,{}):i?/*#__PURE__*/e(R,{}):a?/*#__PURE__*/e(_,{}):null,Ne=({priority:e})=>"web2-first"===e?"Continue with a wallet":"Other wallets";const Ee=({mostRecentlyUsedAccountType:e,smsAvailable:t,emailAvailable:i,prefilledType:a})=>i&&("email"===e&&"phone"!==a||"email"===a)||!t||"phone"!==e&&"phone"!==a?"email":"sms",Pe=({connectOnly:l})=>{let{closePrivyModal:o,connectors:c}=L(),{data:g,setModalData:m,onUserCloseViaDialogOrKeybindRef:f,navigate:y}=W(),v=u(),C=v.appearance.palette.colorScheme,{accountType:b,walletClientType:k}=w(),I=s((()=>b&&"guest"!==b&&"authorization_key"!==b&&"cross_app"!==b?P(b):null),[b]),N=v.loginMethodsAndOrder?.primary??[],E=v.loginMethodsAndOrder?.overflow??[],j=s((()=>[...N,...E]),[N,E]),R=v.loginMethods.passkey,_=g?.login,V=[];k&&j.includes(k)?V.push(k):b&&j.includes(I?.loginMethod)&&V.push(I?.loginMethod);let[U,F]=r("default"),[$,z]=r(Ee({mostRecentlyUsedAccountType:b,smsAvailable:j.includes("sms"),emailAvailable:j.includes("email"),prefilledType:_?.prefill?.type}));n((()=>{z(Ee({mostRecentlyUsedAccountType:b,smsAvailable:j.includes("sms"),emailAvailable:j.includes("email"),prefilledType:_?.prefill?.type}))}),[j,b]),n((()=>{"phone"===b&&z("sms");let e=j.indexOf("sms"),t=j.indexOf("email");e>-1&&e<t&&z("sms")}),[b,N,E]);let H=()=>{o({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{F("default")}),150)};f.current=H;let{listings:G}=T(),q=t=>{if("email"===t)/*#__PURE__*/return e(ue,{isEditable:"email"===$,setIsEditable:()=>{z("email")},defaultValue:"email"===_?.prefill?.type?_.prefill.value:void 0},t);if("sms"===t)/*#__PURE__*/return e(ve,{isEditable:"sms"===$,setIsEditable:()=>{z("sms")},defaultValue:"phone"===_?.prefill?.type?_.prefill.value:void 0},t);if("apple"===t)/*#__PURE__*/return e(be,{provider:"apple"},t);if("discord"===t)/*#__PURE__*/return e(be,{provider:"discord"},t);if("farcaster"===t)/*#__PURE__*/return e(ge,{},t);if("github"===t)/*#__PURE__*/return e(be,{provider:"github"},t);if("google"===t)/*#__PURE__*/return e(be,{provider:"google"},t);if("linkedin"===t)/*#__PURE__*/return e(be,{provider:"linkedin"},t);if("spotify"===t)/*#__PURE__*/return e(be,{provider:"spotify"},t);if("instagram"===t)/*#__PURE__*/return e(be,{provider:"instagram"},t);if("tiktok"===t)/*#__PURE__*/return e(be,{provider:"tiktok"},t);if("line"===t)/*#__PURE__*/return e(be,{provider:"line"},t);if("twitch"===t)/*#__PURE__*/return e(be,{provider:"twitch"},t);if("twitter"===t)/*#__PURE__*/return e(be,{provider:"twitter"},t);if("telegram"===t)/*#__PURE__*/return e(Se,{},t);if(t.startsWith("privy:"))/*#__PURE__*/return e(he,{appId:t.replace("privy:","")},t);let i=v.appearance.walletChainType,a=new D(i,[t]).getWallets(c,G);return a.wallets.map(((t,r)=>/*#__PURE__*/e(O,{index:r,data:{wallets:a.wallets,walletChainType:i,handleWalletClick(e){m((t=>({...t,externalConnectWallet:{walletList:j,walletChainType:i,preSelectedWalletId:e.id}}))),y(l?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}},t.id+r)))},B=V.flatMap(q),K=N.filter((e=>e!==k&&e!==I?.loginMethod)).flatMap(q),X=E.filter((e=>e!==k&&e!==I?.loginMethod)).flatMap(q),[Z,J]=M([...B,...K,...X],je({primary:K.length+B.length,overflow:X.length}));/*#__PURE__*/return t(i,{children:[/*#__PURE__*/e(p,{title:v.appearance.landingHeader,onClose:H,backFn:"default"===U?void 0:()=>{F("default")}}),"default"===U&&/*#__PURE__*/e(De,{}),"default"===U&&("string"==typeof v.appearance.loginMessage?/*#__PURE__*/e(x,{children:v.appearance.loginMessage}):v.appearance.loginMessage),/*#__PURE__*/e(A,{style:{overflow:"hidden"},children:/*#__PURE__*/t(S,{$colorScheme:C,children:["default"===U&&/*#__PURE__*/t(i,{children:[Z,J.length>0&&/*#__PURE__*/e(Me,{text:"More options",icon:/*#__PURE__*/e(a,{}),onClick:()=>F("overflow")})]}),"overflow"===U&&/*#__PURE__*/e(i,{children:J}),R&&"default"===U&&/*#__PURE__*/e(we,{})]})}),v&&/*#__PURE__*/e(d,{app:v}),/*#__PURE__*/e(h,{})]})};let je=({primary:e,overflow:t})=>e<5?e:5===e&&0===t?5:4,De=/*#__PURE__*/c(ce).withConfig({displayName:"StyledAppLogoHeader",componentId:"sc-ead54d53-0"})(["margin-bottom:16px;"]);export{Pe as C,xe as L};