import{o as e}from"./rolldown-runtime.js";import{n as t,t as n}from"./jsx-runtime.js";import{Mt as r,T as i,Vt as a,j as o}from"./useActiveWallet-CEs8euQ3.js";import{k as s}from"./context-Cdw68BC2.js";import{t as c}from"./modal-context-DHfp-mFQ.js";import{t as l}from"./esm.js";import{t as u}from"./ScreenLayout-Dy-3vlz4.js";import{t as d}from"./WalletInfoCard-BQqwW2nb.js";import{t as f}from"./WarningBanner-D5LqDt95.js";var p=n(),m=e(t(),1);o();var h=({address:e,hideWalletAddress:t,accessToken:n,appConfigTheme:r,onClose:i,exportButtonProps:a,onBack:o})=>(0,p.jsx)(u,{title:`Export wallet`,subtitle:(0,p.jsxs)(p.Fragment,{children:[`Copy either your private key or seed phrase to export your wallet.`,` `,(0,p.jsx)(`a`,{href:`https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828`,target:`blank`,rel:`noopener noreferrer`,children:`Learn more`})]}),onClose:i,onBack:o,showBack:!!o,watermark:!0,children:(0,p.jsxs)(g,{children:[(0,p.jsx)(f,{theme:r,children:`Never share your private key or seed phrase with anyone.`}),!t&&(0,p.jsx)(d,{title:`Your wallet`,address:e,showCopyButton:!0}),(0,p.jsx)(`div`,{style:{width:`100%`},children:n&&a&&(0,p.jsx)(v,{accessToken:n,dimensions:{height:`44px`},...a})})]})}),g=i.div`
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  text-align: left;
`;function _({chainType:e,imported:t,isUnifiedWallet:n}){return!t&&(n?e===`ethereum`||e===`bitcoin-taproot`||e===`pearl`:e===`ethereum`)}function v(e){let[t,n]=(0,m.useState)(e.dimensions.width),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(void 0),s=(0,m.useRef)(null);(0,m.useEffect)((()=>{if(s.current&&t===void 0){let{width:e}=s.current.getBoundingClientRect();n(e)}let e=getComputedStyle(document.documentElement);o({background:e.getPropertyValue(`--privy-color-background`),background2:e.getPropertyValue(`--privy-color-background-2`),foreground3:e.getPropertyValue(`--privy-color-foreground-3`),foregroundAccent:e.getPropertyValue(`--privy-color-foreground-accent`),accent:e.getPropertyValue(`--privy-color-accent`),accentDark:e.getPropertyValue(`--privy-color-accent-dark`),success:e.getPropertyValue(`--privy-color-success`),colorScheme:e.getPropertyValue(`color-scheme`)})}),[]);let c=_({chainType:e.chainType,imported:e.imported,isUnifiedWallet:e.isUnifiedWallet});return(0,p.jsx)(`div`,{ref:s,children:t&&(0,p.jsxs)(x,{children:[(0,p.jsx)(`iframe`,{style:{position:`absolute`,zIndex:1,opacity:+!!r,transition:`opacity 50ms ease-in-out`,pointerEvents:r?`auto`:`none`},onLoad:()=>setTimeout((()=>i(!0)),1500),width:t,height:e.dimensions.height,allow:`clipboard-write self *`,src:b({origin:e.origin,appId:e.appId,appClientId:e.appClientId,walletId:e.walletId,entropyId:e.entropyId,entropyIdVerifier:e.entropyIdVerifier,hdWalletIndex:e.hdWalletIndex,chainType:e.chainType,accessToken:e.accessToken,clientAnalyticsId:e.clientAnalyticsId,width:t,palette:a,isUnifiedWallet:e.isUnifiedWallet,exportSeedPhrase:c})}),(0,p.jsx)(S,{children:`Loading...`}),c&&(0,p.jsx)(S,{children:`Loading...`})]})})}var y={component:()=>{let[e,t]=(0,m.useState)(null),{authenticated:n,user:i}=r(),{closePrivyModal:o,createAnalyticsEvent:l,clientAnalyticsId:u,client:d}=a(),f=s(),{data:g,onUserCloseViaDialogOrKeybindRef:_}=c(),{onFailure:v,onSuccess:y,origin:b,appId:x,appClientId:S,entropyId:C,entropyIdVerifier:w,walletId:T,hdWalletIndex:E,chainType:D,address:O,uiOptions:k,isUnifiedWallet:A,imported:j,showBackButton:M}=g.keyExport,N=e=>{o({shouldCallAuthOnSuccess:!1}),v(typeof e==`string`?Error(e):e)},P=()=>{o({shouldCallAuthOnSuccess:!1}),y(),l({eventName:`embedded_wallet_key_export_completed`,payload:{walletAddress:O}})};return(0,m.useEffect)((()=>{if(!n)return N(`User must be authenticated before exporting their wallet`);d.getAccessToken().then(t).catch(N)}),[n,i]),_.current=P,(0,p.jsx)(h,{address:O,hideWalletAddress:k?.hideWalletAddress,accessToken:e,appConfigTheme:f.appearance.palette.colorScheme,onClose:P,isLoading:!e,onBack:M?P:void 0,exportButtonProps:e?{origin:b,appId:x,appClientId:S,clientAnalyticsId:u,entropyId:C,entropyIdVerifier:w,walletId:T,hdWalletIndex:E,isUnifiedWallet:A,imported:j,chainType:D}:void 0})}};function b({origin:e,appId:t,appClientId:n,walletId:r,entropyId:i,entropyIdVerifier:a,hdWalletIndex:o,chainType:s,accessToken:c,clientAnalyticsId:u,width:d,palette:f,isUnifiedWallet:p,exportSeedPhrase:m}){return l({origin:e,path:`/apps/${t}/embedded-wallets/export`,query:p?{v:`1-unified`,wallet_id:r,chain_type:s,client_id:n,width:`${d}px`,caid:u,phrase_export:m,...f}:{v:`1`,entropy_id:i,entropy_id_verifier:a,hd_wallet_index:o,chain_type:s,client_id:n,width:`${d}px`,caid:u,phrase_export:m,...f},hash:{token:c}})}var x=i.div`
  overflow: visible;
  position: relative;
  height: 44px;
  display: flex;
  gap: 12px;
`,S=i.div`
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 16px;
  font-weight: 500;
  border-radius: var(--privy-border-radius-md);
  background-color: var(--privy-color-background-2);
  color: var(--privy-color-foreground-3);
`;export{y as EmbeddedWalletKeyExportScreen,y as default,h as EmbeddedWalletKeyExportView,b as constructWalletExportIframeUrl,_ as supportsSeedPhraseExport};