@privy-io/react-auth
Version:
React client for the Privy Auth API
3 lines (2 loc) • 25.9 kB
JavaScript
import{jsx as e,jsxs as n,Fragment as r}from"react/jsx-runtime";import{BoltIcon as i,ArrowRightIcon as o,ChevronDownIcon as t}from"@heroicons/react/24/outline";import{useState as a}from"react";import{styled as l}from"styled-components";import{formatTokenAmount as d}from"@privy-io/js-sdk-core";import{P as c,E as s}from"./Button-B8mqatRx.mjs";import{M as h,B as m,a as p}from"./ModalHeader-BLGC-7ev.mjs";import{L as u,V as f,a as g}from"./Value-B4M62ove.mjs";import{a as y,R as b}from"./Row-CG0lSY5Z.mjs";import{E as x}from"./ErrorMessage-Cx8GKGhL.mjs";import{L as k}from"./LabelXs-BOisBtqT.mjs";import{S as w}from"./Subtitle-DkvfP2Ev.mjs";import{T as v}from"./Title-D0pfZff-.mjs";import{A as I}from"./Address-BsvZLUXE.mjs";import{W as C}from"./WalletInfoCard-YE5P6CSV.mjs";import{u as T}from"./context-Bycd1SKV.mjs";import{Y as S}from"./useActiveWallet-Bsy5GTCV.mjs";import{L as N}from"./LoadingSkeleton-CHdaq3pb.mjs";import{isAddress as A}from"viem";import{B as j}from"./shared-CtYf3O54.mjs";import{C as E}from"./Checkbox-NmGCZeKL.mjs";import{E as M}from"./ErrorBanner-BdiArMwu.mjs";import{W as $}from"./WarningBanner-BDp-QC9i.mjs";import O from"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import D from"@heroicons/react/24/outline/ClipboardDocumentIcon";import F from"@heroicons/react/24/outline/ExclamationCircleIcon";import{u as L}from"./internal-context-e-Eni5bG.mjs";const B=/*#__PURE__*/l(u).withConfig({displayName:"InteractiveLabel",componentId:"sc-b57d0824-0"})(["cursor:pointer;display:inline-flex;gap:8px;align-items:center;color:var(--privy-color-accent);svg{fill:var(--privy-color-accent);}"]);var P=({iconUrl:r,value:i,symbol:o,usdValue:t,nftName:a,nftCount:l,decimals:d,$isLoading:c})=>{if(c)/*#__PURE__*/return e(R,{$isLoading:c});let s=i&&t&&d?function(e,n,r){let i=parseFloat(e),o=parseFloat(r);if(0===i||0===o||Number.isNaN(i)||Number.isNaN(o))return e;let t=Math.ceil(-Math.log10(.01/(o/i))),a=Math.pow(10,t=Math.max(t=Math.min(t,n),1)),l=+(Math.floor(i*a)/a).toFixed(t).replace(/\.?0+$/,"");return Intl.NumberFormat(void 0,{maximumFractionDigits:n}).format(l)}(i,d,t):i;/*#__PURE__*/return n("div",{children:[/*#__PURE__*/n(R,{$isLoading:c,children:[r&&/*#__PURE__*/e(z,{src:r,alt:"Token icon"}),l&&l>1?l+"x":void 0," ",a,s," ",o]}),t&&/*#__PURE__*/n(W,{$isLoading:c,children:["$",t]})]})};let R=/*#__PURE__*/l.span.withConfig({displayName:"Value",componentId:"sc-991db279-0"})(["color:var(--privy-color-foreground);font-size:0.875rem;font-weight:500;line-height:1.375rem;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],N);const W=/*#__PURE__*/l.span.withConfig({displayName:"Subvalue",componentId:"sc-991db279-1"})(["color:var(--privy-color-foreground-2);font-size:12px;font-weight:400;line-height:18px;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],N);let z=/*#__PURE__*/l.img.withConfig({displayName:"TokenIcon",componentId:"sc-991db279-2"})(["height:14px;width:14px;margin-right:4px;object-fit:contain;"]);const V=i=>{let{chain:o,transactionDetails:t,isTokenContractInfoLoading:a,symbol:l}=i,{action:d,functionName:c}=t;/*#__PURE__*/return e(j,{children:/*#__PURE__*/n(y,{children:["transaction"!==d&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Action"}),/*#__PURE__*/e(f,{children:c})]}),"mint"===c&&"args"in t&&t.args.filter((e=>e)).map(((r,i)=>/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:`Param ${i}`}),/*#__PURE__*/e(f,{children:"string"==typeof r&&A(r)?/*#__PURE__*/e(I,{address:r,url:o?.blockExplorers?.default?.url,showCopyIcon:!1}):r?.toString()})]},i))),"setApprovalForAll"===c&&t.operator&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Operator"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:t.operator,url:o?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),"setApprovalForAll"===c&&void 0!==t.approved&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Set approval to"}),/*#__PURE__*/e(f,{children:t.approved?"true":"false"})]}),"transfer"===c||"transferFrom"===c||"safeTransferFrom"===c||"approve"===c?/*#__PURE__*/n(r,{children:["formattedAmount"in t&&t.formattedAmount&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Amount"}),/*#__PURE__*/n(f,{$isLoading:a,children:[t.formattedAmount," ",l]})]}),"tokenId"in t&&t.tokenId&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Token ID"}),/*#__PURE__*/e(f,{children:t.tokenId.toString()})]})]}):null,"safeBatchTransferFrom"===c&&/*#__PURE__*/n(r,{children:["amounts"in t&&t.amounts&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Amounts"}),/*#__PURE__*/e(f,{children:t.amounts.join(", ")})]}),"tokenIds"in t&&t.tokenIds&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Token IDs"}),/*#__PURE__*/e(f,{children:t.tokenIds.join(", ")})]})]}),"approve"===c&&t.spender&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Spender"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:t.spender,url:o?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&t.transferFrom&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Transferring from"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:t.transferFrom,url:o?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&t.transferTo&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Transferring to"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:t.transferTo,url:o?.blockExplorers?.default?.url,showCopyIcon:!1})})]})]})})},H=({variant:i,setPreventMaliciousTransaction:o,colorScheme:t="light",preventMaliciousTransaction:a})=>"warn"===i?/*#__PURE__*/e(U,{children:/*#__PURE__*/n($,{theme:t,children:[/*#__PURE__*/e("span",{style:{fontWeight:"500"},children:"Warning: Suspicious transaction"}),/*#__PURE__*/e("br",{}),"This has been flagged as a potentially deceptive request. Approving could put your assets or funds at risk."]})}):"error"===i?/*#__PURE__*/e(r,{children:/*#__PURE__*/n(U,{children:[/*#__PURE__*/e(M,{theme:t,children:/*#__PURE__*/n("div",{children:[/*#__PURE__*/e("strong",{children:"This is a malicious transaction"}),/*#__PURE__*/e("br",{}),"This transaction transfers tokens to a known malicious address. Proceeding may result in the loss of valuable assets."]})}),/*#__PURE__*/n(q,{children:[/*#__PURE__*/e(E,{color:"var(--privy-color-error)",checked:!a,readOnly:!0,onClick:()=>o(!a)}),/*#__PURE__*/e("span",{children:"I understand and want to proceed anyways."})]})]})}):null;let U=/*#__PURE__*/l.div.withConfig({displayName:"BannerContainer",componentId:"sc-ab8a5a0b-0"})(["margin-top:1.5rem;"]),q=/*#__PURE__*/l.div.withConfig({displayName:"CheckboxContainer",componentId:"sc-ab8a5a0b-1"})(["display:flex;align-items:center;gap:0.5rem;margin-top:0.75rem;"]);const J=({transactionIndex:e,maxIndex:n})=>"number"!=typeof e||0===n?"":` (${e+1} / ${n+1})`,Q=({img:l,submitError:d,prepareError:p,onClose:k,action:C,title:N,subtitle:A,to:j,tokenAddress:E,network:M,missingFunds:$,fee:O,from:D,cta:F,disabled:L,chain:R,isSubmitting:W,isPreparing:z,isTokenPriceLoading:U,isTokenContractInfoLoading:q,isSponsored:Q,symbol:Y,balance:G,onClick:ne,transactionDetails:re,transactionIndex:ie,maxIndex:oe,onBack:te,chainName:ae,validation:le,hasScanDetails:de,setIsScanDetailsOpen:ce,preventMaliciousTransaction:se,setPreventMaliciousTransaction:he,tokensSent:me,tokensReceived:pe,isScanning:ue,isCancellable:fe,functionName:ge})=>{let{showTransactionDetails:ye,setShowTransactionDetails:be,hasMoreDetails:xe,isErc20Ish:ke}=(e=>{let[n,r]=a(!1),i=!0,o=!1;return(!e||e.isErc20Ish||"transaction"===e.action)&&(i=!1),i&&(o=Object.entries(e||{}).some((([e,n])=>n&&!["action","isErc20Ish","isNFTIsh"].includes(e)))),{showTransactionDetails:n,setShowTransactionDetails:r,hasMoreDetails:i&&o,isErc20Ish:e?.isErc20Ish}})(re),we=T(),ve=ke&&q||z||U||ue;/*#__PURE__*/return n(r,{children:[/*#__PURE__*/e(h,{onClose:k,backFn:te}),l&&/*#__PURE__*/e(Z,{children:l}),/*#__PURE__*/n(v,{style:{marginTop:l?"1.5rem":0},children:[N,/*#__PURE__*/e(J,{maxIndex:oe,transactionIndex:ie})]}),/*#__PURE__*/e(w,{children:A}),/*#__PURE__*/n(y,{style:{marginTop:"2rem"},children:[(!!me[0]||ve)&&/*#__PURE__*/n(b,{children:[pe.length>0?/*#__PURE__*/e(u,{children:"Send"}):/*#__PURE__*/e(u,{children:"approve"===C?"Approval amount":"Amount"}),/*#__PURE__*/e("div",{className:"flex flex-col",children:me.map(((n,r)=>/*#__PURE__*/e(P,{iconUrl:n.iconUrl,value:"setApprovalForAll"===ge?"All":n.value,usdValue:n.usdValue,symbol:n.symbol,nftName:n.nftName,nftCount:n.nftCount,decimals:n.decimals},r)))})]}),pe.length>0&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Receive"}),/*#__PURE__*/e("div",{className:"flex flex-col",children:pe.map(((n,r)=>/*#__PURE__*/e(P,{iconUrl:n.iconUrl,value:n.value,usdValue:n.usdValue,symbol:n.symbol,nftName:n.nftName,nftCount:n.nftCount,decimals:n.decimals},r)))})]}),re&&"spender"in re&&re?.spender?/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Spender"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:re.spender,url:R?.blockExplorers?.default?.url})})]}):null,j&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"To"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:j,url:R?.blockExplorers?.default?.url,showCopyIcon:!0})})]}),E&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Token address"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:E,url:R?.blockExplorers?.default?.url})})]}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Network"}),/*#__PURE__*/e(f,{children:M})]}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Estimated fee"}),/*#__PURE__*/e(f,{$isLoading:z||U||void 0===Q,children:Q?/*#__PURE__*/n(_,{children:[/*#__PURE__*/n(ee,{children:["Sponsored by ",we.name]}),/*#__PURE__*/e(i,{height:16,width:16})]}):O})]}),xe&&!de&&/*#__PURE__*/n(r,{children:[/*#__PURE__*/e(b,{className:"cursor-pointer",onClick:()=>be(!ye),children:/*#__PURE__*/n(g,{className:"flex items-center gap-x-1",children:["Details"," ",/*#__PURE__*/e(t,{style:{width:"0.75rem",marginLeft:"0.25rem",transform:ye?"rotate(180deg)":void 0}})]})}),ye&&re&&/*#__PURE__*/e(V,{action:C,chain:R,transactionDetails:re,isTokenContractInfoLoading:q,symbol:Y})]}),de&&/*#__PURE__*/e(b,{children:/*#__PURE__*/n(B,{onClick:()=>ce(!0),children:[/*#__PURE__*/e("span",{className:"text-color-primary",children:"Details"}),/*#__PURE__*/e(o,{height:"14px",width:"14px",strokeWidth:"2"})]})})]}),/*#__PURE__*/e(S,{}),d?/*#__PURE__*/e(x,{style:{marginTop:"2rem"},children:d.message}):p&&0===ie?
/*#__PURE__*/e(x,{style:{marginTop:"2rem"},children:p.shortMessage??K}):null,/*#__PURE__*/e(H,{variant:le,preventMaliciousTransaction:se,setPreventMaliciousTransaction:he}),/*#__PURE__*/e(X,{$useSmallMargins:!(!p&&!d&&"warn"!==le&&"error"!==le),address:D,balance:G,errMsg:z||p||d||!$?void 0:`Add funds on ${R?.name??ae} to complete transaction.`}),/*#__PURE__*/e(c,{style:{marginTop:"1rem"},loading:W,disabled:L||z,onClick:ne,children:F}),fe&&/*#__PURE__*/e(s,{style:{marginTop:"1rem"},onClick:k,isSubmitting:!1,children:"Not now"}),/*#__PURE__*/e(m,{})]})},Y=({img:o,title:l,subtitle:s,cta:p,instructions:g,network:C,blockExplorerUrl:N,isMissingFunds:A,submitError:j,parseError:E,total:M,swap:$,transactingWalletAddress:O,fee:D,balance:F,disabled:L,isSubmitting:P,isPreparing:R,isTokenPriceLoading:W,onClick:z,onClose:V,onBack:H,isSponsored:U})=>{let q=R||W,[J,Q]=a(!1),Y=T();/*#__PURE__*/return n(r,{children:[/*#__PURE__*/e(h,{onClose:V,backFn:H}),o&&/*#__PURE__*/e(Z,{children:o}),/*#__PURE__*/e(v,{style:{marginTop:o?"1.5rem":0},children:l}),/*#__PURE__*/e(w,{children:s}),/*#__PURE__*/n(y,{style:{marginTop:"2rem",marginBottom:".5rem"},children:[(M||q)&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Amount"}),/*#__PURE__*/e(f,{$isLoading:q,children:M})]}),$&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Swap"}),/*#__PURE__*/e(f,{children:$})]}),C&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Network"}),/*#__PURE__*/e(f,{children:C})]}),(D||q||void 0!==U)&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Estimated fee"}),/*#__PURE__*/e(f,{$isLoading:q,children:U&&!q?/*#__PURE__*/n(_,{children:[/*#__PURE__*/n(ee,{children:["Sponsored by ",Y.name]}),/*#__PURE__*/e(i,{height:16,width:16})]}):D})]})]}),/*#__PURE__*/e(b,{children:/*#__PURE__*/n(B,{onClick:()=>Q((e=>!e)),children:[/*#__PURE__*/e("span",{children:"Advanced"}),/*#__PURE__*/e(t,{height:"16px",width:"16px",strokeWidth:"2",style:{transition:"all 300ms",transform:J?"rotate(180deg)":void 0}})]})}),J&&/*#__PURE__*/e(r,{children:g.map(((r,i)=>"sol-transfer"===r.type?/*#__PURE__*/n(G,{children:[/*#__PURE__*/e(b,{children:/*#__PURE__*/n(k,{children:["Transfer ",r.withSeed?"with seed":""]})}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Amount"}),/*#__PURE__*/n(f,{children:[d({amount:r.value,decimals:r.token.decimals})," ",r.token.symbol]})]}),!!r.toAccount&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Destination"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.toAccount,url:N})})]})]},i):"spl-transfer"===r.type?/*#__PURE__*/n(G,{children:[/*#__PURE__*/e(b,{children:/*#__PURE__*/n(k,{children:["Transfer ",r.token.symbol]})}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Amount"}),/*#__PURE__*/e(f,{children:r.value.toString()})]}),!!r.fromAta&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Source"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.fromAta,url:N})})]}),!!r.toAta&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Destination"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.toAta,url:N})})]}),!!r.token.address&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Token"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.token.address,url:N})})]})]},i):"ata-creation"===r.type?/*#__PURE__*/n(G,{children:[/*#__PURE__*/e(b,{children:/*#__PURE__*/e(k,{children:"Create token account"})}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Program ID"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.program,url:N})})]}),!!r.owner&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Owner"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.owner,url:N})})]})]},i):"create-account"===r.type?/*#__PURE__*/n(G,{children:[/*#__PURE__*/e(b,{children:/*#__PURE__*/n(k,{children:["Create account ",r.withSeed?"with seed":""]})}),!!r.account&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Account"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.account,url:N})})]}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Amount"}),/*#__PURE__*/n(f,{children:[d({amount:r.value,decimals:9})," SOL"]})]})]},i):"spl-init-account"===r.type?/*#__PURE__*/n(G,{children:[/*#__PURE__*/e(b,{children:/*#__PURE__*/e(k,{children:"Initialize token account"})}),!!r.account&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Account"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.account,url:N})})]}),!!r.mint&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Mint"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.mint,url:N})})]}),!!r.owner&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Owner"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.owner,url:N})})]})]},i):"spl-close-account"===r.type?/*#__PURE__*/n(G,{children:[/*#__PURE__*/e(b,{children:/*#__PURE__*/e(k,{children:"Close token account"})}),!!r.source&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Source"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.source,url:N})})]}),!!r.destination&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Destination"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.destination,url:N})})]}),!!r.owner&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Owner"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.owner,url:N})})]})]},i):"spl-sync-native"===r.type?/*#__PURE__*/n(G,{children:[/*#__PURE__*/e(b,{children:/*#__PURE__*/e(k,{children:"Sync native"})}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Program ID"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.program,url:N})})]})]},i):"raydium-swap-base-input"===r.type?/*#__PURE__*/n(G,{children:[/*#__PURE__*/e(b,{children:/*#__PURE__*/n(k,{children:["Raydium swap"," ",r.tokenIn&&r.tokenOut?`${r.tokenIn.symbol} → ${r.tokenOut.symbol}`:""]})}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Amount in"}),/*#__PURE__*/e(f,{children:r.amountIn.toString()})]}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Minimum amount out"}),/*#__PURE__*/e(f,{children:r.minimumAmountOut.toString()})]}),r.mintIn&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Token in"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.mintIn,url:N})})]}),r.mintOut&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Token out"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.mintOut,url:N})})]})]},i):"raydium-swap-base-output"===r.type?/*#__PURE__*/n(G,{children:[/*#__PURE__*/e(b,{children:/*#__PURE__*/n(k,{children:["Raydium swap"," ",r.tokenIn&&r.tokenOut?`${r.tokenIn.symbol} → ${r.tokenOut.symbol}`:""]})}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Max amount in"}),/*#__PURE__*/e(f,{children:r.maxAmountIn.toString()})]}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Amount out"}),/*#__PURE__*/e(f,{children:r.amountOut.toString()})]}),r.mintIn&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Token in"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.mintIn,url:N})})]}),r.mintOut&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Token out"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.mintOut,url:N})})]})]},i):"jupiter-swap-shared-accounts-route"===r.type?/*#__PURE__*/n(G,{children:[/*#__PURE__*/e(b,{children:/*#__PURE__*/n(k,{children:["Jupiter swap"," ",r.tokenIn&&r.tokenOut?`${r.tokenIn.symbol} → ${r.tokenOut.symbol}`:""]})}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"In amount"}),/*#__PURE__*/e(f,{children:r.inAmount.toString()})]}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Quoted out amount"}),/*#__PURE__*/e(f,{children:r.quotedOutAmount.toString()})]}),r.mintIn&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Token in"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.mintIn,url:N})})]}),r.mintOut&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Token out"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.mintOut,url:N})})]})]},i):"jupiter-swap-exact-out-route"===r.type?/*#__PURE__*/n(G,{children:[/*#__PURE__*/e(b,{children:/*#__PURE__*/n(k,{children:["Jupiter swap"," ",r.tokenIn&&r.tokenOut?`${r.tokenIn.symbol} → ${r.tokenOut.symbol}`:""]})}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Quoted in amount"}),/*#__PURE__*/e(f,{children:r.quotedInAmount.toString()})]}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Amount out"}),/*#__PURE__*/e(f,{children:r.outAmount.toString()})]}),r.mintIn&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Token in"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.mintIn,url:N})})]}),r.mintOut&&/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Token out"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.mintOut,url:N})})]})]},i):/*#__PURE__*/n(G,{children:[/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Program ID"}),/*#__PURE__*/e(f,{children:/*#__PURE__*/e(I,{address:r.program,url:N})})]}),/*#__PURE__*/n(b,{children:[/*#__PURE__*/e(u,{children:"Data"}),/*#__PURE__*/e(f,{children:r.discriminator})]})]},i)))}),/*#__PURE__*/e(S,{}),j?/*#__PURE__*/e(x,{style:{marginTop:"2rem"},children:j.message}):E?/*#__PURE__*/e(x,{style:{marginTop:"2rem"},children:K}):null,/*#__PURE__*/e(X,{$useSmallMargins:!(!E&&!j),title:"",address:O,balance:F,errMsg:R||E||j||!A?void 0:"Add funds on Solana to complete transaction."}),/*#__PURE__*/e(c,{style:{marginTop:"1rem"},loading:P,disabled:L||R,onClick:z,children:p}),/*#__PURE__*/e(m,{})]})};let X=/*#__PURE__*/l(C).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-cbe5ab37-0"})(["",""],(e=>e.$useSmallMargins?"margin-top: 0.5rem;":"margin-top: 2rem;")),G=/*#__PURE__*/l(y).withConfig({displayName:"InstructionRows",componentId:"sc-cbe5ab37-1"})(["margin-top:0.5rem;border:1px solid var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-sm);padding:0.5rem;"]),K="There was an error preparing your transaction. Your transaction request will likely fail.",Z=/*#__PURE__*/l.div.withConfig({displayName:"ImageContainer",componentId:"sc-cbe5ab37-2"})(["display:flex;width:100%;justify-content:center;max-height:40px;> img{object-fit:contain;border-radius:var(--privy-border-radius-sm);}"]),_=/*#__PURE__*/l.span.withConfig({displayName:"SponsoredRow",componentId:"sc-cbe5ab37-3"})(["display:inline-flex;align-items:center;gap:0.3rem;"]),ee=/*#__PURE__*/l.span.withConfig({displayName:"SponsoredText",componentId:"sc-cbe5ab37-4"})(["font-size:14px;font-weight:500;color:var(--privy-color-foreground);"]);let ne=()=>/*#__PURE__*/n(ae,{children:[/*#__PURE__*/e(de,{}),/*#__PURE__*/e(le,{})]});const re=({transactionError:i,chainId:o,onClose:t,onRetry:l,chainType:d,transactionHash:c})=>{let{chains:s}=L(),[m,u]=a(!1),{errorCode:f,errorMessage:g}=((e,n)=>{if("ethereum"===n)return{errorCode:e.details??e.message,errorMessage:e.shortMessage};let r=e.txSignature,i=e?.transactionMessage||"Something went wrong.";if(Array.isArray(e.logs)){let n=e.logs.find((e=>/insufficient (lamports|funds)/gi.test(e)));n&&(i=n)}return{transactionHash:r,errorMessage:i}})(i,d),y=(({chains:e,chainId:n,chainType:r,transactionHash:i})=>"ethereum"===r?e.find((e=>e.id===n))?.blockExplorers?.default.url??"https://etherscan.io":function(e,n){return`https://explorer.solana.com/tx/${e}?chain=${n}`}(i||"",n))({chains:s,chainId:o,chainType:d,transactionHash:c});/*#__PURE__*/return n(r,{children:[/*#__PURE__*/e(h,{onClose:t}),/*#__PURE__*/n(ie,{children:[/*#__PURE__*/e(ne,{}),/*#__PURE__*/e(oe,{children:f}),/*#__PURE__*/e(te,{children:"Please try again."}),/*#__PURE__*/n(he,{children:[/*#__PURE__*/e(se,{children:"Error message"}),/*#__PURE__*/e(pe,{$clickable:!1,children:g})]}),c&&/*#__PURE__*/n(he,{children:[/*#__PURE__*/e(se,{children:"Transaction hash"}),/*#__PURE__*/n(me,{children:["Copy this hash to view details about the transaction on a"," ",/*#__PURE__*/e("u",{children:/*#__PURE__*/e("a",{href:y,children:"block explorer"})}),"."]}),/*#__PURE__*/n(pe,{$clickable:!0,onClick:async()=>{await navigator.clipboard.writeText(c),u(!0)},children:[c,/*#__PURE__*/e(ge,{clicked:m})]})]}),/*#__PURE__*/e(ce,{onClick:()=>l({resetNonce:!!c}),children:"Retry transaction"})]}),/*#__PURE__*/e(p,{})]})};let ie=/*#__PURE__*/l.div.withConfig({displayName:"TransactionErrorScreenContainer",componentId:"sc-d58f10e6-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;"]),oe=/*#__PURE__*/l.span.withConfig({displayName:"ErrorCode",componentId:"sc-d58f10e6-1"})(["color:var(--privy-color-foreground);text-align:center;font-size:1.125rem;font-weight:500;line-height:1.25rem;text-align:center;margin:10px;"]),te=/*#__PURE__*/l.span.withConfig({displayName:"Subtitle",componentId:"sc-d58f10e6-2"})(["margin-top:4px;margin-bottom:10px;color:var(--privy-color-foreground-3);text-align:center;font-size:0.875rem;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;"]),ae=/*#__PURE__*/l.div.withConfig({displayName:"CircleContainer",componentId:"sc-d58f10e6-3"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]),le=/*#__PURE__*/l(F).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-d58f10e6-4"})(["position:absolute;width:35px;height:35px;color:var(--privy-color-error);"]),de=/*#__PURE__*/l.div.withConfig({displayName:"StyledRedCircle",componentId:"sc-d58f10e6-5"})(["position:absolute;width:60px;height:60px;border-radius:50%;background-color:var(--privy-color-error);opacity:0.1;"]),ce=/*#__PURE__*/l(c).withConfig({displayName:"RetryButton",componentId:"sc-d58f10e6-6"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]),se=/*#__PURE__*/l.span.withConfig({displayName:"TextBoxTitle",componentId:"sc-d58f10e6-7"})(["width:100%;text-align:left;font-size:0.825rem;color:var(--privy-color-foreground);padding:4px;"]),he=/*#__PURE__*/l.div.withConfig({displayName:"TextBoxContainer",componentId:"sc-d58f10e6-8"})(["width:100%;margin:5px;display:flex;flex-direction:column;justify-content:center;align-items:center;"]),me=/*#__PURE__*/l.text.withConfig({displayName:"HelperText",componentId:"sc-d58f10e6-9"})(["position:relative;width:100%;padding:5px;font-size:0.8rem;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;"]),pe=/*#__PURE__*/l.span.withConfig({displayName:"TextBox",componentId:"sc-d58f10e6-10"})(["position:relative;width:100%;background-color:var(--privy-color-background-2);padding:8px 12px;border-radius:10px;margin-top:5px;font-size:14px;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;",""],(e=>e.$clickable&&"cursor: pointer;\n transition: background-color 0.3s;\n padding-right: 45px;\n\n &:hover {\n background-color: var(--privy-color-foreground-4);\n }")),ue=/*#__PURE__*/l(D).withConfig({displayName:"StyledClipboardIcon",componentId:"sc-d58f10e6-11"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),fe=/*#__PURE__*/l(O).withConfig({displayName:"StyledClipboardCheckIcon",componentId:"sc-d58f10e6-12"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),ge=({clicked:n})=>/*#__PURE__*/e(n?fe:ue,{});export{Q as S,re as T,Y as a};