@privy-io/react-auth
Version:
React client for the Privy Auth API
24 lines (23 loc) • 22.5 kB
JavaScript
"use strict";var e=require("react/jsx-runtime"),t=require("@heroicons/react/24/outline/UserCircleIcon"),i=require("react"),a=require("styled-components"),l=require("./ModalHeader-BCPQgekO.js"),r=require("./context-D-ZJYjUg.js"),n=require("./useActiveWallet-Cn6zOXx5.js"),s=require("./internal-context-BJv4f_bO.js"),o=require("./get-is-unified-wallet-UpdjHxOV.js"),d=require("./index-C8lpxYDX.js"),c=require("./ConnectWalletView-BB2DjcE-.js"),u=require("lucide-react"),p=require("./ConnectEmailForm-BibKRhlR.js"),h=require("./Chip-C6r7fZiR.js"),g=require("./farcaster-CWHXGAib.js"),y=require("@privy-io/js-sdk-core"),m=require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),f=require("@heroicons/react/24/outline/FingerPrintIcon"),x=require("./Link-BdtTp2J4.js"),j=require("./ConnectPhoneForm-BPgbe0j3.js"),w=require("./twitter-CJSxxOMI.js"),v=require("./twitch-BNvhZb2Y.js"),C=require("./telegram-D3O0_F1a.js"),b=require("./WalletOverflowButton-BqeWaSEy.js"),S=require("./ScreenLayout-CMb-Fua0.js");function k(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var M=/*#__PURE__*/k(t),T=/*#__PURE__*/k(i),L=/*#__PURE__*/k(m),A=/*#__PURE__*/k(f);const W=()=>{let t=r.useAppConfig(),i=t?.appearance?.logo,a=`${t?.name} logo`,l={maxHeight:"90px",maxWidth:"180px"};return i?"string"==typeof i?/*#__PURE__*/e.jsx("img",{src:i,alt:a,style:l}):"svg"===i.type||"img"===i.type?/*#__PURE__*/T.default.cloneElement(i,{alt:a,style:l}):(console.warn("`config.appearance.logo` must be a string, or an SVG / IMG element. Nothing will be rendered."),null):null},P=a.styled.div`
display: flex;
flex-direction: column;
align-items: center;
padding: 24px 0;
flex-grow: 1;
justify-content: center;
`,I=({name:t,logoUrl:i,size:a="38px"})=>{let l=`${t??"Provider app"} logo`;return"string"==typeof i?/*#__PURE__*/e.jsx("img",{src:i,alt:l,style:{width:a,height:a,maxHeight:"90px",maxWidth:"180px",borderRadius:"8px"}}):
/*#__PURE__*/e.jsx("span",{})},E=({appId:t})=>{let[a,l]=i.useState(void 0),{startCrossAppAuthFlow:r,authenticated:d}=o.usePrivyContext(),{data:c}=o.usePrivyModal(),{client:u}=s.usePrivyInternal();return i.useEffect((()=>{(async()=>{u&&l(await u.getCrossAppProviderDetails(t))})()}),[u]),/*#__PURE__*/e.jsx(n.LoginMethodButton,{onClick:()=>r({appId:t,action:d?"link":"login",disableSignup:c?.login?.disableSignup}),disabled:!a,children:a?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(I,{name:a.name,logoUrl:a.icon_url||void 0,size:"24px"})," ",a.name]}):/*#__PURE__*/e.jsx(n.ButtonLoader,{})})},F=({isEditable:t,setIsEditable:a,defaultValue:l})=>{let r=i.useRef(null);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(n.Hide,{$if:!t,children:/*#__PURE__*/e.jsx(p.ConnectEmailForm,{ref:r,defaultValue:l})}),/*#__PURE__*/e.jsx(n.Hide,{$if:t,children:/*#__PURE__*/e.jsxs(n.LoginMethodButton,{onClick:()=>{a(),setTimeout((()=>{r.current?.focus()}),0)},children:[/*#__PURE__*/e.jsx(n.LoginMethodIconWrapper,{children:/*#__PURE__*/e.jsx(u.Mail,{})}),"Continue with Email"]})})]})},q=()=>{let[t,a]=i.useState(!1),{currentScreen:l,navigate:r,setModalData:c,data:u}=o.usePrivyModal(),{enabled:p,token:h}=d.useCaptcha(),{initLoginWithFarcaster:y}=s.usePrivyInternal(),{accountType:m}=n.useRecentlyUsedLogin();/*#__PURE__*/return e.jsxs(n.LoginMethodButton,{onClick:async()=>{a(!0);try{p&&!h?(c({captchaModalData:{callback:e=>y(e,u?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:"FarcasterConnectStatusScreen",onErrorNavigateTo:"ErrorScreen"}}),r("CaptchaScreen")):(await y(h,u?.login?.disableSignup),r("FarcasterConnectStatusScreen"))}catch(e){c({errorModalData:{error:e,previousScreen:l||"LandingScreen"}}),r("ErrorScreen")}finally{a(!1)}},disabled:!1,children:[/*#__PURE__*/e.jsx(g.Farcaster,{width:32,height:32})," Farcaster",t&&/*#__PURE__*/e.jsx(n.ButtonLoader,{}),"farcaster"===m&&/*#__PURE__*/e.jsx(N,{color:"gray",children:"Recent"})]})};let N=a.styled(h.Chip)`
margin-left: auto;
`;const D=({...t})=>/*#__PURE__*/e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",...t,children:[/*#__PURE__*/e.jsxs("g",{clipPath:"url(#clip0_2856_1743)",children:[/*#__PURE__*/e.jsx("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.jsx("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.jsx("defs",{children:/*#__PURE__*/e.jsx("clipPath",{id:"clip0_2856_1743",children:/*#__PURE__*/e.jsx("rect",{x:"0.5",y:"0.5",width:"24",height:"24",rx:"6",fill:"white"})})})]}),R=({chainType:t,withPadding:i})=>{let a="";return a="ethereum-only"===t||"ethereum-and-solana"===t?"Rainbow, Phantom, or Coinbase Wallet":"Phantom or Solflare",/*#__PURE__*/e.jsx(n.EmptyWalletState,{$withPadding:i,children:/*#__PURE__*/e.jsxs(n.Header,{children:[/*#__PURE__*/e.jsx(L.default,{style:{color:"var(--privy-color-warn)",height:48,width:48}}),/*#__PURE__*/e.jsx("h3",{children:"No wallets available"}),/*#__PURE__*/e.jsxs("p",{children:["Please download an external wallet provider, like ",a,"."]})]})},"empty-wallet-state")},O=()=>{let{enabled:t,token:a}=d.useCaptcha(),{navigate:l,setModalData:c,data:u}=o.usePrivyModal(),p=r.useAppConfig(),{initLoginWithPasskey:h}=s.usePrivyInternal(),g=()=>{p.loginConfig.passkeysForSignupEnabled?l("PasskeySelectSignupOrLogin"):(async()=>{t&&!a?(c({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>h({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:"PasskeyStatusScreen",onErrorNavigateTo:"ErrorScreen"}}),l("CaptchaScreen")):(await h({withPrivyUi:!0,captchaToken:a}),c({passkeyAuthModalData:{passkeySignupFlow:!1}}),l("PasskeyStatusScreen"))})()};return 0===i.useMemo((()=>{let e=u?.login?.loginMethods;return e?e.filter((e=>"passkey"!==e)).length:Object.entries(p.loginMethods).filter((([e,t])=>t)).filter((([e])=>"passkey"!==e)).length}),[p.loginMethods,u?.login])?/*#__PURE__*/e.jsxs(n.LoginMethodButton,{onClick:g,children:[/*#__PURE__*/e.jsx(A.default,{})," Continue with passkey"]}):/*#__PURE__*/e.jsx(x.Link,{as:"button",onClick:g,size:"sm",variant:"navigation",style:{width:"100%",justifyContent:"center"},children:"I have a passkey"})},U=({isEditable:t,setIsEditable:a,defaultValue:l})=>{let c=i.useRef(null),{authenticated:p}=o.usePrivyContext(),{navigate:h,setModalData:g,currentScreen:y,data:m}=o.usePrivyModal(),{initLoginWithSms:f}=s.usePrivyInternal(),{enabled:x,token:w}=d.useCaptcha(),{whatsAppEnabled:v}=r.useAppConfig();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(n.Hide,{$if:!t,children:/*#__PURE__*/e.jsx(j.ConnectPhoneNumberForm,{ref:c,onSubmit:async function({qualifiedPhoneNumber:e}){if(!x||w||p)try{await f({phoneNumber:e,captchaToken:w,withPrivyUi:!0,disableSignup:m?.login?.disableSignup}),h("AwaitingPasswordlessCodeScreen")}catch(e){g({errorModalData:{error:e,previousScreen:y||"LandingScreen"}}),h("ErrorScreen")}else g({captchaModalData:{callback:t=>f({phoneNumber:e,captchaToken:t,withPrivyUi:!0,disableSignup:m?.login?.disableSignup}),userIntentRequired:!1,onSuccessNavigateTo:"AwaitingPasswordlessCodeScreen",onErrorNavigateTo:"ErrorScreen"}}),h("CaptchaScreen")},defaultValue:l})}),/*#__PURE__*/e.jsx(n.Hide,{$if:t,children:/*#__PURE__*/e.jsxs(n.LoginMethodButton,{onClick:()=>{a(),setTimeout((()=>{c.current?.focus()}),0)},children:[/*#__PURE__*/e.jsx(n.LoginMethodIconWrapper,{children:/*#__PURE__*/e.jsx(u.Smartphone,{})}),"Continue with ",v?"WhatsApp":"SMS"]})})]})};let B={apple:{logo:w.Apple,displayName:"Apple"},discord:{logo:w.Discord,displayName:"Discord"},github:{logo:w.Github,displayName:"GitHub"},google:{logo:w.Google,displayName:"Google"},linkedin:{logo:w.LinkedIn,displayName:"LinkedIn"},spotify:{logo:w.Spotify,displayName:"Spotify"},instagram:{logo:w.Instagram,displayName:"Instagram"},twitter:{logo:w.Twitter,displayName:"Twitter"},tiktok:{logo:w.Tiktok,displayName:"TikTok"},line:{logo:v.Line,displayName:"LINE"},twitch:{logo:v.Twitch,displayName:"Twitch"}};const V=({provider:t})=>{let{enabled:a,token:l}=d.useCaptcha(),{navigate:c,setModalData:u,data:p}=o.usePrivyModal(),[h,g]=i.useState(!1),y=r.useAppConfig(),{initLoginWithOAuth:m}=s.usePrivyInternal(),{accountType:f}=n.useRecentlyUsedLogin(),x=i.useMemo((()=>f&&"guest"!==f&&"authorization_key"!==f&&"cross_app"!==f?d.toDisplayFromAccountType(f):null),[f]),{displayName:j,logo:w}=i.useMemo((()=>{if(o.isCustomOAuthProvider(t)){let i=y.customOAuthProviders.find((e=>e.provider===t)),a=i.provider_icon_url,l=i.provider_display_name;return{displayName:l,logo:({style:t})=>/*#__PURE__*/e.jsx("img",{alt:`${l} logo`,src:a,style:t})}}return B[t]}),[t,y.customOAuthProviders]);/*#__PURE__*/return e.jsxs(n.LoginMethodButton,{onClick:()=>{g(!0),setTimeout((()=>{g(!1)}),2e3),a&&!l?(u({captchaModalData:{callback:e=>m(t,e,p?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:"ErrorScreen"}}),c("CaptchaScreen")):m(t,void 0,p?.login?.disableSignup)},disabled:h,children:[/*#__PURE__*/e.jsx(n.LoginMethodIconWrapper,{$fullSize:!0,children:/*#__PURE__*/e.jsx(w,{style:{width:"32px",height:"32px"}})}),j,x?.loginMethod===t&&/*#__PURE__*/e.jsx(_,{color:"gray",children:"Recent"})]})};let _=a.styled(h.Chip)`
margin-left: auto;
`;const H=()=>{let{enabled:t,token:a}=d.useCaptcha(),{navigate:l,setModalData:r,data:c}=o.usePrivyModal(),[u,p]=i.useState(!1),{initLoginWithTelegram:h}=s.usePrivyInternal(),{accountType:g}=n.useRecentlyUsedLogin();async function y(e){try{await h(e,c?.login?.disableSignup),r({telegramAuthModalData:{seamlessAuth:!1}}),l("TelegramAuthScreen")}catch(e){console.error(e),p(!1)}}/*#__PURE__*/return e.jsxs(n.LoginMethodButton,{onClick:async function(){if(p(!0),t&&!a)return r({captchaModalData:{callback:y,userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:"ErrorScreen"}}),void l("CaptchaScreen");await y(a)},disabled:u,children:[/*#__PURE__*/e.jsx(C.Telegram,{width:32,height:32}),"Telegram","telegram"===g&&/*#__PURE__*/e.jsx($,{color:"gray",children:"Recent"})]})};let $=a.styled(h.Chip)`
margin-left: auto;
`;const z=({onClick:t,text:i,icon:a})=>/*#__PURE__*/e.jsxs(n.LoginMethodButton,{onClick:t,children:[/*#__PURE__*/e.jsx(n.LoginMethodIconWrapper,{children:a}),/*#__PURE__*/e.jsx(n.Grow,{children:i})]});let G=a.styled.div`
text-align: center;
font-size: 14px;
margin-bottom: 24px;
`,K=a.styled.div`
margin-bottom: 24px;
`,Q=({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",Y=({priority:t,email:i,sms:a,social:l})=>"web2-first"===t||l.length>0?/*#__PURE__*/e.jsx(u.UserCircle,{}):i&&a?/*#__PURE__*/e.jsx(D,{}):i?/*#__PURE__*/e.jsx(u.Mail,{}):a?/*#__PURE__*/e.jsx(u.Smartphone,{}):null,Z=({priority:e})=>"web2-first"===e?"Continue with a wallet":"Other wallets";const J=({mostRecentlyUsedAccountType:e,smsAvailable:t,emailAvailable:i,prefilledType:a})=>i&&("email"===e&&"phone"!==a||"email"===a)||!t||"phone"!==e&&"phone"!==a?"email":"sms";let X=({primary:e,overflow:t})=>e<5?e:5===e&&0===t?5:4,ee=a.styled((t=>{let i=r.useAppConfig();return i?.appearance.logo?/*#__PURE__*/e.jsx(P,{...t,children:/*#__PURE__*/e.jsx(W,{})}):null}))`
margin-bottom: 16px;
`;exports.CustomLandingScreenView=({connectOnly:t})=>{let{closePrivyModal:a,connectors:u}=s.usePrivyInternal(),{data:p,setModalData:h,onUserCloseViaDialogOrKeybindRef:g,navigate:y}=o.usePrivyModal(),m=r.useAppConfig(),f=m.appearance.palette.colorScheme,{accountType:x,walletClientType:j}=n.useRecentlyUsedLogin(),w=i.useMemo((()=>x&&"guest"!==x&&"authorization_key"!==x&&"cross_app"!==x?d.toDisplayFromAccountType(x):null),[x]),v=m.loginMethodsAndOrder?.primary??[],C=m.loginMethodsAndOrder?.overflow??[],b=i.useMemo((()=>[...v,...C]),[v,C]),S=m.loginMethods.passkey,k=p?.login,T=[];j&&b.includes(j)?T.push(j):x&&b.includes(w?.loginMethod)&&T.push(w?.loginMethod);let[L,A]=i.useState("default"),[W,P]=i.useState(J({mostRecentlyUsedAccountType:x,smsAvailable:b.includes("sms"),emailAvailable:b.includes("email"),prefilledType:k?.prefill?.type}));i.useEffect((()=>{P(J({mostRecentlyUsedAccountType:x,smsAvailable:b.includes("sms"),emailAvailable:b.includes("email"),prefilledType:k?.prefill?.type}))}),[b,x]),i.useEffect((()=>{"phone"===x&&P("sms");let e=b.indexOf("sms"),t=b.indexOf("email");e>-1&&e<t&&P("sms")}),[x,v,C]);let I=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{A("default")}),150)};g.current=I;let{listings:N}=n.useExternalWalletListings(),D=i=>{if("email"===i)/*#__PURE__*/return e.jsx(F,{isEditable:"email"===W,setIsEditable:()=>{P("email")},defaultValue:"email"===k?.prefill?.type?k.prefill.value:void 0},i);if("sms"===i)/*#__PURE__*/return e.jsx(U,{isEditable:"sms"===W,setIsEditable:()=>{P("sms")},defaultValue:"phone"===k?.prefill?.type?k.prefill.value:void 0},i);if("apple"===i)/*#__PURE__*/return e.jsx(V,{provider:"apple"},i);if("discord"===i)/*#__PURE__*/return e.jsx(V,{provider:"discord"},i);if("farcaster"===i)/*#__PURE__*/return e.jsx(q,{},i);if("github"===i)/*#__PURE__*/return e.jsx(V,{provider:"github"},i);if("google"===i)/*#__PURE__*/return e.jsx(V,{provider:"google"},i);if("linkedin"===i)/*#__PURE__*/return e.jsx(V,{provider:"linkedin"},i);if("spotify"===i)/*#__PURE__*/return e.jsx(V,{provider:"spotify"},i);if("instagram"===i)/*#__PURE__*/return e.jsx(V,{provider:"instagram"},i);if("tiktok"===i)/*#__PURE__*/return e.jsx(V,{provider:"tiktok"},i);if("line"===i)/*#__PURE__*/return e.jsx(V,{provider:"line"},i);if("twitch"===i)/*#__PURE__*/return e.jsx(V,{provider:"twitch"},i);if("twitter"===i)/*#__PURE__*/return e.jsx(V,{provider:"twitter"},i);if("telegram"===i)/*#__PURE__*/return e.jsx(H,{},i);if(i.startsWith("privy:"))/*#__PURE__*/return e.jsx(E,{appId:i.replace("privy:","")},i);let a=m.appearance.walletChainType,l=new c.WalletFilterer(a,[i]).getWallets(u,N);return l.wallets.map(((i,r)=>/*#__PURE__*/e.jsx(c.WalletRow,{index:r,data:{wallets:l.wallets,walletChainType:a,handleWalletClick(e){h((t=>({...t,externalConnectWallet:{walletList:b,walletChainType:a,preSelectedWalletId:e.id}}))),y(t?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}},i.id+r)))},R=T.flatMap(D),B=v.filter((e=>e!==j&&e!==w?.loginMethod)).flatMap(D),_=C.filter((e=>e!==j&&e!==w?.loginMethod)).flatMap(D),[$,G]=n.splitAtIndex([...R,...B,..._],X({primary:B.length+R.length,overflow:_.length}));/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(l.ModalHeader,{title:m.appearance.landingHeader,onClose:I,backFn:"default"===L?void 0:()=>{A("default")}}),"default"===L&&/*#__PURE__*/e.jsx(ee,{}),"default"===L&&("string"==typeof m.appearance.loginMessage?/*#__PURE__*/e.jsx(n.Subtitle,{children:m.appearance.loginMessage}):m.appearance.loginMessage),/*#__PURE__*/e.jsx(n.AlignBottom,{style:{overflow:"hidden"},children:/*#__PURE__*/e.jsxs(n.LoginMethodContainerWithScrollShadows,{$colorScheme:f,children:["default"===L&&/*#__PURE__*/e.jsxs(e.Fragment,{children:[$,G.length>0&&/*#__PURE__*/e.jsx(z,{text:"More options",icon:/*#__PURE__*/e.jsx(M.default,{}),onClick:()=>A("overflow")})]}),"overflow"===L&&/*#__PURE__*/e.jsx(e.Fragment,{children:G}),S&&"default"===L&&/*#__PURE__*/e.jsx(O,{})]})}),m&&/*#__PURE__*/e.jsx(l.TermsAndConditions,{app:m}),/*#__PURE__*/e.jsx(l.BlobbyFooter,{})]})},exports.LandingScreenView=({connectOnly:t})=>{let{closePrivyModal:a}=s.usePrivyInternal(),{data:u,setModalData:p,onUserCloseViaDialogOrKeybindRef:h,navigate:g}=o.usePrivyModal(),m=r.useAppConfig(),f=u?.login,x=m.appearance.walletList,j=f?.walletChainType??m.appearance.walletChainType,{accountType:w,walletClientType:v,chainType:C}=n.useRecentlyUsedLogin(),k=i.useMemo((()=>w&&"guest"!==w&&"authorization_key"!==w&&"cross_app"!==w?d.toDisplayFromAccountType(w):null),[w]),{email:M,sms:T,google:L,twitter:A,discord:P,github:I,spotify:N,instagram:D,tiktok:B,line:_,twitch:$,linkedin:X,apple:ee,wallet:te,farcaster:ie,telegram:ae}=i.useMemo((()=>f?.loginMethods?y.toObjectKeys(f.loginMethods,!0):null),[f])??m.loginMethods,{wallets:le}=c.useWalletsListController({enabled:n.shouldFetchWcRegistryListings(te?x:[]),walletList:x,walletChainType:j}),re=m.customOAuthProviders,ne=m.crossAppProviders,{passkey:se}=m.loginMethods,oe=[M&&"email",T&&"sms",L&&"google",A&&"twitter",P&&"discord",I&&"github",N&&"spotify",D&&"instagram",B&&"tiktok",_&&"line",$&&"twitch",X&&"linkedin",ee&&"apple",ie&&"farcaster",ae&&"telegram",...re.map((e=>e.provider)),...ne].filter((e=>!!e)),de=oe.length>0,ce=i.useMemo((()=>te&&!de?"web3-first":te&&m?.appearance.loginGroupPriority||"web2-first"),[te,de,m?.appearance.loginGroupPriority]),ue=m?.appearance.hideDirectWeb2Inputs,[pe,he]=i.useState("default"),[ge,ye]=i.useState(J({mostRecentlyUsedAccountType:w,smsAvailable:T,emailAvailable:M,prefilledType:f?.prefill?.type}));i.useEffect((()=>{ye(J({mostRecentlyUsedAccountType:w,smsAvailable:T,emailAvailable:M,prefilledType:f?.prefill?.type}))}),[M,T,w]);let me=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{he("default")}),150)};h.current=me;let fe=[];v&&te?fe.push(v):k?.loginMethod&&oe.includes(k.loginMethod)&&fe.push(k.loginMethod);let xe=i=>{if("email"===i)/*#__PURE__*/return e.jsx(F,{isEditable:"email"===ge,setIsEditable:()=>{ye("email")},defaultValue:"email"===f?.prefill?.type?f.prefill.value:void 0},i);if("sms"===i)/*#__PURE__*/return e.jsx(U,{isEditable:"sms"===ge,setIsEditable:()=>{ye("sms")},defaultValue:"phone"===f?.prefill?.type?f.prefill.value:void 0},i);if("apple"===i)/*#__PURE__*/return e.jsx(V,{provider:"apple"},i);if("discord"===i)/*#__PURE__*/return e.jsx(V,{provider:"discord"},i);if("farcaster"===i)/*#__PURE__*/return e.jsx(q,{},i);if("github"===i)/*#__PURE__*/return e.jsx(V,{provider:"github"},i);if("google"===i)/*#__PURE__*/return e.jsx(V,{provider:"google"},i);if("linkedin"===i)/*#__PURE__*/return e.jsx(V,{provider:"linkedin"},i);if("tiktok"===i)/*#__PURE__*/return e.jsx(V,{provider:"tiktok"},i);if("line"===i)/*#__PURE__*/return e.jsx(V,{provider:"line"},i);if("twitch"===i)/*#__PURE__*/return e.jsx(V,{provider:"twitch"},i);if("spotify"===i)/*#__PURE__*/return e.jsx(V,{provider:"spotify"},i);if("instagram"===i)/*#__PURE__*/return e.jsx(V,{provider:"instagram"},i);if("twitter"===i)/*#__PURE__*/return e.jsx(V,{provider:"twitter"},i);if("telegram"===i)/*#__PURE__*/return e.jsx(H,{},i);if(o.isCustomOAuthProvider(i))/*#__PURE__*/return e.jsx(V,{provider:i},i);if(i.startsWith("privy:")){let t=i.split(":")[1];if(!t)throw Error("Invalid cross-app provider format. App ID missing.");/*#__PURE__*/return e.jsx(E,{appId:t},i)}let a=le.findIndex((({id:e})=>e===c.WalletFilterer.normalize(i))),l="solana"===C?"solana-only":"ethereum-only";/*#__PURE__*/return e.jsx(c.WalletRow,{recent:!0,index:a,data:{wallets:le,walletChainType:l,handleWalletClick(e){p((t=>({...t,externalConnectWallet:{walletList:x,walletChainType:l,preSelectedWalletId:e.id}}))),g(t?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}})},je=le.filter((e=>e.id!==c.WalletFilterer.normalize(v||""))),we=je.map(((i,a)=>/*#__PURE__*/e.jsx(c.WalletRow,{index:a,data:{walletChainType:j,wallets:je,handleWalletClick(e){p((t=>({...t,externalConnectWallet:{walletList:x,walletChainType:j,preSelectedWalletId:e.id}}))),g(t?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}},i.id))),ve=oe.filter((e=>e!==k?.loginMethod)).flatMap(xe),Ce=fe.flatMap(xe);"web3-first"===ce&&"default"===pe?we.unshift(...Ce):"web2-first"===ce&&ve.unshift(...Ce);let be="web2-overflow"===pe?()=>he("default"):void 0,Se=oe.filter((e=>"email"!==e&&"sms"!==e)),ke=Q({priority:ce,email:M,sms:T,social:Se}),Me=Y({priority:ce,email:M,sms:T,social:Se}),Te=/*#__PURE__*/e.jsx(b.WalletOverflowButton,{text:Z({priority:ce}),onClick:()=>{p({...u,externalConnectWallet:{walletChainType:f?.walletChainType??m.appearance.walletChainType}}),g(t?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}),Le=/*#__PURE__*/e.jsx(z,{text:ke,icon:Me,onClick:()=>he("web2-overflow")}),Ae=ue?0:1,We=te&&we.length>0,Pe=0===ve.length&&te&&0===we.length,Ie=5-(We?1:0),Ee="default"===pe&&m?.appearance.logo,Fe="default"===pe&&m.appearance.loginMessage;/*#__PURE__*/return e.jsxs(S.ScreenLayout,{title:m.appearance.landingHeader,icon:Ee?/*#__PURE__*/e.jsx(W,{}):void 0,iconVariant:Ee?"logo":void 0,onClose:me,showClose:!0,onBack:be,showBack:!!be,helpText:m||se&&"default"===pe?/*#__PURE__*/e.jsxs(e.Fragment,{children:[se&&"default"===pe&&!m.globalDisablePasskeys&&/*#__PURE__*/e.jsx(O,{}),m&&/*#__PURE__*/e.jsx(l.TermsAndConditions,{app:m})]}):void 0,watermark:!0,children:[Fe&&("string"==typeof m.appearance.loginMessage?/*#__PURE__*/e.jsx(G,{children:m.appearance.loginMessage}):/*#__PURE__*/e.jsx(K,{children:m.appearance.loginMessage})),/*#__PURE__*/e.jsx(n.LoginMethodContainerWithScrollShadows,{$colorScheme:m.appearance.palette.colorScheme,children:"default"===pe&&"web2-first"===ce?/*#__PURE__*/e.jsxs(e.Fragment,{children:[ve.length>Ie?ve.slice(0,Ie-1):ve,ve.length>Ie&&Le,We&&Te,Pe&&/*#__PURE__*/e.jsx(R,{chainType:m.appearance.walletChainType})]}):"default"===pe&&"web3-first"===ce?/*#__PURE__*/e.jsxs(e.Fragment,{children:[te&&/*#__PURE__*/e.jsxs(e.Fragment,{children:[we.length>Ie?we.slice(0,Ie-1):we,we.length>Ie&&Te]}),ve.length>Ae&&Le,ve.length===Ae&&ve[0],Pe&&/*#__PURE__*/e.jsx(R,{chainType:m.appearance.walletChainType})]}):"web2-overflow"===pe?/*#__PURE__*/e.jsx(e.Fragment,{children:"web3-first"===ce?ve:ve.slice(3)}):null})]})};