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,xt as a}from"./useActiveWallet-CEs8euQ3.js";import{k as o,x as s}from"./context-Cdw68BC2.js";import{t as c}from"./modal-context-DHfp-mFQ.js";import{t as l}from"./createLucideIcon.js";import{t as u}from"./circle-alert.js";import{t as d}from"./circle-check-big.js";import{t as f}from"./ScreenLayout-Dy-3vlz4.js";import{t as p}from"./WalletInfoCard-BQqwW2nb.js";var m=l(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),h=n(),g=e(t(),1);i();var _=({appName:e,address:t,success:n,error:r,onAccept:i,onDecline:a,onClose:o})=>(0,h.jsx)(f,n||r?{title:r?`Something went wrong`:`Success!`,subtitle:r?`Please try again.`:`You've successfully granted delegated action permissions to ${e}.`,icon:r?u:d,iconVariant:r?`error`:`success`,onBack:o,watermark:!0}:{title:`Enable offline access`,subtitle:`By confirming, ${e} will be able to use your wallet for you even when you're not around. You can revoke this later.`,icon:m,primaryCta:{label:`Accept`,onClick:i},secondaryCta:{label:`Not now`,onClick:a},onBack:o,watermark:!0,children:(0,h.jsx)(p,{address:t,title:`Wallet`})}),v={component:()=>{let{data:e}=c(),t=o(),{closePrivyModal:n}=r(),[i,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(),{address:f,onDelegate:p,onSuccess:m,onError:v}=e.delegatedActions.consent,y=async()=>{i?m():v(u??new a(`User declined delegating actions.`)),n({shouldCallAuthOnSuccess:!1})};return(0,g.useEffect)((()=>{if(!i&&!u)return;let e=setTimeout(y,s);return()=>clearTimeout(e)}),[i,u]),(0,h.jsx)(_,{appName:t.name,address:f,success:i,error:u,onAccept:async()=>{try{await p(),l(!0)}catch(e){d(e)}},onDecline:()=>{y()},onClose:y})}};export{v as DelegatedActionsConsentScreen,v as default,_ as DelegatedActionsConsentScreenView};