import{o as e}from"./rolldown-runtime.js";import{n as t,t as n}from"./jsx-runtime.js";import{Vt as r,j as i}from"./useActiveWallet-CEs8euQ3.js";import{k as a}from"./context-Cdw68BC2.js";import{t as o}from"./modal-context-DHfp-mFQ.js";import{t as s}from"./ScreenLayout-Dy-3vlz4.js";import{t as c}from"./PhoneIcon.js";import{t as l}from"./ConnectPhoneForm-6YkGGDnO.js";var u=n(),d=e(t(),1);i();var f=({title:e=`Connect your phone`,subtitle:t=`Add your number to your account`,onSubmit:n,isSubmitting:r=!1})=>{let[i,a]=(0,d.useState)(null),o=async()=>{i?.qualifiedPhoneNumber&&await n(i)};return(0,u.jsx)(s,{title:e,subtitle:t,icon:c,primaryCta:{label:r?`Submitting`:`Submit`,onClick:o,disabled:!i?.isValid||r},watermark:!0,children:(0,u.jsx)(l,{onChange:e=>{a(e)},onSubmit:o,noIncludeSubmitButton:!0,hideRecent:!0})})},p={component:()=>{let{currentScreen:e,data:t,navigate:n,setModalData:i}=o(),s=a(),{initLoginWithSms:c}=r(),[l,p]=(0,d.useState)(!1);return(0,u.jsx)(f,{subtitle:`Add your number to your ${s?.name} account`,onSubmit:async r=>{p(!0);try{await c({phoneNumber:r.qualifiedPhoneNumber,withPrivyUi:!0}),n(`AwaitingPasswordlessCodeScreen`)}catch(r){i({errorModalData:{error:r,previousScreen:t?.errorModalData?.previousScreen||e||`LinkPhoneScreen`}}),n(`ErrorScreen`)}finally{p(!1)}},isSubmitting:l})}};export{p as LinkPhoneScreen,p as default,f as LinkPhoneScreenView};