import{o as e}from"./rolldown-runtime.js";import{n as t,t as n}from"./jsx-runtime.js";import{T as r,Vt as i,_ as a,d as o,n as s,ut as c}from"./useActiveWallet-CEs8euQ3.js";import{k as l}from"./context-Cdw68BC2.js";import{Cn as u}from"./ccip.js";import{s as d,x as f,y as p}from"./index-CKYEOQWW.js";import{s as m}from"./toViemAccount-BywVRwQG.js";import{o as h}from"./get-entropy-details-for-user-Bq7nAeEf.js";import{l as g,o as _,r as v,t as y}from"./ModalHeader-BS54PZSj.js";import{t as b}from"./ScreenLayout-Dy-3vlz4.js";import{a as x,d as S,g as C,h as w,i as T,m as E,n as D,o as O,r as k,s as A,v as j,x as M,y as N}from"./PinInput-YqT0dSuH.js";import{t as P}from"./ExclamationTriangleIcon.js";import{t as F}from"./FingerPrintIcon.js";import{t as I}from"./PhoneIcon.js";import{t as L}from"./ShieldCheckIcon.js";import{t as R}from"./useGetTokenPrice-Bm_VkGB-.js";import{t as z}from"./StackedContainer-B2vaEl56.js";import{t as B}from"./TransactionDetails-Gb0WrEsR.js";var V=n(),H=e(t());function U({title:e,titleId:t,...n},r){return H.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?H.createElement(`title`,{id:t},e):null,H.createElement(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0v-7.5A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5`}))}var W=H.forwardRef(U),G=({handleClose:e,mfaMethods:t,onSelect:n})=>(0,V.jsxs)(b,{title:`Verify your identity`,subtitle:`Choose a verification method`,icon:L,iconVariant:`subtle`,onClose:e,showClose:!0,watermark:!0,children:[(0,V.jsxs)(C,{children:[t.includes(`totp`)&&(0,V.jsxs)(o,{onClick:()=>n(`totp`),children:[(0,V.jsx)(a,{children:(0,V.jsx)(M,{})}),`Authenticator app`]},`totp`),t.includes(`sms`)&&(0,V.jsxs)(o,{onClick:()=>n(`sms`),children:[(0,V.jsx)(a,{children:(0,V.jsx)(I,{})}),`SMS`]},`sms`),t.includes(`passkey`)&&(0,V.jsxs)(o,{onClick:()=>n(`passkey`),children:[(0,V.jsx)(a,{children:(0,V.jsx)(F,{})}),`Passkey`]},`passkey`)]}),(0,V.jsx)(_,{})]}),K=({pendingTransaction:e})=>{let{wallets:t}=h(),{walletProxy:n,rpcConfig:r,chains:a,appId:o,nativeTokenSymbolForChainId:s}=i(),[l,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(e),{tokenPrice:g}=R(f.chainId),_=s(e.chainId)||`ETH`,v=(0,H.useMemo)((()=>t.find((e=>e.walletClientType===`privy`))),[t]);return(0,H.useEffect)((()=>{(async function(){if(!n||!v)return f;let e=c(f.chainId,a,r,{appId:o}),t=await m(f,e,v.address);return d(u(BigInt(t.gas??0))),t})().then(p).catch(console.error)}),[n]),v?(0,V.jsx)(q,{children:(0,V.jsx)(B,{from:v.address,to:f.to,txn:f,gas:l??void 0,tokenPrice:g,tokenSymbol:_})}):null},q=r.div`
  width: 100%;
  padding: 1rem 0;
`,J=({hasBlockingError:e,error:t,onClose:n,onBack:r,handleSubmit:a,account:o,submitSuccess:c})=>{let{pendingTransaction:l}=i();return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(v,{onClose:n},`header`),(0,V.jsx)(z,{children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(s,{success:c,fail:!!t}),(0,V.jsx)(t?P:D,{style:{width:`38px`,height:`38px`}})]})}),(0,V.jsx)(S,{style:{marginTop:`1rem`},children:`Verifying with passkey`}),(0,V.jsxs)(w,{children:[(0,V.jsxs)(N,{children:[(0,V.jsx)(O,{children:(0,V.jsx)(L,{})}),`Approve this action using your touch, face, PIN, or hardware key.`]}),(0,V.jsxs)(N,{children:[(0,V.jsx)(O,{children:(0,V.jsx)(W,{})}),`You last added a passkey on`,` `,o?.firstVerifiedAt?.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`}),`.`]})]}),l&&(0,V.jsx)(E,{children:(0,V.jsx)(K,{pendingTransaction:l})}),t&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(T,{style:{marginTop:`1.25rem`},children:t.message}),(0,V.jsx)(g,{disabled:e,onClick:a,style:{margin:`1.25rem auto 0`},children:`Try again`})]}),r&&(0,V.jsx)(x,{style:{marginTop:`1rem`},onClick:r,children:`Choose another method`}),(0,V.jsx)(_,{})]})},Y=({selectedMethod:e,submitSuccess:t,hasBlockingError:n,onClose:r,onBack:a,handleSubmitCode:o})=>{let s=l(),{pendingTransaction:c}=i();switch(e){case`sms`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(v,{onClose:r},`header`),(0,V.jsx)(j,{style:{marginBottom:`1.5rem`},children:(0,V.jsx)(I,{})}),(0,V.jsx)(S,{children:`Enter verification code`}),(0,V.jsxs)(E,{children:[(0,V.jsx)(k,{success:t,disabled:n,onChange:o}),(0,V.jsxs)(A,{children:[`To continue, please enter the 6-digit code sent to your `,(0,V.jsx)(`strong`,{children:`mobile device`})]}),c&&(0,V.jsx)(K,{pendingTransaction:c})]}),a&&(0,V.jsx)(x,{theme:s?.appearance.palette.colorScheme,onClick:a,children:`Choose another method`}),(0,V.jsx)(y,{onClick:r,children:`Cancel`}),(0,V.jsx)(_,{})]});case`totp`:return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(v,{onClose:r},`header`),(0,V.jsx)(j,{style:{marginBottom:`1.5rem`},children:(0,V.jsx)(M,{})}),(0,V.jsx)(S,{children:`Enter verification code`}),(0,V.jsxs)(E,{children:[(0,V.jsx)(k,{success:t,disabled:n,onChange:o}),(0,V.jsxs)(A,{children:[`To continue, please enter the 6-digit code generated from your`,` `,(0,V.jsx)(`strong`,{children:`authenticator app`})]}),c&&(0,V.jsx)(K,{pendingTransaction:c})]}),a&&(0,V.jsx)(x,{theme:s?.appearance.palette.colorScheme,onClick:a,children:`Choose another method`}),(0,V.jsx)(y,{onClick:r,children:`Cancel`}),(0,V.jsx)(_,{})]});default:return null}},X=e=>f(e)?{isBlocking:!0,error:Error(`You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.`)}:d(e)?{isBlocking:!1,error:Error(`The code you entered is not valid`)}:p(e)?{isBlocking:!0,error:Error(`You have exceeded the time limit for code entry. Please try again in 30 seconds.`)}:(console.error(e),{isBlocking:!1,error:Error(`Something went wrong.`)});export{G as i,Y as n,X as r,J as t};