@tuwaio/nova-payments 0.0.0-stage → 0.0.0
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.
- package/LICENSE +201 -0
- package/README.md +116 -2
- package/dist/chunk-2GRM2VF3.cjs +1 -0
- package/dist/chunk-4TPU7WSP.cjs +1 -0
- package/dist/chunk-BK3GAYTJ.js +1 -0
- package/dist/chunk-XAUJNVKC.js +1 -0
- package/dist/evm/index.cjs +1 -0
- package/dist/evm/index.d.cts +33 -0
- package/dist/evm/index.d.ts +33 -0
- package/dist/evm/index.js +1 -0
- package/dist/i18n/index.cjs +1 -0
- package/dist/i18n/index.d.cts +29 -0
- package/dist/i18n/index.d.ts +29 -0
- package/dist/i18n/index.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.css +910 -0
- package/dist/index.d.cts +1296 -0
- package/dist/index.d.ts +1296 -0
- package/dist/index.js +1 -0
- package/dist/locales-DtReb4Tp.d.cts +588 -0
- package/dist/locales-DtReb4Tp.d.ts +588 -0
- package/dist/solana/index.cjs +1 -0
- package/dist/solana/index.d.cts +38 -0
- package/dist/solana/index.d.ts +38 -0
- package/dist/solana/index.js +1 -0
- package/dist/types-Bmj8ctqc.d.cts +241 -0
- package/dist/types-Bmj8ctqc.d.ts +241 -0
- package/package.json +152 -4
- package/socket.json +17 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b,d,f,e,c}from'./chunk-BK3GAYTJ.js';import {b as b$1,a}from'./chunk-XAUJNVKC.js';export{a as PaymentWalletError,b as walletErrorKind}from'./chunk-XAUJNVKC.js';import {getChainName,WalletIcon,cn as cn$1,TokenIcon,NetworkIcon,Dialog,DialogContent,DialogTitle}from'@tuwaio/nova-core';import {createContext,useContext,useId,useRef,useEffect,useState,useMemo,useEffectEvent,useCallback}from'react';import {toCaip2ChainId,formatCaip10AccountId,toEvmChainId,parseCaip19AssetId,parseCaip10AccountId,OrbitAdapter,parseCaip2ChainId}from'@tuwaio/orbit-core';import {ArrowPathIcon,LockClosedIcon,ClockIcon,GlobeAltIcon,ChevronDownIcon,CheckIcon as CheckIcon$1,XMarkIcon,WalletIcon as WalletIcon$1,QrCodeIcon,DevicePhoneMobileIcon,NoSymbolIcon,ArrowPathRoundedSquareIcon,XCircleIcon,ArrowUturnLeftIcon,MagnifyingGlassIcon,ExclamationTriangleIcon,DocumentTextIcon,ArrowDownTrayIcon,CheckCircleIcon,DocumentDuplicateIcon}from'@heroicons/react/24/outline';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {CheckIcon}from'@heroicons/react/24/solid';import {TxStatusVisual,TxProgressIndicator,HashLink}from'@tuwaio/nova-transactions';import {useLabels,NovaTransactionsLabelsProvider}from'@tuwaio/nova-transactions/providers';import {MotionConfig}from'framer-motion';import {createCheckoutStore}from'@tuwaio/quasar-sdk/checkout';import {useStore}from'zustand';import {SatelliteStoreContext}from'@tuwaio/satellite-react';import {createStore}from'zustand/vanilla';import {NovaConnectProviderContext}from'@tuwaio/nova-connect/hooks';import {encode}from'uqr';var Ie=createContext(null),Ze=Ie.Provider;function C(){let a=useContext(Ie);if(!a)throw new Error("useCheckoutContext must be used inside PaymentCheckout");return a}function X(a,e=2){let o=a.startsWith("-"),t=(o?a.slice(1):a).padStart(e+1,"0");return `${o?"-":""}${t.slice(0,-e)}.${t.slice(-e)}`}var Je=a=>new Intl.NumberFormat(a).formatToParts(1.1).find(e=>e.type==="decimal")?.value??".";function H(a,e){let[o="0",t=""]=(typeof a=="number"?a.toFixed(2):a.trim()).split("."),n=o.startsWith("-"),r=new Intl.NumberFormat(e).format(BigInt(n?o.slice(1):o));return `${n?"-":""}${r}${Je(e)}${t.padEnd(2,"0").slice(0,2)}`}function $(a,e,o){let t=BigInt(a),n=t<0n,r=n?-t:t,s=10n**BigInt(e),c=new Intl.NumberFormat(o).format(r/s),y=(r%s).toString().padStart(e,"0").replace(/0+$/,"").padEnd(2,"0");return `${n?"-":""}${c}${Je(o)}${y}`}function se(a,e){let o=BigInt(a),t=10n**BigInt(e),n=(o%t).toString().padStart(e,"0").replace(/0+$/,"");return n?`${o/t}.${n}`:String(o/t)}function Y(a,e=a.startsWith("0x")?6:4,o=4){return a.length<=e+o+1?a:`${a.slice(0,e)}\u2026${a.slice(-o)}`}var Ca=a=>String(a).padStart(2,"0");function ua(a){let e=Math.max(0,Math.floor(a/1e3)),o=Math.floor(e/86400),t=Math.floor(e%86400/3600),n=Math.floor(e%3600/60),r=e%60;return o>0?`${o}d ${Ca(t)}:${Ca(n)}:${Ca(r)}`:t>0?`${Ca(t)}:${Ca(n)}:${Ca(r)}`:`${Ca(n)}:${Ca(r)}`}var Po={metamask:"MetaMask",walletconnect:"WalletConnect",coinbase:"Coinbase Wallet",okx:"OKX Wallet",trust:"Trust Wallet",injected:"Browser wallet"};function So(a){let e=a.slice(a.indexOf(":")+1).toLowerCase();return Po[e]??e.charAt(0).toUpperCase()+e.slice(1)}var Xe=a=>{let e=parseCaip2ChainId(a)?.namespace;return e==="eip155"||e==="solana"?e:null};function at(a){if(!a?.address)return null;let e=toCaip2ChainId(a.chainId),o=e?Xe(e):null;return !e||!o?null:{address:a.address,chainId:e,family:o,connectorType:a.connectorType,walletId:a.connectorType.slice(a.connectorType.indexOf(":")+1).toLowerCase(),name:So(a.connectorType),connection:a}}function aa(a){return Xe(a.chainId)}function ma(a,e){return !a||a.family!==aa(e)?null:formatCaip10AccountId(e.chainId,a.address)??null}function et(a,e){let o=aa(a);return o==="solana"||o==="eip155"&&!!e}function Te(a){let e=o=>String(Number((o/100).toFixed(2)));return a.discountBps>0?{kind:"discount",percent:e(a.discountBps)}:a.markupBps>0?{kind:"markup",percent:e(a.markupBps)}:null}function G(a){return getChainName(toEvmChainId(a)??a).name}function tt(a){let e=a.assetId?parseCaip19AssetId(a.assetId):void 0;return !e||e.assetNamespace==="slip44"?"native":e.assetReference}function ot(a,e){return a.supportEmail?`mailto:${a.supportEmail}?subject=${encodeURIComponent(e)}`:a.website??null}var Io=["buyer","selectMethod","quoting","awaitingPayment"];function Ae(a){return Io.includes(a)}function pe(a,e){switch(a.code){case "screening_unavailable":return e.pay.screeningUnavailable;case "request_failed":return e.pay.noAnswer;case "amount_out_of_range":case "method_not_found":return e.method.methodUnavailable;case "payer_not_expected":return e.method.payerNotExpected;case "rate_limited":return e.method.rateLimited;default:return e.error.generic}}function nt(a,e){if(a?.status!=="available")return null;let o=e.find(r=>r.id===a.methodId);if(!o)return null;let{request:t}=a,n=t.rules.find(r=>r.type==="expiry")?.data;return {chainId:`eip155:${Number.parseInt(t.chainId,16)}`,to:t.to,limit:BigInt(t.permission.data.periodAmount).toString(),decimals:o.decimals,symbol:o.symbol,periodSeconds:t.permission.data.periodDuration,expiresAt:n?.timestamp?n.timestamp*1e3:null}}function rt(a,e){let o=a%86400===0;return new Intl.NumberFormat(e,{style:"unit",unit:o?"day":"hour",unitDisplay:"long"}).format(o?a/86400:Math.round(a/3600))}function st(a,e){if(!a||e===null)return null;let o=BigInt(a.cryptoAmountExpected)-BigInt(e);return o>0n?o.toString():null}var A="novapay:focus-visible:outline-2 novapay:focus-visible:outline-offset-2 novapay:focus-visible:outline-[var(--tuwa-text-accent)]",Fa=`novapay:inline-flex novapay:h-7 novapay:min-w-7 novapay:items-center novapay:justify-center novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-1.5 novapay:text-[var(--tuwa-text-primary)] novapay:cursor-pointer novapay:transition-colors novapay:hover:bg-[var(--tuwa-bg-muted)] ${A}`,x="novapay:font-mono novapay:tabular-nums";function ya({title:a,subtitle:e,children:o}){return jsxs("section",{className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-2.5 novapay:px-5 novapay:py-4",children:[jsxs("div",{children:[jsx("h2",{className:cn$1(x,"novapay:m-0 novapay:text-base novapay:font-bold"),children:a}),e&&jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:e})]}),o]})}function K({children:a}){return jsx("footer",{className:"novapay:flex novapay:flex-col novapay:gap-1.5 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:px-5 novapay:pb-3.5 novapay:pt-3",children:a})}function ie({children:a,id:e}){return jsx("span",{id:e,className:cn$1(x,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:a})}function U({busy:a,children:e,className:o,...t}){return jsxs("button",{type:"button","aria-busy":a||void 0,...t,disabled:t.disabled||a,className:cn$1(x,"novapay:inline-flex novapay:h-11 novapay:w-full novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border-0 novapay:bg-[var(--tuwa-button-primary-bg)] novapay:text-sm novapay:font-bold novapay:text-[var(--tuwa-text-on-accent)] novapay:transition-colors novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)] novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70",A,o),children:[a&&jsx(ArrowPathIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:animate-spin novapay:motion-reduce:animate-none"}),e]})}function J({children:a}){return jsx("p",{role:"alert",className:"novapay:m-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-error-bg)] novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-error-text)]",children:a})}function za({text:a,label:e,copiedLabel:o,children:t}){let[n,r]=useState(false);useEffect(()=>{if(!n)return;let c=setTimeout(()=>r(false),2e3);return ()=>clearTimeout(c)},[n]);let s=n?CheckIcon$1:DocumentDuplicateIcon;return jsxs(Fragment,{children:[jsxs("button",{type:"button","aria-label":t?void 0:e,onClick:()=>{navigator.clipboard?.writeText(a).then(()=>r(true),()=>{});},className:cn$1(Fa,"novapay:min-h-6 novapay:min-w-6 novapay:text-xs"),children:[jsx(s,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),t]}),jsx("span",{role:"status",className:"novapay:sr-only",children:n?o:""})]})}function D({name:a,children:e}){return jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between novapay:gap-3 novapay:text-xs",children:[jsx("dt",{className:"novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]",children:a}),jsx("dd",{className:cn$1(x,"novapay:m-0 novapay:min-w-0 novapay:text-right novapay:break-words"),children:e})]})}function W({children:a,onClick:e}){return jsx("button",{type:"button",onClick:e,className:cn$1("novapay:min-h-6 novapay:cursor-pointer novapay:border-0 novapay:bg-transparent novapay:p-0 novapay:text-xs novapay:text-[var(--tuwa-text-accent)] novapay:underline novapay:hover:no-underline",A),children:a})}function ce({kind:a,walletName:e,walletId:o,amount:t,merchant:n,network:r,to:s,priceTime:c,onRetry:y,onCancel:l}){let{labels:u}=C(),i=useId(),v=useRef(null);useEffect(()=>v.current?.focus(),[a]);let m={wallet:e,amount:t,merchant:n,network:r},b$1=a==="sign"?u.walletPrompt.signIn:a==="switch"?u.walletPrompt.switchIn:a==="submitting"?u.walletPrompt.submitting:a==="permission"?u.autoPay.approveIn:u.walletPrompt.confirmIn;return jsxs("section",{"aria-labelledby":i,className:"novapay:absolute novapay:inset-0 novapay:z-10 novapay:flex novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:bg-[var(--tuwa-bg-primary)] novapay:px-6 novapay:py-5 novapay:text-center",children:[jsxs("span",{className:"novapay:relative novapay:h-12 novapay:w-12",children:[o&&jsx(WalletIcon,{walletName:o}),jsx(ArrowPathIcon,{"aria-hidden":true,className:"novapay:absolute novapay:-bottom-1 novapay:-right-1 novapay:h-5 novapay:w-5 novapay:animate-spin novapay:rounded-full novapay:bg-[var(--tuwa-bg-primary)] novapay:text-[var(--tuwa-text-accent)] novapay:motion-reduce:animate-none"})]}),jsx("h2",{id:i,ref:v,tabIndex:-1,className:cn$1(x,"novapay:m-0 novapay:text-base novapay:font-bold novapay:outline-none"),children:b(b$1,m)}),(a==="sign"||a==="confirm")&&jsxs(Fragment,{children:[jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:b(a==="sign"?u.walletPrompt.signText:u.walletPrompt.confirmText,m)}),jsxs("div",{className:"novapay:w-full novapay:max-w-xs novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2 novapay:text-left",children:[jsx("span",{className:"novapay:text-[11px] novapay:font-semibold",children:b(u.walletPrompt.check,m)}),jsxs("dl",{className:"novapay:m-0 novapay:mt-1.5 novapay:flex novapay:flex-col novapay:gap-1",children:[jsx(D,{name:u.walletPrompt.amount,children:t}),jsx(D,{name:u.walletPrompt.to,children:s}),jsx(D,{name:u.walletPrompt.network,children:r}),c&&jsx(D,{name:u.walletPrompt.priceLocked,children:c})]})]}),y?jsxs("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[u.walletPrompt.notOpened," ",jsx(W,{onClick:y,children:u.walletPrompt.tryAgain})]}):jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:b(u.walletPrompt.stillWaiting,m)})]}),a==="permission"&&jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:u.autoPay.walletNote}),a!=="submitting"&&jsx(W,{onClick:l,children:u.walletPrompt.cancel})]})}function it(){let{checkout:a,state:e,store:o,labels:t,locale:n,wallet:r,adapterFor:s,setAutoPay:c}=C(),[y,l]=useState(false),[u,i]=useState(null);if(!a)return null;let v=a.merchant.name,m=nt(a.autoCharge,a.methods),b$2=a.autoCharge,N=b$2?.status==="available"?a.methods.find(w=>w.id===b$2.methodId):void 0,S=N?aa(N):null,T=S?s(S):void 0,f=async()=>{if(b$2?.status!=="available"||!m||!r||!T?.requestPermission)return i("unsupported");i(null),l(true);try{let w=await T.requestPermission({request:b$2.request,account:r.address});await o.getState().grantPermission({payer:`${m.chainId}:${r.address}`,...w})&&c(!1);}catch(w){i(b$1(w));}finally{l(false);}},d={wallet:r?.name??"",network:m?G(m.chainId):""},h=u==="declined"?b(t.pay.declined,d):u==="unsupported"?b(t.autoPay.unavailable,d):u?t.error.generic:e.error?pe(e.error,t):null;return jsxs("div",{className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{inert:y,className:"novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs(ya,{title:t.autoPay.title,subtitle:t.autoPay.subtitle,children:[m&&jsxs(Fragment,{children:[jsxs("div",{className:"novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2",children:[jsx("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:b(t.autoPay.allow,{merchant:v})}),jsxs("p",{className:cn$1(x,"novapay:m-0 novapay:text-lg novapay:font-bold"),children:[b(t.autoPay.limit,{amount:`${$(m.limit,m.decimals,n)} ${m.symbol}`})," ",jsx("span",{className:"novapay:text-sm novapay:font-normal",children:b(t.autoPay.every,{period:rt(m.periodSeconds,n)})})]})]}),jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5",children:[r&&jsxs(D,{name:t.autoPay.from,children:[Y(r.address)," \xB7 ",G(m.chainId)]}),jsxs(D,{name:t.autoPay.to,children:[Y(m.to)," ",jsx("span",{className:"novapay:font-sans novapay:text-[var(--tuwa-text-secondary)]",children:v})]}),m.expiresAt&&jsx(D,{name:t.autoPay.validUntil,children:b(t.autoPay.validUntilValue,{date:new Intl.DateTimeFormat(n,{dateStyle:"medium"}).format(m.expiresAt)})})]}),jsxs("ul",{className:"novapay:m-0 novapay:flex novapay:list-disc novapay:flex-col novapay:gap-1 novapay:pl-4 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsx("li",{children:t.autoPay.invoices}),jsx("li",{children:b(t.autoPay.cap,{merchant:v})}),jsx("li",{children:t.autoPay.turnOff})]})]}),h&&jsx(J,{children:h})]}),jsxs(K,{children:[jsx(U,{busy:y,disabled:!m,onClick:()=>{f();},children:t.autoPay.confirm}),jsx(W,{onClick:()=>c(false),children:t.autoPay.skip}),jsx("p",{className:"novapay:m-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:t.autoPay.walletNote})]})]}),y&&r&&jsx(ce,{kind:"permission",walletName:r.name,walletId:r.walletId,amount:"",merchant:v,network:d.network,to:"",priceTime:null,onCancel:()=>l(false)})]})}var Go=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ct="AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW".split(" "),Ko=new Set(ct);function Ee(a,e){let o=a==="full"||e,t=[{name:"email",required:true,autoComplete:"email",type:"email"}];return o?[...t,{name:"name",required:true,autoComplete:e?"organization":"name",type:"text"},{name:"addressLine1",required:true,autoComplete:"address-line1",type:"text"},{name:"addressLine2",required:false,autoComplete:"address-line2",type:"text"},{name:"postalCode",required:false,autoComplete:"postal-code",type:"text"},{name:"city",required:false,autoComplete:"address-level2",type:"text"},{name:"country",required:true,autoComplete:"country",type:"country"},...e?Vo():[]]:t}var Vo=()=>[{name:"taxId",required:true,autoComplete:"off",type:"text"},{name:"registrationNumber",required:false,autoComplete:"off",type:"text"}];function lt(a,e,o){let t={};for(let n of Ee(e,o)){let r=a[n.name]?.trim()??"";r?n.type==="email"&&!Go.test(r)?t[n.name]="email":n.type==="country"&&!Ko.has(r.toUpperCase())&&(t[n.name]="country"):n.required&&(t[n.name]="required");}return t}function ut(a){let e={};for(let[o,t]of Object.entries(a)){let n=t?.trim();n&&(e[o]=o==="country"?n.toUpperCase():n);}return e}function mt(a){let e=new Intl.DisplayNames([a],{type:"region"});return ct.map(o=>({code:o,name:e.of(o)??o})).sort((o,t)=>o.name.localeCompare(t.name,a))}var jo=(a,e,o)=>e==="name"&&o?a.buyer.companyName:a.buyer[e]??e,zo=(a,e)=>e==="email"?a.buyer.invalidEmail:e==="country"?a.buyer.invalidCountry:a.buyer.required,yt=a=>cn$1("novapay:h-9 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:bg-[var(--tuwa-bg-primary)] novapay:px-2.5 novapay:text-[13px] novapay:text-[var(--tuwa-text-primary)]",a?"novapay:border-[var(--tuwa-error-icon)]":"novapay:border-[var(--tuwa-text-secondary)]",A);function vt(){let{checkout:a,state:e,store:o,labels:t,locale:n}=C(),[r,s]=useState({}),[c,y]=useState(false),[l,u]=useState(false),[i,v]=useState(false),m=useId(),b=useMemo(()=>mt(n),[n]);if(!a||a.buyer.collect==="off")return null;let N=a.buyer.collect,S=Ee(N,c),T=lt(r,N,c),f=(h,w)=>s(B=>({...B,[h]:w})),d=async h=>{if(h.preventDefault(),u(true),Object.keys(T).length>0){document.getElementById(`${m}-${Object.keys(T)[0]}`)?.focus();return}v(true),await o.getState().setBuyer(ut(r),{company:c}),v(false);};return jsxs("form",{noValidate:true,onSubmit:h=>{d(h);},className:"novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs(ya,{title:t.buyer.title,subtitle:t.buyer.subtitle,children:[a.buyer.companyInvoice&&jsxs("label",{className:"novapay:flex novapay:cursor-pointer novapay:items-center novapay:gap-2 novapay:text-[13px]",children:[jsx("input",{type:"checkbox",checked:c,onChange:h=>y(h.target.checked),className:cn$1("novapay:h-4 novapay:w-4 novapay:accent-[var(--tuwa-text-accent)]",A)}),t.buyer.companyInvoice]}),jsx("div",{className:"novapay:grid novapay:grid-cols-1 novapay:gap-x-3 novapay:gap-y-2.5 novapay:sm:grid-cols-2",children:S.map(h=>{let w=`${m}-${h.name}`,B=l?T[h.name]:void 0,_=h.name==="email"||h.name==="name"||h.name.startsWith("addressLine");return jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-1",_&&"novapay:sm:col-span-2"),children:[jsxs("label",{htmlFor:w,className:"novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",children:[jo(t,h.name,c),!h.required&&jsxs("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:[" (",t.buyer.optional,")"]})]}),h.type==="country"?jsxs("select",{id:w,autoComplete:h.autoComplete,required:h.required,"aria-invalid":!!B,"aria-describedby":B?`${w}-error`:void 0,value:r.country??"",onChange:F=>f("country",F.target.value),className:yt(!!B),children:[jsx("option",{value:"",children:t.buyer.chooseCountry}),b.map(F=>jsx("option",{value:F.code,children:F.name},F.code))]}):jsx("input",{id:w,type:h.type,autoComplete:h.autoComplete,required:h.required,"aria-invalid":!!B,"aria-describedby":B?`${w}-error`:void 0,value:r[h.name]??"",onChange:F=>f(h.name,F.target.value),className:yt(!!B)}),B&&jsx("span",{id:`${w}-error`,className:"novapay:text-[11px] novapay:text-[var(--tuwa-error-text)]",children:zo(t,B)})]},h.name)})}),e.error&&e.phase==="buyer"&&jsx(J,{children:e.error.message})]}),jsx(K,{children:jsx(U,{type:"submit",busy:i,children:t.buyer.continue})})]})}function dt(a,e={}){switch(a.phase){case "selectMethod":return e.handoff&&e.payWith==="qr"?"qr":"method";case "quoting":return a.quote?e.payWith==="qr"||a.quote.payer===null?"qr":"pay":"method";case "awaitingPayment":case "submitting":return e.payWith==="qr"||a.quote?.payer===null?"qr":"pay";case "confirming":return "confirm";case "paid":return e.autoPay&&a.checkout?.autoCharge?.status==="available"?"autoPay":"paid";case "cancelled":return a.checkout?.invoice.replacedBy?"replaced":"cancelled";default:return a.phase}}var Yo={buyer:"details",method:"method",pay:"pay",qr:"pay",underpaid:"pay",confirm:"confirm",autoPay:"autoPay"};function Me(a,e={}){let o=Yo[a];if(!o)return null;let t=[...e.withDetails||o==="details"?["details"]:[],"method","pay","confirm",...o==="autoPay"?["autoPay"]:[]],n=t.indexOf(o);return t.map((r,s)=>({key:r,state:s<n?"done":s===n?"current":"upcoming"}))}function ft(a,e){let o=s=>s.chainId===e?0:s.featured?1:2,t=new Map;for(let s of a)t.set(s.symbol,[...t.get(s.symbol)??[],s]);let n=[...t].map(([s,c])=>{let y=[...c].sort((l,u)=>o(l)-o(u));return {symbol:s,methods:y,featured:c.some(l=>l.featured),inWallet:!!e&&c.some(l=>l.chainId===e)}}),r=s=>s.inWallet?0:s.featured?1:2;return n.sort((s,c)=>r(s)-r(c))}var Zo=[10,5,1];function xt(a,e){if(a===null||e<=0)return null;let o=Zo.filter(t=>a>t*6e4&&e<=t*6e4);return o.length?Math.min(...o):null}var Be=6e4;function ht(a){return a>0&&a<=Be}function Re({steps:a,labels:e,className:o}){let t=a.findIndex(n=>n.state==="current");return jsx("nav",{"aria-label":e.steps.label,className:cn$1("novapay:min-w-0 novapay:flex-1",o),children:jsx("ol",{className:"novapay:flex novapay:items-center novapay:gap-1.5",children:a.map((n,r)=>{let s=e.steps[n.key];return jsxs("li",{"aria-current":n.state==="current"?"step":void 0,className:cn$1("novapay:flex novapay:min-w-0 novapay:items-center novapay:gap-1.5",r>0&&"novapay:flex-auto"),children:[r>0&&jsx("span",{"aria-hidden":true,className:cn$1("novapay:h-0.5 novapay:min-w-2 novapay:flex-1 novapay:rounded-full",n.state==="upcoming"?"novapay:bg-[var(--tuwa-border-primary)]":"novapay:bg-[var(--tuwa-success-icon)]")}),jsx("span",{"aria-hidden":true,className:cn$1(x,"novapay:flex novapay:h-5 novapay:w-5 novapay:shrink-0 novapay:items-center novapay:justify-center novapay:rounded-full novapay:text-[10px] novapay:font-bold",n.state==="done"&&"novapay:bg-[var(--tuwa-success-icon)] novapay:text-white",n.state==="current"&&"novapay:border-2 novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",n.state==="upcoming"&&"novapay:border-2 novapay:border-[var(--tuwa-border-primary)] novapay:text-[var(--tuwa-text-secondary)]"),children:n.state==="done"?jsx(CheckIcon,{className:"novapay:h-3 novapay:w-3"}):r+1}),jsx("span",{className:cn$1(x,"novapay:truncate novapay:text-[11px]",n.state==="current"?"novapay:font-bold novapay:text-[var(--tuwa-text-primary)]":"novapay:text-[var(--tuwa-text-secondary)]"),children:n.state==="current"?jsxs(Fragment,{children:[jsx("span",{className:"novapay:sr-only",children:b(e.steps.progress,{current:t+1,total:a.length,name:s})}),jsx("span",{"aria-hidden":true,children:s})]}):s})]},n.key)})})})}function ue(a){let e=a.lineItems.reduce((r,s)=>r+BigInt(s.netMinor),0n),o=BigInt(a.totalMinor??e.toString()),t=o-e,n=[...new Set(a.lineItems.filter(r=>Number(r.taxRate)>0).map(r=>r.taxRate))];return {subtotal:X(e.toString()),tax:t>0n?X(t.toString()):null,rate:n.length===1?String(Number(n[0])):null,total:X(o.toString())}}var gt=new Set(["open","processing","underpaid"]),rn=a=>{try{return new URL(a).host}catch{return a}};function Fe({compact:a=false}){let{checkout:e,state:o,labels:t}=C();if(!e)return null;let{merchant:n,invoice:r}=e,s=a?"novapay:h-8 novapay:w-8":"novapay:h-9 novapay:w-9";return jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:items-center novapay:gap-2.5",children:[o.logoUrl?jsx("img",{src:o.logoUrl,alt:"",className:cn$1(s,"novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:object-contain")}):jsx("span",{"aria-hidden":true,className:cn$1(s,x,"novapay:flex novapay:shrink-0 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-text-primary)] novapay:text-[15px] novapay:font-bold novapay:text-[var(--tuwa-bg-primary)]"),children:n.name.trim().charAt(0).toUpperCase()}),jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:truncate novapay:text-sm novapay:font-semibold",children:n.name}),a?r.number&&jsx("span",{className:cn$1(x,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:r.number}):n.website&&jsx("a",{href:n.website,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:truncate novapay:text-xs novapay:text-[var(--tuwa-text-secondary)] novapay:hover:underline",A),children:rn(n.website)})]}),r.environment==="test"&&jsxs("span",{title:t.summary.testHint,className:cn$1(x,"novapay:ml-auto novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-pending-bg)] novapay:px-1.5 novapay:py-0.5 novapay:text-[10px] novapay:font-bold novapay:uppercase novapay:tracking-wider novapay:text-[var(--tuwa-pending-text)]"),children:[t.summary.test,jsxs("span",{className:"novapay:sr-only",children:[": ",t.summary.testHint]})]})]})}function wt({checkout:a,labels:e}){let{merchant:o}=a,t=o.seller,n=[[e.summary.terms,o.links.terms],[e.summary.refundPolicy,o.links.refundPolicy],[e.summary.privacy,o.links.privacy]].filter(r=>!!r[1]);return jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:py-2.5 novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:[t?.legalName&&jsx("span",{className:"novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-primary)]",children:t.legalName}),(t?.address||t?.country)&&jsx("span",{children:[t.address,t.country].filter(Boolean).join(", ")}),t?.registrationNumber&&jsxs("span",{children:[e.summary.registration," ",t.registrationNumber]}),t?.taxId&&jsxs("span",{children:[e.summary.taxId," ",t.taxId]}),o.supportEmail&&jsx("a",{href:`mailto:${o.supportEmail}`,className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",A),children:o.supportEmail}),n.length>0&&jsx("span",{className:"novapay:flex novapay:flex-wrap novapay:gap-x-3",children:n.map(([r,s])=>jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",A),children:r},r))}),jsx("span",{children:b(e.summary.sellerRole,{seller:t?.legalName||o.name})})]})}function sn(){let{checkout:a,labels:e,locale:o,now:t}=C(),n=a?.invoice.dueAt;if(!a||!n||!gt.has(a.invoice.status))return null;let r=new Intl.DateTimeFormat(o,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(n));return jsxs("div",{className:"novapay:flex novapay:items-center novapay:justify-between novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:py-2.5",children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-0.5",children:[jsx("span",{className:cn$1(x,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:e.summary.payWithin}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:b(e.summary.until,{date:r})})]}),jsx("span",{role:"timer",className:cn$1(x,"novapay:text-lg novapay:font-bold"),children:ua(Date.parse(n)-t)})]})}function kt(){let{checkout:a,labels:e,locale:o}=C();if(!a)return null;let{invoice:t}=a,n=ue(t);return jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3.5",children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2.5",children:[t.number&&jsxs("div",{className:cn$1(x,"novapay:flex novapay:justify-between novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:[jsx("span",{children:e.summary.invoice}),jsx("span",{children:t.number})]}),jsx("ul",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-2.5 novapay:p-0",children:t.lineItems.map((r,s)=>jsxs("li",{className:"novapay:flex novapay:justify-between novapay:gap-2 novapay:text-[13px]",children:[jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:break-words",children:r.name}),r.description&&jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:r.description}),jsx("span",{className:cn$1(x,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:b(e.summary.quantity,{quantity:r.quantity,price:H(r.unitPrice,o)})})]}),jsx("span",{className:x,children:H(X(r.netMinor),o)})]},s))})]}),n.tax&&jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5 novapay:border-t novapay:border-dashed novapay:border-[var(--tuwa-border-primary)] novapay:pt-2.5 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:e.summary.subtotal}),jsx("dd",{className:cn$1(x,"novapay:m-0"),children:H(n.subtotal,o)})]}),jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:n.rate?b(e.summary.taxRate,{rate:n.rate}):e.summary.tax}),jsx("dd",{className:cn$1(x,"novapay:m-0"),children:H(n.tax,o)})]})]})]})}function pn(){let{checkout:a,labels:e,locale:o}=C();return a?jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between",children:[jsx("span",{className:cn$1(x,"novapay:text-xs novapay:font-bold"),children:e.summary.total}),jsxs("span",{className:cn$1(x,"novapay:text-[22px] novapay:font-bold"),children:[H(ue(a.invoice).total,o)," ",jsx("span",{className:"novapay:text-[13px] novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:a.invoice.currency})]})]}):null}function cn(){let{checkout:a,labels:e}=C();return jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:[jsxs("span",{className:"novapay:flex novapay:items-center novapay:gap-1.5",children:[jsx(LockClosedIcon,{"aria-hidden":true,className:"novapay:h-3 novapay:w-3"}),e.summary.secured]}),a?.merchant.supportEmail&&jsxs("span",{children:[e.summary.help,":"," ",jsx("a",{href:`mailto:${a.merchant.supportEmail}`,className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",A),children:a.merchant.supportEmail})]})]})}function Nt({label:a,children:e,className:o}){let[t,n]=useState(false),r=useId();return jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-2",o),children:[jsxs("button",{type:"button","aria-expanded":t,"aria-controls":r,onClick:()=>n(s=>!s),className:cn$1("novapay:inline-flex novapay:cursor-pointer novapay:items-center novapay:gap-1 novapay:self-start novapay:border-0 novapay:bg-transparent novapay:p-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)] novapay:hover:text-[var(--tuwa-text-primary)]",A),children:[a,jsx(ChevronDownIcon,{"aria-hidden":true,className:cn$1("novapay:h-3 novapay:w-3 novapay:transition-transform novapay:motion-reduce:transition-none",t&&"novapay:rotate-180")})]}),jsx("div",{id:r,hidden:!t,children:e})]})}function Ct(){let{checkout:a,labels:e}=C();return a?jsxs("div",{className:"novapay:flex novapay:h-full novapay:flex-col novapay:gap-3.5",children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1.5",children:[jsx(Fe,{}),jsx(Nt,{label:e.summary.sellerDetails,children:jsx(wt,{checkout:a,labels:e})})]}),jsx(sn,{}),jsx("div",{className:"novapay:-mr-2.5 novapay:min-h-0 novapay:flex-1 novapay:overflow-y-auto novapay:pr-2.5",children:jsx(kt,{})}),jsx(pn,{}),jsx(cn,{})]}):null}function Pt(){let{checkout:a,labels:e,locale:o,now:t}=C();if(!a)return null;let{invoice:n}=a,r=ue(n),s=n.dueAt&>.has(n.status)?Date.parse(n.dueAt):null;return jsxs("div",{className:"novapay:mx-4 novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:p-3",children:[jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between",children:[jsxs("span",{className:cn$1(x,"novapay:text-[22px] novapay:font-bold"),children:[H(r.total,o)," ",jsx("span",{className:"novapay:text-xs novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:n.currency})]}),s&&jsxs("span",{role:"timer",className:cn$1(x,"novapay:flex novapay:items-center novapay:gap-1 novapay:text-xs novapay:font-bold"),children:[jsx(ClockIcon,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-secondary)]"}),ua(s-t)]})]}),jsx(Nt,{label:`${b(e.summary.compact,{count:n.lineItems.length,tax:r.tax?H(r.tax,o):H("0",o)})} \xB7 ${e.summary.showOrder}`,children:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3 novapay:pt-1",children:[jsx(kt,{}),jsx(wt,{checkout:a,labels:e})]})})]})}function It({locale:a,labels:e,receiptIssued:o,onSelect:t,className:n}){let[r,s]=useState(false),c=d.find(f=>f.code===a)??d[0],[y,l]=useState(0),u=useId(),i=useRef(null),v=useRef(null),m=useRef(null);useEffect(()=>{if(!r)return;m.current?.focus();let f=d=>{i.current?.contains(d.target)||s(false);};return document.addEventListener("pointerdown",f),()=>document.removeEventListener("pointerdown",f)},[r]);let b$1=()=>{l(Math.max(0,d.indexOf(c))),s(true);},N=()=>{s(false),v.current?.focus();},S=f=>{N(),f!==c.code&&t(f);},T=f=>{let d$1=d.length-1,h={ArrowDown:()=>Math.min(d$1,y+1),ArrowUp:()=>Math.max(0,y-1),Home:()=>0,End:()=>d$1};h[f.key]?(f.preventDefault(),l(h[f.key]())):f.key==="Enter"||f.key===" "?(f.preventDefault(),S(d[y].code)):(f.key==="Escape"||f.key==="Tab")&&(f.preventDefault(),f.stopPropagation(),N());};return jsxs("div",{ref:i,className:cn$1("novapay:relative",n),children:[jsxs("button",{ref:v,type:"button","aria-haspopup":"listbox","aria-expanded":r,"aria-controls":r?`${u}-list`:void 0,"aria-label":b(e.language.button,{language:c.name}),className:cn$1(Fa,x,"novapay:text-[11px] novapay:font-semibold"),onClick:()=>r?N():b$1(),onKeyDown:f=>{f.key==="ArrowDown"&&!r&&(f.preventDefault(),b$1());},children:[jsx(GlobeAltIcon,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),jsx("span",{"aria-hidden":true,children:c.short}),jsx(ChevronDownIcon,{"aria-hidden":true,className:"novapay:h-3 novapay:w-3"})]}),r&&jsxs("div",{className:"novapay:absolute novapay:right-0 novapay:top-full novapay:z-20 novapay:mt-1.5 novapay:w-60 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:p-1.5 novapay:shadow-xl",children:[jsx("span",{id:`${u}-title`,className:cn$1(x,"novapay:block novapay:px-2.5 novapay:py-1 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:e.language.title}),jsx("ul",{ref:m,id:`${u}-list`,role:"listbox",tabIndex:-1,"aria-labelledby":`${u}-title`,"aria-activedescendant":`${u}-${d[y].code}`,onKeyDown:T,className:cn$1("novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-0.5 novapay:p-0",A),children:d.map((f,d)=>{let h=f.code===c.code;return jsxs("li",{id:`${u}-${f.code}`,role:"option","aria-selected":h,lang:f.code,onClick:()=>S(f.code),onPointerMove:()=>l(d),className:cn$1("novapay:flex novapay:h-8 novapay:cursor-pointer novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:px-2.5 novapay:text-[13px]",d===y&&"novapay:bg-[var(--tuwa-bg-muted)]","novapay:text-[var(--tuwa-text-primary)]",h&&"novapay:font-semibold"),children:[jsx("span",{"aria-hidden":true,className:cn$1(x,"novapay:w-5 novapay:text-[11px]"),children:f.short}),jsx("span",{children:f.name}),h&&jsx(CheckIcon$1,{"aria-hidden":true,className:"novapay:ml-auto novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-accent)]"})]},f.code)})}),jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:px-2.5 novapay:pb-1 novapay:pt-2 novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:o?e.language.noteAfterPaid:e.language.note})]})]})}function Tt({title:a,withDetails:e}){let{screen:o,labels:t,locale:n,store:r,close:s,state:c}=C(),y=Me(o,{withDetails:e}),l=jsxs("div",{className:"novapay:ml-auto novapay:flex novapay:shrink-0 novapay:items-center novapay:gap-2",children:[jsx(It,{locale:n,labels:t,receiptIssued:!!c.receiptUrl,onSelect:u=>{r.getState().setLocale(u);}}),s&&jsx("button",{type:"button","aria-label":t.common.close,onClick:s,className:Fa,children:jsx(XMarkIcon,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"})})]});return jsxs(Fragment,{children:[jsxs("header",{className:"novapay:hidden novapay:items-center novapay:gap-3 novapay:border-b novapay:border-[var(--tuwa-border-primary)] novapay:py-3.5 novapay:pl-5 novapay:pr-4 novapay:sm:flex",children:[y?jsx(Re,{steps:y,labels:t}):a&&jsx("h2",{className:cn$1(x,"novapay:m-0 novapay:flex-1 novapay:text-[15px] novapay:font-bold"),children:a}),l]}),jsxs("header",{className:"novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-4 novapay:pb-3 novapay:pt-1.5 novapay:sm:hidden",children:[jsx(Fe,{compact:true}),l]})]})}function At({withDetails:a}){let{screen:e,labels:o}=C(),t=Me(e,{withDetails:a});return t?jsx(Re,{steps:t,labels:o,className:"novapay:px-4 novapay:pt-3.5"}):null}function Lt(a,e){return e.withGas||!a.gasless?"transfer":a.gasless.paymaster&&e.canSponsorCalls?"paymaster":a.gasless.relay?"relay":"transfer"}function Mt(a){let e=BigInt(a.amountToSend),o=BigInt(a.cryptoAmountExpected);return !a.transferFee||e<=o?{send:a.amountToSend,receives:a.cryptoAmountExpected,fee:null}:{send:a.amountToSend,receives:a.cryptoAmountExpected,fee:{amount:String(e-o),percent:String(a.transferFee.bps/100)}}}var ve=10000n,Et=8n;function Bt(a,e){let o=BigInt(a.cryptoAmountExpected);if(!e||o<=0n)return null;let n=BigInt(e)*(ve+BigInt(a.markupBps))*(ve-BigInt(a.discountBps))*10n**BigInt(a.decimals)*10n**Et/(100n*ve*ve*o);return Number(n)/10**Number(Et)}function Rt(a,e,o=0n){let t=BigInt(e.amountToSend)+o;return a>=t?null:{have:String(a),need:String(t),short:String(t-a)}}function na(a){return a.family==="eip155"?`eip155:${a.chainId}`:a.chainId}function de(){let{state:a,locale:e,adapterFor:o}=C(),t=a.quote,n=t?na(t.instructions):null,r=a.txHash??a.txKey,s=t?.payer?parseCaip10AccountId(t.payer)?.address:void 0;return {network:n?G(n):null,amount:t?`${$(t.amountToSend,t.decimals,e)} ${t.instructions.symbol}`:null,txKey:r,explorerUrl:t&&n&&r?o(t.instructions.family)?.explorerUrl?.({chainId:n,txKey:r}):void 0,from:s?Y(s):null}}function fe({children:a}){let{labels:e}=C(),o=useLabels(),t=useMemo(()=>({...o,trackingModal:{...o.trackingModal,progressIndicator:{created:e.confirm.sent,processing:e.confirm.confirming,succeed:e.confirm.paid}},statuses:{...o.statuses,confirmed:e.confirm.confirmed,failed:e.confirm.failed},actions:{...o.actions,viewOnExplorer:e.confirm.viewOnExplorer,copy:e.confirm.copyHash},txError:{...o.txError,copied:e.pay.copied}}),[o,e]);return jsx(NovaTransactionsLabelsProvider,{labels:t,children:a})}function Ft(){let{labels:a,close:e}=C(),o=de();return jsxs(fe,{children:[jsxs("section",{className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",children:[jsx(TxStatusVisual,{isProcessing:true}),jsxs("div",{children:[jsx("h2",{className:cn$1(x,"novapay:m-0 novapay:text-base novapay:font-bold"),children:a.confirm.title}),o.network&&jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:b(a.confirm.hint,{network:o.network})})]}),jsx(TxProgressIndicator,{isProcessing:true,className:"novapay:max-w-sm"}),jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:w-full novapay:max-w-sm novapay:flex-col novapay:gap-1.5 novapay:text-left",children:[o.network&&jsx(D,{name:a.confirm.network,children:o.network}),o.amount&&jsx(D,{name:a.confirm.amount,children:o.amount}),o.txKey&&jsx(D,{name:a.confirm.transaction,children:jsx(HashLink,{hash:o.txKey,explorerUrl:o.explorerUrl,variant:"compact"})}),o.from&&jsx(D,{name:a.confirm.from,children:o.from})]}),jsx("p",{role:"status",className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:a.confirm.canClose})]}),e&&jsx(K,{children:jsx(W,{onClick:e,children:a.common.close})})]})}function Dt({onStay:a,onLeave:e}){let{checkout:o,labels:t,locale:n}=C(),r=useId(),s=useRef(null);useEffect(()=>s.current?.focus(),[]);let c=o?.invoice.dueAt?new Intl.DateTimeFormat(n,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(o.invoice.dueAt)):null;return jsx("section",{role:"alertdialog","aria-modal":"true","aria-labelledby":r,className:"novapay:absolute novapay:inset-0 novapay:z-20 novapay:flex novapay:items-center novapay:justify-center novapay:bg-[var(--tuwa-bg-primary)]/95 novapay:p-6",children:jsxs("div",{className:"novapay:flex novapay:max-w-sm novapay:flex-col novapay:gap-3 novapay:text-center",children:[jsx("h2",{id:r,ref:s,tabIndex:-1,className:cn$1(x,"novapay:m-0 novapay:text-base novapay:font-bold novapay:outline-none"),children:t.leave.title}),jsx("p",{className:"novapay:m-0 novapay:text-xs",children:c?b(t.leave.text,{date:c}):t.leave.textNoDate}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:t.leave.price}),jsx(U,{onClick:a,children:t.leave.stay}),jsx(W,{onClick:e,children:t.leave.leave})]})})}function he({label:a,items:e,value:o,getKey:t,onChange:n,children:r,className:s,itemClassName:c}){let y=useRef([]),l=Math.max(0,e.findIndex(i=>t(i)===o)),u=(i,v)=>{let m=e.length-1,b={ArrowRight:v+1,ArrowDown:v+1,ArrowLeft:v-1,ArrowUp:v-1,Home:0,End:m}[i.key];if(b===void 0)return;i.preventDefault();let N=b<0?m:b>m?0:b;n(t(e[N])),y.current[N]?.focus();};return jsx("div",{role:"radiogroup","aria-label":a,className:s,children:e.map((i,v)=>{let m=t(i),b=m===o;return jsx("button",{ref:N=>{y.current[v]=N;},type:"button",role:"radio","aria-checked":b,tabIndex:v===l?0:-1,onClick:()=>n(m),onKeyDown:N=>u(N,v),className:cn$1("novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:text-left novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors",b?"novapay:border-2 novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)]":"novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-text-secondary)]",A,c?.(b)),children:r(i,b)},m)})})}function Za({tone:a,children:e}){return jsx("span",{className:cn$1("novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:px-1.5 novapay:py-0.5 novapay:text-[11px]",a==="neutral"&&"novapay:bg-[var(--tuwa-bg-muted)] novapay:text-[var(--tuwa-text-primary)]",a==="accent"&&"novapay:border novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",a==="success"&&"novapay:bg-[var(--tuwa-success-bg)] novapay:text-[var(--tuwa-success-text)]"),children:e})}function Ot({method:a,labels:e}){let o=Te(a);return o?o.kind==="discount"?jsx(Za,{tone:"success",children:b(e.method.discount,{percent:o.percent})}):jsx(Za,{tone:"neutral",children:b(e.method.markup,{percent:o.percent})}):null}function Kn({selected:a}){return jsx("span",{"aria-hidden":true,className:cn$1("novapay:h-3.5 novapay:w-3.5 novapay:shrink-0 novapay:rounded-full novapay:box-border",a?"novapay:border-4 novapay:border-[var(--tuwa-text-accent)]":"novapay:border novapay:border-[var(--tuwa-text-secondary)]")})}function Vn({labels:a,terms:e,refundPolicy:o}){let t=(r,s)=>jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",A),children:s},r),n=e&&o?c(a.method.agreeBoth,{terms:t(e,a.summary.terms),refundPolicy:t(o,a.summary.refundPolicy)}):e||o?c(a.method.agreeOne,{link:e?t(e,a.summary.terms):t(o,a.summary.refundPolicy)}):null;return n?jsx("p",{className:"novapay:m-0 novapay:text-center novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:n}):null}function $t(){let{checkout:a,state:e,store:o,labels:t,wallet:n,payWith:r,setPayWith:s,payUrl:c,connectWallet:y,adapterFor:l,setHandoff:u}=C(),i=useMemo(()=>a?.methods??[],[a]),v=useMemo(()=>ft(i,n?.chainId),[i,n?.chainId]),m=i.find(g=>g.id===e.methodId)??null,b$1=v.find(g=>g.symbol===m?.symbol)??null,N=m?et(m,c):false,S=m?aa(m):null,f=[...(S?!!l(S):false)?["wallet"]:[],...N?["qr"]:[]],d=f.includes(r)?r:f[0]??null,[h,w]=useState(false),B=useEffectEvent(()=>{let g=v[0]?.methods[0];!e.methodId&&g&&o.getState().selectMethod(g.id);});if(useEffect(()=>B(),[v]),!a)return null;if(i.length===0)return jsx(ya,{title:t.method.title,children:jsx(J,{children:t.method.noMethods})});let _=e.phase==="quoting",F=async()=>{if(!m||!d)return;if(w(false),d==="qr"){if(r!=="qr"&&s("qr"),S!=="solana")return u(true);o.getState().setPayer(null),await o.getState().requestQuote();return}r!=="wallet"&&s("wallet");let g=ma(n,m);if(!g)return w(!y(m));o.getState().setPayer(g),await o.getState().requestQuote();};return jsxs(Fragment,{children:[jsxs(ya,{title:t.method.title,subtitle:b(t.method.subtitle,{minutes:Math.round(a.quoteTtlSeconds/60)}),children:[jsx(ie,{children:t.method.token}),jsx(he,{label:t.method.token,items:v,value:b$1?.symbol??null,getKey:g=>g.symbol,onChange:g=>{let j=v.find(Ba=>Ba.symbol===g)?.methods[0];j&&o.getState().selectMethod(j.id);},className:"novapay:grid novapay:grid-cols-2 novapay:gap-2 novapay:sm:grid-cols-4",itemClassName:()=>"novapay:flex novapay:flex-col novapay:items-center novapay:gap-1 novapay:px-1 novapay:py-2",children:g=>jsxs(Fragment,{children:[jsx("span",{className:"novapay:h-6.5 novapay:w-6.5",children:jsx(TokenIcon,{symbol:g.symbol})}),jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:g.symbol}),jsx("span",{className:"novapay:text-[10px] novapay:text-[var(--tuwa-text-secondary)]",children:g.methods.length>1?b(t.method.networks,{count:g.methods.length}):Te(g.methods[0])?jsx(Ot,{method:g.methods[0],labels:t}):G(g.methods[0].chainId)})]})}),b$1&&b$1.methods.length>1&&jsxs(Fragment,{children:[jsx(ie,{children:b(t.method.network,{symbol:b$1.symbol})}),jsx(he,{label:b(t.method.network,{symbol:b$1.symbol}),items:b$1.methods,value:m?.id??null,getKey:g=>g.id,onChange:g=>o.getState().selectMethod(g),className:"novapay:flex novapay:flex-col novapay:gap-1.5",itemClassName:()=>"novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-3 novapay:py-2",children:(g,j)=>jsxs(Fragment,{children:[jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(NetworkIcon,{chainId:toEvmChainId(g.chainId)??g.chainId})}),jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:G(g.chainId)}),jsxs("span",{className:"novapay:ml-auto novapay:flex novapay:flex-wrap novapay:justify-end novapay:gap-1.5",children:[n?.chainId===g.chainId&&jsx(Za,{tone:"neutral",children:t.method.yourWallet}),g.featured&&jsx(Za,{tone:"accent",children:t.method.popular}),jsx(Ot,{method:g,labels:t}),g.gasless==="auto"?jsx(Za,{tone:"success",children:t.method.noGasFee}):jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:t.method.buyerPaysGas})]}),jsx(Kn,{selected:j})]})})]}),jsx(ie,{children:t.method.payWith}),jsx(he,{label:t.method.payWith,items:f,value:d,getKey:g=>g,onChange:g=>{w(false),s(g);},className:cn$1("novapay:grid novapay:gap-2",f.length>1&&"novapay:grid-cols-2"),itemClassName:()=>"novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-2.5 novapay:py-2",children:g=>g==="wallet"?jsxs(Fragment,{children:[n?jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(WalletIcon,{walletName:n.walletId})}):jsx(WalletIcon$1,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0 novapay:text-[var(--tuwa-text-accent)]"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:t.method.wallet}),jsx("span",{className:cn$1("novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",n&&x),children:n?`${n.name} \xB7 ${Y(n.address)}`:t.method.walletHint})]})]}):jsxs(Fragment,{children:[m&&aa(m)==="solana"?jsx(QrCodeIcon,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0"}):jsx(DevicePhoneMobileIcon,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0"}),jsxs("span",{className:"novapay:flex novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:t.method.qr}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:t.method.qrHint})]})]})}),m&&!d&&jsx(J,{children:t.method.methodUnavailable}),h&&jsx(J,{children:N?t.pay.connectUnavailable:t.method.methodUnavailable}),e.error&&e.phase==="selectMethod"&&jsx(J,{children:pe(e.error,t)})]}),jsxs(K,{children:[jsx(U,{busy:_,disabled:!m||!d,onClick:()=>{F();},children:_?t.method.quoting:t.method.continue}),jsx(Vn,{labels:t,terms:a.merchant.links.terms,refundPolicy:a.merchant.links.refundPolicy})]})]})}var ar={underpaid:{Icon:ExclamationTriangleIcon,tone:"novapay:text-[var(--tuwa-pending-icon)]"},held:{Icon:MagnifyingGlassIcon,tone:"novapay:text-[var(--tuwa-info-icon)]"},refunded:{Icon:ArrowUturnLeftIcon,tone:"novapay:text-[var(--tuwa-info-icon)]"},expired:{Icon:ClockIcon,tone:"novapay:text-[var(--tuwa-text-secondary)]"},cancelled:{Icon:XCircleIcon,tone:"novapay:text-[var(--tuwa-text-secondary)]"},replaced:{Icon:ArrowPathRoundedSquareIcon,tone:"novapay:text-[var(--tuwa-info-icon)]"},blocked:{Icon:NoSymbolIcon,tone:"novapay:text-[var(--tuwa-error-icon)]"}},sa=({children:a,muted:e})=>jsx("p",{className:cn$1("novapay:m-0 novapay:max-w-sm novapay:text-xs",e?"novapay:text-[var(--tuwa-text-secondary)]":"novapay:text-[var(--tuwa-text-primary)]"),children:a});function er(){let{checkout:a,labels:e,onContact:o}=C();if(!a)return null;let t=b(e.outcome.contact,{merchant:a.merchant.name}),n=cn$1("novapay:inline-flex novapay:min-h-6 novapay:items-center novapay:justify-center novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-accent)] novapay:underline novapay:hover:no-underline",A);if(o)return jsx("button",{type:"button",onClick:o,className:cn$1(n,"novapay:cursor-pointer novapay:border-0 novapay:bg-transparent"),children:t});let r=ot(a.merchant,b(e.outcome.contactSubject,{number:a.invoice.number??a.invoice.id}));return r?jsx("a",{href:r,target:r.startsWith("mailto:")?void 0:"_blank",rel:"noopener noreferrer",className:n,children:t}):null}function Ut({kind:a}){let{checkout:e,state:o,store:t,labels:n,locale:r,wallet:s,connectWallet:c,openInvoice:y}=C();if(!e)return null;let l=e.merchant.name,{Icon:u,tone:i}=ar[a],v=o.quote,m=e.methods.find(d=>d.id===(o.methodId??v?.methodId)),b$1=e.invoice.dueAt?new Intl.DateTimeFormat(r,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(e.invoice.dueAt)):null,N=d=>v?`${$(d,v.decimals,r)} ${v.instructions.symbol}`:d,S,T=null,f=null;switch(a){case "underpaid":{let d=e.invoice.amountPaid,h=st(v,d);S=n.outcome.underpaidTitle,T=jsxs(Fragment,{children:[v&&d&&jsx(sa,{children:b(n.outcome.underpaidText,{received:N(d),total:N(v.cryptoAmountExpected)})}),v&&h&&jsx(sa,{children:b(n.outcome.underpaidRest,{rest:N(h),network:G(na(v.instructions))})}),b$1&&jsx(sa,{muted:true,children:b(n.outcome.underpaidNote,{merchant:l,date:b$1})})]});let w=()=>{if(!m)return;let B=v?.payer===null?null:s?ma(s,m):null;if(v?.payer!==null&&!B)return void c(m);t.getState().setPayer(B),t.getState().requestQuote();};f=jsx(U,{busy:o.phase==="quoting",onClick:w,children:n.outcome.payRest});break}case "held":{S=b(n.outcome.heldTitle,{merchant:l});let d=e.invoice.review?.reason,h=d==="late"?n.outcome.heldLate:d==="overpaid"?n.outcome.heldOverpaid:n.outcome.heldScreening;T=jsxs(Fragment,{children:[jsx(sa,{children:b(h,{merchant:l})}),jsx(sa,{muted:true,children:n.outcome.heldNote})]});break}case "refunded":{S=n.outcome.refundedTitle;let d=e.invoice.refundedTotalMinor??e.invoice.totalMinor;T=d&&jsx(sa,{children:b(n.outcome.refundedText,{merchant:l,amount:H(X(d),r),currency:e.invoice.currency})});break}case "expired":S=n.outcome.expiredTitle,T=jsxs(Fragment,{children:[b$1&&jsx(sa,{children:b(n.outcome.expiredText,{date:b$1,merchant:l})}),jsx(sa,{muted:true,children:n.outcome.expiredNote})]});break;case "cancelled":S=n.outcome.cancelledTitle,T=jsx(sa,{children:b(n.outcome.cancelledText,{merchant:l})});break;case "replaced":{let d=e.invoice.replacedBy,h=d?.number??"";if(S=b(n.outcome.replacedTitle,{merchant:l}),T=jsxs(Fragment,{children:[jsx(sa,{children:b(n.outcome.replacedText,{number:h})}),jsx(sa,{muted:true,children:n.outcome.replacedPaid})]}),d?.checkoutToken){let w=d.checkoutToken;f=jsx(U,{onClick:()=>y(w),children:b(n.outcome.openReplacement,{number:h})});}break}case "blocked":{S=n.outcome.blockedTitle;let d=o.payer?parseCaip10AccountId(o.payer)?.address:void 0;T=jsxs(Fragment,{children:[jsx(sa,{children:b(n.outcome.blockedText,{merchant:l})}),d&&jsx("p",{className:cn$1(x,"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]"),children:Y(d)})]}),m&&(f=jsx(U,{onClick:()=>{c(m);},children:n.outcome.useAnotherWallet}));break}}return jsxs(Fragment,{children:[jsxs("section",{role:a==="blocked"?"alert":void 0,className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:px-5 novapay:py-6 novapay:text-center",children:[jsx(u,{"aria-hidden":true,className:cn$1("novapay:h-12 novapay:w-12",i)}),jsx("h2",{className:cn$1(x,"novapay:m-0 novapay:max-w-sm novapay:text-base novapay:font-bold"),children:S}),T]}),jsxs(K,{children:[f,jsx(er,{})]})]})}function Vt(a,e,o){let t=useRef(false),n=useEffectEvent(()=>{e&&o?.(e);});useEffect(()=>{a!=="paid"||t.current||(t.current=true,n());},[a]);}function _t({url:a,seconds:e,now:o,navigate:t=n=>window.location.assign(n)}){let[n]=useState(o),[r,s]=useState(false),c=a&&e>0&&!r?Math.max(0,e-Math.floor((o-n)/1e3)):null,y=useEffectEvent(()=>{a&&t(a);});return useEffect(()=>{c===0&&y();},[c]),{left:c,stay:()=>s(true)}}function Qt(){let{checkout:a,state:e,labels:o,locale:t,now:n,close:r,wallet:s,adapterFor:c,setAutoPay:y,autoReturnSeconds:l}=C(),u=de(),[i]=useState(n),v=a?.merchant.name??"",m=a?.invoice.successUrl??null,b$1=a?.autoCharge??null,N=b$1?.status==="available"?a?.methods.find(B=>B.id===b$1.methodId):void 0,S=N?aa(N):null,T=!!(s&&S&&c(S)?.requestPermission),f=_t({url:m,seconds:T?0:l,now:n});if(!a)return null;let d=a.invoice.totalMinor?H(X(a.invoice.totalMinor),t):null,h=a.invoice.refundedTotalMinor&&BigInt(a.invoice.refundedTotalMinor)>0n?H(X(a.invoice.refundedTotalMinor),t):null,w=new Intl.DateTimeFormat(t,{dateStyle:"medium",timeStyle:"short"}).format(i);return jsxs(fe,{children:[jsxs("section",{className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",children:[jsx(TxStatusVisual,{isSucceed:true}),jsx("h2",{className:cn$1(x,"novapay:m-0 novapay:text-base novapay:font-bold"),children:o.paid.title}),jsxs("div",{children:[jsx("p",{className:cn$1(x,"novapay:m-0 novapay:text-2xl novapay:font-bold"),children:u.amount??(d&&`${d} ${a.invoice.currency}`)}),jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:u.network?b(o.paid.summary,{network:u.network,date:w}):w})]}),u.txKey&&jsx(HashLink,{hash:u.txKey,explorerUrl:u.explorerUrl,variant:"compact",className:"novapay:max-w-sm"}),jsx(TxProgressIndicator,{isSucceed:true,isConfirmed:true,className:"novapay:max-w-sm"}),h&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:b(o.paid.refunded,{amount:h,currency:a.invoice.currency})}),e.receiptUrl&&jsxs("div",{className:"novapay:flex novapay:w-full novapay:max-w-sm novapay:items-center novapay:gap-3 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2 novapay:text-left",children:[jsx(DocumentTextIcon,{"aria-hidden":true,className:"novapay:h-6 novapay:w-6 novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:o.paid.receipt}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.paid.receiptHint})]}),jsxs("a",{href:e.receiptUrl,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:inline-flex novapay:min-h-6 novapay:items-center novapay:gap-1 novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-accent)]",A),children:[jsx(ArrowDownTrayIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"}),o.paid.download]})]}),b$1?.status==="active"&&jsxs("p",{className:"novapay:m-0 novapay:flex novapay:items-center novapay:gap-1.5 novapay:text-xs novapay:text-[var(--tuwa-success-text)]",children:[jsx(CheckCircleIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"}),o.paid.autoPayActive]})]}),jsxs(K,{children:[T&&jsx(U,{onClick:()=>y(true),children:o.paid.autoPayOffer}),m?jsxs(Fragment,{children:[jsx("a",{href:m,className:cn$1(x,"novapay:inline-flex novapay:h-11 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:text-sm novapay:font-bold novapay:no-underline",T?"novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:text-[var(--tuwa-text-primary)]":"novapay:bg-[var(--tuwa-button-primary-bg)] novapay:text-[var(--tuwa-text-on-accent)]",A),children:b(o.paid.back,{merchant:v})}),f.left!==null&&jsxs("p",{className:"novapay:m-0 novapay:text-center novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsx("span",{role:"timer","aria-live":"off",children:b(o.paid.returning,{merchant:v,seconds:f.left})})," ","\xB7 ",jsx(W,{onClick:f.stay,children:o.paid.stay})]})]}):r&&jsx(W,{onClick:r,children:o.common.close})]})]})}var Ma=()=>new Promise(()=>{}),dr={view:Ma,quote:Ma,buyer:Ma,locale:Ma,submit:Ma,relay:Ma,permission:Ma,url:()=>""},fr=createCheckoutStore({token:"idle",api:dr,EventSource:null});function zt(a){let{token:e,baseUrl:o,api:t,EventSource:n,pollMs:r}=a,[s,c]=useState(fr),y=useEffectEvent(()=>createCheckoutStore({token:e,baseUrl:o,api:t,EventSource:n,pollMs:r}));return useEffect(()=>{let l=y();return c(l),l.getState().load(),()=>l.getState().destroy()},[e,o]),s}function Yt(a,e){return useStore(a,e)}var kr=createStore(()=>({}));function Zt(){let a=useContext(SatelliteStoreContext),e=useStore(a??kr,o=>o.activeConnection);return useMemo(()=>at(e),[e])}var ge=createContext({});function we(){return useContext(ge)}function Jt(a,e=true){let[o,t]=useState(()=>Date.now());return useEffect(()=>{if(!e)return;let n=setInterval(()=>t(Date.now()),a);return ()=>clearInterval(n)},[a,e]),o}var Ir=100,Tr=300,Xt=(a,e)=>a.length>e?`${a.slice(0,e-1)}\u2026`:a,Ar=["paid","underpaid","held","refunded","expired","cancelled","blocked"];function ao(a){return !Ar.includes(a.phase)&&a.error?.code!=="payment_failed"}async function eo({adapter:a,pulsar:e,payment:o,labels:t,merchant:n,invoice:r,amount:s}){if(!e||!a?.pulsarTransaction)return false;let c=r.number?b(t.pay.txDescription,{amount:s,invoice:r.number}):s,y=a.pulsarTransaction({...o,title:Xt(b(t.pay.txTitle,{merchant:n}),Ir),description:Xt(c,Tr),payload:{quasarInvoice:r.id}});return await e.injectExternalPendingTxs([y]),true}function to({store:a,open:e,adapterFor:o,pulsar:t,labels:n,locale:r}){let s=useRef(null),c=useRef(!e),y=useRef({adapterFor:o,pulsar:t,labels:n,locale:r});useEffect(()=>{y.current={adapterFor:o,pulsar:t,labels:n,locale:r};});let l=useCallback(i=>{let{phase:v,error:m,checkout:b}=a.getState();if(!b||!ao({phase:v,error:m}))return;let{adapterFor:N,pulsar:S,labels:T,locale:f}=y.current,{amount:d,decimals:h,symbol:w}=i.instructions;eo({adapter:N(i.instructions.family),pulsar:S,payment:i,labels:T,merchant:b.merchant.name,invoice:{id:b.invoice.id,number:b.invoice.number},amount:`${$(d,h,f)} ${w}`}).catch(()=>{});},[a]),u=useCallback(()=>{c.current=true,s.current&&l(s.current),s.current=null;},[l]);return useEffect(()=>{e?c.current=false:u();},[e,u]),useEffect(()=>u,[u]),useCallback(i=>{c.current?l(i):s.current=i;},[l])}function oo(a){let{labels:e$1,customization:o}=we(),t=o?.labels?.transform;return useMemo(()=>{let n=f(e(a),e$1);return t?t(n,{locale:a}):n},[a,e$1,t])}function ro(a){let e=useContext(NovaConnectProviderContext);return {canConnect:!!(e||a),connecting:e?.isConnectModalOpen??false,connect:o=>e?(e.setIsConnectModalOpen(true,{adapter:o==="solana"?OrbitAdapter.SOLANA:OrbitAdapter.EVM}),true):a?(a(o),true):false}}function Xa(a,e){let[o,t]=useState(null),n=useEffectEvent(e);return useEffect(()=>{if(a===null)return;let r=true,s;try{s=Promise.resolve(n());}catch(c){s=Promise.reject(c);}return s.then(c=>r&&t({key:a,value:c}),()=>r&&t({key:a,value:null})),()=>{r=false;}},[a]),o&&o.key===a?o.value:void 0}var so=a$1=>new a("unsupported",`${a$1} is not available`);async function po({adapter:a,store:e,quote:o,wallet:t,path:n,paymasterUrl:r,onWalletDone:s,onSent:c}){let y=t.address;if(n==="relay"){let u=o.gasless?.relay?.typedData;if(!u||!a.signTransferAuthorization)throw so("A gasless signature");let i=await a.signTransferAuthorization({typedData:u,account:y});return s?.(),e.getState().relay(i)}if(n==="paymaster"){let u=o.gasless?.paymaster?.calls;if(!u||!r||!a.sendSponsoredCalls)throw so("A sponsored payment");let i=na(o.instructions),v=await a.sendSponsoredCalls({calls:u,paymasterUrl:r,chainId:i,account:y,onSent:s});return s?.(),c?.(v),e.getState().submit({txKey:v,connectorType:t.connectorType})}let l=await a.sendTransfer({instructions:o.instructions,account:y,connection:t.connection});return s?.(),c?.(l),e.getState().submit({txKey:l,connectorType:t.connectorType})}function co({adapter:a,store:e,quote:o,wallet:t,path:n,paymasterUrl:r,onSent:s}){let[c,y]=useState("idle"),[l,u]=useState(null),i=useRef(0),v=async(m,b)=>{let N=++i.current,S=()=>i.current===N;u(null),y(m);try{await b(S);}catch(T){S()&&u(b$1(T));}finally{S()&&y("idle");}};return {status:c,problem:l,pay:()=>v("wallet",async m=>{if(!a||!o||!t)return u("unsupported");await po({adapter:a,store:e,quote:o,wallet:t,path:n,paymasterUrl:r,onWalletDone:()=>m()&&y("submitting"),onSent:b=>s?.({txKey:b,instructions:o.instructions,account:t.address,connectorType:t.connectorType})});}),switchNetwork:()=>v("switching",async()=>{if(!a?.switchChain||!o)return u("unsupported");await a.switchChain(na(o.instructions));}),dismiss:()=>{i.current++,y("idle");}}}function Ur(a,e){return a>=1?H(a,e):new Intl.NumberFormat(e,{maximumSignificantDigits:6}).format(a)}function Hr(a,e,o,t){return o==="declined"?b(a.pay.declined,e):o==="unsupported"?b(a.pay.unsupported,e):o==="failed"||t==="payment_failed"?b(a.pay.failed,e):t==="screening_unavailable"?a.pay.screeningUnavailable:t==="request_failed"?a.pay.noAnswer:null}function Gr(a,e,o){let{wallet:t,adapterFor:n}=C(),r=e?.instructions.family,s=r?n(r):void 0,c=a.filter(l=>l.id!==e?.methodId&&aa(l)===r),y=Xa(o&&s&&t&&c.length?`${t.address}:${c.map(l=>l.id).join()}`:null,()=>Promise.all(c.map(l=>s.getBalance({chainId:l.chainId,account:t.address,token:tt(l)}).catch(()=>0n))));return y?c.map((l,u)=>({method:l,balance:y[u]})).filter(l=>l.balance>0n):[]}function lo(){let{checkout:a,state:e,store:o,labels:t,locale:n,now:r,wallet:s,adapterFor:c,connectWallet:y,backToMethods:l,onPaymentSent:u}=C(),i=e.quote,v=a?.methods??[],m=v.find(z=>z.id===i?.methodId),b$1=i?.instructions.family??"eip155",N=c(b$1),S=i?na(i.instructions):"",T=s?.address??"",[f,d]=useState(false),h=Xa(i?.gasless?.paymaster&&N?.canSponsorCalls&&s?`${S}:${T}`:null,()=>N.canSponsorCalls({chainId:S,account:T})),w=i?Lt(i,{withGas:f,canSponsorCalls:h===true}):"transfer",B=Xa(i&&N&&s?`${S}:${T}:${i.instructions.token}`:null,()=>N.getBalance({chainId:S,account:T,token:i.instructions.token})),_=Xa(i&&w==="transfer"&&N?.estimateFee&&s?`${S}:${T}:${i.amountToSend}`:null,()=>N.estimateFee({instructions:i.instructions,account:T})),F=co({adapter:N,store:o,quote:i,wallet:s,path:w,paymasterUrl:e.paymasterUrl,onSent:u}),g=i?.instructions.token==="native",j=i&&typeof B=="bigint"?Rt(B,i,g&&_?_.amount:0n):null,Ba=Gr(v,i,!!j);if(!a||!i||!m)return null;let da=a.merchant.name,fa=G(S),xa=z=>`${$(z,i.decimals,n)} ${i.instructions.symbol}`,Z=Mt(i),ka=i.expiresAt?Date.parse(i.expiresAt)-r:Number.POSITIVE_INFINITY,ha=ka<=0,Ce=ht(ka),Aa=e.phase==="quoting",ae=a.invoice.amountPaid?null:Bt(i,a.invoice.totalMinor),ee=a.invoice.totalMinor?H(X(a.invoice.totalMinor),n):null,ba=!!(s&&i.payer&&ma(s,m)===i.payer),Va=b$1==="eip155"&&s&&s.chainId!==S&&!!N?.switchChain,te=F.status!=="idle"||e.phase==="submitting"||Aa,oe=Hr(t,{wallet:s?.name??"",network:fa},F.problem,e.phase==="awaitingPayment"?e.error?.code:void 0),_a=()=>{o.getState().requestQuote();},la;ha?la={label:t.pay.newPrice,run:_a}:ba?Va?la={label:b(t.pay.switchTo,{network:fa}),run:()=>{F.switchNetwork();}}:la={label:b(w==="transfer"?t.pay.payAmount:t.pay.signToPay,{amount:xa(Z.send)}),run:()=>{F.pay();},disabled:!!j}:la={label:t.pay.connect,run:()=>{y(m);}};let Qa=F.status==="switching"?"switch":F.status==="submitting"||e.phase==="submitting"?"submitting":F.status==="wallet"?w==="transfer"?"confirm":"sign":null;return jsxs("div",{className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{inert:Qa!==null,className:"novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("section",{className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-3 novapay:px-5 novapay:py-4",children:[jsx("h2",{className:"novapay:sr-only",children:t.pay.title}),s&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2",children:[jsx("span",{className:"novapay:h-7 novapay:w-7 novapay:shrink-0",children:jsx(WalletIcon,{walletName:s.walletId})}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:s.name}),jsx("span",{className:cn$1(x,"novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:b(t.pay.walletLine,{address:Y(s.address),network:G(s.chainId)})})]}),jsx("button",{type:"button","aria-label":t.pay.changeWallet,onClick:()=>y(m),className:cn$1("novapay:min-h-6 novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-transparent novapay:px-2.5 novapay:py-1 novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-bg-muted)]",A),children:t.pay.change})]}),Va&&ba&&!ha&&jsxs("div",{role:"status",className:"novapay:flex novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-pending-bg)] novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-pending-text)]",children:[jsx(ExclamationTriangleIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),jsxs("span",{children:[jsx("strong",{className:"novapay:block",children:t.pay.wrongNetwork}),b(t.pay.wrongNetworkText,{current:G(s.chainId),network:fa})," ",t.pay.switchHint]})]}),jsxs("div",{children:[jsx("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:t.pay.youSend}),jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:gap-2",children:[jsx("span",{className:cn$1(x,"novapay:text-[28px] novapay:font-bold novapay:leading-tight"),children:$(Z.send,i.decimals,n)}),jsx("span",{className:cn$1(x,"novapay:text-sm novapay:font-semibold"),children:i.instructions.symbol}),jsx(za,{text:se(Z.send,i.decimals),label:t.pay.copyAmount,copiedLabel:t.pay.copied})]}),jsxs("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[b(t.pay.onNetwork,{network:fa}),ee&&!Z.fee&&jsxs(Fragment,{children:[" \xB7 ",b(t.pay.fiatValue,{amount:ee,currency:a.invoice.currency})]})]})]}),Z.fee&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:px-3 novapay:py-2",children:[jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1",children:[jsx(D,{name:t.pay.invoiceTotal,children:$(Z.receives,i.decimals,n)}),jsx(D,{name:b(t.pay.transferFee,{percent:Z.fee.percent}),children:$(Z.fee.amount,i.decimals,n)}),jsx(D,{name:b(t.pay.merchantReceives,{merchant:da}),children:xa(Z.receives)})]}),jsx("p",{className:"novapay:m-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:t.pay.transferFeeNote})]}),!ha&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2 novapay:text-xs",children:[jsx(ClockIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:text-[var(--tuwa-text-secondary)]"}),jsx("span",{role:"timer","aria-live":"off",className:"novapay:flex-1",children:b(t.pay.priceLocked,{time:ua(ka)})}),jsx(W,{onClick:_a,children:t.pay.refreshPrice})]}),Ce&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-text-accent)] novapay:px-3 novapay:py-2",children:[jsx("span",{"aria-hidden":true,className:"novapay:text-xs",children:b(t.pay.priceEnding,{time:ua(ka)})}),jsx("span",{role:"status",className:"novapay:sr-only",children:b(t.pay.priceEnding,{time:ua(Be)})}),jsx("button",{type:"button",onClick:_a,disabled:Aa,className:cn$1(x,"novapay:min-h-8 novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border-0 novapay:bg-[var(--tuwa-button-primary-bg)] novapay:px-3 novapay:text-xs novapay:font-bold novapay:text-[var(--tuwa-text-on-accent)] novapay:disabled:opacity-70",A),children:b(t.pay.keepPrice,{minutes:Math.round(a.quoteTtlSeconds/60)})})]}),ha&&jsx(J,{children:t.pay.priceExpired}),j&&!ha&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:px-3 novapay:py-2 novapay:text-xs",children:[jsxs("div",{role:"alert",children:[jsx("strong",{className:"novapay:block",children:t.pay.notEnough}),b(t.pay.walletHas,{amount:xa(j.have),network:fa}),"."," ",b(t.pay.shortBy,{short:xa(j.short),need:xa(j.need)})]}),Ba.length>0&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1.5",children:[jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:t.pay.payFromBalance}),Ba.map(({method:z,balance:Ke})=>jsxs("button",{type:"button",onClick:()=>{let Ve=s?ma(s,z):null;o.getState().selectMethod(z.id),o.getState().setPayer(Ve),o.getState().requestQuote();},className:cn$1("novapay:flex novapay:cursor-pointer novapay:items-center novapay:justify-between novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-transparent novapay:px-2.5 novapay:py-1.5 novapay:text-left novapay:text-xs novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-bg-muted)]",A),children:[jsxs("span",{className:"novapay:font-semibold",children:[z.symbol," \xB7 ",G(z.chainId)]}),jsx("span",{className:cn$1(x,"novapay:text-[var(--tuwa-text-secondary)]"),children:b(t.pay.youHave,{amount:`${$(String(Ke),z.decimals,n)} ${z.symbol}`})})]},z.id))]}),a.merchant.fundingUrl&&jsxs("span",{children:[b(t.pay.topUp,{symbol:i.instructions.symbol})," ",jsxs("a",{href:a.merchant.fundingUrl,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",A),children:[b(t.pay.getToken,{symbol:i.instructions.symbol})," \u2197"]})]})]}),jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:pt-3",children:[ae!==null&&jsx(D,{name:t.pay.rate,children:b(t.pay.rateValue,{symbol:i.instructions.symbol,price:Ur(ae,n),currency:a.invoice.currency})}),jsx(D,{name:t.pay.networkFee,children:w!=="transfer"?jsx("span",{className:"novapay:text-[var(--tuwa-success-text)]",children:b(t.pay.merchantPaysGas,{merchant:da})}):_?b(t.pay.gasEstimate,{amount:`${$(String(_.amount),_.decimals,n)} ${_.symbol}`}):t.pay.gasFromWallet}),jsxs(D,{name:t.pay.to,children:[Y(i.instructions.to)," ",jsx("span",{className:"novapay:font-sans novapay:text-[var(--tuwa-text-secondary)]",children:da})]})]}),oe&&jsx(J,{children:oe})]}),jsxs(K,{children:[jsx(U,{busy:te,disabled:la.disabled,onClick:la.run,children:la.label}),jsxs("div",{className:"novapay:flex novapay:items-center novapay:justify-between novapay:gap-3",children:[jsx(W,{onClick:l,children:t.pay.back}),i.gasless&&jsx(W,{onClick:()=>d(!f),children:f?b(t.pay.payGasless,{merchant:da}):t.pay.payWithGas})]}),jsx("p",{className:"novapay:m-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:b(t.pay.disclaimer,{merchant:da})})]})]}),Qa&&jsx(ce,{kind:Qa,walletName:s?.name??"",walletId:s?.walletId??"",amount:xa(Z.send),merchant:da,network:fa,to:Y(i.instructions.to),priceTime:ha?null:ua(ka),onRetry:w==="relay"?()=>{F.pay();}:void 0,onCancel:F.dismiss})]})}var $e=4;function uo(a){let{size:e,data:o}=encode(a,{ecc:"M",border:0}),t="";return o.forEach((n,r)=>n.forEach((s,c)=>{s&&(t+=`M${c+$e} ${r+$e}h1v1h-1z`);})),{size:e+$e*2,path:t}}function Ue({value:a,label:e,className:o}){let{size:t,path:n}=useMemo(()=>uo(a),[a]);return jsxs("svg",{role:"img","aria-label":e,viewBox:`0 0 ${t} ${t}`,shapeRendering:"crispEdges",className:cn$1("novapay:block novapay:rounded-[var(--tuwa-rounded-corners)]",o),children:[jsx("rect",{width:t,height:t,fill:"#ffffff"}),jsx("path",{d:n,fill:"#111827"})]})}function Zr({payUrl:a}){let{labels:e,backToMethods:o}=C();return jsxs(Fragment,{children:[jsx(ya,{title:e.qr.handoffTitle,subtitle:e.qr.handoffHint,children:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:items-center novapay:gap-3 novapay:py-2",children:[jsx(Ue,{value:a,label:e.qr.handoffCode,className:"novapay:h-48 novapay:w-48"}),jsx(za,{text:a,label:e.qr.copyLink,copiedLabel:e.pay.copied,children:e.qr.copyLink}),jsx("p",{className:"novapay:m-0 novapay:max-w-xs novapay:text-center novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:e.qr.handoffNote})]})}),jsx(K,{children:jsx(W,{onClick:o,children:e.qr.back})})]})}function yo(){let{checkout:a,state:e,store:o,labels:t,locale:n,now:r,payUrl:s,backToMethods:c}=C(),y=e.quote;if(!a)return null;if(!y||y.instructions.family!=="solana")return s?jsx(Zr,{payUrl:s}):null;let{instructions:l}=y,u=G(na(l)),i=`${$(y.amountToSend,y.decimals,n)} ${l.symbol}`,v=y.expiresAt?Date.parse(y.expiresAt)-r:Number.POSITIVE_INFINITY,m=v<=0,b$1=e.phase==="quoting";return jsxs(Fragment,{children:[jsxs(ya,{title:t.qr.solanaTitle,subtitle:t.qr.solanaHint,children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:items-center novapay:gap-4 novapay:sm:flex-row novapay:sm:items-start",children:[jsx(Ue,{value:l.solanaPayUrl,label:b(t.qr.solanaCode,{amount:i}),className:cn$1("novapay:h-44 novapay:w-44 novapay:shrink-0",m&&"novapay:opacity-30")}),jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-2 novapay:text-xs",children:[jsxs("ol",{className:"novapay:m-0 novapay:flex novapay:list-decimal novapay:flex-col novapay:gap-1 novapay:pl-4",children:[jsx("li",{children:t.qr.scanStep}),jsx("li",{children:t.qr.approveStep})]}),jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:gap-2",children:[jsx("span",{className:cn$1(x,"novapay:text-2xl novapay:font-bold"),children:$(y.amountToSend,y.decimals,n)}),jsx(za,{text:se(y.amountToSend,y.decimals),label:t.pay.copyAmount,copiedLabel:t.pay.copied})]}),jsxs("span",{className:cn$1(x,"novapay:text-[var(--tuwa-text-secondary)]"),children:[l.symbol," \xB7 ",u," \xB7 ",Y(l.to)]}),!m&&jsxs(Fragment,{children:[jsxs("span",{role:"status",className:"novapay:flex novapay:items-center novapay:gap-1.5",children:[jsx(ArrowPathIcon,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5 novapay:animate-spin novapay:motion-reduce:animate-none"}),t.qr.waiting]}),jsx("span",{role:"timer","aria-live":"off",className:"novapay:text-[var(--tuwa-text-secondary)]",children:b(t.pay.priceLocked,{time:ua(v)})})]})]})]}),m&&jsx(J,{children:t.pay.priceExpired}),jsxs("p",{className:"novapay:m-0 novapay:flex novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-pending-bg)] novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-pending-text)]",children:[jsx(ExclamationTriangleIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),t.qr.exchangeWarning]})]}),jsxs(K,{children:[m?jsx(U,{busy:b$1,onClick:()=>{o.getState().requestQuote();},children:t.pay.newPrice}):jsx("a",{href:l.solanaPayUrl,className:cn$1(x,"novapay:inline-flex novapay:h-11 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:bg-[var(--tuwa-button-primary-bg)] novapay:text-sm novapay:font-bold novapay:text-[var(--tuwa-text-on-accent)] novapay:no-underline novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)]",A),children:t.qr.openInWallet}),jsx(W,{onClick:c,children:t.qr.back})]})]})}function ss(){let{labels:a}=C();return jsxs("div",{role:"status",className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:p-8 novapay:text-sm novapay:text-[var(--tuwa-text-secondary)]",children:[jsx(ArrowPathIcon,{"aria-hidden":true,className:"novapay:h-6 novapay:w-6 novapay:animate-spin novapay:motion-reduce:animate-none"}),a.common.loading]})}function ps(){let{labels:a,state:e,store:o}=C(),t=e.error?.code==="checkout_not_found";return jsxs("div",{role:"alert",className:"novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:p-8 novapay:text-center",children:[jsx(ExclamationTriangleIcon,{"aria-hidden":true,className:"novapay:h-7 novapay:w-7 novapay:text-[var(--tuwa-error-icon)]"}),jsx("h2",{className:cn$1(x,"novapay:m-0 novapay:text-base novapay:font-bold"),children:a.error.title}),jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-[13px] novapay:text-[var(--tuwa-text-secondary)]",children:t?a.error.notFound:a.error.generic}),!t&&jsx("button",{type:"button",onClick:()=>{o.getState().load();},className:cn$1(x,"novapay:h-9 novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border-0 novapay:bg-[var(--tuwa-standart-button-bg)] novapay:px-4 novapay:text-xs novapay:font-bold novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-standart-button-hover)]",A),children:a.common.retry})]})}function is(){let{screen:a}=C();return a==="loading"?jsx(ss,{}):a==="error"?jsx(ps,{}):a==="buyer"?jsx(vt,{}):a==="method"?jsx($t,{}):a==="pay"?jsx(lo,{}):a==="qr"?jsx(yo,{}):a==="confirm"?jsx(Ft,{}):a==="paid"?jsx(Qt,{}):a==="autoPay"?jsx(it,{}):jsx(Ut,{kind:a})}function cs({className:a,withDetails:e,leave:o}){let{checkout:t,locale:n,labels:r,now:s}=C(),[c,y]=useState(""),l=useRef(null),u=t?.invoice.dueAt?Date.parse(t.invoice.dueAt):null;return useEffect(()=>{if(u===null)return;let i=u-s,v=xt(l.current,i);l.current=i,v!==null&&y(v===1?r.summary.oneMinuteLeft:b(r.summary.minutesLeft,{minutes:v}));},[u,s,r]),jsxs("div",{lang:n,className:cn$1("novapay:relative novapay:flex novapay:w-full novapay:flex-col novapay:overflow-hidden novapay:bg-[var(--tuwa-bg-primary)] novapay:text-[var(--tuwa-text-primary)] novapay:sm:h-[600px] novapay:sm:w-[760px] novapay:sm:flex-row",a),children:[t&&jsx("aside",{className:"novapay:hidden novapay:w-[286px] novapay:shrink-0 novapay:border-r novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:p-5 novapay:sm:block",children:jsx(Ct,{})}),jsxs("div",{className:"novapay:flex novapay:min-h-0 novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx(Tt,{withDetails:e}),jsxs("div",{className:"novapay:sm:hidden",children:[t&&jsx(Pt,{}),jsx(At,{withDetails:e})]}),jsx("div",{className:"novapay:flex novapay:min-h-0 novapay:flex-1 novapay:flex-col novapay:overflow-y-auto",children:jsx(is,{})})]}),jsx("div",{role:"status","aria-live":"polite",className:"novapay:sr-only",children:c}),o&&jsx(Dt,{onStay:o.onStay,onLeave:o.onLeave})]})}function yu({token:a,display:e="modal",open:o=true,onOpenChange:t,onClose:n,baseUrl:r,api:s,EventSource:c,pollMs:y,payUrl:l,onConnectWallet:u,onPaid:i,autoReturnSeconds:v=5,onContact:m,className:b$1}){let N=we(),[S,T]=useState({from:a,token:a}),f=S.from===a?S.token:a,d=zt({token:f,baseUrl:r??N.baseUrl,api:s,EventSource:c,pollMs:y}),h=Yt(d,Q=>Q),w=h.checkout,B=h.locale??w?.invoice.locale??"en",_=oo(B),F=Jt(1e3,!!w),g=Zt(),j=ro(u),Ba=N.adapters,[da,fa]=useState("wallet"),[xa,Z]=useState(false),[ka,ha]=useState(false),[Ce,Aa]=useState(false),[ae,ee]=useState(f);ae!==f&&(ee(f),Z(false),ha(false),fa("wallet"));let ba=useRef(null),Va=dt(h,{payWith:da,handoff:xa,autoPay:ka});Vt(h.phase,w?.invoice,i);let te=Q=>Ba?.find(Ra=>Ra.family===Q),oe=to({store:d,open:e!=="modal"||o,adapterFor:te,pulsar:N.pulsar,labels:_,locale:B}),_a=useEffectEvent(()=>{if(!g||!w)return;let{quote:Q,phase:Ra}=d.getState();if(ba.current){let ne=w.methods.find(fo=>fo.id===ba.current),Qe=ne?ma(g,ne):null;if(!Qe)return;ba.current=null,d.getState().setPayer(Qe),d.getState().requestQuote();return}if(Ra!=="awaitingPayment"||!Q?.payer)return;let ja=w.methods.find(ne=>ne.id===Q.methodId),Pe=ja?ma(g,ja):null;if(Pe!==Q.payer){if(!Pe)return d.getState().releaseQuote();d.getState().setPayer(Pe),d.getState().requestQuote();}});useEffect(()=>_a(),[g?.address,g?.chainId,g?.connectorType]),useEffect(()=>{j.connecting||(ba.current=null);},[j.connecting]);let[la,Qa]=useState(false);Va==="buyer"&&!la&&Qa(true);let z=useMemo(()=>e==="modal"?()=>t?t(false):n?.():n,[e,t,n]),_e=jsx(Ze,{value:{store:d,state:h,checkout:w,screen:Va,locale:B,labels:_,now:F,close:z&&(()=>Ae(d.getState().phase)?Aa(true):z()),wallet:g,payWith:da,setPayWith:fa,payUrl:l,connectWallet:Q=>{let Ra=aa(Q);ba.current=Q.id;let ja=Ra!==null&&j.connect(Ra);return ja||(ba.current=null),ja},adapterFor:te,handoff:xa,setHandoff:Z,backToMethods:()=>{Z(false),d.getState().releaseQuote();},onPaymentSent:oe,autoPay:ka,setAutoPay:ha,openInvoice:Q=>T({from:a,token:Q}),onContact:m,autoReturnSeconds:v},children:jsx(MotionConfig,{reducedMotion:"user",children:jsx(cs,{withDetails:la,leave:Ce?{onStay:()=>Aa(false),onLeave:()=>{Aa(false),d.getState().releaseQuote(),z?.();}}:null,className:e==="modal"?b$1:void 0})})});return e==="modal"?jsx(Dialog,{open:o,onOpenChange:Q=>{if(!Q&&Ae(d.getState().phase))return Aa(true);t?.(Q),Q||n?.();},children:jsxs(DialogContent,{className:"novapay:w-full novapay:sm:w-auto",children:[jsx(DialogTitle,{className:"novapay:sr-only",children:b(_.common.dialogTitle,{merchant:w?.merchant.name??""})}),_e]})}):jsx("section",{"aria-label":b(_.common.dialogTitle,{merchant:w?.merchant.name??""}),className:cn$1("novapay:w-full novapay:overflow-hidden novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:sm:w-[760px]",e==="page"&&"novapay:mx-auto novapay:my-8",b$1),children:_e})}function Fu({baseUrl:a,labels:e,customization:o,adapters:t,pulsar:n,children:r}){let s=useMemo(()=>({baseUrl:a,labels:e,customization:o,adapters:t,pulsar:n}),[a,e,o,t,n]);return jsx(ge.Provider,{value:s,children:r})}export{it as AutoPayScreen,vt as BuyerScreen,Ie as CheckoutContext,Ze as CheckoutContextProvider,Tt as CheckoutHeader,Re as CheckoutStepper,Ct as CheckoutSummary,Pt as CompactSummary,Ft as ConfirmScreen,Zo as DEADLINE_ANNOUNCEMENTS,sn as DeadlineTimer,Dt as LeaveDialog,It as LocaleSwitcher,Fe as MerchantBadge,$t as MethodScreen,At as MobileSteps,ge as NovaPaymentsContext,Fu as NovaPaymentsProvider,kt as OrderLines,pn as OrderTotal,Ut as OutcomeScreen,Qt as PaidScreen,lo as PayScreen,yu as PaymentCheckout,Be as QUOTE_WARNING_MS,yo as QrScreen,wt as SellerDetailsContent,cn as SummaryFooter,ce as WalletPrompt,nt as autoPayTerms,Rt as balanceShortfall,se as baseUnitsToDecimal,Ee as buyerFields,lt as buyerIssues,et as canPayWithQr,dt as checkoutScreen,Me as checkoutSteps,ut as cleanBuyer,at as connectedWallet,ot as contactHref,mt as countryOptions,xt as deadlineAnnouncement,ua as formatCountdown,H as formatFiat,rt as formatPeriod,$ as formatTokenAmount,ft as groupMethodsByToken,eo as handOverPayment,na as instructionsChainId,ue as invoiceTotals,ht as isQuoteEnding,pe as methodErrorText,aa as methodFamily,tt as methodToken,X as minorToDecimal,Ae as needsLeaveConfirm,G as networkName,po as payInvoice,Lt as payPath,ma as payerFor,Te as priceAdjustment,uo as qrPath,Mt as quoteAmounts,Bt as quoteRate,Y as shortAddress,ao as shouldHandOver,st as underpaidRest,Xa as useAsyncValue,_t as useAutoReturn,C as useCheckoutContext,Yt as useCheckoutState,zt as useCheckoutStore,Zt as useConnectedWallet,we as useNovaPayments,Jt as useNow,Vt as usePaidCallback,co as usePayment,de as usePaymentFacts,to as usePaymentHandOver,oo as usePaymentsLabels,ro as useWalletConnection,So as walletLabel};
|