@rio-pay/sdk 0.0.0-stage → 0.0.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,208 @@
1
+ "use client";
2
+ import{useCallback as W,useEffect as I,useId as Nr,useMemo as xt,useReducer as Rr,useRef as P,useState as N}from"react";import{useEffect as Z,useLayoutEffect as Eo,useRef as ae,useState as me}from"react";function ho(e){let t=typeof e==="bigint"?e:BigInt(e),n=t<0n,a=n?-t:t,r=a/1000000n,o=(a%1000000n).toString().padStart(6,"0").replace(/0+$/,"");if(o.length<2)o=o.padEnd(2,"0");let s=r.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",");return`${n?"-":""}${s}.${o}`}function Zt(e){return e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e}function ya(e){return`0x${e.toString(16)}`}function ba(e){return`0x${BigInt(e||"0").toString(16)}`}var yo=[["name","string"],["version","string"],["chainId","uint256"],["verifyingContract","address"],["salt","bytes32"]];function wa(e){let t={...e.domain};if(typeof t.chainId==="string")t.chainId=Number(t.chainId);let n=yo.filter(([a])=>t[a]!==void 0).map(([a,r])=>({name:a,type:r}));return JSON.stringify({domain:t,types:{...e.types,EIP712Domain:e.types.EIP712Domain??n},primaryType:e.primaryType,message:e.message})}function va(e,t,n){let a=e.message;return{from:typeof a.from==="string"?a.from:t,value:String(a.value),validAfter:String(a.validAfter),validBefore:String(a.validBefore),nonce:String(a.nonce),signature:n}}function Ue(e){return!!e&&typeof e==="object"}var bo=(e)=>e==="pending"||e==="provisional"||e==="final";function en(e){return{confirmed:e.confirmed===!0,confirmation:bo(e.confirmation)?e.confirmation:"pending"}}var wo=["created","payment_pending","funded","settled","underpaid","expired"];function xa(e){if(!Ue(e)||!wo.includes(e.status))return null;return{status:e.status,...en(e),funded_amount:typeof e.funded_amount==="string"?e.funded_amount:null}}var vo=["localhost","127.0.0.1","[::1]"];function xo(e){try{let t=new URL(e);if(t.username||t.password)return null;if(t.protocol!=="https:"&&!(t.protocol==="http:"&&vo.includes(t.hostname)))return null;return e.replace(/\/+$/,"")}catch{return null}}var ko=(e)=>typeof e==="string"?/^[1-9]\d{0,18}$/.test(e)?e:null:typeof e==="number"&&Number.isSafeInteger(e)&&e>0?String(e):null;function ka(e){if(!Ue(e))return null;let t=e.chain,n=ko(e.amount);if(typeof e.chargeId!=="string"||typeof e.clientSecret!=="string"||!e.clientSecret||typeof e.serviceUrl!=="string"||typeof e.chargeAddress!=="string"||n===null||!Ue(t)||typeof t.id!=="number")return null;let a=xo(e.serviceUrl);if(!a)return null;return{chargeId:e.chargeId,clientSecret:e.clientSecret,serviceUrl:a,amount:n,chain:{id:t.id,name:typeof t.name==="string"?t.name:"sei",usdc:typeof t.usdc==="string"?t.usdc:"",add_chain:Ue(t.add_chain)?t.add_chain:null},chargeAddress:e.chargeAddress,status:typeof e.status==="string"?e.status:"created",...en(e),expiresAt:typeof e.expiresAt==="string"?e.expiresAt:null}}function Ca(e){if(!Ue(e))return null;let t=typeof e.chargeId==="string"?e.chargeId:typeof e.id==="string"?e.id:null;if(t===null||typeof e.status!=="string")return null;let{confirmed:n,confirmation:a}=en(e),r=e.collectedAmount??e.collected_amount;return{chargeId:t,orderId:typeof e.orderId==="string"?e.orderId:null,status:e.status,confirmed:n,confirmation:a,collectedAmount:typeof r==="string"||typeof r==="number"?String(r):null,...Array.isArray(e.tags)?{tags:e.tags.filter((o)=>typeof o==="string")}:{}}}function Sa(e,t){return t?t(e):null}function Pa(e,t){if(typeof e!=="string"||!e)return null;try{let n=new URL(t),a=new URL(e,n);if(a.protocol!=="https:"&&a.protocol!=="http:")return null;return a.origin===n.origin?a.toString():null}catch{return null}}var je={trigger:"Pay with USDC",title:"Pay",titleFor:"Pay {merchant}",close:"Close",done:"Done",amountDue:"Amount due",payWith:"Pay with",chooseUsdc:"Choose how to pay",connectWallet:"Connect wallet",connectingWallet:"Connecting…",pay:"Pay {amount}",opening:"Opening your wallet…",confirm:"Confirm in your wallet",confirmTx:"Confirm in your wallet ({n} of {total})",confirming:"Confirming payment…",paid:"Paid",preparing:"Preparing your payment",walletName:"Wallet",balanceLabel:"USDC balance",gasLabel:"Gas",lowGas:"Low gas",notEnough:"Not enough",checking:"Checking balances…",noUsdc:"No USDC found in this wallet.",insufficientAll:"There isn't enough USDC in this wallet for this payment.",checkAgain:"Check again",payAnotherWay:"Pay another way",back:"Back",tryAgain:"Try again",startNew:"Start a new payment",details:"Show details",rejected:"No problem, tap Pay when you're ready.",rejectedConnect:"No problem, tap Connect wallet when you're ready.",rejectedPick:"No problem, pick a wallet when you're ready.",noWallet:"We couldn't find a wallet in this browser. Install one like MetaMask, or pay another way.",noWalletMobile:"We couldn't find a wallet in this browser. Open this page in your wallet app, or pay another way.",noWalletForOption:"That option needs a different wallet than the one in this browser. Pick another option, or pay another way.",openInWalletApp:"Open in your wallet app",wrongNetwork:"Your wallet didn't switch. Approve the switch in your wallet and try again.",insufficient:"You have {balance}, you need {needed}.",noGas:"This wallet needs a little gas to send the payment. Add some and try again.",walletBusy:"Your wallet already has a request waiting. Open it to continue.",txFailed:"That payment didn't go through. Please try again.",network:"We can't reach the payment service. Check your connection and try again.",service:"Something went wrong on our side. Please try again in a moment.",unknown:"Something went wrong. Please try again.",expired:"This payment expired. Start a new one to continue.",createFailed:"Checkout is temporarily unavailable. Please try again.",conflict:"This order changed. Start a new payment to continue.",slow:"This is taking a little longer than usual. You can keep this page open.",received:"Payment confirmed",receivedProvisional:"Payment received",finalizing:"We'll finish confirming in the background. You can leave this page.",receiptLabel:"Receipt",returnToStore:"Back to the store",stagesLabel:"Payment progress",stageWallet:"Confirm in wallet",stageSent:"Payment sent",stageConfirmed:"Payment confirmed",manualIntro:"Send USDC on the network shown to the address below. Make sure {amount} arrives: exchanges deduct their fee.",manualWarning:"Choose {network} as the network when you withdraw or send. Only USDC sent on {network} reaches this payment: anything else sent to this address is lost and can't be recovered.",manualConfirm:"I'll send USDC on {network}",manualWaiting:"This page updates by itself when it arrives.",manualOwnWallet:"Exchange can't send on {network}? Withdraw USDC to your own browser wallet, then connect it and pay here.",copyAddress:"Copy address",copied:"Copied",openInWallet:"Open in wallet app",partial:"We've received {received} so far. {remaining} to go.",confirmNamed:"Confirm in {wallet}",confirmTxNamed:"Confirm in {wallet} ({n} of {total})",openingNamed:"Opening {wallet}…",sending:"Sending payment…",notEnoughUsdc:"Not enough USDC",needsGas:"Needs gas",needsGasReason:"Add a little gas to this wallet to continue.",needsOtherWallet:"Needs a different wallet",couldntCheck:"Couldn't check",balanceUpdated:"Balance updated",walletMenu:"Wallet options",copyWalletAddress:"Copy address",switchWallet:"Switch wallet",disconnect:"Disconnect",chooseWallet:"Choose a wallet",lastUsed:"Last used",closeConfirm:"Your payment is still going through. You can close this and it will keep going.",closeAnyway:"Close",stay:"Stay",pauseBalances:"Pause balance updates",openInPhantom:"Open in Phantom",balanceLabelFor:"{symbol} balance",youPay:"You pay {amount}",youPayChecking:"Checking the price…",youPayUpdating:"Updating the price…",youPayTakes:"Usually takes about {minutes} min",optionUnavailable:"Not available right now",optionUnavailableReason:"This way of paying isn't available right now. Pick another, or try again in a moment.",notEnoughToken:"Not enough {symbol}",priceChanged:"The price just updated. Check the amount and tap Pay again."};function B(e,t={}){return e.replace(/\{(\w+)\}/g,(n,a)=>(a in t)?String(t[a]):n)}function Aa(e){if(!e)return je;let t={...je};for(let n of Object.keys(e)){let a=e[n];if(typeof a==="string")t[n]=a}return t}function we(e){let t=typeof e==="bigint"?e:BigInt(e);return`${t<0n?"-":""}$${ho(t<0n?-t:t)}`}function Ra(e){return e.split(/[-_\s]+/).filter(Boolean).map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Ea(e){return`#${e.replace(/^[a-z]+_/i,"").replace(/[^a-z0-9]/gi,"").slice(-8).toUpperCase()}`}var Co=/^0x[0-9a-fA-F]{40}$/;function So(e){return typeof e==="string"&&Co.test(e)}function st(e){try{let t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;return`https://metamask.app.link/dapp/${t.host}${t.pathname}${t.search}`}catch{return null}}function it(e){try{let t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;return`https://phantom.com/ul/browse/${encodeURIComponent(t.toString())}?ref=${encodeURIComponent(t.origin)}`}catch{return null}}function tn(e){return/Android|iPhone|iPad|iPod|Mobile/i.test(e)}function nn(e){if(!So(e))throw Error("Invalid address");return`0x70a08231${e.slice(2).toLowerCase().padStart(64,"0")}`}function ze(e){if(typeof e!=="string"||!/^0x[0-9a-fA-F]*$/.test(e))throw Error("Unexpected balance response");return e==="0x"?0n:BigInt(e)}function Na(e,t){let n=BigInt(e)-BigInt(t||"0");return n>0n?n:0n}class ne extends Error{problem;constructor(e){super(e.message);this.problem=e}}var Po=new Set(["amount_mismatch","charge_expired","error","expired","forbidden","invalid_request","network","not_found","rate_limited","recreate_failed","unauthorized"]),fa=(e,t)=>typeof e==="number"&&Number.isInteger(e)&&Math.abs(e)<t;function La(e){let t=[fa(e.status,1000)&&e.status>=0?`status ${e.status}`:null,typeof e.code==="string"&&Po.has(e.code)?`code ${e.code}`:null,fa(e.code,1e5)?`code ${e.code}`:null].filter((n)=>n!==null);return t.length?t.join(", "):void 0}var Ta=(e)=>e.split(`
3
+ `)[0].slice(0,240);function Ao(e){let t=e&&typeof e==="object"?e:{};return Ta(typeof t.message==="string"?t.message:String(e))}function Ia(e,t=je){let n=La({status:e.status,code:e.code}),a=(r,o)=>({kind:r,message:o,...n?{detail:n}:{},...e.error?{cause:Ta(e.error)}:{}});if(/expired/i.test(e.code??"")||e.status===410)return a("expired",t.expired);if(e.status===409)return a("conflict",t.conflict);if(e.status===0||e.status===408)return a("network",t.network);if(e.status===429||e.status>=500)return a("service",t.createFailed);return a("unknown",t.createFailed)}var Ro=/user (rejected|denied|declined|cancell?ed)|rejected the request|request rejected|declined/i;function He(e,t={}){if(e instanceof ne)return e.problem;let n=t.copy??je,a=e&&typeof e==="object"?e:{},r=La({status:a.status,code:a.code}),o=Ao(e),s=(u,g)=>({kind:u,message:g,...r?{detail:r}:{},cause:o}),i=typeof a.message==="string"?a.message:"";if(typeof a.status==="number"){let u=typeof a.code==="string"?a.code:"";if(/expired/i.test(u)||a.status===410)return s("expired",n.expired);if(a.status===409)return s("conflict",n.conflict);if(a.status===0||a.status===408)return s("network",n.network);if(a.status===429||a.status>=500)return s("service",n.service);return s("unknown",n.unknown)}let l=typeof a.code==="number"?a.code:void 0;if(l===4001||a.code==="ACTION_REJECTED"||Ro.test(i)){if(t.step==="switching")return s("wrong_network",n.wrongNetwork);return s("rejected",n.rejected)}if(l===4902||l===-32603&&t.step==="switching")return s("wrong_network",n.wrongNetwork);if(l===-32002)return s("wallet_busy",n.walletBusy);if(e instanceof TypeError||/failed to fetch|networkerror|load failed/i.test(i))return s("network",n.network);if(t.step==="switching")return s("wrong_network",n.wrongNetwork);if(/insufficient funds/i.test(i))return s("no_gas",n.noGas);if(/reverted|transaction failed|failed on chain/i.test(i))return s("tx_failed",n.txFailed);return s("unknown",n.unknown)}function Oa(e){let t=e&&typeof e==="object"?e:{};if(typeof t.status!=="number")return!1;return t.status===410||typeof t.code==="string"&&/expired/i.test(t.code)||t.status===422&&/expired|valid_before|validbefore/i.test(String(t.message??""))}function ct(e){let t=e&&typeof e==="object"?e:{};return t.status===409&&(t.code==="payment_in_flight"||t.code==="authorization_in_flight")}var ma=["idle","connecting","switching","checking","signing","submitting","processing","paid"],an={step:"idle",problem:null};function ha(e){return e!=="idle"&&e!=="paid"&&e!=="processing"}function Ma(e,t){switch(t.type){case"start":return e.step==="idle"?{step:"connecting",problem:null}:e;case"step":return ha(e.step)&&ma.indexOf(t.step)>ma.indexOf(e.step)?{step:t.step,problem:null}:e;case"submitted":return ha(e.step)?{step:"processing",problem:null}:e;case"failed":return e.step==="paid"?e:{step:"idle",problem:t.problem};case"paid":return{step:"paid",problem:null};case"reset":return e.step==="paid"?e:an}}function _a(e){let t=e==="connecting"||e==="switching"||e==="checking"||e==="signing"?0:e==="submitting"?1:e==="processing"?2:e==="paid"?3:-1;return["wallet","sent","confirmed"].map((a,r)=>({key:a,state:r<t?"done":r===t?"active":"pending"}))}function Wa(e,t,n=je,a){switch(e){case"connecting":case"switching":case"checking":return a?B(n.openingNamed,{wallet:a}):n.opening;case"signing":return a?B(n.confirmNamed,{wallet:a}):n.confirm;case"submitting":return n.sending;case"processing":return n.confirming;case"paid":return n.paid;default:return B(n.pay,{amount:t})}}function lt(e,t,n){return B(n?e.confirmTxNamed:e.confirmTx,{n:t.i+1,total:t.total,...n?{wallet:n}:{}})}function Ba(e,t){let n=typeof t==="string"?t.trim().slice(0,60):"";return n?B(e.titleFor,{merchant:n}):e.title}var Da="payments:prefs";function Ua(){try{return typeof window>"u"?null:window.localStorage}catch{return null}}function fe(e=Ua()){try{let t=e?.getItem(Da),n=t?JSON.parse(t):null;if(!n||typeof n!=="object")return{};let{wallet:a}=n;return typeof a==="string"&&a.length<=40?{wallet:a}:{}}catch{return{}}}function rn(e,t=Ua()){try{if(!t)return;t.setItem(Da,JSON.stringify({...fe(t),...e}))}catch{}}var ja=Object.freeze({name:"Rio",poweredBy:"Powered by Rio"}),za="M 13 70 L 13 12 L 40 12 C 59 12 68 22 68 35 C 68 48 58 55 41 55 L 13 55 M 41 55 L 67 70";var Ha=`.sc-root{--scd-bg:#fff;--scd-surface:#f3f5f8;--scd-fg:#0b1220;--scd-muted:#5a6376;--scd-border:#dfe3e9;--scd-line:#8a92a0;--scd-accent:#315cff;--scd-on-accent:#fff;--scd-success:#15803d;--scd-danger:#b42318;--scd-warn:#a15c07;--scd-shadow:0 24px 64px rgba(15,23,42,.22),0 2px 8px rgba(15,23,42,.08);--scd-scrim:rgba(15,23,42,.42)}
4
+ .sc-root[data-appearance="dark"]{--scd-bg:#0b1220;--scd-surface:#141d31;--scd-fg:#f3f5f8;--scd-muted:#a9b3c7;--scd-border:#26314a;--scd-line:#6f7b94;--scd-accent:#7c97ff;--scd-on-accent:#0b1220;--scd-success:#4ade80;--scd-danger:#ff8f84;--scd-warn:#fbbf24;--scd-shadow:0 24px 64px rgba(0,0,0,.6),0 2px 8px rgba(0,0,0,.4);--scd-scrim:rgba(0,0,0,.62)}
5
+ @media (prefers-color-scheme:dark){.sc-root[data-appearance="auto"]{--scd-bg:#0b1220;--scd-surface:#141d31;--scd-fg:#f3f5f8;--scd-muted:#a9b3c7;--scd-border:#26314a;--scd-line:#6f7b94;--scd-accent:#7c97ff;--scd-on-accent:#0b1220;--scd-success:#4ade80;--scd-danger:#ff8f84;--scd-warn:#fbbf24;--scd-shadow:0 24px 64px rgba(0,0,0,.6),0 2px 8px rgba(0,0,0,.4);--scd-scrim:rgba(0,0,0,.62)}}`;import{jsx as c,jsxs as b,Fragment as gt}from"react/jsx-runtime";var on=`
6
+ ${Ha}
7
+ .sc-root{--c-bg:var(--sc-bg,var(--scd-bg));--c-fg:var(--sc-fg,var(--scd-fg));--c-muted:var(--sc-muted,var(--scd-muted));--c-border:var(--sc-border,var(--scd-border));--c-accent:var(--sc-accent,var(--scd-accent));--c-success:var(--sc-success,var(--scd-success));--c-danger:var(--sc-danger,var(--scd-danger));--c-radius:var(--sc-radius,12px);--c-surface:var(--sc-surface,var(--scd-surface));--c-on-accent:var(--sc-on-accent,var(--scd-on-accent));--c-line:var(--sc-line,var(--scd-line));--c-warn:var(--sc-warn,var(--scd-warn));--c-ease:cubic-bezier(.22,1,.36,1);--c-spring:cubic-bezier(.34,1.4,.64,1)}
8
+ .sc-root{box-sizing:border-box;display:block;width:100%;min-width:0;color:var(--c-fg);font-family:inherit;font-size:15px;line-height:1.5;text-align:left;-webkit-text-size-adjust:100%}
9
+ .sc-root *,.sc-root *::before,.sc-root *::after{box-sizing:border-box}
10
+ .sc-root :where(button,summary,a){font:inherit;color:inherit}
11
+ .sc-root :focus-visible{outline:2px solid var(--c-accent);outline-offset:2px;border-radius:6px}
12
+ .sc-root [tabindex="-1"]:focus{outline:none}
13
+ .sc-live{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
14
+ .sc-btn{display:flex;align-items:center;justify-content:center;gap:8px;width:100%;min-height:56px;padding:8px 16px;border:0;border-radius:var(--c-radius);background:var(--c-accent);color:var(--c-on-accent);font-size:17px;font-weight:600;line-height:24px;cursor:pointer;text-decoration:none;transition:filter .12s ease,transform .1s ease,background-color .2s ease,color .2s ease}
15
+ .sc-btn:hover{filter:brightness(1.06)}
16
+ .sc-btn:active{transform:scale(.985)}
17
+ .sc-btn[aria-disabled="true"]:not([aria-busy="true"]){cursor:default;filter:none;transform:none;background:color-mix(in srgb,var(--c-fg) 8%,var(--c-bg));color:var(--c-muted)}
18
+ .sc-btn[aria-busy="true"]{cursor:progress;filter:none;transform:none}
19
+ .sc-btn:focus-visible{outline-color:var(--c-fg)}
20
+ .sc-link{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:44px;padding:0 8px;border:0;background:none;color:var(--c-accent);font-weight:600;cursor:pointer;text-decoration:underline;text-underline-offset:3px}
21
+ .sc-link-quiet{color:var(--c-muted);font-weight:500;font-size:14px}
22
+ .sc-link-quiet:hover{color:var(--c-fg)}
23
+ .sc-actions{display:flex;flex-wrap:wrap;gap:0 8px;margin:8px -8px -8px}
24
+ .sc-sec{display:flex;align-items:center;justify-content:center;gap:8px;width:100%;min-height:48px;padding:8px 16px;border:1px solid var(--c-line);border-radius:var(--c-radius);background:transparent;font-weight:600;cursor:pointer;text-decoration:none;text-align:center;transition:background-color .12s ease,transform .1s ease}
25
+ .sc-sec:hover{background:var(--c-surface)}
26
+ .sc-sec:active{transform:scale(.985)}
27
+ .sc-spin{flex:none;width:20px;height:20px;animation:sc-rot .8s linear infinite}
28
+ .sc-spin-s{width:14px;height:14px}
29
+ .sc-sk{display:block;border-radius:10px;background:linear-gradient(90deg,color-mix(in srgb,var(--c-fg) 7%,var(--c-bg)) 25%,color-mix(in srgb,var(--c-fg) 14%,var(--c-bg)) 37%,color-mix(in srgb,var(--c-fg) 7%,var(--c-bg)) 63%);background-size:400% 100%;animation:sc-shimmer 1.4s ease infinite}
30
+
31
+ .sc-dialog{box-sizing:border-box;width:min(420px,calc(100vw - 32px));max-width:none;max-height:calc(100dvh - clamp(16px,9vh,80px) - 16px);margin:clamp(16px,9vh,80px) auto auto;padding:0;border:1px solid var(--c-border);border-radius:calc(var(--c-radius) + 8px);background:var(--c-bg);color:var(--c-fg);box-shadow:var(--scd-shadow);overflow:visible;font:inherit;text-align:left}
32
+ .sc-dialog:not([open]){display:none}
33
+ .sc-dialog::backdrop{background:var(--scd-scrim);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}
34
+ .sc-dialog[open]{animation:sc-pop .22s var(--c-ease)}
35
+ .sc-dialog[open]::backdrop{animation:sc-fade .2s ease}
36
+ .sc-dialog[data-closing]{animation:sc-out .14s ease-in forwards}
37
+ .sc-dialog[data-closing]::backdrop{animation:sc-fade-out .14s ease-in forwards}
38
+ .sc-card{box-sizing:border-box;width:100%;padding:20px 20px 16px;background:var(--c-bg);color:var(--c-fg);border:1px solid var(--c-border);border-radius:calc(var(--c-radius) + 8px)}
39
+ .sc-dialog .sc-card{border:0;border-radius:inherit;max-height:calc(100dvh - clamp(16px,9vh,80px) - 18px);overflow:auto;overscroll-behavior:contain}
40
+ .sc-hgt{margin:-4px;padding:4px}
41
+ .sc-hgt[data-ready="true"]{transition:height .22s var(--c-ease)}
42
+ .sc-hgt[data-anim="true"]{overflow:hidden}
43
+ .sc-fade{animation:sc-rise .18s var(--c-ease) both}
44
+ .sc-head{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:44px;margin:-6px -8px 8px 0}
45
+ .sc-title{margin:0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:17px;line-height:24px;font-weight:650;letter-spacing:-.005em}
46
+ .sc-title:focus{outline:none}
47
+ .sc-head-end{display:flex;align-items:center;gap:4px;min-width:0}
48
+ .sc-head-end:first-child{flex:1}
49
+ .sc-x{display:inline-flex;align-items:center;justify-content:center;flex:none;width:44px;height:44px;border:0;border-radius:50%;background:none;color:var(--c-muted);cursor:pointer;transition:background-color .12s ease,color .12s ease,transform .1s ease}
50
+ .sc-x:hover{background:var(--c-surface);color:var(--c-fg)}
51
+ .sc-x:active{transform:scale(.94)}
52
+ .sc-wrow{position:relative;display:flex;align-items:center;margin:0 0 12px}
53
+ .sc-wallet{position:relative;display:inline-flex;align-items:center;gap:8px;min-width:0;max-width:100%;min-height:36px;padding:0 10px 0 12px;border-radius:999px;background:var(--c-surface);border:1px solid var(--c-border);font-size:13px;line-height:20px;color:var(--c-fg);cursor:pointer;transition:border-color .12s ease,background-color .12s ease}
54
+ .sc-wallet::after{content:"";position:absolute;inset:-4px -2px}
55
+ .sc-wallet:hover{border-color:var(--c-line)}
56
+ .sc-wallet:active{background:color-mix(in srgb,var(--c-fg) 6%,var(--c-surface))}
57
+ .sc-wallet[aria-expanded="true"]{border-color:var(--c-accent)}
58
+ .sc-wallet[data-static="true"]{cursor:default;padding-right:12px}
59
+ .sc-wallet[data-static="true"]:hover{border-color:var(--c-border)}
60
+ .sc-wallet-dot{flex:none;width:8px;height:8px;border-radius:50%;background:var(--c-success)}
61
+ .sc-wallet-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600}
62
+ .sc-wallet-addr{flex:none;color:var(--c-muted);font-variant-numeric:tabular-nums}
63
+ .sc-pop{position:absolute;left:0;top:calc(100% + 6px);z-index:5;display:flex;flex-direction:column;gap:2px;min-width:232px;max-width:100%;padding:6px;border-radius:calc(var(--c-radius) + 4px);background:var(--c-bg);border:1px solid var(--c-border);box-shadow:var(--scd-shadow);animation:sc-rise .14s var(--c-ease) both}
64
+ .sc-mi{display:flex;align-items:center;gap:10px;width:100%;min-height:44px;padding:6px 10px;border:0;border-radius:var(--c-radius);background:none;text-align:left;cursor:pointer;font-size:15px;transition:background-color .08s ease}
65
+ .sc-mi:hover,.sc-mi:focus-visible{background:var(--c-surface)}
66
+ .sc-mi:active{background:color-mix(in srgb,var(--c-fg) 8%,var(--c-surface))}
67
+ .sc-mi svg{flex:none;color:var(--c-muted)}
68
+ .sc-mi-sub{margin-left:auto;font-size:12px;color:var(--c-muted);font-variant-numeric:tabular-nums}
69
+ .sc-deco-row{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:28px;margin:0 2px 6px;font-size:13px;line-height:20px;color:var(--c-muted)}
70
+ .sc-deco-label{font-weight:500}
71
+ .sc-deco-end{display:flex;align-items:center;gap:8px;min-width:0}
72
+ .sc-deco{position:relative;display:flex;align-items:center;gap:6px;min-width:0;font-variant-numeric:tabular-nums}
73
+ .sc-deco-cycle{display:grid;min-height:20px;justify-items:end;align-items:center}
74
+ .sc-deco-item{grid-area:1/1;display:inline-flex;align-items:baseline;gap:6px;opacity:0;transition:opacity .35s ease;white-space:nowrap}
75
+ .sc-deco-item[data-active="true"]{opacity:1}
76
+ .sc-deco-k{color:var(--c-muted)}
77
+ .sc-deco-v{color:var(--c-fg);font-weight:600}
78
+ .sc-deco-item[data-warn="true"] .sc-deco-v{color:var(--c-warn)}
79
+ .sc-deco-flag{padding:1px 7px;border-radius:999px;border:1px solid var(--c-warn);color:var(--c-warn);font-size:12px;font-weight:600;line-height:16px}
80
+ .sc-pause{position:relative;display:inline-flex;align-items:center;justify-content:center;flex:none;width:24px;height:24px;padding:0;border:0;border-radius:50%;background:none;color:var(--c-muted);cursor:pointer}
81
+ .sc-pause::after{content:"";position:absolute;inset:-10px}
82
+ .sc-pause:hover{background:var(--c-surface);color:var(--c-fg)}
83
+ .sc-box{position:relative;display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:96px;padding:16px;border-radius:calc(var(--c-radius) + 4px);background:var(--c-surface);border:1px solid var(--c-border)}
84
+ .sc-pick{display:flex;min-width:0}
85
+ .sc-tok-btn{display:inline-flex;align-items:center;gap:10px;min-height:48px;max-width:100%;padding:6px 12px 6px 8px;border:1px solid var(--c-border);border-radius:999px;background:var(--c-bg);cursor:pointer;transition:border-color .12s ease,box-shadow .15s ease,transform .1s ease}
86
+ .sc-tok-btn:hover:not([aria-disabled="true"]){border-color:var(--c-line)}
87
+ .sc-tok-btn:active:not([aria-disabled="true"]){transform:scale(.985)}
88
+ .sc-tok-btn[aria-expanded="true"]{border-color:var(--c-accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--c-accent) 18%,transparent)}
89
+ .sc-tok-btn[aria-disabled="true"]{cursor:default}
90
+ .sc-tok-btn[data-single="true"],.sc-tok-btn[aria-disabled="true"]{padding-right:14px}
91
+ .sc-tok{display:inline-flex;align-items:baseline;min-width:0;font-size:16px;font-weight:650;letter-spacing:-.005em;white-space:nowrap}
92
+ .sc-tok sub{margin-left:5px;font-size:12px;font-weight:500;line-height:1;vertical-align:baseline;position:relative;top:.28em;color:var(--c-muted);overflow:hidden;text-overflow:ellipsis;max-width:120px}
93
+ .sc-chev{flex:none;color:var(--c-muted);transition:transform .18s var(--c-ease)}
94
+ .sc-tok-btn[aria-expanded="true"] .sc-chev{transform:rotate(180deg)}
95
+ .sc-logo{flex:none;display:block}
96
+ .sc-mark{position:relative;flex:none;display:inline-block}
97
+ .sc-badge{position:absolute;right:-5px;bottom:-4px;display:flex;align-items:center;justify-content:center;width:15px;height:15px;border-radius:50%;box-shadow:0 0 0 2px var(--c-bg);background:hsl(var(--bh,215) 58% 34%);color:#fff;font-size:9px;font-weight:700;line-height:1;letter-spacing:0}
98
+ .sc-badge-icon{overflow:hidden;background:#fff;padding:0}.sc-badge-icon[data-icon="base"]{border-radius:3px}.sc-badge-icon svg{display:block}.sc-badge[data-hue="0"]{--bh:268}.sc-badge[data-hue="1"]{--bh:338}.sc-badge[data-hue="2"]{--bh:8}.sc-badge[data-hue="3"]{--bh:162}.sc-badge[data-hue="4"]{--bh:96}.sc-badge[data-hue="5"]{--bh:196}
99
+ .sc-amt{margin:0;min-width:0;font-size:32px;line-height:40px;font-weight:700;letter-spacing:-.02em;font-variant-numeric:tabular-nums;text-align:right;overflow-wrap:anywhere}
100
+ .sc-payline{display:flex;flex-wrap:wrap;align-items:center;gap:2px 10px;margin:10px 4px 0;font-size:14px;line-height:20px;color:var(--c-muted);animation:sc-rise .18s var(--c-ease) both}
101
+ .sc-payline-main{color:var(--c-fg);font-weight:600;font-variant-numeric:tabular-nums}
102
+ .sc-payline[data-kind="unavailable"]{color:var(--c-warn)}
103
+ .sc-payline .sc-link{min-height:44px}
104
+ .sc-glyph{flex:none;display:block}
105
+ .sc-menu{margin-top:6px;display:flex;flex-direction:column;gap:2px;padding:6px;border-radius:calc(var(--c-radius) + 4px);background:var(--c-bg);border:1px solid var(--c-border);animation:sc-rise .18s var(--c-ease) both}
106
+ .sc-opt{display:flex;align-items:center;gap:12px;width:100%;min-height:56px;padding:8px 10px;border:0;border-radius:var(--c-radius);background:none;text-align:left;cursor:pointer;animation:sc-rise .2s var(--c-ease) both;animation-delay:calc(var(--i,0) * 20ms);transition:background-color .08s ease}
107
+ .sc-opt:hover:not([aria-disabled="true"]),.sc-opt:focus-visible{background:var(--c-surface)}
108
+ .sc-opt:active:not([aria-disabled="true"]){background:color-mix(in srgb,var(--c-fg) 8%,var(--c-surface))}
109
+ .sc-opt[aria-disabled="true"]{cursor:not-allowed}
110
+ .sc-opt[aria-disabled="true"] .sc-logo{opacity:.45}
111
+ .sc-opt[aria-selected="true"]{background:color-mix(in srgb,var(--c-accent) 10%,transparent)}
112
+ .sc-opt-main{display:flex;flex:1;align-items:center;gap:12px;min-width:0}
113
+ .sc-opt-bal{display:flex;flex-direction:column;align-items:flex-end;margin-left:auto;font-size:15px;font-weight:600;font-variant-numeric:tabular-nums;line-height:20px;text-align:right}
114
+ .sc-opt-bal[data-muted="true"]>span:first-child{color:var(--c-muted)}
115
+ .sc-opt-sub{font-size:12px;line-height:16px;font-weight:500;color:var(--c-muted)}
116
+ .sc-opt-check{flex:none;width:16px;color:var(--c-accent)}
117
+ .sc-msg{margin:12px 0 0;padding:12px 14px;border-radius:var(--c-radius);background:var(--c-surface);font-size:14px;color:var(--c-muted);animation:sc-rise .18s var(--c-ease) both}
118
+ .sc-msg .sc-actions{margin-top:4px}
119
+ .sc-msg .sc-sec{margin-top:10px;min-height:44px;color:var(--c-fg)}
120
+ .sc-msg-strong{color:var(--c-fg)}
121
+ .sc-pair{display:flex;gap:8px;margin-top:10px}
122
+ .sc-pair .sc-sec{margin-top:0;min-height:44px}
123
+ .sc-cta{margin-top:16px}
124
+ .sc-powered{display:flex;align-items:center;justify-content:center;gap:6px;margin:14px 0 0;color:var(--c-muted);font-size:12px;line-height:1}
125
+ .sc-powered svg{width:14px;height:14px;flex:none;color:var(--c-accent)}
126
+ .sc-foot{display:flex;justify-content:center;margin:4px 0 -4px}
127
+ .sc-notice{margin:12px 0 0;padding:14px 16px;border-radius:var(--c-radius);background:var(--c-surface);border-left:4px solid var(--c-danger);font-size:14px;animation:sc-rise .18s var(--c-ease) both}
128
+ .sc-notice[data-kind="rejected"]{border-left-color:var(--c-line)}
129
+ .sc-notice[data-kind="manual"],.sc-notice[data-kind="wallet_busy"],.sc-notice[data-kind="wrong_network"],.sc-notice[data-kind="no_wallet"],.sc-notice[data-kind="insufficient"],.sc-notice[data-kind="no_gas"]{border-left-color:var(--c-warn)}
130
+ .sc-notice-head{display:flex;gap:8px;align-items:flex-start}
131
+ .sc-notice-head svg{flex:none;margin-top:2px}
132
+ .sc-notice-head p{margin:0}
133
+ .sc-tech{margin-top:8px;font-size:12px;color:var(--c-muted)}
134
+ .sc-tech summary{display:inline-flex;align-items:center;min-height:44px;cursor:pointer}
135
+ .sc-tech code{display:block;margin-top:4px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;overflow-wrap:anywhere;white-space:pre-wrap}
136
+ .sc-steps{list-style:none;margin:12px 0 0;padding:0}
137
+ .sc-steps li{position:relative;display:flex;align-items:center;gap:14px;min-height:44px;color:var(--c-muted);font-size:15px;transition:color .2s ease}
138
+ .sc-steps li:not(:last-child)::after{content:"";position:absolute;left:11px;top:34px;width:2px;height:20px;border-radius:1px;background:linear-gradient(var(--c-success),var(--c-success)) top/100% 0% no-repeat,var(--c-border);transition:background-size .24s var(--c-ease)}
139
+ .sc-steps li[data-state="done"]:not(:last-child)::after{background-size:100% 100%,100% 100%}
140
+ .sc-steps li[data-state="active"]{color:var(--c-fg);font-size:16px;font-weight:600}
141
+ .sc-steps li[data-state="done"]{color:var(--c-fg)}
142
+ .sc-dot{display:inline-flex;align-items:center;justify-content:center;flex:none;width:24px;height:24px;border-radius:50%;border:2px solid var(--c-line);transition:background-color .2s ease,border-color .2s ease}
143
+ .sc-steps li[data-state="done"] .sc-dot{background:var(--c-success);border-color:var(--c-success);color:var(--c-bg)}
144
+ .sc-steps li[data-state="done"] .sc-dot svg{animation:sc-tick .22s var(--c-spring) both}
145
+ .sc-steps li[data-state="active"] .sc-dot{border-color:var(--c-accent)}
146
+ .sc-steps li[data-state="active"] .sc-dot::after{content:"";width:8px;height:8px;border-radius:50%;background:var(--c-accent);animation:sc-pulse 1.4s ease-in-out infinite}
147
+ .sc-hair{position:relative;height:2px;margin:10px 0 0;border-radius:1px;background:var(--c-border);overflow:hidden}
148
+ .sc-hair>i{position:absolute;inset:0;background:var(--c-accent);transform-origin:left center;transform:scaleX(0);animation:sc-hair 60s cubic-bezier(.2,.6,.2,1) forwards}
149
+ .sc-expect{margin:10px 0 0;font-size:13px;line-height:20px;color:var(--c-muted);animation:sc-rise .18s var(--c-ease) both}
150
+ .sc-ok{display:flex;flex-direction:column;align-items:center;text-align:center;padding:12px 0 4px}
151
+ .sc-ok:focus{outline:none}
152
+ .sc-check{width:64px;height:64px;margin-bottom:16px;animation:sc-pop-in .3s var(--c-spring) both}
153
+ .sc-check circle{fill:none;stroke:var(--c-success);stroke-width:3;stroke-dasharray:176;stroke-dashoffset:176;animation:sc-draw .45s ease-out forwards}
154
+ .sc-check path{fill:none;stroke:var(--c-success);stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:36;stroke-dashoffset:36;animation:sc-draw .28s .3s ease-out forwards}
155
+ .sc-ok h3{margin:0;font-size:20px;line-height:28px;font-weight:700;animation:sc-rise .2s var(--c-ease) both}
156
+ .sc-ok-amt{margin:0;font-size:32px;line-height:40px;font-weight:700;font-variant-numeric:tabular-nums}
157
+ .sc-receipt{margin:8px 0 0;font-size:13px;color:var(--c-muted)}
158
+ .sc-receipt code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
159
+ .sc-fin{margin:12px 0 0;font-size:13.5px;color:var(--c-muted);max-width:30ch}
160
+ .sc-slot{width:100%;margin-top:16px;text-align:center}
161
+ .sc-ok .sc-btn{margin-top:20px}
162
+ .sc-inline-ok{display:flex;align-items:center;justify-content:center;gap:8px;min-height:48px;margin:0;font-weight:600;color:var(--c-success)}
163
+ .sc-link-a{display:flex;align-items:center;justify-content:center;min-height:44px;margin-top:8px;color:var(--c-accent);font-weight:600}
164
+ .sc-wl{display:flex;flex-direction:column;gap:2px;margin:0;padding:0;list-style:none}
165
+ .sc-wl-row{display:flex;align-items:center;gap:12px;width:100%;min-height:56px;padding:8px 10px;border:0;border-radius:var(--c-radius);background:none;text-align:left;cursor:pointer;font-size:16px;font-weight:600;transition:background-color .08s ease}
166
+ .sc-wl-row:hover:not([aria-disabled="true"]),.sc-wl-row:focus-visible{background:var(--c-surface)}
167
+ .sc-wl-row:active:not([aria-disabled="true"]){background:color-mix(in srgb,var(--c-fg) 8%,var(--c-surface))}
168
+ .sc-wl-row[aria-disabled="true"]{cursor:default}
169
+ .sc-wl-icon{flex:none;width:32px;height:32px;border-radius:8px;object-fit:cover;background:var(--c-surface)}
170
+ .sc-wl-mono{flex:none;display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:8px;background:var(--c-surface);border:1px solid var(--c-border);color:var(--c-muted);font-size:14px;font-weight:700}
171
+ .sc-wl-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
172
+ .sc-wl-tag{flex:none;padding:1px 8px;border-radius:999px;background:var(--c-surface);border:1px solid var(--c-border);font-size:12px;font-weight:500;color:var(--c-muted)}
173
+ .sc-wl-sub{font-size:13px;font-weight:500;color:var(--c-muted);display:flex;align-items:center;gap:6px}
174
+ .sc-addr{display:block;margin:12px 0 8px;padding:14px 16px;border-radius:var(--c-radius);background:var(--c-surface);border:1px solid var(--c-border);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:14px;line-height:22px;overflow-wrap:anywhere;user-select:all}
175
+ .sc-confirm{display:flex;align-items:center;gap:10px;min-height:44px;margin-top:8px;font-size:15px;cursor:pointer}
176
+ .sc-confirm input{flex:none;width:20px;height:20px;margin:0;accent-color:var(--c-accent);cursor:pointer}
177
+ .sc-two{display:grid;grid-template-columns:1fr;gap:8px;margin-top:8px}
178
+ .sc-muted{margin:12px 0 0;color:var(--c-muted);font-size:14px}
179
+ .sc-chip{display:inline-flex;align-items:center;gap:10px;min-height:44px;padding:6px 14px 6px 8px;border:1px solid var(--c-border);border-radius:999px;background:var(--c-surface)}
180
+ .sc-back{display:inline-flex;align-items:center;gap:4px;min-height:44px;margin:0 0 0 -8px;padding:0 8px;border:0;background:none;color:var(--c-muted);cursor:pointer;transition:color .12s ease}
181
+ .sc-back:hover{color:var(--c-fg)}
182
+ @keyframes sc-draw{to{stroke-dashoffset:0}}
183
+ @keyframes sc-shimmer{0%{background-position:100% 50%}100%{background-position:0 50%}}
184
+ @keyframes sc-rot{to{transform:rotate(360deg)}}
185
+ @keyframes sc-pulse{0%,100%{opacity:1}50%{opacity:.35}}
186
+ @keyframes sc-pop{from{opacity:0;transform:translateY(8px) scale(.985)}to{opacity:1;transform:none}}
187
+ @keyframes sc-out{to{opacity:0;transform:scale(.985)}}
188
+ @keyframes sc-fade{from{opacity:0}to{opacity:1}}
189
+ @keyframes sc-fade-out{to{opacity:0}}
190
+ @keyframes sc-rise{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
191
+ @keyframes sc-tick{from{opacity:0;transform:scale(.6)}to{opacity:1;transform:none}}
192
+ @keyframes sc-pop-in{from{opacity:0;transform:scale(.85)}to{opacity:1;transform:none}}
193
+ @keyframes sc-hair{to{transform:scaleX(.9)}}
194
+ html:has(.sc-dialog[open]){overflow:hidden}
195
+ @media (max-width:520px){
196
+ .sc-dialog{width:100%;max-width:100%;margin:auto 0 0;border-radius:20px 20px 0 0;border-bottom:0;max-height:calc(100dvh - 12px)}
197
+ .sc-dialog[open]{animation:sc-sheet .3s cubic-bezier(.2,.9,.2,1)}
198
+ .sc-dialog[data-closing]{animation:sc-sheet-out .2s ease-in forwards}
199
+ .sc-dialog .sc-card{border-radius:20px 20px 0 0;max-height:calc(100dvh - 14px);padding-bottom:max(16px,env(safe-area-inset-bottom))}
200
+ .sc-amt{font-size:28px;line-height:36px}
201
+ .sc-pop{min-width:0;width:100%}
202
+ }
203
+ @keyframes sc-sheet{from{transform:translateY(100%)}to{transform:none}}
204
+ @keyframes sc-sheet-out{to{transform:translateY(100%)}}
205
+ @media (max-width:360px){.sc-card{padding:16px 16px 12px}.sc-tok sub{max-width:84px}}
206
+ @media (prefers-reduced-motion:reduce){.sc-root *,.sc-root *::before,.sc-root *::after,.sc-dialog,.sc-dialog::backdrop{animation-duration:.001ms!important;animation-delay:0s!important;animation-iteration-count:1!important;transition:none!important}.sc-spin{animation:none!important}.sc-sk{animation:none!important}.sc-check circle,.sc-check path{stroke-dashoffset:0!important}.sc-steps li[data-state="active"] .sc-dot::after{animation:none!important}.sc-hair>i{animation:none!important;transform:scaleX(.5)!important}.sc-deco-cycle{display:flex;gap:14px;justify-content:flex-end}.sc-deco-item{grid-area:auto;opacity:1}.sc-pause{display:none}}
207
+ `,ee=({children:e,size:t=20,className:n})=>c("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",className:n,children:e}),ut=({small:e})=>c(ee,{className:e?"sc-spin sc-spin-s":"sc-spin",children:c("path",{d:"M21 12a9 9 0 1 1-6.2-8.55"})}),$a=()=>c(ee,{size:16,className:"sc-chev",children:c("path",{d:"m6 9 6 6 6-6"})}),No=()=>c(ee,{size:16,children:c("path",{d:"m15 18-6-6 6-6"})}),$e=({size:e=16})=>c(ee,{size:e,children:c("path",{d:"M5 12.5l4.5 4.5L19 7.5"})}),sn=()=>b(ee,{size:16,children:[c("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),c("path",{d:"M5 15V6a2 2 0 0 1 2-2h9"})]}),Lo=()=>b(ee,{size:16,children:[c("path",{d:"M7 7h12l-3-3"}),c("path",{d:"M17 17H5l3 3"})]}),To=()=>b(ee,{size:16,children:[c("path",{d:"M12 3v8"}),c("path",{d:"M6.3 7.3a8 8 0 1 0 11.4 0"})]}),Io=()=>c(ee,{size:14,children:c("path",{d:"M8 5v14M16 5v14"})}),Oo=()=>c(ee,{size:14,children:c("path",{d:"M7 4.5v15l12-7.5z"})}),Mo=()=>b(ee,{children:[c("circle",{cx:"12",cy:"12",r:"9"}),c("path",{d:"M12 8v5"}),c("path",{d:"M12 16.5h.01"})]}),_o=()=>b(ee,{children:[c("circle",{cx:"12",cy:"12",r:"9"}),c("path",{d:"M12 11v5"}),c("path",{d:"M12 7.5h.01"})]});function Wo({size:e=28}){return b("svg",{className:"sc-logo",width:e,height:e,viewBox:"0 0 32 32","aria-hidden":"true",focusable:"false",children:[c("circle",{cx:"16",cy:"16",r:"16",fill:"#2775CA"}),c("path",{d:"M20.4 18.2c0-2.3-1.4-3.1-4.2-3.4-2-.3-2.4-.8-2.4-1.7 0-.9.7-1.4 2-1.4 1.2 0 1.9.4 2.2 1.4.1.2.3.3.5.3h1.1c.3 0 .5-.2.5-.5v-.1c-.3-1.4-1.4-2.4-2.9-2.6V8.3c0-.3-.2-.5-.5-.5h-1c-.3 0-.5.2-.5.5v1.4c-2 .3-3.2 1.6-3.2 3.2 0 2.2 1.3 3 4.1 3.3 1.9.4 2.5.8 2.5 1.8s-.9 1.6-2.2 1.6c-1.7 0-2.3-.7-2.5-1.7-.1-.3-.3-.4-.5-.4h-1.2c-.3 0-.5.2-.5.5v.1c.3 1.6 1.3 2.5 3.4 2.8v1.5c0 .3.2.5.5.5h1c.3 0 .5-.2.5-.5v-1.5c2-.3 3.3-1.7 3.3-3.4z",fill:"#fff"}),c("path",{d:"M12.6 25.2C7.7 23.4 5.2 18 7 13.2c.9-2.5 2.9-4.4 5.4-5.3.3-.1.4-.3.4-.6v-1c0-.3-.2-.5-.5-.5-.1 0-.1 0-.2.1C6 7.8 3 14.4 5.2 20.5c1.3 3.6 4.1 6.4 7.7 7.7.3.1.6 0 .6-.3.1-.1.1-.2.1-.2v-1c0-.2-.3-.4-.5-.6-.2-.1-.3-.1-.5-.1zM19.4 4.3c-.3-.1-.6 0-.6.3-.1.1-.1.2-.1.2v1c0 .3.3.5.5.6 4.9 1.8 7.4 7.2 5.6 12-.9 2.5-2.9 4.4-5.4 5.3-.3.1-.4.3-.4.6v1c0 .3.2.5.5.5.1 0 .1 0 .2-.1 6-1.9 9-8.5 6.8-14.6-1.3-3.7-4.2-6.5-7.1-7.8z",fill:"#fff"})]})}var Bo=["M11.9969 23.9965H11.9965L11.9967 23.9965L11.9969 23.9965Z","M16.085 19.5256C16.8061 18.8689 17.9092 18.869 18.6303 19.5258L18.6305 19.5259L20.091 20.8558C17.957 22.8065 15.1158 23.9965 11.9967 23.9965C8.88824 23.9964 6.05591 22.8147 3.92448 20.876L5.4072 19.5259L5.40734 19.5258C6.12844 18.869 7.23147 18.8689 7.95265 19.5256L9.25088 20.7087L9.25109 20.7089C10.8195 22.1374 13.2182 22.1374 14.7866 20.7089L14.7868 20.7087L16.085 19.5256L16.085 19.5256Z","M11.9965 0C15.1214 0 17.9672 1.19421 20.1025 3.15105C20.0412 3.20075 19.981 3.25245 19.922 3.30619L19.9218 3.30636L18.6236 4.48944C17.9025 5.14605 16.7996 5.14605 16.0785 4.48944L14.7803 3.30636L14.78 3.30619L14.7431 3.27296C13.1742 1.87772 10.8007 1.88883 9.24454 3.30622L5.92566 6.32832L7.42038 7.96939L10.7394 4.94715L10.7395 4.94704C11.4607 4.29025 12.5637 4.29016 13.2849 4.94683L14.5831 6.12991L14.5833 6.13012C16.1517 7.55866 18.5504 7.55866 20.1188 6.13012L20.119 6.12994L21.4172 4.94687L21.4172 4.94683C21.4753 4.89391 21.5359 4.8453 21.5986 4.80091C23.1043 6.80592 23.9965 9.2979 23.9965 11.9983C23.9965 14.7069 23.0988 17.2058 21.5847 19.2139L20.1253 17.885L20.1253 17.8849C18.5569 16.4564 16.1582 16.4564 14.5898 17.8849L14.5896 17.8851L13.2914 19.0682C12.5703 19.7248 11.4674 19.7248 10.7463 19.0682L9.44805 17.8851L9.44784 17.8849L9.41092 17.8517C7.842 16.4565 5.46849 16.4676 3.91233 17.885L2.42664 19.2378C1.38127 17.8584 0.627365 16.2461 0.256536 14.4924L2.73458 12.236L2.73472 12.2359C3.45586 11.579 4.55861 11.579 5.27978 12.2358L6.57837 13.4188L6.57847 13.4189C8.14681 14.8474 10.5455 14.8476 12.1137 13.4188L13.4122 12.2358C14.1334 11.579 15.2365 11.579 15.9577 12.2359L15.9578 12.236L19.2769 15.2582L20.7716 13.6171L17.4527 10.595L17.4527 10.595C15.8843 9.16646 13.4856 9.16646 11.9172 10.595L11.9171 10.5951L10.6185 11.7782L10.6185 11.7782C9.89779 12.4348 8.79476 12.435 8.07352 11.7782L6.77493 10.5951L6.77486 10.595L6.73795 10.5618C5.16903 9.16654 2.79587 9.17765 1.23971 10.595L0 11.7239C0.145876 5.22438 5.46071 7.07913e-06 11.9965 0Z"],Do="M0,101.12c0-34.64,0-51.95,6.53-65.28,6.25-12.76,16.56-23.07,29.32-29.32C49.17,0,66.48,0,101.12,0h1077.76c34.63,0,51.96,0,65.28,6.53,12.75,6.25,23.06,16.56,29.32,29.32,6.52,13.32,6.52,30.64,6.52,65.28v1077.76c0,34.63,0,51.96-6.52,65.28-6.26,12.75-16.57,23.06-29.32,29.32-13.32,6.52-30.65,6.52-65.28,6.52H101.12c-34.64,0-51.95,0-65.28-6.52-12.76-6.26-23.07-16.57-29.32-29.32-6.53-13.32-6.53-30.65-6.53-65.28V101.12Z",Uo="M100.48 69.3817L83.8068 86.8015C83.4444 87.1799 83.0058 87.4816 82.5185 87.6878C82.0312 87.894 81.5055 88.0003 80.9743 88H1.93563C1.55849 88 1.18957 87.8926 0.874202 87.6912C0.558829 87.4897 0.31074 87.2029 0.160416 86.8659C0.0100923 86.529 -0.0359181 86.1566 0.0280382 85.7945C0.0919944 85.4324 0.263131 85.0964 0.520422 84.8278L17.2061 67.408C17.5676 67.0306 18.0047 66.7295 18.4904 66.5234C18.9762 66.3172 19.5002 66.2104 20.0301 66.2095H99.0644C99.4415 66.2095 99.8104 66.3169 100.126 66.5183C100.441 66.7198 100.689 67.0067 100.84 67.3436C100.99 67.6806 101.036 68.0529 100.972 68.415C100.908 68.7771 100.737 69.1131 100.48 69.3817ZM83.8068 34.3032C83.4444 33.9248 83.0058 33.6231 82.5185 33.4169C82.0312 33.2108 81.5055 33.1045 80.9743 33.1048H1.93563C1.55849 33.1048 1.18957 33.2121 0.874202 33.4136C0.558829 33.6151 0.31074 33.9019 0.160416 34.2388C0.0100923 34.5758 -0.0359181 34.9482 0.0280382 35.3103C0.0919944 35.6723 0.263131 36.0083 0.520422 36.277L17.2061 53.6968C17.5676 54.0742 18.0047 54.3752 18.4904 54.5814C18.9762 54.7875 19.5002 54.8944 20.0301 54.8952H99.0644C99.4415 54.8952 99.8104 54.7879 100.126 54.5864C100.441 54.3849 100.689 54.0981 100.84 53.7612C100.99 53.4242 101.036 53.0518 100.972 52.6897C100.908 52.3277 100.737 51.9917 100.48 51.723L83.8068 34.3032ZM1.93563 21.7905H80.9743C81.5055 21.7907 82.0312 21.6845 82.5185 21.4783C83.0058 21.2721 83.4444 20.9704 83.8068 20.592L100.48 3.17219C100.737 2.90357 100.908 2.56758 100.972 2.2055C101.036 1.84342 100.99 1.47103 100.84 1.13408C100.689 0.79713 100.441 0.510296 100.126 0.308823C99.8104 0.107349 99.4415 1.24074e-05 99.0644 0L20.0301 0C19.5002 0.000878397 18.9762 0.107699 18.4904 0.313848C18.0047 0.519998 17.5676 0.821087 17.2061 1.19848L0.524723 18.6183C0.267681 18.8866 0.0966198 19.2223 0.0325185 19.5839C-0.0315829 19.9456 0.0140624 20.3177 0.163856 20.6545C0.31365 20.9913 0.561081 21.2781 0.875804 21.4799C1.19053 21.6817 1.55886 21.7896 1.93563 21.7905Z";function jo({icon:e}){if(e==="sei")return b("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:[c("rect",{width:"24",height:"24",fill:"#000"}),c("g",{transform:"translate(4 4) scale(0.6667)",fill:"#fff",children:Bo.map((t,n)=>c("path",{d:t},n))})]});if(e==="base")return c("svg",{viewBox:"0 0 1280 1280",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:c("path",{d:Do,fill:"#0000FF"})});return b("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%","aria-hidden":"true",focusable:"false",children:[c("rect",{width:"24",height:"24",fill:"#000"}),c("defs",{children:b("linearGradient",{id:"sc-sol-grad",x1:"8.52558",y1:"90.0973",x2:"88.9933",y2:"-3.01622",gradientUnits:"userSpaceOnUse",children:[c("stop",{offset:"0.08",stopColor:"#9945FF"}),c("stop",{offset:"0.5",stopColor:"#5497D5"}),c("stop",{offset:"0.97",stopColor:"#19FB9B"})]})}),c("g",{transform:"translate(4.5 5.2) scale(0.1485)",children:c("path",{d:Uo,fill:"url(#sc-sol-grad)"})})]})}var zo={usdt:"#26A17B",eth:"#627EEA",pol:"#8247E5",usdc:"#2775CA"},Ho={usdt:"₮",eth:"Ξ"};function $o({token:e,size:t=28}){let n=e.logo.toLowerCase(),a=Ho[n]??(/[\p{L}\p{N}]/u.exec(e.symbol)?.[0]??"•").toUpperCase();return b("svg",{className:"sc-glyph",width:t,height:t,viewBox:"0 0 32 32","aria-hidden":"true",focusable:"false","data-token":n,children:[c("circle",{cx:"16",cy:"16",r:"16",fill:zo[n]??"#475569"}),c("text",{x:"16",y:"21.5",textAnchor:"middle",fontSize:"16",fontWeight:"700",fill:"#fff",fontFamily:"system-ui,sans-serif",children:a})]})}function dt({size:e=28,badge:t,token:n}){let a=!!n&&n.logo.toLowerCase()!=="usdc";return b("span",{className:"sc-mark",style:{width:e,height:e},children:[a?c($o,{token:n,size:e}):c(Wo,{size:e}),t?t.icon?c("span",{className:"sc-badge sc-badge-icon","data-icon":t.icon,"aria-hidden":"true",children:c(jo,{icon:t.icon})}):c("span",{className:"sc-badge","data-hue":t.hue,"aria-hidden":"true",children:t.letter}):null]})}function Fo(){return b("svg",{className:"sc-check",viewBox:"0 0 64 64","aria-hidden":"true",focusable:"false",children:[c("circle",{cx:"32",cy:"32",r:"28"}),c("path",{d:"M20 33l8 8 16-17"})]})}function pt({chain:e,symbol:t="USDC"}){return b("span",{className:"sc-tok",children:[t,c("sub",{children:e})]})}function qo({options:e,selectedId:t,open:n,locked:a,label:r,amount:o,onOpenChange:s,onSelect:i}){let l=ae(null),u=ae(null),g=e.find((p)=>p.id===t)??e[0]??null,h=e.length<=1,k=!h&&!a;Z(()=>{if(!n)return;let p=u.current?.querySelectorAll('[role="option"]'),f=Math.max(0,e.findIndex((D)=>D.id===t));p?.[f]?.focus({preventScroll:!0});let C=setTimeout(()=>{u.current?.closest(".sc-card")?.querySelector('[data-testid="sc-pay"]')?.scrollIntoView({block:"nearest",behavior:"smooth"})},240),te=(D)=>{let z=D.target;if(z&&!u.current?.contains(z)&&!l.current?.contains(z))s(!1)};return document.addEventListener("pointerdown",te,!0),()=>{clearTimeout(C),document.removeEventListener("pointerdown",te,!0)}},[n]);let A=(p)=>{let f=Array.from(u.current?.querySelectorAll('[role="option"]')??[]);if(f.length===0)return;let C=f.indexOf(document.activeElement),te=p==="first"?0:p==="last"?f.length-1:Math.min(f.length-1,Math.max(0,C+p));f[te]?.focus()},L=(p)=>{if(p.key==="Escape")p.preventDefault(),p.stopPropagation(),s(!1),l.current?.focus();else if(p.key==="ArrowDown")p.preventDefault(),A(1);else if(p.key==="ArrowUp")p.preventDefault(),A(-1);else if(p.key==="Home")p.preventDefault(),A("first");else if(p.key==="End")p.preventDefault(),A("last");else if(p.key==="Tab")s(!1)};return b(gt,{children:[b("div",{className:"sc-box",children:[c("div",{className:"sc-pick",children:b("button",{ref:l,type:"button",className:"sc-tok-btn","aria-haspopup":h?void 0:"listbox","aria-expanded":h?void 0:n,"aria-disabled":h||a,"aria-label":g?`${r}: ${g.symbol??"USDC"} ${g.chain}`:r,"data-testid":"sc-token","data-single":h?"true":void 0,onClick:()=>{if(k)s(!n)},onKeyDown:(p)=>{if((p.key==="ArrowDown"||p.key==="ArrowUp")&&k)p.preventDefault(),s(!0)},children:[c(dt,{badge:g?.badge,token:g?.symbol?{symbol:g.symbol,logo:g.logo??g.symbol.toLowerCase()}:null}),g?c(pt,{chain:g.chain,symbol:g.symbol}):c("span",{className:"sc-tok",children:"USDC"}),k&&c($a,{})]})}),o]}),n&&!h&&c("div",{ref:u,className:"sc-menu",role:"listbox","aria-label":r,onKeyDown:L,"data-testid":"sc-menu",children:e.map((p,f)=>b("button",{type:"button",role:"option",className:"sc-opt",style:{"--i":Math.min(f,3)},"aria-selected":p.id===t,"aria-disabled":p.disabled,"data-testid":"sc-option",onClick:()=>{if(p.disabled)return;i(p.id),s(!1),l.current?.focus()},children:[b("span",{className:"sc-opt-main",children:[c(dt,{badge:p.badge,token:p.symbol?{symbol:p.symbol,logo:p.logo??p.symbol.toLowerCase()}:null}),c(pt,{chain:p.chain,symbol:p.symbol})]}),p.loading?c("span",{className:"sc-sk",style:{width:56,height:14},"data-testid":"sc-row-skeleton","aria-hidden":"true"}):p.balanceText!==null||p.reason?b("span",{className:"sc-opt-bal","data-muted":p.disabled?"true":void 0,children:[p.balanceText!==null&&c("span",{children:p.balanceText}),p.reason&&c("span",{className:"sc-opt-sub",children:p.reason})]}):null,c("span",{className:"sc-opt-check","aria-hidden":"true",children:p.id===t?c($e,{}):null})]},p.id))})]})}function Ko({items:e,paused:t,lowGas:n,pauseLabel:a,optionKey:r,interval:o=2500}){let s=e.findIndex((j)=>j.warn),[i,l]=me(Math.max(0,s)),[u,g]=me(!1),[h,k]=me(!1),[A,L]=me(!1),p=e.map((j)=>j.label).join("|"),f=e.map((j)=>j.value).join(", "),[C,te]=me(f),D=ae(r??null);Z(()=>l(Math.max(0,s)),[p,s]),Z(()=>{if(e.length===0||D.current===(r??null))return;D.current=r??null,te(f)},[r,e.length]);let z=e.length>1&&s<0,de=t||u||h||A;if(Z(()=>{if(!z||de)return;let j=setInterval(()=>l((V)=>(V+1)%e.length),o);return()=>clearInterval(j)},[z,de,e.length,o]),e.length===0)return null;return b("div",{className:"sc-deco","data-testid":"sc-decorator",onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),onFocus:(j)=>k(j.target.matches(":focus-visible")),onBlur:()=>k(!1),children:[c("span",{className:"sc-live",role:"status","aria-live":"polite",children:C}),c("span",{className:"sc-deco-cycle",children:e.map((j,V)=>b("span",{className:"sc-deco-item","aria-hidden":"true","data-active":V===i,"data-warn":j.warn,children:[c("span",{className:"sc-deco-v",children:j.value}),j.warn&&c("span",{className:"sc-deco-flag","data-testid":"sc-lowgas",children:n})]},j.label))}),z&&c("button",{type:"button",className:"sc-pause","aria-pressed":A,"aria-label":a,"data-testid":"sc-pause",onClick:()=>L((j)=>!j),children:A?c(Oo,{}):c(Io,{})})]})}function Go({wallet:e,copy:t,actions:n,inert:a}){let[r,o]=me(!1),[s,i]=me(!1),l=ae(null),u=ae(null),g=ae(null);Z(()=>()=>{if(g.current)clearTimeout(g.current)},[]),Z(()=>{if(!r)return;u.current?.querySelector('[role="menuitem"]')?.focus();let p=(f)=>{let C=f.target;if(C&&!u.current?.contains(C)&&!l.current?.contains(C))o(!1)};return document.addEventListener("pointerdown",p,!0),()=>document.removeEventListener("pointerdown",p,!0)},[r]),Z(()=>{if(a)o(!1)},[a]);let h=e.name??t.walletName,k=b(gt,{children:[c("span",{className:"sc-wallet-dot","aria-hidden":"true"}),c("span",{className:"sc-wallet-name",children:h}),c("span",{className:"sc-wallet-addr",children:e.short}),!a&&n?c($a,{}):null]});if(a||!n)return c("div",{className:"sc-wrow",children:c("span",{className:"sc-wallet","data-static":"true","data-testid":"sc-wallet",children:k})});let A=[{key:"copy",icon:s?c($e,{}):c(sn,{}),label:s?t.copied:t.copyWalletAddress,sub:e.short,run:()=>{if(n.onCopy(),i(!0),g.current)clearTimeout(g.current);g.current=setTimeout(()=>i(!1),1600)},keepOpen:!0},{key:"switch",icon:c(Lo,{}),label:t.switchWallet,run:n.onSwitch},{key:"disconnect",icon:c(To,{}),label:t.disconnect,run:n.onDisconnect}],L=(p)=>{let f=Array.from(u.current?.querySelectorAll('[role="menuitem"]')??[]),C=f.indexOf(document.activeElement);if(p.key==="Escape")p.preventDefault(),p.stopPropagation(),o(!1),l.current?.focus();else if(p.key==="ArrowDown")p.preventDefault(),f[(C+1)%f.length]?.focus();else if(p.key==="ArrowUp")p.preventDefault(),f[(C-1+f.length)%f.length]?.focus();else if(p.key==="Tab")o(!1)};return b("div",{className:"sc-wrow",children:[c("button",{ref:l,type:"button",className:"sc-wallet","aria-haspopup":"menu","aria-expanded":r,"aria-label":`${t.walletMenu}: ${h} ${e.short}`,"data-testid":"sc-wallet",onClick:()=>o((p)=>!p),onKeyDown:(p)=>{if(p.key==="ArrowDown"&&!r)p.preventDefault(),o(!0)},children:k}),r&&c("div",{ref:u,className:"sc-pop",role:"menu","aria-label":t.walletMenu,onKeyDown:L,"data-testid":"sc-wallet-menu",children:A.map((p)=>b("button",{type:"button",role:"menuitem",className:"sc-mi","data-testid":`sc-wallet-${p.key}`,onClick:()=>{if(p.run(),!p.keepOpen)o(!1)},children:[p.icon,c("span",{children:p.label}),p.sub?c("span",{className:"sc-mi-sub",children:p.sub}):null]},p.key))})]})}function Qo({wallets:e,busyId:t,copy:n,onPick:a}){let r=ae(null);Z(()=>{r.current?.querySelector("button")?.focus({preventScroll:!0})},[]);let o=(s)=>{let i=Array.from(r.current?.querySelectorAll("button")??[]),l=i.indexOf(document.activeElement);if(s.key==="ArrowDown")s.preventDefault(),i[Math.min(i.length-1,l+1)]?.focus();else if(s.key==="ArrowUp")s.preventDefault(),i[Math.max(0,l-1)]?.focus()};return c("ul",{ref:r,className:"sc-wl","aria-label":n.chooseWallet,"data-testid":"sc-wallets",onKeyDown:o,children:e.map((s,i)=>{let l=t===s.id;return c("li",{children:b("button",{type:"button",className:"sc-wl-row",style:{animation:"sc-rise .2s var(--c-ease) both",animationDelay:`${Math.min(i,3)*20}ms`},"aria-disabled":t!==null,"aria-busy":l,"data-testid":"sc-wallet-option",onClick:()=>{if(t===null)a(s.id)},children:[s.icon?c("img",{className:"sc-wl-icon",src:s.icon,alt:"",width:32,height:32}):c("span",{className:"sc-wl-mono","aria-hidden":"true",children:s.name.charAt(0).toUpperCase()}),b("span",{className:"sc-wl-name",children:[s.name,l&&b("span",{className:"sc-wl-sub",children:[c(ut,{small:!0}),B(n.openingNamed,{wallet:s.name})]})]}),s.lastUsed&&!l?c("span",{className:"sc-wl-tag",children:n.lastUsed}):null]})},s.id)})})}function Yo({stages:e,copy:t,tx:n,walletName:a}){let r=(o)=>o.key==="wallet"?o.state==="active"&&n&&n.total>1?lt(t,n,a):a?B(t.confirmNamed,{wallet:a}):t.stageWallet:o.key==="sent"?t.stageSent:t.stageConfirmed;return c("ol",{className:"sc-steps","aria-label":t.stagesLabel,"data-testid":"sc-stages",children:e.map((o)=>b("li",{"data-state":o.state,"data-stage":o.key,children:[c("span",{className:"sc-dot","aria-hidden":"true",children:o.state==="done"?c($e,{size:14}):null}),b("span",{children:[r(o),c("span",{className:"sc-live",children:o.state==="done"?" (done)":o.state==="active"?" (in progress)":""})]})]},o.key))})}function ft({problem:e,copy:t,noticeRef:n,children:a}){let r=e.kind==="rejected";return b("div",{className:"sc-notice",ref:n,tabIndex:-1,"data-kind":e.kind,"data-testid":"sc-notice",children:[b("div",{className:"sc-notice-head",children:[r?c(_o,{}):c(Mo,{}),c("p",{children:e.message})]}),a?c("div",{className:"sc-actions",children:a}):null,e.detail&&!r&&b("details",{className:"sc-tech",children:[c("summary",{children:t.details}),c("code",{children:e.detail})]})]})}function Jo({copy:e,amountText:t,receipt:n,finalizing:a,slot:r,returnHref:o,doneRef:s,onDone:i}){let l=o?c("a",{className:"sc-btn",href:o,ref:s,"data-testid":"sc-return",children:e.returnToStore}):i?c("button",{type:"button",className:"sc-btn",onClick:i,ref:s,"data-testid":"sc-done",children:e.done}):null;return b("div",{className:"sc-ok",ref:l?void 0:s,tabIndex:l?void 0:-1,"data-testid":"sc-success","data-receipt":a?"provisional":"final",children:[c(Fo,{}),c("h3",{children:a?e.receivedProvisional:e.received},a?"received":"confirmed"),c("p",{className:"sc-ok-amt",children:t}),b("p",{className:"sc-receipt",children:[e.receiptLabel," ",c("code",{children:n})]}),a&&c("p",{className:"sc-fin","data-testid":"sc-finalizing",children:e.finalizing}),r?c("div",{className:"sc-slot",children:r}):null,l]})}function Vo(){return b("div",{"aria-hidden":"true","data-testid":"sc-skeleton",children:[c("span",{className:"sc-sk",style:{width:120,height:14,margin:"6px 0 10px"}}),c("span",{className:"sc-sk",style:{width:"100%",height:96,borderRadius:16}}),c("span",{className:"sc-sk",style:{width:"100%",height:56,marginTop:16}})]})}var Xo=()=>typeof window<"u"&&typeof window.matchMedia==="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,Zo=typeof window>"u"?Z:Eo;function Fa({open:e,onClose:t,onBackdrop:n,titleId:a,children:r,initialFocus:o}){let s=ae(null),[i,l]=me(e);return Zo(()=>{if(e)l(!0)},[e]),Z(()=>{let u=s.current;if(!u)return;if(e&&!u.open){u.removeAttribute("data-closing");try{u.showModal()}catch{u.setAttribute("open","")}o?.current?.focus();return}if(e||!u.open)return;let g=!1,h=()=>{if(g)return;g=!0,u.removeAttribute("data-closing"),u.close(),l(!1)};if(Xo()){h();return}u.setAttribute("data-closing",""),u.addEventListener("animationend",h,{once:!0});let k=setTimeout(h,260);return()=>{if(clearTimeout(k),u.removeEventListener("animationend",h),!g&&s.current?.open)u.removeAttribute("data-closing")}},[e]),c("dialog",{ref:s,className:"sc-dialog","aria-labelledby":a,"data-testid":"sc-modal",onCancel:(u)=>{u.preventDefault(),t()},onClick:(u)=>{let g=s.current;if(!g||u.target!==g)return;let h=g.getBoundingClientRect();if(u.clientX<h.left||u.clientX>h.right||u.clientY<h.top||u.clientY>h.bottom)(n??t)()},children:e||i?r:null})}function es({title:e,titleId:t,titleRef:n,closeLabel:a,onClose:r,back:o}){return b("div",{className:"sc-head",children:[b("div",{className:"sc-head-end",children:[o&&b("button",{type:"button",className:"sc-back",onClick:o.onClick,"data-testid":"sc-back",children:[c(No,{}),o.label]}),c("h2",{className:"sc-title",id:t,ref:n,tabIndex:-1,children:e})]}),c("div",{className:"sc-head-end",children:r&&c("button",{type:"button",className:"sc-x",onClick:r,"aria-label":a,"data-testid":"sc-close",children:c(ee,{children:c("path",{d:"M6 6l12 12M18 6L6 18"})})})})]})}function ts({children:e}){let t=ae(null),n=ae(null);return Z(()=>{let a=t.current,r=n.current;if(!a||!r||typeof ResizeObserver>"u")return;let o=!0,s,i=new ResizeObserver(()=>{let l=r.getBoundingClientRect().height;if(l===0){a.style.height="";return}if(a.style.height=`${l+8}px`,o){o=!1,requestAnimationFrame(()=>a.setAttribute("data-ready","true"));return}a.setAttribute("data-anim","true"),clearTimeout(s),s=setTimeout(()=>a.removeAttribute("data-anim"),260)});return i.observe(r),()=>{i.disconnect(),clearTimeout(s)}},[]),c("div",{className:"sc-hgt",ref:t,children:c("div",{ref:n,children:e})})}function ns({line:e,copy:t,onRetry:n}){let a=e.kind==="loading"||e.kind==="refreshing";return b("div",{className:"sc-payline",role:"status","aria-live":"polite","aria-atomic":"true","data-testid":"sc-payline","data-kind":e.kind,children:[a&&c(ut,{small:!0}),c("span",{className:e.kind==="ready"||e.kind==="refreshing"?"sc-payline-main":void 0,children:e.text}),e.note?c("span",{children:e.note}):null,e.eta?c("span",{children:e.eta}):null,e.kind==="unavailable"&&n?c("button",{type:"button",className:"sc-link",onClick:n,children:t.tryAgain}):null]})}function qa(e){let{copy:t}=e,n=e.phase==="paying",a=e.phase==="pick"||e.phase==="paying",r=ae(null),o=!!e.closeGuard&&n;Z(()=>{if(o)r.current?.focus()},[o]);let s=e.phase==="manual"?t.payAnotherWay:e.phase==="wallets"?t.chooseWallet:e.title??t.title;return b("div",{className:"sc-card","data-phase":e.phase,children:[b(ts,{children:[c(es,{title:s,titleId:e.titleId,titleRef:e.titleRef,closeLabel:t.close,onClose:e.onClose,back:(e.phase==="manual"||e.phase==="wallets")&&e.onBack?{label:t.back,onClick:e.onBack}:null}),e.phase==="loading"&&!e.notice&&c(Vo,{}),a&&e.wallet&&c(Go,{wallet:e.wallet,copy:t,actions:e.walletActions??null,inert:n}),a&&b(gt,{children:[b("div",{className:"sc-deco-row",children:[c("span",{className:"sc-deco-label",children:t.payWith}),b("span",{className:"sc-deco-end",children:[e.refreshing?c("span",{"data-testid":"sc-refreshing",style:{display:"inline-flex"},children:c(ut,{small:!0})}):null,c(Ko,{items:e.decorator,paused:e.menuOpen||n,lowGas:t.lowGas,pauseLabel:t.pauseBalances,optionKey:e.decoratorKey})]})]}),c(qo,{options:e.options,selectedId:e.selectedId,open:e.menuOpen,locked:n,label:t.chooseUsdc,amount:c("p",{className:"sc-amt","data-testid":"sc-amount","aria-label":`${t.amountDue} ${e.amountText}`,children:e.amountText}),onOpenChange:e.onMenuChange,onSelect:e.onSelect}),e.payLine&&c(ns,{line:e.payLine,copy:t,onRetry:e.onPayLineRetry})]}),e.phase==="wallets"&&e.walletPicker&&c(Qo,{wallets:e.walletPicker.wallets,busyId:e.walletPicker.busyId,copy:t,onPick:e.walletPicker.onPick}),(e.phase==="pick"||e.phase==="wallets")&&e.message?c("div",{className:"sc-msg",role:"status","data-testid":"sc-message",children:e.message}):null,e.notice,n&&e.stages&&b(gt,{children:[c(Yo,{stages:e.stages,copy:t,tx:e.tx,walletName:e.walletName}),c("div",{className:"sc-hair","aria-hidden":"true","data-testid":"sc-progress",children:c("i",{})}),e.slow?c("p",{className:"sc-expect","data-testid":"sc-status",children:t.slow}):null]}),o&&e.closeGuard&&b("div",{className:"sc-msg","data-testid":"sc-close-guard",children:[c("span",{className:"sc-msg-strong",children:t.closeConfirm}),b("div",{className:"sc-pair",children:[c("button",{type:"button",className:"sc-sec",onClick:e.closeGuard.onClose,"data-testid":"sc-close-anyway",children:t.closeAnyway}),c("button",{type:"button",className:"sc-sec",ref:r,onClick:e.closeGuard.onStay,"data-testid":"sc-stay",children:t.stay})]})]}),(e.phase==="pick"||e.phase==="paying")&&e.cta&&b("button",{ref:e.cta.ref,type:"button",className:"sc-btn sc-cta","aria-busy":e.cta.busy,"aria-disabled":e.cta.disabled||e.cta.busy,"data-testid":"sc-pay",onClick:()=>{if(!e.cta.disabled&&!e.cta.busy)e.cta.onClick()},children:[(e.cta.busy||e.cta.spinner)&&c(ut,{}),c("span",{children:e.cta.label})]}),e.phase==="pick"&&e.onPayAnotherWay&&c("div",{className:"sc-foot",children:c("button",{type:"button",className:"sc-link sc-link-quiet",onClick:e.onPayAnotherWay,"data-testid":"sc-another-way",children:t.payAnotherWay})}),e.phase==="done"&&e.done&&c(Jo,{copy:t,amountText:e.amountText,receipt:e.done.receipt,finalizing:e.done.finalizing,slot:e.done.slot,returnHref:e.done.returnHref,doneRef:e.done.ref,onDone:e.done.onDone}),e.phase==="manual"&&e.manual]}),b("p",{className:"sc-powered","data-testid":"sc-powered",children:[c("svg",{viewBox:"0 0 80 80","aria-hidden":"true",focusable:"false",children:c("path",{d:za,fill:"none",stroke:"currentColor",strokeWidth:"11",strokeLinecap:"round",strokeLinejoin:"round"})}),c("span",{children:ja.poweredBy})]})]})}var as={pending:"",event:"",data:[],started:!1},rs=/\r\n|\n|\r/;function os(e,t){if(t===""){let s=e.data.length>0?{event:e.event||"message",data:e.data.join(`
208
+ `)}:null;return{state:{...e,event:"",data:[]},frame:s}}if(t.startsWith(":"))return{state:e,frame:null};let n=t.indexOf(":"),a=n===-1?t:t.slice(0,n),r=n===-1?"":t.slice(n+1),o=r.startsWith(" ")?r.slice(1):r;if(a==="event")return{state:{...e,event:o},frame:null};if(a==="data")return{state:{...e,data:[...e.data,o]},frame:null};return{state:e,frame:null}}function ss(e,t){let n=e.pending+(e.started?t:t.replace(/^\uFEFF/,"")),a=n.endsWith("\r")?"\r":"",r=n.slice(0,n.length-a.length).split(rs),o=r.pop(),s=r.reduce((i,l)=>{let u=os(i.state,l);return{state:u.state,frames:u.frame?[...i.frames,u.frame]:i.frames}},{state:{...e,started:!0},frames:[]});return{state:{...s.state,pending:o+a},frames:s.frames}}async function Ka(e,t,n){let a=e.getReader(),r=new TextDecoder,o=()=>void a.cancel().catch(()=>{});if(n?.aborted)return o();n?.addEventListener("abort",o,{once:!0});try{let s=as;for(;;){let{done:i,value:l}=await a.read();if(i||n?.aborted)return;let u=ss(s,r.decode(l,{stream:!0}));s=u.state;for(let g of u.frames)if(t(g),n?.aborted)return o()}}finally{n?.removeEventListener("abort",o)}}class Pe extends Error{status;code;constructor(e,t,n){super(n);this.status=e;this.code=t}}var is={retries:3,baseMs:400};function cs(e,t={}){let{retryRateLimit:n=!0}=t;return e instanceof Pe&&(e.status===0||e.status===408||n&&e.status===429||e.status>=500)}async function ls(e,t={}){let{retries:n,baseMs:a,retryRateLimit:r}={...is,...t};for(let o=0;;o++)try{return await e()}catch(s){if(o>=n||!cs(s,{retryRateLimit:r}))throw s;await new Promise((i)=>setTimeout(i,a*2**o+Math.random()*a*0.25))}}function cn(e,t,n,a){let r=`${e}/v1/charges/${encodeURIComponent(t)}`;async function o(i,l){let u;try{u=await fetch(`${r}${i}`,{method:l===void 0?"GET":"POST",headers:{"X-Client-Secret":n,...l===void 0?{}:{"content-type":"application/json"}},...l===void 0?{}:{body:JSON.stringify(l)},cache:"no-store"})}catch{throw new Pe(0,"network","Network request failed")}let g=await u.text(),h=null;try{h=g?JSON.parse(g):null}catch{h=null}if(!u.ok){let k=h?.error;throw new Pe(u.status,k?.code??"error",k?.message??`HTTP ${u.status}`)}return h}let s=(i,l)=>ls(()=>o(i,l),{...a,retryRateLimit:l===void 0});return{charge:()=>o(""),events:async(i,l)=>{let u;try{u=await fetch(`${r}/events`,{headers:{"X-Client-Secret":n,accept:"text/event-stream"},cache:"no-store",...l?{signal:l}:{}})}catch{throw new Pe(0,"network","Network request failed")}if(!u.ok||!u.body){let g=await u.json().catch(()=>null);throw new Pe(u.status,g?.error?.code??"error",g?.error?.message??`HTTP ${u.status}`)}await Ka(u.body,i,l)},options:()=>s("/options"),pay:(i,l)=>s("/pay",{option_id:i,buyer:l}),authorize:(i)=>s("/authorizations",i),submitSolana:(i)=>s("/rails/cctp/submit",{transaction:i}),fundingAttempt:(i,l,u={})=>s("/funding_attempts",{rail:u.rail??"cctp",source_chain:i,tx_hash:l,...u.buyer?{buyer:u.buyer}:{}}),lifiQuote:(i,l)=>o(`/rails/lifi/quote?option_id=${encodeURIComponent(i)}&buyer=${encodeURIComponent(l)}`)}}async function ve(e,t,n,a={}){let r=Error("No RPC endpoint available");for(let o of e){let s=new AbortController,i=setTimeout(()=>s.abort(),a.timeoutMs??8000);try{let l=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:t,params:n}),signal:s.signal});if(!l.ok)throw Error(`RPC HTTP ${l.status}`);let u=await l.json();if(u.error)throw Error(u.error.message??"RPC error");if(!("result"in u))throw Error("RPC returned no result");return u.result}catch(l){r=l}finally{clearTimeout(i)}}throw r}function Ae(e){return!!e&&typeof e==="object"}function us(e){if(!Ae(e)||typeof e.id!=="string"||!e.id)return null;if(e.kind!=="evm"&&e.kind!=="solana")return null;let{chain:t,token:n}=e;if(!Ae(t)||!(typeof t.id==="number"||typeof t.id==="string")||typeof t.name!=="string")return null;if(!Ae(n)||typeof n.address!=="string"||!n.address)return null;if(!Array.isArray(e.rpc_urls))return null;let a=e.native;return{id:e.id,kind:e.kind,chain:{id:t.id,name:t.name,display_name:typeof t.display_name==="string"&&t.display_name?t.display_name:null},...e.rail==="lifi"?{rail:"lifi"}:{},token:{symbol:typeof n.symbol==="string"?n.symbol:"USDC",address:n.address,decimals:typeof n.decimals==="number"?n.decimals:6,logo:typeof n.logo==="string"?n.logo:"usdc",...n.native===!0?{native:!0}:{}},native:Ae(a)&&typeof a.symbol==="string"&&typeof a.decimals==="number"?{symbol:a.symbol,decimals:a.decimals}:null,default:e.default===!0,route:e.route==="direct"?"direct":"bridge",...e.gasless===!0?{gasless:!0}:{},add_chain:Ae(e.add_chain)?e.add_chain:null,rpc_urls:e.rpc_urls.filter((r)=>typeof r==="string"&&/^https?:\/\//i.test(r))}}function Qa(e){return(Array.isArray(e)?e:Ae(e)&&Array.isArray(e.data)?e.data:[]).map(us).filter((n)=>n!==null)}function ht(e){return e.chain.display_name??Ra(e.chain.name)}function ds(e){let t=e.chain,n=t.add_chain?.nativeCurrency;return{id:`evm:${t.id}`,kind:"evm",chain:{id:t.id,name:t.name,display_name:t.add_chain?.chainName??null},token:{symbol:"USDC",address:t.usdc,decimals:6,logo:"usdc"},native:n?{symbol:n.symbol,decimals:n.decimals}:null,default:!0,route:"direct",add_chain:t.add_chain,rpc_urls:t.add_chain?.rpcUrls??[]}}var Ya=(e,t)=>t.find((n)=>n.default&&!F(n))??ds(e);function dn(e){return!e.gasless&&(e.kind==="solana"||e.route==="bridge")}function un(e,t){let n=10n**BigInt(t),a=e/n,o=(t===0?"":(e%n).toString().padStart(t,"0")).slice(0,4).replace(/0+$/,"");if(o.length<2)o=o.padEnd(2,"0");return`${a.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}.${o}`}var F=(e)=>e.rail==="lifi";function yt(e,t,n){return F(e)?t.usdc>0n:t.usdc>=BigInt(n)}function Ja(e,t,n,a){let r={balanceText:null,disabled:!1,reason:null,loading:!1};if(a&&!a[e.kind])return a.evm||a.solana?{...r,reason:"needs_wallet"}:r;if(!t)return{...r,loading:!!a?.[e.kind]};if(t.status==="loading")return{...r,loading:!0};if(t.status==="error")return{...r,reason:"unreadable"};let o=!yt(e,t,n);return{balanceText:un(t.usdc,e.token.decimals),disabled:o,reason:o?"not_enough":null,loading:!1}}function Va(e,t,n,a){let r=e.filter((i)=>n[i.kind]);if(r.length===0)return e;if(r.some((i)=>{let l=t[i.id];return!l||l.status==="loading"}))return e;let o=(i)=>{let l=n[i.kind]?t[i.id]:void 0;return l?.status==="ok"?yt(i,l,a)?0:2:1},s=(i)=>{let l=t[i.id];return l?.status==="ok"?l.usdc:0n};return e.map((i,l)=>({o:i,i:l})).sort((i,l)=>{let u=o(i.o)-o(l.o);if(u!==0)return u;if(o(i.o)===0){let g=Number(F(i.o))-Number(F(l.o));if(g!==0)return g;if(!F(i.o)){let h=s(i.o),k=s(l.o);if(h!==k)return h>k?-1:1;let A=Number(l.o.default)-Number(i.o.default);if(A!==0)return A}}return i.i-l.i}).map((i)=>i.o)}function pn(e,t,n){return e.filter((a)=>{if(!n[a.kind])return!1;let r=t[a.id];return!r||r.status!=="ok"||r.usdc>0n})}var ln=6;function Xa(e){let t=new Set;return e.map((n)=>{let a=0;for(let s of n)a=a*31+s.charCodeAt(0)>>>0;let r=a%ln;for(let s=0;t.has(r)&&s<ln;s++)r=(r+1)%ln;return t.add(r),{letter:/[\p{L}\p{N}]/u.exec(n)?.[0]?.toUpperCase()??"•",hue:r}})}function Za(e,t,n){let a=BigInt(n),r=e.flatMap((l)=>{let u=t[l.id];return!F(l)&&u?.status==="ok"&&u.usdc>=a?[{o:l,usdc:u.usdc}]:[]});if(r.length>0)return r.sort((l,u)=>Number(u.o.default)-Number(l.o.default)||(l.usdc===u.usdc?0:l.usdc>u.usdc?-1:1)),r[0].o.id;let o=e.filter((l)=>{let u=t[l.id];return F(l)&&u?.status==="ok"&&u.usdc>0n}),s=(l)=>/^(usdc|usdt)$/i.test(l.token.logo)?0:1;if(o.length>0)return o.map((l,u)=>({o:l,i:u})).sort((l,u)=>s(l.o)-s(u.o)||l.i-u.i)[0].o.id;let i=e.filter((l)=>t[l.id]?.status==="error");return i.sort((l,u)=>Number(u.default)-Number(l.default)),i[0]?.id??null}function er(e,t){if(!dn(e)||!e.native||!t||t.status!=="ok"||t.native===null)return"na";if(t.native===0n)return"none";return t.native<10n**BigInt(Math.max(0,e.native.decimals-4))?"low":"ok"}function tr(e,t,n){if(!t||t.status!=="ok")return[];let a=[{label:F(e)?B(n.balanceLabelFor,{symbol:e.token.symbol}):n.balanceLabel,value:`${un(t.usdc,e.token.decimals)} ${e.token.symbol}`,warn:!1}];if(e.native&&t.native!==null){let r=er(e,t);a.push({label:n.gasLabel,value:`${un(t.native,e.native.decimals)} ${e.native.symbol}`,warn:r==="low"||r==="none"})}return a}function nr(e,t,n,a){let r=e.filter((i)=>n[i.kind]);if(r.length===0)return"idle";let o=r.map((i)=>t[i.id]);if(o.some((i)=>!i||i.status==="loading"))return"loading";if(o.some((i)=>i.status==="error"))return"ok";let s=o;if(s.some((i,l)=>yt(r[l],i,a)))return"ok";return s.every((i)=>i.usdc===0n)?"empty":"short"}function ar(e,t,n,a,r){if(!e)return{kind:"connect",disabled:!0,reason:null};if(!t[e.kind])return{kind:"connect",disabled:!1,reason:null};if(!n||n.status==="loading")return{kind:"pay",disabled:!0,reason:"checking"};if(n.status==="ok"&&!yt(e,n,a))return{kind:"pay",disabled:!0,reason:"not_enough"};if(F(e)){let o=r??{status:"idle"};if(o.status==="unavailable")return{kind:"pay",disabled:!0,reason:"unavailable"};if(o.status!=="ready")return{kind:"pay",disabled:!0,reason:"checking"};let s=mn(e,n,o.quote);if(s!=="ok")return{kind:"pay",disabled:!0,reason:s};return{kind:"pay",disabled:!1,reason:null}}if(er(e,n)==="none")return{kind:"pay",disabled:!0,reason:"needs_gas"};return{kind:"pay",disabled:!1,reason:null}}function mt(e){return e&&typeof e==="object"?e:{}}var Ga=(e)=>typeof e==="string"&&/^\d+$/.test(e)?BigInt(e):null;function gn(e){let t=mt(e),n=mt(t.pay),a=Ga(n.amount);if(typeof t.option_id!=="string"||a===null||a===0n||typeof n.symbol!=="string"||typeof n.decimals!=="number"||!Number.isInteger(n.decimals))throw Error("Unexpected quote response");if(!Array.isArray(t.txs)||t.txs.length===0)throw Error("Unexpected quote response");let r=t.txs.map((i)=>{let l=mt(i);if(typeof l.to!=="string"||typeof l.data!=="string")throw Error("Unexpected quote response");return{description:typeof l.description==="string"?l.description:"",to:l.to,data:l.data,value:typeof l.value==="string"||typeof l.value==="number"?String(l.value):"0"}}),o=typeof t.expires_at==="string"?Date.parse(t.expires_at):NaN;if(!Number.isFinite(o))throw Error("Unexpected quote response");let s=mt(t.chain);return{optionId:t.option_id,pay:{amount:a,symbol:n.symbol,decimals:n.decimals},txs:r,chainName:typeof s.name==="string"?s.name:null,addChain:s.add_chain&&typeof s.add_chain==="object"?s.add_chain:null,estimatedSeconds:typeof t.estimated_seconds==="number"?t.estimated_seconds:null,expiresAt:o,gasEstimate:Ga(t.gas_estimate)}}function rr(e,t){switch(t.type){case"reset":return{status:"idle"};case"fetch":return{status:"loading",previous:e.status==="ready"?e.quote:e.status==="loading"?e.previous:null};case"ok":if(t.optionId!==void 0&&t.quote.optionId!==t.optionId)return e;return{status:"ready",quote:t.quote};case"fail":return{status:"unavailable"}}}function or(e,t){return!!e&&t.pay.amount>e.pay.amount}function sr(e,t){return Math.max(1000,e.expiresAt-15000-t)}function fn(e,t,n="up"){if(e===0n)return"0";let a=10n**BigInt(t),r=(e%a).toString().padStart(t,"0"),o=r.length-r.replace(/^0+/,"").length,s=Math.min(t,e>=a?4:o+4),i=10n**BigInt(t-s),l=e/i;if(n==="up"&&e%i!==0n)l+=1n;let u=10n**BigInt(s),g=(l%u).toString().padStart(s,"0").replace(/0+$/,"");return`${(l/u).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}${g?`.${g}`:""}`}function ps(e,t){if(t.gasEstimate!==null)return t.gasEstimate*3n/2n;return 10n**BigInt(Math.max(0,(e.native?.decimals??18)-4))}function mn(e,t,n){if(!t||t.status!=="ok")return"ok";if(t.usdc<n.pay.amount)return"not_enough";let a=ps(e,n);if(e.token.native)return t.usdc<n.pay.amount+a?"needs_gas":"ok";return t.native!==null&&t.native<a?"needs_gas":"ok"}function ir(e,t,n){if(!F(e))return null;let a=(o)=>B(n.youPay,{amount:`${fn(o.pay.amount,o.pay.decimals)} ${o.pay.symbol}`}),r=(o)=>o.estimatedSeconds?B(n.youPayTakes,{minutes:Math.max(1,Math.ceil(o.estimatedSeconds/60))}):null;if(t.status==="ready")return{kind:"ready",text:a(t.quote),eta:r(t.quote)};if(t.status==="loading"&&t.previous)return{kind:"refreshing",text:a(t.previous),eta:null,note:n.youPayUpdating};if(t.status==="unavailable")return{kind:"unavailable",text:n.optionUnavailableReason,eta:null};return{kind:"loading",text:n.youPayChecking,eta:null}}function cr(e){if(e.kind==="solana")return"solana";let t=typeof e.chain.id==="number"?e.chain.id:Number(e.chain.id);if(t===1328||t===1329)return"sei";if(t===84532||t===8453)return"base";return null}var Fe=(e)=>!!e&&typeof e.request==="function";function bt(e){let t=e;if(t.isRabby)return"Rabby";if(t.isCoinbaseWallet)return"Coinbase Wallet";if(t.isBraveWallet)return"Brave Wallet";if(t.isPhantom)return"Phantom";if(t.isMetaMask)return"MetaMask";return"your wallet"}function lr(e){if(typeof window>"u")return null;let t=window.ethereum;if(!Fe(t))return null;let n=Array.isArray(t.providers)?t.providers.filter(Fe):[];if(e&&n.length>1){let a=n.find((r)=>bt(r)===e);if(a)return a}return t}var gs=/^data:image\/(png|svg\+xml|webp|jpeg|gif);/i;function fs(e){let t=e,n=t?.info;if(!n||typeof n.uuid!=="string"||typeof n.name!=="string"||!n.name.trim()||!Fe(t?.provider))return null;let a=typeof n.icon==="string"&&gs.test(n.icon)&&n.icon.length<200000?n.icon:null;return{id:n.uuid,name:n.name.trim().slice(0,40),icon:a,provider:t.provider}}function ms(){if(typeof window>"u")return[];let e=window.ethereum;if(!Fe(e))return[];let t=Array.isArray(e.providers)?e.providers.filter(Fe):[];return t.length>1?t:[e]}function ur(e,t={}){let n=t.target??(typeof window>"u"?null:window),a=new Map,r=!1,o=(l)=>{if(!r)e(l)},s=(l)=>{let u=fs(l.detail);if(!u)return;for(let[g,h]of a)if(h.provider===u.provider&&g!==u.id)a.delete(g);a.set(u.id,u),o([...a.values()])};n?.addEventListener("eip6963:announceProvider",s);try{n?.dispatchEvent(new Event("eip6963:requestProvider"))}catch{}let i=setTimeout(()=>{if(a.size>0)return;let l=new Map;o((t.legacy??ms)().map((u)=>{let g=bt(u),h=(l.get(g)??0)+1;return l.set(g,h),{id:`legacy:${g}:${h}`,name:g,icon:null,provider:u}}))},t.timeoutMs??150);return()=>{r=!0,clearTimeout(i),n?.removeEventListener("eip6963:announceProvider",s)}}async function dr(e){try{await e.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]})}catch(t){if(gr(t)===4001)throw t}return wn(e)}async function yn(e){try{return(await e.request({method:"eth_accounts"}))?.[0]??null}catch{return null}}async function hn(e){try{let t=await e.request({method:"eth_chainId"}),n=Number.parseInt(t,16);return Number.isFinite(n)?n:null}catch{return null}}async function pr(e,t,n){let a=await e.request({method:"eth_call",params:[{to:t,data:nn(n)},"latest"]});return ze(a)}async function bn(e,t){return ze(await e.request({method:"eth_getBalance",params:[t,"latest"]}))}async function wt(e,t){let[n,a]=await Promise.allSettled([ve(e.rpc_urls,"eth_call",[{to:e.token.address,data:nn(t)},"latest"]).then(ze),ve(e.rpc_urls,"eth_getBalance",[t,"latest"]).then(ze)]);if(n.status==="rejected")throw n.reason;return{usdc:n.value,native:a.status==="fulfilled"?a.value:null}}function gr(e){let t=e?.code;return typeof t==="number"?t:void 0}async function wn(e){let n=(await e.request({method:"eth_requestAccounts"}))?.[0];if(!n)throw Error("No wallet account available");return n}async function fr(e,t,n){let a=ya(t);if(await hn(e)===t)return;let r=()=>e.request({method:"wallet_switchEthereumChain",params:[{chainId:a}]});try{await r()}catch(o){if(!(gr(o)===4902||/unrecogni[sz]ed chain|not been added/i.test(o instanceof Error?o.message:""))||!n)throw o;if(await e.request({method:"wallet_addEthereumChain",params:[n]}),await hn(e)!==t)await r()}if(await hn(e)!==t)throw Error("The wallet is still on another chain")}async function mr(e,t,n){let a=await e.request({method:"eth_signTypedData_v4",params:[t,wa(n)]});return va(n,t,a)}async function vn(e,t,n={}){let a=n.intervalMs??2000,r=Date.now()+(n.timeoutMs??600000);for(;;){if(n.signal?.aborted)return"unknown";let o=await e.request({method:"eth_getTransactionReceipt",params:[t]}).catch(()=>null);if(o)return o.status==="0x0"?"failed":"confirmed";if(Date.now()>r)return"unknown";await new Promise((s)=>setTimeout(s,a))}}async function hr(e,t,n,a={}){if(n.length===0)throw Error("No transactions to send");for(let r=0;;r++){let o=n[r];a.onStep?.(r,o.description);let s=await e.request({method:"eth_sendTransaction",params:[{from:t,to:o.to,data:o.data,value:ba(o.value)}]});if(r===n.length-1)return s;switch(await vn(e,s,{signal:a.signal,intervalMs:a.intervalMs})){case"confirmed":break;case"failed":throw Error("Transaction reverted");case"unknown":throw Error(a.signal?.aborted?"Cancelled":"Timed out waiting for the transaction to confirm")}}}function hs(e){let t=[],n=new Set,r=Object.freeze({register:(...o)=>{let s=!1;for(let i of o)if(!t.includes(i))t.push(i),s=!0;if(s)n.forEach((i)=>i());return()=>{for(let i of o){let l=t.indexOf(i);if(l>=0)t.splice(l,1)}n.forEach((i)=>i())}}});e.addEventListener("wallet-standard:register-wallet",(o)=>{try{let s=o.detail;if(typeof s==="function")s(r)}catch{}});try{e.dispatchEvent(new CustomEvent("wallet-standard:app-ready",{detail:r}))}catch{}return{get:()=>t.slice(),on:(o)=>(n.add(o),()=>void n.delete(o))}}var ys=null;function br(){if(typeof window>"u")return null;return ys??=hs(window)}function bs(e){return e.chains.some((t)=>t.startsWith("solana:"))&&typeof e.features["standard:connect"]?.connect==="function"&&typeof e.features["solana:signAndSendTransaction"]?.signAndSendTransaction==="function"}function wr(e,t){let n=(e?.get()??[]).filter(bs);return t?[...n].sort((a,r)=>Number(r.name===t)-Number(a.name===t)):n}var yr=(e)=>e?.find((t)=>!t.chains||t.chains.length===0||t.chains.some((n)=>n.startsWith("solana:")))??null;async function xn(e,t={}){let n=e.features["standard:connect"];try{let{accounts:a}=await n.connect(t.silent?{silent:!0}:void 0),r=yr(a)??yr(e.accounts);if(!r){if(t.silent)return null;throw Error("No wallet account available")}return{wallet:e,account:r,address:r.address}}catch(a){if(t.silent)return null;throw a}}var ws="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function vs(e){let t=0;while(t<e.length&&e[t]===0)t++;let n=[];for(let a=t;a<e.length;a++){let r=e[a];for(let o=0;o<n.length;o++)r+=n[o]<<8,n[o]=r%58,r=r/58|0;while(r>0)n.push(r%58),r=r/58|0}return"1".repeat(t)+n.reverse().map((a)=>ws[a]).join("")}function xs(e){let t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function vr(e){let t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}async function xr(e,t,n){let a=e.wallet.features["solana:signAndSendTransaction"],[r]=await a.signAndSendTransaction({account:e.account,transaction:vr(t),chain:`solana:${n}`});if(!r?.signature)throw Error("The wallet returned no signature");return vs(r.signature)}async function kr(e,t,n){let a=e.wallet.features["solana:signTransaction"];if(typeof a?.signTransaction!=="function")throw Error("This wallet cannot sign this payment");let[r]=await a.signTransaction({account:e.account,transaction:vr(t),chain:`solana:${n}`});if(!r?.signedTransaction)throw Error("The wallet returned no transaction");return xs(r.signedTransaction)}async function vt(e,t){let[n,a]=await Promise.allSettled([ve(e.rpc_urls,"getTokenAccountsByOwner",[t,{mint:e.token.address},{encoding:"jsonParsed"}]),ve(e.rpc_urls,"getBalance",[t,{commitment:"confirmed"}])]);if(n.status==="rejected")throw n.reason;let r=n.value?.value??[],o=0n;for(let i of r){let l=i.account?.data?.parsed?.info?.tokenAmount?.amount;if(typeof l==="string"&&/^\d+$/.test(l))o+=BigInt(l)}let s=a.status==="fulfilled"?a.value?.value:void 0;return{usdc:o,native:typeof s==="number"||typeof s==="string"?BigInt(s):null}}async function Cr(e,t,n={}){let a=n.intervalMs??1500,r=Date.now()+(n.timeoutMs??90000);for(;;){if(n.signal?.aborted)return"unknown";let s=(await ve(e,"getSignatureStatuses",[[t],{searchTransactionHistory:!0}]).catch(()=>null))?.value?.[0];if(s?.err)return"failed";if(s?.confirmationStatus==="confirmed"||s?.confirmationStatus==="finalized")return"confirmed";if(Date.now()>r)return"unknown";await new Promise((i)=>setTimeout(i,a))}}function ie(e){return!!e&&typeof e==="object"}function Pr(e){return{txs:e.txs,chain:{name:e.chainName,add_chain:e.addChain},estimated_seconds:e.estimatedSeconds,pay:{amount:e.pay.amount.toString(),symbol:e.pay.symbol,decimals:e.pay.decimals},gas_estimate:e.gasEstimate===null?null:e.gasEstimate.toString()}}var ks=new Set(["from","value","validAfter","validBefore","nonce","signature"]);function Cs(e){if(!ie(e))throw Error("Unexpected pay response");if(ie(e.sign)&&ie(e.sign.typedData)){let i=ie(e.sign.extra)?Object.fromEntries(Object.entries(e.sign.extra).filter((l)=>typeof l[1]==="string"&&!ks.has(l[0]))):{};return{type:"sign",typedData:e.sign.typedData,extra:i}}let t=e.txs;if(!Array.isArray(t)||t.length===0)throw Error("Unexpected pay response");let n=ie(e.chain)?e.chain:{},a=typeof e.estimated_seconds==="number"?e.estimated_seconds:null,r=t[0];if(ie(r)&&r.kind==="solana"){if(typeof r.transaction!=="string"||!r.transaction)throw Error("Unexpected pay response");return{type:"solana",transaction:r.transaction,sponsored:r.sponsored===!0,estimatedSeconds:a}}let o=t.map((i)=>{if(!ie(i)||typeof i.to!=="string"||typeof i.data!=="string")throw Error("Unexpected pay response");return{description:typeof i.description==="string"?i.description:"",to:i.to,data:i.data,value:typeof i.value==="string"||typeof i.value==="number"?String(i.value):"0"}}),s=ie(e.pay)&&typeof e.pay.amount==="string"&&/^\d+$/.test(e.pay.amount)&&typeof e.pay.symbol==="string"&&typeof e.pay.decimals==="number"?{amount:BigInt(e.pay.amount),symbol:e.pay.symbol,decimals:e.pay.decimals}:null;return{type:"evm",txs:o,chainName:typeof n.name==="string"?n.name:null,addChain:ie(n.add_chain)?n.add_chain:null,estimatedSeconds:a,pay:s,gasEstimate:typeof e.gas_estimate==="string"&&/^\d+$/.test(e.gas_estimate)?BigInt(e.gas_estimate):null}}function Ss(e){if(!ie(e)||typeof e.signature!=="string"||!e.signature)throw Error("Unexpected pay response");return e.signature}function Ps(e,t,n){return new ne({kind:"insufficient",message:B(n.insufficient,{balance:we(e),needed:we(t)}),balance:e.toString(),needed:t.toString()})}function As(e,t,n){let a=(r,o)=>`${fn(r,t.decimals,o)} ${t.symbol}`;return new ne({kind:"insufficient",message:B(n.insufficient,{balance:a(e,"down"),needed:a(t.amount,"up")}),balance:e.toString(),needed:t.amount.toString()})}async function Rs(e,t){try{if(t.kind==="solana")return await vt(e,t.account);try{if(e.token.native){let r=await bn(t.provider,t.account);return{usdc:r,native:r}}let n=await pr(t.provider,e.token.address,t.account),a=await bn(t.provider,t.account).catch(()=>null);return{usdc:n,native:a}}catch{return await wt(e,t.account)}}catch{return null}}async function Sr(e,t){let n=()=>e().then(()=>!0,()=>!1),[a,r]=await Promise.all([n(),t()]);switch(r){case"failed":throw Error("Transaction failed on chain");case"confirmed":if(!a)await n();return;case"unknown":return}}async function Ar(e){try{return await Es(e)}catch(t){if(ct(t))return{estimatedSeconds:null};throw t}}async function Es(e){let{option:t,session:n,api:a,hooks:r,copy:o}=e,s=BigInt(e.amount);if(n.kind==="evm")r.step("switching"),await fr(n.provider,Number(t.chain.id),t.add_chain);r.step("checking");let i=await Rs(t,n),l=F(t);if(!l){if(i&&i.usdc<s)throw Ps(i.usdc,s,o);if(i&&i.native===0n&&dn(t))throw new ne({kind:"no_gas",message:o.noGas})}let u=Cs(await a.pay(t.id,n.account));if(l){if(u.type!=="evm"||!u.pay)throw Error("Unexpected pay response");let g=mn(t,i?{status:"ok",...i}:void 0,{pay:u.pay,gasEstimate:u.gasEstimate});if(g==="not_enough")throw As(i?.usdc??0n,u.pay,o);if(g==="needs_gas")throw new ne({kind:"no_gas",message:o.noGas})}if(u.type==="sign"&&n.kind==="evm"){r.step("signing");let g=await mr(n.provider,n.account,u.typedData);return r.step("submitting"),await a.authorize({...g,...u.extra}),{estimatedSeconds:null}}if(u.type==="evm"&&n.kind==="evm"){r.step("signing");let g=await hr(n.provider,n.account,u.txs,{signal:e.signal,intervalMs:e.intervalMs,onStep:(h)=>r.tx?.(h,u.txs.length)});return r.step("submitting"),await Sr(()=>a.fundingAttempt(u.chainName??t.chain.name,g,l?{rail:"lifi",buyer:n.account}:void 0),()=>vn(n.provider,g,{signal:e.signal,intervalMs:e.intervalMs,timeoutMs:e.timeoutMs})),{estimatedSeconds:u.estimatedSeconds}}if(u.type==="solana"&&n.kind==="solana"){r.step("signing");let g=String(t.chain.id),h=u.sponsored?Ss(await a.submitSolana(await kr(n.session,u.transaction,g))):await xr(n.session,u.transaction,g);return r.step("submitting"),await Sr(()=>a.fundingAttempt(t.chain.name,h),()=>Cr(t.rpc_urls,h,{signal:e.signal,intervalMs:e.intervalMs,timeoutMs:e.timeoutMs})),{estimatedSeconds:u.estimatedSeconds}}throw Error("Unexpected pay response")}import{jsx as x,jsxs as K,Fragment as Ct}from"react/jsx-runtime";function kt(e,t,n=!0){let a=P(!0);I(()=>{if(a.current){a.current=!1;return}if(n)e.current?.focus({preventScroll:!1})},[t])}var Ns="your wallet",Er=(e)=>e&&e!==Ns?e:null;function Ls(e){let[t,n]=N([]),a=P([]),[r,o]=N(null),s=P(null),i=P(!1),l=P(new Set),u=W((L)=>{s.current=L,o(L)},[]);I(()=>{if(!e)return;return ur((L)=>{a.current=L,n(L)})},[e]),I(()=>{if(!e||s.current||i.current||t.length===0)return;let L=fe().wallet,p=t.find((f)=>f.name===L)??(t.length===1?t[0]:void 0);if(!p||l.current.has(p.id))return;l.current.add(p.id),yn(p.provider).then((f)=>{if(f&&!s.current&&!i.current)u({provider:p.provider,account:f,name:p.name})})},[e,t,u]);let g=r?.provider;I(()=>{if(!g)return;let L=(p)=>{let f=Array.isArray(p)&&typeof p[0]==="string"?p[0]:null,C=s.current;if(C?.provider===g)u(f?{...C,account:f}:null)};return g.on?.("accountsChanged",L),()=>g.removeListener?.("accountsChanged",L)},[g,u]);let h=W(async(L)=>{let p=a.current,f=L?L:p.find((z)=>z.name===fe().wallet)??(p.length===1?p[0]:null)??(()=>{let z=lr(fe().wallet);return z?{provider:z,name:bt(z)}:null})();if(!f)return null;let te=(s.current?.provider===f.provider?s.current.account:null)??await yn(f.provider)??await wn(f.provider);i.current=!1;let D={provider:f.provider,account:te,name:f.name};return u(D),rn({wallet:D.name}),D},[u]),k=W(()=>{i.current=!0,u(null)},[u]),A=W(async()=>{let L=s.current;if(!L)return;let p=await dr(L.provider);u({...L,account:p})},[u]);return{wallets:t,conn:r,connRef:s,connect:h,disconnect:k,switchAccount:A}}var Ts=/^data:image\/(png|svg\+xml|webp|jpeg|gif);/i,Is=(e)=>{let t=e.icon;return typeof t==="string"&&Ts.test(t)?t:null};function Os(e){let[t,n]=N([]),[a,r]=N(null),o=P(null),s=P(!1),i=W((g)=>{o.current=g,r(g)},[]);I(()=>{if(!e)return;let g=br(),h=()=>n(wr(g,fe().wallet));return h(),g?.on(h)},[e]),I(()=>{if(!e||s.current)return;let g=fe().wallet;if(!g)return;let h=t.find((A)=>A.name===g);if(!h)return;let k=!0;return xn(h,{silent:!0}).then((A)=>k&&A&&!o.current&&!s.current&&i({session:A,name:h.name})),()=>{k=!1}},[e,t,i]);let l=W(async(g)=>{let h=g??t[0];if(!h)return null;let k=(o.current?.session.wallet===h?o.current.session:null)??await xn(h);if(!k)return null;s.current=!1;let A={session:k,name:h.name};return i(A),rn({wallet:h.name}),A},[i,t]),u=W(()=>{s.current=!0,o.current?.session.wallet.features["standard:disconnect"]?.disconnect?.().catch(()=>{}),i(null)},[i]);return{wallets:t,conn:a,connRef:o,connect:l,disconnect:u}}var Ms=(e)=>new Promise((t)=>setTimeout(t,e));function _s({orderId:e,createCharge:t,returnUrl:n,onPaid:a,statusUrl:r,className:o,appearance:s="auto",onStatusChange:i,onError:l,copy:u,successSlot:g,defaultOpen:h=!1,manualPayment:k=!1,presentation:A="modal",merchantName:L}){let p=A==="inline",f=xt(()=>Aa(u),[u]),C=P(f);C.current=f;let te=Nr(),[D,z]=N(h||p),[de,j]=N(h||p),[V,xe]=N("pick"),[Re,Ir]=N("evm"),[Or,Cn]=N(null),[Mr,Ee]=N(!1),[_r,Sn]=N(0),[zs,Pn]=N(null),[R,An]=N(null),[ke,Pt]=N(null),[q,At]=N(null),[qe,Rn]=N(null),[O,ce]=Rr(Ma,an),[Rt,En]=N({status:"loading",list:[]}),[Wr,Br]=N(0),[G,Et]=N({}),[Ke,Ne]=Rr(rr,{status:"idle"}),[Dr,Ur]=N(0),[Nt,Nn]=N(null),[jr,Ge]=N(!1),[Le,Ln]=N(!1),[Te,re]=N(null),[Qe,Lt]=N(null),[zr,Tn]=N(!1),[Hr,$r]=N(!1),[Fr,Ie]=N(""),In=P(a);In.current=a;let On=P(r);On.current=r;let Mn=P(i);Mn.current=i;let _n=P(l);_n.current=l;let Wn=P(t);Wn.current=t;let Bn=P(Ke);Bn.current=Ke;let Dn=P(!1),T=Ls(de),E=Os(de),Oe=P(null),oe=xt(()=>R?cn(R.serviceUrl,R.chargeId,R.clientSecret):null,[R]),Tt=P(0),Ye=P(null),Un=W(()=>{if(Ye.current)return Ye.current;let m=(async()=>{let y={ok:!1,status:503,error:C.current.createFailed};for(let v=0;v<3;v++){try{y=await Wn.current()}catch{y={ok:!1,status:503,error:C.current.createFailed}}if(y?.ok){let w=ka(y.charge);return w?{ok:!0,charge:w}:{ok:!1,status:503,error:C.current.createFailed}}if(y.status<500)return y;if(v<2)await Ms(700*2**v)}return y})().finally(()=>{Ye.current=null});return Ye.current=m,m},[]),It=P(0),se=W(async(d)=>{let m=++Tt.current;if(!d)An(null),Oe.current=null,At(null),Pt(null),Rn(null),ce({type:"reset"});let y=await Un();if(y.ok){if(m===Tt.current)Oe.current=y.charge,An(y.charge),At({status:y.charge.status,confirmed:y.charge.confirmed,confirmation:y.charge.confirmation,funded_amount:null}),Pt(null);return{ok:!0,charge:y.charge}}let v=Ia(y,C.current);if(!d&&m===Tt.current)Pt(v);return{ok:!1,problem:v}},[Un]),jn=P(null);I(()=>{if(!de)return;if(jn.current===e)return;jn.current=e,It.current=0,se(!1)},[de,e,se]),I(()=>{$r(tn(navigator.userAgent))},[]),I(()=>{if(!oe||!R)return;let d=!0;return oe.options().then((m)=>{if(!d)return;let y=Qa(m);En(y.length?{status:"ready",list:y}:{status:"error",list:[]})}).catch(()=>{if(!d)return;En((m)=>m.status==="ready"?m:{status:"error",list:[]})}),()=>{d=!1}},[oe,R,Wr]);let U=Rt.list,Ot=P(U);Ot.current=U;let he=R?.amount??"0",zn=P({evm:0,solana:0}),pe=W(async(d,m)=>{let y=Ot.current.filter((w)=>w.kind===d);if(y.length===0)return;let v=++zn.current[d];Et((w)=>({...w,...Object.fromEntries(y.map((S)=>[S.id,w[S.id]?.status==="ok"?w[S.id]:{status:"loading"}]))})),Sn((w)=>w+1);try{await Promise.all(y.map(async(w)=>{let S;try{let M=d==="evm"?await wt(w,m):await vt(w,m);S={status:"ok",usdc:M.usdc,native:M.native}}catch{S={status:"error"}}if(v===zn.current[d])Et((M)=>({...M,[w.id]:S.status==="error"&&M[w.id]?.status==="ok"?M[w.id]:S}))}))}finally{Sn((w)=>w-1)}},[]),Je=U.map((d)=>d.id).join("|"),ye=T.conn?.account??null,Mt=E.conn?.session.address??null,Ve=W((d)=>{Et((m)=>{let y={...m};for(let v of Ot.current)if(v.kind===d)delete y[v.id];return y})},[]);I(()=>{if(Ve("evm"),ye&&Je)pe("evm",ye)},[ye,Je,pe,Ve]),I(()=>{if(Ve("solana"),Mt&&Je)pe("solana",Mt)},[Mt,Je,pe,Ve]);let Q={evm:!!T.conn,solana:!!E.conn},Xe=new Set(U.map((d)=>d.kind)).size>1,Hn=P(!1),{evm:$n,solana:Fn}=Q;I(()=>{if(U.length===0)return;let d=pn(U,G,{evm:$n,solana:Fn}),m=d.length>0?d:U;Nn((y)=>{let v=y&&m.some((w)=>w.id===y);if(!Hn.current){let w=Za(m,G,he);if(w)return w}return v?y:(m.find((w)=>w.default)??m[0]).id})},[U,G,he,$n,Fn]);let _=U.find((d)=>d.id===Nt)??null,_t=nr(U,G,Q,he),qn=W((d)=>{At((m)=>m&&JSON.stringify(m)===JSON.stringify(d)?m:d)},[]),Kn=q?.status==="settled"||q?.status==="expired",Wt=O.step==="processing"||O.step==="submitting";I(()=>{if(!oe||Kn)return;let d=!1,m=new AbortController,y=null,v=(M)=>{let Se=xa(M);if(Se&&!d)qn(Se)},w=()=>{oe.charge().then(v).catch(()=>{})},S=()=>{if(y||d)return;w(),y=setInterval(w,Wt?1500:3000)};if(w(),typeof ReadableStream>"u")S();else if(oe.events((M)=>{if(M.event!=="charge.updated")return;try{v(JSON.parse(M.data))}catch{}},m.signal).catch(()=>{}).then(S),Wt)y=setInterval(w,1500);return()=>{if(d=!0,m.abort(),y)clearInterval(y)}},[oe,Kn,Wt,qn]);let Bt=r===null,Gn=!!q&&q.confirmed,Dt=P(null);I(()=>{Dt.current=null},[R?.chargeId]),I(()=>{if(Bt||!R||!(Gn||O.step==="processing")||qe?.confirmation==="final")return;let d=Sa(R.chargeId,On.current);if(!d)return;let m=!1,y=async()=>{try{let w=await fetch(d,{cache:"no-store"}),S=w.ok?Ca(await w.json().catch(()=>null)):null;if(!S||m)return;if(Rn(S),S.confirmed&&Dt.current!==S.confirmation)Dt.current=S.confirmation,In.current?.(S)}catch{}};y();let v=setInterval(y,O.step==="processing"?1500:3000);return()=>{m=!0,clearInterval(v)}},[Bt,R,Gn,O.step,qe?.confirmation]),I(()=>{if(q?.status!=="expired"||O.step!=="idle")return;if(It.current>=3)return;It.current+=1,se(!0)},[q,O.step,se]);let Me=Bt?q?.confirmed?q.confirmation:null:qe?.confirmed?qe.confirmation:null,Y=!!Me;I(()=>{if(Y)ce({type:"paid"})},[Y]),I(()=>{if(O.step!=="processing"){Tn(!1);return}let d=setTimeout(()=>Tn(!0),30000);return()=>clearTimeout(d)},[O.step]);let Ze=R?we(R.amount):"",H=O.problem??null,X=O.step!=="idle"&&O.step!=="paid";Dn.current=X;let le=_&&F(_)?_:null,et=le?G[le.id]:void 0,Ut=!!le&&!!ye&&(et?.status==="error"||et?.status==="ok"&&et.usdc>0n),tt=le?.id??null,qr=q?.funded_amount??"";I(()=>{if(Ne({type:"reset"}),!oe||!R||!tt||!Ut||!ye)return;let d=!0,m=null,y=async()=>{if(!d)return;if(Dn.current){m=setTimeout(y,5000);return}Ne({type:"fetch"});try{let v=gn(await oe.lifiQuote(tt,ye));if(!d)return;Ne({type:"ok",quote:v,optionId:tt}),m=setTimeout(y,sr(v,Date.now()))}catch(v){if(!d)return;if(ct(v))m=setTimeout(y,5000);else Ne({type:"fail"})}};return m=setTimeout(y,350),()=>{if(d=!1,m)clearTimeout(m)}},[oe,R?.chargeId,tt,Ut,ye,qr,Dr]);let _e=ke?"failed":!de?"ready":!R||!q?"loading":Me==="final"||q.status==="settled"?"settled":Me?"paid":H?"problem":O.step==="signing"?"confirming":O.step==="connecting"||O.step==="switching"||O.step==="checking"||Le?"connecting":O.step==="submitting"||O.step==="processing"?"processing":"ready",Qn=P(null);I(()=>{if(Qn.current===_e)return;Qn.current=_e,Mn.current?.(_e)},[_e]);let jt=ke??H;I(()=>{if(jt)_n.current?.(jt)},[jt]);let Yn=T.conn?{name:Er(T.conn.name),address:T.conn.account}:null,Jn=E.conn?{name:Er(E.conn.name),address:E.conn.session.address}:null,be=_?.kind==="solana"?Jn:_?.kind==="evm"?Yn:Yn??Jn,zt=be?.name??null,nt=Qe&&Qe.total>1&&O.step==="signing"?lt(f,Qe,zt):Wa(O.step,Ze,f,zt);I(()=>{if(Me)Ie(f.received);else if(H?.kind==="rejected")Ie(H.message);else if(X)Ie(nt);else Ie("")},[Me,H,X,nt,f]);let Ht=P(null),at=P(null),Vn=P(null),$t=P(null);kt(Vn,Y,Y),kt(at,H,!!H&&H.kind!=="rejected"),kt(Ht,H?.kind==="rejected"?H:null,H?.kind==="rejected"),kt($t,V,V!=="pick");let Xn=W((d,m)=>{ce({type:"failed",problem:He(d,{step:m,copy:C.current})})},[]),Kr=()=>tn(navigator.userAgent)?C.current.noWalletMobile:C.current.noWallet,We=W((d)=>{Ir(d),re(null),Ge(!1),xe("wallets")},[]),Gr=W(async()=>{if(!_||Le)return;if(re(null),Xe&&T.wallets.length>0&&E.wallets.length>0&&!T.conn&&!E.conn){We("any");return}let m=Xe&&!T.conn&&!E.conn&&T.wallets.length===0&&E.wallets.length>0?"solana":_.kind;if(m==="evm"?T.wallets.length>1&&!T.conn:E.wallets.length>1&&!E.conn){We(m);return}Ln(!0);try{if(!(m==="evm"?await T.connect():await E.connect()))re(m==="evm"?Kr():C.current.noWalletForOption)}catch(y){let v=He(y,{step:"connecting",copy:C.current});re(v.kind==="rejected"?C.current.rejectedConnect:v.message)}finally{Ln(!1)}},[_,Le,T,E,We,Xe]),Zn=(d,m)=>`${m}:${d.name}`,ea=V==="wallets"?fe().wallet:void 0,ta=(d)=>T.wallets.map((m)=>({id:`${d}${m.id}`,name:m.name,icon:m.icon,lastUsed:m.name===ea})),na=(d)=>E.wallets.map((m,y)=>({id:`${d}${Zn(m,y)}`,name:m.name,icon:Is(m),lastUsed:m.name===ea})),Qr=V!=="wallets"?[]:Re==="evm"?ta(""):Re==="solana"?na(""):[...ta("evm|"),...na("solana|")],Yr=async(d)=>{Cn(d),re(null);let m=Re==="any"?/^(evm|solana)\|(.*)$/.exec(d):null,y=m?m[1]:Re==="any"?"evm":Re,v=m?m[2]:d;try{let w=!1;if(y==="evm"){let S=T.wallets.find((M)=>M.id===v);w=!!S&&!!await T.connect(S)}else{let S=E.wallets.findIndex((Se,J)=>Zn(Se,J)===v),M=E.wallets[S];w=!!M&&!!await E.connect(M)}if(w)xe("pick")}catch(w){let S=He(w,{step:"connecting",copy:C.current});re(S.kind==="rejected"?C.current.rejectedPick:S.message)}finally{Cn(null)}},ge=W(async()=>{if(T.connRef.current)await pe("evm",T.connRef.current.account);if(E.connRef.current)await pe("solana",E.connRef.current.session.address)},[T.connRef,E.connRef,pe]),aa=W(async()=>{ce({type:"reset"}),re(null),await ge()},[ge]),Jr=(d)=>d.kind==="evm"?T.conn?{kind:"evm",provider:T.conn.provider,account:T.conn.account}:null:E.conn?{kind:"solana",session:E.conn.session,account:E.conn.session.address}:null,Vr=W(async()=>{let d=_,m=d?Jr(d):null;if(!d||!m||!Oe.current)return;ce({type:"start"}),Lt(null),Pn(null),Ee(!1);let y="connecting",v=Oe.current;try{for(let w=0;;w++)try{if(v.expiresAt&&Date.parse(v.expiresAt)-Date.now()<30000){let J=await se(!0);if(!J.ok)throw new ne(J.problem);v=J.charge}let S=cn(v.serviceUrl,v.chargeId,v.clientSecret),M=F(d)?{...S,pay:async(J,Vt)=>{let ot=Bn.current,mo=ot.status==="ready"?ot.quote:ot.status==="loading"?ot.previous:null,Xt=gn(await S.lifiQuote(J,Vt));if(Ne({type:"ok",quote:Xt,optionId:J}),or(mo,Xt))throw new ne({kind:"service",message:C.current.priceChanged});return Pr(Xt)}}:S,Se=await Ar({option:d,session:m,amount:v.amount,api:M,copy:C.current,hooks:{step:(J)=>{y=J,ce({type:"step",step:J})},tx:(J,Vt)=>Lt({i:J,total:Vt})}});Pn(Se.estimatedSeconds),ce({type:"submitted"});return}catch(S){if(w===0&&Oa(S)){let M=await se(!0);if(M.ok){v=M.charge;continue}ce({type:"failed",problem:{...M.problem}});return}throw S}}catch(w){if(w instanceof ne&&(w.problem.kind==="insufficient"||w.problem.kind==="no_gas"))ge();Xn(w,y)}finally{Lt(null)}},[_,T.conn,E.conn,se,Xn,ge]),Xr=xt(()=>Va(U,G,{evm:Q.evm,solana:Q.solana},he),[U,G,Q.evm,Q.solana,he]),ra=xt(()=>{let d=Xa(U.map(ht));return new Map(U.map((m,y)=>[m.id,{...d[y],icon:cr(m)}]))},[U]),Zr=(d)=>d==="not_enough"?f.notEnough:d==="needs_wallet"?f.needsOtherWallet:d==="unreadable"?f.couldntCheck:null,eo=new Set(pn(U,G,Q).map((d)=>d.id)),to=Xr.filter((d)=>eo.has(d.id)).map((d)=>{let m=Ja(d,G[d.id],he,Q);return{id:d.id,chain:ht(d),badge:ra.get(d.id)??null,balanceText:m.balanceText,disabled:m.disabled,reason:Zr(m.reason),loading:m.loading,...F(d)?{symbol:d.token.symbol,logo:d.token.logo}:{}}}),ue=ar(_,Q,_?G[_.id]:void 0,he,Ke),Ft=ue.reason==="needs_gas",qt=_t==="empty"||_t==="short",oa=qt||Ft||H?.kind==="insufficient"||H?.kind==="no_gas",no=X?{label:nt,disabled:!0,busy:!0,onClick:()=>{},ref:Ht}:{label:(()=>ue.kind==="connect"?Le?f.connectingWallet:f.connectWallet:ue.reason==="checking"?le&&et?.status==="ok"?f.youPayChecking:f.checking:ue.reason==="not_enough"?le?B(f.notEnoughToken,{symbol:le.token.symbol}):f.notEnoughUsdc:ue.reason==="needs_gas"?f.needsGas:ue.reason==="unavailable"?f.optionUnavailable:B(f.pay,{amount:Ze}))(),disabled:ue.disabled||!R,busy:Le,spinner:ue.reason==="checking",onClick:()=>void(ue.kind==="connect"?Gr():Vr()),ref:Ht};I(()=>{if(!oa||!D)return;let d=()=>{if(document.visibilityState==="visible")ge()};return window.addEventListener("focus",d),document.addEventListener("visibilitychange",d),()=>{window.removeEventListener("focus",d),document.removeEventListener("visibilitychange",d)}},[oa,D,ge]);let rt=(qt||Ft)&&D;I(()=>{if(!rt)return;let d=Date.now(),m=setInterval(()=>{if(Date.now()-d>120000)clearInterval(m);else ge()},5000);return()=>clearInterval(m)},[rt,ge]);let Be=U.filter((d)=>Q[d.kind]).map((d)=>{let m=G[d.id];return m?.status==="ok"?`${d.id}:${m.usdc}:${m.native??""}`:m?.status??"-"}).join("|"),Kt=P(null),sa=P(!1);I(()=>{if(!Be.includes("loading")&&!Be.includes("-")){if(sa.current&&Kt.current!==null&&Kt.current!==Be)Ie(C.current.balanceUpdated);Kt.current=Be}sa.current=rt},[Be,rt]);let ao=W(()=>{j(!0),xe("pick"),Ge(!1),Ee(!1),z(!0)},[]),De=W(()=>{z(!1)},[]);I(()=>{if(!D||O.step!=="idle")return;let d=Oe.current;if(d?.expiresAt&&Date.parse(d.expiresAt)-Date.now()<120000)se(!0)},[D]);let ia=W(()=>{if(X&&!Y)Ee((d)=>!d);else De()},[X,Y,De]);I(()=>{if(!X||Y)Ee(!1)},[X,Y]);let ca={className:`sc-root${o?` ${o}`:""}`,"data-appearance":s,"data-testid":"payments-checkout","data-state":_e},Gt=x("div",{className:"sc-live",role:"status","aria-live":"polite","aria-atomic":"true","data-testid":"sc-live",children:Fr}),Qt=Pa(n,typeof window>"u"?"":window.location.origin),Yt=q?.status==="underpaid"&&R?Na(R.amount,q.funded_amount):null,ro=be&&_?{onCopy:()=>{try{navigator.clipboard?.writeText(be.address)?.catch(()=>{})}catch{}},onSwitch:()=>{let d=_.kind;if(Xe&&T.wallets.length>0&&E.wallets.length>0)We("any");else if(d==="evm"?T.wallets.length>1:E.wallets.length>1)We(d);else if(d==="evm")T.switchAccount().catch((m)=>{let y=He(m,{step:"connecting",copy:C.current});if(y.kind!=="rejected")re(y.message)});else E.disconnect(),E.connect().catch(()=>{})},onDisconnect:()=>{if(Ge(!1),re(null),_.kind==="evm")T.disconnect();else E.disconnect()}}:null,la=x("button",{type:"button",className:"sc-sec",onClick:()=>void aa(),children:f.checkAgain}),oo=x("button",{type:"button",className:"sc-link",onClick:()=>void aa(),children:f.checkAgain}),so=k?x("button",{type:"button",className:"sc-link",onClick:()=>xe("manual"),children:f.payAnotherWay}):null,Ce=typeof window>"u"?"":window.location.href,io=Te===f.noWallet||Te===f.noWalletMobile,co=Yt!==null&&Yt>0n?B(f.partial,{received:we(BigInt(q?.funded_amount||"0")),remaining:we(Yt)}):Te?K(Ct,{children:[Te,Hr&&io&&_?.kind==="evm"&&(st(Ce)||it(Ce))&&K("div",{className:"sc-actions",children:[st(Ce)&&x("a",{className:"sc-link",href:st(Ce),children:f.openInWalletApp}),it(Ce)&&x("a",{className:"sc-link",href:it(Ce),children:f.openInPhantom})]})]}):qt?K(Ct,{children:[_t==="empty"?f.noUsdc:f.insufficientAll,la]}):Ft?K(Ct,{children:[f.needsGasReason,la]}):null,lo=(d)=>{switch(d.kind){case"insufficient":case"no_gas":return oo;case"expired":case"conflict":return x("button",{type:"button",className:"sc-link",onClick:()=>void se(!1),children:f.startNew});case"network":case"service":case"unknown":case"tx_failed":return x("button",{type:"button",className:"sc-link",onClick:()=>ce({type:"reset"}),children:f.tryAgain});default:return null}},ua=!ke&&R&&Rt.status==="error"?{kind:"service",message:f.service}:null,uo=ke?x(ft,{problem:ke,copy:f,noticeRef:at,children:x("button",{type:"button",className:"sc-link",onClick:()=>void se(!1),children:ke.kind==="conflict"?f.startNew:f.tryAgain})}):ua?K(ft,{problem:ua,copy:f,noticeRef:at,children:[x("button",{type:"button",className:"sc-link",onClick:()=>Br((d)=>d+1),children:f.tryAgain}),so]}):H?x(ft,{problem:H,copy:f,noticeRef:at,children:lo(H)}):null,po=!!R&&!!q&&Rt.status==="ready",go=Y?"done":V==="manual"&&R?"manual":!po?"loading":X?"paying":V==="wallets"?"wallets":"pick",Jt=R?Ya(R,U):null,fo=R&&Jt?x(Ws,{entry:{address:R.chargeAddress,chain:ht(Jt),badge:ra.get(Jt.id)??null},copy:f,amountText:Ze}):null,da=_&&Q[_.kind]?tr(_,G[_.id],f):[],pa=x(qa,{copy:f,titleId:te,titleRef:$t,title:Ba(f,L),amountText:Ze,phase:go,wallet:be?{name:be.name,short:Zt(be.address),address:be.address}:null,walletActions:ro,walletPicker:V==="wallets"?{wallets:Qr,busyId:Or,onPick:(d)=>void Yr(d)}:null,onClose:p?null:ia,onBack:()=>xe("pick"),options:to,selectedId:Nt,menuOpen:jr,onMenuChange:Ge,onSelect:(d)=>{Hn.current=!0,re(null),Nn(d);let m=U.find((v)=>v.id===d),y=m?.kind==="evm"?T.connRef.current?.account:E.connRef.current?.session.address;if(m&&y&&G[d]?.status==="error")pe(m.kind,y)},decorator:da,payLine:le&&Q.evm&&Ut?ir(le,Ke,f):null,onPayLineRetry:()=>Ur((d)=>d+1),decoratorKey:Nt,refreshing:_r>0&&da.length>0,cta:no,message:V==="wallets"?Te:co,notice:uo,stages:X?_a(O.step):null,tx:Qe,walletName:zt,slow:zr,closeGuard:Mr?{onStay:()=>Ee(!1),onClose:De}:null,done:Y&&R?{receipt:Ea(R.chargeId),finalizing:!1,slot:g,returnHref:Qt,ref:Vn,onDone:p?void 0:De}:null,manual:fo,onPayAnotherWay:R&&k?()=>xe("manual"):null});if(p)return K("div",{...ca,children:[x("style",{children:on}),Gt,pa]});let ga=X&&!Y?nt:null;return K("div",{...ca,children:[x("style",{children:on}),!D&&Gt,Y&&!D?K("div",{"data-testid":"sc-inline-done",children:[x("p",{className:"sc-inline-ok",role:"status",children:f.received}),g?x("div",{className:"sc-slot",children:g}):null,Qt&&x("a",{className:"sc-link-a",href:Qt,children:f.returnToStore})]}):x("button",{type:"button",className:"sc-btn","aria-haspopup":"dialog","aria-busy":!!ga,"data-testid":"sc-trigger",onClick:ao,children:x("span",{children:ga??f.trigger})}),K(Fa,{open:D,onClose:ia,onBackdrop:X&&!Y?()=>{}:De,titleId:te,initialFocus:$t,children:[Gt,pa]})]})}function kn(e,t){return e.split("{network}").flatMap((n,a)=>a===0?[n]:[x("strong",{className:"sc-net",children:t},a),n])}function Ws({entry:e,copy:t,amountText:n}){let[a,r]=N(!1),[o,s]=N(!1),i=P(null),l=P(null),u=Nr();I(()=>()=>{if(i.current)clearTimeout(i.current)},[]);let g=(k)=>{r(k),s(!1)};async function h(k){let A=!1;try{await navigator.clipboard.writeText(k),A=!0}catch{let L=l.current;if(L){let p=document.createRange();p.selectNodeContents(L);let f=window.getSelection();f?.removeAllRanges(),f?.addRange(p);try{A=document.execCommand("copy")}catch{A=!1}}}if(A){if(s(!0),i.current)clearTimeout(i.current);i.current=setTimeout(()=>s(!1),2000)}}return K("div",{"data-testid":"sc-manual",children:[K("span",{className:"sc-chip",children:[x(dt,{badge:e.badge}),x(pt,{chain:e.chain})]}),x("div",{className:"sc-notice","data-kind":"manual",role:"note",id:u,"data-testid":"sc-manual-warning",children:kn(t.manualWarning,e.chain)}),K("label",{className:"sc-confirm",children:[x("input",{type:"checkbox",checked:a,onChange:(k)=>g(k.target.checked),"aria-describedby":u,"data-testid":"sc-manual-confirm"}),x("span",{children:kn(t.manualConfirm,e.chain)})]}),a&&K(Ct,{children:[x("p",{className:"sc-muted",children:B(t.manualIntro,{amount:n})}),x("code",{className:"sc-addr",ref:l,"data-testid":"charge-address",title:Zt(e.address),children:e.address}),x("div",{className:"sc-two",children:K("button",{type:"button",className:"sc-btn",onClick:()=>void h(e.address),"data-testid":"sc-copy",children:[o?x($e,{size:18}):x(sn,{}),x("span",{children:o?t.copied:t.copyAddress})]})})]}),x("p",{className:"sc-live",role:"status","aria-live":"polite",children:o?t.copied:""}),x("p",{className:"sc-muted",children:t.manualWaiting}),x("p",{className:"sc-muted","data-testid":"sc-manual-own-wallet",children:kn(t.manualOwnWallet,e.chain)})]})}var Lr={ok:!1,status:503,error:"Checkout is temporarily unavailable."},Tr=(e)=>!!e&&typeof e==="object"&&!Array.isArray(e),St=(e)=>typeof e==="string"?e:void 0,Bs=(e)=>Tr(e)?{error:St(e.error),code:St(e.code)}:{};async function Ds(e){let t=new Headers({"content-type":"application/json"}),n=typeof e==="function"?await e():e;if(n)new Headers(n).forEach((a,r)=>t.set(r,a));return t}function Us(e,t,n){let a=(()=>{try{return n(t)??{}}catch{return{}}})(),r=St(a.code);return{ok:!1,status:e,error:St(a.error)??"Checkout is temporarily unavailable.",...r?{code:r}:{}}}async function js(e,t,n={}){let{method:a="POST",credentials:r,signal:o,selectCharge:s=(l)=>l,selectError:i=Bs}=n;try{let u=await(n.fetch??fetch)(e,{method:a,headers:await Ds(n.headers),body:typeof t==="string"?t:JSON.stringify(t),...r?{credentials:r}:{},...o?{signal:o}:{}}),g=await u.json().catch(()=>null);if(!u.ok)return Us(u.status,g,i);let h=s(g);return Tr(h)?{ok:!0,charge:h}:Lr}catch{return Lr}}export{_s as CheckoutWidget,js as postCreateCharge};
@@ -0,0 +1,2 @@
1
+ export { createRioClient, RioError } from "./lib/rio-client";
2
+ export type { CreateChargeInput, CreateChargeOptions, RioClient, RioClientOptions } from "./lib/rio-client";
package/dist/client.js ADDED
@@ -0,0 +1 @@
1
+ class a extends Error{status;code;constructor(e,r,s){super(s);this.name="RioError",this.status=e,this.code=r}}var l=(e)=>!!e&&typeof e==="object"&&!Array.isArray(e),c=(e)=>typeof e==="string"?e:void 0,m=(e)=>["localhost","127.0.0.1","[::1]"].includes(e.hostname),p=(e)=>{if(!e)throw TypeError("createRioClient needs a serviceUrl (or the RIO_SERVICE_URL environment variable).");let r;try{r=new URL(e)}catch{throw TypeError("createRioClient: serviceUrl is not a URL.")}if(r.username||r.password)throw TypeError("createRioClient: serviceUrl must not contain credentials.");if(r.protocol!=="https:"&&!(r.protocol==="http:"&&m(r)))throw TypeError("createRioClient: serviceUrl must be https (http only for localhost).");return`${r.origin}${r.pathname.replace(/\/+$/,"")}`},C=(e)=>({amount:e.amount,external_ref:e.externalRef,...e.origin!==void 0?{origin:e.origin}:{},...e.merchantId!==void 0?{merchant_id:e.merchantId}:{},...e.returnUrl!==void 0?{return_url:e.returnUrl}:{},...e.expiresInSeconds!==void 0?{expires_in_seconds:e.expiresInSeconds}:{},...e.requireConfirmation!==void 0?{require_confirmation:e.requireConfirmation}:{},...e.speed!==void 0?{speed:e.speed}:{},...e.tags!==void 0?{tags:e.tags}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}),f=(e,r)=>{let s=r.chain;if(typeof r.id!=="string"||typeof r.client_secret!=="string"||!l(s))return null;return{chargeId:r.id,clientSecret:r.client_secret,serviceUrl:e,amount:String(r.amount),chain:s,chargeAddress:String(r.charge_address),status:r.status,confirmed:r.confirmed===!0,confirmation:r.confirmation,expiresAt:c(r.expires_at)??null}},y=(e)=>({chargeId:String(e.id),orderId:c(e.external_ref)??null,status:e.status,confirmed:e.confirmed===!0,confirmation:e.confirmation,collectedAmount:c(e.collected_amount)??null});function w(e){if(!e.apiKey)throw TypeError("createRioClient needs an apiKey.");let r=p(e.serviceUrl??(typeof process>"u"?void 0:process.env?.RIO_SERVICE_URL)),s=e.apiKey,h=async(i,o)=>{let t=await(async()=>{try{return await(e.fetch??fetch)(`${r}${i}`,{method:o.method,headers:{authorization:`Bearer ${s}`,...o.body!==void 0?{"content-type":"application/json"}:{},...o.headers},...o.body!==void 0?{body:JSON.stringify(o.body)}:{},cache:"no-store"})}catch{throw new a(0,"network_error","Could not reach the service.")}})(),n=await t.json().catch(()=>null);if(!t.ok){let d=l(n)&&l(n.error)?n.error:{};throw new a(t.status,c(d.code)??"request_failed",c(d.message)??`The request failed (${t.status}).`)}if(!l(n))throw new a(t.status,"invalid_response","The service answered with something that is not a charge.");return{status:t.status,json:n}};return{charges:{create:async(i,o={})=>{let{json:t}=await h("/v1/charges",{method:"POST",headers:{"idempotency-key":o.idempotencyKey??i.externalRef},body:C(i)}),n=f(r,t);if(n!==null)return n;let d=c(t.id);if(d===void 0)throw new a(200,"invalid_response","The service answered with something that is not a charge.");let u=await h(`/v1/charges/${encodeURIComponent(d)}/client_secret`,{method:"POST"}),g=f(r,{...t,client_secret:u.json.client_secret});if(g===null)throw new a(u.status,"client_secret_unavailable","The service did not return a client secret for this charge.");return g},retrieve:async(i)=>y((await h(`/v1/charges/${encodeURIComponent(i)}`,{method:"GET"})).json)}}}export{a as RioError,w as createRioClient};
@@ -0,0 +1,73 @@
1
+ import { type ReactNode } from "react";
2
+ import { type ChainBadge } from "./payments-modal";
3
+ import { type ChargeCreateResult, type PlatformChargeStatus, type Problem, type CheckoutCopy, type CheckoutState } from "../lib/payments";
4
+ export type { CheckoutCopy, CheckoutState, Problem as CheckoutError };
5
+ interface CheckoutWidgetBaseProps {
6
+ /** Your order id. The charge is idempotent per order. */
7
+ orderId: string;
8
+ /** Creates the charge through your own server route and resolves to a `ChargeCreateResult` (`postCreateCharge(url, body)` does the fetch for the common case). Called when the modal first opens. The widget validates the charge itself before using it. */
9
+ createCharge: () => Promise<ChargeCreateResult>;
10
+ /** Same-origin URL (or path) the buyer can return to after paying. */
11
+ returnUrl?: string;
12
+ /** Your route that returns the authoritative status for a charge (a PlatformChargeStatus). `null` disables the poll (and `onPaid`). */
13
+ statusUrl: ((chargeId: string) => string) | null;
14
+ /** Called with the host's authoritative status when the order becomes confirmed (`confirmation` "provisional"), and again when it becomes "final". */
15
+ onPaid?: (status: PlatformChargeStatus) => void;
16
+ className?: string;
17
+ /** "auto" follows the visitor's prefers-color-scheme. Default "auto". */
18
+ appearance?: "auto" | "light" | "dark";
19
+ /** Coarse, UI-facing state changes (loading, ready, connecting, confirming, processing, paid, settled, problem, failed). */
20
+ onStatusChange?: (state: CheckoutState) => void;
21
+ /** Called whenever the buyer is shown a problem (never contains the client secret). `cause` holds the raw host, service or wallet text, which is never shown to the buyer. */
22
+ onError?: (error: Problem) => void;
23
+ /** Override any user-facing string (i18n, the trigger label). `{amount}`-style placeholders are filled in. */
24
+ copy?: Partial<CheckoutCopy>;
25
+ /** Rendered under the success message. */
26
+ successSlot?: ReactNode;
27
+ /** Open the modal on mount (and create the charge right away). Default false. */
28
+ defaultOpen?: boolean;
29
+ /**
30
+ * Offer the "pay another way" screen: the charge address for a plain transfer from any wallet or exchange that sends USDC on the
31
+ * charge's network. Default false (hidden): the modal keeps the charge fresh instead, and a transfer (an exchange withdrawal
32
+ * especially) can outlive the charge, so give charges a longer expiry when you turn it on. Payments that still reach an expired charge's address are accepted by the service as a safety net.
33
+ */
34
+ manualPayment?: boolean;
35
+ /**
36
+ * "modal" (default): a single trigger button that opens the modal.
37
+ * "inline": no trigger and no dialog chrome; the same modal content renders in place. For hosts that are
38
+ * already inside their own dialog.
39
+ */
40
+ presentation?: "modal" | "inline";
41
+ /** The store's name, for the header ("Pay Moon Lantern"). Default: just "Pay". */
42
+ merchantName?: string;
43
+ }
44
+ /**
45
+ * `createCharge` calls YOUR server route, whose code computes the amount and creates the charge. The widget
46
+ * never sends an amount anywhere. It must resolve to a ChargeCreateResult (a callback result, not an HTTP body); do not throw for expected failures
47
+ * (a 409 for an order whose amount changed is `{ ok: false, status: 409, error }`). `postCreateCharge` adapts a route's HTTP
48
+ * response to that result, or write your own. The widget validates the charge you
49
+ * resolve with (https service URL without credentials, the client secret and the other fields it needs present) and treats
50
+ * an invalid one as a failed create, so it does not matter how your route fetched it.
51
+ *
52
+ * Theme with CSS custom properties on the widget or any ancestor: --sc-accent,
53
+ * --sc-radius, --sc-bg, --sc-fg, --sc-muted, --sc-border, --sc-success, --sc-danger.
54
+ */
55
+ export type CheckoutWidgetProps = CheckoutWidgetBaseProps;
56
+ export declare function CheckoutWidget({ orderId, createCharge, returnUrl, onPaid, statusUrl, className, appearance, onStatusChange, onError, copy: copyOverrides, successSlot, defaultOpen, manualPayment, presentation, merchantName, }: CheckoutWidgetProps): import("react").JSX.Element;
57
+ /** The address on the "pay another way" screen: the chip shows which chain's USDC it takes (service data). */
58
+ export interface ManualEntry {
59
+ address: string;
60
+ chain: string;
61
+ badge: ChainBadge | null;
62
+ }
63
+ /**
64
+ * The charge address for a plain transfer (a wallet, or an exchange that sends USDC on the charge's network). A withdrawal on
65
+ * the wrong network is lost, so a warning names the network to choose and the address (and its copy button) stays hidden
66
+ * until the buyer confirms that network. The copy also says that what arrives must cover the price, and points a buyer whose
67
+ * exchange cannot send on that network to their own wallet, to pay with it in the modal.
68
+ */
69
+ export declare function PayManual({ entry, copy, amountText }: {
70
+ entry: ManualEntry;
71
+ copy: CheckoutCopy;
72
+ amountText: string;
73
+ }): import("react").JSX.Element;