@privy-io/react-auth
Version:
React client for the Privy Auth API
3 lines (2 loc) • 22.9 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-DB7Tbjwz.js"),n=require("./context-DFq1obBO.js"),r=require("./useActiveWallet-BOX8xCn9.js"),o=require("./internal-context-NWsAL807.js"),s=require("./get-is-unified-wallet-D4ouXJpi.js"),d=require("./index-NJrQkxJ7.js"),c=require("./ConnectWalletView-DsOX-lHz.js"),p=require("lucide-react"),u=require("./ConnectEmailForm-D0Xd9Tnw.js"),h=require("./Chip-ChrHHazc.js"),g=require("./farcaster-CWHXGAib.js"),m=require("@privy-io/js-sdk-core"),y=require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),f=require("@heroicons/react/24/outline/FingerPrintIcon"),x=require("./Link-DmzPZ_M7.js"),w=require("./ConnectPhoneForm-WT8rso3i.js"),j=require("./twitter-BVVRWkcG.js"),v=require("./twitch-BNvhZb2Y.js"),C=require("./telegram-D3O0_F1a.js"),S=require("./WalletOverflowButton-iCeXR9aA.js"),b=require("./ScreenLayout-BeH-Q6N2.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(y),A=/*#__PURE__*/k(f);const W=()=>{let t=n.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},I=t=>{let i=n.useAppConfig();return i?.appearance.logo?/*#__PURE__*/e.jsx(P,{...t,children:/*#__PURE__*/e.jsx(W,{})}):null},P=/*#__PURE__*/a.styled.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;"]),E=({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",{})},N=({appId:t})=>{let[a,l]=i.useState(void 0),{startCrossAppAuthFlow:n,authenticated:d}=s.usePrivyContext(),{client:c}=o.usePrivyInternal();return i.useEffect((()=>{(async()=>{c&&l(await c.getCrossAppProviderDetails(t))})()}),[c]),/*#__PURE__*/e.jsx(r.LoginMethodButton,{onClick:()=>n({appId:t,action:d?"link":"login"}),disabled:!a,children:a?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(E,{name:a.name,logoUrl:a.icon_url||void 0,size:"24px"})," ",a.name]}):/*#__PURE__*/e.jsx(r.ButtonLoader,{})})},F=({isEditable:t,setIsEditable:a,defaultValue:l})=>{let n=i.useRef(null);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(r.Hide,{$if:!t,children:/*#__PURE__*/e.jsx(u.ConnectEmailForm,{ref:n,defaultValue:l})}),/*#__PURE__*/e.jsx(r.Hide,{$if:t,children:/*#__PURE__*/e.jsxs(r.LoginMethodButton,{onClick:()=>{a(),setTimeout((()=>{n.current?.focus()}),0)},children:[/*#__PURE__*/e.jsx(r.LoginMethodIconWrapper,{children:/*#__PURE__*/e.jsx(p.Mail,{})}),"Continue with Email"]})})]})},q=()=>{let[t,a]=i.useState(!1),{currentScreen:l,navigate:n,setModalData:c,data:p}=s.usePrivyModal(),{enabled:u,token:h}=d.useCaptcha(),{initLoginWithFarcaster:m}=o.usePrivyInternal(),{accountType:y}=r.useRecentlyUsedLogin();/*#__PURE__*/return e.jsxs(r.LoginMethodButton,{onClick:async()=>{a(!0);try{u&&!h?(c({captchaModalData:{callback:e=>m(e,p?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:"FarcasterConnectStatusScreen",onErrorNavigateTo:"ErrorScreen"}}),n("CaptchaScreen")):(await m(h,p?.login?.disableSignup),n("FarcasterConnectStatusScreen"))}catch(e){c({errorModalData:{error:e,previousScreen:l||"LandingScreen"}}),n("ErrorScreen")}finally{a(!1)}},disabled:!1,children:[/*#__PURE__*/e.jsx(g.Farcaster,{width:32,height:32})," Farcaster",t&&/*#__PURE__*/e.jsx(r.ButtonLoader,{}),"farcaster"===y&&/*#__PURE__*/e.jsx(R,{color:"gray",children:"Recent"})]})};let R=/*#__PURE__*/a.styled(h.Chip).withConfig({displayName:"StyledChip",componentId:"sc-2f1c7323-0"})(["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"})})})]}),O=({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(r.EmptyWalletState,{$withPadding:i,children:/*#__PURE__*/e.jsxs(r.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")},U=()=>{let{enabled:t,token:a}=d.useCaptcha(),{navigate:l,setModalData:c,data:p}=s.usePrivyModal(),u=n.useAppConfig(),{initLoginWithPasskey:h}=o.usePrivyInternal(),g=()=>{u.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=p?.login?.loginMethods;return e?e.filter((e=>"passkey"!==e)).length:Object.entries(u.loginMethods).filter((([e,t])=>t)).filter((([e])=>"passkey"!==e)).length}),[u.loginMethods,p?.login])?/*#__PURE__*/e.jsxs(r.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"})},B=({isEditable:t,setIsEditable:a,defaultValue:l})=>{let c=i.useRef(null),{authenticated:u}=s.usePrivyContext(),{navigate:h,setModalData:g,currentScreen:m,data:y}=s.usePrivyModal(),{initLoginWithSms:f}=o.usePrivyInternal(),{enabled:x,token:j}=d.useCaptcha(),{whatsAppEnabled:v}=n.useAppConfig();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(r.Hide,{$if:!t,children:/*#__PURE__*/e.jsx(w.ConnectPhoneNumberForm,{ref:c,onSubmit:async function({qualifiedPhoneNumber:e}){if(!x||j||u)try{await f({phoneNumber:e,captchaToken:j,withPrivyUi:!0,disableSignup:y?.login?.disableSignup}),h("AwaitingPasswordlessCodeScreen")}catch(e){g({errorModalData:{error:e,previousScreen:m||"LandingScreen"}}),h("ErrorScreen")}else g({captchaModalData:{callback:t=>f({phoneNumber:e,captchaToken:t,withPrivyUi:!0,disableSignup:y?.login?.disableSignup}),userIntentRequired:!1,onSuccessNavigateTo:"AwaitingPasswordlessCodeScreen",onErrorNavigateTo:"ErrorScreen"}}),h("CaptchaScreen")},defaultValue:l})}),/*#__PURE__*/e.jsx(r.Hide,{$if:t,children:/*#__PURE__*/e.jsxs(r.LoginMethodButton,{onClick:()=>{a(),setTimeout((()=>{c.current?.focus()}),0)},children:[/*#__PURE__*/e.jsx(r.LoginMethodIconWrapper,{children:/*#__PURE__*/e.jsx(p.Smartphone,{})}),"Continue with ",v?"WhatsApp":"SMS"]})})]})};let V={apple:{logo:j.Apple,displayName:"Apple"},discord:{logo:j.Discord,displayName:"Discord"},github:{logo:j.Github,displayName:"GitHub"},google:{logo:j.Google,displayName:"Google"},linkedin:{logo:j.LinkedIn,displayName:"LinkedIn"},spotify:{logo:j.Spotify,displayName:"Spotify"},instagram:{logo:j.Instagram,displayName:"Instagram"},twitter:{logo:j.Twitter,displayName:"Twitter"},tiktok:{logo:j.Tiktok,displayName:"TikTok"},line:{logo:v.Line,displayName:"LINE"},twitch:{logo:v.Twitch,displayName:"Twitch"}};const _=({provider:t})=>{let{enabled:a,token:l}=d.useCaptcha(),{navigate:c,setModalData:p,data:u}=s.usePrivyModal(),[h,g]=i.useState(!1),m=n.useAppConfig(),{initLoginWithOAuth:y}=o.usePrivyInternal(),{accountType:f}=r.useRecentlyUsedLogin(),x=i.useMemo((()=>f&&"guest"!==f&&"authorization_key"!==f&&"cross_app"!==f?d.toDisplayFromAccountType(f):null),[f]),{displayName:w,logo:j}=i.useMemo((()=>{if(s.isCustomOAuthProvider(t)){let i=m.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 V[t]}),[t,m.customOAuthProviders]);/*#__PURE__*/return e.jsxs(r.LoginMethodButton,{onClick:()=>{g(!0),setTimeout((()=>{g(!1)}),2e3),a&&!l?(p({captchaModalData:{callback:e=>y(t,e,u?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:"ErrorScreen"}}),c("CaptchaScreen")):y(t,void 0,u?.login?.disableSignup)},disabled:h,children:[/*#__PURE__*/e.jsx(r.LoginMethodIconWrapper,{$fullSize:!0,children:/*#__PURE__*/e.jsx(j,{style:{width:"32px",height:"32px"}})}),w,x?.loginMethod===t&&/*#__PURE__*/e.jsx(H,{color:"gray",children:"Recent"})]})};let H=/*#__PURE__*/a.styled(h.Chip).withConfig({displayName:"StyledChip",componentId:"sc-e74c7091-0"})(["margin-left:auto;"]);const $=()=>{let{enabled:t,token:a}=d.useCaptcha(),{navigate:l,setModalData:n,data:c}=s.usePrivyModal(),[p,u]=i.useState(!1),{initLoginWithTelegram:h}=o.usePrivyInternal(),{accountType:g}=r.useRecentlyUsedLogin();async function m(e){try{await h(e,c?.login?.disableSignup),n({telegramAuthModalData:{seamlessAuth:!1}}),l("TelegramAuthScreen")}catch(e){console.error(e),u(!1)}}/*#__PURE__*/return e.jsxs(r.LoginMethodButton,{onClick:async function(){if(u(!0),t&&!a)return n({captchaModalData:{callback:m,userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:"ErrorScreen"}}),void l("CaptchaScreen");await m(a)},disabled:p,children:[/*#__PURE__*/e.jsx(C.Telegram,{width:32,height:32}),"Telegram","telegram"===g&&/*#__PURE__*/e.jsx(z,{color:"gray",children:"Recent"})]})};let z=/*#__PURE__*/a.styled(h.Chip).withConfig({displayName:"StyledChip",componentId:"sc-639dd483-0"})(["margin-left:auto;"]);const G=({onClick:t,text:i,icon:a})=>/*#__PURE__*/e.jsxs(r.LoginMethodButton,{onClick:t,children:[/*#__PURE__*/e.jsx(r.LoginMethodIconWrapper,{children:a}),/*#__PURE__*/e.jsx(r.Grow,{children:i})]});let K=/*#__PURE__*/a.styled.div.withConfig({displayName:"StyledSubtitle",componentId:"sc-c85d71fe-0"})(["text-align:center;font-size:14px;margin-bottom:24px;"]),J=/*#__PURE__*/a.styled.div.withConfig({displayName:"MessageContainer",componentId:"sc-c85d71fe-1"})(["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",X=({priority:t,email:i,sms:a,social:l})=>"web2-first"===t||l.length>0?/*#__PURE__*/e.jsx(p.UserCircle,{}):i&&a?/*#__PURE__*/e.jsx(D,{}):i?/*#__PURE__*/e.jsx(p.Mail,{}):a?/*#__PURE__*/e.jsx(p.Smartphone,{}):null,Z=({priority:e})=>"web2-first"===e?"Continue with a wallet":"Other wallets";const Y=({mostRecentlyUsedAccountType:e,smsAvailable:t,emailAvailable:i,prefilledType:a})=>i&&("email"===e&&"phone"!==a||"email"===a)||!t||"phone"!==e&&"phone"!==a?"email":"sms";let ee=({primary:e,overflow:t})=>e<5?e:5===e&&0===t?5:4,te=/*#__PURE__*/a.styled(I).withConfig({displayName:"StyledAppLogoHeader",componentId:"sc-ead54d53-0"})(["margin-bottom:16px;"]);exports.CustomLandingScreenView=({connectOnly:t})=>{let{closePrivyModal:a,connectors:p}=o.usePrivyInternal(),{data:u,setModalData:h,onUserCloseViaDialogOrKeybindRef:g,navigate:m}=s.usePrivyModal(),y=n.useAppConfig(),f=y.appearance.palette.colorScheme,{accountType:x,walletClientType:w}=r.useRecentlyUsedLogin(),j=i.useMemo((()=>x&&"guest"!==x&&"authorization_key"!==x&&"cross_app"!==x?d.toDisplayFromAccountType(x):null),[x]),v=y.loginMethodsAndOrder?.primary??[],C=y.loginMethodsAndOrder?.overflow??[],S=i.useMemo((()=>[...v,...C]),[v,C]),b=y.loginMethods.passkey,k=u?.login,T=[];w&&S.includes(w)?T.push(w):x&&S.includes(j?.loginMethod)&&T.push(j?.loginMethod);let[L,A]=i.useState("default"),[W,I]=i.useState(Y({mostRecentlyUsedAccountType:x,smsAvailable:S.includes("sms"),emailAvailable:S.includes("email"),prefilledType:k?.prefill?.type}));i.useEffect((()=>{I(Y({mostRecentlyUsedAccountType:x,smsAvailable:S.includes("sms"),emailAvailable:S.includes("email"),prefilledType:k?.prefill?.type}))}),[S,x]),i.useEffect((()=>{"phone"===x&&I("sms");let e=S.indexOf("sms"),t=S.indexOf("email");e>-1&&e<t&&I("sms")}),[x,v,C]);let P=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{A("default")}),150)};g.current=P;let{listings:E}=r.useExternalWalletListings(),R=i=>{if("email"===i)/*#__PURE__*/return e.jsx(F,{isEditable:"email"===W,setIsEditable:()=>{I("email")},defaultValue:"email"===k?.prefill?.type?k.prefill.value:void 0},i);if("sms"===i)/*#__PURE__*/return e.jsx(B,{isEditable:"sms"===W,setIsEditable:()=>{I("sms")},defaultValue:"phone"===k?.prefill?.type?k.prefill.value:void 0},i);if("apple"===i)/*#__PURE__*/return e.jsx(_,{provider:"apple"},i);if("discord"===i)/*#__PURE__*/return e.jsx(_,{provider:"discord"},i);if("farcaster"===i)/*#__PURE__*/return e.jsx(q,{},i);if("github"===i)/*#__PURE__*/return e.jsx(_,{provider:"github"},i);if("google"===i)/*#__PURE__*/return e.jsx(_,{provider:"google"},i);if("linkedin"===i)/*#__PURE__*/return e.jsx(_,{provider:"linkedin"},i);if("spotify"===i)/*#__PURE__*/return e.jsx(_,{provider:"spotify"},i);if("instagram"===i)/*#__PURE__*/return e.jsx(_,{provider:"instagram"},i);if("tiktok"===i)/*#__PURE__*/return e.jsx(_,{provider:"tiktok"},i);if("line"===i)/*#__PURE__*/return e.jsx(_,{provider:"line"},i);if("twitch"===i)/*#__PURE__*/return e.jsx(_,{provider:"twitch"},i);if("twitter"===i)/*#__PURE__*/return e.jsx(_,{provider:"twitter"},i);if("telegram"===i)/*#__PURE__*/return e.jsx($,{},i);if(i.startsWith("privy:"))/*#__PURE__*/return e.jsx(N,{appId:i.replace("privy:","")},i);let a=y.appearance.walletChainType,l=new c.WalletFilterer(a,[i]).getWallets(p,E);return l.wallets.map(((i,n)=>/*#__PURE__*/e.jsx(c.WalletRow,{index:n,data:{wallets:l.wallets,walletChainType:a,handleWalletClick(e){h((t=>({...t,externalConnectWallet:{walletList:S,walletChainType:a,preSelectedWalletId:e.id}}))),m(t?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}},i.id+n)))},D=T.flatMap(R),O=v.filter((e=>e!==w&&e!==j?.loginMethod)).flatMap(R),V=C.filter((e=>e!==w&&e!==j?.loginMethod)).flatMap(R),[H,z]=r.splitAtIndex([...D,...O,...V],ee({primary:O.length+D.length,overflow:V.length}));/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(l.ModalHeader,{title:y.appearance.landingHeader,onClose:P,backFn:"default"===L?void 0:()=>{A("default")}}),"default"===L&&/*#__PURE__*/e.jsx(te,{}),"default"===L&&("string"==typeof y.appearance.loginMessage?/*#__PURE__*/e.jsx(r.Subtitle,{children:y.appearance.loginMessage}):y.appearance.loginMessage),/*#__PURE__*/e.jsx(r.AlignBottom,{style:{overflow:"hidden"},children:/*#__PURE__*/e.jsxs(r.LoginMethodContainerWithScrollShadows,{$colorScheme:f,children:["default"===L&&/*#__PURE__*/e.jsxs(e.Fragment,{children:[H,z.length>0&&/*#__PURE__*/e.jsx(G,{text:"More options",icon:/*#__PURE__*/e.jsx(M.default,{}),onClick:()=>A("overflow")})]}),"overflow"===L&&/*#__PURE__*/e.jsx(e.Fragment,{children:z}),b&&"default"===L&&/*#__PURE__*/e.jsx(U,{})]})}),y&&/*#__PURE__*/e.jsx(l.TermsAndConditions,{app:y}),/*#__PURE__*/e.jsx(l.BlobbyFooter,{})]})},exports.LandingScreenView=({connectOnly:t})=>{let{closePrivyModal:a}=o.usePrivyInternal(),{data:p,setModalData:u,onUserCloseViaDialogOrKeybindRef:h,navigate:g}=s.usePrivyModal(),y=n.useAppConfig(),f=p?.login,x=y.appearance.walletList,w=f?.walletChainType??y.appearance.walletChainType,{accountType:j,walletClientType:v,chainType:C}=r.useRecentlyUsedLogin(),k=i.useMemo((()=>j&&"guest"!==j&&"authorization_key"!==j&&"cross_app"!==j?d.toDisplayFromAccountType(j):null),[j]),{email:M,sms:T,google:L,twitter:A,discord:I,github:P,spotify:E,instagram:R,tiktok:D,line:V,twitch:H,linkedin:z,apple:ee,wallet:te,farcaster:ie,telegram:ae}=i.useMemo((()=>f?.loginMethods?m.toObjectKeys(f.loginMethods,!0):null),[f])??y.loginMethods,{wallets:le}=c.useWalletsListController({enabled:r.shouldFetchWcRegistryListings(te?x:[]),walletList:x,walletChainType:w}),ne=y.customOAuthProviders,re=y.crossAppProviders,{passkey:oe}=y.loginMethods,se=[M&&"email",T&&"sms",L&&"google",A&&"twitter",I&&"discord",P&&"github",E&&"spotify",R&&"instagram",D&&"tiktok",V&&"line",H&&"twitch",z&&"linkedin",ee&&"apple",ie&&"farcaster",ae&&"telegram",...ne.map((e=>e.provider)),...re].filter((e=>!!e)),de=se.length>0,ce=i.useMemo((()=>te&&!de?"web3-first":te&&y?.appearance.loginGroupPriority||"web2-first"),[te,de,y?.appearance.loginGroupPriority]),pe=y?.appearance.hideDirectWeb2Inputs,[ue,he]=i.useState("default"),[ge,me]=i.useState(Y({mostRecentlyUsedAccountType:j,smsAvailable:T,emailAvailable:M,prefilledType:f?.prefill?.type}));i.useEffect((()=>{me(Y({mostRecentlyUsedAccountType:j,smsAvailable:T,emailAvailable:M,prefilledType:f?.prefill?.type}))}),[M,T,j]);let ye=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{he("default")}),150)};h.current=ye;let fe=[];v&&te?fe.push(v):k?.loginMethod&&se.includes(k.loginMethod)&&fe.push(k.loginMethod);let xe=i=>{if("email"===i)/*#__PURE__*/return e.jsx(F,{isEditable:"email"===ge,setIsEditable:()=>{me("email")},defaultValue:"email"===f?.prefill?.type?f.prefill.value:void 0},i);if("sms"===i)/*#__PURE__*/return e.jsx(B,{isEditable:"sms"===ge,setIsEditable:()=>{me("sms")},defaultValue:"phone"===f?.prefill?.type?f.prefill.value:void 0},i);if("apple"===i)/*#__PURE__*/return e.jsx(_,{provider:"apple"},i);if("discord"===i)/*#__PURE__*/return e.jsx(_,{provider:"discord"},i);if("farcaster"===i)/*#__PURE__*/return e.jsx(q,{},i);if("github"===i)/*#__PURE__*/return e.jsx(_,{provider:"github"},i);if("google"===i)/*#__PURE__*/return e.jsx(_,{provider:"google"},i);if("linkedin"===i)/*#__PURE__*/return e.jsx(_,{provider:"linkedin"},i);if("tiktok"===i)/*#__PURE__*/return e.jsx(_,{provider:"tiktok"},i);if("line"===i)/*#__PURE__*/return e.jsx(_,{provider:"line"},i);if("twitch"===i)/*#__PURE__*/return e.jsx(_,{provider:"twitch"},i);if("spotify"===i)/*#__PURE__*/return e.jsx(_,{provider:"spotify"},i);if("instagram"===i)/*#__PURE__*/return e.jsx(_,{provider:"instagram"},i);if("twitter"===i)/*#__PURE__*/return e.jsx(_,{provider:"twitter"},i);if("telegram"===i)/*#__PURE__*/return e.jsx($,{},i);if(s.isCustomOAuthProvider(i))/*#__PURE__*/return e.jsx(_,{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(N,{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){u((t=>({...t,externalConnectWallet:{walletList:x,walletChainType:l,preSelectedWalletId:e.id}}))),g(t?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}})},we=le.filter((e=>e.id!==c.WalletFilterer.normalize(v||""))),je=we.map(((i,a)=>/*#__PURE__*/e.jsx(c.WalletRow,{index:a,data:{walletChainType:w,wallets:we,handleWalletClick(e){u((t=>({...t,externalConnectWallet:{walletList:x,walletChainType:w,preSelectedWalletId:e.id}}))),g(t?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}},i.id))),ve=se.filter((e=>e!==k?.loginMethod)).flatMap(xe),Ce=fe.flatMap(xe);"web3-first"===ce&&"default"===ue?je.unshift(...Ce):"web2-first"===ce&&ve.unshift(...Ce);let Se="web2-overflow"===ue?()=>he("default"):void 0,be=se.filter((e=>"email"!==e&&"sms"!==e)),ke=Q({priority:ce,email:M,sms:T,social:be}),Me=X({priority:ce,email:M,sms:T,social:be}),Te=/*#__PURE__*/e.jsx(S.WalletOverflowButton,{text:Z({priority:ce}),onClick:()=>{u({...p,externalConnectWallet:{walletChainType:f?.walletChainType??y.appearance.walletChainType}}),g(t?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}),Le=/*#__PURE__*/e.jsx(G,{text:ke,icon:Me,onClick:()=>he("web2-overflow")}),Ae=pe?0:1,We=te&&je.length>0,Ie=0===ve.length&&te&&0===je.length,Pe=5-(We?1:0),Ee="default"===ue&&y?.appearance.logo,Ne="default"===ue&&y.appearance.loginMessage;/*#__PURE__*/return e.jsxs(b.ScreenLayout,{title:y.appearance.landingHeader,icon:Ee?/*#__PURE__*/e.jsx(W,{}):void 0,iconVariant:Ee?"logo":void 0,onClose:ye,showClose:!0,onBack:Se,showBack:!!Se,helpText:y||oe&&"default"===ue?/*#__PURE__*/e.jsxs(e.Fragment,{children:[oe&&"default"===ue&&/*#__PURE__*/e.jsx(U,{}),y&&/*#__PURE__*/e.jsx(l.TermsAndConditions,{app:y})]}):void 0,watermark:!0,children:[Ne&&("string"==typeof y.appearance.loginMessage?/*#__PURE__*/e.jsx(K,{children:y.appearance.loginMessage}):/*#__PURE__*/e.jsx(J,{children:y.appearance.loginMessage})),/*#__PURE__*/e.jsx(r.LoginMethodContainerWithScrollShadows,{$colorScheme:y.appearance.palette.colorScheme,children:"default"===ue&&"web2-first"===ce?/*#__PURE__*/e.jsxs(e.Fragment,{children:[ve.length>Pe?ve.slice(0,Pe-1):ve,ve.length>Pe&&Le,We&&Te,Ie&&/*#__PURE__*/e.jsx(O,{chainType:y.appearance.walletChainType})]}):"default"===ue&&"web3-first"===ce?/*#__PURE__*/e.jsxs(e.Fragment,{children:[te&&/*#__PURE__*/e.jsxs(e.Fragment,{children:[je.length>Pe?je.slice(0,Pe-1):je,je.length>Pe&&Te]}),ve.length>Ae&&Le,ve.length===Ae&&ve[0],Ie&&/*#__PURE__*/e.jsx(O,{chainType:y.appearance.walletChainType})]}):"web2-overflow"===ue?/*#__PURE__*/e.jsx(e.Fragment,{children:"web3-first"===ce?ve:ve.slice(3)}):null})]})};