@tuwaio/nova-payments 0.5.1 → 0.6.1

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.
Files changed (40) hide show
  1. package/dist/chunk-BZLZLS4M.js +1 -0
  2. package/dist/chunk-GYQQA7PP.cjs +1 -0
  3. package/dist/de-7KHJV7AA.cjs +1 -0
  4. package/dist/de-P3LQGPPB.js +1 -0
  5. package/dist/es-2VTQFYQ3.cjs +1 -0
  6. package/dist/es-FOTJ6TZM.js +1 -0
  7. package/dist/evm/index.cjs +1 -1
  8. package/dist/evm/index.js +1 -1
  9. package/dist/i18n/index.cjs +1 -1
  10. package/dist/i18n/index.d.cts +2 -2
  11. package/dist/i18n/index.d.ts +2 -2
  12. package/dist/i18n/index.js +1 -1
  13. package/dist/index.cjs +2 -2
  14. package/dist/index.css +1 -1
  15. package/dist/index.d.cts +19 -8
  16. package/dist/index.d.ts +19 -8
  17. package/dist/index.js +2 -2
  18. package/dist/it-UMWTJDZC.js +1 -0
  19. package/dist/it-X7ZZ26HA.cjs +1 -0
  20. package/dist/{locales-fU-NVESw.d.cts → locales-ktZpTqwO.d.cts} +10 -0
  21. package/dist/{locales-fU-NVESw.d.ts → locales-ktZpTqwO.d.ts} +10 -0
  22. package/dist/{types-DQDwgCpt.d.ts → types-CratTkKj.d.cts} +19 -3
  23. package/dist/{types-DQDwgCpt.d.cts → types-CratTkKj.d.ts} +19 -3
  24. package/dist/uk-BHFSEFI5.cjs +1 -0
  25. package/dist/uk-K3ZCK3VC.js +1 -0
  26. package/dist/zhCN-JPT6UGTX.js +1 -0
  27. package/dist/zhCN-QI3WCAPE.cjs +1 -0
  28. package/package.json +23 -22
  29. package/dist/chunk-BPBRT7WV.cjs +0 -1
  30. package/dist/chunk-SB5LW2OQ.js +0 -1
  31. package/dist/de-PVPQNE4K.js +0 -1
  32. package/dist/de-RZFQ3674.cjs +0 -1
  33. package/dist/es-GOJORJOI.js +0 -1
  34. package/dist/es-LRJYQNXS.cjs +0 -1
  35. package/dist/it-AHKP5KMI.cjs +0 -1
  36. package/dist/it-AYCHUHO5.js +0 -1
  37. package/dist/uk-3MU32HNY.js +0 -1
  38. package/dist/uk-ITONA5SG.cjs +0 -1
  39. package/dist/zhCN-EOV4NMX5.js +0 -1
  40. package/dist/zhCN-W2PLK7SO.cjs +0 -1
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import {c,b,e,h,g,i,j,f,d}from'./chunk-SB5LW2OQ.js';import {b as b$1,a}from'./chunk-7HSDAUKN.js';export{a as PaymentWalletError,b as walletErrorKind}from'./chunk-7HSDAUKN.js';import {getChainName,cn as cn$1,DrawnCheck,CloseIcon,MorphText,WalletIcon,Dialog,DialogContent,DialogTitle,TokenIcon,QuasarLoader,StatusEdge,NetworkIcon,NovaSetIcon,CopyIcon,useNovaIcons,DrawnCross,pixelFlight}from'@tuwaio/nova-core';import {createContext,lazy,useContext,useState,useId,useMemo,Fragment,useRef,useEffect,useEffectEvent,useCallback,Suspense,useLayoutEffect}from'react';import {LockClosedIcon,FingerPrintIcon,QrCodeIcon,DevicePhoneMobileIcon,ArrowDownTrayIcon,NoSymbolIcon,ArrowPathRoundedSquareIcon,ArrowUturnLeftIcon,MagnifyingGlassIcon}from'@tuwaio/nova-icons/24/outline';import {jsxs,jsx,Fragment as Fragment$1}from'react/jsx-runtime';import {HashLink,TxProgressIndicator,TxStatusVisual}from'@tuwaio/nova-transactions';import {parseCaip2ChainId,toCaip2ChainId,formatCaip10AccountId,toEvmChainId,parseCaip19AssetId,parseCaip10AccountId,formatBaseUnits,shortAddress,OrbitAdapter,getAdapterFromConnectorType,getConnectorTypeFromName,formatConnectorName,getSolanaCluster,isSameAddress}from'@tuwaio/orbit-core';export{shortAddress}from'@tuwaio/orbit-core';import {useLabels,NovaTransactionsLabelsProvider}from'@tuwaio/nova-transactions/providers';import {MotionConfig,AnimatePresence}from'framer-motion';import {createCheckoutStore,payoutAddressesOf,withPayoutAddresses}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 ra=createContext(null),Go=ra.Provider;function I(){let e=useContext(ra);if(!e)throw new Error("useCheckoutContext must be used inside PaymentCheckout");return e}function qe(){return useContext(ra)}var Fc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Qo="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(" "),Mc=new Set(Qo);function Ya(e,t){let a=e==="full"||t,n=[{name:"email",required:true,autoComplete:"email",type:"email"}];return a?[...n,{name:"name",required:true,autoComplete:t?"organization":"name",type:"text"},{name:"country",required:true,autoComplete:"country",type:"country"},{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"},...t?Bc():[]]:n}var Bc=()=>[{name:"taxId",required:true,autoComplete:"off",type:"text"},{name:"registrationNumber",required:false,autoComplete:"off",type:"text"}];function jo(e,t,a){let n={};for(let o of Ya(t,a)){let r=e[o.name]?.trim()??"";r?o.type==="email"&&!Fc.test(r)?n[o.name]="email":o.type==="country"&&!Mc.has(r.toUpperCase())&&(n[o.name]="country"):o.required&&(n[o.name]="required");}return n}function Yo(e){let t={};for(let[a,n]of Object.entries(e)){let o=n?.trim();o&&(t[a]=a==="country"?o.toUpperCase():o);}return t}function Zo(e){let t=new Intl.DisplayNames([e],{type:"region"});return Qo.map(a=>({code:a,name:t.of(a)??a})).sort((a,n)=>a.name.localeCompare(n.name,e))}var ce="novapay:focus-visible:outline-2 novapay:focus-visible:outline-offset-2 novapay:focus-visible:outline-[var(--tuwa-text-accent)]",Pt=`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-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:px-1.5 novapay:text-[var(--tuwa-text-primary)] novapay:cursor-pointer novapay:transition-colors novapay:hover:bg-[var(--tuwa-standart-button-hover)] ${ce}`,$="novapay:font-mono novapay:tabular-nums",nt="novapay:font-mono novapay:font-bold novapay:uppercase novapay:tracking-[0.12em]",Oe=`${nt} novapay:text-[11px] novapay:leading-4 novapay:text-[var(--tuwa-text-secondary)]`,en=`${nt} novapay:inline-flex novapay:shrink-0 novapay:items-center novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-1.5 novapay:py-0.5 novapay:text-[10px] novapay:leading-3`,tn={neutral:"novapay:border-[var(--tuwa-border-strong)] novapay:text-[var(--tuwa-text-primary)]",accent:"novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",success:"novapay:border-[color-mix(in_srgb,var(--tuwa-success-icon)_35%,transparent)] novapay:bg-[var(--tuwa-success-bg)] novapay:text-[var(--tuwa-success-text)]",pending:"novapay:border-[color-mix(in_srgb,var(--tuwa-pending-icon)_35%,transparent)] novapay:bg-[var(--tuwa-pending-bg)] novapay:text-[var(--tuwa-pending-text)]",error:"novapay:border-[color-mix(in_srgb,var(--tuwa-error-icon)_35%,transparent)] novapay:bg-[var(--tuwa-error-bg)] novapay:text-[var(--tuwa-error-text)]"},at=`novapay-title ${$} novapay:m-0 novapay:text-base novapay:font-bold novapay:text-balance novapay:outline-none`,Nt={tabIndex:-1,"data-novapay-heading":""},Jo=`${nt} novapay:box-border novapay:inline-flex novapay:min-h-11 novapay:w-full novapay:min-w-0 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2 novapay:text-center novapay:text-xs novapay:leading-4 novapay:no-underline novapay:transition-colors novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${ce}`,Tt=`tuwa-solid ${Jo} novapay:border-[var(--tuwa-button-primary-bg)] novapay:bg-[var(--tuwa-button-primary-bg)] novapay:text-[var(--tuwa-text-on-accent)] novapay:hover:border-[var(--tuwa-button-primary-bg-hover)] novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)]`,sa=`${Jo} novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-standart-button-hover)]`,nn=`${nt} novapay:inline-flex novapay:min-h-7 novapay:shrink-0 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:px-2.5 novapay:py-1 novapay:text-[10px] novapay:leading-3 novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors novapay:hover:bg-[var(--tuwa-standart-button-hover)] novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${ce}`,Xo=`tuwa-solid ${nt} novapay:inline-flex novapay:min-h-8 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-button-primary-bg)] novapay:bg-[var(--tuwa-button-primary-bg)] novapay:px-3 novapay:py-1.5 novapay:text-center novapay:text-[11px] novapay:leading-4 novapay:text-[var(--tuwa-text-on-accent)] novapay:transition-colors novapay:hover:border-[var(--tuwa-button-primary-bg-hover)] novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)] novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${ce}`,ia="novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[color-mix(in_srgb,var(--tuwa-pending-icon)_35%,transparent)] novapay:bg-[var(--tuwa-pending-bg)] novapay:text-[var(--tuwa-pending-text)]";function ca(e){return e==="modal"?{frame:"novapay:sm:w-[min(760px,calc(100vw_-_2rem_-_2px))]",section:""}:{frame:"",section:`novapay:box-border ${e==="page"?"novapay:w-[880px]":"novapay:w-[760px]"} novapay:max-w-full`}}var er={default:{frame:"tuwa-scanlines novapay:relative novapay:box-border 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-[680px] novapay:sm:flex-row",aside:"tuwa-scanlines 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",main:"novapay:flex novapay:min-h-0 novapay:min-w-0 novapay:flex-1 novapay:flex-col",area:"novapay:@container novapay:flex novapay:min-h-0 novapay:flex-1 novapay:flex-col novapay:overflow-y-auto"},page:{frame:"tuwa-scanlines novapay:relative novapay:box-border novapay:flex novapay:w-full novapay:flex-1 novapay:flex-col novapay:bg-[var(--tuwa-bg-primary)] novapay:text-[var(--tuwa-text-primary)] novapay:sm:min-h-[calc(var(--novapay-page-floor)_-_2px)] novapay:sm:flex-row",aside:"novapay-page-aside tuwa-scanlines novapay:hidden novapay:w-[clamp(260px,36.4%,320px)] novapay:shrink-0 novapay:flex-col novapay:border-r novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:p-5 novapay:sm:flex",main:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",area:"novapay:@container novapay:flex novapay:flex-1 novapay:flex-col"}};function tr(e){return e.length<=7?"novapay:text-[36px]":e.length<=10?"novapay:text-[30px]":e.length<=13?"novapay:text-[24px]":"novapay:text-[20px]"}function dt(){return useNovaIcons().outline}function an(e){return jsx(NovaSetIcon,{solid:"ChevronDownIcon",...e})}function nr(e){return jsx(NovaSetIcon,{solid:"GlobeAltIcon",...e})}function on(e){return jsx(NovaSetIcon,{outline:"ClockIcon",...e})}function ar(e){return jsx(NovaSetIcon,{outline:"DocumentTextIcon",...e})}function yt(e){return jsx(NovaSetIcon,{outline:"ExclamationTriangleIcon",...e})}function or(e){return jsx(NovaSetIcon,{outline:"InformationCircleIcon",...e})}function rr(e){return jsx(NovaSetIcon,{outline:"WalletIcon",...e})}function sr(e){let a=dt().ArrowDownTrayIcon??ArrowDownTrayIcon;return jsx(a,{...e})}function ir(e){let a=dt().ArrowPathRoundedSquareIcon??ArrowPathRoundedSquareIcon;return jsx(a,{...e})}function cr(e){let a=dt().ArrowUturnLeftIcon??ArrowUturnLeftIcon;return jsx(a,{...e})}function lr(e){let a=dt().DevicePhoneMobileIcon??DevicePhoneMobileIcon;return jsx(a,{...e})}function pr(e){let a=dt().FingerPrintIcon??FingerPrintIcon;return jsx(a,{...e})}function ur(e){let a=dt().LockClosedIcon??LockClosedIcon;return jsx(a,{...e})}function mr(e){let a=dt().MagnifyingGlassIcon??MagnifyingGlassIcon;return jsx(a,{...e})}function dr(e){let a=dt().NoSymbolIcon??NoSymbolIcon;return jsx(a,{...e})}function yr(e){let a=dt().QrCodeIcon??QrCodeIcon;return jsx(a,{...e})}var fr={metamask:"MetaMask",walletconnect:"WalletConnect",coinbase:"Coinbase Wallet",okx:"OKX Wallet",trust:"Trust Wallet",injected:"Browser wallet"};function nl(e,t){let a=e.slice(e.indexOf(":")+1).toLowerCase();return a==="injected"?fr.injected:t?.trim()||fr[a]||a.charAt(0).toUpperCase()+a.slice(1)}var Ja=e=>/^data:image\//i.test(e)||/^https:\/\//i.test(e),Za=e=>{let t=typeof e=="string"?e.trim():"";return t&&Ja(t)?t:void 0};function al(e,t,a){let n=getAdapterFromConnectorType(t),o=e[n];if(!Array.isArray(o))return;let r=o.filter(s=>typeof s=="object"&&s!==null&&typeof s.name=="string"&&getConnectorTypeFromName(n,formatConnectorName(s.name))===t);return a&&r.find(s=>Za(s.icon)===a)||r[0]}var Rt=e=>{let t=parseCaip2ChainId(e)?.namespace;return t==="eip155"||t==="solana"?t:null};function vr(e,t){if(!e?.address)return null;let a=toCaip2ChainId(e.chainId),n=a?Rt(a):null;if(!a||!n)return null;let o=Za(e.icon),r=t?al(t,e.connectorType,o):void 0;return {address:e.address,chainId:a,family:n,connectorType:e.connectorType,walletId:e.connectorType.slice(e.connectorType.indexOf(":")+1).toLowerCase(),name:nl(e.connectorType,typeof r?.name=="string"?r.name:void 0),icon:o??Za(r?.icon),connection:e}}function Ye(e){return Rt(e.chainId)}function Ue(e,t){return !e||e.family!==Ye(t)?null:formatCaip10AccountId(t.chainId,e.address)??null}function hr(e,t){let a=Ye(e);return a==="solana"||a==="eip155"&&!!t}function Xa(e){let t=a=>String(Number((a/100).toFixed(2)));return e.discountBps>0?{kind:"discount",percent:t(e.discountBps)}:e.markupBps>0?{kind:"markup",percent:t(e.markupBps)}:null}function ve(e){return getChainName(toEvmChainId(e)??e).name}function xr(e){let t=e.assetId?parseCaip19AssetId(e.assetId):void 0;return !t||t.assetNamespace==="slip44"?"native":t.assetReference}var ol=new Set(["awaitingPayment","selectMethod","underpaid"]),rl="too_many_payments";function eo(e,t={}){if(t.labelsReady===false&&e.phase!=="error")return "loading";if(e.phase==="unconfirmed")return It(e.error)==="retrying"?"confirm":"unconfirmed";if(t.afterFailure&&e.error?.code==="payment_failed"&&ol.has(e.phase))return "failed";let a=e.payerProof==="required"||e.payerProof==="confirming"||e.payerProof==="confirmed"&&!e.error,n=!!(t.confirmWallet&&a);switch(e.phase){case "selectMethod":return n&&!(t.handoff&&t.payWith==="qr")?"confirmWallet":t.handoff&&t.payWith==="qr"?"qr":"method";case "underpaid":return n?"confirmWallet":"underpaid";case "quoting":return e.quote?t.payWith==="qr"||e.quote.payer===null?"qr":"pay":t.confirmWallet?"confirmWallet":"method";case "awaitingPayment":case "submitting":return e.phase==="submitting"&&!e.quote?"confirm":t.payWith==="qr"||e.quote?.payer===null?"qr":"pay";case "confirming":return "confirm";case "cancelled":return e.checkout?.invoice.replacedBy?"replaced":"cancelled";default:return e.phase}}var sl={buyer:"details",method:"method",confirmWallet:"method",pay:"pay",qr:"pay",underpaid:"pay",confirm:"confirm",unconfirmed:"confirm",failed:"confirm"};function gr(e,t={}){let a=sl[e];if(!a)return null;let n=[...t.withDetails||a==="details"?["details"]:[],"method","pay","confirm"],o=n.indexOf(a);return n.map((r,s)=>({key:r,state:s<o?"done":s===o?"current":"upcoming"}))}function br(e={}){return [...e.withDetails?["details"]:[],"method","pay","confirm"].map(a=>({key:a,state:"done"}))}function wr(e,t){let a=s=>s.chainId===t?0:s.featured?1:2,n=new Map;for(let s of e)n.set(s.symbol,[...n.get(s.symbol)??[],s]);let o=[...n].map(([s,i])=>{let c=[...i].sort((l,p)=>a(l)-a(p));return {symbol:s,methods:c,featured:i.some(l=>l.featured),inWallet:!!t&&i.some(l=>l.chainId===t)}}),r=s=>s.inWallet?0:s.featured?1:2;return o.sort((s,i)=>r(s)-r(i))}var il=new Set(["open","processing","underpaid"]),cl=new Set(["loading","error","buyer","method","confirmWallet","pay","qr","failed","underpaid","blocked"]);function Ln(e,t,a){return il.has(e)?t==="confirm"||t==="unconfirmed"?"confirming":cl.has(t)?e==="underpaid"&&a===false?"closed":"paying":null:null}var ll=[10,5,1];function kr(e,t,a=ll){if(e===null||t<=0)return null;let n=a.filter(o=>e>o*6e4&&t<=o*6e4);return n.length?Math.min(...n):null}var to=6e4;function Cr(e){let{phase:t,quotePayer:a,payer:n}=e;return t!=="awaitingPayment"||!a||n===a?"keep":n?"lock":"release"}function Sr(e){let{open:t,storePayer:a,payer:n,paysRest:o}=e;return !t||n===a?"keep":n&&o?"follow":"leave"}function Pr(e){return e>0&&e<=to}function Nr(e){return e.amlScreening!==false}function ot(e){return e.paymentOnTheWay??!!(e.txKey||e.txHash)}function ft(e,t){let a=t?.invoice?.pendingPayments??0;return e.invoicePaymentOnTheWay??a>0}function Tr({state:e,checkout:t,handedOverAt:a,dueAt:n}){let o=e.paymentSentInTime,r=ot({paymentOnTheWay:e.paymentOnTheWay,txKey:e.txKey??null,txHash:e.txHash??null});if(typeof o=="boolean"&&r)return o;let s=t.invoice.paymentCountsUntil;return s===void 0?a!==null&&a<n:a!==null&&a>=n?false:(e.paymentCountsUntil===void 0?s:e.paymentCountsUntil)!==null}var no="settlement_failed",Rr="tx_already_used";function Ir(e){let t=e?.code,a=e?.reason;return (t==="payment_failed"||t==="payment_mismatch")&&!!a&&a!==no}var pl=new Set(["no_matching_transfer","reference_missing","too_early","tx_already_used","payer_mismatch","payer_unconfirmed","quote_changed","too_many_parts","too_many_transfers","below_minimum","native_from_contract_unverifiable","invoice_not_payable"]);function vt(e){let t=e?.code,a=e?.reason;return a===no?false:t==="payment_mismatch"?true:t==="payment_failed"&&a!==void 0&&pl.has(a)}function Er(e){let t=e?.reason;return vt(e)&&t===Rr}function qt(e,t){let a=t?.invoice?.unresolvedPayments??0;return e.invoicePaymentUnresolved??a>0}function It(e){let t=e?.code,{reason:a,rechecked:n,stillRead:o}=e??{};return t==="payment_failed"&&a==="unresolved_after_24h"?"closed":a===no&&(t==="payment_unconfirmed"||t==="payment_mismatch")?n===true?"settlementRetrying":"settlementFailed":t!=="payment_unconfirmed"?null:a==="nonce_spent_unexplained"?"nonceSpent":a==="unmined_after_24h"||o===true?"unmined":a===Rr?"takenElsewhere":a==="submit_retrying"?"retrying":a==="submit_failed"?"notReceived":a===rl?"invoiceFull":n===true?"rechecked":"contact"}function Lr(e,t){let{txKey:a}=e.error??{};if(a)return a;let n=t?.invoice?.rejectedPayments;return e.txHash??e.txKey??n?.[0]?.txKey??null}function Ar({picked:e,page:t,invoice:a}){return e&&e.page===t?e.locale:t??a??"en"}function _r(e,t){return e.supportEmail?`mailto:${e.supportEmail}?subject=${encodeURIComponent(t)}`:e.website??null}var Fr={nonceSpent:"unconfirmedNonceSpent",closed:"unconfirmedClosed",takenElsewhere:"unconfirmedTakenElsewhere",settlementRetrying:"unconfirmedSettlementRetrying",settlementFailed:"unconfirmedSettlementFailed",invoiceFull:"unconfirmedInvoiceFull"};function An(e,t,a){let n=e.reason;return n==="expired"?t.pay.failedExpired:n==="cancelled"?t.pay.failedCancelled:n==="reverted"?a?c(t.pay.failed,{network:a}):t.method.paymentFailed:t.pay.didNotGoThrough}function la(e){if(e?.code!=="payment_failed"&&e?.code!=="payment_mismatch")return null;let{txKey:t}=e;return typeof t=="string"&&t?t:null}var ml=new Set(["payer_mismatch","payer_unconfirmed"]);function Ut(e,t,a=""){if(vt(e)){let r=e.reason??"",s=e.unmatched===true;if(r==="quote_changed")return c(t.pay.mismatchChargeUnmatched,{merchant:a});if(r==="too_many_parts")return c(t.pay.mismatchTooManyParts,{merchant:a});if(r==="reference_missing"&&s)return c(t.pay.mismatchNoReferenceUnmatched,{merchant:a});let i=ml.has(r)?s?t.pay.mismatchOtherWalletUnmatched:t.pay.mismatchOtherWallet:s?t.pay.mismatchUnmatchedElsewhere:Er(e)?t.pay.mismatchTakenElsewhere:t.pay.mismatch;return c(i,{merchant:a})}let n=It(e),o=n?Fr[n]:void 0;return o?c(t.outcome[o],{merchant:a}):null}var dl=["buyer","selectMethod","quoting","awaitingPayment"];function ao(e,t,a){if(a==="underpaid")return false;let n=It(t);return dl.includes(e)&&!vt(t)&&!(n&&Fr[n])}function pa(e,t,a=""){let n=Ut(e,t,a);if(n!==null)return n;switch(e.code){case "screening_unavailable":return t.pay.screeningUnavailable;case "request_failed":return t.pay.noAnswer;case "amount_out_of_range":case "method_not_found":case "testnet_required":return t.method.methodUnavailable;case "payer_not_expected":return t.method.payerNotExpected;case "payer_is_recipient":return t.method.payerIsRecipient;case "too_many_payments":return c(t.method.tooManyPayments,{merchant:a});case "too_many_payers":return c(t.method.tooManyPayers,{merchant:a});case "native_from_contract":return t.method.nativeFromSmartWallet;case "rate_limited":return t.method.rateLimited;case "price_unavailable":case "price_no_rpc":return t.method.priceUnavailable;case "consent_required":return t.method.consentRequired;case "payer_proof_required":case "payer_proof_declined":return t.payerProof.text;case "payer_proof_invalid":return t.payerProof.invalid;case "payer_proof_unavailable":return t.payerProof.unavailable;case "payment_failed":return An(e,t);case "rest_method_mismatch":return t.method.restSameMethod;default:return t.error.generic}}function Mr(e,t){if(!e||t===null)return null;let a=BigInt(e.cryptoAmountExpected)-BigInt(t);return a>0n?a.toString():null}function rn(e,t,a,n,o,r=a.pay.restRateEnded){let s=e?.rateHeldUntil?Date.parse(e.rateHeldUntil):null;if(s===null)return null;if(s<=t)return c(r,{merchant:n});let i=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(s);return c(a.pay.restRateUntil,{time:i,merchant:n})}function Et(e){return parseCaip10AccountId(e)?.address??e}function sn(e,t){let a=Et(e),n=Et(t);return a.startsWith("0x")?a.toLowerCase()===n.toLowerCase():a===n}function Br(e){return e&&/^\d+$/.test(e)&&BigInt(e)>0n?e:null}function Or(e){let t=BigInt(e.cryptoAmount),a=e.received?BigInt(e.received):null;if(a&&t>a&&(t-a)*200n>=a)return true;if(!e.atPaymentRate)return false;let n=BigInt(e.atPaymentRate);return n===0n?false:(t>n?t-n:n-t)*200n>=n}var yl=new Set(["needs_review","refunded","expired","cancelled","blocked","error"]);function Dr(e,t,a){return a?e==="paid"?t!==0:!yl.has(e):true}function qr(e,t){return t.withGas||!e.gasless?"transfer":e.gasless.paymaster&&t.canSponsorCalls?"paymaster":e.gasless.relay?"relay":"transfer"}function Ur(e){let t=BigInt(e.amountToSend),a=BigInt(e.amountDue);return !e.transferFee||t<=a?{send:e.amountToSend,receives:e.amountDue,fee:null}:{send:e.amountToSend,receives:e.amountDue,fee:{amount:String(t-a),percent:String(e.transferFee.bps/100)}}}var ua=10000n,Wr=8n;function Hr(e,t){let a=BigInt(e.cryptoAmountExpected);if(!t||a<=0n)return null;let o=BigInt(t)*(ua+BigInt(e.markupBps))*(ua-BigInt(e.discountBps))*10n**BigInt(e.decimals)*10n**Wr/(100n*ua*ua*a);return Number(o)/10**Number(Wr)}function $r(e,t,a=0n){let n=BigInt(t.amountToSend)+a;return e>=n?null:{have:String(e),need:String(n),short:String(n-e)}}function he(e){return e.family==="eip155"?`eip155:${e.chainId}`:e.chainId}var Vr="novapay:normal-case",gl=3,bl={};function wl(e){let[,t="",a="",n=""]=/^(\s*)([\s\S]*?)(\s*)$/.exec(e)??[];return [t,a,n]}function kl(e,t){let a=e.ownerDocument.createElement("span");a.style.cssText="position:absolute;visibility:hidden;white-space:nowrap;pointer-events:none";for(let[o,r]of t){let s=e.ownerDocument.createElement("span");r&&(s.style.textTransform="none"),s.textContent=o,a.append(s);}e.append(a);let{width:n}=a.getBoundingClientRect();return a.remove(),n}function Cl(e,t){let a=getComputedStyle(t),n=[...t.children].filter(s=>s!==e),o=n.reduce((s,i)=>s+i.getBoundingClientRect().width,0),r=(Number.parseFloat(a.columnGap)||0)*n.length;return t.clientWidth-Number.parseFloat(a.paddingLeft)-Number.parseFloat(a.paddingRight)-o-r}function ge({label:e,values:t=bl}){let a=useRef(null),[n,o]=useState(false),[r,s]=useState(gl),i=Object.fromEntries(Object.entries(t).map(([p,m])=>[p,{own:String(m)}])),c=d(e,i).map(p=>typeof p=="string"?[p,false]:[p.own,true]),l=JSON.stringify(c);return useLayoutEffect(()=>{let p=a.current,m=p?.parentElement;if(!p||!m)return;let y=JSON.parse(l),f=()=>{o(kl(p,y)>Cl(p,m)+.5),s(d=>Math.max(d,y.length));};if(f(),typeof ResizeObserver>"u")return;let v=new ResizeObserver(f);return v.observe(m),()=>v.disconnect()},[l]),n?jsx("span",{ref:a,className:"novapay:min-w-0",children:jsx("span",{className:"novapay-label-fade",children:c.map(([p,m],y)=>m?jsx("span",{className:Vr,children:p},y):p)},l)}):jsx("span",{ref:a,className:"novapay:min-w-0 novapay:whitespace-nowrap",children:Array.from({length:Math.max(r,c.length)},(p,m)=>{let[y,f]=c[m]??["",false],[v,d,R]=wl(y);return jsxs(Fragment,{children:[v,jsx(MorphText,{className:f?Vr:void 0,children:d}),R]},m)})})}function Y(e,t,a){let n=e.customization.classNames?.[t];return n?.({screen:e.screen,checkoutState:e.state,checkout:e.checkout,...a})}function Ze({children:e,labels:t}){let a=qe(),n=t??a?.labels,o=useLabels(),r=useMemo(()=>({...o,trackingModal:{...o.trackingModal,progressIndicator:{created:n.confirm.sent,processing:n.confirm.confirming,succeed:n.confirm.paid}},statuses:{...o.statuses,confirmed:n.confirm.confirmed,failed:n.confirm.failed},actions:{...o.actions,viewOnExplorer:n.confirm.viewOnExplorer,copy:n.confirm.copyHash},txError:{...o.txError,copied:n.pay.copied}}),[o,n]);return jsx(NovaTransactionsLabelsProvider,{labels:r,children:e})}var $t=(e,t)=>e?Y(e,t):void 0;function Fn({walletId:e,icon:t}){let[a,n]=useState(null);return t&&t!==a&&Ja(t)?jsx("img",{src:t,alt:"",onError:()=>n(t),className:"novapay:block novapay:h-full novapay:w-full novapay:object-contain"}):jsx(WalletIcon,{walletName:e})}function He({hash:e,chainId:t,explorerUrl:a,labels:n}){let o=qe(),r=a??(t?o?.adapterFor(t.startsWith("solana:")?"solana":"eip155")?.explorerAddressUrl?.({chainId:t,address:e}):void 0);return jsx(Ze,{labels:n,children:jsx(HashLink,{hash:e,explorerUrl:r,variant:"compact",...o?.customization.childCustomizations?.hashLink})})}function ma({walletId:e,walletIcon:t}){return !e&&!t?jsx(QuasarLoader,{size:48,accent:"var(--tuwa-pending-icon)"}):jsx("span",{className:"novapay-chase novapay:relative novapay:flex novapay:h-20 novapay:w-20 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-full)] novapay:border-2 novapay:border-[color-mix(in_srgb,var(--tuwa-pending-text)_25%,transparent)]",children:jsx("span",{className:"novapay:block novapay:h-11 novapay:w-11",children:jsx(Fn,{walletId:e??"",icon:t})})})}function de({title:e,subtitle:t,children:a}){let n=qe(),o=n?.display==="page";return jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-2.5 novapay:px-5 novapay:py-4",o&&"novapay-page-screen",$t(n,"screen")),children:[jsxs("div",{children:[jsx("h2",{...Nt,className:at,children:typeof e=="string"?jsx(MorphText,{wrap:true,children:e}):e}),t&&jsx("p",{className:cn$1("novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",o&&"novapay-page-subtitle"),children:t})]}),a]})}function Z({children:e}){let t=qe(),a=useRef(null),n=t?.display==="page";return useEffect(()=>{let o=a.current,r=n?o?.ownerDocument.documentElement:o?.closest("[data-novapay-scroll]");if(!o||!r||typeof ResizeObserver>"u")return;let s=()=>r.style.scrollPaddingBottom=!n||getComputedStyle(o).position==="sticky"?`${o.offsetHeight+8}px`:"";s();let i=new ResizeObserver(s);return i.observe(o),()=>{i.disconnect(),r.style.scrollPaddingBottom="";}},[n]),jsx("footer",{ref:a,className:cn$1("tuwa-scanlines novapay:empty:hidden novapay:sticky novapay:bottom-0 novapay:z-10 novapay:flex novapay:flex-col novapay:gap-2 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-5 novapay:pb-3.5 novapay:pt-3 novapay:text-center",n&&"novapay-page-footer",$t(t,"footer")),children:e})}function cn({children:e,id:t}){let a=qe()?.display==="page";return jsx("span",{id:t,className:cn$1(Oe,a&&"novapay-page-group"),children:e})}function X({busy:e,children:t,className:a,...n}){let o=qe(),r=$t(o,"primaryButton"),s=o?.customization.components?.PrimaryButton;return s?jsx(s,{busy:e,className:cn$1(a,r),...n,children:t}):jsxs("button",{type:"button","aria-busy":e||void 0,...n,disabled:n.disabled||e,className:cn$1(Tt,a,r),children:[e&&jsx(QuasarLoader,{size:16,accent:"currentColor"}),typeof t=="string"?jsx(ge,{label:t}):t]})}function ae({children:e,className:t,...a}){let n=qe();return jsx("button",{type:"button",...a,className:cn$1(sa,t,$t(n,"secondaryButton")),children:e})}function da({className:e,...t}){return jsxs("span",{className:cn$1("novapay:relative novapay:inline-flex novapay:h-4 novapay:w-4 novapay:shrink-0",e),children:[jsx("input",{type:"checkbox",...t,className:cn$1("novapay:peer novapay:m-0 novapay:box-border novapay:h-4 novapay:w-4 novapay:cursor-pointer novapay:appearance-none novapay:rounded-[var(--tuwa-rounded-full)] novapay:border novapay:border-[var(--tuwa-text-secondary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:transition-colors novapay:checked:border-[var(--tuwa-text-accent)] novapay:checked:bg-[var(--tuwa-text-accent)]",ce)}),jsx(DrawnCheck,{className:"novapay:pointer-events-none novapay:absolute novapay:inset-0 novapay:m-auto novapay:h-3 novapay:w-3 novapay:text-[var(--tuwa-bg-primary)] novapay:opacity-0 novapay:peer-checked:opacity-100"})]})}function $e({children:e}){return jsx("p",{className:"novapay:m-0 novapay:text-center novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:e})}function xe({children:e,className:t}){let a=qe();return jsx("dl",{className:cn$1("tuwa-scanlines novapay:m-0 novapay:flex novapay:w-full novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-left",t,$t(a,"detailsCard")),children:e})}function Q({children:e}){let t=qe();return jsx("p",{role:"alert",className:cn$1("novapay:m-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[color-mix(in_srgb,var(--tuwa-error-icon)_35%,transparent)] novapay:bg-[var(--tuwa-error-bg)] novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-error-text)]",$t(t,"error")),children:e})}function ya({error:e}){let t=qe(),a=la(e);if(!t||!a)return null;let n=t.state.quote??t.checkout?.quote,o=n?he(n.instructions):null,r=n&&o?t.adapterFor(n.instructions.family)?.explorerUrl?.({chainId:o,txKey:a}):void 0;return jsx(Ze,{children:jsx(xe,{children:jsx(H,{name:t.labels.confirm.transaction,children:jsx(HashLink,{hash:a,explorerUrl:r,variant:"compact",...t.customization.childCustomizations?.hashLink})})})})}function Mn({text:e,label:t,copiedLabel:a,children:n}){let[o,r]=useState(false);return useEffect(()=>{if(!o)return;let s=setTimeout(()=>r(false),2e3);return ()=>clearTimeout(s)},[o]),jsxs(Fragment$1,{children:[jsxs("button",{type:"button","aria-label":n?void 0:t,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>r(true),()=>{});},className:cn$1(Pt,"novapay:min-h-6 novapay:min-w-6 novapay:text-xs"),children:[jsx(CopyIcon,{copied:o,className:"novapay:h-3.5 novapay:w-3.5"}),n]}),jsx("span",{role:"status",className:"novapay:sr-only",children:o?a:""})]})}function H({name:e,children:t}){let a=qe();return jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:justify-between novapay:gap-3 novapay:py-2 novapay:text-xs",a?.display==="page"&&"novapay-page-row",$t(a,"detailRow")),children:[jsx("dt",{className:"novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]",children:e}),jsx("dd",{className:cn$1($,"novapay:m-0 novapay:min-w-0 novapay:text-right novapay:break-words"),children:t})]})}function ht({children:e,onClick:t,disabled:a}){return jsx("button",{type:"button",onClick:t,disabled:a,className:cn$1("novapay:disabled:cursor-default novapay:disabled:opacity-50 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",ce),children:e})}var Dl=(e,t,a)=>t==="name"&&a?e.buyer.companyName:e.buyer[t]??t,Wl=(e,t)=>t==="email"?e.buyer.invalidEmail:t==="country"?e.buyer.invalidCountry:e.buyer.required,ql=new Set(["postalCode","city","taxId","registrationNumber"]),Ul=new Set(["name","country","addressLine1","addressLine2"]),Yr=e=>cn$1("novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-[13px] novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors novapay:focus:border-[var(--tuwa-text-accent)]",e?"novapay:border-[var(--tuwa-error-icon)]":"novapay:border-[var(--tuwa-text-secondary)] novapay:hover:border-[var(--tuwa-text-primary)]",ce);function Zr(){let{checkout:e,state:t,store:a,labels:n,locale:o,display:r}=I(),[s,i]=useState({}),[c,l]=useState(false),[p,m]=useState(false),[y,f]=useState(false),v=useId(),d=useMemo(()=>Zo(o),[o]);if(!e||e.buyer.collect==="off")return null;let R=e.buyer.collect,h=Ya(R,c),x=jo(s,R,c),g=(N,b)=>i(L=>({...L,[N]:b})),k=async N=>{if(N.preventDefault(),m(true),Object.keys(x).length>0){document.getElementById(`${v}-${Object.keys(x)[0]}`)?.focus();return}f(true),await a.getState().setBuyer(Yo(s),{company:c}),f(false);};return jsxs("form",{noValidate:true,onSubmit:N=>{k(N);},className:"novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs(de,{title:n.buyer.title,subtitle:n.buyer.subtitle,children:[jsx("div",{className:"novapay:grid novapay:grid-cols-1 novapay:gap-x-3 novapay:gap-y-3.5 novapay:pt-1 novapay:sm:grid-cols-2",children:h.map((N,b)=>{let L=`${v}-${N.name}`,B=p?x[N.name]:void 0,_=N.type==="country"?jsxs("div",{className:"novapay:relative",children:[jsxs("select",{id:L,autoComplete:N.autoComplete,required:N.required,"aria-invalid":!!B,"aria-describedby":B?`${L}-error`:void 0,value:s.country??"",onChange:w=>g("country",w.target.value),className:cn$1(Yr(!!B),"novapay:cursor-pointer novapay:appearance-none novapay:pr-9",!s.country&&"novapay:text-[var(--tuwa-text-secondary)]"),children:[jsx("option",{value:"",children:n.buyer.chooseCountry}),d.map(w=>jsx("option",{value:w.code,children:w.name},w.code))]}),jsx(an,{"aria-hidden":true,className:"novapay:pointer-events-none novapay:absolute novapay:top-1/2 novapay:right-3 novapay:h-4 novapay:w-4 novapay:-translate-y-1/2 novapay:text-[var(--tuwa-text-secondary)]"})]}):jsx("input",{id:L,type:N.type,autoComplete:N.autoComplete,required:N.required,"aria-invalid":!!B,"aria-describedby":B?`${L}-error`:void 0,value:s[N.name]??"",onChange:w=>g(N.name,w.target.value),className:Yr(!!B)});return jsxs(Fragment,{children:[jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-1.5",!ql.has(N.name)&&(r==="page"&&Ul.has(N.name)?"novapay:sm:@max-[519px]:col-span-2":"novapay:sm:col-span-2")),children:[jsxs("label",{htmlFor:L,className:"novapay:text-xs novapay:font-medium novapay:text-[var(--tuwa-text-primary)]",children:[Dl(n,N.name,c),N.required&&jsxs("span",{"aria-hidden":"true",className:"novapay:text-[var(--tuwa-error-text)]",children:[" ","*"]}),!N.required&&jsxs("span",{className:"novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:[" ","(",n.buyer.optional,")"]})]}),_,B&&jsx("span",{id:`${L}-error`,className:"novapay:text-[11px] novapay:text-[var(--tuwa-error-text)]",children:Wl(n,B)})]}),b===0&&e.buyer.companyInvoice&&jsxs("label",{className:cn$1("novapay:flex novapay:cursor-pointer novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2.5 novapay:text-[13px] novapay:transition-colors novapay:sm:col-span-2",c?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]"),children:[jsx(da,{checked:c,onChange:w=>l(w.target.checked)}),jsx("span",{className:"novapay:font-semibold",children:n.buyer.companyInvoice})]})]},N.name)})}),t.error&&t.phase==="buyer"&&jsx(Q,{children:n.buyer.refused})]}),jsx(Z,{children:jsx(X,{type:"submit",busy:y,children:n.buyer.continue})})]})}function Xr({steps:e,labels:t,className:a,stepClassName:n}){let o=e.findIndex(p=>p.state==="current"),r=e.map(p=>t.steps[p.key]).join(""),s=useRef(null),i=useRef(null),[c$1,l]=useState(false);return useEffect(()=>{let p=s.current,m=i.current;if(!p||!m||typeof ResizeObserver>"u")return;let y=()=>l(m.offsetWidth+e.length*32+(e.length-1)*24>p.clientWidth);y();let f=new ResizeObserver(y);return f.observe(p),()=>f.disconnect()},[r,e.length]),jsxs("nav",{ref:s,"aria-label":t.steps.label,className:cn$1("novapay:relative novapay:min-w-0 novapay:flex-1",a),children:[jsx("span",{"aria-hidden":true,className:"novapay:invisible novapay:absolute novapay:h-0 novapay:w-0 novapay:overflow-hidden",children:jsx("span",{ref:i,className:cn$1(nt,"novapay:whitespace-nowrap novapay:text-[11px]"),children:r})}),jsx("ol",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:items-center novapay:gap-1.5 novapay:p-0",children:e.map((p,m)=>{let y=t.steps[p.key];return jsxs("li",{"aria-current":p.state==="current"?"step":void 0,className:cn$1("novapay:flex novapay:min-w-0 novapay:items-center novapay:gap-1.5",m>0&&"novapay:flex-auto",n?.(p,m)),children:[m>0&&jsx("span",{"aria-hidden":true,className:cn$1("novapay:h-px novapay:min-w-2 novapay:flex-1 novapay:transition-colors novapay:duration-300 novapay:motion-reduce:transition-none",p.state==="upcoming"?"novapay:bg-[var(--tuwa-border-primary)]":"novapay:bg-[var(--tuwa-success-icon)]")}),jsx("span",{"aria-hidden":true,className:cn$1($,"novapay:box-border novapay:flex novapay:h-5 novapay:w-5 novapay:shrink-0 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-full)] novapay:border novapay:text-[10px] novapay:font-bold",p.state==="done"&&"novapay:border-[var(--tuwa-success-icon)] novapay:bg-[var(--tuwa-success-icon)] novapay:text-white",p.state==="current"&&"novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",p.state==="upcoming"&&"novapay:border-[var(--tuwa-border-strong)] novapay:text-[var(--tuwa-text-secondary)]"),children:p.state==="done"?jsx(DrawnCheck,{className:"novapay:h-3 novapay:w-3"}):m+1}),jsx("span",{className:cn$1(nt,"novapay:truncate novapay:text-[11px] novapay:leading-4",p.state==="current"?"novapay:text-[var(--tuwa-text-primary)]":"novapay:text-[var(--tuwa-text-secondary)]",c$1&&p.state!=="current"&&"novapay:sr-only"),children:p.state==="current"?jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:sr-only",children:c(t.steps.progress,{current:o+1,total:e.length,name:y})}),jsx("span",{"aria-hidden":true,children:y})]}):y})]},p.key)})})]})}function Re(e,t=2){let a=e.startsWith("-"),n=(a?e.slice(1):e).padStart(t+1,"0");return `${a?"-":""}${n.slice(0,-t)}.${n.slice(-t)}`}var es=e=>new Intl.NumberFormat(e).formatToParts(1.1).find(t=>t.type==="decimal")?.value??".";function ye(e,t){let[a="0",n=""]=(typeof e=="number"?e.toFixed(2):e.trim()).split("."),o=a.startsWith("-"),r=new Intl.NumberFormat(t).format(BigInt(o?a.slice(1):a));return `${o?"-":""}${r}${es(t)}${n.padEnd(2,"0").slice(0,2)}`}function pe(e,t,a){let n=BigInt(e),o=n<0n,r=o?-n:n,s=10n**BigInt(t),i=new Intl.NumberFormat(a).format(r/s),c=(r%s).toString().padStart(t,"0").replace(/0+$/,"").padEnd(2,"0");return `${o?"-":""}${i}${es(a)}${c}`}function ha(e,t,a){let n=10n**BigInt(Math.max(t-6,0)),o=(BigInt(e)+n/2n)/n*n;return o===0n?null:pe(o.toString(),t,a)}function xa(e,t){return formatBaseUnits(e,t)??"0"}var Kt=e=>String(e).padStart(2,"0");function st(e){let t=Math.max(0,Math.floor(e/1e3)),a=Math.floor(t/86400),n=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),r=t%60;return a>0?`${a}d ${Kt(n)}:${Kt(o)}`:n>0?`${Kt(n)}:${Kt(o)}:${Kt(r)}`:`${Kt(o)}:${Kt(r)}`}function pn(e){let t=e.lineItems.reduce((r,s)=>r+BigInt(s.netMinor),0n),a=BigInt(e.totalMinor??t.toString()),n=a-t,o=[...new Set(e.lineItems.filter(r=>Number(r.taxRate)>0).map(r=>r.taxRate))];return {subtotal:Re(t.toString()),tax:n>0n?Re(n.toString()):null,rate:o.length===1?String(Number(o[0])):null,total:Re(a.toString())}}var Ql=e=>{try{return new URL(e).host}catch{return e}};function ga({compact:e=false}){let{checkout:t,state:a,labels:n,display:o}=I(),[r,s]=useState(false);if(!t)return null;let{merchant:i,invoice:c}=t,l=e?"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:[a.logoUrl&&!r?jsx("img",{src:a.logoUrl,alt:"",onError:()=>s(true),className:cn$1(l,"novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:object-contain")}):jsx("span",{"aria-hidden":true,className:cn$1(l,$,"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:i.name.trim().charAt(0).toUpperCase()}),jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:cn$1("novapay:text-sm novapay:font-semibold",o==="page"&&!e?"novapay:line-clamp-2 novapay:break-words":"novapay:truncate"),children:i.name}),e?c.number&&jsx("span",{className:cn$1($,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c.number}):i.website&&jsx("a",{href:i.website,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:truncate novapay:text-xs novapay:text-[var(--tuwa-text-secondary)] novapay:hover:underline",ce),children:Ql(i.website)})]}),c.environment==="test"&&jsxs("span",{title:n.summary.testHint,className:cn$1(en,tn.pending,"novapay:ml-auto"),children:[n.summary.test,jsxs("span",{className:"novapay:sr-only",children:[": ",n.summary.testHint]})]})]})}function ro({checkout:e,labels:t}){let{merchant:a}=e,n=a.seller,o=[[t.summary.terms,a.links.terms],[t.summary.refundPolicy,a.links.refundPolicy],[t.summary.privacy,a.links.privacy]].filter(r=>!!r[1]);return jsxs("div",{className:"tuwa-scanlines 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:[n?.legalName&&jsx("span",{className:"novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-primary)]",children:n.legalName}),(n?.address||n?.country)&&jsx("span",{children:[n.address,n.country].filter(Boolean).join(", ")}),n?.registrationNumber&&jsxs("span",{children:[t.summary.registration," ",n.registrationNumber]}),n?.taxId&&jsxs("span",{children:[t.summary.taxId," ",n.taxId]}),a.supportEmail&&jsx("a",{href:`mailto:${a.supportEmail}`,className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ce),children:a.supportEmail}),o.length>0&&jsx("span",{className:"novapay:flex novapay:flex-wrap novapay:gap-x-3",children:o.map(([r,s])=>jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ce),children:r},r))}),jsx("span",{children:c(t.summary.sellerRole,{seller:n?.legalName||a.name})})]})}function os(){let{checkout:e,labels:t,locale:a,now:n,screen:o,display:r}=I(),s=e?.invoice.dueAt,i=e&&Ln(e.invoice.status,o,e.invoice.restPayable);if(!e||!s||!i)return null;let c$1=new Intl.DateTimeFormat(a,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(s));return jsxs("div",{className:cn$1("tuwa-scanlines 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",r==="page"&&"novapay-page-deadline"),children:[jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-0.5",children:[jsx("span",{className:Oe,children:i==="closed"?t.summary.refundAfter:t.summary.payWithin}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:i==="closed"?c$1:c(t.summary.until,{date:c$1})})]}),jsx("span",{role:"timer",className:cn$1($,"novapay:shrink-0 novapay:whitespace-nowrap novapay:text-lg novapay:font-bold"),children:st(Date.parse(s)-n)})]})}function rs(){let{checkout:e,labels:t,locale:a}=I();if(!e)return null;let{invoice:n}=e,o=pn(n);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:[n.number&&jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between novapay:gap-3",children:[jsx("span",{className:Oe,children:t.summary.invoice}),jsx("span",{className:cn$1($,"novapay:min-w-0 novapay:break-all novapay:text-right novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:n.number})]}),jsx("ul",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-2.5 novapay:p-0",children:n.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($,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(t.summary.quantity,{quantity:r.quantity,price:ye(r.unitPrice,a)})})]}),jsx("span",{className:$,children:ye(Re(r.netMinor),a)})]},s))})]}),o.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:t.summary.subtotal}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.subtotal,a)})]}),jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:o.rate?c(t.summary.taxRate,{rate:o.rate}):t.summary.tax}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.tax,a)})]})]})]})}function jl(){let e=I(),{checkout:t,labels:a,locale:n}=e;return t?jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:justify-between",Y(e,"total")),children:[jsx("span",{className:cn$1(Oe,"novapay:text-[var(--tuwa-text-primary)]"),children:a.summary.total}),jsxs("span",{className:cn$1($,"novapay:text-[22px] novapay:font-bold"),children:[ye(pn(t.invoice).total,n)," ",jsx("span",{className:"novapay:text-[13px] novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:t.invoice.currency})]})]}):null}function ss(){let{checkout:e,labels:t}=I();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(ur,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5 novapay:shrink-0"}),t.summary.secured]}),e?.merchant.supportEmail&&jsxs("span",{children:[t.summary.help,":"," ",jsx("a",{href:`mailto:${e.merchant.supportEmail}`,className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ce),children:e.merchant.supportEmail})]})]})}function ba({label:e,children:t,className:a,buttonClassName:n,growsUp:o=false}){let[r,s]=useState(false),i=useId();return jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-2",a),children:[jsxs("button",{type:"button","aria-expanded":r,"aria-controls":i,onClick:()=>s(c=>!c),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)]",ce,n),children:[e,jsx(an,{"aria-hidden":true,className:cn$1("novapay:h-3.5 novapay:w-3.5 novapay:transition-transform novapay:motion-reduce:transition-none",r!==o&&"novapay:rotate-180")})]}),jsx("div",{id:i,hidden:!r,children:t})]})}var ts=5;function Yl(){let e=I(),{checkout:t,labels:a,locale:n}=e;if(!t)return null;let o=ye(pn(t.invoice).total,n);return jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-1.5",Y(e,"total")),children:[jsx("span",{className:Oe,children:a.summary.total}),jsxs("span",{className:cn$1($,"novapay:flex novapay:flex-wrap novapay:items-baseline novapay:gap-x-2 novapay:gap-y-1 novapay:font-bold",tr(o)),children:[jsx("span",{children:o}),jsx("span",{className:"novapay:text-[15px] novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:t.invoice.currency})]})]})}var is="novapay:flex novapay:justify-between novapay:gap-3 novapay:px-3 novapay:py-2";function ns({line:e}){let{labels:t,locale:a}=I(),n=ye(Re(e.netMinor),a),o=ye(e.unitPrice,a);return jsxs("li",{className:cn$1(is,"novapay:text-[13px]"),children:[jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:break-words",children:e.name}),e.description&&jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:e.description}),(Number(e.quantity)!==1||o!==n)&&jsx("span",{className:cn$1($,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(t.summary.quantity,{quantity:e.quantity,price:o})})]}),jsx("span",{className:cn$1($,"novapay:shrink-0"),children:n})]})}function Zl(){let{checkout:e,labels:t,locale:a}=I();if(!e)return null;let{invoice:n}=e,o=pn(n),r=o.tax?ts-1:ts,s=n.lineItems,i=s.length>r?s.slice(0,r-1):s,c$1=s.slice(i.length);return !n.number&&s.length===0?null:jsxs("div",{className:"tuwa-scanlines novapay:flex novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)]",children:[n.number&&jsxs("div",{className:cn$1(is,"novapay:items-baseline"),children:[jsx("span",{className:Oe,children:t.summary.invoice}),jsx("span",{className:cn$1($,"novapay:min-w-0 novapay:break-all novapay:text-right novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:n.number})]}),i.length>0&&jsx("ul",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:p-0",children:i.map((l,p)=>jsx(ns,{line:l},p))}),c$1.length>0&&jsx(ba,{label:`+${c$1.length} \xB7 ${t.summary.showOrder}`,className:"novapay:px-3 novapay:py-2",buttonClassName:"novapay:min-h-6",children:jsx("ul",{className:"novapay:-mx-3 novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:p-0",children:c$1.map((l,p)=>jsx(ns,{line:l},p))})}),o.tax&&jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5 novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:t.summary.subtotal}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.subtotal,a)})]}),jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:o.rate?c(t.summary.taxRate,{rate:o.rate}):t.summary.tax}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.tax,a)})]})]})]})}function Jl(){let{checkout:e,labels:t}=I();return e?jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx(ga,{}),jsx("div",{className:"novapay:mt-6",children:jsx(Yl,{})}),jsx("div",{className:"novapay:mt-5",children:jsx(Zl,{})}),jsxs("div",{className:"novapay:mt-auto novapay:flex novapay:flex-col novapay:gap-3 novapay:pt-5",children:[jsx(os,{}),jsx(ba,{label:t.summary.sellerDetails,buttonClassName:"novapay:min-h-6",growsUp:true,children:jsx(ro,{checkout:e,labels:t})}),jsx(ss,{})]})]}):null}function cs(){let{checkout:e,labels:t,display:a}=I();return e?a==="page"?jsx(Jl,{}):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(ga,{}),jsx(ba,{label:t.summary.sellerDetails,children:jsx(ro,{checkout:e,labels:t})})]}),jsx(os,{}),jsx("div",{className:"novapay:-mr-2.5 novapay:min-h-0 novapay:flex-1 novapay:overflow-y-auto novapay:pr-2.5",children:jsx(rs,{})}),jsx(jl,{}),jsx(ss,{})]}):null}function ls({className:e}={}){let{checkout:t,labels:a,locale:n,now:o,screen:r}=I();if(!t)return null;let{invoice:s}=t,i=pn(s),c=s.dueAt&&Ln(s.status,r)?Date.parse(s.dueAt):null;return jsxs("div",{className:cn$1("tuwa-scanlines 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",e),children:[jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between",children:[jsxs("span",{className:cn$1($,"novapay:text-[22px] novapay:font-bold"),children:[ye(i.total,n)," ",jsx("span",{className:"novapay:text-xs novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:s.currency})]}),c&&jsxs("span",{role:"timer",className:cn$1($,"novapay:flex novapay:items-center novapay:gap-1 novapay:whitespace-nowrap novapay:text-xs novapay:font-bold"),children:[jsx(on,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-secondary)]"}),st(c-o)]})]}),jsx(ba,{label:`${b(i.tax?{one:a.summary.compactOne,other:a.summary.compact}:{one:a.summary.compactNoTaxOne,other:a.summary.compactNoTax},s.lineItems.length,n,i.tax?{tax:ye(i.tax,n)}:{})} \xB7 ${a.summary.showOrder}`,children:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3 novapay:pt-1",children:[jsx(rs,{}),jsx(ro,{checkout:t,labels:a})]})})]})}function us({locale:e$1,labels:t,receiptIssued:a,onSelect:n,className:o}){let[r,s]=useState(false),i=e.find(x=>x.code===e$1)??e[0],[c$1,l]=useState(0),p=useId(),m=useRef(null),y=useRef(null),f=useRef(null);useEffect(()=>{if(!r)return;f.current?.focus();let x=g=>{m.current?.contains(g.target)||s(false);};return document.addEventListener("pointerdown",x),()=>document.removeEventListener("pointerdown",x)},[r]);let v=()=>{l(Math.max(0,e.indexOf(i))),s(true);},d=()=>{s(false),y.current?.focus();},R=x=>{d(),x!==i.code&&n(x);},h=x=>{let g=e.length-1,k={ArrowDown:()=>Math.min(g,c$1+1),ArrowUp:()=>Math.max(0,c$1-1),Home:()=>0,End:()=>g};k[x.key]?(x.preventDefault(),l(k[x.key]())):x.key==="Enter"||x.key===" "?(x.preventDefault(),R(e[c$1].code)):(x.key==="Escape"||x.key==="Tab")&&(x.preventDefault(),x.stopPropagation(),d());};return jsxs("div",{ref:m,className:cn$1("novapay:relative",o),children:[jsxs("button",{ref:y,type:"button","aria-haspopup":"listbox","aria-expanded":r,"aria-controls":r?`${p}-list`:void 0,className:cn$1(Pt,nt,"novapay:text-[11px]"),onClick:()=>r?d():v(),onKeyDown:x=>{x.key==="ArrowDown"&&!r&&(x.preventDefault(),v());},children:[jsx(nr,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),jsx("span",{children:i.short}),jsxs("span",{className:"novapay:sr-only",children:[", ",c(t.language.button,{language:i.name})]}),jsx(an,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"})]}),r&&jsxs("div",{className:"tuwa-scanlines 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-strong)] novapay:bg-[var(--tuwa-bg-primary)] novapay:p-1.5",children:[jsx("span",{id:`${p}-title`,className:cn$1(Oe,"novapay:block novapay:px-2.5 novapay:py-1"),children:t.language.title}),jsx("ul",{ref:f,id:`${p}-list`,role:"listbox",tabIndex:-1,"aria-labelledby":`${p}-title`,"aria-activedescendant":`${p}-${e[c$1].code}`,onKeyDown:h,className:cn$1("novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-0.5 novapay:p-0",ce),children:e.map((x,g)=>{let k=x.code===i.code;return jsxs("li",{id:`${p}-${x.code}`,role:"option","aria-selected":k,lang:x.code,onClick:()=>R(x.code),onPointerMove:()=>l(g),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]",g===c$1&&"novapay:bg-[var(--tuwa-bg-muted)]","novapay:text-[var(--tuwa-text-primary)]",k&&"novapay:font-semibold"),children:[jsx("span",{"aria-hidden":true,className:cn$1($,"novapay:w-5 novapay:text-[11px]"),children:x.short}),jsx("span",{children:x.name}),k&&jsx(DrawnCheck,{className:"novapay:ml-auto novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-accent)]"})]},x.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:a?t.language.noteAfterPaid:t.language.note})]})]})}var ms=(e,t)=>gr(e.screen,{withDetails:t})??(e.screen==="paid"?br({withDetails:t}):null);function ds(e,t,a){let n=e.customization.components?.Stepper??Xr;return jsx(n,{steps:t,labels:e.labels,className:cn$1(a,Y(e,"stepper")),stepClassName:(o,r)=>Y(e,"step",{step:o,index:r})})}function ys({title:e,withDetails:t}){let a=I(),{labels:n,locale:o,setLocale:r,close:s,state:i}=a,c=a.display==="page",l=a.customization.config?.showSteps===false?null:ms(a,t),p=Y(a,"header"),m=a.customization.handlers?.onLocaleChange,y=jsxs("div",{className:"novapay:ml-auto novapay:flex novapay:shrink-0 novapay:items-center novapay:gap-2",children:[jsx(us,{locale:o,labels:n,receiptIssued:!!i.receiptUrl,onSelect:f=>{m?m({locale:f,proceed:()=>r(f)}):r(f);}}),s&&jsx("button",{type:"button","aria-label":n.common.close,onClick:s,className:Pt,children:jsx(CloseIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"})})]});return jsxs(Fragment$1,{children:[jsxs("header",{className:cn$1("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",c&&"novapay-page-header",p),children:[l?ds(a,l):e&&jsx("h2",{className:cn$1($,"novapay:m-0 novapay:flex-1 novapay:text-[15px] novapay:font-bold"),children:e}),y]}),jsxs("header",{className:cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-4 novapay:pb-3 novapay:pt-1.5 novapay:sm:hidden",c&&"novapay-page-header-phone",p),children:[jsx(ga,{compact:true}),y]})]})}function fs({withDetails:e}){let t=I();if(t.customization.config?.showSteps===false)return null;let a=ms(t,e);return a?ds(t,a,"novapay:px-4 novapay:pt-3.5"):null}var rp=new Set(["paid","needs_review","refunded","partially_refunded"]);function dn(){let{state:e,locale:t,adapterFor:a}=I(),o=(e.invoiceStatus&&rp.has(e.invoiceStatus)?e.checkout?.quote:null)??e.quote,r=o?he(o.instructions):null,s=e.txHash??e.txKey,i=o?.payer?parseCaip10AccountId(o.payer)?.address:void 0,c=(e.checkout?.invoice.payments??[]).map(l=>{let p=l.chainId?Rt(l.chainId):null;return {txKey:l.txKey,amount:l.symbol&&l.decimals!==null?`${pe(l.amount,l.decimals,t)} ${l.symbol}`:null,at:Date.parse(l.at),explorerUrl:p&&l.chainId?a(p)?.explorerUrl?.({chainId:l.chainId,txKey:l.txKey}):void 0}});return {network:r?ve(r):null,amount:o?`${pe(o.amountToSend,o.decimals,t)} ${o.instructions.symbol}`:null,paidAmount:o?`${pe(o.amountDue===o.cryptoAmountExpected?o.amountToSend:o.cryptoAmountExpected,o.decimals,t)} ${o.instructions.symbol}`:null,txKey:s,lastOfParts:o?o.amountDue!==o.cryptoAmountExpected:false,transfers:c,explorerUrl:o&&r&&s?a(o.instructions.family)?.explorerUrl?.({chainId:r,txKey:s}):void 0,from:i?shortAddress(i):null,fromAddress:i??null,fromUrl:o&&r&&i?a(o.instructions.family)?.explorerAddressUrl?.({chainId:r,address:i}):void 0}}var io=new WeakMap,cp=500;function bt(e,t){let a=io.get(e)?.get(t);if(a)return a.leftAt===null||Date.now()-a.leftAt<cp?a.value:void 0}function On(e,t,a,n=true){let o=io.get(e)??new Map;o.set(t,{value:a,leftAt:n?Date.now():null}),io.set(e,o);}function Ke(e,t){let{store:a}=I(),[n,o]=useState(()=>bt(a,e)??t);return useEffect(()=>(o(t),On(a,e,t,false),()=>On(a,e,t)),[a,e,t]),n}var vs="actionKind",pp="actionLabel",Ca="novapay-action-arrives";function yn(e,t){let{store:a,customization:n}=I(),[o]=useState(()=>e==="primary"&&bt(a,vs)==="secondary"&&!n.config?.animation?.disabled);return Ke(vs,e??"none"),{label:Ke(pp,e?t:"")||t,arrives:o}}function xs({tone:e,children:t}){let a=I(),n=Ke("chipTone",e),o=Ke("chipLabel",t);return jsx("span",{className:cn$1(en,"novapay:transition-colors novapay:duration-300 novapay:motion-reduce:transition-none",tn[n],Y(a,"statusChip",{tone:e})),children:jsx(MorphText,{children:o})})}var gs=["................",".....######.....","...##########...","..############..",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.","..############..","...##########...",".....######.....","................"],dp=["................","................","................","................","................","..........##....",".........###....","....##..###.....","....######......",".....####.......","......##........","................","................","................","................","................"],yp=["................","................","................","................","....##....##....","....###..###....",".....######.....","......####......","......####......",".....######.....","....###..###....","....##....##....","................","................","................","................"],Sa=e=>e.flatMap((t,a)=>[...t].flatMap((n,o)=>n==="."?[]:[{x:o,y:a}])),bs=({x:e,y:t})=>`${e},${t}`,ws=(e,t)=>{let a=new Set(t.map(bs));return e.filter(n=>!a.has(bs(n)))},Cs={check:ws(Sa(gs),Sa(dp)),cross:ws(Sa(gs),Sa(yp))},ks=/M(\d+) (\d+)h(\d+)v1h-\3z/g;function Ss(e){let t=new Map,a=(n,o)=>t.set(`${n},${o}`,{x:n,y:o});for(let n of e){if("d"in n){if(n.d.replace(ks,"")!=="")continue;for(let[,r,s,i]of n.d.matchAll(ks))for(let c=0;c<Number(i);c++)a(Number(r)+c,Number(s));continue}if([n.x,n.y,n.width,n.height].every(Number.isInteger))for(let r=0;r<n.height;r++)for(let s=0;s<n.width;s++)a(n.x+s,n.y+r);}return [...t.values()]}function Ps(e,t,a){if(t.length===0)return [];let n=Math.PI*2,o=({x:i,y:c})=>Math.atan2(c-a.y,i-a.x),r=(i,c)=>{let l=Math.abs(i-c)%n;return l>Math.PI?n-l:l},s=t.map(i=>({source:i,at:o(i)}));return e.map(i=>{let c=o(i);return s.reduce((l,p)=>r(p.at,c)<r(l.at,c)?p:l).source})}var co="mark",wp={paid:{mark:"check",tone:"novapay:text-[var(--tuwa-success-icon)]"},failed:{mark:"cross",tone:"novapay:text-[var(--tuwa-error-icon)]"},cancelled:{mark:"cross",tone:"novapay:text-[var(--tuwa-text-secondary)]"}},kp={unconfirmed:{Icon:yt,tone:"novapay:text-[var(--tuwa-pending-icon)]"},underpaid:{Icon:yt,tone:"novapay:text-[var(--tuwa-pending-icon)]"},needs_review:{Icon:mr,tone:"novapay:text-[var(--tuwa-info-icon)]"},refunded:{Icon:cr,tone:"novapay:text-[var(--tuwa-info-icon)]"},expired:{Icon:on,tone:"novapay:text-[var(--tuwa-text-secondary)]"},replaced:{Icon:ir,tone:"novapay:text-[var(--tuwa-info-icon)]"},blocked:{Icon:dr,tone:"novapay:text-[var(--tuwa-error-icon)]"}},Rs={waiting:"processing",paid:"succeed",failed:"failed"};function Cp(e,t){let a=e.viewBox.baseVal,n=e.getBoundingClientRect();if(!a||a.width===0||n.width===0)return [];let o=(c,l)=>Number(c.getAttribute(l)??0),r=c=>!c.closest("defs, clipPath, mask"),s=[...[...e.querySelectorAll("rect")].filter(r).map(c=>({x:o(c,"x"),y:o(c,"y"),width:o(c,"width"),height:o(c,"height")})),...[...e.querySelectorAll("path")].filter(r).map(c=>({d:c.getAttribute("d")??""}))],i=n.width/a.width;return Ss(s).map(({x:c,y:l})=>({x:n.left-t.left+(c+.5)*i,y:n.top-t.top+(l+.5)*i}))}function Sp(e,t,a){let n=[...e.querySelectorAll("[data-px]")],o=e.viewBox.baseVal,r=e.getBoundingClientRect();if(n.length===0||!o||o.width===0||r.width===0)return;let s=r.width/o.width,i=n.map(p=>({x:r.left-t.left+(Number(p.getAttribute("x")??0)+.5)*s,y:r.top-t.top+(Number(p.getAttribute("y")??0)+.5)*s})),c=Ps(i,a,{x:t.width/2,y:t.height/2});if(c.length===0)return;let l=p=>`${Math.round(p/s*100)/100}px`;n.forEach((p,m)=>{p.style.setProperty("--nova-px-x",l(c[m].x-i[m].x)),p.style.setProperty("--nova-px-y",l(c[m].y-i[m].y));});}function Pp({mark:e,moves:t,className:a}){return jsx("svg",{viewBox:`0 0 ${16} ${16}`,shapeRendering:"crispEdges",fill:"currentColor","aria-hidden":"true",className:cn$1("novapay:block",a),"data-motion":t?"assemble":void 0,children:Cs[e].map(({x:n,y:o})=>jsx("rect",{x:n,y:o,width:1,height:1,"data-px":"",style:pixelFlight(n,o)},`${n}-${o}`))})}function Is({kind:e,className:t}){let a=I(),{store:n,customization:o}=a,{look:r}=useNovaIcons(),s=useRef(null),i=useRef(null),c=!o.config?.animation?.disabled;useLayoutEffect(()=>{let h=s.current,x=h?.querySelector("svg")??null,g=h?.getBoundingClientRect(),k=i.current??bt(n,co)??null;x&&g&&c&&k&&k.kind!==e&&Sp(x,g,k.pixels);let N={kind:e,pixels:x&&g?Cp(x,g):[]};return i.current=N,On(n,co,N,false),()=>On(n,co,N)},[e,n,c]);let l=o.childCustomizations?.statusVisual,p=e in Rs?Rs[e]:null,m=p&&cn$1(l?.iconClassNames?.icon,l?.iconClassNames?.statusOverrides?.[p]),y=wp[e],f=kp[e],v=o.components?.StatusIcon,d=p?void 0:Y(a,"statusIcon",{kind:e}),R;if(!p&&v)R=jsx(v,{kind:e,className:d});else {if(p&&r!=="pixel")return jsx(TxStatusVisual,{isProcessing:e==="waiting",isSucceed:e==="paid",isFailed:e==="failed",...l,className:cn$1(t,l?.className)});e==="waiting"?R=jsx(QuasarLoader,{size:64,accent:"var(--tuwa-pending-icon)",className:cn$1("novapay:text-[var(--tuwa-text-primary)]",m)}):y&&r==="pixel"?R=jsx(Pp,{mark:y.mark,moves:c,className:cn$1(p?"novapay:h-16 novapay:w-16":"novapay:h-12 novapay:w-12",y.tone,m,d)}):y?R=jsx(DrawnCross,{variant:"disc",className:cn$1("novapay:h-12 novapay:w-12",y.tone,d)}):f&&(R=jsx(f.Icon,{"aria-hidden":true,className:cn$1("novapay:h-12 novapay:w-12",f.tone,d),...c&&r==="pixel"?{motion:"assemble"}:{}}));}return jsx("div",{className:cn$1("novapay:flex novapay:justify-center novapay:py-4",t,p&&l?.className),children:jsx("span",{ref:s,className:"novapay:relative novapay:flex novapay:h-16 novapay:w-16 novapay:items-center novapay:justify-center",children:R})})}function Ls({children:e,className:t}){let a=Ke("title",e);return jsx("h2",{...Nt,"aria-label":e,className:cn$1(at,t),children:jsx(MorphText,{wrap:true,children:a})})}function At({mark:e,tone:t,chip:a,title:n,amount:o,note:r}){let{display:s}=I(),i=s==="page",c=Ke("amount",o??""),l=Ke("note",r??"");return jsxs(Fragment$1,{children:[jsx(Is,{kind:e,className:i?"novapay-page-visual":void 0}),jsxs("div",{className:"novapay:flex novapay:w-full novapay:max-w-sm novapay:flex-col novapay:items-center",children:[jsx(xs,{tone:t,children:a}),jsx(Ls,{className:"novapay:mt-2",children:n}),o&&jsx("p",{"aria-label":o,className:cn$1($,"novapay:m-0 novapay:mt-2 novapay:text-2xl novapay:font-bold",i&&"novapay-page-amount"),children:jsx(MorphText,{children:c||o})}),r&&jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:jsx(MorphText,{wrap:true,children:l||r})})]})]})}var Fs="steps";function fn({state:e}){let{store:t,customization:a}=I(),n=a.childCustomizations,[o]=useState(()=>bt(t,Fs)!==void 0),r=Ke(Fs,e),s=jsx(TxProgressIndicator,{isProcessing:r==="processing",isSucceed:r==="succeed",isConfirmed:r==="succeed",isFailed:r==="failed",...n?.progressIndicator,className:cn$1("novapay:max-w-sm",n?.progressIndicator?.className)});return o?jsx(AnimatePresence,{initial:false,children:s}):s}var Mp=new Set(["open","underpaid"]);function Ds(){let{checkout:e,state:t,labels:a,close:n,customization:o,now:r,handedOverAt:s,display:i}=I(),c$1=i==="page",l=o.childCustomizations,p=dn(),m=e?.invoice.dueAt?Date.parse(e.invoice.dueAt):null,y=t.invoiceStatus??e?.invoice.status,f=ot(t),v=!f&&ft(t,e),d=e!==null&&(f||v)&&Mp.has(y??"")&&m!==null&&r>=m,R=d&&Tr({state:t,checkout:e,handedOverAt:s,dueAt:m}),h=It(t.error)==="retrying",x=yn(n?"secondary":null,a.common.close);return jsxs(Ze,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",c$1&&"novapay-page-status"),children:[jsx(At,{mark:"waiting",tone:"pending",chip:a.status.pending,title:a.confirm.title,amount:p.amount,note:p.network?c(a.confirm.hint,{network:p.network}):null}),jsx(fn,{state:"processing"}),jsxs(xe,{className:"novapay:max-w-sm",children:[p.network&&jsx(H,{name:a.confirm.network,children:p.network}),p.txKey&&jsx(H,{name:a.confirm.transaction,children:jsx(HashLink,{hash:p.txKey,explorerUrl:p.explorerUrl,variant:"compact",...l?.hashLink})}),p.fromAddress&&jsx(H,{name:a.confirm.from,children:jsx(HashLink,{hash:p.fromAddress,explorerUrl:p.fromUrl,variant:"compact",...l?.hashLink})})]}),jsx("p",{role:"status",className:cn$1("novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",c$1&&"novapay:mt-auto"),children:jsx(MorphText,{wrap:true,children:h?a.outcome.unconfirmedRetrying:d?c(R?a.confirm.afterDeadline:a.confirm.pastDeadline,{merchant:e.merchant.name}):v?a.confirm.invoicePayment:a.confirm.canClose})})]}),n&&jsx(Z,{children:jsx(ae,{onClick:n,children:x.label})})]})}function Pa({adapter:e,store:t,wallet:a$1,chainId:n}){let[o,r]=useState("idle"),[s,i]=useState(null),[c,l]=useState(null),p=useRef(0),m=a$1?.address,y=useRef(m);useEffect(()=>{y.current!==m&&(y.current=m,p.current++,r("idle"),i(null),l(null));},[m]);let f=useRef(false);return useEffect(()=>(f.current=false,()=>{f.current=true;}),[]),{step:o,problem:s,request:c,confirm:async({quote:d=false}={})=>{let R=++p.current,h=()=>p.current===R;i(null);let x=e?.signMessage;if(!x||!a$1)return i("unsupported"),false;if(a$1.chainId!==n&&e.switchChain){r("switching");try{await e.switchChain(n);}catch(b){if(h()){let L=b$1(b);i(L==="declined"?"switchDeclined":L==="failed"?"switchFailed":L),r("idle");}return false}if(!h())return false}h()&&r("signing");let g=t.getState().payer,k=null,N=await t.getState().confirmPayer(async(b,L)=>{h()&&l(L);try{return await x({message:b,account:a$1.address,chainId:L.chainId})}catch(B){let _=b$1(B);throw k=_==="declined"&&B instanceof a&&B.step==="switch"?"switchDeclined":_,B}});return h()&&(i(k),r("idle")),N&&d&&!f.current&&t.getState().payer===g&&await t.getState().requestQuote(),N},dismiss:()=>{p.current++,r("idle"),t.getState().abandonConfirmation();}}}function qs(e){return e.closest("[data-novapay-scroll]")??null}function Op(e,t){let a=t?.offsetHeight;return a&&a>0?Math.min(e,a):e}function Dp(e){let t=e.offsetHeight;return t>0?Op(t,qs(e)):null}function Na(e){let[t,a]=useState(null),[n,o]=useState(null),[r,s]=useState(null);return useEffect(()=>{if(!t)return;let i=qs(t),c=()=>{if(!e){let m=Dp(t);m!==null&&o(m);}let p=i?.offsetHeight;s(p&&p>0?p:null);};if(c(),typeof ResizeObserver>"u")return;let l=new ResizeObserver(c);return e||l.observe(t),i&&l.observe(i),()=>l.disconnect()},[t,e]),!e||n===null?[a,null]:[a,r?Math.min(n,r):n]}var Wp=new Set(["evm:coinbase","evm:baseaccount","evm:porto"]);function Ta(e){return !!(e&&Wp.has(e.connectorType.toLowerCase()))}function Us(e,t){return e==="required"||e==="confirming"?true:e==="unless_relayed"&&t!=="relay"}async function Hs(e,t){let{payerProof:a}=e.getState();if(a==="required"||a==="confirming")return t(true),null;t(false);let n=await e.getState().requestQuote();return !n&&e.getState().error?.code==="payer_proof_required"&&t(true),n}var qp=new Set(["payer_chain_mismatch","too_many_payers","payer_is_recipient"]);function yo(e){let t=e?.code;return t!==void 0&&(t.startsWith("payer_proof_")||qp.has(t))}var Up=new Set(["rate_limited","request_failed","origin_required","invoice_not_payable"]);function Dn(e){let t=e?.code;return yo(e)||t!==void 0&&Up.has(t)}function Ra(e,t,a,n){if(t==="declined")return c(a.payerProof.declined,n);if(t==="switchDeclined")return c(a.payerProof.switchDeclined,n);if(t==="unsupported")return c(a.payerProof.unsupported,n);if(t==="wrongNetwork"||t==="switchFailed")return c(a.payerProof.wrongNetwork,n);if(t==="notAuthorized")return c(a.pay.notAuthorized,n);if(t==="alreadyPending")return c(a.walletPrompt.stillWaiting,n);if(t)return c(a.payerProof.failed,n);switch(e?.code){case void 0:case "payer_proof_required":return null;case "payer_proof_declined":return c(a.payerProof.declined,n);case "payer_proof_invalid":return a.payerProof.invalid;case "payer_proof_unavailable":return a.payerProof.unavailable;case "payer_chain_mismatch":return c(a.payerProof.wrongNetwork,n);case "too_many_payers":return c(a.payerProof.tooManyWallets,n);case "payer_is_recipient":return a.method.payerIsRecipient;case "rate_limited":return a.method.rateLimited;case "request_failed":return a.pay.noAnswer;default:return a.error.generic}}function qn({kind:e,walletName:t,walletId:a,walletIcon:n,amount:o,merchant:r,network:s,to:i,priceTime:c$1,onRetry:l,text:p,details:m,hint:y,onCancel:f,stepHeight:v}){let{labels:d,display:R}=I(),h=useId(),x=useRef(null);useEffect(()=>x.current?.focus(),[e]);let[g]=useState(()=>typeof document>"u"?null:document.activeElement);useEffect(()=>()=>{let b=g?.ownerDocument;if(!g||!b||g===b.body||!g.isConnected)return;let L=b.activeElement;L&&L!==b.body&&!L.contains(g)||g.focus();},[g]);let k={wallet:t,amount:o,merchant:r,network:s},N=e==="sign"||e==="proof"?d.walletPrompt.signIn:e==="switch"?d.walletPrompt.switchIn:e==="submitting"?d.walletPrompt.submitting:d.walletPrompt.confirmIn;return jsxs("section",{"aria-labelledby":h,style:v?{"--novapay-step-height":`${v}px`}:void 0,className:cn$1("tuwa-scanlines novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center-safe novapay:gap-3 novapay:bg-[var(--tuwa-bg-primary)] novapay:px-6 novapay:py-5 novapay:text-center",v&&(R==="page"?"novapay:min-h-[var(--novapay-step-height)]":"novapay:max-sm:min-h-[var(--novapay-step-height)]")),children:[jsx(ma,{walletId:a,walletIcon:n}),jsx("h2",{id:h,ref:x,tabIndex:-1,className:at,children:c(N,k)}),(e==="sign"||e==="confirm"||e==="proof")&&jsxs(Fragment$1,{children:[jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:p??c(e==="confirm"?d.walletPrompt.confirmText:d.walletPrompt.signText,k)}),y&&jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:y}),jsxs("div",{className:"novapay:flex novapay:w-full novapay:max-w-xs novapay:flex-col novapay:gap-1.5 novapay:text-left",children:[jsx("span",{className:Oe,children:jsx(ge,{label:d.walletPrompt.check,values:k})}),jsx(xe,{children:m?m.map(b=>jsx(H,{name:b.name,children:b.value},b.name)):jsxs(Fragment$1,{children:[jsx(H,{name:d.walletPrompt.amount,children:o}),jsx(H,{name:d.walletPrompt.to,children:i}),jsx(H,{name:d.walletPrompt.network,children:s}),c$1&&jsx(H,{name:d.walletPrompt.priceLocked,children:c$1})]})})]}),l?jsxs("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[d.walletPrompt.notOpened," ",jsx(ht,{onClick:l,children:d.walletPrompt.tryAgain})]}):jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(d.walletPrompt.stillWaiting,k)})]}),e!=="submitting"&&jsx(ae,{onClick:f,className:"novapay:max-w-xs",children:d.walletPrompt.cancel})]})}function zs(){let{checkout:e,state:t,store:a,labels:n,locale:o,wallet:r,adapterFor:s,connectWallet:i,setConfirmWallet:c$1}=I(),l=e?.methods.find(z=>z.id===t.methodId)??null,p=l?Ye(l):null,m=Pa({adapter:p?s(p):void 0,store:a,wallet:r,chainId:l?.chainId??""}),[y,f]=useState(false),v=useRef(null),d=m.step!=="idle",[R,h]=Na(d),x=useRef(false);if(useEffect(()=>{x.current&&!d&&v.current?.querySelector("[data-novapay-heading]")?.focus(),x.current=d;},[d]),!e||!l)return null;let g=e.merchant.name,k=r?.name??"",N=ve(l.chainId),b=e.invoice.number??e.invoice.id,L=e.invoice.totalMinor?`${ye(Re(e.invoice.totalMinor),o)} ${e.invoice.currency}`:null,B=Ta(r),_=t.phase==="quoting",w=d,D=Ra(!_&&Dn(t.error)?t.error:null,m.problem,n,{wallet:k,network:N,merchant:g}),E={wallet:k,invoice:b,merchant:g},C=Ue(r,l),ie=()=>{C&&t.payer!==C&&a.getState().setPayer(C),m.confirm({quote:true});},P=()=>{c$1(false),a.getState().clearError();},W=C?t.confirmedWallets?.find(z=>!sn(z,C)):void 0;return jsxs("div",{ref:v,className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{ref:R,inert:d,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",d&&"novapay:hidden"),children:[jsxs(de,{title:n.payerProof.title,subtitle:n.payerProof.text,children:[r&&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:r.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:k}),jsx("span",{className:cn$1($,"novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.walletLine,{address:shortAddress(r.address),network:ve(r.chainId)})})]}),jsx("button",{type:"button","aria-label":n.pay.changeWallet,onClick:()=>{i(l)||f(true);},className:nn,children:n.pay.change})]}),jsx(cn,{children:n.payerProof.summary}),jsxs(xe,{children:[jsx(H,{name:n.payerProof.invoice,children:b}),jsx(H,{name:n.payerProof.merchant,children:g}),L&&jsx(H,{name:n.payerProof.amount,children:L}),r&&jsx(H,{name:n.payerProof.wallet,children:jsx(He,{hash:r.address,chainId:r.chainId})})]}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.payerProof.why}),B&&jsxs("p",{className:"novapay:m-0 novapay:flex novapay:items-start novapay:gap-2 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsx(pr,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),jsx("span",{children:c(n.payerProof.passkey,E)})]}),r&&p==="eip155"&&r.chainId!==l.chainId&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(n.payerProof.willSwitch,{current:ve(r.chainId),network:N})}),W&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",children:c(n.payerProof.alreadyConfirmed,{wallet:shortAddress(Et(W))})}),D&&jsx(Q,{children:D}),y&&jsx(Q,{children:n.pay.connectUnavailable})]}),jsxs(Z,{children:[jsx(X,{busy:w||_,onClick:ie,children:_?n.method.quoting:w?jsx(ge,{label:n.payerProof.waiting,values:E}):jsx(ge,{label:n.payerProof.confirm,values:E})}),jsx(ae,{disabled:_,onClick:P,children:(t.invoiceStatus??e?.invoice.status)==="underpaid"?n.pay.backFromRest:n.pay.back}),jsx($e,{children:B?n.payerProof.noteSmart:n.payerProof.note})]})]}),d&&jsx(qn,{kind:m.step==="switching"?"switch":"proof",walletName:k,walletId:r?.walletId??"",walletIcon:r?.icon,amount:L??"",merchant:g,network:N,to:"",priceTime:null,text:c(B?n.payerProof.promptPasskey:n.payerProof.promptText,E),details:[...m.request?[{name:n.payerProof.site,value:m.request.domain}]:[],{name:n.payerProof.invoice,value:b},{name:n.payerProof.merchant,value:g},...L?[{name:n.payerProof.amount,value:L}]:[]],hint:m.request?c(n.payerProof.signInRequest,{wallet:k,site:m.request.domain}):void 0,onRetry:ie,onCancel:m.dismiss,stepHeight:h})]})}var Zp=/^0x[0-9a-fA-F]{64}$/,Jp=/^[1-9A-HJ-NP-Za-km-z]{64,90}$/;function Hn(){let{store:e,state:t,checkout:a,labels:n,wallet:o}=I(),[r,s]=useState(false),[i,c]=useState(""),[l,p]=useState(false),[m,y]=useState(null),f=useId(),v=t.quote??a?.quote;if(!v)return null;let d=n.outcome;if(!r)return jsx(ht,{onClick:()=>s(true),children:d.nameHash});let R=async h=>{h.preventDefault();let x=i.trim();if(!(v.instructions.family==="solana"?Jp:Zp).test(x))return y(d.nameHashInvalid);y(null),p(true);let k=await e.getState().submit({txKey:x,...o?{from:o.address}:{}});p(false),k||y(d.nameHashRefused);};return jsxs("form",{onSubmit:h=>{R(h);},className:"novapay:flex novapay:w-full novapay:max-w-sm novapay:flex-col novapay:gap-2 novapay:text-left",children:[jsx("label",{htmlFor:f,className:"novapay:text-xs novapay:font-semibold",children:d.nameHashField}),jsx("input",{id:f,value:i,autoComplete:"off",spellCheck:false,"aria-invalid":m?true:void 0,onChange:h=>c(h.target.value),className:cn$1($,"novapay:box-border novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",ce)}),m&&jsx(Q,{children:m}),jsx(ae,{type:"submit",disabled:l||!i.trim(),children:d.nameHashSend})]})}var js=e=>e?.code==="payment_unconfirmed",nu={nonceSpent:"unconfirmedNonceSpent",unmined:"unconfirmedUnmined",rechecked:"unconfirmedNote",retrying:"unconfirmedRetrying",notReceived:"unconfirmedNotReceived",contact:"unconfirmedContact",closed:"unconfirmedClosed",takenElsewhere:"unconfirmedTakenElsewhere",settlementRetrying:"unconfirmedSettlementRetrying",settlementFailed:"unconfirmedSettlementFailed",invoiceFull:"unconfirmedInvoiceFull"},Ys=new Set(["nonceSpent","unmined","notReceived","contact","closed","takenElsewhere","settlementRetrying","settlementFailed","invoiceFull"]),Zs=new Set(["nonceSpent","takenElsewhere","settlementRetrying","settlementFailed","invoiceFull"]),Js={unconfirmed:{tone:"pending",label:"unconfirmed"},underpaid:{tone:"pending",label:"underpaid"},needs_review:{tone:"neutral",label:"review"},refunded:{tone:"neutral",label:"refunded"},expired:{tone:"neutral",label:"expired"},cancelled:{tone:"neutral",label:"cancelled"},replaced:{tone:"neutral",label:"replaced"},blocked:{tone:"error",label:"blocked"}},ee=({children:e,muted:t})=>jsx("p",{className:cn$1("novapay:m-0 novapay:max-w-sm novapay:text-xs",t?"novapay:text-[var(--tuwa-text-secondary)]":"novapay:text-[var(--tuwa-text-primary)]"),children:e});function vo(){let e=I(),{checkout:t,labels:a,onContact:n}=e;if(!t)return null;let o=jsx(ge,{label:a.outcome.contact,values:{merchant:t.merchant.name}}),r=cn$1(sa,Y(e,"secondaryButton"));if(n)return jsx("button",{type:"button",onClick:n,className:r,children:o});let s=_r(t.merchant,c(a.outcome.contactSubject,{number:t.invoice.number??t.invoice.id}));return s?jsx("a",{href:s,target:s.startsWith("mailto:")?void 0:"_blank",rel:"noopener noreferrer",className:r,children:o}):null}function Xs({kind:e}){let[t,a]=useState(false),n=I(),{checkout:o,state:r,store:s,labels:i,locale:c$1,now:l,wallet:p,connectWallet:m,openInvoice:y,qrShown:f,paymentSent:v,adapterFor:d,lockPrice:R}=n;if(!o)return null;let h=o.merchant.name,x=r.quote,g=o.methods.find(P=>P.id===(r.methodId??x?.methodId)),k=o.invoice.dueAt&&!o.invoice.closed?new Intl.DateTimeFormat(c$1,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(o.invoice.dueAt)):null,N=(P,W=x)=>W?`${pe(P,W.decimals,c$1)} ${W.instructions.symbol}`:P,b=It(r.error),L=P=>c(i.outcome[nu[P]],{merchant:h}),B=r.followingUntil??null,_=B?jsx(ee,{muted:true,children:c(i.outcome.followingUntil,{time:new Intl.DateTimeFormat(c$1,{timeStyle:"short"}).format(Date.parse(B))})}):null,w=Lr(r,o),D=P=>{if(!w||P!=="mismatch"&&(!P||!Ys.has(P)))return null;let W=x??o.quote,z=W?he(W.instructions):null,Se=W&&z?d(W.instructions.family)?.explorerUrl?.({chainId:z,txKey:w}):void 0;return jsx(Ze,{children:jsx(xe,{className:"novapay:w-full novapay:max-w-sm",children:jsx(H,{name:i.confirm.transaction,children:jsx(HashLink,{hash:w,explorerUrl:Se,variant:"compact",...n.customization.childCustomizations?.hashLink})})})})},E,C=null,ie=null;switch(e){case "unconfirmed":{if(E=i.outcome.unconfirmedTitle,vt(r.error))C=jsxs(Fragment$1,{children:[jsx(ee,{children:Ut(r.error,i,h)}),D("mismatch")]});else if(b&&Zs.has(b))C=jsxs(Fragment$1,{children:[jsx(ee,{children:L(b)}),D(b),b==="nonceSpent"&&jsx(Hn,{})]});else {let z=b??"contact";C=jsxs(Fragment$1,{children:[jsx(ee,{children:i.outcome.unconfirmedText}),jsx(ee,{muted:true,children:L(z)}),D(z),jsx(Hn,{})]});}let{payAgain:P}=s.getState(),W=r.invoiceStatus??o.invoice.status;P&&(W==="open"||W==="underpaid")&&!(b&&Zs.has(b))&&(ie=vt(r.error)?r.error.unmatched===true?jsx(X,{onClick:()=>P(),children:i.pay.payAgain}):jsx(ae,{onClick:()=>P(),children:i.pay.payAgain}):jsx(ae,{onClick:()=>P(),children:i.outcome.unconfirmedPayAgain}));break}case "underpaid":{let P=x??o.quote,W=o.invoice.amountPaid,z=Mr(P,W);E=i.outcome.underpaidTitle;let Se=P&&W&&jsx(ee,{children:c(i.outcome.underpaidText,{received:N(W,P),total:N(P.cryptoAmountExpected,P)})});if(o.invoice.status==="underpaid"&&o.invoice.restPayable===false||r.error?.code==="method_not_found"){C=jsxs(Fragment$1,{children:[Se,jsx(ee,{children:i.outcome.underpaidClosed}),k&&jsx(ee,{children:c(i.outcome.underpaidClosedRefund,{merchant:h,date:k})})]});break}let we=rn(P,l,i,h,c$1,i.outcome.underpaidRateEnded),re=o.methods.find(De=>De.id===P?.methodId)??g??o.methods[0],ke=r.error?.code==="payer_blocked"?c(i.outcome.underpaidBlocked,{merchant:h}):r.error&&r.error.code!=="payer_mismatch"?pa(r.error,i,h):null;C=jsxs(Fragment$1,{children:[Se,P&&z&&jsx(ee,{children:c(i.outcome.underpaidRest,{rest:N(z,P),network:ve(he(P.instructions))})}),k&&jsx(ee,{muted:true,children:c(i.outcome.underpaidNote,{merchant:h,date:k})}),we&&jsx(ee,{muted:true,children:we}),ke&&jsx(Q,{children:ke})]});let A=re&&p?Ue(p,re):null,F=r.error?.code==="payer_mismatch"?r.error.originWallet??null:null,U=F??o.invoice.originWallet??P?.payer??null,ne=U?Et(U):void 0,le=A?parseCaip10AccountId(A)?.address:void 0,se=P?.payer!==null&&!!(ne&&(le?!sn(le,ne):F)),Me=()=>{if(!re)return;if(se)return void m(re);let De=P?.payer===null?null:A;if(P?.payer!==null&&!De)return void m(re);r.methodId!==re.id&&s.getState().selectMethod(re.id),s.getState().setPayer(De),R();};se&&ne&&(C=jsxs(Fragment$1,{children:[C,jsx(ee,{children:c(i.outcome.payRestFirstWallet,{wallet:shortAddress(ne)})})]})),ie=jsx(X,{busy:r.phase==="quoting",onClick:Me,children:i.outcome.payRest});break}case "needs_review":{E=c(i.outcome.reviewTitle,{merchant:h});let P=o.invoice.review?.reason,W=P==="late"?i.outcome.reviewLate:P==="overpaid"?i.outcome.reviewOverpaid:P==="quote_expired"?i.outcome.reviewQuoteExpired:i.outcome.reviewScreening;C=jsxs(Fragment$1,{children:[jsx(ee,{children:c(W,{merchant:h})}),jsx(ee,{muted:true,children:i.outcome.reviewNote})]});break}case "refunded":{E=i.outcome.refundedTitle;let P=o.invoice.refundedTotalMinor??o.invoice.totalMinor;C=P&&jsx(ee,{children:c(i.outcome.refundedText,{merchant:h,amount:ye(Re(P),c$1),currency:o.invoice.currency})});break}case "expired":{E=i.outcome.expiredTitle;let P=Br(o.invoice.amountPaid),W=x??o.quote,z=ot(r)||ft(r,o),Se=js(r.error)||b==="settlementFailed"||b==="settlementRetrying",Ne=Se||!z&&qt(r,o),we=!Ne&&b==="closed",re=!Ne&&!we&&(z||v),ke=!Ne&&!we&&!re&&vt(r.error),A=re||Ne||we||ke||f,F=Se?b??"contact":"rechecked";C=jsxs(Fragment$1,{children:[P?jsxs(Fragment$1,{children:[k&&jsx(ee,{children:W?c(i.outcome.expiredPartText,{date:k,amount:N(P,W)}):c(i.outcome.expiredPartNoAmount,{date:k})}),!k&&W&&jsx(ee,{children:c(i.outcome.closedPartText,{merchant:h,amount:N(P,W)})}),jsx(ee,{children:c(i.outcome.expiredPartRefund,{merchant:h})})]}):!A&&k&&jsx(ee,{children:c(i.outcome.expiredText,{date:k,merchant:h})}),Ne?jsxs(Fragment$1,{children:[jsx(ee,{children:F==="rechecked"?c(i.outcome.expiredUnconfirmed,{merchant:h}):L(F)}),D(F),F==="nonceSpent"&&jsx(Hn,{})]}):we?jsxs(Fragment$1,{children:[jsx(ee,{children:L("closed")}),D("closed")]}):re?jsxs(Fragment$1,{children:[jsx(ee,{children:c(i.outcome.expiredWhileConfirming,{merchant:h})}),_]}):ke?jsxs(Fragment$1,{children:[jsx(ee,{children:Ut(r.error,i,h)}),D("mismatch")]}):f?jsx(ee,{children:c(i.outcome.expiredAfterQr,{merchant:h})}):jsx(ee,{muted:true,children:i.outcome.expiredNote})]});break}case "cancelled":{if(E=i.outcome.cancelledTitle,b&&Ys.has(b)){C=jsxs(Fragment$1,{children:[jsx(ee,{children:L(b)}),D(b),b==="nonceSpent"&&jsx(Hn,{})]});break}let P=js(r.error)||b==="closed"||ot(r)||ft(r,o)||qt(r,o)||v,W=!P&&vt(r.error),z=P?c(i.outcome.cancelledWhilePaying,{merchant:h}):W?Ut(r.error,i,h):c(f?i.outcome.cancelledAfterQr:i.outcome.cancelledText,{merchant:h});C=jsxs(Fragment$1,{children:[jsx(ee,{children:z}),W&&D("mismatch"),b==="retrying"&&jsx(ee,{muted:true,children:i.outcome.unconfirmedRetrying}),P&&_]});break}case "replaced":{let P=o.invoice.replacedBy,W=P?.number??"";if(E=c(i.outcome.replacedTitle,{merchant:h}),C=jsxs(Fragment$1,{children:[jsx(ee,{children:c(i.outcome.replacedText,{number:W})}),jsx(ee,{muted:true,children:i.outcome.replacedPaid})]}),P?.checkoutToken){let z=P.checkoutToken;ie=jsx(X,{onClick:()=>y(z),children:jsx(ge,{label:i.outcome.openReplacement,values:{number:W}})});}break}case "blocked":{E=i.outcome.blockedTitle;let P=r.payer?parseCaip10AccountId(r.payer)?.address:void 0;C=jsxs(Fragment$1,{children:[jsx(ee,{children:r.error?.code==="payer_not_expected"?i.method.payerNotExpected:c(i.outcome.blockedText,{merchant:h})}),P&&jsx(He,{hash:P,chainId:x??o.quote?he((x??o.quote).instructions):null})]}),g&&(ie=jsx(X,{onClick:()=>{m(g)||a(true);},children:i.outcome.useAnotherWallet}));break}}return jsxs(Fragment$1,{children:[jsxs("section",{role:e==="blocked"?"alert":void 0,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",n.display==="page"&&"novapay-page-status"),children:[jsx(At,{mark:e,tone:Js[e].tone,chip:i.status[Js[e].label],title:E}),C,t&&jsx(Q,{children:i.pay.connectUnavailable})]}),jsxs(Z,{children:[ie,jsx(vo,{})]})]})}function $n({children:e,className:t}){let{store:a,customization:n}=I(),[o]=useState(()=>bt(a,"title")!==void 0),r=o&&!n.config?.animation?.disabled;return jsx("div",{className:cn$1("novapay:w-full",r&&"novapay-status-reveal",t),children:e})}function ti(){let e=I(),{checkout:t,state:a,labels:n,adapterFor:o,payAfterFailure:r,customization:s,display:i}=e,c$1=dn(),l=yn("primary",n.pay.payAgain);if(!t||!a.error)return null;let p=i==="page",m=s.childCustomizations,y=la(a.error)??c$1.txKey,f=a.quote??t.quote,v=f?he(f.instructions):null,d=y===c$1.txKey?c$1.explorerUrl:f&&v&&y?o(f.instructions.family)?.explorerUrl?.({chainId:v,txKey:y}):void 0;return jsxs(Ze,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",p&&"novapay-page-status"),children:[jsx(At,{mark:"failed",tone:"error",chip:n.status.failed,title:n.failed.title,amount:c$1.amount,note:c$1.network?c(n.failed.summary,{network:c$1.network}):null}),jsx(fn,{state:"failed"}),(c$1.network||y||c$1.fromAddress)&&jsxs(xe,{className:"novapay:max-w-sm",children:[c$1.network&&jsx(H,{name:n.confirm.network,children:c$1.network}),y&&jsx(H,{name:n.confirm.transaction,children:jsx(HashLink,{hash:y,explorerUrl:d,variant:"compact",...m?.hashLink})}),c$1.fromAddress&&jsx(H,{name:n.confirm.from,children:jsx(HashLink,{hash:c$1.fromAddress,explorerUrl:c$1.fromUrl,variant:"compact",...m?.hashLink})})]}),jsx($n,{className:"novapay:max-w-sm",children:jsx("p",{role:"status",className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",children:An(a.error,n,c$1.network??void 0)})})]}),jsxs(Z,{children:[jsx(X,{onClick:r,className:l.arrives?Ca:void 0,children:l.label}),jsx($n,{children:jsx(vo,{})})]})]})}function oi({onStay:e,onLeave:t}){let{checkout:a,labels:n,locale:o}=I(),r=useId(),s=useId(),i=useRef(null),c$1=a?.invoice.dueAt?new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(a.invoice.dueAt)):null;return jsx(Dialog,{open:true,onOpenChange:l=>{l||e();},children:jsxs(DialogContent,{role:"alertdialog","aria-labelledby":r,"aria-describedby":s,onOpenAutoFocus:l=>{l.preventDefault(),i.current?.focus();},className:"novapay:w-full novapay:sm:w-[24rem]",children:[jsx(DialogTitle,{"aria-hidden":true,className:"novapay:sr-only",children:n.leave.title}),jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3 novapay:p-5 novapay:text-center",children:[jsx("h2",{id:r,ref:i,tabIndex:-1,className:at,children:n.leave.title}),jsx("p",{id:s,className:"novapay:m-0 novapay:text-xs",children:c$1?c(n.leave.text,{date:c$1}):n.leave.textNoDate}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.leave.price}),jsx(X,{onClick:e,children:n.leave.stay}),jsx(ae,{onClick:t,children:n.leave.leave})]})]})})}function vn({label:e,items:t,value:a,getKey:n,onChange:o,children:r,className:s,itemClassName:i}){let c=useRef([]),l=Math.max(0,t.findIndex(m=>n(m)===a)),p=(m,y)=>{let f=t.length-1,v={ArrowRight:y+1,ArrowDown:y+1,ArrowLeft:y-1,ArrowUp:y-1,Home:0,End:f}[m.key];if(v===void 0)return;m.preventDefault();let d=v<0?f:v>f?0:v;o(n(t[d])),c.current[d]?.focus();};return jsx("div",{role:"radiogroup","aria-label":e,className:s,children:t.map((m,y)=>{let f=n(m),v=f===a;return jsx("button",{ref:d=>{c.current[y]=d;},type:"button",role:"radio","aria-checked":v,tabIndex:y===l?0:-1,onClick:()=>o(f),onKeyDown:d=>p(d,y),className:cn$1("novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:text-left novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors","novapay:border",v?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]",ce,i?.(v,m)),children:r(m,v)},f)})})}function Kn({tone:e,children:t}){return jsx("span",{className:cn$1(en,tn[e]),children:t})}function ci({method:e,labels:t}){let a=Xa(e);return a?a.kind==="discount"?jsx(Kn,{tone:"success",children:c(t.method.discount,{percent:a.percent})}):jsx(Kn,{tone:"neutral",children:c(t.method.markup,{percent:a.percent})}):null}function gu({selected:e}){return jsx("span",{"aria-hidden":true,className:cn$1("novapay:h-3.5 novapay:w-3.5 novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-full)] novapay:box-border",e?"novapay:border-4 novapay:border-[var(--tuwa-text-accent)]":"novapay:border novapay:border-[var(--tuwa-text-secondary)]")})}function bu({labels:e,terms:t,refundPolicy:a}){let n=(r,s)=>jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ce),children:s},r),o=t&&a?d(e.method.agreeBoth,{terms:n(t,e.summary.terms),refundPolicy:n(a,e.summary.refundPolicy)}):t||a?d(e.method.agreeOne,{link:t?n(t,e.summary.terms):n(a,e.summary.refundPolicy)}):null;return o?jsx("p",{className:"novapay:m-0 novapay:text-center novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o}):null}function li(){let e=I(),{checkout:t,state:a,store:n,labels:o,wallet:r,payWith:s,setPayWith:i,payUrl:c$1,connectWallet:l,adapterFor:p,setHandoff:m,lockPrice:y}=e,{TokenOption:f,NetworkOption:v}=e.customization.components??{},d=useMemo(()=>t?.methods??[],[t]),R=useMemo(()=>wr(d,r?.chainId),[d,r?.chainId]),h=d.find(A=>A.id===a.methodId)??null,x=R.find(A=>A.symbol===h?.symbol)??null,g=h?hr(h,c$1):false,k=h?Ye(h):null,b=[...(k?!!p(k):false)?["wallet"]:[],...g?["qr"]:[]],L=b.includes(s)?s:b[0]??null,[B,_]=useState(false),w=useId(),D=useId(),E=useEffectEvent(()=>{let A=R[0]?.methods[0];!a.methodId&&A&&n.getState().selectMethod(A.id,{keepError:true});});if(useEffect(()=>E(),[R]),!t)return null;if(d.length===0)return jsx(de,{title:o.method.title,children:jsx(Q,{children:o.method.noMethods})});let C=e.display==="page",ie=R.reduce((A,F)=>F.methods.length>A.methods.length?F:A,R[0]),P=a.phase==="quoting",W=t.consent??null,z=!!a.consentGiven,Se=!!(W?.required&&!z),Ne=e.customization.handlers,we=A=>{let F=()=>n.getState().selectMethod(A.id);Ne?.onMethodSelect?Ne.onMethodSelect({method:A,select:F}):F();},re=async()=>{if(!h||!L)return;if(_(false),L==="qr"){if(s!=="qr"&&i("qr"),k!=="solana")return m(true);n.getState().setPayer(null),await n.getState().requestQuote();return}s!=="wallet"&&i("wallet");let A=Ue(r,h);if(!A)return _(!l(h));n.getState().setPayer(A),await y();},ke=A=>jsxs(Fragment$1,{children:[jsx(cn,{children:jsx(ge,{label:o.method.network,values:{symbol:A.symbol}})}),jsx(vn,{label:c(o.method.network,{symbol:A.symbol}),items:A.methods,value:h?.id??null,getKey:F=>F.id,onChange:F=>{let U=A.methods.find(ne=>ne.id===F);U&&we(U);},className:C&&A.methods.length>1?"novapay:grid novapay:grid-cols-1 novapay:gap-1.5 novapay:@min-[520px]:grid-cols-2":"novapay:flex novapay:flex-col novapay:gap-1.5",itemClassName:(F,U)=>cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-3 novapay:py-2.5",Y(e,"networkOption",{method:U,selected:F})),children:(F,U)=>v?jsx(v,{method:F,selected:U}):jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(NetworkIcon,{chainId:toEvmChainId(F.chainId)??F.chainId})}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col novapay:gap-1",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:ve(F.chainId)}),jsxs("span",{className:"novapay:flex novapay:flex-wrap novapay:items-center novapay:gap-1.5",children:[r?.chainId===F.chainId&&jsx(Kn,{tone:"neutral",children:o.method.yourWallet}),F.featured&&jsx(Kn,{tone:"accent",children:o.method.popular}),jsx(ci,{method:F,labels:o}),F.gasless==="auto"?jsx(Kn,{tone:"success",children:o.method.noGasFee}):jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.buyerPaysGas})]})]}),jsx(gu,{selected:U})]})})]});return jsxs(Fragment$1,{children:[jsxs(de,{title:o.method.title,subtitle:c(o.method.subtitle,{minutes:Math.round(t.quoteTtlSeconds/60)}),children:[jsx(cn,{children:o.method.token}),jsx(vn,{label:o.method.token,items:R,value:x?.symbol??null,getKey:A=>A.symbol,onChange:A=>{let F=R.find(U=>U.symbol===A)?.methods[0];F&&we(F);},className:"novapay:grid novapay:grid-cols-[repeat(auto-fit,minmax(5.5rem,1fr))] novapay:gap-2",itemClassName:(A,F)=>cn$1("novapay:flex novapay:min-w-0 novapay:flex-col novapay:items-center novapay:gap-1 novapay:px-2 novapay:py-2",C&&"novapay-page-token",Y(e,"tokenOption",{group:F,selected:A})),children:(A,F)=>f?jsx(f,{group:A,selected:F}):jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:h-6.5 novapay:w-6.5",children:jsx(TokenIcon,{symbol:A.symbol})}),jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:A.symbol}),jsx("span",{className:"novapay:max-w-full novapay:truncate novapay:text-[10px] novapay:text-[var(--tuwa-text-secondary)]",children:A.methods.length>1?c(o.method.networks,{count:A.methods.length}):Xa(A.methods[0])?jsx(ci,{method:A.methods[0],labels:o}):ve(A.methods[0].chainId)})]})}),C&&x?jsxs("div",{className:cn$1("novapay:grid",x.methods.length===1&&"novapay:max-sm:hidden"),children:[ie!==x&&jsx("div",{inert:true,"aria-hidden":true,className:"novapay:invisible novapay:flex novapay:flex-col novapay:gap-2.5 novapay:[grid-area:1/1] novapay:max-sm:hidden",children:ke(ie)}),jsx("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-2.5 novapay:[grid-area:1/1]",children:ke(x)})]}):x&&x.methods.length>1&&ke(x),jsx(cn,{children:o.method.payWith}),jsx(vn,{label:o.method.payWith,items:b,value:L,getKey:A=>A,onChange:A=>{_(false),i(A);},className:cn$1("novapay:grid novapay:gap-2",b.length>1&&"novapay:grid-cols-2"),itemClassName:(A,F)=>cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-2.5 novapay:py-2",C&&"novapay-page-way",Y(e,"payWithOption",{payWith:F,selected:A})),children:A=>A==="wallet"?jsxs(Fragment$1,{children:[r?jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(Fn,{walletId:r.walletId,icon:r.icon})}):jsx(rr,{"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:o.method.wallet}),jsx("span",{className:cn$1("novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",r&&$),children:r?`${r.name} \xB7 ${shortAddress(r.address)}`:o.method.walletHint})]})]}):jsxs(Fragment$1,{children:[h&&Ye(h)==="solana"?jsx(yr,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0"}):jsx(lr,{"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:o.method.qr}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.qrHint})]})]})}),W&&jsxs("label",{className:cn$1("novapay:flex novapay:cursor-pointer novapay:items-start novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2.5 novapay:transition-colors",z?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]",Y(e,"consentOption",{checked:z,required:W.required})),children:[jsx(da,{checked:z,required:W.required,"aria-labelledby":w,"aria-describedby":W.required?D:void 0,onChange:A=>n.getState().setConsentGiven(A.target.checked),className:"novapay:mt-0.5"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-1",children:[jsx("span",{id:w,className:"novapay:whitespace-pre-line novapay:break-words novapay:text-[12px] novapay:leading-snug",children:W.text}),W.required&&jsx("span",{id:D,className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.consentRequired})]})]}),h&&!L&&jsx(Q,{children:o.method.methodUnavailable}),B&&jsx(Q,{children:g?o.pay.connectUnavailable:o.method.methodUnavailable}),a.error&&a.phase==="selectMethod"&&jsxs(Fragment$1,{children:[jsx(Q,{children:pa(a.error,o,t.merchant.name)}),jsx(ya,{error:a.error})]})]}),jsxs(Z,{children:[jsx(X,{busy:P,disabled:!h||!L||Se,onClick:()=>{h&&L&&Ne?.onQuote?Ne.onQuote({method:h,payWith:L,proceed:re}):re();},children:P?o.method.quoting:o.method.continue}),jsx(bu,{labels:o,terms:t.merchant.links.terms,refundPolicy:t.merchant.links.refundPolicy})]})]})}function di(e,t,a,n=false){let o=useRef(null),r=t?.id??null,s=useEffectEvent(()=>{t&&a?.({...t,status:"paid"});});useEffect(()=>{e!=="paid"||!r||o.current===r||(o.current=r,n||s());},[e,r,n]);}function yi({url:e,seconds:t,now:a,navigate:n=o=>window.location.assign(o)}){let[o,r]=useState(t>0?a:null);t>0!=(o!==null)&&r(t>0?a:null);let s=t>0?o??a:a,[i,c]=useState(false),l=e&&t>0&&!i?Math.max(0,t-Math.floor((a-s)/1e3)):null,p=useEffectEvent(()=>{e&&n(e);});return useEffect(()=>{l===0&&p();},[l]),{left:l,stay:()=>c(true)}}function vi(){let e=I(),{checkout:t,state:a,labels:n,locale:o,now:r,close:s,autoReturnSeconds:i,openedPaid:c$1,display:l}=e,p=e.customization.childCustomizations,m=dn(),[y]=useState(r),f=t?.merchant.name??"",v=l==="modal"&&i===0?null:t?.invoice.successUrl??null,d=yi({url:v,seconds:c$1?0:i,now:r}),R=v?n.paid.back:s?n.common.close:null,h=yn(R===null?null:"primary",R??""),x=h.arrives?Ca:void 0;if(!t)return null;let g=t.invoice.totalMinor?ye(Re(t.invoice.totalMinor),o):null,k=t.invoice.refundedTotalMinor&&BigInt(t.invoice.refundedTotalMinor)>0n?ye(Re(t.invoice.refundedTotalMinor),o):null,N=t.invoice.paidAt?Date.parse(t.invoice.paidAt):y,b=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(N),{transfers:L}=m,B=L.length>1?L:null,_=L.length===1?L[0]:null,w=m.txKey??_?.txKey??null,D=m.txKey?m.explorerUrl:_?.explorerUrl,E=new Intl.DateTimeFormat(o,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});return jsxs(Ze,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",e.display==="page"&&"novapay-page-status"),children:[jsx(At,{mark:"paid",tone:"success",chip:n.status.paid,title:n.paid.title,amount:m.paidAmount??(g&&`${g} ${t.invoice.currency}`),note:m.network?c(n.paid.summary,{network:m.network,date:b}):b}),jsx(fn,{state:"succeed"}),(m.network||w||B||m.from)&&jsxs(xe,{className:"novapay:max-w-sm",children:[m.network&&jsx(H,{name:n.confirm.network,children:m.network}),B?B.map((C,ie)=>jsxs(H,{name:jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:block",children:c(n.confirm.transferOf,{index:ie+1,count:B.length})}),jsx("time",{dateTime:new Date(C.at).toISOString(),className:"novapay:block novapay:text-[11px] novapay:leading-4",children:E.format(C.at)})]}),children:[C.amount&&jsx("span",{className:"novapay:block",children:C.amount}),jsx(HashLink,{hash:C.txKey,explorerUrl:C.explorerUrl,variant:"compact",...p?.hashLink})]},`${C.txKey}:${ie}`)):w&&jsx(H,{name:m.lastOfParts?n.confirm.lastTransfer:n.confirm.transaction,children:jsx(HashLink,{hash:w,explorerUrl:D,variant:"compact",...p?.hashLink})}),m.fromAddress&&jsx(H,{name:n.confirm.from,children:jsx(HashLink,{hash:m.fromAddress,explorerUrl:m.fromUrl,variant:"compact",...p?.hashLink})})]}),k&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(n.paid.refunded,{amount:k,currency:t.invoice.currency})}),a.receiptUrl&&jsx($n,{className:"novapay:max-w-sm",children:jsxs("div",{className:"novapay:flex novapay:w-full 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(ar,{"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:n.paid.receipt}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:n.paid.receiptHint})]}),jsxs("a",{href:a.receiptUrl,target:"_blank",rel:"noopener noreferrer",className:cn$1(nn,"novapay:gap-1.5 novapay:no-underline"),children:[jsx(sr,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),n.paid.download]})]})})]}),jsx(Z,{children:v?jsxs(Fragment$1,{children:[jsx("a",{href:v,className:cn$1(Tt,x,Y(e,"primaryButton")),children:jsx(ge,{label:h.label,values:{merchant:f}})}),d.left!==null&&jsxs($e,{children:[jsx("span",{role:"timer","aria-live":"off",children:c(n.paid.returning,{merchant:f,seconds:d.left})})," ","\xB7 ",jsx(ht,{onClick:d.stay,children:n.paid.stay})]})]}):s&&jsx(X,{onClick:s,className:x,children:h.label})})]})}function La({payee:e}){let{labels:t,checkout:a,state:n,backToMethods:o}=I();if(e.status==="checking")return jsxs("div",{role:"status",className:cn$1("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)]","novapay-payee-wait"),children:[jsx(QuasarLoader,{size:40}),t.pay.payeeChecking]});let r=a?.merchant.name??"",s=(n.invoiceStatus??a?.invoice.status)==="underpaid";return jsxs(Fragment$1,{children:[jsx(de,{title:t.pay.payeeRefusedTitle,children:jsx("div",{"data-payee-refusal":e.reason,children:jsx(Q,{children:c(t.pay.payeeRefused,{merchant:r})})})}),jsx(Z,{children:jsx(ae,{onClick:o,children:s?t.pay.backFromRest:t.pay.back})})]})}function xi({state:e,screen:t,now:a,locale:n=null,handlers:o}){let r=e.checkout?.invoice.status??null,{phase:s,error:i}=e,c=e.quote?.expiresAt?Date.parse(e.quote.expiresAt):null,l=c!==null&&a>=c,p=useEffectEvent(()=>o?.onStatusChange?.({phase:s,status:r,screen:t}));useEffect(()=>p(),[s,r]);let m=useEffectEvent(()=>{n&&o?.onLocaleShown?.({locale:n});});useEffect(()=>m(),[n]);let y=useEffectEvent(()=>{i&&o?.onError?.({error:i,screen:t});});useEffect(()=>y(),[i]);let f=useRef({quote:false,invoice:false}),v=useEffectEvent(d=>o?.onExpire?.({kind:d,paymentOnTheWay:ot(e)||ft(e,e.checkout)||qt(e,e.checkout)}));useEffect(()=>{l&&!f.current.quote&&v("quote"),f.current.quote=l;},[l]),useEffect(()=>{let d=r==="expired";d&&!f.current.invoice&&v("invoice"),f.current.invoice=d;},[r]);}var Qt=()=>new Promise(()=>{}),Lu={view:Qt,quote:Qt,buyer:Qt,locale:Qt,submit:Qt,relay:Qt,authorizeRelay:Qt,url:()=>""},Au=createCheckoutStore({token:"idle",api:Lu,EventSource:null});function bi(e){let{token:t,baseUrl:a,api:n,EventSource:o,pollMs:r,enabled:s=true,payee:i}=e,[c,l]=useState(Au),p=useEffectEvent(()=>createCheckoutStore({token:t,baseUrl:a,api:n,EventSource:o,pollMs:r,payee:i})),m=i?.addresses?.join(`
2
- `)??"";return useEffect(()=>{if(!s)return;let y=p();return l(y),y.getState().load(),()=>y.getState().destroy()},[t,a,s,m]),c}function wi(e,t){return useStore(e,t)}var Du=createStore(()=>({}));function _a(){let e=useContext(SatelliteStoreContext)??Du,t=useStore(e,l=>l.activeConnection),a=useStore(e,l=>l.getConnectors),n=useStore(e,l=>l.watchConnectors),[o,r]=useState(0);useEffect(()=>n?.(()=>r(l=>l+1)),[n]);let s=useMemo(()=>vr(t,a?.()),[t,a,o]),i=s?.name,c=s?.icon;return useMemo(()=>s,[t,i,c])}function Ci(e){let[t,a]=useState({store:e,at:null});return useEffect(()=>e.subscribe((n,o)=>{n.phase!==o.phase&&(n.phase==="confirming"?a({store:e,at:o.phase==="submitting"?Date.now():null}):o.phase==="confirming"&&a({store:e,at:null}));}),[e]),t.store===e?t.at:null}var Si=Symbol.for("tuwaio.nova-payments.context"),Pi=globalThis,Gn=Pi[Si]??(Pi[Si]=createContext({}));function pt(){return useContext(Gn)}function Ni(e,t=true){let[a,n]=useState(()=>Date.now());return useEffect(()=>{if(!t)return;let o=setInterval(()=>n(Date.now()),e);return ()=>clearInterval(o)},[e,t]),a}var bo="nova-payments:sponsoredBatches";var wo=()=>{try{return globalThis.sessionStorage??null}catch{return null}},ko=()=>{try{let e=JSON.parse(wo()?.getItem(bo)??"[]");return Array.isArray(e)?e:[]}catch{return []}},Ti=e=>{try{e.length>0?wo()?.setItem(bo,JSON.stringify(e)):wo()?.removeItem(bo);}catch{}},Fa=e=>Ti(ko().filter(t=>t.invoiceId!==e)),Ri=e=>Ti([...ko().filter(t=>t.invoiceId!==e.invoiceId),e]),Co=e=>ko().find(t=>t.invoiceId===e&&Date.now()-t.at<21e5)??null;function xn(e){let t=e.payeeCheck;return !e.quote||!t||t.quote!==e.quote||t.status==="checking"?{status:"checking"}:t.status==="verified"?{status:"verified"}:{status:"refused",reason:t.reason}}function Ii(e,t){return e.payeeCheck?.quote===t&&e.payeeCheck.status==="verified"}function Ei(e,t){let a=Rt(t.chainId),n=a?e?.find(o=>o.family===a)?.verifyPayoutRecord:void 0;return n?n(t):Promise.resolve(null)}function Li(e,t){return !e||!t?.length||payoutAddressesOf(e)?e:withPayoutAddresses(e,t)}var Ai=e=>new a("unsupported",`${e} is not available`);async function _i({adapter:e,store:t,quote:a$1,wallet:n,path:o,paymasterUrl:r,onWalletDone:s,onBatchAccepted:i,onSent:c}){if(!Ii(t.getState(),a$1))throw new a("unsupported","The payee of the quote is not verified");let l=n.address;if(o==="relay"){let m=a$1.gasless?.relay?.typedData;if(!m||!e.signTransferAuthorization)throw Ai("A gasless signature");let y=await e.signTransferAuthorization({typedData:m,account:l});s?.();let{relayFromPage:f,relay:v}=t.getState(),d=e.sendOneTimeRelay;return f&&d&&r?f(y,R=>d({chainId:R.chainId,call:R.call,paymasterUrl:r})):v(y)}if(o==="paymaster"){let m=a$1.gasless?.paymaster?.calls;if(!m||!r||!e.sendSponsoredCalls)throw Ai("A sponsored payment");let y=he(a$1.instructions),f=await e.sendSponsoredCalls({calls:m,paymasterUrl:r,chainId:y,account:l,onSent:s,onAccepted:i,onLate:v=>{c?.(v),t.getState().submit({txKey:v,connectorType:n.connectorType,methodId:a$1.methodId});}});return s?.(),c?.(f),t.getState().submit({txKey:f,connectorType:n.connectorType,methodId:a$1.methodId})}let p=await e.sendTransfer({instructions:a$1.instructions,account:l,connection:n.connection});return s?.(),c?.(p),t.getState().submit({txKey:p,connectorType:n.connectorType,methodId:a$1.methodId})}var Ma=6e5;var Ft=new WeakMap;function Oa(e){let t=Ft.get(e);return !!(t?.accepted&&Date.now()<t.until)}function Mi({adapter:e,store:t,quote:a$1,wallet:n,path:o,paymasterUrl:r,invoiceId:s,onSent:i}){let[c,l]=useState("idle"),[p,m]=useState(()=>{let g=Ft.get(t),k=g?.unconfirmed&&g.account===n?.address&&Date.now()<g.until,N=s?Co(s):null;return k||N?"sentUnconfirmed":null}),y=useEffectEvent(g=>i?.(g));useEffect(()=>{if(!s||Ft.has(t))return;let g=Co(s);if(!g)return;let k=Promise.reject(new a("sentUnconfirmed","The sponsored payment is not confirmed yet"));k.catch(()=>{});let N=g.at+21e5;Ft.set(t,{account:g.account,path:"paymaster",paying:k,until:N,unconfirmed:true,instructions:g.instructions,accepted:true}),e?.followSponsoredCalls?.({batchId:g.batchId,until:N,onLate:b=>{Fa(s),y({txKey:b,instructions:g.instructions,account:g.account,connectorType:g.connectorType}),t.getState().submit({txKey:b,connectorType:g.connectorType,methodId:g.methodId});}});},[s,e,t]);let f=useRef(0),[v,d]=useState(null),[R,h]=useState(null),x=async(g,k)=>{let N=++f.current,b=()=>f.current===N;m(null),l(g);try{await k(b);}catch(L){b()&&m(b$1(L));}finally{b()&&l("idle");}};return {status:c,problem:p,askedWallet:v,askedInstructions:R,pay:()=>x("wallet",async g=>{if(!e||!a$1||!n)return m("unsupported");d(n);let k=Ft.get(t),N=k?.path==="relay"&&o==="relay";if(k?.account===n.address&&!N&&Date.now()<k.until){h(k.instructions),await k.paying;return}h(a$1.instructions);let b={account:n.address,path:o,paying:Promise.resolve(),until:Date.now()+6e5,unconfirmed:!1,instructions:a$1.instructions,accepted:!1};Ft.set(t,b);let L=_i({adapter:e,store:t,quote:a$1,wallet:n,path:o,paymasterUrl:r,onWalletDone:()=>{o==="paymaster"&&(b.accepted=!0),g()&&l("submitting");},onBatchAccepted:_=>{s&&Ri({invoiceId:s,batchId:_,account:n.address,instructions:a$1.instructions,connectorType:n.connectorType,methodId:a$1.methodId,at:Date.now()});},onSent:_=>{s&&Fa(s),i?.({txKey:_,instructions:a$1.instructions,account:n.address,connectorType:n.connectorType});}});b.paying=L;let B=()=>{Ft.get(t)===b&&Ft.delete(t),s&&Fa(s);};L.then(B,_=>{if(b$1(_)!=="sentUnconfirmed")return B();b.unconfirmed=!0,b.until=Date.now()+21e5;}),await L;}),switchNetwork:()=>x("switching",async()=>{if(!e?.switchChain||!a$1)return m("unsupported");await e.switchChain(he(a$1.instructions));}),dismiss:()=>{f.current++,l("idle");}}}var Yu=100,Zu=300,Bi=(e,t)=>e.length>t?`${e.slice(0,t-1)}\u2026`:e;async function Oi({adapter:e,pulsar:t,payment:a,labels:n,merchant:o,invoice:r,amount:s}){if(!t||!e?.pulsarTransaction)return false;let i=r.number?c(n.pay.txDescription,{amount:s,invoice:r.number}):s,c$1=e.pulsarTransaction({...a,title:Bi(c(n.pay.txTitle,{merchant:o}),Yu),description:Bi(i,Zu),payload:{quasarInvoice:r.id}});return await t.injectExternalPendingTxs([c$1]),true}var Xu=new Set(["open","processing","underpaid"]),qi=new WeakMap,So=e=>{let t=qi.get(e);return t||qi.set(e,t={keys:new Set,sentHere:false}),t},em=e=>e.split(":").at(-1)??e;function Ui({store:e,adapterFor:t,pulsar:a,labels:n,locale:o}){let r=useRef({adapterFor:t,pulsar:a,labels:n,locale:o});useEffect(()=>{r.current={adapterFor:t,pulsar:a,labels:n,locale:o};});let s=useCallback(i=>{let{checkout:c}=e.getState(),{adapterFor:l,pulsar:p,labels:m,locale:y}=r.current,f=So(e);if(!c||!p||f.keys.has(i.txKey))return;f.keys.add(i.txKey);let{amount:v,decimals:d,symbol:R}=i.instructions;Oi({adapter:l(i.instructions.family),pulsar:p,payment:i,labels:m,merchant:c.merchant.name,invoice:{id:c.invoice.id,number:c.invoice.number},amount:`${pe(v,d,y)} ${R}`}).catch(()=>{});},[e]);return useEffect(()=>e.subscribe((i,c)=>{let{txHash:l,quote:p,checkout:m}=i;if(!l||l===c.txHash||!p||!m||!Xu.has(c.invoiceStatus)||So(e).sentHere)return;let y=m.invoice.originWallet??p.payer;s({txKey:l,instructions:p.instructions,account:y?em(y):"",connectorType:""});}),[e,s]),useCallback(i=>{So(e).sentHere=true,s(i);},[e,s])}function $i({store:e,state:t,walletTxKey:a=null}){let[n,o]=useState(null),[r,s]=useState(null),i=a!==null&&a!==r;i&&s(a);let c=t.phase,l=i||ot(t)||ft(t,t.checkout)||qt(t,t.checkout)||c==="confirming"||c==="unconfirmed",p=n?.store===e?n:null,m=l?p&&p.error===t.error?p:{store:e,error:t.error}:p&&Ir(t.error)&&t.error!==p.error?null:n;return m!==n&&o(m),m?.store===e}function zn(e){let{labels:t,customization:a}=pt(),n=a?.labels?.transform,[o,r]=useState(()=>h(e)),s=g(e);s&&o!==h(e)&&r(h(e));let i$1=s?h(e):o;return useEffect(()=>{if(g(e))return;let c=true;return i(e).then(l=>c&&r(l)),()=>{c=false;}},[e]),useMemo(()=>{let c=j(i$1,t);return n?n(c,{locale:e}):c},[i$1,e,t,n])}function Ki({store:e,screen:t}){let[a,n]=useState(null),o=t==="qr";return o&&a!==e&&n(e),o||a===e}function Da(e){let t=useContext(NovaConnectProviderContext),a=pt(),n=e??a.onConnectWallet;return {canConnect:!!(t||n),connecting:t?.isConnectModalOpen??false,connect:o=>t?(t.setIsConnectModalOpen(true,{adapter:o==="solana"?OrbitAdapter.SOLANA:OrbitAdapter.EVM}),true):n?(n(o),true):false}}function Gi({box:e,content:t,isNarrow:a,isActive:n,duration:o=300}){if(typeof ResizeObserver>"u")return ()=>{};let r,s,i=0,c=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,l=()=>{s=void 0,e.style.removeProperty("overflow");},p=()=>{let f=s;l(),f?.cancel();},m=()=>{let f=t.offsetHeight,v=r;if(r=f,v===void 0||v===f)return;if(s){s.effect?.setKeyframes?.([{height:`${i}px`},{height:`${f}px`}]);return}if(!a()||!n()||c()||typeof e.animate!="function"||Math.abs(f-v)<12)return;i=v,e.style.overflow="clip";let R=e.animate([{height:`${v}px`},{height:`${f}px`}],{duration:o,easing:"cubic-bezier(0.2, 0, 0, 1)"});s=R;let h=()=>{s===R&&l();};R.onfinish=h,R.oncancel=h;},y=new ResizeObserver(m);return y.observe(t),m(),()=>{y.disconnect(),p();}}function ji({active:e,children:t}){let a=useRef(null),n=useRef(null),o=useRef(e);return useEffect(()=>{o.current=e;},[e]),useEffect(()=>{if(!a.current||!n.current||typeof window>"u"||!window.matchMedia)return;let r=window.matchMedia("(max-width: 639.98px)");return Gi({box:a.current,content:n.current,isNarrow:()=>r.matches,isActive:()=>o.current})},[]),jsx("div",{ref:a,className:"novapay:flex novapay:flex-none novapay:flex-col novapay:sm:min-h-0 novapay:sm:flex-1",children:jsx("div",{ref:n,className:"novapay:flex novapay:flex-none novapay:flex-col novapay:sm:min-h-0 novapay:sm:flex-1",children:t})})}function gn(e,t){let[a,n]=useState(null),o=useEffectEvent(t);return useEffect(()=>{if(e===null)return;let r=true,s;try{s=Promise.resolve(o());}catch(i){s=Promise.reject(i);}return s.then(i=>r&&n({key:e,value:i}),()=>r&&n({key:e,value:null})),()=>{r=false;}},[e]),a&&a.key===e?a.value:void 0}function Wa(e,t,a){let[n,o]=useState(0),[r,s]=useState(null),i=useEffectEvent(t);return useEffect(()=>{if(e===null||typeof window>"u")return;let c=()=>{document.visibilityState!=="hidden"&&o(m=>m+1);},l=window,p=document;return l.addEventListener("focus",c),p.addEventListener("visibilitychange",c),()=>{l.removeEventListener("focus",c),p.removeEventListener("visibilitychange",c);}},[e]),useEffect(()=>{if(e===null)return;let c=true,l;try{l=Promise.resolve(i());}catch(p){l=Promise.reject(p);}return l.then(p=>c&&s({key:e,value:p}),()=>c&&s({key:e,value:null})),()=>{c=false;}},[e,n,a]),r&&r.key===e?r.value:void 0}var im=e=>e.charAt(0).toUpperCase()+e.slice(1);function Zi(e,t,a){let n=e.startsWith("solana:")?getSolanaCluster(e):void 0;if(!n||n==="mainnet")return null;let o={network:ve(e),cluster:im(n),wallet:t?.name??""},r=t?.family!=="solana"?void 0:t.walletId==="phantom"?a.pay.solanaHintPhantom:t.walletId==="solflare"?a.pay.solanaHintSolflare:a.pay.solanaHintOther;return {title:c(a.pay.solanaNetwork,o),text:c(a.pay.solanaNetworkText,o),...r?{hint:c(r,o)}:{}}}function Ji(e,t){let a=e.startsWith("solana:")?getSolanaCluster(e):void 0;return !a||t?.family!=="solana"||getSolanaCluster(t.chainId)===a?null:e}function Xi(e,t){let a=useContext(SatelliteStoreContext),n=Ji(e,t);useEffect(()=>{n&&a?.getState().switchNetwork?.(n);},[a,n]);}function um(e,t){return e>=1?ye(e,t):new Intl.NumberFormat(t,{maximumSignificantDigits:6}).format(e)}function mm(e,t,a,n){let o=n?.code;if(a==="declined")return c(e.pay.declined,t);if(a==="unsupported")return c(e.pay.unsupported,t);if(a==="wrongNetwork")return c(e.pay.wrongCluster,t);if(a==="switchFailed")return c(e.pay.switchFailed,t);if(a==="notAuthorized")return c(e.pay.notAuthorized,t);if(a==="alreadyPending")return c(e.walletPrompt.stillWaiting,t);if(a==="sentUnconfirmed")return c(e.pay.sentUnconfirmed,t);let r=a?null:Ut(n,e,t.merchant);return r!==null?r:a==="failed"?c(e.pay.walletFailed,t):n&&o==="payment_failed"?An(n,e,t.network):o==="screening_unavailable"?e.pay.screeningUnavailable:o==="request_failed"?e.pay.noAnswer:o==="price_unavailable"||o==="price_no_rpc"?e.method.priceUnavailable:o==="rate_limited"?e.method.rateLimited:o==="method_not_found"||o==="amount_out_of_range"||o==="testnet_required"?e.method.methodUnavailable:n&&!yo(n)?e.error.generic:null}var dm=(...e)=>e.reduce((t,a)=>t&&!/[。!?]$/.test(t)?`${t} ${a}`:`${t}${a}`,"");function ym(e,t,a){let{wallet:n,adapterFor:o}=I(),r=t?.instructions.family,s=r?o(r):void 0,i=e.filter(l=>l.id!==t?.methodId&&Ye(l)===r),c=gn(a&&s&&n&&i.length?`${n.address}:${i.map(l=>l.id).join()}`:null,()=>Promise.all(i.map(l=>s.getBalance({chainId:l.chainId,account:n.address,token:xr(l)}).catch(()=>0n))));return c?i.map((l,p)=>({method:l,balance:c[p]})).filter(l=>l.balance>0n):[]}function nc(){let{checkout:e,state:t,store:a,labels:n,locale:o,now:r,wallet:s,adapterFor:i,connectWallet:c$1,backToMethods:l,onPaymentSent:p,customization:m,lockPrice:y,display:f}=I(),v=m.config?.balanceCheck!==false,d=t.quote,R=e?.methods??[],h=R.find(We=>We.id===d?.methodId),x=d?.instructions.family??"eip155",g=i(x),k=d?he(d.instructions):"",N=s?.address??"",[b,L]=useState(false),B=gn(d?.gasless?.paymaster&&g?.canSponsorCalls&&s?`${k}:${N}`:null,()=>g.canSponsorCalls({chainId:k,account:N})),_=d?qr(d,{withGas:b,canSponsorCalls:B===true}):"transfer",w=Wa(v&&d&&g&&s?`${k}:${N}:${d.instructions.token}`:null,()=>g.getBalance({chainId:k,account:N,token:d.instructions.token}),d?.expiresAt),D=gn(d&&_==="transfer"&&g?.estimateFee&&s?`${k}:${N}:${d.amountToSend}`:null,()=>g.estimateFee({instructions:d.instructions,account:N})),E=Mi({adapter:g,store:a,quote:d,wallet:s,path:_,paymasterUrl:t.paymasterUrl,invoiceId:e?.invoice.id,onSent:p}),C=Pa({adapter:g,store:a,wallet:s,chainId:k});Xi(k,s);let ie=d?.instructions.token==="native",P=d&&typeof w=="bigint"?$r(w,d,ie&&D?D.amount:0n):null,W=(t.invoiceStatus??e?.invoice.status)==="underpaid",z=ym(R,d,v&&!!P&&!W),[Se,Ne]=useState(false),we=C.step==="switching"||C.step==="signing"||E.status==="switching"||E.status==="submitting"||E.status==="wallet"||t.phase==="submitting",[re,ke]=Na(we);if(e&&d&&!h)return jsxs(Fragment$1,{children:[jsx(de,{title:n.method.methodUnavailable,children:null}),jsx(Z,{children:jsx(ae,{onClick:l,children:n.pay.back})})]});if(!e||!d||!h)return null;let A=xn(t);if(A.status!=="verified"&&t.phase!=="submitting"&&E.status==="idle")return jsx(La,{payee:A});let F=e.merchant.name,U=ve(k),ne=We=>`${pe(We,d.decimals,o)} ${d.instructions.symbol}`,le=Ur(d),se=E.askedInstructions,Me=se&&se.amount!==d.instructions.amount?`${pe(se.amount,se.decimals,o)} ${se.symbol}`:ne(le.send),De=d.expiresAt?Date.parse(d.expiresAt)-r:Number.POSITIVE_INFINITY,Be=De<=0,Yt=Pr(De),Qe=t.phase==="quoting",Yn=e.invoice.amountPaid?null:Hr(d,e.invoice.totalMinor),ut=(t.invoiceStatus??e.invoice.status)==="underpaid",Cn=f==="page",Zn=D?ha(String(D.amount),D.decimals,o):null,Mt=ut?rn(d,r,n,F,o):null,Zt=e.invoice.totalMinor?ye(Re(e.invoice.totalMinor),o):null,Sn=!!(s&&d.payer&&Ue(s,h)===d.payer),kt=x==="eip155"&&s&&s.chainId!==k&&!!g?.switchChain,Jn=E.status!=="idle"||t.phase==="submitting"||Qe||C.step!=="idle",Ve=Zi(k,s,n),Jt=()=>{a.getState().requestQuote();},Ka=t.payerProof,Bt=Us(Ka,_),Pn=Bt?Ra(Dn(t.error)?t.error:null,C.problem,n,{wallet:s?.name??"",network:U,merchant:F}):null,Ot=t.phase==="awaitingPayment"&&!(Bt&&Dn(t.error))?t.error:void 0,Nn=mm(n,{wallet:s?.name??"",network:U,merchant:F},E.problem,Ot),Xn=!E.problem&&(Ot?.code==="payment_failed"||Ot?.code==="payment_mismatch"),Tn=()=>{c$1(h)||Ne(true);},Ee;Be?Ee={label:ut?n.outcome.payRest:n.pay.newPrice,run:Jt}:Sn?kt?Ee={label:jsx(ge,{label:n.pay.switchTo,values:{network:U}}),run:()=>{E.switchNetwork();}}:Bt?Ee={label:n.payerProof.confirmToPay,run:()=>{C.confirm();}}:Ee={label:Xn?n.pay.payAgain:jsx(ge,{label:_==="transfer"?n.pay.payAmount:n.pay.signToPay,values:{amount:ne(le.send)}}),run:()=>{m.handlers?.onSubmit?m.handlers.onSubmit({quote:d,method:h,proceed:E.pay}):E.pay();},disabled:!!P||E.problem==="sentUnconfirmed"}:Ee={label:n.pay.connect,run:Tn};let mt=C.step==="switching"?"switch":C.step==="signing"?"proof":E.status==="switching"?"switch":E.status==="submitting"||t.phase==="submitting"?"submitting":E.status==="wallet"?_==="transfer"?"confirm":"sign":null,ea=e.invoice.number??e.invoice.id,tt=s??E.askedWallet,ta={wallet:tt?.name??"",invoice:ea,merchant:F};return jsxs("div",{className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{ref:re,inert:we,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",we&&"novapay:hidden"),children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-3 novapay:px-5 novapay:py-4",Cn&&"novapay-page-screen novapay-page-pay"),children:[jsx("h2",{...Nt,className:"novapay:sr-only",children:n.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(Fn,{walletId:s.walletId,icon:s.icon})}),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($,"novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.walletLine,{address:shortAddress(s.address),network:ve(s.chainId)})})]}),jsx("button",{type:"button","aria-label":n.pay.changeWallet,onClick:Tn,className:nn,children:n.pay.change})]}),kt&&Sn&&!Be&&jsxs("div",{role:"status",className:cn$1(ia,"novapay:flex novapay:gap-2 novapay:px-3 novapay:py-2 novapay:text-xs"),children:[jsx(yt,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),jsxs("span",{children:[jsx("strong",{className:"novapay:block",children:n.pay.wrongNetwork}),c(n.pay.wrongNetworkText,{current:ve(s.chainId),network:U})," ",n.pay.switchHint]})]}),Ve&&!Be&&jsxs("div",{className:"novapay:flex 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:[jsx(or,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]"}),jsxs("span",{className:"novapay:flex novapay:flex-col novapay:gap-0.5",children:[jsx("strong",{children:Ve.title}),jsx("span",{children:Ve.text}),Ve.hint&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:Ve.hint})]})]}),jsxs("div",{children:[jsx("span",{className:cn$1(Oe,"novapay:block"),children:ut?n.pay.youSendRest:n.pay.youSend}),jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:gap-2",Cn&&"novapay-page-amount-row"),children:[jsx("span",{className:cn$1($,"novapay:text-[28px] novapay:font-bold novapay:leading-tight",Cn&&"novapay-page-amount"),children:pe(le.send,d.decimals,o)}),jsx("span",{className:cn$1($,"novapay:text-sm novapay:font-semibold"),children:d.instructions.symbol}),jsx(Mn,{text:xa(le.send,d.decimals),label:n.pay.copyAmount,copiedLabel:n.pay.copied})]}),jsxs("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[c(n.pay.onNetwork,{network:U}),Zt&&!le.fee&&!ut&&jsxs(Fragment$1,{children:[" \xB7 ",c(n.pay.fiatValue,{amount:Zt,currency:e.invoice.currency})]})]})]}),le.fee&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1.5",children:[jsxs(xe,{children:[jsx(H,{name:ut?n.pay.invoiceRest:n.pay.invoiceTotal,children:pe(le.receives,d.decimals,o)}),jsx(H,{name:c(n.pay.transferFee,{percent:le.fee.percent}),children:pe(le.fee.amount,d.decimals,o)}),jsx(H,{name:c(n.pay.merchantReceives,{merchant:F}),children:ne(le.receives)})]}),jsx("p",{className:"novapay:m-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:n.pay.transferFeeNote})]}),!Be&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2 novapay:text-xs",children:[jsx(on,{"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:c(Mt?n.pay.restTimeLeft:n.pay.priceLocked,{time:st(De)})}),!ut&&jsx(ht,{disabled:Qe,onClick:Jt,children:n.pay.refreshPrice})]}),Yt&&!Mt&&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:c(n.pay.priceEnding,{time:st(De)})}),jsx("span",{role:"status",className:"novapay:sr-only",children:c(n.pay.priceEnding,{time:st(to)})}),jsx("button",{type:"button",onClick:Jt,disabled:Qe,className:Xo,children:jsx(ge,{label:n.pay.keepPrice,values:{minutes:Math.round(e.quoteTtlSeconds/60)}})})]}),Be&&jsx(Q,{children:n.pay.priceExpired}),Mt&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:Mt}),P&&!Be&&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:n.pay.notEnough}),c(n.pay.walletHas,{amount:ne(P.have),network:U}),"."," ",c(n.pay.shortBy,{short:ne(P.short),need:ne(P.need)})]}),z.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:n.pay.payFromBalance}),z.map(({method:We,balance:Va})=>jsxs("button",{type:"button",onClick:()=>{let na=s?Ue(s,We):null;a.getState().selectMethod(We.id),a.getState().setPayer(na),y();},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)]",ce),children:[jsxs("span",{className:"novapay:font-semibold",children:[We.symbol," \xB7 ",ve(We.chainId)]}),jsx("span",{className:cn$1($,"novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.youHave,{amount:`${pe(String(Va),We.decimals,o)} ${We.symbol}`})})]},We.id))]}),e.merchant.fundingUrl&&jsxs("span",{children:[c(n.pay.topUp,{symbol:d.instructions.symbol})," ",jsxs("a",{href:e.merchant.fundingUrl,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",ce),children:[c(n.pay.getToken,{symbol:d.instructions.symbol})," \u2197"]})]})]}),jsxs(xe,{children:[Yn!==null&&jsx(H,{name:n.pay.rate,children:c(n.pay.rateValue,{symbol:d.instructions.symbol,price:um(Yn,o),currency:e.invoice.currency})}),jsx(H,{name:n.pay.networkFee,children:jsxs("span",{className:"novapay:inline-flex novapay:flex-col novapay:items-end novapay:gap-0.5",children:[_!=="transfer"?jsx("span",{className:"novapay:text-[var(--tuwa-success-text)]",children:c(n.pay.merchantPaysGas,{merchant:F})}):Zn?c(n.pay.gasEstimate,{amount:`${Zn} ${D?.symbol}`}):n.pay.gasFromWallet,d.gasless&&jsx(ht,{onClick:()=>L(!b),children:b?c(n.pay.payGasless,{merchant:F}):n.pay.payWithGas})]})}),jsxs(H,{name:n.pay.to,children:[jsx(He,{hash:d.instructions.to,chainId:k}),jsx("span",{className:"novapay:font-sans novapay:text-[var(--tuwa-text-secondary)]",children:F})]})]}),Bt&&!Be&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.payerProof.payNote}),Pn&&jsx(Q,{children:Pn}),Nn&&jsx(Q,{children:Nn}),!E.problem&&jsx(ya,{error:Ot}),Se&&jsx(Q,{children:n.pay.connectUnavailable})]}),jsxs(Z,{children:[jsx(X,{busy:Jn,disabled:Ee.disabled,onClick:Ee.run,children:Ee.label}),jsx(ae,{disabled:Qe,onClick:l,children:ut?n.pay.backFromRest:n.pay.back}),jsx($e,{children:dm(c(n.pay.disclaimer,{merchant:F}),...Nr(e)?[c(n.pay.disclaimerScreening,{merchant:F})]:[])})]})]}),mt==="proof"&&jsx(qn,{kind:"proof",walletName:tt?.name??"",walletId:tt?.walletId??"",walletIcon:tt?.icon,amount:Me,merchant:F,network:U,to:shortAddress(d.instructions.to),priceTime:null,text:c(Ta(s)?n.payerProof.promptPasskey:n.payerProof.promptText,ta),details:[...C.request?[{name:n.payerProof.site,value:C.request.domain}]:[],{name:n.payerProof.invoice,value:ea},{name:n.payerProof.merchant,value:F}],hint:C.request?c(n.payerProof.signInRequest,{wallet:tt?.name??"",site:C.request.domain}):void 0,onRetry:()=>{C.confirm();},onCancel:C.dismiss,stepHeight:ke}),mt&&mt!=="proof"&&jsx(qn,{kind:mt,walletName:tt?.name??"",walletId:tt?.walletId??"",walletIcon:tt?.icon,amount:Me,merchant:F,network:U,to:shortAddress(d.instructions.to),priceTime:Be?null:st(De),onRetry:_==="relay"?()=>{E.pay();}:void 0,onCancel:C.step==="switching"?C.dismiss:E.dismiss,stepHeight:ke})]})}var Io=4;function ac(e){let{size:t,data:a}=encode(e,{ecc:"M",border:0}),n="";return a.forEach((o,r)=>o.forEach((s,i)=>{s&&(n+=`M${i+Io} ${r+Io}h1v1h-1z`);})),{size:t+Io*2,path:n}}function Lo({value:e,label:t,className:a}){let n=I(),o=cn$1(a,Y(n,"qrCode")),{size:r,path:s}=useMemo(()=>ac(e),[e]),i=n.customization.components?.QrCode;return i?jsx(i,{value:e,label:t,className:o}):jsxs("svg",{role:"img","aria-label":t,viewBox:`0 0 ${r} ${r}`,shapeRendering:"crispEdges",className:cn$1("novapay:block novapay:rounded-[var(--tuwa-rounded-corners)]",o),children:[jsx("rect",{width:r,height:r,fill:"#ffffff"}),jsx("path",{d:s,fill:"#111827"})]})}function gm({payUrl:e}){let{labels:t,backToMethods:a,display:n}=I();return jsxs(Fragment$1,{children:[jsx(de,{title:t.qr.handoffTitle,subtitle:t.qr.handoffHint,children:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:items-center novapay:gap-3 novapay:py-2",children:[jsx(Lo,{value:e,label:t.qr.handoffCode,className:cn$1("novapay:h-48 novapay:w-48",n==="page"&&"novapay-page-qr-handoff")}),jsx(Mn,{text:e,label:t.qr.copyLink,copiedLabel:t.pay.copied,children:t.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:t.qr.handoffNote})]})}),jsx(Z,{children:jsx(ae,{onClick:a,children:t.qr.back})})]})}function rc(){let e=I(),{checkout:t,state:a,store:n,labels:o,locale:r,now:s,payUrl:i,backToMethods:c$1}=e,l=a.quote;if(!t)return null;if(!l||l.instructions.family!=="solana")return i?jsx(gm,{payUrl:i}):null;let p=xn(a);if(p.status!=="verified"&&a.phase!=="submitting")return jsx(La,{payee:p});let{instructions:m}=l,y=ve(he(m)),f=`${pe(l.amountToSend,l.decimals,r)} ${m.symbol}`,v=l.expiresAt?Date.parse(l.expiresAt)-s:Number.POSITIVE_INFINITY,d=v<=0,R=a.phase==="quoting",h=(a.invoiceStatus??t.invoice.status)==="underpaid",x=h?rn(l,s,o,t.merchant.name,r):null,g=h?t.invoice.originWallet:null,k=g?c(o.qr.restHint,{wallet:shortAddress(Et(g))}):o.qr.solanaHint;return jsxs(Fragment$1,{children:[jsxs(de,{title:o.qr.solanaTitle,subtitle:k,children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:items-center novapay:gap-4 novapay:@min-[440px]:flex-row novapay:@min-[440px]:items-start",children:[jsx(Lo,{value:m.solanaPayUrl,label:c(o.qr.solanaCode,{amount:f}),className:cn$1("novapay:h-44 novapay:w-44 novapay:shrink-0",e.display==="page"&&"novapay-page-qr",d&&"novapay:opacity-30")}),jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-2 novapay:self-stretch novapay:text-xs novapay:@min-[440px]:self-auto",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:o.qr.scanStep}),jsx("li",{children:o.qr.approveStep})]}),h&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:o.pay.youSendRest}),jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:gap-2",children:[jsx("span",{className:cn$1($,"novapay:text-2xl novapay:font-bold"),children:pe(l.amountToSend,l.decimals,r)}),jsx(Mn,{text:xa(l.amountToSend,l.decimals),label:o.pay.copyAmount,copiedLabel:o.pay.copied})]}),jsxs("div",{"data-qr-line":true,className:cn$1($,"novapay:flex novapay:flex-wrap novapay:items-center novapay:gap-x-1 novapay:gap-y-0.5 novapay:text-[var(--tuwa-text-secondary)]"),children:[jsxs("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:[m.symbol," \xB7"]}),jsxs("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:[y," \xB7"]}),jsx("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:jsx(He,{hash:m.to,chainId:he(m)})})]}),!d&&jsxs(Fragment$1,{children:[jsxs("span",{role:"status",className:"novapay:flex novapay:items-center novapay:gap-1.5",children:[jsx(QuasarLoader,{size:14,accent:"var(--tuwa-pending-icon)"}),o.qr.waiting]}),jsx("span",{role:"timer","aria-live":"off",className:"novapay:text-[var(--tuwa-text-secondary)]",children:c(x?o.pay.restTimeLeft:o.pay.priceLocked,{time:st(v)})})]})]})]}),d&&jsx(Q,{children:o.pay.priceExpired}),x&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:x}),jsxs("p",{className:cn$1(ia,"novapay:m-0 novapay:flex novapay:gap-2 novapay:px-3 novapay:py-2 novapay:text-xs"),children:[jsx(yt,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),o.qr.exchangeWarning]})]}),jsxs(Z,{children:[d?jsx(X,{busy:R,onClick:()=>{n.getState().requestQuote();},children:h?o.outcome.payRest:o.pay.newPrice}):jsx("a",{href:m.solanaPayUrl,className:cn$1(Tt,Y(e,"primaryButton")),children:o.qr.openInWallet}),jsx(ae,{onClick:c$1,children:h?o.pay.backFromRest:o.qr.back})]})]})}function _o(e){switch(e){case "confirm":return "pending";case "unconfirmed":case "underpaid":return "warning";case "paid":return "success";case "failed":case "blocked":case "error":return "error";case "needs_review":case "refunded":case "expired":case "cancelled":case "replaced":return "neutral";default:return null}}function Rm(){let{labels:e}=I();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(QuasarLoader,{size:48}),e.common.loading]})}function Im(){let{labels:e,state:t,store:a}=I(),n=t.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(yt,{"aria-hidden":true,className:"novapay:h-7 novapay:w-7 novapay:text-[var(--tuwa-error-icon)]"}),jsx("h2",{...Nt,className:at,children:e.error.title}),jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-[13px] novapay:text-[var(--tuwa-text-secondary)]",children:n?e.error.notFound:e.error.generic}),!n&&jsx(ae,{onClick:()=>{a.getState().load();},className:"novapay:w-auto novapay:px-6",children:e.common.retry})]})}var Em=new Set(["paid","partially_refunded","refunded"]);function ic(){let{screen:e,customization:t}=I(),a=t.components?.screens?.[e];return a?jsx(a,{screen:e}):e==="loading"?jsx(Rm,{}):e==="error"?jsx(Im,{}):e==="buyer"?jsx(Zr,{}):e==="method"?jsx(li,{}):e==="confirmWallet"?jsx(zs,{}):e==="pay"?jsx(nc,{}):e==="qr"?jsx(rc,{}):e==="confirm"?jsx(Ds,{}):e==="failed"?jsx(ti,{}):e==="paid"?jsx(vi,{}):jsx(Xs,{kind:e})}function Lm({className:e,withDetails:t,leave:a}){let n=I(),{checkout:o,locale:r,labels:s,now:i,customization:c$1,display:l}=n,{Header:p=ys,Summary:m=cs,CompactSummary:y=ls}=c$1.components??{},f=c$1.config?.deadlineAnnouncements,{screen:v,state:d}=n,R=useRef(null),h=(v==="pay"||v==="qr"&&d.quote?.instructions.family==="solana")&&d.phase!=="submitting"&&!!d.quote&&xn(d).status==="checking",x=useRef(v);useEffect(()=>{if(h)return;let E=x.current;x.current=v;let C=R.current;if(!C||E===v||E==="loading")return;let ie=C.ownerDocument.activeElement;if(ie&&ie!==C.ownerDocument.body&&!C.contains(ie))return;let P=C.querySelector("[data-novapay-scroll] [data-novapay-heading]");if(l!=="page")return P?.focus();C.getBoundingClientRect().top<0&&C.scrollIntoView({block:"start"}),P?.focus({preventScroll:true});},[v,l,h]);let[g,k]=useState(""),N=useRef(null),b=o?.invoice.dueAt?Date.parse(o.invoice.dueAt):null,L=o?Ln(o.invoice.status,v,o.invoice.restPayable)==="paying":false;useEffect(()=>{if(b===null)return;let E=b-i,C=kr(N.current,E,f);N.current=E,C!==null&&L&&k(C===1?s.summary.oneMinuteLeft:c(s.summary.minutesLeft,{minutes:C}));},[b,i,s,f,L]);let B=l==="page",_=er[B?"page":"default"],w=_o(v),D=c$1.components?.StatusEdge??StatusEdge;return jsxs("div",{ref:R,lang:r,className:cn$1(_.frame,ca(l).frame,e),children:[o&&jsx("aside",{inert:!!a,className:cn$1(_.aside,Y(n,"summary")),children:jsx(m,{})}),jsxs("div",{inert:!!a,className:cn$1("novapay:relative",_.main),children:[w&&jsx(D,{tone:w,className:cn$1("novapay:z-20",Y(n,"statusEdge",{tone:w}))}),jsxs(ji,{active:!!w&&!B&&!c$1.config?.animation?.disabled,children:[jsx(p,{withDetails:t}),jsxs("div",{className:"novapay:sm:hidden",children:[o&&jsx(y,{className:Y(n,"compactSummary")}),jsx(fs,{withDetails:t})]}),jsx("div",{"data-novapay-scroll":"",className:cn$1(_.area,Y(n,"body")),children:B?jsx("div",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",!c$1.config?.animation?.disabled&&"novapay-page-fade"),children:jsx(ic,{})},w?"status":v):jsx(ic,{})})]})]}),jsx("div",{role:"status","aria-live":"polite",className:"novapay:sr-only",children:g}),a&&jsx(oi,{onStay:a.onStay,onLeave:a.onLeave})]})}function Gw({token:e,display:t="modal",open:a=true,onOpenChange:n,onClose:o,baseUrl:r,api:s,EventSource:i,pollMs:c$1,payUrl:l,payoutAddresses:p,onConnectWallet:m,onPaid:y,autoReturnSeconds:f$1,onContact:v,locale:d,className:R,customization:h}){let x=pt(),[g$1,k]=useState({from:e,token:e}),N=g$1.from===e?g$1.token:e,[b,L]=useState(t!=="modal"||a);!b&&(t!=="modal"||a)&&L(true);let B=useRef(x.adapters);useEffect(()=>{B.current=x.adapters;},[x.adapters]);let _=useCallback(te=>Ei(B.current,te),[]),w=bi({token:N,baseUrl:r??x.baseUrl,api:s,EventSource:i,pollMs:c$1,enabled:b,payee:{verify:_,addresses:p}}),D=wi(w,te=>te),E=D.checkout,C=f(d),[ie,P]=useState(null),W=Ar({picked:ie,page:C,invoice:D.locale??E?.invoice.locale}),z=zn(W),Se=!!E&&b&&Dr(D.phase,f$1,g(W)),we=Ni(1e3,Se)-(D.clockSkewMs??0),re=_a(),ke=Da(m),A=x.adapters,[F,U]=useState("wallet"),[ne,le]=useState(false),[se,Me]=useState(null);E&&se?.store!==w&&Me({store:w,paid:Em.has(E.invoice.status)});let[De,Be]=useState(false),[Yt,Qe]=useState(false),[Yn,ut]=useState(N);Yn!==N&&(ut(N),le(false),U("wallet"),Qe(false));let Cn=D.payerProof==="confirmed"&&!!D.error,Zn=D.error?.code==="payer_mismatch";Yt&&(D.phase==="awaitingPayment"||Cn||Zn)&&Qe(false);let Mt=(D.invoiceStatus??E?.invoice.status)==="underpaid"?E?.invoice.originWallet??null:null,Zt=te=>!Mt||sn(te,Mt),Sn=E?.methods.find(te=>te.id===D.methodId),kt=Sn?Ue(re,Sn):null,Jn=Sr({open:Yt,storePayer:D.payer,payer:kt,paysRest:!kt||Zt(kt)});Jn==="leave"&&Qe(false);let Ve=useRef(null),[Jt,Ka]=useState(false);!Jt&&E&&g(W)&&Ka(true);let Bt={payWith:F,handoff:ne,confirmWallet:Yt,labelsReady:Jt||!E},Pn=eo(D,Bt),[Ot,Nn]=useState(null),[Xn,Tn]=useState(null);Pn==="confirm"?Ot!==w&&Nn(w):Ot===w&&(Nn(null),D.error?.code==="payment_failed"&&Tn(D.error));let Ee=Xn!==null&&D.error===Xn?eo(D,{...Bt,afterFailure:true}):Pn,mt=async()=>{await Hs(w,Qe);},ea=Ci(w),tt=Ki({store:w,screen:Ee}),[ta,We]=useState(null),Va=$i({store:w,state:D,walletTxKey:ta?.store===w?ta.txKey:null});di(D.phase,E?.invoice,y,se?.store===w&&se.paid),xi({state:D,screen:Ee,now:we,locale:E||C?W:null,handlers:h?.handlers});let na=te=>A?.find(je=>je.family===te),Oo=Ui({store:w,adapterFor:na,pulsar:x.pulsar,labels:z,locale:W}),Sc=useCallback(te=>{We({store:w,txKey:te.txKey}),Oo(te);},[w,Oo]),Pc=useEffectEvent(()=>{if(!E)return;let{quote:te,phase:je}=w.getState();if(re&&Ve.current){let oa=E.methods.find(Ac=>Ac.id===Ve.current),ja=oa?Ue(re,oa):null;if(!ja)return;Ve.current=null,w.getState().setPayer(ja),Zt(ja)&&mt();return}if(je==="selectMethod"||je==="underpaid"||je==="blocked"){if(D.payer===null||kt===D.payer)return;w.getState().setPayer(kt),Jn==="follow"&&mt();return}if(!re)return;let Rn=E.methods.find(oa=>oa.id===te?.methodId),aa=Rn?Ue(re,Rn):null,Uo=Cr({phase:je,quotePayer:te?.payer,payer:aa});if(Uo==="release")return w.getState().releaseQuote();Uo==="keep"||!aa||(w.getState().setPayer(aa),Zt(aa)&&mt());}),Nc=D.quote?.payer,Tc=!!E;useEffect(()=>Pc(),[re?.address,re?.chainId,re?.connectorType,D.phase,Nc,Tc]),useEffect(()=>{ke.connecting||(Ve.current=null);},[ke.connecting]);let[Do,Rc]=useState(false);Ee==="buyer"&&!Do&&Rc(true);let Ga=useMemo(()=>t==="modal"?()=>{n?.(false),o?.();}:o,[t,n,o]),Ic=Ga&&(()=>ao(w.getState().phase,w.getState().error,w.getState().invoiceStatus)&&!Oa(w)?Be(true):Ga()),Ec=De?{onStay:()=>Be(false),onLeave:()=>{Be(false),w.getState().releaseQuote(),Ga?.();}}:null,Wo=h??{},Lc={store:w,state:D,checkout:E,screen:Ee,locale:W,labels:z,setLocale:async te=>{let je=ie;P({locale:te,page:C}),await w.getState().setLocale(te)||P(je);},now:we,handedOverAt:ea,qrShown:tt,paymentSent:Va||Oa(w),close:Ic,wallet:re,payWith:F,setPayWith:U,payUrl:Li(l,p),connectWallet:te=>{let je=Ye(te);Ve.current=te.id;let Rn=je!==null&&ke.connect(je);return Rn||(Ve.current=null),Rn},connectFamily:te=>ke.connect(te),openedPaid:se?.store===w&&se.paid,adapterFor:na,handoff:ne,setHandoff:le,backToMethods:()=>{le(false),Qe(false),w.getState().releaseQuote();},payAfterFailure:()=>{Tn(null),w.getState().clearError();},confirmWallet:Yt,setConfirmWallet:Qe,lockPrice:mt,onPaymentSent:Sc,openInvoice:te=>k({from:e,token:te}),onContact:v,autoReturnSeconds:f$1??(t==="modal"?0:5),display:t,customization:Wo},za=cn$1(R,Y({customization:Wo,screen:Ee,state:D,checkout:E},"container")),Qa=jsx(Go,{value:Lc,children:jsx(MotionConfig,{reducedMotion:h?.config?.animation?.disabled?"always":"user",children:jsx(Lm,{withDetails:Do,leave:Ec,className:t==="modal"?za:void 0})})});if(t==="modal")return jsx(Dialog,{open:a,onOpenChange:te=>{if(!te&&De)return Be(false);if(!te&&ao(w.getState().phase,w.getState().error,w.getState().invoiceStatus)&&!Oa(w))return Be(true);n?.(te),te||o?.();},children:jsxs(DialogContent,{className:"novapay:w-full novapay:sm:w-auto",animateHeight:_o(Ee)===null,children:[jsx(DialogTitle,{className:"novapay:sr-only",children:c(z.common.dialogTitle,{merchant:E?.merchant.name??""})}),Qa]})});let qo=c(z.common.dialogTitle,{merchant:E?.merchant.name??""});return t==="page"?jsx(Am,{label:qo,className:za,children:Qa}):jsx("section",{"aria-label":qo,className:cn$1("novapay:overflow-hidden novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)]",ca(t).section,za),children:Qa})}function Am({label:e,className:t,children:a}){return jsx("div",{className:"novapay-page",children:jsx("section",{"aria-label":e,className:cn$1(ca("page").section,"novapay-page-block",t),children:a})})}function cc(e){if(!e.to)return null;let t=parseCaip19AssetId(e.assetId),a={to:e.to,token:!t||t.assetNamespace==="slip44"?"native":t.assetReference,amount:e.amount,decimals:e.decimals,symbol:e.symbol},n=Rt(e.chainId);if(n==="solana")return {family:n,chainId:e.chainId,...a,reference:"",solanaPayUrl:""};let o=n==="eip155"?toEvmChainId(e.chainId):void 0;return o===void 0?null:{family:"eip155",chainId:o,...a}}function pc(e){let t=b$1(e);return t==="switchFailed"?"wrongNetwork":t==="notAuthorized"||t==="alreadyPending"||t==="sentUnconfirmed"?"failed":t}var Mo=new WeakMap,wn=new WeakMap;function uc({store:e,invoiceId:t,invoice:a,params:n,open:o,labels:r,locale:s,onConnectWallet:i}){let c$1=useStore(e),{adapters:l,pulsar:p}=pt(),m=_a(),y=Da(i),[f,v]=useState("idle"),[d,R]=useState(null),[,h]=useState(0),x=wn.has(e),g=useRef(0),k=useRef(o),N=c$1.sentTransaction?.txHash??c$1.refund?.txHash??null,b=c$1.instructions?cc(c$1.instructions):null,L=b?.family??null,B=b?he(b):c$1.instructions?.chainId??null,_=l?.find(U=>U.family===L),w=m&&m.family===L?m:null,D=B?ve(B):"",E=d&&d.account===w?.address?d.problem:null,C=U=>R(U?{problem:U,account:w?.address}:null),ie=!!(w&&L==="eip155"&&B&&w.chainId!==B),P=c$1.instructions,W=P?`${pe(P.amount,P.decimals,s)} ${P.symbol}`:"",z=Wa(b&&w&&_?`balance|${B}|${w.address}|${b.token}`:null,()=>_.getBalance({chainId:B,account:w.address,token:b.token}),c$1.refund?.id),Se=gn(b&&w&&_?.estimateFee?`fee|${B}|${w.address}|${b.token}`:null,()=>_.estimateFee({instructions:b,account:w.address}));useEffect(()=>{!n||Mo.get(e)===t||e.getState().phase!=="idle"||(Mo.set(e,t),e.getState().start(t,n));},[n,e,t]),useEffect(()=>{o&&!k.current&&!n&&e.getState().phase==="confirmed"&&e.getState().reset(),k.current=o;},[o,n,e]),useEffect(()=>(e.getState().keepFollowing(),()=>e.getState().stopFollowing()),[e]),useEffect(()=>{let U=true;return wn.get(e)?.settled.then(()=>{U&&h(ne=>ne+1);}),()=>{U=false;}},[e]);let Ne=async(U,ne,le)=>{if(!p||!_?.pulsarTransaction||!c$1.refund)return;let se={invoice:a??t,amount:W};try{await p.injectExternalPendingTxs([_.pulsarTransaction({txKey:U,instructions:le,account:ne.address,connectorType:ne.connectorType,title:c(r.refund.txTitle,se),description:c(c$1.refund.unmatchedTransfer?r.refund.txDescriptionSender:r.refund.txDescription,se),payload:{quasarRefund:c$1.refund.id}})]);}catch{}},we=async()=>{if(C(null),!(!ie||!_?.switchChain))try{v("switching"),await _.switchChain(B);}catch(U){C(pc(U));}finally{v("idle");}},re=async()=>{if(C(null),!b)return C("noRecipient");if(!w||!_)return C("unsupported");if(c$1.sentTransaction){await e.getState().submit(c$1.sentTransaction);return}let U=BigInt(b.amount)+(b.token==="native"&&Se?Se.amount:0n);if(typeof z=="bigint"&&z<U)return C("notEnough");if(L&&b.to&&isSameAddress(L,w.address,b.to))return C("fromBuyer");if(!await e.getState().recheck()){let se=e.getState(),Me=se.error?.code==="refund_repriced";se.phase==="awaitingTransfer"&&!se.sentTransaction&&!Me&&C("unreachable");return}let ne=++g.current,le=()=>g.current===ne;try{ie&&_.switchChain&&(v("switching"),await _.switchChain(B)),le()&&v("wallet");let se=await _.sendTransfer({instructions:b,account:w.address,connection:w.connection});le()?v("idle"):R(null),Ne(se,w,b),await e.getState().submit({txHash:se,from:w.address});}catch(se){le()?(v("idle"),C(pc(se))):R(null);}},ke=async()=>{if(wn.has(e))return;let U,ne={settled:new Promise(Me=>U=Me)},le=()=>{wn.get(e)===ne&&wn.delete(e),U(),h(Me=>Me+1);},se=setTimeout(le,6e5);wn.set(e,ne),h(Me=>Me+1);try{await re();}finally{clearTimeout(se),le();}},A=f!=="idle"?f:w?"confirm":"connect";return {step:c$1.phase==="idle"?n&&!c$1.error&&Mo.get(e)!==t?"requesting":"amount":c$1.phase==="awaitingTransfer"?A:c$1.phase,phase:c$1.phase,refund:c$1.refund,error:c$1.error,transfer:b,chainId:B,network:D,amount:W,wallet:w,wrongNetwork:ie,balance:z,fee:Se,problem:E??(c$1.instructions&&!b?"noRecipient":null),txKey:N,transactionUrl:U=>B?_?.explorerUrl?.({chainId:B,txKey:U}):void 0,addressUrl:U=>B?_?.explorerAddressUrl?.({chainId:B,address:U}):void 0,canConnect:y.canConnect,connecting:y.connecting,preview:async U=>{let ne=await e.getState().preview(t,U);return ne||(e.getState().error?"refused":null)},start:async U=>{C(null),await e.getState().start(t,U);},connect:()=>{L&&y.connect(L);},switchNetwork:we,send:ke,dismiss:()=>{g.current++,v("idle"),C("stillInWallet");},sending:x}}function Sk({label:e,className:t,disabled:a,...n}){let[o,r]=useState(false),s=zn(n.locale??"en");return jsxs(Fragment$1,{children:[jsx("button",{type:"button",disabled:a,onClick:()=>r(true),className:cn$1(Tt,"novapay:w-auto novapay:px-4",t),children:e??s.refund.button}),jsx($m,{...n,open:o,onOpenChange:r})]})}function $m({open:e,onOpenChange:t,locale:a="en",onRefunded:n,...o}){let r=zn(a),s=uc({store:o.store,invoiceId:o.invoiceId,invoice:o.invoice,params:e?o.params:void 0,open:e,labels:r,locale:a,onConnectWallet:o.onConnectWallet}),i=useEffectEvent(p=>n?.(p)),c$1=s.phase==="confirmed"?s.refund:null;useEffect(()=>{c$1&&i(c$1);},[c$1]);let l=o.invoice?c(r.refund.title,{invoice:o.invoice}):r.refund.button;return jsx(Dialog,{open:e,onOpenChange:t,children:jsxs(DialogContent,{className:"novapay:w-full novapay:sm:w-[440px]",children:[jsxs("div",{className:"novapay:flex novapay:items-center novapay:justify-between novapay:gap-3 novapay:border-b novapay:border-[var(--tuwa-border-primary)] novapay:px-5 novapay:py-3",children:[jsx(DialogTitle,{className:cn$1($,"novapay:m-0 novapay:truncate novapay:text-sm novapay:font-bold"),children:l}),jsx("button",{type:"button","aria-label":r.refund.close,onClick:()=>t(false),className:Pt,children:jsx(CloseIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"})})]}),jsx(Km,{flow:s,labels:r,locale:a,close:()=>t(false),...o})]})})}function Km({flow:e,labels:t,locale:a,close:n,currency:o="USD",refundable:r,details:s,onRecord:i}){let c$1=t.refund,l={network:e.network,symbol:e.transfer?.symbol??e.refund?.assetId??"",amount:e.amount,wallet:e.wallet?.name??""},p=e.refund?.txHash??e.txKey,m=i&&jsxs(Fragment$1,{children:[jsx(ae,{onClick:i,children:c$1.record}),jsx($e,{children:c$1.recordHint})]});switch(e.step){case "amount":return jsx(Jm,{flow:e,labels:t,locale:a,currency:o,refundable:r});case "requesting":case "submitting":return jsx(vc,{children:e.step==="requesting"?c$1.requesting:c$1.submitting});case "switching":case "wallet":return jsxs(Fragment$1,{children:[jsxs(vc,{walletId:e.wallet?.walletId,walletIcon:e.wallet?.icon,children:[jsx("strong",{className:cn$1($,"novapay:text-sm"),children:c(e.step==="switching"?c$1.switchTitle:c$1.walletTitle,l)}),e.step==="wallet"&&jsx("span",{children:c(c$1.walletText,l)})]}),jsx(Z,{children:jsx(ae,{onClick:e.dismiss,children:t.walletPrompt.cancel})})]});case "connect":return jsxs(Fragment$1,{children:[jsxs(de,{title:c$1.connectTitle,subtitle:c(c$1.connectText,l),children:[e.problem==="noRecipient"&&jsx(Q,{children:c$1.noRecipient}),!e.canConnect&&jsx(Q,{children:c$1.connectUnavailable})]}),jsxs(Z,{children:[e.canConnect&&e.problem!=="noRecipient"&&jsx(X,{busy:e.connecting,onClick:e.connect,children:c$1.connect}),m]})]});case "confirm":return jsx(Xm,{flow:e,labels:t,locale:a,values:l,details:s?.confirm,recordAction:m});case "confirming":return jsxs(Fragment$1,{children:[jsxs(de,{title:c$1.onItsWay,children:[jsxs(xe,{children:[jsx(H,{name:c$1.status,children:c$1.pending}),p&&jsx(H,{name:c$1.transaction,children:jsx(He,{hash:p,explorerUrl:e.transactionUrl(p),labels:t})}),jsx(H,{name:c$1.network,children:c(c$1.waiting,l)})]}),fc(e.refund)&&jsx($e,{children:c$1.slowNote})]}),jsxs(Z,{children:[jsx(ae,{onClick:n,children:c$1.close}),fc(e.refund)?m:jsx($e,{children:c$1.canClose})]})]});case "confirmed":return jsxs(Fragment$1,{children:[jsx(de,{title:c$1.refunded,children:jsxs(xe,{children:[e.refund?.creditNoteNumber&&jsx(H,{name:c$1.creditNote,children:e.refund.creditNoteNumber}),p&&jsx(H,{name:c$1.transaction,children:jsx(He,{hash:p,explorerUrl:e.transactionUrl(p),labels:t})}),s?.done]})}),jsx(Z,{children:jsx(X,{onClick:n,children:c$1.done})})]});case "failed":return jsx(Zm,{flow:e,labels:t,locale:a,values:l,recordAction:m,close:n})}}var Vm={amount_short:"failedShort",over_limit:"failedByHand",tx_of_another_refund:"failedByHand",refund_from_buyer:"failedFromBuyer",transaction_failed:"failedNotFound",dropped:"failedDropped",too_early:"failedTooEarly",no_matching_transfer:"failedNoTransfer",withdrawn:"failedWithdrawn",cancelled:"failedCancelling",cancelled_final:"failedCancelled",resend_confirmed:"failedResendConfirmed"},dc=(e,t,a)=>{let n=e?.failureReason?Vm[e.failureReason]:void 0;return n?t[n]:c(t.failedText,a)},Gm={withdrawn:"failedWithdrawnTitle",cancelled:"failedCancelledTitle",cancelled_final:"failedCancelledTitle"},yc=(e,t)=>t[e?.failureReason&&Gm[e.failureReason]||"failedTitle"],zm={refund_repriced:"movedTitle",request_failed:"unreachable",amount_exceeds_refundable:"refusedAmount",invoice_not_refundable:"refusedNotRefundable",payment_unknown:"refusedNotRefundable",unmatched_transfer_not_refundable:"refusedNotRefundable",review_refund_must_be_whole:"refusedWhole",sender_blocked:"refusedBlocked",refund_not_waiting:"refusedNotWaiting",refund_may_have_landed:"refusedMayHaveLanded",refund_from_buyer:"failedFromBuyer",method_not_priced:"refusedPrice",price_no_rpc:"refusedPrice",price_unavailable:"refusedPrice",mainnet_disabled_on_node:"refusedTestOnly"},Qm=600*1e3,fc=e=>{let t=e?.updatedAt??e?.createdAt;return !!t&&Date.now()-Date.parse(t)>Qm},Ha=(e,t)=>e.text??t[zm[e.code]??"refusedOther"],jm=e=>e?.failureReason==="over_limit"||e?.failureReason==="tx_of_another_refund",Ym=e=>{let t=e.mode==="fiat_value"||e.failureReason==="amount_short";return {mode:t?"fiat_value":e.mode,...t&&{amount:e.amount},...e.reason&&{reason:e.reason}}};function gc(e){let[t,a]=useState(false),[n,o]=useState(null),r=useRef(false);return useEffect(()=>(r.current=false,()=>{r.current=true;}),[]),{ask:async(i,c)=>{if(i?.mode==="fiat_value"){a(true);let l=await e.preview(i);if(r.current||(a(false),l==="refused"))return;if(l&&Or(c?{cryptoAmount:l.cryptoAmount,atPaymentRate:c.cryptoAmount}:l))return o({preview:l,request:i})}o(null),e.start(i);},checking:t,moved:n,back:()=>o(null)}}function bc({preview:e,request:t},a,n,o,r,s){let i=o.refund,c$1=l=>`${pe(l,e.decimals,r)} ${e.symbol}`;return jsxs(Fragment$1,{children:[jsxs(de,{title:i.movedTitle,children:[jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(i.movedText,{symbol:e.symbol})}),jsxs(xe,{children:[jsx(H,{name:i.movedSend,children:c$1(e.cryptoAmount)}),e.atPaymentRate&&jsx(H,{name:i.movedAtPayment,children:c$1(e.atPaymentRate)}),e.received&&jsx(H,{name:i.movedReceived,children:c$1(e.received)})]}),s&&e.exactPossible&&jsx($e,{children:c(i.movedExact,{exact:i.modeExact})}),n.error&&jsx(Q,{children:Ha(n.error,i)})]}),jsxs(Z,{children:[jsx(X,{busy:a.checking,onClick:()=>{a.ask(t,e);},children:i.movedContinue}),jsx(ae,{disabled:a.checking,onClick:a.back,children:i.movedBack})]})]})}function Zm({flow:e,labels:t,locale:a,values:n,recordAction:o,close:r}){let s=t.refund,i=gc(e);return e.refund?.unmatchedTransfer?jsxs(Fragment$1,{children:[jsxs(de,{title:yc(e.refund,s),children:[jsx(Q,{children:dc(e.refund,s,n)}),jsx($e,{children:s.failedUnmatchedNote})]}),jsx(Z,{children:jsx(X,{onClick:r,children:s.close})})]}):i.moved?bc(i.moved,i,e,t,a,false):jsxs(Fragment$1,{children:[jsxs(de,{title:yc(e.refund,s),children:[jsx(Q,{children:dc(e.refund,s,n)}),e.error&&jsx(Q,{children:Ha(e.error,s)})]}),jsxs(Z,{children:[jm(e.refund)?jsx(X,{onClick:r,children:s.close}):jsx(X,{busy:i.checking,onClick:()=>e.refund&&void i.ask(Ym(e.refund)),children:s.sendRefund}),o]})]})}function vc({walletId:e,walletIcon:t,children:a}){return jsxs("section",{role:"status",className:"novapay:flex novapay:min-h-56 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:px-5 novapay:py-6 novapay:text-center",children:[jsx(ma,{walletId:e,walletIcon:t}),a]})}function Jm({flow:e,labels:t,locale:a,currency:n,refundable:o}){let r=t.refund,s=useId(),i=useId(),[c$1,l]=useState("fiat_value"),[p,m]=useState(""),[y,f]=useState(""),v=gc(e),d=c$1==="exact_received"||p.trim()===""||/^\d{1,12}(\.\d{1,2})?$/.test(p.trim()),R=[{key:"fiat_value",title:r.modeFiat,hint:c(r.modeFiatText,{currency:n})},{key:"exact_received",title:r.modeExact,hint:r.modeExactText}],h="novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-sm novapay:text-[var(--tuwa-text-primary)]",x={mode:c$1,...c$1==="fiat_value"&&p.trim()&&{amount:p.trim()},...y.trim()&&{reason:y.trim()}};return v.moved?bc(v.moved,v,e,t,a,true):jsxs(Fragment$1,{children:[jsxs(de,{title:r.amountTitle,children:[jsxs("fieldset",{disabled:v.checking,className:"novapay:contents",children:[jsx(vn,{label:r.amountTitle,items:[...R],value:c$1,getKey:g=>g.key,onChange:g=>l(g),className:"novapay:flex novapay:flex-col novapay:gap-2",itemClassName:()=>"novapay:flex novapay:flex-col novapay:gap-0.5 novapay:px-3 novapay:py-2.5",children:g=>jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:text-sm novapay:font-semibold",children:g.title}),jsx("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:g.hint})]})}),c$1==="fiat_value"&&jsxs("label",{htmlFor:s,className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-xs",children:[jsxs("span",{children:[c(r.amount,{currency:n}),jsxs("span",{"aria-hidden":"true",className:"novapay:text-[var(--tuwa-error-text)]",children:[" ","*"]})]}),jsx("input",{id:s,required:true,inputMode:"decimal",value:p,placeholder:"0.00","aria-invalid":!d||void 0,onChange:g=>m(g.target.value.replace(",",".")),className:cn$1($,h)}),o&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:c(r.amountHint,{amount:o})})]}),jsxs("label",{htmlFor:i,className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-xs",children:[jsx("span",{children:r.reason}),jsx("input",{id:i,value:y,maxLength:500,onChange:g=>f(g.target.value),className:h})]})]}),e.error&&jsx(Q,{children:Ha(e.error,r)})]}),jsx(Z,{children:jsx(X,{busy:v.checking,disabled:!d,onClick:()=>{v.ask(x);},children:r.continue})})]})}function hc(e,t){return jsxs("span",{className:"novapay:flex novapay:flex-col novapay:items-end novapay:gap-1",children:[e,t&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:t})]})}function Xm({flow:e,labels:t,locale:a,values:n,details:o,recordAction:r}){let s=t.refund,i=e.transfer,c$1=typeof e.balance=="bigint"&&i?`${pe(e.balance.toString(),i.decimals,a)} ${i.symbol}`:null,l=e.fee?ha(e.fee.amount.toString(),e.fee.decimals,a):null,p=e.fee&&l?`${l} ${e.fee.symbol}`:null,m={notEnough:c(s.notEnough,{...n,address:e.wallet?shortAddress(e.wallet.address):"",balance:c$1??""}),declined:c(s.declined,n),unsupported:c(s.unsupported,n),wrongNetwork:c(s.wrongNetwork,n),failed:s.failed,noRecipient:s.noRecipient,fromBuyer:s.failedFromBuyer,stillInWallet:c(t.walletPrompt.stillWaiting,n),unreachable:s.unreachable},y=!!e.problem,f=!!e.txKey;return jsxs(Fragment$1,{children:[jsxs(de,{title:y?s.notSent:s.confirmTitle,children:[jsxs(xe,{children:[jsx(H,{name:s.send,children:n.amount}),jsx(H,{name:s.network,children:n.network}),i&&jsx(H,{name:s.to,children:hc(jsx(He,{hash:i.to,explorerUrl:e.addressUrl(i.to),labels:t}),e.refund?.unmatchedTransfer?s.theSender:s.thePayer)}),e.wallet&&jsx(H,{name:s.from,children:hc(jsx(He,{hash:e.wallet.address,explorerUrl:e.addressUrl(e.wallet.address),labels:t}),c$1&&c(s.balance,{amount:c$1}))}),p&&jsx(H,{name:s.networkFee,children:c(s.feeEstimate,{amount:p})}),o]}),e.problem&&jsx(Q,{children:m[e.problem]}),e.problem&&!["noRecipient","unreachable","stillInWallet"].includes(e.problem)&&jsx($e,{children:s.nothingSent}),f&&e.error&&jsx(Q,{children:s.notHandedOver}),!f&&e.error&&e.problem!=="unreachable"&&jsx(Q,{children:Ha(e.error,s)})]}),jsxs(Z,{children:[e.problem!=="noRecipient"&&(e.wrongNetwork&&!f?jsx(X,{onClick:()=>{e.switchNetwork();},children:jsx(ge,{label:s.switchTo,values:n})}):jsx(X,{busy:e.sending,onClick:()=>{e.send();},children:f?s.handOver:s.sendRefund})),(y||f)&&r,!y&&!f&&e.wallet&&jsx(ae,{onClick:e.connect,children:t.pay.changeWallet})]})]})}function nd(e){return e.appStore?e.novaConnect?"app":"appStore":e.ownConnection?"own":"none"}function $a(e){let t=useContext(SatelliteStoreContext),a=useContext(NovaConnectProviderContext);return nd({appStore:t!=null,novaConnect:a!==void 0,ownConnection:e})}function eC(){let e=pt(),t=$a(false);return e.connection??t}var od=()=>import('./OwnConnection-ET76SUMX.js').then(e=>({default:e.OwnConnection})),kc=lazy(od);var pd=()=>process.env.NODE_ENV==="development";function cC({baseUrl:e,labels:t,customization:a,adapters:n,pulsar:o,ownConnection:r,onConnectWallet:s,children:i}){let c=useContext(Gn),l=$a(!!r),[p]=useState(l),[m]=useState(r),y=p==="own"?r??m:void 0,f=(p==="app"||p==="appStore")&&c.connection!==void 0&&c.connection!=="none",v=y?y.adapters:n??(f?c.adapters:void 0),d=useMemo(()=>({baseUrl:e,labels:t,customization:a,adapters:v,pulsar:o,connection:p,onConnectWallet:s}),[e,t,a,v,o,p,s]),R=useRef(null),h=!!r,x=!!v;return useEffect(()=>{if(!pd())return;R.current??=new Set;let g=R.current,k=(N,b)=>{g.has(N)||(g.add(N),console.warn(`[NovaPaymentsProvider] ${b}`));};l!==p&&k("connection",`it keeps the wallet connection it chose on its first render ("${p}"), though the providers above now call for "${l}". Render it inside the app's SatelliteConnectProvider and NovaConnectProvider from the start.`),h&&p==="appStore"&&k("appStore","it is inside the app's SatelliteConnectProvider without NovaConnectProvider: it uses the app's wallet and never adds a second store, so `ownConnection` is not used. Connect wallets with `onConnectWallet`, or render it inside NovaConnectProvider."),h&&!x&&(p==="app"||p==="appStore")&&k("adapters","it uses the app's wallet connection, so the adapters of `ownConnection` are not used: pass `adapters` on the app's wagmi config to pay from the app's wallet.");},[l,p,h,x]),jsx(Gn.Provider,{value:d,children:y?jsx(Suspense,{fallback:null,children:jsx(kc,{own:y,children:i})}):i})}export{Jm as AmountStep,Zr as BuyerScreen,ra as CheckoutContext,Go as CheckoutContextProvider,Lm as CheckoutFrame,ys as CheckoutHeader,Am as CheckoutPageRoot,Xr as CheckoutStepper,cs as CheckoutSummary,ls as CompactSummary,Ds as ConfirmScreen,Xm as ConfirmStep,zs as ConfirmWalletScreen,vo as ContactLink,ll as DEADLINE_ANNOUNCEMENTS,os as DeadlineTimer,ba as Disclosure,ti as FailedScreen,Zm as FailedStep,oi as LeaveDialog,us as LocaleSwitcher,ga as MerchantBadge,li as MethodScreen,fs as MobileSteps,Gn as NovaPaymentsContext,cC as NovaPaymentsProvider,Ma as OPEN_REQUEST_MS,rs as OrderLines,jl as OrderTotal,Xs as OutcomeScreen,vi as PaidScreen,nc as PayScreen,La as PayeeScreen,Gw as PaymentCheckout,to as QUOTE_WARNING_MS,rc as QrScreen,Sk as RefundButton,$m as RefundDialog,Km as RefundSteps,ic as ScreenBody,ro as SellerDetailsContent,ss as SummaryFooter,qn as WalletPrompt,Et as addressOfWallet,$r as balanceShortfall,xa as baseUnitsToDecimal,Ya as buyerFields,jo as buyerIssues,hr as canPayWithQr,Y as checkoutClassName,eo as checkoutScreen,gr as checkoutSteps,Yo as cleanBuyer,vr as connectedWallet,_r as contactHref,Zo as countryOptions,kr as deadlineAnnouncement,Ln as deadlineState,la as failedPaymentTx,Rt as familyOf,st as formatCountdown,ha as formatFeeAmount,ye as formatFiat,pe as formatTokenAmount,wr as groupMethodsByToken,Li as handOffPayUrl,Oi as handOverPayment,he as instructionsChainId,pn as invoiceTotals,Dn as isConfirmationError,Ir as isFinalPaymentFailure,ft as isInvoicePaymentOnTheWay,qt as isInvoicePaymentUnresolved,vt as isMovedMoneyFailure,Er as isPaidElsewhere,yo as isPayerProofError,Oa as isPaymentAccepted,ot as isPaymentOnTheWay,Pr as isQuoteEnding,sn as isSameWallet,fc as isSlow,Ta as isSmartWallet,Ja as isWalletIconUrl,Ut as leftTheWalletText,Hs as lockPrice,Cr as lockedPriceOnWallet,pa as methodErrorText,Ye as methodFamily,xr as methodToken,Re as minorToDecimal,ao as needsLeaveConfirm,Us as needsPayerProof,Dr as needsTheClock,ve as networkName,br as paidSteps,_i as payInvoice,qr as payPath,xn as payeeStatus,Ii as payeeVerified,Ue as payerFor,Ra as payerProofErrorText,An as paymentFailedText,Xa as priceAdjustment,ac as qrPath,Ur as quoteAmounts,Hr as quoteRate,Br as receivedAmount,Or as refundRateMoved,cc as refundTransfer,Ha as refusalText,rn as restRateText,Nr as screensPayingWallets,Tr as sentBeforeDeadline,Ar as shownLocale,It as unconfirmedFollowUp,Lr as unconfirmedTxKey,Mr as underpaidRest,gn as useAsyncValue,yi as useAutoReturn,I as useCheckoutContext,xi as useCheckoutEvents,wi as useCheckoutState,bi as useCheckoutStore,_a as useConnectedWallet,pt as useNovaPayments,Ni as useNow,qe as useOptionalCheckoutContext,di as usePaidCallback,Pa as usePayerProof,Mi as usePayment,dn as usePaymentFacts,Ui as usePaymentHandOver,eC as usePaymentsConnection,zn as usePaymentsLabels,uc as useRefund,Wa as useRereadValue,Da as useWalletConnection,Ei as verifyPayeeWith,nl as walletLabel,Sr as walletOnConfirmStep};
1
+ import {c,b,e,h,g,i,j,f,d}from'./chunk-BZLZLS4M.js';import {b as b$1,a}from'./chunk-7HSDAUKN.js';export{a as PaymentWalletError,b as walletErrorKind}from'./chunk-7HSDAUKN.js';import {getChainName,cn as cn$1,DrawnCheck,CloseIcon,MorphText,WalletIcon,Dialog,DialogContent,DialogTitle,TokenIcon,QuasarLoader,StatusEdge,NetworkIcon,NovaSetIcon,CopyIcon,useNovaIcons,flyFrom,pixelsOf,DrawnCross,pixelFlight}from'@tuwaio/nova-core';import {createContext,lazy,useContext,useState,useId,useMemo,Fragment,useRef,useEffect,useEffectEvent,useCallback,Suspense,useLayoutEffect}from'react';import {LockClosedIcon,FingerPrintIcon,QrCodeIcon,DevicePhoneMobileIcon,ArrowDownTrayIcon,NoSymbolIcon,ArrowPathRoundedSquareIcon,ArrowUturnLeftIcon,MagnifyingGlassIcon}from'@tuwaio/nova-icons/24/outline';import {jsxs,jsx,Fragment as Fragment$1}from'react/jsx-runtime';import {HashLink,TxProgressIndicator,TxStatusVisual}from'@tuwaio/nova-transactions';import {parseCaip2ChainId,toCaip2ChainId,formatCaip10AccountId,toEvmChainId,parseCaip19AssetId,parseCaip10AccountId,formatBaseUnits,shortAddress,OrbitAdapter,getAdapterFromConnectorType,getConnectorTypeFromName,formatConnectorName,getSolanaCluster,isSameAddress}from'@tuwaio/orbit-core';export{shortAddress}from'@tuwaio/orbit-core';import {useLabels,NovaTransactionsLabelsProvider}from'@tuwaio/nova-transactions/providers';import {MotionConfig,AnimatePresence}from'framer-motion';import {createCheckoutStore,payoutAddressesOf,withPayoutAddresses}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 oa=createContext(null),jo=oa.Provider;function E(){let e=useContext(oa);if(!e)throw new Error("useCheckoutContext must be used inside PaymentCheckout");return e}function Oe(){return useContext(oa)}var Fc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Zo="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(" "),Mc=new Set(Zo);function Ya(e,t){let a=e==="full"||t,n=[{name:"email",required:true,autoComplete:"email",type:"email"}];return a?[...n,{name:"name",required:true,autoComplete:t?"organization":"name",type:"text"},{name:"country",required:true,autoComplete:"country",type:"country"},{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"},...t?Bc():[]]:n}var Bc=()=>[{name:"taxId",required:true,autoComplete:"off",type:"text"},{name:"registrationNumber",required:false,autoComplete:"off",type:"text"}];function Jo(e,t,a){let n={};for(let o of Ya(t,a)){let r=e[o.name]?.trim()??"";r?o.type==="email"&&!Fc.test(r)?n[o.name]="email":o.type==="country"&&!Mc.has(r.toUpperCase())&&(n[o.name]="country"):o.required&&(n[o.name]="required");}return n}function Xo(e){let t={};for(let[a,n]of Object.entries(e)){let o=n?.trim();o&&(t[a]=a==="country"?o.toUpperCase():o);}return t}function er(e){let t=new Intl.DisplayNames([e],{type:"region"});return Zo.map(a=>({code:a,name:t.of(a)??a})).sort((a,n)=>a.name.localeCompare(n.name,e))}var se="novapay:focus-visible:outline-2 novapay:focus-visible:outline-offset-2 novapay:focus-visible:outline-[var(--tuwa-text-accent)]",Tt=`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-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:px-1.5 novapay:text-[var(--tuwa-text-primary)] novapay:cursor-pointer novapay:transition-colors novapay:hover:bg-[var(--tuwa-standart-button-hover)] ${se}`,$="novapay:font-mono novapay:tabular-nums",nt="novapay:font-mono novapay:font-bold novapay:uppercase novapay:tracking-[0.12em]",Be=`${nt} novapay:text-[11px] novapay:leading-4 novapay:text-[var(--tuwa-text-secondary)]`,nn=`${nt} novapay:inline-flex novapay:shrink-0 novapay:items-center novapay:gap-1 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-1.5 novapay:py-0.5 novapay:text-[10px] novapay:leading-3`,an={neutral:"novapay:border-[var(--tuwa-border-strong)] novapay:text-[var(--tuwa-text-primary)]",accent:"novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",success:"novapay:border-[color-mix(in_srgb,var(--tuwa-success-icon)_35%,transparent)] novapay:bg-[var(--tuwa-success-bg)] novapay:text-[var(--tuwa-success-text)]",pending:"novapay:border-[color-mix(in_srgb,var(--tuwa-pending-icon)_35%,transparent)] novapay:bg-[var(--tuwa-pending-bg)] novapay:text-[var(--tuwa-pending-text)]",error:"novapay:border-[color-mix(in_srgb,var(--tuwa-error-icon)_35%,transparent)] novapay:bg-[var(--tuwa-error-bg)] novapay:text-[var(--tuwa-error-text)]"},at=`novapay-title ${$} novapay:m-0 novapay:text-base novapay:font-bold novapay:text-balance novapay:outline-none`,It={tabIndex:-1,"data-novapay-heading":""},tr=`${nt} novapay:box-border novapay:inline-flex novapay:min-h-11 novapay:w-full novapay:min-w-0 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:gap-2 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2 novapay:text-center novapay:text-xs novapay:leading-4 novapay:no-underline novapay:transition-colors novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${se}`,Rt=`tuwa-solid ${tr} novapay:border-[var(--tuwa-button-primary-bg)] novapay:bg-[var(--tuwa-button-primary-bg)] novapay:text-[var(--tuwa-text-on-accent)] novapay:hover:border-[var(--tuwa-button-primary-bg-hover)] novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)]`,ra=`${tr} novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:text-[var(--tuwa-text-primary)] novapay:hover:bg-[var(--tuwa-standart-button-hover)]`,on=`${nt} novapay:inline-flex novapay:min-h-7 novapay:shrink-0 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-strong)] novapay:bg-[var(--tuwa-standart-button-bg)] novapay:px-2.5 novapay:py-1 novapay:text-[10px] novapay:leading-3 novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors novapay:hover:bg-[var(--tuwa-standart-button-hover)] novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${se}`,nr=`tuwa-solid ${nt} novapay:inline-flex novapay:min-h-8 novapay:cursor-pointer novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-button-primary-bg)] novapay:bg-[var(--tuwa-button-primary-bg)] novapay:px-3 novapay:py-1.5 novapay:text-center novapay:text-[11px] novapay:leading-4 novapay:text-[var(--tuwa-text-on-accent)] novapay:transition-colors novapay:hover:border-[var(--tuwa-button-primary-bg-hover)] novapay:hover:bg-[var(--tuwa-button-primary-bg-hover)] novapay:disabled:cursor-not-allowed novapay:disabled:opacity-70 ${se}`,sa="novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[color-mix(in_srgb,var(--tuwa-pending-icon)_35%,transparent)] novapay:bg-[var(--tuwa-pending-bg)] novapay:text-[var(--tuwa-pending-text)]";function ia(e){return e==="modal"?{frame:"novapay:sm:w-[min(760px,calc(100vw_-_2rem_-_2px))]",section:""}:{frame:"",section:`novapay:box-border ${e==="page"?"novapay:w-[880px]":"novapay:w-[760px]"} novapay:max-w-full`}}var ar={default:{frame:"tuwa-scanlines novapay:relative novapay:box-border 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-[680px] novapay:sm:flex-row",aside:"tuwa-scanlines 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",main:"novapay:flex novapay:min-h-0 novapay:min-w-0 novapay:flex-1 novapay:flex-col",area:"novapay:@container novapay:flex novapay:min-h-0 novapay:flex-1 novapay:flex-col novapay:overflow-y-auto"},page:{frame:"tuwa-scanlines novapay:relative novapay:box-border novapay:flex novapay:w-full novapay:flex-1 novapay:flex-col novapay:bg-[var(--tuwa-bg-primary)] novapay:text-[var(--tuwa-text-primary)] novapay:sm:min-h-[calc(var(--novapay-page-floor)_-_2px)] novapay:sm:flex-row",aside:"novapay-page-aside tuwa-scanlines novapay:hidden novapay:w-[clamp(260px,36.4%,320px)] novapay:shrink-0 novapay:flex-col novapay:border-r novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:p-5 novapay:sm:flex",main:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",area:"novapay:@container novapay:flex novapay:flex-1 novapay:flex-col"}};function or(e){return e.length<=7?"novapay:text-[36px]":e.length<=10?"novapay:text-[30px]":e.length<=13?"novapay:text-[24px]":"novapay:text-[20px]"}function yt(){return useNovaIcons().outline}function rn(e){return jsx(NovaSetIcon,{solid:"ChevronDownIcon",...e})}function rr(e){return jsx(NovaSetIcon,{solid:"GlobeAltIcon",...e})}function sn(e){return jsx(NovaSetIcon,{outline:"ClockIcon",...e})}function sr(e){return jsx(NovaSetIcon,{outline:"DocumentTextIcon",...e})}function ft(e){return jsx(NovaSetIcon,{outline:"ExclamationTriangleIcon",...e})}function ir(e){return jsx(NovaSetIcon,{outline:"InformationCircleIcon",...e})}function cr(e){return jsx(NovaSetIcon,{outline:"WalletIcon",...e})}function lr(e){let a=yt().ArrowDownTrayIcon??ArrowDownTrayIcon;return jsx(a,{...e})}function pr(e){let a=yt().ArrowPathRoundedSquareIcon??ArrowPathRoundedSquareIcon;return jsx(a,{...e})}function ur(e){let a=yt().ArrowUturnLeftIcon??ArrowUturnLeftIcon;return jsx(a,{...e})}function mr(e){let a=yt().DevicePhoneMobileIcon??DevicePhoneMobileIcon;return jsx(a,{...e})}function dr(e){let a=yt().FingerPrintIcon??FingerPrintIcon;return jsx(a,{...e})}function yr(e){let a=yt().LockClosedIcon??LockClosedIcon;return jsx(a,{...e})}function fr(e){let a=yt().MagnifyingGlassIcon??MagnifyingGlassIcon;return jsx(a,{...e})}function vr(e){let a=yt().NoSymbolIcon??NoSymbolIcon;return jsx(a,{...e})}function hr(e){let a=yt().QrCodeIcon??QrCodeIcon;return jsx(a,{...e})}var xr={metamask:"MetaMask",walletconnect:"WalletConnect",coinbase:"Coinbase Wallet",okx:"OKX Wallet",trust:"Trust Wallet",injected:"Browser wallet"};function nl(e,t){let a=e.slice(e.indexOf(":")+1).toLowerCase();return a==="injected"?xr.injected:t?.trim()||xr[a]||a.charAt(0).toUpperCase()+a.slice(1)}var Ja=e=>/^data:image\//i.test(e)||/^https:\/\//i.test(e),Za=e=>{let t=typeof e=="string"?e.trim():"";return t&&Ja(t)?t:void 0};function al(e,t,a){let n=getAdapterFromConnectorType(t),o=e[n];if(!Array.isArray(o))return;let r=o.filter(s=>typeof s=="object"&&s!==null&&typeof s.name=="string"&&getConnectorTypeFromName(n,formatConnectorName(s.name))===t);return a&&r.find(s=>Za(s.icon)===a)||r[0]}var vt=e=>{let t=parseCaip2ChainId(e)?.namespace;return t==="eip155"||t==="solana"?t:null};function gr(e,t){if(!e?.address)return null;let a=toCaip2ChainId(e.chainId),n=a?vt(a):null;if(!a||!n)return null;let o=Za(e.icon),r=t?al(t,e.connectorType,o):void 0;return {address:e.address,chainId:a,family:n,connectorType:e.connectorType,walletId:e.connectorType.slice(e.connectorType.indexOf(":")+1).toLowerCase(),name:nl(e.connectorType,typeof r?.name=="string"?r.name:void 0),icon:o??Za(r?.icon),connection:e}}function je(e){return vt(e.chainId)}function De(e,t){return !e||e.family!==je(t)?null:formatCaip10AccountId(t.chainId,e.address)??null}function br(e,t){let a=je(e);return a==="solana"||a==="eip155"&&(e.ownAddress===true||!!t)}function Xa(e){let t=a=>String(Number((a/100).toFixed(2)));return e.discountBps>0?{kind:"discount",percent:t(e.discountBps)}:e.markupBps>0?{kind:"markup",percent:t(e.markupBps)}:null}function ve(e){return getChainName(toEvmChainId(e)??e).name}function wr(e){let t=e.assetId?parseCaip19AssetId(e.assetId):void 0;return !t||t.assetNamespace==="slip44"?"native":t.assetReference}var ol=new Set(["awaitingPayment","selectMethod","underpaid"]),rl="too_many_payments";function eo(e,t={}){if(t.labelsReady===false&&e.phase!=="error")return "loading";if(e.phase==="unconfirmed")return Et(e.error)==="retrying"?"confirm":"unconfirmed";if(t.afterFailure&&e.error?.code==="payment_failed"&&ol.has(e.phase))return "failed";let a=e.payerProof==="required"||e.payerProof==="confirming"||e.payerProof==="confirmed"&&!e.error,n=!!(t.confirmWallet&&a);switch(e.phase){case "selectMethod":return n&&!(t.handoff&&t.payWith==="qr")?"confirmWallet":t.handoff&&t.payWith==="qr"?"qr":"method";case "underpaid":return n?"confirmWallet":"underpaid";case "quoting":return e.quote?t.payWith==="qr"||e.quote.payer===null?"qr":"pay":t.confirmWallet?"confirmWallet":"method";case "awaitingPayment":case "submitting":return e.phase==="submitting"&&!e.quote?"confirm":t.payWith==="qr"||e.quote?.payer===null?"qr":"pay";case "confirming":return "confirm";case "cancelled":return e.checkout?.invoice.replacedBy?"replaced":"cancelled";default:return e.phase}}var sl={buyer:"details",method:"method",confirmWallet:"method",pay:"pay",qr:"pay",underpaid:"pay",confirm:"confirm",unconfirmed:"confirm",failed:"confirm"};function kr(e,t={}){let a=sl[e];if(!a)return null;let n=[...t.withDetails||a==="details"?["details"]:[],"method","pay","confirm"],o=n.indexOf(a);return n.map((r,s)=>({key:r,state:s<o?"done":s===o?"current":"upcoming"}))}function Cr(e={}){return [...e.withDetails?["details"]:[],"method","pay","confirm"].map(a=>({key:a,state:"done"}))}function Sr(e,t){let a=s=>s.chainId===t?0:s.featured?1:2,n=new Map;for(let s of e)n.set(s.symbol,[...n.get(s.symbol)??[],s]);let o=[...n].map(([s,i])=>{let c=[...i].sort((l,p)=>a(l)-a(p));return {symbol:s,methods:c,featured:i.some(l=>l.featured),inWallet:!!t&&i.some(l=>l.chainId===t)}}),r=s=>s.inWallet?0:s.featured?1:2;return o.sort((s,i)=>r(s)-r(i))}var il=new Set(["open","processing","underpaid"]),cl=new Set(["loading","error","buyer","method","confirmWallet","pay","qr","failed","underpaid","blocked"]);function Fn(e,t,a){return il.has(e)?t==="confirm"||t==="unconfirmed"?"confirming":cl.has(t)?e==="underpaid"&&a===false?"closed":"paying":null:null}var ll=[10,5,1];function Pr(e,t,a=ll){if(e===null||t<=0)return null;let n=a.filter(o=>e>o*6e4&&t<=o*6e4);return n.length?Math.min(...n):null}var to=6e4;function Nr(e){let{phase:t,quotePayer:a,payer:n}=e;return t!=="awaitingPayment"||!a||n===a?"keep":n?"lock":"release"}function Tr(e){let{open:t,storePayer:a,payer:n,paysRest:o}=e;return !t||n===a?"keep":n&&o?"follow":"leave"}function Ir(e){return e>0&&e<=to}function Rr(e){return e.amlScreening!==false}function ot(e){return e.paymentOnTheWay??!!(e.txKey||e.txHash)}function ht(e,t){let a=t?.invoice?.pendingPayments??0;return e.invoicePaymentOnTheWay??a>0}function Er({state:e,checkout:t,handedOverAt:a,dueAt:n}){let o=e.paymentSentInTime,r=ot({paymentOnTheWay:e.paymentOnTheWay,txKey:e.txKey??null,txHash:e.txHash??null});if(typeof o=="boolean"&&r)return o;let s=t.invoice.paymentCountsUntil;return s===void 0?a!==null&&a<n:a!==null&&a>=n?false:(e.paymentCountsUntil===void 0?s:e.paymentCountsUntil)!==null}var no="settlement_failed",Ar="tx_already_used";function Lr(e){let t=e?.code,a=e?.reason;return (t==="payment_failed"||t==="payment_mismatch")&&!!a&&a!==no}var pl=new Set(["no_matching_transfer","reference_missing","too_early","tx_already_used","payer_mismatch","payer_unconfirmed","quote_changed","too_many_parts","too_many_transfers","below_minimum","native_from_contract_unverifiable","invoice_not_payable"]);function xt(e){let t=e?.code,a=e?.reason;return a===no?false:t==="payment_mismatch"?true:t==="payment_failed"&&a!==void 0&&pl.has(a)}function _r(e){let t=e?.reason;return xt(e)&&t===Ar}function Ht(e,t){let a=t?.invoice?.unresolvedPayments??0;return e.invoicePaymentUnresolved??a>0}function Et(e){let t=e?.code,{reason:a,rechecked:n,stillRead:o}=e??{};return t==="payment_failed"&&a==="unresolved_after_24h"?"closed":a===no&&(t==="payment_unconfirmed"||t==="payment_mismatch")?n===true?"settlementRetrying":"settlementFailed":t!=="payment_unconfirmed"?null:a==="nonce_spent_unexplained"?"nonceSpent":a==="unmined_after_24h"||o===true?"unmined":a===Ar?"takenElsewhere":a==="submit_retrying"?"retrying":a==="submit_failed"?"notReceived":a===rl?"invoiceFull":n===true?"rechecked":"contact"}function Fr(e,t){let{txKey:a}=e.error??{};if(a)return a;let n=t?.invoice?.rejectedPayments;return e.txHash??e.txKey??n?.[0]?.txKey??null}function Mr({picked:e,page:t,invoice:a}){return e&&e.page===t?e.locale:t??a??"en"}function Br(e,t){return e.supportEmail?`mailto:${e.supportEmail}?subject=${encodeURIComponent(t)}`:e.website??null}var Or={nonceSpent:"unconfirmedNonceSpent",closed:"unconfirmedClosed",takenElsewhere:"unconfirmedTakenElsewhere",settlementRetrying:"unconfirmedSettlementRetrying",settlementFailed:"unconfirmedSettlementFailed",invoiceFull:"unconfirmedInvoiceFull"};function Mn(e,t,a){let n=e.reason;return n==="expired"?t.pay.failedExpired:n==="cancelled"?t.pay.failedCancelled:n==="reverted"?a?c(t.pay.failed,{network:a}):t.method.paymentFailed:t.pay.didNotGoThrough}function ca(e){if(e?.code!=="payment_failed"&&e?.code!=="payment_mismatch")return null;let{txKey:t}=e;return typeof t=="string"&&t?t:null}var ml=new Set(["payer_mismatch","payer_unconfirmed"]);function $t(e,t,a=""){if(xt(e)){let r=e.reason??"",s=e.unmatched===true;if(r==="quote_changed")return c(t.pay.mismatchChargeUnmatched,{merchant:a});if(r==="too_many_parts")return c(t.pay.mismatchTooManyParts,{merchant:a});if(r==="reference_missing"&&s)return c(t.pay.mismatchNoReferenceUnmatched,{merchant:a});let i=ml.has(r)?s?t.pay.mismatchOtherWalletUnmatched:t.pay.mismatchOtherWallet:s?t.pay.mismatchUnmatchedElsewhere:_r(e)?t.pay.mismatchTakenElsewhere:t.pay.mismatch;return c(i,{merchant:a})}let n=Et(e),o=n?Or[n]:void 0;return o?c(t.outcome[o],{merchant:a}):null}var dl=["buyer","selectMethod","quoting","awaitingPayment"];function ao(e,t,a){if(a==="underpaid")return false;let n=Et(t);return dl.includes(e)&&!xt(t)&&!(n&&Or[n])}function la(e,t,a=""){let n=$t(e,t,a);if(n!==null)return n;switch(e.code){case "screening_unavailable":return t.pay.screeningUnavailable;case "request_failed":return t.pay.noAnswer;case "amount_out_of_range":case "method_not_found":case "testnet_required":return t.method.methodUnavailable;case "payer_not_expected":return t.method.payerNotExpected;case "payer_is_recipient":return t.method.payerIsRecipient;case "too_many_payments":return c(t.method.tooManyPayments,{merchant:a});case "too_many_payers":return c(t.method.tooManyPayers,{merchant:a});case "native_from_contract":return t.method.nativeFromSmartWallet;case "rate_limited":return t.method.rateLimited;case "price_unavailable":case "price_no_rpc":return t.method.priceUnavailable;case "consent_required":return t.method.consentRequired;case "payer_proof_required":case "payer_proof_declined":return t.payerProof.text;case "payer_proof_invalid":return t.payerProof.invalid;case "payer_proof_unavailable":return t.payerProof.unavailable;case "payment_failed":return Mn(e,t);case "rest_method_mismatch":return t.method.restSameMethod;default:return t.error.generic}}function Dr(e,t){if(!e||t===null)return null;let a=BigInt(e.cryptoAmountExpected)-BigInt(t);return a>0n?a.toString():null}function cn(e,t,a,n,o,r=a.pay.restRateEnded){let s=e?.rateHeldUntil?Date.parse(e.rateHeldUntil):null;if(s===null)return null;if(s<=t)return c(r,{merchant:n});let i=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(s);return c(a.pay.restRateUntil,{time:i,merchant:n})}function At(e){return parseCaip10AccountId(e)?.address??e}function ln(e,t){let a=At(e),n=At(t);return a.startsWith("0x")?a.toLowerCase()===n.toLowerCase():a===n}function Wr(e){return e&&/^\d+$/.test(e)&&BigInt(e)>0n?e:null}function qr(e){let t=BigInt(e.cryptoAmount),a=e.received?BigInt(e.received):null;if(a&&t>a&&(t-a)*200n>=a)return true;if(!e.atPaymentRate)return false;let n=BigInt(e.atPaymentRate);return n===0n?false:(t>n?t-n:n-t)*200n>=n}var yl=new Set(["needs_review","refunded","expired","cancelled","blocked","error"]);function Ur(e,t,a){return a?e==="paid"?t!==0:!yl.has(e):true}function $r(e,t){return t.withGas||!e.gasless?"transfer":e.gasless.paymaster&&t.canSponsorCalls?"paymaster":e.gasless.relay?"relay":"transfer"}function Kr(e){let t=BigInt(e.amountToSend),a=BigInt(e.amountDue);return !e.transferFee||t<=a?{send:e.amountToSend,receives:e.amountDue,fee:null}:{send:e.amountToSend,receives:e.amountDue,fee:{amount:String(t-a),percent:String(e.transferFee.bps/100)}}}var pa=10000n,Hr=8n;function Vr(e,t){let a=BigInt(e.cryptoAmountExpected);if(!t||a<=0n)return null;let o=BigInt(t)*(pa+BigInt(e.markupBps))*(pa-BigInt(e.discountBps))*10n**BigInt(e.decimals)*10n**Hr/(100n*pa*pa*a);return Number(o)/10**Number(Hr)}function Gr(e,t,a=0n){let n=BigInt(t.amountToSend)+a;return e>=n?null:{have:String(e),need:String(n),short:String(n-e)}}function xe(e){return e.family==="eip155"?`eip155:${e.chainId}`:e.chainId}var Qr="novapay:normal-case",gl=3,bl={};function wl(e){let[,t="",a="",n=""]=/^(\s*)([\s\S]*?)(\s*)$/.exec(e)??[];return [t,a,n]}function kl(e,t){let a=e.ownerDocument.createElement("span");a.style.cssText="position:absolute;visibility:hidden;white-space:nowrap;pointer-events:none";for(let[o,r]of t){let s=e.ownerDocument.createElement("span");r&&(s.style.textTransform="none"),s.textContent=o,a.append(s);}e.append(a);let{width:n}=a.getBoundingClientRect();return a.remove(),n}function Cl(e,t){let a=getComputedStyle(t),n=[...t.children].filter(s=>s!==e),o=n.reduce((s,i)=>s+i.getBoundingClientRect().width,0),r=(Number.parseFloat(a.columnGap)||0)*n.length;return t.clientWidth-Number.parseFloat(a.paddingLeft)-Number.parseFloat(a.paddingRight)-o-r}function we({label:e,values:t=bl}){let a=useRef(null),[n,o]=useState(false),[r,s]=useState(gl),i=Object.fromEntries(Object.entries(t).map(([p,m])=>[p,{own:String(m)}])),c=d(e,i).map(p=>typeof p=="string"?[p,false]:[p.own,true]),l=JSON.stringify(c);return useLayoutEffect(()=>{let p=a.current,m=p?.parentElement;if(!p||!m)return;let y=JSON.parse(l),f=()=>{o(kl(p,y)>Cl(p,m)+.5),s(d=>Math.max(d,y.length));};if(f(),typeof ResizeObserver>"u")return;let v=new ResizeObserver(f);return v.observe(m),()=>v.disconnect()},[l]),n?jsx("span",{ref:a,className:"novapay:min-w-0",children:jsx("span",{className:"novapay-label-fade",children:c.map(([p,m],y)=>m?jsx("span",{className:Qr,children:p},y):p)},l)}):jsx("span",{ref:a,className:"novapay:min-w-0 novapay:whitespace-nowrap",children:Array.from({length:Math.max(r,c.length)},(p,m)=>{let[y,f]=c[m]??["",false],[v,d,I]=wl(y);return jsxs(Fragment,{children:[v,jsx(MorphText,{className:f?Qr:void 0,children:d}),I]},m)})})}function Z(e,t,a){let n=e.customization.classNames?.[t];return n?.({screen:e.screen,checkoutState:e.state,checkout:e.checkout,...a})}function Ye({children:e,labels:t}){let a=Oe(),n=t??a?.labels,o=useLabels(),r=useMemo(()=>({...o,trackingModal:{...o.trackingModal,progressIndicator:{created:n.confirm.sent,processing:n.confirm.confirming,succeed:n.confirm.paid}},statuses:{...o.statuses,confirmed:n.confirm.confirmed,failed:n.confirm.failed},actions:{...o.actions,viewOnExplorer:n.confirm.viewOnExplorer,copy:n.confirm.copyHash},txError:{...o.txError,copied:n.pay.copied}}),[o,n]);return jsx(NovaTransactionsLabelsProvider,{labels:r,children:e})}var Vt=(e,t)=>e?Z(e,t):void 0;function On({walletId:e,icon:t}){let[a,n]=useState(null);return t&&t!==a&&Ja(t)?jsx("img",{src:t,alt:"",onError:()=>n(t),className:"novapay:block novapay:h-full novapay:w-full novapay:object-contain"}):jsx(WalletIcon,{walletName:e})}function We({hash:e,chainId:t,explorerUrl:a,labels:n}){let o=Oe(),r=a??(t?o?.adapterFor(t.startsWith("solana:")?"solana":"eip155")?.explorerAddressUrl?.({chainId:t,address:e}):void 0);return jsx(Ye,{labels:n,children:jsx(HashLink,{hash:e,explorerUrl:r,variant:"compact",...o?.customization.childCustomizations?.hashLink})})}function ua({walletId:e,walletIcon:t}){return !e&&!t?jsx(QuasarLoader,{size:48,accent:"var(--tuwa-pending-icon)"}):jsx("span",{className:"novapay-chase novapay:relative novapay:flex novapay:h-20 novapay:w-20 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-full)] novapay:border-2 novapay:border-[color-mix(in_srgb,var(--tuwa-pending-text)_25%,transparent)]",children:jsx("span",{className:"novapay:block novapay:h-11 novapay:w-11",children:jsx(On,{walletId:e??"",icon:t})})})}function de({title:e,subtitle:t,children:a}){let n=Oe(),o=n?.display==="page";return jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-2.5 novapay:px-5 novapay:py-4",o&&"novapay-page-screen",Vt(n,"screen")),children:[jsxs("div",{children:[jsx("h2",{...It,className:at,children:typeof e=="string"?jsx(MorphText,{wrap:true,children:e}):e}),t&&jsx("p",{className:cn$1("novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",o&&"novapay-page-subtitle"),children:t})]}),a]})}function J({children:e}){let t=Oe(),a=useRef(null),n=t?.display==="page";return useEffect(()=>{let o=a.current,r=n?o?.ownerDocument.documentElement:o?.closest("[data-novapay-scroll]");if(!o||!r||typeof ResizeObserver>"u")return;let s=()=>r.style.scrollPaddingBottom=!n||getComputedStyle(o).position==="sticky"?`${o.offsetHeight+8}px`:"";s();let i=new ResizeObserver(s);return i.observe(o),()=>{i.disconnect(),r.style.scrollPaddingBottom="";}},[n]),jsx("footer",{ref:a,className:cn$1("tuwa-scanlines novapay:empty:hidden novapay:sticky novapay:bottom-0 novapay:z-10 novapay:flex novapay:flex-col novapay:gap-2 novapay:border-t novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-5 novapay:pb-3.5 novapay:pt-3 novapay:text-center",n&&"novapay-page-footer",Vt(t,"footer")),children:e})}function pn({children:e,id:t}){let a=Oe()?.display==="page";return jsx("span",{id:t,className:cn$1(Be,a&&"novapay-page-group"),children:e})}function ee({busy:e,children:t,className:a,...n}){let o=Oe(),r=Vt(o,"primaryButton"),s=o?.customization.components?.PrimaryButton;return s?jsx(s,{busy:e,className:cn$1(a,r),...n,children:t}):jsxs("button",{type:"button","aria-busy":e||void 0,...n,disabled:n.disabled||e,className:cn$1(Rt,a,r),children:[e&&jsx(QuasarLoader,{size:16,accent:"currentColor"}),typeof t=="string"?jsx(we,{label:t}):t]})}function ae({children:e,className:t,...a}){let n=Oe();return jsx("button",{type:"button",...a,className:cn$1(ra,t,Vt(n,"secondaryButton")),children:e})}function ma({className:e,...t}){return jsxs("span",{className:cn$1("novapay:relative novapay:inline-flex novapay:h-4 novapay:w-4 novapay:shrink-0",e),children:[jsx("input",{type:"checkbox",...t,className:cn$1("novapay:peer novapay:m-0 novapay:box-border novapay:h-4 novapay:w-4 novapay:cursor-pointer novapay:appearance-none novapay:rounded-[var(--tuwa-rounded-full)] novapay:border novapay:border-[var(--tuwa-text-secondary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:transition-colors novapay:checked:border-[var(--tuwa-text-accent)] novapay:checked:bg-[var(--tuwa-text-accent)]",se)}),jsx(DrawnCheck,{className:"novapay:pointer-events-none novapay:absolute novapay:inset-0 novapay:m-auto novapay:h-3 novapay:w-3 novapay:text-[var(--tuwa-bg-primary)] novapay:opacity-0 novapay:peer-checked:opacity-100"})]})}function qe({children:e}){return jsx("p",{className:"novapay:m-0 novapay:text-center novapay:text-[11px] novapay:leading-snug novapay:text-[var(--tuwa-text-secondary)]",children:e})}function ge({children:e,className:t}){let a=Oe();return jsx("dl",{className:cn$1("tuwa-scanlines novapay:m-0 novapay:flex novapay:w-full novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-left",t,Vt(a,"detailsCard")),children:e})}function Q({children:e}){let t=Oe();return jsx("p",{role:"alert",className:cn$1("novapay:m-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[color-mix(in_srgb,var(--tuwa-error-icon)_35%,transparent)] novapay:bg-[var(--tuwa-error-bg)] novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-error-text)]",Vt(t,"error")),children:e})}function da({error:e}){let t=Oe(),a=ca(e);if(!t||!a)return null;let n=t.state.quote??t.checkout?.quote,o=n?xe(n.instructions):null,r=n&&o?t.adapterFor(n.instructions.family)?.explorerUrl?.({chainId:o,txKey:a}):void 0;return jsx(Ye,{children:jsx(ge,{children:jsx(U,{name:t.labels.confirm.transaction,children:jsx(HashLink,{hash:a,explorerUrl:r,variant:"compact",...t.customization.childCustomizations?.hashLink})})})})}function Dn({text:e,label:t,copiedLabel:a,children:n}){let[o,r]=useState(false);return useEffect(()=>{if(!o)return;let s=setTimeout(()=>r(false),2e3);return ()=>clearTimeout(s)},[o]),jsxs(Fragment$1,{children:[jsxs("button",{type:"button","aria-label":n?void 0:t,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>r(true),()=>{});},className:cn$1(Tt,"novapay:min-h-6 novapay:min-w-6 novapay:text-xs"),children:[jsx(CopyIcon,{copied:o,className:"novapay:h-3.5 novapay:w-3.5"}),n]}),jsx("span",{role:"status",className:"novapay:sr-only",children:o?a:""})]})}function U({name:e,children:t}){let a=Oe();return jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:justify-between novapay:gap-3 novapay:py-2 novapay:text-xs",a?.display==="page"&&"novapay-page-row",Vt(a,"detailRow")),children:[jsx("dt",{className:"novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]",children:e}),jsx("dd",{className:cn$1($,"novapay:m-0 novapay:min-w-0 novapay:text-right novapay:break-words"),children:t})]})}function gt({children:e,onClick:t,disabled:a}){return jsx("button",{type:"button",onClick:t,disabled:a,className:cn$1("novapay:disabled:cursor-default novapay:disabled:opacity-50 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",se),children:e})}var Dl=(e,t,a)=>t==="name"&&a?e.buyer.companyName:e.buyer[t]??t,Wl=(e,t)=>t==="email"?e.buyer.invalidEmail:t==="country"?e.buyer.invalidCountry:e.buyer.required,ql=new Set(["postalCode","city","taxId","registrationNumber"]),Ul=new Set(["name","country","addressLine1","addressLine2"]),Xr=e=>cn$1("novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-[13px] novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors novapay:focus:border-[var(--tuwa-text-accent)]",e?"novapay:border-[var(--tuwa-error-icon)]":"novapay:border-[var(--tuwa-text-secondary)] novapay:hover:border-[var(--tuwa-text-primary)]",se);function es(){let{checkout:e,state:t,store:a,labels:n,locale:o,display:r}=E(),[s,i]=useState({}),[c,l]=useState(false),[p,m]=useState(false),[y,f]=useState(false),v=useId(),d=useMemo(()=>er(o),[o]);if(!e||e.buyer.collect==="off")return null;let I=e.buyer.collect,h=Ya(I,c),x=Jo(s,I,c),g=(C,b)=>i(R=>({...R,[C]:b})),k=async C=>{if(C.preventDefault(),m(true),Object.keys(x).length>0){document.getElementById(`${v}-${Object.keys(x)[0]}`)?.focus();return}f(true),await a.getState().setBuyer(Xo(s),{company:c}),f(false);};return jsxs("form",{noValidate:true,onSubmit:C=>{k(C);},className:"novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs(de,{title:n.buyer.title,subtitle:n.buyer.subtitle,children:[jsx("div",{className:"novapay:grid novapay:grid-cols-1 novapay:gap-x-3 novapay:gap-y-3.5 novapay:pt-1 novapay:sm:grid-cols-2",children:h.map((C,b)=>{let R=`${v}-${C.name}`,_=p?x[C.name]:void 0,F=C.type==="country"?jsxs("div",{className:"novapay:relative",children:[jsxs("select",{id:R,autoComplete:C.autoComplete,required:C.required,"aria-invalid":!!_,"aria-describedby":_?`${R}-error`:void 0,value:s.country??"",onChange:D=>g("country",D.target.value),className:cn$1(Xr(!!_),"novapay:cursor-pointer novapay:appearance-none novapay:pr-9",!s.country&&"novapay:text-[var(--tuwa-text-secondary)]"),children:[jsx("option",{value:"",children:n.buyer.chooseCountry}),d.map(D=>jsx("option",{value:D.code,children:D.name},D.code))]}),jsx(rn,{"aria-hidden":true,className:"novapay:pointer-events-none novapay:absolute novapay:top-1/2 novapay:right-3 novapay:h-4 novapay:w-4 novapay:-translate-y-1/2 novapay:text-[var(--tuwa-text-secondary)]"})]}):jsx("input",{id:R,type:C.type,autoComplete:C.autoComplete,required:C.required,"aria-invalid":!!_,"aria-describedby":_?`${R}-error`:void 0,value:s[C.name]??"",onChange:D=>g(C.name,D.target.value),className:Xr(!!_)});return jsxs(Fragment,{children:[jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-1.5",!ql.has(C.name)&&(r==="page"&&Ul.has(C.name)?"novapay:sm:@max-[519px]:col-span-2":"novapay:sm:col-span-2")),children:[jsxs("label",{htmlFor:R,className:"novapay:text-xs novapay:font-medium novapay:text-[var(--tuwa-text-primary)]",children:[Dl(n,C.name,c),C.required&&jsxs("span",{"aria-hidden":"true",className:"novapay:text-[var(--tuwa-error-text)]",children:[" ","*"]}),!C.required&&jsxs("span",{className:"novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:[" ","(",n.buyer.optional,")"]})]}),F,_&&jsx("span",{id:`${R}-error`,className:"novapay:text-[11px] novapay:text-[var(--tuwa-error-text)]",children:Wl(n,_)})]}),b===0&&e.buyer.companyInvoice&&jsxs("label",{className:cn$1("novapay:flex novapay:cursor-pointer novapay:items-center novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2.5 novapay:text-[13px] novapay:transition-colors novapay:sm:col-span-2",c?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]"),children:[jsx(ma,{checked:c,onChange:D=>l(D.target.checked)}),jsx("span",{className:"novapay:font-semibold",children:n.buyer.companyInvoice})]})]},C.name)})}),t.error&&t.phase==="buyer"&&jsx(Q,{children:n.buyer.refused})]}),jsx(J,{children:jsx(ee,{type:"submit",busy:y,children:n.buyer.continue})})]})}function ns({steps:e,labels:t,className:a,stepClassName:n}){let o=e.findIndex(p=>p.state==="current"),r=e.map(p=>t.steps[p.key]).join(""),s=useRef(null),i=useRef(null),[c$1,l]=useState(false);return useEffect(()=>{let p=s.current,m=i.current;if(!p||!m||typeof ResizeObserver>"u")return;let y=()=>l(m.offsetWidth+e.length*32+(e.length-1)*24>p.clientWidth);y();let f=new ResizeObserver(y);return f.observe(p),()=>f.disconnect()},[r,e.length]),jsxs("nav",{ref:s,"aria-label":t.steps.label,className:cn$1("novapay:relative novapay:min-w-0 novapay:flex-1",a),children:[jsx("span",{"aria-hidden":true,className:"novapay:invisible novapay:absolute novapay:h-0 novapay:w-0 novapay:overflow-hidden",children:jsx("span",{ref:i,className:cn$1(nt,"novapay:whitespace-nowrap novapay:text-[11px]"),children:r})}),jsx("ol",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:items-center novapay:gap-1.5 novapay:p-0",children:e.map((p,m)=>{let y=t.steps[p.key];return jsxs("li",{"aria-current":p.state==="current"?"step":void 0,className:cn$1("novapay:flex novapay:min-w-0 novapay:items-center novapay:gap-1.5",m>0&&"novapay:flex-auto",n?.(p,m)),children:[m>0&&jsx("span",{"aria-hidden":true,className:cn$1("novapay:h-px novapay:min-w-2 novapay:flex-1 novapay:transition-colors novapay:duration-300 novapay:motion-reduce:transition-none",p.state==="upcoming"?"novapay:bg-[var(--tuwa-border-primary)]":"novapay:bg-[var(--tuwa-success-icon)]")}),jsx("span",{"aria-hidden":true,className:cn$1($,"novapay:box-border novapay:flex novapay:h-5 novapay:w-5 novapay:shrink-0 novapay:items-center novapay:justify-center novapay:rounded-[var(--tuwa-rounded-full)] novapay:border novapay:text-[10px] novapay:font-bold",p.state==="done"&&"novapay:border-[var(--tuwa-success-icon)] novapay:bg-[var(--tuwa-success-icon)] novapay:text-white",p.state==="current"&&"novapay:border-[var(--tuwa-text-accent)] novapay:text-[var(--tuwa-text-accent)]",p.state==="upcoming"&&"novapay:border-[var(--tuwa-border-strong)] novapay:text-[var(--tuwa-text-secondary)]"),children:p.state==="done"?jsx(DrawnCheck,{className:"novapay:h-3 novapay:w-3"}):m+1}),jsx("span",{className:cn$1(nt,"novapay:truncate novapay:text-[11px] novapay:leading-4",p.state==="current"?"novapay:text-[var(--tuwa-text-primary)]":"novapay:text-[var(--tuwa-text-secondary)]",c$1&&p.state!=="current"&&"novapay:sr-only"),children:p.state==="current"?jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:sr-only",children:c(t.steps.progress,{current:o+1,total:e.length,name:y})}),jsx("span",{"aria-hidden":true,children:y})]}):y})]},p.key)})})]})}function Re(e,t=2){let a=e.startsWith("-"),n=(a?e.slice(1):e).padStart(t+1,"0");return `${a?"-":""}${n.slice(0,-t)}.${n.slice(-t)}`}var as=e=>new Intl.NumberFormat(e).formatToParts(1.1).find(t=>t.type==="decimal")?.value??".";function ye(e,t){let[a="0",n=""]=(typeof e=="number"?e.toFixed(2):e.trim()).split("."),o=a.startsWith("-"),r=new Intl.NumberFormat(t).format(BigInt(o?a.slice(1):a));return `${o?"-":""}${r}${as(t)}${n.padEnd(2,"0").slice(0,2)}`}function ue(e,t,a){let n=BigInt(e),o=n<0n,r=o?-n:n,s=10n**BigInt(t),i=new Intl.NumberFormat(a).format(r/s),c=(r%s).toString().padStart(t,"0").replace(/0+$/,"").padEnd(2,"0");return `${o?"-":""}${i}${as(a)}${c}`}function va(e,t,a){let n=10n**BigInt(Math.max(t-6,0)),o=(BigInt(e)+n/2n)/n*n;return o===0n?null:ue(o.toString(),t,a)}function ha(e,t){return formatBaseUnits(e,t)??"0"}var Gt=e=>String(e).padStart(2,"0");function st(e){let t=Math.max(0,Math.floor(e/1e3)),a=Math.floor(t/86400),n=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),r=t%60;return a>0?`${a}d ${Gt(n)}:${Gt(o)}`:n>0?`${Gt(n)}:${Gt(o)}:${Gt(r)}`:`${Gt(o)}:${Gt(r)}`}function mn(e){let t=e.lineItems.reduce((r,s)=>r+BigInt(s.netMinor),0n),a=BigInt(e.totalMinor??t.toString()),n=a-t,o=[...new Set(e.lineItems.filter(r=>Number(r.taxRate)>0).map(r=>r.taxRate))];return {subtotal:Re(t.toString()),tax:n>0n?Re(n.toString()):null,rate:o.length===1?String(Number(o[0])):null,total:Re(a.toString())}}var Ql=e=>{try{return new URL(e).host}catch{return e}};function xa({compact:e=false}){let{checkout:t,state:a,labels:n,display:o}=E(),[r,s]=useState(false);if(!t)return null;let{merchant:i,invoice:c}=t,l=e?"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:[a.logoUrl&&!r?jsx("img",{src:a.logoUrl,alt:"",onError:()=>s(true),className:cn$1(l,"novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:object-contain")}):jsx("span",{"aria-hidden":true,className:cn$1(l,$,"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:i.name.trim().charAt(0).toUpperCase()}),jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:cn$1("novapay:text-sm novapay:font-semibold",o==="page"&&!e?"novapay:line-clamp-2 novapay:break-words":"novapay:truncate"),children:i.name}),e?c.number&&jsx("span",{className:cn$1($,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c.number}):i.website&&jsx("a",{href:i.website,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:truncate novapay:text-xs novapay:text-[var(--tuwa-text-secondary)] novapay:hover:underline",se),children:Ql(i.website)})]}),c.environment==="test"&&jsxs("span",{title:n.summary.testHint,className:cn$1(nn,an.pending,"novapay:ml-auto"),children:[n.summary.test,jsxs("span",{className:"novapay:sr-only",children:[": ",n.summary.testHint]})]})]})}function ro({checkout:e,labels:t}){let{merchant:a}=e,n=a.seller,o=[[t.summary.terms,a.links.terms],[t.summary.refundPolicy,a.links.refundPolicy],[t.summary.privacy,a.links.privacy]].filter(r=>!!r[1]);return jsxs("div",{className:"tuwa-scanlines 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:[n?.legalName&&jsx("span",{className:"novapay:text-xs novapay:font-semibold novapay:text-[var(--tuwa-text-primary)]",children:n.legalName}),(n?.address||n?.country)&&jsx("span",{children:[n.address,n.country].filter(Boolean).join(", ")}),n?.registrationNumber&&jsxs("span",{children:[t.summary.registration," ",n.registrationNumber]}),n?.taxId&&jsxs("span",{children:[t.summary.taxId," ",n.taxId]}),a.supportEmail&&jsx("a",{href:`mailto:${a.supportEmail}`,className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",se),children:a.supportEmail}),o.length>0&&jsx("span",{className:"novapay:flex novapay:flex-wrap novapay:gap-x-3",children:o.map(([r,s])=>jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",se),children:r},r))}),jsx("span",{children:c(t.summary.sellerRole,{seller:n?.legalName||a.name})})]})}function is(){let{checkout:e,labels:t,locale:a,now:n,screen:o,display:r}=E(),s=e?.invoice.dueAt,i=e&&Fn(e.invoice.status,o,e.invoice.restPayable);if(!e||!s||!i)return null;let c$1=new Intl.DateTimeFormat(a,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(s));return jsxs("div",{className:cn$1("tuwa-scanlines 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",r==="page"&&"novapay-page-deadline"),children:[jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-0.5",children:[jsx("span",{className:Be,children:i==="closed"?t.summary.refundAfter:t.summary.payWithin}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:i==="closed"?c$1:c(t.summary.until,{date:c$1})})]}),jsx("span",{role:"timer",className:cn$1($,"novapay:shrink-0 novapay:whitespace-nowrap novapay:text-lg novapay:font-bold"),children:st(Date.parse(s)-n)})]})}function cs(){let{checkout:e,labels:t,locale:a}=E();if(!e)return null;let{invoice:n}=e,o=mn(n);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:[n.number&&jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between novapay:gap-3",children:[jsx("span",{className:Be,children:t.summary.invoice}),jsx("span",{className:cn$1($,"novapay:min-w-0 novapay:break-all novapay:text-right novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:n.number})]}),jsx("ul",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-2.5 novapay:p-0",children:n.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($,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(t.summary.quantity,{quantity:r.quantity,price:ye(r.unitPrice,a)})})]}),jsx("span",{className:$,children:ye(Re(r.netMinor),a)})]},s))})]}),o.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:t.summary.subtotal}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.subtotal,a)})]}),jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:o.rate?c(t.summary.taxRate,{rate:o.rate}):t.summary.tax}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.tax,a)})]})]})]})}function jl(){let e=E(),{checkout:t,labels:a,locale:n}=e;return t?jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:justify-between",Z(e,"total")),children:[jsx("span",{className:cn$1(Be,"novapay:text-[var(--tuwa-text-primary)]"),children:a.summary.total}),jsxs("span",{className:cn$1($,"novapay:text-[22px] novapay:font-bold"),children:[ye(mn(t.invoice).total,n)," ",jsx("span",{className:"novapay:text-[13px] novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:t.invoice.currency})]})]}):null}function ls(){let{checkout:e,labels:t}=E();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(yr,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5 novapay:shrink-0"}),t.summary.secured]}),e?.merchant.supportEmail&&jsxs("span",{children:[t.summary.help,":"," ",jsx("a",{href:`mailto:${e.merchant.supportEmail}`,className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",se),children:e.merchant.supportEmail})]})]})}function ga({label:e,children:t,className:a,buttonClassName:n,growsUp:o=false}){let[r,s]=useState(false),i=useId();return jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-2",a),children:[jsxs("button",{type:"button","aria-expanded":r,"aria-controls":i,onClick:()=>s(c=>!c),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)]",se,n),children:[e,jsx(rn,{"aria-hidden":true,className:cn$1("novapay:h-3.5 novapay:w-3.5 novapay:transition-transform novapay:motion-reduce:transition-none",r!==o&&"novapay:rotate-180")})]}),jsx("div",{id:i,hidden:!r,children:t})]})}var os=5;function Yl(){let e=E(),{checkout:t,labels:a,locale:n}=e;if(!t)return null;let o=ye(mn(t.invoice).total,n);return jsxs("div",{className:cn$1("novapay:flex novapay:flex-col novapay:gap-1.5",Z(e,"total")),children:[jsx("span",{className:Be,children:a.summary.total}),jsxs("span",{className:cn$1($,"novapay:flex novapay:flex-wrap novapay:items-baseline novapay:gap-x-2 novapay:gap-y-1 novapay:font-bold",or(o)),children:[jsx("span",{children:o}),jsx("span",{className:"novapay:text-[15px] novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:t.invoice.currency})]})]})}var ps="novapay:flex novapay:justify-between novapay:gap-3 novapay:px-3 novapay:py-2";function rs({line:e}){let{labels:t,locale:a}=E(),n=ye(Re(e.netMinor),a),o=ye(e.unitPrice,a);return jsxs("li",{className:cn$1(ps,"novapay:text-[13px]"),children:[jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col",children:[jsx("span",{className:"novapay:break-words",children:e.name}),e.description&&jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:e.description}),(Number(e.quantity)!==1||o!==n)&&jsx("span",{className:cn$1($,"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(t.summary.quantity,{quantity:e.quantity,price:o})})]}),jsx("span",{className:cn$1($,"novapay:shrink-0"),children:n})]})}function Zl(){let{checkout:e,labels:t,locale:a}=E();if(!e)return null;let{invoice:n}=e,o=mn(n),r=o.tax?os-1:os,s=n.lineItems,i=s.length>r?s.slice(0,r-1):s,c$1=s.slice(i.length);return !n.number&&s.length===0?null:jsxs("div",{className:"tuwa-scanlines novapay:flex novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)]",children:[n.number&&jsxs("div",{className:cn$1(ps,"novapay:items-baseline"),children:[jsx("span",{className:Be,children:t.summary.invoice}),jsx("span",{className:cn$1($,"novapay:min-w-0 novapay:break-all novapay:text-right novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:n.number})]}),i.length>0&&jsx("ul",{className:"novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:p-0",children:i.map((l,p)=>jsx(rs,{line:l},p))}),c$1.length>0&&jsx(ga,{label:`+${c$1.length} \xB7 ${t.summary.showOrder}`,className:"novapay:px-3 novapay:py-2",buttonClassName:"novapay:min-h-6",children:jsx("ul",{className:"novapay:-mx-3 novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:divide-y novapay:divide-[var(--tuwa-border-primary)] novapay:p-0",children:c$1.map((l,p)=>jsx(rs,{line:l},p))})}),o.tax&&jsxs("dl",{className:"novapay:m-0 novapay:flex novapay:flex-col novapay:gap-1.5 novapay:px-3 novapay:py-2 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:t.summary.subtotal}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.subtotal,a)})]}),jsxs("div",{className:"novapay:flex novapay:justify-between",children:[jsx("dt",{children:o.rate?c(t.summary.taxRate,{rate:o.rate}):t.summary.tax}),jsx("dd",{className:cn$1($,"novapay:m-0"),children:ye(o.tax,a)})]})]})]})}function Jl(){let{checkout:e,labels:t}=E();return e?jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col",children:[jsx(xa,{}),jsx("div",{className:"novapay:mt-6",children:jsx(Yl,{})}),jsx("div",{className:"novapay:mt-5",children:jsx(Zl,{})}),jsxs("div",{className:"novapay:mt-auto novapay:flex novapay:flex-col novapay:gap-3 novapay:pt-5",children:[jsx(is,{}),jsx(ga,{label:t.summary.sellerDetails,buttonClassName:"novapay:min-h-6",growsUp:true,children:jsx(ro,{checkout:e,labels:t})}),jsx(ls,{})]})]}):null}function us(){let{checkout:e,labels:t,display:a}=E();return e?a==="page"?jsx(Jl,{}):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(xa,{}),jsx(ga,{label:t.summary.sellerDetails,children:jsx(ro,{checkout:e,labels:t})})]}),jsx(is,{}),jsx("div",{className:"novapay:-mr-2.5 novapay:min-h-0 novapay:flex-1 novapay:overflow-y-auto novapay:pr-2.5",children:jsx(cs,{})}),jsx(jl,{}),jsx(ls,{})]}):null}function ms({className:e}={}){let{checkout:t,labels:a,locale:n,now:o,screen:r}=E();if(!t)return null;let{invoice:s}=t,i=mn(s),c=s.dueAt&&Fn(s.status,r)?Date.parse(s.dueAt):null;return jsxs("div",{className:cn$1("tuwa-scanlines 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",e),children:[jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:justify-between",children:[jsxs("span",{className:cn$1($,"novapay:text-[22px] novapay:font-bold"),children:[ye(i.total,n)," ",jsx("span",{className:"novapay:text-xs novapay:font-normal novapay:text-[var(--tuwa-text-secondary)]",children:s.currency})]}),c&&jsxs("span",{role:"timer",className:cn$1($,"novapay:flex novapay:items-center novapay:gap-1 novapay:whitespace-nowrap novapay:text-xs novapay:font-bold"),children:[jsx(sn,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-secondary)]"}),st(c-o)]})]}),jsx(ga,{label:`${b(i.tax?{one:a.summary.compactOne,other:a.summary.compact}:{one:a.summary.compactNoTaxOne,other:a.summary.compactNoTax},s.lineItems.length,n,i.tax?{tax:ye(i.tax,n)}:{})} \xB7 ${a.summary.showOrder}`,children:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3 novapay:pt-1",children:[jsx(cs,{}),jsx(ro,{checkout:t,labels:a})]})})]})}function ys({locale:e$1,labels:t,receiptIssued:a,onSelect:n,className:o}){let[r,s]=useState(false),i=e.find(x=>x.code===e$1)??e[0],[c$1,l]=useState(0),p=useId(),m=useRef(null),y=useRef(null),f=useRef(null);useEffect(()=>{if(!r)return;f.current?.focus();let x=g=>{m.current?.contains(g.target)||s(false);};return document.addEventListener("pointerdown",x),()=>document.removeEventListener("pointerdown",x)},[r]);let v=()=>{l(Math.max(0,e.indexOf(i))),s(true);},d=()=>{s(false),y.current?.focus();},I=x=>{d(),x!==i.code&&n(x);},h=x=>{let g=e.length-1,k={ArrowDown:()=>Math.min(g,c$1+1),ArrowUp:()=>Math.max(0,c$1-1),Home:()=>0,End:()=>g};k[x.key]?(x.preventDefault(),l(k[x.key]())):x.key==="Enter"||x.key===" "?(x.preventDefault(),I(e[c$1].code)):(x.key==="Escape"||x.key==="Tab")&&(x.preventDefault(),x.stopPropagation(),d());};return jsxs("div",{ref:m,className:cn$1("novapay:relative",o),children:[jsxs("button",{ref:y,type:"button","aria-haspopup":"listbox","aria-expanded":r,"aria-controls":r?`${p}-list`:void 0,className:cn$1(Tt,nt,"novapay:text-[11px]"),onClick:()=>r?d():v(),onKeyDown:x=>{x.key==="ArrowDown"&&!r&&(x.preventDefault(),v());},children:[jsx(rr,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),jsx("span",{children:i.short}),jsxs("span",{className:"novapay:sr-only",children:[", ",c(t.language.button,{language:i.name})]}),jsx(rn,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"})]}),r&&jsxs("div",{className:"tuwa-scanlines 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-strong)] novapay:bg-[var(--tuwa-bg-primary)] novapay:p-1.5",children:[jsx("span",{id:`${p}-title`,className:cn$1(Be,"novapay:block novapay:px-2.5 novapay:py-1"),children:t.language.title}),jsx("ul",{ref:f,id:`${p}-list`,role:"listbox",tabIndex:-1,"aria-labelledby":`${p}-title`,"aria-activedescendant":`${p}-${e[c$1].code}`,onKeyDown:h,className:cn$1("novapay:m-0 novapay:flex novapay:list-none novapay:flex-col novapay:gap-0.5 novapay:p-0",se),children:e.map((x,g)=>{let k=x.code===i.code;return jsxs("li",{id:`${p}-${x.code}`,role:"option","aria-selected":k,lang:x.code,onClick:()=>I(x.code),onPointerMove:()=>l(g),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]",g===c$1&&"novapay:bg-[var(--tuwa-bg-muted)]","novapay:text-[var(--tuwa-text-primary)]",k&&"novapay:font-semibold"),children:[jsx("span",{"aria-hidden":true,className:cn$1($,"novapay:w-5 novapay:text-[11px]"),children:x.short}),jsx("span",{children:x.name}),k&&jsx(DrawnCheck,{className:"novapay:ml-auto novapay:h-3.5 novapay:w-3.5 novapay:text-[var(--tuwa-text-accent)]"})]},x.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:a?t.language.noteAfterPaid:t.language.note})]})]})}var fs=(e,t)=>kr(e.screen,{withDetails:t})??(e.screen==="paid"?Cr({withDetails:t}):null);function vs(e,t,a){let n=e.customization.components?.Stepper??ns;return jsx(n,{steps:t,labels:e.labels,className:cn$1(a,Z(e,"stepper")),stepClassName:(o,r)=>Z(e,"step",{step:o,index:r})})}function hs({title:e,withDetails:t}){let a=E(),{labels:n,locale:o,setLocale:r,close:s,state:i}=a,c=a.display==="page",l=a.customization.config?.showSteps===false?null:fs(a,t),p=Z(a,"header"),m=a.customization.handlers?.onLocaleChange,y=jsxs("div",{className:"novapay:ml-auto novapay:flex novapay:shrink-0 novapay:items-center novapay:gap-2",children:[jsx(ys,{locale:o,labels:n,receiptIssued:!!i.receiptUrl,onSelect:f=>{m?m({locale:f,proceed:()=>r(f)}):r(f);}}),s&&jsx("button",{type:"button","aria-label":n.common.close,onClick:s,className:Tt,children:jsx(CloseIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"})})]});return jsxs(Fragment$1,{children:[jsxs("header",{className:cn$1("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",c&&"novapay-page-header",p),children:[l?vs(a,l):e&&jsx("h2",{className:cn$1($,"novapay:m-0 novapay:flex-1 novapay:text-[15px] novapay:font-bold"),children:e}),y]}),jsxs("header",{className:cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-4 novapay:pb-3 novapay:pt-1.5 novapay:sm:hidden",c&&"novapay-page-header-phone",p),children:[jsx(xa,{compact:true}),y]})]})}function xs({withDetails:e}){let t=E();if(t.customization.config?.showSteps===false)return null;let a=fs(t,e);return a?vs(t,a,"novapay:px-4 novapay:pt-3.5"):null}var rp=new Set(["paid","needs_review","refunded","partially_refunded"]);function fn(){let{state:e,locale:t,adapterFor:a}=E(),o=(e.invoiceStatus&&rp.has(e.invoiceStatus)?e.checkout?.quote:null)??e.quote,r=o?xe(o.instructions):null,s=e.txHash??e.txKey,i=o?.payer?parseCaip10AccountId(o.payer)?.address:void 0,c=(e.checkout?.invoice.payments??[]).map(l=>{let p=l.chainId?vt(l.chainId):null;return {txKey:l.txKey,amount:l.symbol&&l.decimals!==null?`${ue(l.amount,l.decimals,t)} ${l.symbol}`:null,at:Date.parse(l.at),explorerUrl:p&&l.chainId?a(p)?.explorerUrl?.({chainId:l.chainId,txKey:l.txKey}):void 0}});return {network:r?ve(r):null,amount:o?`${ue(o.amountToSend,o.decimals,t)} ${o.instructions.symbol}`:null,paidAmount:o?`${ue(o.amountDue===o.cryptoAmountExpected?o.amountToSend:o.cryptoAmountExpected,o.decimals,t)} ${o.instructions.symbol}`:null,txKey:s,lastOfParts:o?o.amountDue!==o.cryptoAmountExpected:false,transfers:c,explorerUrl:o&&r&&s?a(o.instructions.family)?.explorerUrl?.({chainId:r,txKey:s}):void 0,from:i?shortAddress(i):null,fromAddress:i??null,fromUrl:o&&r&&i?a(o.instructions.family)?.explorerAddressUrl?.({chainId:r,address:i}):void 0}}var io=new WeakMap,cp=500;function kt(e,t){let a=io.get(e)?.get(t);if(a)return a.leftAt===null||Date.now()-a.leftAt<cp?a.value:void 0}function qn(e,t,a,n=true){let o=io.get(e)??new Map;o.set(t,{value:a,leftAt:n?Date.now():null}),io.set(e,o);}function Ue(e,t){let{store:a}=E(),[n,o]=useState(()=>kt(a,e)??t);return useEffect(()=>(o(t),qn(a,e,t,false),()=>qn(a,e,t)),[a,e,t]),n}var gs="actionKind",pp="actionLabel",ka="novapay-action-arrives";function vn(e,t){let{store:a,customization:n}=E(),[o]=useState(()=>e==="primary"&&kt(a,gs)==="secondary"&&!n.config?.animation?.disabled);return Ue(gs,e??"none"),{label:Ue(pp,e?t:"")||t,arrives:o}}function ws({tone:e,children:t}){let a=E(),n=Ue("chipTone",e),o=Ue("chipLabel",t);return jsx("span",{className:cn$1(nn,"novapay:transition-colors novapay:duration-300 novapay:motion-reduce:transition-none",an[n],Z(a,"statusChip",{tone:e})),children:jsx(MorphText,{children:o})})}var co=16,ks=["................",".....######.....","...##########...","..############..",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.",".##############.","..############..","...##########...",".....######.....","................"],dp=["................","................","................","................","................","..........##....",".........###....","....##..###.....","....######......",".....####.......","......##........","................","................","................","................","................"],yp=["................","................","................","................","....##....##....","....###..###....",".....######.....","......####......","......####......",".....######.....","....###..###....","....##....##....","................","................","................","................"],Ca=e=>e.flatMap((t,a)=>[...t].flatMap((n,o)=>n==="."?[]:[{x:o,y:a}])),Cs=({x:e,y:t})=>`${e},${t}`,Ss=(e,t)=>{let a=new Set(t.map(Cs));return e.filter(n=>!a.has(Cs(n)))},Ps={check:Ss(Ca(ks),Ca(dp)),cross:Ss(Ca(ks),Ca(yp))};var lo="mark",Cp={paid:{mark:"check",tone:"novapay:text-[var(--tuwa-success-icon)]"},failed:{mark:"cross",tone:"novapay:text-[var(--tuwa-error-icon)]"},cancelled:{mark:"cross",tone:"novapay:text-[var(--tuwa-text-secondary)]"}},Sp={unconfirmed:{Icon:ft,tone:"novapay:text-[var(--tuwa-pending-icon)]"},underpaid:{Icon:ft,tone:"novapay:text-[var(--tuwa-pending-icon)]"},needs_review:{Icon:fr,tone:"novapay:text-[var(--tuwa-info-icon)]"},refunded:{Icon:ur,tone:"novapay:text-[var(--tuwa-info-icon)]"},expired:{Icon:sn,tone:"novapay:text-[var(--tuwa-text-secondary)]"},replaced:{Icon:pr,tone:"novapay:text-[var(--tuwa-info-icon)]"},blocked:{Icon:vr,tone:"novapay:text-[var(--tuwa-error-icon)]"}},Ts={waiting:"processing",paid:"succeed",failed:"failed"};function Pp({mark:e,moves:t,className:a}){return jsx("svg",{viewBox:`0 0 ${co} ${co}`,shapeRendering:"crispEdges",fill:"currentColor","aria-hidden":"true",className:cn$1("novapay:block",a),"data-motion":t?"assemble":void 0,children:Ps[e].map(({x:n,y:o})=>jsx("rect",{x:n,y:o,width:1,height:1,"data-px":"",style:pixelFlight(n,o)},`${n}-${o}`))})}function Is({kind:e,className:t}){let a=E(),{store:n,customization:o}=a,{look:r}=useNovaIcons(),s=useRef(null),i=useRef(null),c=!o.config?.animation?.disabled;useLayoutEffect(()=>{let h=s.current,x=h?.querySelector("svg")??null,g=h?.getBoundingClientRect(),k=i.current??kt(n,lo)??null;x&&g&&c&&k&&k.kind!==e&&flyFrom(x,g,k.pixels);let C={kind:e,pixels:x&&g?pixelsOf(x,g):[]};return i.current=C,qn(n,lo,C,false),()=>qn(n,lo,C)},[e,n,c]);let l=o.childCustomizations?.statusVisual,p=e in Ts?Ts[e]:null,m=p&&cn$1(l?.iconClassNames?.icon,l?.iconClassNames?.statusOverrides?.[p]),y=Cp[e],f=Sp[e],v=o.components?.StatusIcon,d=p?void 0:Z(a,"statusIcon",{kind:e}),I;if(!p&&v)I=jsx(v,{kind:e,className:d});else {if(p&&r!=="pixel")return jsx(TxStatusVisual,{isProcessing:e==="waiting",isSucceed:e==="paid",isFailed:e==="failed",...l,className:cn$1(t,l?.className)});e==="waiting"?I=jsx(QuasarLoader,{size:64,accent:"var(--tuwa-pending-icon)",className:cn$1("novapay:text-[var(--tuwa-text-primary)]",m)}):y&&r==="pixel"?I=jsx(Pp,{mark:y.mark,moves:c,className:cn$1(p?"novapay:h-16 novapay:w-16":"novapay:h-12 novapay:w-12",y.tone,m,d)}):y?I=jsx(DrawnCross,{variant:"disc",className:cn$1("novapay:h-12 novapay:w-12",y.tone,d)}):f&&(I=jsx(f.Icon,{"aria-hidden":true,className:cn$1("novapay:h-12 novapay:w-12",f.tone,d),...c&&r==="pixel"?{motion:"assemble"}:{}}));}return jsx("div",{className:cn$1("novapay:flex novapay:justify-center novapay:py-4",t,p&&l?.className),children:jsx("span",{ref:s,className:"novapay:relative novapay:flex novapay:h-16 novapay:w-16 novapay:items-center novapay:justify-center",children:I})})}function Es({children:e,className:t}){let a=Ue("title",e);return jsx("h2",{...It,"aria-label":e,className:cn$1(at,t),children:jsx(MorphText,{wrap:true,children:a})})}function _t({mark:e,tone:t,chip:a,title:n,amount:o,note:r}){let{display:s}=E(),i=s==="page",c=Ue("amount",o??""),l=Ue("note",r??"");return jsxs(Fragment$1,{children:[jsx(Is,{kind:e,className:i?"novapay-page-visual":void 0}),jsxs("div",{className:"novapay:flex novapay:w-full novapay:max-w-sm novapay:flex-col novapay:items-center",children:[jsx(ws,{tone:t,children:a}),jsx(Es,{className:"novapay:mt-2",children:n}),o&&jsx("p",{"aria-label":o,className:cn$1($,"novapay:m-0 novapay:mt-2 novapay:text-2xl novapay:font-bold",i&&"novapay-page-amount"),children:jsx(MorphText,{children:c||o})}),r&&jsx("p",{className:"novapay:m-0 novapay:mt-1 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:jsx(MorphText,{wrap:true,children:l||r})})]})]})}var _s="steps";function hn({state:e}){let{store:t,customization:a}=E(),n=a.childCustomizations,[o]=useState(()=>kt(t,_s)!==void 0),r=Ue(_s,e),s=jsx(TxProgressIndicator,{isProcessing:r==="processing",isSucceed:r==="succeed",isConfirmed:r==="succeed",isFailed:r==="failed",...n?.progressIndicator,className:cn$1("novapay:max-w-sm",n?.progressIndicator?.className)});return o?jsx(AnimatePresence,{initial:false,children:s}):s}var Mp=new Set(["open","underpaid"]);function Os(){let{checkout:e,state:t,labels:a,close:n,customization:o,now:r,handedOverAt:s,display:i}=E(),c$1=i==="page",l=o.childCustomizations,p=fn(),m=e?.invoice.dueAt?Date.parse(e.invoice.dueAt):null,y=t.invoiceStatus??e?.invoice.status,f=ot(t),v=!f&&ht(t,e),d=e!==null&&(f||v)&&Mp.has(y??"")&&m!==null&&r>=m,I=d&&Er({state:t,checkout:e,handedOverAt:s,dueAt:m}),h=Et(t.error)==="retrying",x=vn(n?"secondary":null,a.common.close);return jsxs(Ye,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",c$1&&"novapay-page-status"),children:[jsx(_t,{mark:"waiting",tone:"pending",chip:a.status.pending,title:a.confirm.title,amount:p.amount,note:p.network?c(a.confirm.hint,{network:p.network}):null}),jsx(hn,{state:"processing"}),jsxs(ge,{className:"novapay:max-w-sm",children:[p.network&&jsx(U,{name:a.confirm.network,children:p.network}),p.txKey&&jsx(U,{name:a.confirm.transaction,children:jsx(HashLink,{hash:p.txKey,explorerUrl:p.explorerUrl,variant:"compact",...l?.hashLink})}),p.fromAddress&&jsx(U,{name:a.confirm.from,children:jsx(HashLink,{hash:p.fromAddress,explorerUrl:p.fromUrl,variant:"compact",...l?.hashLink})})]}),jsx("p",{role:"status",className:cn$1("novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",c$1&&"novapay:mt-auto"),children:jsx(MorphText,{wrap:true,children:h?a.outcome.unconfirmedRetrying:d?c(I?a.confirm.afterDeadline:a.confirm.pastDeadline,{merchant:e.merchant.name}):v?a.confirm.invoicePayment:a.confirm.canClose})})]}),n&&jsx(J,{children:jsx(ae,{onClick:n,children:x.label})})]})}function Sa({adapter:e,store:t,wallet:a$1,chainId:n}){let[o,r]=useState("idle"),[s,i]=useState(null),[c,l]=useState(null),p=useRef(0),m=a$1?.address,y=useRef(m);useEffect(()=>{y.current!==m&&(y.current=m,p.current++,r("idle"),i(null),l(null));},[m]);let f=useRef(false);return useEffect(()=>(f.current=false,()=>{f.current=true;}),[]),{step:o,problem:s,request:c,confirm:async({quote:d=false}={})=>{let I=++p.current,h=()=>p.current===I;i(null);let x=e?.signMessage;if(!x||!a$1)return i("unsupported"),false;if(a$1.chainId!==n&&e.switchChain){r("switching");try{await e.switchChain(n);}catch(b){if(h()){let R=b$1(b);i(R==="declined"?"switchDeclined":R==="failed"?"switchFailed":R),r("idle");}return false}if(!h())return false}h()&&r("signing");let g=t.getState().payer,k=null,C=await t.getState().confirmPayer(async(b,R)=>{h()&&l(R);try{return await x({message:b,account:a$1.address,chainId:R.chainId})}catch(_){let F=b$1(_);throw k=F==="declined"&&_ instanceof a&&_.step==="switch"?"switchDeclined":F,_}});return h()&&(i(k),r("idle")),C&&d&&!f.current&&t.getState().payer===g&&await t.getState().requestQuote(),C},dismiss:()=>{p.current++,r("idle"),t.getState().abandonConfirmation();}}}function Ws(e){return e.closest("[data-novapay-scroll]")??null}function Op(e,t){let a=t?.offsetHeight;return a&&a>0?Math.min(e,a):e}function Dp(e){let t=e.offsetHeight;return t>0?Op(t,Ws(e)):null}function Pa(e){let[t,a]=useState(null),[n,o]=useState(null),[r,s]=useState(null);return useEffect(()=>{if(!t)return;let i=Ws(t),c=()=>{if(!e){let m=Dp(t);m!==null&&o(m);}let p=i?.offsetHeight;s(p&&p>0?p:null);};if(c(),typeof ResizeObserver>"u")return;let l=new ResizeObserver(c);return e||l.observe(t),i&&l.observe(i),()=>l.disconnect()},[t,e]),!e||n===null?[a,null]:[a,r?Math.min(n,r):n]}var Wp=new Set(["evm:coinbase","evm:baseaccount","evm:porto"]);function Na(e){return !!(e&&Wp.has(e.connectorType.toLowerCase()))}function qs(e,t){return e==="required"||e==="confirming"?true:e==="unless_relayed"&&t!=="relay"}async function Us(e,t){let{payerProof:a}=e.getState();if(a==="required"||a==="confirming")return t(true),null;t(false);let n=await e.getState().requestQuote();return !n&&e.getState().error?.code==="payer_proof_required"&&t(true),n}var qp=new Set(["payer_chain_mismatch","too_many_payers","payer_is_recipient"]);function fo(e){let t=e?.code;return t!==void 0&&(t.startsWith("payer_proof_")||qp.has(t))}var Up=new Set(["rate_limited","request_failed","origin_required","invoice_not_payable"]);function Un(e){let t=e?.code;return fo(e)||t!==void 0&&Up.has(t)}function Ta(e,t,a,n){if(t==="declined")return c(a.payerProof.declined,n);if(t==="switchDeclined")return c(a.payerProof.switchDeclined,n);if(t==="unsupported")return c(a.payerProof.unsupported,n);if(t==="wrongNetwork"||t==="switchFailed")return c(a.payerProof.wrongNetwork,n);if(t==="notAuthorized")return c(a.pay.notAuthorized,n);if(t==="alreadyPending")return c(a.walletPrompt.stillWaiting,n);if(t)return c(a.payerProof.failed,n);switch(e?.code){case void 0:case "payer_proof_required":return null;case "payer_proof_declined":return c(a.payerProof.declined,n);case "payer_proof_invalid":return a.payerProof.invalid;case "payer_proof_unavailable":return a.payerProof.unavailable;case "payer_chain_mismatch":return c(a.payerProof.wrongNetwork,n);case "too_many_payers":return c(a.payerProof.tooManyWallets,n);case "payer_is_recipient":return a.method.payerIsRecipient;case "rate_limited":return a.method.rateLimited;case "request_failed":return a.pay.noAnswer;default:return a.error.generic}}function $n({kind:e,walletName:t,walletId:a,walletIcon:n,amount:o,merchant:r,network:s,to:i,priceTime:c$1,onRetry:l,text:p,details:m,hint:y,onCancel:f,stepHeight:v}){let{labels:d,display:I}=E(),h=useId(),x=useRef(null);useEffect(()=>x.current?.focus(),[e]);let[g]=useState(()=>typeof document>"u"?null:document.activeElement);useEffect(()=>()=>{let b=g?.ownerDocument;if(!g||!b||g===b.body||!g.isConnected)return;let R=b.activeElement;R&&R!==b.body&&!R.contains(g)||g.focus();},[g]);let k={wallet:t,amount:o,merchant:r,network:s},C=e==="sign"||e==="proof"?d.walletPrompt.signIn:e==="switch"?d.walletPrompt.switchIn:e==="submitting"?d.walletPrompt.submitting:d.walletPrompt.confirmIn;return jsxs("section",{"aria-labelledby":h,style:v?{"--novapay-step-height":`${v}px`}:void 0,className:cn$1("tuwa-scanlines novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:justify-center-safe novapay:gap-3 novapay:bg-[var(--tuwa-bg-primary)] novapay:px-6 novapay:py-5 novapay:text-center",v&&(I==="page"?"novapay:min-h-[var(--novapay-step-height)]":"novapay:max-sm:min-h-[var(--novapay-step-height)]")),children:[jsx(ua,{walletId:a,walletIcon:n}),jsx("h2",{id:h,ref:x,tabIndex:-1,className:at,children:c(C,k)}),(e==="sign"||e==="confirm"||e==="proof")&&jsxs(Fragment$1,{children:[jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:p??c(e==="confirm"?d.walletPrompt.confirmText:d.walletPrompt.signText,k)}),y&&jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:y}),jsxs("div",{className:"novapay:flex novapay:w-full novapay:max-w-xs novapay:flex-col novapay:gap-1.5 novapay:text-left",children:[jsx("span",{className:Be,children:jsx(we,{label:d.walletPrompt.check,values:k})}),jsx(ge,{children:m?m.map(b=>jsx(U,{name:b.name,children:b.value},b.name)):jsxs(Fragment$1,{children:[jsx(U,{name:d.walletPrompt.amount,children:o}),jsx(U,{name:d.walletPrompt.to,children:i}),jsx(U,{name:d.walletPrompt.network,children:s}),c$1&&jsx(U,{name:d.walletPrompt.priceLocked,children:c$1})]})})]}),l?jsxs("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[d.walletPrompt.notOpened," ",jsx(gt,{onClick:l,children:d.walletPrompt.tryAgain})]}):jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(d.walletPrompt.stillWaiting,k)})]}),e!=="submitting"&&jsx(ae,{onClick:f,className:"novapay:max-w-xs",children:d.walletPrompt.cancel})]})}function Gs(){let{checkout:e,state:t,store:a,labels:n,locale:o,wallet:r,adapterFor:s,connectWallet:i,setConfirmWallet:c$1}=E(),l=e?.methods.find(V=>V.id===t.methodId)??null,p=l?je(l):null,m=Sa({adapter:p?s(p):void 0,store:a,wallet:r,chainId:l?.chainId??""}),[y,f]=useState(false),v=useRef(null),d=m.step!=="idle",[I,h]=Pa(d),x=useRef(false);if(useEffect(()=>{x.current&&!d&&v.current?.querySelector("[data-novapay-heading]")?.focus(),x.current=d;},[d]),!e||!l)return null;let g=e.merchant.name,k=r?.name??"",C=ve(l.chainId),b=e.invoice.number??e.invoice.id,R=e.invoice.totalMinor?`${ye(Re(e.invoice.totalMinor),o)} ${e.invoice.currency}`:null,_=Na(r),F=t.phase==="quoting",D=d,A=Ta(!F&&Un(t.error)?t.error:null,m.problem,n,{wallet:k,network:C,merchant:g}),N={wallet:k,invoice:b,merchant:g},w=De(r,l),re=()=>{w&&t.payer!==w&&a.getState().setPayer(w),m.confirm({quote:true});},P=()=>{c$1(false),a.getState().clearError();},H=w?t.confirmedWallets?.find(V=>!ln(V,w)):void 0;return jsxs("div",{ref:v,className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{ref:I,inert:d,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",d&&"novapay:hidden"),children:[jsxs(de,{title:n.payerProof.title,subtitle:n.payerProof.text,children:[r&&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:r.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:k}),jsx("span",{className:cn$1($,"novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.walletLine,{address:shortAddress(r.address),network:ve(r.chainId)})})]}),jsx("button",{type:"button","aria-label":n.pay.changeWallet,onClick:()=>{i(l)||f(true);},className:on,children:n.pay.change})]}),jsx(pn,{children:n.payerProof.summary}),jsxs(ge,{children:[jsx(U,{name:n.payerProof.invoice,children:b}),jsx(U,{name:n.payerProof.merchant,children:g}),R&&jsx(U,{name:n.payerProof.amount,children:R}),r&&jsx(U,{name:n.payerProof.wallet,children:jsx(We,{hash:r.address,chainId:r.chainId})})]}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.payerProof.why}),_&&jsxs("p",{className:"novapay:m-0 novapay:flex novapay:items-start novapay:gap-2 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[jsx(dr,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),jsx("span",{children:c(n.payerProof.passkey,N)})]}),r&&p==="eip155"&&r.chainId!==l.chainId&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(n.payerProof.willSwitch,{current:ve(r.chainId),network:C})}),H&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",children:c(n.payerProof.alreadyConfirmed,{wallet:shortAddress(At(H))})}),A&&jsx(Q,{children:A}),y&&jsx(Q,{children:n.pay.connectUnavailable})]}),jsxs(J,{children:[jsx(ee,{busy:D||F,onClick:re,children:F?n.method.quoting:D?jsx(we,{label:n.payerProof.waiting,values:N}):jsx(we,{label:n.payerProof.confirm,values:N})}),jsx(ae,{disabled:F,onClick:P,children:(t.invoiceStatus??e?.invoice.status)==="underpaid"?n.pay.backFromRest:n.pay.back}),jsx(qe,{children:_?n.payerProof.noteSmart:n.payerProof.note})]})]}),d&&jsx($n,{kind:m.step==="switching"?"switch":"proof",walletName:k,walletId:r?.walletId??"",walletIcon:r?.icon,amount:R??"",merchant:g,network:C,to:"",priceTime:null,text:c(_?n.payerProof.promptPasskey:n.payerProof.promptText,N),details:[...m.request?[{name:n.payerProof.site,value:m.request.domain}]:[],{name:n.payerProof.invoice,value:b},{name:n.payerProof.merchant,value:g},...R?[{name:n.payerProof.amount,value:R}]:[]],hint:m.request?c(n.payerProof.signInRequest,{wallet:k,site:m.request.domain}):void 0,onRetry:re,onCancel:m.dismiss,stepHeight:h})]})}var Zp=/^0x[0-9a-fA-F]{64}$/,Jp=/^[1-9A-HJ-NP-Za-km-z]{64,90}$/;function Vn(){let{store:e,state:t,checkout:a,labels:n,wallet:o}=E(),[r,s]=useState(false),[i,c]=useState(""),[l,p]=useState(false),[m,y]=useState(null),f=useId(),v=t.quote??a?.quote;if(!v)return null;let d=n.outcome;if(!r)return jsx(gt,{onClick:()=>s(true),children:d.nameHash});let I=async h=>{h.preventDefault();let x=i.trim();if(!(v.instructions.family==="solana"?Jp:Zp).test(x))return y(d.nameHashInvalid);y(null),p(true);let k=await e.getState().submit({txKey:x,...o?{from:o.address}:{}});p(false),k||y(d.nameHashRefused);};return jsxs("form",{onSubmit:h=>{I(h);},className:"novapay:flex novapay:w-full novapay:max-w-sm novapay:flex-col novapay:gap-2 novapay:text-left",children:[jsx("label",{htmlFor:f,className:"novapay:text-xs novapay:font-semibold",children:d.nameHashField}),jsx("input",{id:f,value:i,autoComplete:"off",spellCheck:false,"aria-invalid":m?true:void 0,onChange:h=>c(h.target.value),className:cn$1($,"novapay:box-border novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",se)}),m&&jsx(Q,{children:m}),jsx(ae,{type:"submit",disabled:l||!i.trim(),children:d.nameHashSend})]})}var Qs=e=>e?.code==="payment_unconfirmed",nu={nonceSpent:"unconfirmedNonceSpent",unmined:"unconfirmedUnmined",rechecked:"unconfirmedNote",retrying:"unconfirmedRetrying",notReceived:"unconfirmedNotReceived",contact:"unconfirmedContact",closed:"unconfirmedClosed",takenElsewhere:"unconfirmedTakenElsewhere",settlementRetrying:"unconfirmedSettlementRetrying",settlementFailed:"unconfirmedSettlementFailed",invoiceFull:"unconfirmedInvoiceFull"},js=new Set(["nonceSpent","unmined","notReceived","contact","closed","takenElsewhere","settlementRetrying","settlementFailed","invoiceFull"]),Ys=new Set(["nonceSpent","takenElsewhere","settlementRetrying","settlementFailed","invoiceFull"]),Zs={unconfirmed:{tone:"pending",label:"unconfirmed"},underpaid:{tone:"pending",label:"underpaid"},needs_review:{tone:"neutral",label:"review"},refunded:{tone:"neutral",label:"refunded"},expired:{tone:"neutral",label:"expired"},cancelled:{tone:"neutral",label:"cancelled"},replaced:{tone:"neutral",label:"replaced"},blocked:{tone:"error",label:"blocked"}},te=({children:e,muted:t})=>jsx("p",{className:cn$1("novapay:m-0 novapay:max-w-sm novapay:text-xs",t?"novapay:text-[var(--tuwa-text-secondary)]":"novapay:text-[var(--tuwa-text-primary)]"),children:e});function ho(){let e=E(),{checkout:t,labels:a,onContact:n}=e;if(!t)return null;let o=jsx(we,{label:a.outcome.contact,values:{merchant:t.merchant.name}}),r=cn$1(ra,Z(e,"secondaryButton"));if(n)return jsx("button",{type:"button",onClick:n,className:r,children:o});let s=Br(t.merchant,c(a.outcome.contactSubject,{number:t.invoice.number??t.invoice.id}));return s?jsx("a",{href:s,target:s.startsWith("mailto:")?void 0:"_blank",rel:"noopener noreferrer",className:r,children:o}):null}function Js({kind:e}){let[t,a]=useState(false),n=E(),{checkout:o,state:r,store:s,labels:i,locale:c$1,now:l,wallet:p,connectWallet:m,openInvoice:y,qrShown:f,paymentSent:v,adapterFor:d,lockPrice:I}=n;if(!o)return null;let h=o.merchant.name,x=r.quote,g=o.methods.find(P=>P.id===(r.methodId??x?.methodId)),k=o.invoice.dueAt&&!o.invoice.closed?new Intl.DateTimeFormat(c$1,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(o.invoice.dueAt)):null,C=(P,H=x)=>H?`${ue(P,H.decimals,c$1)} ${H.instructions.symbol}`:P,b=Et(r.error),R=P=>c(i.outcome[nu[P]],{merchant:h}),_=r.followingUntil??null,F=_?jsx(te,{muted:true,children:c(i.outcome.followingUntil,{time:new Intl.DateTimeFormat(c$1,{timeStyle:"short"}).format(Date.parse(_))})}):null,D=Fr(r,o),A=P=>{if(!D||P!=="mismatch"&&(!P||!js.has(P)))return null;let H=x??o.quote,V=H?xe(H.instructions):null,be=H&&V?d(H.instructions.family)?.explorerUrl?.({chainId:V,txKey:D}):void 0;return jsx(Ye,{children:jsx(ge,{className:"novapay:w-full novapay:max-w-sm",children:jsx(U,{name:i.confirm.transaction,children:jsx(HashLink,{hash:D,explorerUrl:be,variant:"compact",...n.customization.childCustomizations?.hashLink})})})})},N,w=null,re=null;switch(e){case "unconfirmed":{if(N=i.outcome.unconfirmedTitle,xt(r.error))w=jsxs(Fragment$1,{children:[jsx(te,{children:$t(r.error,i,h)}),A("mismatch")]});else if(b&&Ys.has(b))w=jsxs(Fragment$1,{children:[jsx(te,{children:R(b)}),A(b),b==="nonceSpent"&&jsx(Vn,{})]});else {let V=b??"contact";w=jsxs(Fragment$1,{children:[jsx(te,{children:i.outcome.unconfirmedText}),jsx(te,{muted:true,children:R(V)}),A(V),jsx(Vn,{})]});}let{payAgain:P}=s.getState(),H=r.invoiceStatus??o.invoice.status;P&&(H==="open"||H==="underpaid")&&!(b&&Ys.has(b))&&(re=xt(r.error)?r.error.unmatched===true?jsx(ee,{onClick:()=>P(),children:i.pay.payAgain}):jsx(ae,{onClick:()=>P(),children:i.pay.payAgain}):jsx(ae,{onClick:()=>P(),children:i.outcome.unconfirmedPayAgain}));break}case "underpaid":{let P=x??o.quote,H=o.invoice.amountPaid,V=Dr(P,H);N=i.outcome.underpaidTitle;let be=P&&H&&jsx(te,{children:c(i.outcome.underpaidText,{received:C(H,P),total:C(P.cryptoAmountExpected,P)})});if(o.invoice.status==="underpaid"&&o.invoice.restPayable===false||r.error?.code==="method_not_found"){w=jsxs(Fragment$1,{children:[be,jsx(te,{children:i.outcome.underpaidClosed}),k&&jsx(te,{children:c(i.outcome.underpaidClosedRefund,{merchant:h,date:k})})]});break}let Ne=cn(P,l,i,h,c$1,i.outcome.underpaidRateEnded),he=o.methods.find(He=>He.id===P?.methodId)??g??o.methods[0],pe=r.error?.code==="payer_blocked"?c(i.outcome.underpaidBlocked,{merchant:h}):r.error&&r.error.code!=="payer_mismatch"?la(r.error,i,h):null;w=jsxs(Fragment$1,{children:[be,P&&V&&jsx(te,{children:c(i.outcome.underpaidRest,{rest:C(V,P),network:ve(xe(P.instructions))})}),k&&jsx(te,{muted:true,children:c(i.outcome.underpaidNote,{merchant:h,date:k})}),Ne&&jsx(te,{muted:true,children:Ne}),pe&&jsx(Q,{children:pe})]});let L=he&&p?De(p,he):null,B=r.error?.code==="payer_mismatch"?r.error.originWallet??null:null,q=B??o.invoice.originWallet??P?.payer??null,ne=q?At(q):void 0,ce=L?parseCaip10AccountId(L)?.address:void 0,ie=P?.payer!==null&&!!(ne&&(ce?!ln(ce,ne):B)),Ce=()=>{if(!he)return;if(ie)return void m(he);let He=P?.payer===null?null:L;if(P?.payer!==null&&!He)return void m(he);r.methodId!==he.id&&s.getState().selectMethod(he.id),s.getState().setPayer(He),I();};ie&&ne&&(w=jsxs(Fragment$1,{children:[w,jsx(te,{children:c(i.outcome.payRestFirstWallet,{wallet:shortAddress(ne)})})]})),re=jsx(ee,{busy:r.phase==="quoting",onClick:Ce,children:i.outcome.payRest});break}case "needs_review":{N=c(i.outcome.reviewTitle,{merchant:h});let P=o.invoice.review?.reason,H=P==="late"?i.outcome.reviewLate:P==="overpaid"?i.outcome.reviewOverpaid:P==="quote_expired"?i.outcome.reviewQuoteExpired:i.outcome.reviewScreening;w=jsxs(Fragment$1,{children:[jsx(te,{children:c(H,{merchant:h})}),jsx(te,{muted:true,children:i.outcome.reviewNote})]});break}case "refunded":{N=i.outcome.refundedTitle;let P=o.invoice.refundedTotalMinor??o.invoice.totalMinor;w=P&&jsx(te,{children:c(i.outcome.refundedText,{merchant:h,amount:ye(Re(P),c$1),currency:o.invoice.currency})});break}case "expired":{N=i.outcome.expiredTitle;let P=Wr(o.invoice.amountPaid),H=x??o.quote,V=ot(r)||ht(r,o),be=Qs(r.error)||b==="settlementFailed"||b==="settlementRetrying",Pe=be||!V&&Ht(r,o),Ne=!Pe&&b==="closed",he=!Pe&&!Ne&&(V||v),pe=!Pe&&!Ne&&!he&&xt(r.error),L=he||Pe||Ne||pe||f,B=be?b??"contact":"rechecked";w=jsxs(Fragment$1,{children:[P?jsxs(Fragment$1,{children:[k&&jsx(te,{children:H?c(i.outcome.expiredPartText,{date:k,amount:C(P,H)}):c(i.outcome.expiredPartNoAmount,{date:k})}),!k&&H&&jsx(te,{children:c(i.outcome.closedPartText,{merchant:h,amount:C(P,H)})}),jsx(te,{children:c(i.outcome.expiredPartRefund,{merchant:h})})]}):!L&&k&&jsx(te,{children:c(i.outcome.expiredText,{date:k,merchant:h})}),Pe?jsxs(Fragment$1,{children:[jsx(te,{children:B==="rechecked"?c(i.outcome.expiredUnconfirmed,{merchant:h}):R(B)}),A(B),B==="nonceSpent"&&jsx(Vn,{})]}):Ne?jsxs(Fragment$1,{children:[jsx(te,{children:R("closed")}),A("closed")]}):he?jsxs(Fragment$1,{children:[jsx(te,{children:c(i.outcome.expiredWhileConfirming,{merchant:h})}),F]}):pe?jsxs(Fragment$1,{children:[jsx(te,{children:$t(r.error,i,h)}),A("mismatch")]}):f?jsx(te,{children:c(i.outcome.expiredAfterQr,{merchant:h})}):jsx(te,{muted:true,children:i.outcome.expiredNote})]});break}case "cancelled":{if(N=i.outcome.cancelledTitle,b&&js.has(b)){w=jsxs(Fragment$1,{children:[jsx(te,{children:R(b)}),A(b),b==="nonceSpent"&&jsx(Vn,{})]});break}let P=Qs(r.error)||b==="closed"||ot(r)||ht(r,o)||Ht(r,o)||v,H=!P&&xt(r.error),V=P?c(i.outcome.cancelledWhilePaying,{merchant:h}):H?$t(r.error,i,h):c(f?i.outcome.cancelledAfterQr:i.outcome.cancelledText,{merchant:h});w=jsxs(Fragment$1,{children:[jsx(te,{children:V}),H&&A("mismatch"),b==="retrying"&&jsx(te,{muted:true,children:i.outcome.unconfirmedRetrying}),P&&F]});break}case "replaced":{let P=o.invoice.replacedBy,H=P?.number??"";if(N=c(i.outcome.replacedTitle,{merchant:h}),w=jsxs(Fragment$1,{children:[jsx(te,{children:c(i.outcome.replacedText,{number:H})}),jsx(te,{muted:true,children:i.outcome.replacedPaid})]}),P?.checkoutToken){let V=P.checkoutToken;re=jsx(ee,{onClick:()=>y(V),children:jsx(we,{label:i.outcome.openReplacement,values:{number:H}})});}break}case "blocked":{N=i.outcome.blockedTitle;let P=r.payer?parseCaip10AccountId(r.payer)?.address:void 0;w=jsxs(Fragment$1,{children:[jsx(te,{children:r.error?.code==="payer_not_expected"?i.method.payerNotExpected:c(i.outcome.blockedText,{merchant:h})}),P&&jsx(We,{hash:P,chainId:x??o.quote?xe((x??o.quote).instructions):null})]}),g&&(re=jsx(ee,{onClick:()=>{m(g)||a(true);},children:i.outcome.useAnotherWallet}));break}}return jsxs(Fragment$1,{children:[jsxs("section",{role:e==="blocked"?"alert":void 0,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",n.display==="page"&&"novapay-page-status"),children:[jsx(_t,{mark:e,tone:Zs[e].tone,chip:i.status[Zs[e].label],title:N}),w,t&&jsx(Q,{children:i.pay.connectUnavailable})]}),jsxs(J,{children:[re,jsx(ho,{})]})]})}function Gn({children:e,className:t}){let{store:a,customization:n}=E(),[o]=useState(()=>kt(a,"title")!==void 0),r=o&&!n.config?.animation?.disabled;return jsx("div",{className:cn$1("novapay:w-full",r&&"novapay-status-reveal",t),children:e})}function ei(){let e=E(),{checkout:t,state:a,labels:n,adapterFor:o,payAfterFailure:r,customization:s,display:i}=e,c$1=fn(),l=vn("primary",n.pay.payAgain);if(!t||!a.error)return null;let p=i==="page",m=s.childCustomizations,y=ca(a.error)??c$1.txKey,f=a.quote??t.quote,v=f?xe(f.instructions):null,d=y===c$1.txKey?c$1.explorerUrl:f&&v&&y?o(f.instructions.family)?.explorerUrl?.({chainId:v,txKey:y}):void 0;return jsxs(Ye,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",p&&"novapay-page-status"),children:[jsx(_t,{mark:"failed",tone:"error",chip:n.status.failed,title:n.failed.title,amount:c$1.amount,note:c$1.network?c(n.failed.summary,{network:c$1.network}):null}),jsx(hn,{state:"failed"}),(c$1.network||y||c$1.fromAddress)&&jsxs(ge,{className:"novapay:max-w-sm",children:[c$1.network&&jsx(U,{name:n.confirm.network,children:c$1.network}),y&&jsx(U,{name:n.confirm.transaction,children:jsx(HashLink,{hash:y,explorerUrl:d,variant:"compact",...m?.hashLink})}),c$1.fromAddress&&jsx(U,{name:n.confirm.from,children:jsx(HashLink,{hash:c$1.fromAddress,explorerUrl:c$1.fromUrl,variant:"compact",...m?.hashLink})})]}),jsx(Gn,{className:"novapay:max-w-sm",children:jsx("p",{role:"status",className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-primary)]",children:Mn(a.error,n,c$1.network??void 0)})})]}),jsxs(J,{children:[jsx(ee,{onClick:r,className:l.arrives?ka:void 0,children:l.label}),jsx(Gn,{children:jsx(ho,{})})]})]})}function ai({onStay:e,onLeave:t}){let{checkout:a,labels:n,locale:o}=E(),r=useId(),s=useId(),i=useRef(null),c$1=a?.invoice.dueAt?new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(Date.parse(a.invoice.dueAt)):null;return jsx(Dialog,{open:true,onOpenChange:l=>{l||e();},children:jsxs(DialogContent,{role:"alertdialog","aria-labelledby":r,"aria-describedby":s,onOpenAutoFocus:l=>{l.preventDefault(),i.current?.focus();},className:"novapay:w-full novapay:sm:w-[24rem]",children:[jsx(DialogTitle,{"aria-hidden":true,className:"novapay:sr-only",children:n.leave.title}),jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-3 novapay:p-5 novapay:text-center",children:[jsx("h2",{id:r,ref:i,tabIndex:-1,className:at,children:n.leave.title}),jsx("p",{id:s,className:"novapay:m-0 novapay:text-xs",children:c$1?c(n.leave.text,{date:c$1}):n.leave.textNoDate}),jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.leave.price}),jsx(ee,{onClick:e,children:n.leave.stay}),jsx(ae,{onClick:t,children:n.leave.leave})]})]})})}function xn({label:e,items:t,value:a,getKey:n,onChange:o,children:r,className:s,itemClassName:i}){let c=useRef([]),l=Math.max(0,t.findIndex(m=>n(m)===a)),p=(m,y)=>{let f=t.length-1,v={ArrowRight:y+1,ArrowDown:y+1,ArrowLeft:y-1,ArrowUp:y-1,Home:0,End:f}[m.key];if(v===void 0)return;m.preventDefault();let d=v<0?f:v>f?0:v;o(n(t[d])),c.current[d]?.focus();};return jsx("div",{role:"radiogroup","aria-label":e,className:s,children:t.map((m,y)=>{let f=n(m),v=f===a;return jsx("button",{ref:d=>{c.current[y]=d;},type:"button",role:"radio","aria-checked":v,tabIndex:y===l?0:-1,onClick:()=>o(f),onKeyDown:d=>p(d,y),className:cn$1("novapay:cursor-pointer novapay:rounded-[var(--tuwa-rounded-corners)] novapay:text-left novapay:text-[var(--tuwa-text-primary)] novapay:transition-colors","novapay:border",v?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]",se,i?.(v,m)),children:r(m,v)},f)})})}function zn({tone:e,children:t}){return jsx("span",{className:cn$1(nn,an[e]),children:t})}function ii({method:e,labels:t}){let a=Xa(e);return a?a.kind==="discount"?jsx(zn,{tone:"success",children:c(t.method.discount,{percent:a.percent})}):jsx(zn,{tone:"neutral",children:c(t.method.markup,{percent:a.percent})}):null}function gu({selected:e}){return jsx("span",{"aria-hidden":true,className:cn$1("novapay:h-3.5 novapay:w-3.5 novapay:shrink-0 novapay:rounded-[var(--tuwa-rounded-full)] novapay:box-border",e?"novapay:border-4 novapay:border-[var(--tuwa-text-accent)]":"novapay:border novapay:border-[var(--tuwa-text-secondary)]")})}function bu({labels:e,terms:t,refundPolicy:a}){let n=(r,s)=>jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",se),children:s},r),o=t&&a?d(e.method.agreeBoth,{terms:n(t,e.summary.terms),refundPolicy:n(a,e.summary.refundPolicy)}):t||a?d(e.method.agreeOne,{link:t?n(t,e.summary.terms):n(a,e.summary.refundPolicy)}):null;return o?jsx("p",{className:"novapay:m-0 novapay:text-center novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o}):null}function ci(){let e=E(),{checkout:t,state:a,store:n,labels:o,wallet:r,payWith:s,setPayWith:i,payUrl:c$1,connectWallet:l,adapterFor:p,setHandoff:m,lockPrice:y}=e,{TokenOption:f,NetworkOption:v}=e.customization.components??{},d=useMemo(()=>t?.methods??[],[t]),I=useMemo(()=>Sr(d,r?.chainId),[d,r?.chainId]),h=d.find(L=>L.id===a.methodId)??null,x=I.find(L=>L.symbol===h?.symbol)??null,g=h?br(h,c$1):false,k=h?je(h):null,b=[...(k?!!p(k):false)?["wallet"]:[],...g?["qr"]:[]],R=b.includes(s)?s:b[0]??null,[_,F]=useState(false),D=useId(),A=useId(),N=useEffectEvent(()=>{let L=I[0]?.methods[0];!a.methodId&&L&&n.getState().selectMethod(L.id,{keepError:true});});if(useEffect(()=>N(),[I]),!t)return null;if(d.length===0)return jsx(de,{title:o.method.title,children:jsx(Q,{children:o.method.noMethods})});let w=e.display==="page",re=I.reduce((L,B)=>B.methods.length>L.methods.length?B:L,I[0]),P=a.phase==="quoting",H=t.consent??null,V=!!a.consentGiven,be=!!(H?.required&&!V),Pe=e.customization.handlers,Ne=L=>{let B=()=>n.getState().selectMethod(L.id);Pe?.onMethodSelect?Pe.onMethodSelect({method:L,select:B}):B();},he=async()=>{if(!h||!R)return;if(F(false),R==="qr"){if(s!=="qr"&&i("qr"),k!=="solana"&&!h.ownAddress)return m(true);n.getState().setPayer(null),await n.getState().requestQuote();return}s!=="wallet"&&i("wallet");let L=De(r,h);if(!L)return F(!l(h));n.getState().setPayer(L),await y();},pe=L=>jsxs(Fragment$1,{children:[jsx(pn,{children:jsx(we,{label:o.method.network,values:{symbol:L.symbol}})}),jsx(xn,{label:c(o.method.network,{symbol:L.symbol}),items:L.methods,value:h?.id??null,getKey:B=>B.id,onChange:B=>{let q=L.methods.find(ne=>ne.id===B);q&&Ne(q);},className:w&&L.methods.length>1?"novapay:grid novapay:grid-cols-1 novapay:gap-1.5 novapay:@min-[520px]:grid-cols-2":"novapay:flex novapay:flex-col novapay:gap-1.5",itemClassName:(B,q)=>cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-3 novapay:py-2.5",Z(e,"networkOption",{method:q,selected:B})),children:(B,q)=>v?jsx(v,{method:B,selected:q}):jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(NetworkIcon,{chainId:toEvmChainId(B.chainId)??B.chainId})}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-1 novapay:flex-col novapay:gap-1",children:[jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:ve(B.chainId)}),jsxs("span",{className:"novapay:flex novapay:flex-wrap novapay:items-center novapay:gap-1.5",children:[r?.chainId===B.chainId&&jsx(zn,{tone:"neutral",children:o.method.yourWallet}),B.featured&&jsx(zn,{tone:"accent",children:o.method.popular}),jsx(ii,{method:B,labels:o}),B.gasless==="auto"?jsx(zn,{tone:"success",children:o.method.noGasFee}):jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.buyerPaysGas})]})]}),jsx(gu,{selected:q})]})})]});return jsxs(Fragment$1,{children:[jsxs(de,{title:o.method.title,subtitle:c(o.method.subtitle,{minutes:Math.round(t.quoteTtlSeconds/60)}),children:[jsx(pn,{children:o.method.token}),jsx(xn,{label:o.method.token,items:I,value:x?.symbol??null,getKey:L=>L.symbol,onChange:L=>{let B=I.find(q=>q.symbol===L)?.methods[0];B&&Ne(B);},className:"novapay:grid novapay:grid-cols-[repeat(auto-fit,minmax(5.5rem,1fr))] novapay:gap-2",itemClassName:(L,B)=>cn$1("novapay:flex novapay:min-w-0 novapay:flex-col novapay:items-center novapay:gap-1 novapay:px-2 novapay:py-2",w&&"novapay-page-token",Z(e,"tokenOption",{group:B,selected:L})),children:(L,B)=>f?jsx(f,{group:L,selected:B}):jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:h-6.5 novapay:w-6.5",children:jsx(TokenIcon,{symbol:L.symbol})}),jsx("span",{className:"novapay:text-[13px] novapay:font-semibold",children:L.symbol}),jsx("span",{className:"novapay:max-w-full novapay:truncate novapay:text-[10px] novapay:text-[var(--tuwa-text-secondary)]",children:L.methods.length>1?c(o.method.networks,{count:L.methods.length}):Xa(L.methods[0])?jsx(ii,{method:L.methods[0],labels:o}):ve(L.methods[0].chainId)})]})}),w&&x?jsxs("div",{className:cn$1("novapay:grid",x.methods.length===1&&"novapay:max-sm:hidden"),children:[re!==x&&jsx("div",{inert:true,"aria-hidden":true,className:"novapay:invisible novapay:flex novapay:flex-col novapay:gap-2.5 novapay:[grid-area:1/1] novapay:max-sm:hidden",children:pe(re)}),jsx("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-2.5 novapay:[grid-area:1/1]",children:pe(x)})]}):x&&x.methods.length>1&&pe(x),jsx(pn,{children:o.method.payWith}),jsx(xn,{label:o.method.payWith,items:b,value:R,getKey:L=>L,onChange:L=>{F(false),i(L);},className:cn$1("novapay:grid novapay:gap-2",b.length>1&&"novapay:grid-cols-2"),itemClassName:(L,B)=>cn$1("novapay:flex novapay:items-center novapay:gap-2.5 novapay:px-2.5 novapay:py-2",w&&"novapay-page-way",Z(e,"payWithOption",{payWith:B,selected:L})),children:L=>L==="wallet"?jsxs(Fragment$1,{children:[r?jsx("span",{className:"novapay:h-5 novapay:w-5 novapay:shrink-0",children:jsx(On,{walletId:r.walletId,icon:r.icon})}):jsx(cr,{"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:o.method.wallet}),jsx("span",{className:cn$1("novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",r&&$),children:r?`${r.name} \xB7 ${shortAddress(r.address)}`:o.method.walletHint})]})]}):jsxs(Fragment$1,{children:[h&&je(h)==="solana"?jsx(hr,{"aria-hidden":true,className:"novapay:h-5 novapay:w-5 novapay:shrink-0"}):jsx(mr,{"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:o.method.qr}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.qrHint})]})]})}),H&&jsxs("label",{className:cn$1("novapay:flex novapay:cursor-pointer novapay:items-start novapay:gap-2.5 novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:px-3 novapay:py-2.5 novapay:transition-colors",V?"novapay:border-[var(--tuwa-text-accent)] novapay:bg-[var(--tuwa-bg-primary)] novapay:ring-1 novapay:ring-[var(--tuwa-text-accent)]":"novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-secondary)] novapay:hover:border-[var(--tuwa-border-strong)]",Z(e,"consentOption",{checked:V,required:H.required})),children:[jsx(ma,{checked:V,required:H.required,"aria-labelledby":D,"aria-describedby":H.required?A:void 0,onChange:L=>n.getState().setConsentGiven(L.target.checked),className:"novapay:mt-0.5"}),jsxs("span",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-1",children:[jsx("span",{id:D,className:"novapay:whitespace-pre-line novapay:break-words novapay:text-[12px] novapay:leading-snug",children:H.text}),H.required&&jsx("span",{id:A,className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:o.method.consentRequired})]})]}),h&&!R&&jsx(Q,{children:o.method.methodUnavailable}),_&&jsx(Q,{children:g?o.pay.connectUnavailable:o.method.methodUnavailable}),a.error&&a.phase==="selectMethod"&&jsxs(Fragment$1,{children:[jsx(Q,{children:la(a.error,o,t.merchant.name)}),jsx(da,{error:a.error})]})]}),jsxs(J,{children:[jsx(ee,{busy:P,disabled:!h||!R||be,onClick:()=>{h&&R&&Pe?.onQuote?Pe.onQuote({method:h,payWith:R,proceed:he}):he();},children:P?o.method.quoting:o.method.continue}),jsx(bu,{labels:o,terms:t.merchant.links.terms,refundPolicy:t.merchant.links.refundPolicy})]})]})}function mi(e,t,a,n=false){let o=useRef(null),r=t?.id??null,s=useEffectEvent(()=>{t&&a?.({...t,status:"paid"});});useEffect(()=>{e!=="paid"||!r||o.current===r||(o.current=r,n||s());},[e,r,n]);}function di({url:e,seconds:t,now:a,navigate:n=o=>window.location.assign(o)}){let[o,r]=useState(t>0?a:null);t>0!=(o!==null)&&r(t>0?a:null);let s=t>0?o??a:a,[i,c]=useState(false),l=e&&t>0&&!i?Math.max(0,t-Math.floor((a-s)/1e3)):null,p=useEffectEvent(()=>{e&&n(e);});return useEffect(()=>{l===0&&p();},[l]),{left:l,stay:()=>c(true)}}function fi(){let e=E(),{checkout:t,state:a,labels:n,locale:o,now:r,close:s,autoReturnSeconds:i,openedPaid:c$1,display:l}=e,p=e.customization.childCustomizations,m=fn(),[y]=useState(r),f=t?.merchant.name??"",v=l==="modal"&&i===0?null:t?.invoice.successUrl??null,d=di({url:v,seconds:c$1?0:i,now:r}),I=v?n.paid.back:s?n.common.close:null,h=vn(I===null?null:"primary",I??""),x=h.arrives?ka:void 0;if(!t)return null;let g=t.invoice.totalMinor?ye(Re(t.invoice.totalMinor),o):null,k=t.invoice.refundedTotalMinor&&BigInt(t.invoice.refundedTotalMinor)>0n?ye(Re(t.invoice.refundedTotalMinor),o):null,C=t.invoice.paidAt?Date.parse(t.invoice.paidAt):y,b=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}).format(C),{transfers:R}=m,_=R.length>1?R:null,F=R.length===1?R[0]:null,D=m.txKey??F?.txKey??null,A=m.txKey?m.explorerUrl:F?.explorerUrl,N=new Intl.DateTimeFormat(o,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});return jsxs(Ye,{children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:items-center novapay:gap-3 novapay:px-5 novapay:py-5 novapay:text-center",e.display==="page"&&"novapay-page-status"),children:[jsx(_t,{mark:"paid",tone:"success",chip:n.status.paid,title:n.paid.title,amount:m.paidAmount??(g&&`${g} ${t.invoice.currency}`),note:m.network?c(n.paid.summary,{network:m.network,date:b}):b}),jsx(hn,{state:"succeed"}),(m.network||D||_||m.from)&&jsxs(ge,{className:"novapay:max-w-sm",children:[m.network&&jsx(U,{name:n.confirm.network,children:m.network}),_?_.map((w,re)=>jsxs(U,{name:jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:block",children:c(n.confirm.transferOf,{index:re+1,count:_.length})}),jsx("time",{dateTime:new Date(w.at).toISOString(),className:"novapay:block novapay:text-[11px] novapay:leading-4",children:N.format(w.at)})]}),children:[w.amount&&jsx("span",{className:"novapay:block",children:w.amount}),jsx(HashLink,{hash:w.txKey,explorerUrl:w.explorerUrl,variant:"compact",...p?.hashLink})]},`${w.txKey}:${re}`)):D&&jsx(U,{name:m.lastOfParts?n.confirm.lastTransfer:n.confirm.transaction,children:jsx(HashLink,{hash:D,explorerUrl:A,variant:"compact",...p?.hashLink})}),m.fromAddress&&jsx(U,{name:n.confirm.from,children:jsx(HashLink,{hash:m.fromAddress,explorerUrl:m.fromUrl,variant:"compact",...p?.hashLink})})]}),k&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(n.paid.refunded,{amount:k,currency:t.invoice.currency})}),a.receiptUrl&&jsx(Gn,{className:"novapay:max-w-sm",children:jsxs("div",{className:"novapay:flex novapay:w-full 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(sr,{"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:n.paid.receipt}),jsx("span",{className:"novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:n.paid.receiptHint})]}),jsxs("a",{href:a.receiptUrl,target:"_blank",rel:"noopener noreferrer",className:cn$1(on,"novapay:gap-1.5 novapay:no-underline"),children:[jsx(lr,{"aria-hidden":true,className:"novapay:h-3.5 novapay:w-3.5"}),n.paid.download]})]})})]}),jsx(J,{children:v?jsxs(Fragment$1,{children:[jsx("a",{href:v,className:cn$1(Rt,x,Z(e,"primaryButton")),children:jsx(we,{label:h.label,values:{merchant:f}})}),d.left!==null&&jsxs(qe,{children:[jsx("span",{role:"timer","aria-live":"off",children:c(n.paid.returning,{merchant:f,seconds:d.left})})," ","\xB7 ",jsx(gt,{onClick:d.stay,children:n.paid.stay})]})]}):s&&jsx(ee,{onClick:s,className:x,children:h.label})})]})}function Ea({payee:e}){let{labels:t,checkout:a,state:n,backToMethods:o}=E();if(e.status==="checking")return jsxs("div",{role:"status",className:cn$1("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)]","novapay-payee-wait"),children:[jsx(QuasarLoader,{size:40}),t.pay.payeeChecking]});let r=a?.merchant.name??"",s=(n.invoiceStatus??a?.invoice.status)==="underpaid";return jsxs(Fragment$1,{children:[jsx(de,{title:t.pay.payeeRefusedTitle,children:jsx("div",{"data-payee-refusal":e.reason,children:jsx(Q,{children:c(t.pay.payeeRefused,{merchant:r})})})}),jsx(J,{children:jsx(ae,{onClick:o,children:s?t.pay.backFromRest:t.pay.back})})]})}function hi({state:e,screen:t,now:a,locale:n=null,handlers:o}){let r=e.checkout?.invoice.status??null,{phase:s,error:i}=e,c=e.quote?.expiresAt?Date.parse(e.quote.expiresAt):null,l=c!==null&&a>=c,p=useEffectEvent(()=>o?.onStatusChange?.({phase:s,status:r,screen:t}));useEffect(()=>p(),[s,r]);let m=useEffectEvent(()=>{n&&o?.onLocaleShown?.({locale:n});});useEffect(()=>m(),[n]);let y=useEffectEvent(()=>{i&&o?.onError?.({error:i,screen:t});});useEffect(()=>y(),[i]);let f=useRef({quote:false,invoice:false}),v=useEffectEvent(d=>o?.onExpire?.({kind:d,paymentOnTheWay:ot(e)||ht(e,e.checkout)||Ht(e,e.checkout)}));useEffect(()=>{l&&!f.current.quote&&v("quote"),f.current.quote=l;},[l]),useEffect(()=>{let d=r==="expired";d&&!f.current.invoice&&v("invoice"),f.current.invoice=d;},[r]);}var Yt=()=>new Promise(()=>{}),Au={view:Yt,quote:Yt,buyer:Yt,locale:Yt,submit:Yt,relay:Yt,authorizeRelay:Yt,url:()=>""},Lu=createCheckoutStore({token:"idle",api:Au,EventSource:null});function gi(e){let{token:t,baseUrl:a,api:n,EventSource:o,pollMs:r,enabled:s=true,payee:i}=e,[c,l]=useState(Lu),p=useEffectEvent(()=>createCheckoutStore({token:t,baseUrl:a,api:n,EventSource:o,pollMs:r,payee:i})),m=i?.addresses?.join(`
2
+ `)??"";return useEffect(()=>{if(!s)return;let y=p();return l(y),y.getState().load(),()=>y.getState().destroy()},[t,a,s,m]),c}function bi(e,t){return useStore(e,t)}var Du=createStore(()=>({}));function La(){let e=useContext(SatelliteStoreContext)??Du,t=useStore(e,l=>l.activeConnection),a=useStore(e,l=>l.getConnectors),n=useStore(e,l=>l.watchConnectors),[o,r]=useState(0);useEffect(()=>n?.(()=>r(l=>l+1)),[n]);let s=useMemo(()=>gr(t,a?.()),[t,a,o]),i=s?.name,c=s?.icon;return useMemo(()=>s,[t,i,c])}function ki(e){let[t,a]=useState({store:e,at:null});return useEffect(()=>e.subscribe((n,o)=>{n.phase!==o.phase&&(n.phase==="confirming"?a({store:e,at:o.phase==="submitting"?Date.now():null}):o.phase==="confirming"&&a({store:e,at:null}));}),[e]),t.store===e?t.at:null}var Ci=Symbol.for("tuwaio.nova-payments.context"),Si=globalThis,jn=Si[Ci]??(Si[Ci]=createContext({}));function pt(){return useContext(jn)}function Pi(e,t=true){let[a,n]=useState(()=>Date.now());return useEffect(()=>{if(!t)return;let o=setInterval(()=>n(Date.now()),e);return ()=>clearInterval(o)},[e,t]),a}var wo="nova-payments:sponsoredBatches";var ko=()=>{try{return globalThis.sessionStorage??null}catch{return null}},Co=()=>{try{let e=JSON.parse(ko()?.getItem(wo)??"[]");return Array.isArray(e)?e:[]}catch{return []}},Ni=e=>{try{e.length>0?ko()?.setItem(wo,JSON.stringify(e)):ko()?.removeItem(wo);}catch{}},_a=e=>Ni(Co().filter(t=>t.invoiceId!==e)),Ti=e=>Ni([...Co().filter(t=>t.invoiceId!==e.invoiceId),e]),So=e=>Co().find(t=>t.invoiceId===e&&Date.now()-t.at<21e5)??null;function bn(e){let t=e.payeeCheck;return !e.quote||!t||t.quote!==e.quote||t.status==="checking"?{status:"checking"}:t.status==="verified"?{status:"verified"}:{status:"refused",reason:t.reason}}function Ii(e,t){return e.payeeCheck?.quote===t&&e.payeeCheck.status==="verified"}function Ri(e,t){let a=vt(t.chainId),n=a?e?.find(o=>o.family===a)?.verifyPayoutRecord:void 0;return n?n(t):Promise.resolve(null)}function Ei(e,t){let a=vt(t.chainId),n=a?e?.find(o=>o.family===a)?.verifyInvoiceAddress:void 0;return n?n(t):Promise.resolve(null)}function Ai(e,t){return !e||!t?.length||payoutAddressesOf(e)?e:withPayoutAddresses(e,t)}var Li=e=>new a("unsupported",`${e} is not available`);async function _i({adapter:e,store:t,quote:a$1,wallet:n,path:o,paymasterUrl:r,onWalletDone:s,onBatchAccepted:i,onSent:c}){if(!Ii(t.getState(),a$1))throw new a("unsupported","The payee of the quote is not verified");let l=n.address;if(o==="relay"){let m=a$1.gasless?.relay?.typedData;if(!m||!e.signTransferAuthorization)throw Li("A gasless signature");let y=await e.signTransferAuthorization({typedData:m,account:l});s?.();let{relayFromPage:f,relay:v}=t.getState(),d=e.sendOneTimeRelay;return f&&d&&r?f(y,I=>d({chainId:I.chainId,call:I.call,paymasterUrl:r})):v(y)}if(o==="paymaster"){let m=a$1.gasless?.paymaster?.calls;if(!m||!r||!e.sendSponsoredCalls)throw Li("A sponsored payment");let y=xe(a$1.instructions),f=await e.sendSponsoredCalls({calls:m,paymasterUrl:r,chainId:y,account:l,onSent:s,onAccepted:i,onLate:v=>{c?.(v),t.getState().submit({txKey:v,connectorType:n.connectorType,methodId:a$1.methodId});}});return s?.(),c?.(f),t.getState().submit({txKey:f,connectorType:n.connectorType,methodId:a$1.methodId})}let p=await e.sendTransfer({instructions:a$1.instructions,account:l,connection:n.connection});return s?.(),c?.(p),t.getState().submit({txKey:p,connectorType:n.connectorType,methodId:a$1.methodId})}var Fa=6e5;var Mt=new WeakMap;function Ba(e){let t=Mt.get(e);return !!(t?.accepted&&Date.now()<t.until)}function Mi({adapter:e,store:t,quote:a$1,wallet:n,path:o,paymasterUrl:r,invoiceId:s,onSent:i}){let[c,l]=useState("idle"),[p,m]=useState(()=>{let g=Mt.get(t),k=g?.unconfirmed&&g.account===n?.address&&Date.now()<g.until,C=s?So(s):null;return k||C?"sentUnconfirmed":null}),y=useEffectEvent(g=>i?.(g));useEffect(()=>{if(!s||Mt.has(t))return;let g=So(s);if(!g)return;let k=Promise.reject(new a("sentUnconfirmed","The sponsored payment is not confirmed yet"));k.catch(()=>{});let C=g.at+21e5;Mt.set(t,{account:g.account,path:"paymaster",paying:k,until:C,unconfirmed:true,instructions:g.instructions,accepted:true}),e?.followSponsoredCalls?.({batchId:g.batchId,until:C,onLate:b=>{_a(s),y({txKey:b,instructions:g.instructions,account:g.account,connectorType:g.connectorType}),t.getState().submit({txKey:b,connectorType:g.connectorType,methodId:g.methodId});}});},[s,e,t]);let f=useRef(0),[v,d]=useState(null),[I,h]=useState(null),x=async(g,k)=>{let C=++f.current,b=()=>f.current===C;m(null),l(g);try{await k(b);}catch(R){b()&&m(b$1(R));}finally{b()&&l("idle");}};return {status:c,problem:p,askedWallet:v,askedInstructions:I,pay:()=>x("wallet",async g=>{if(!e||!a$1||!n)return m("unsupported");d(n);let k=Mt.get(t),C=k?.path==="relay"&&o==="relay";if(k?.account===n.address&&!C&&Date.now()<k.until){h(k.instructions),await k.paying;return}h(a$1.instructions);let b={account:n.address,path:o,paying:Promise.resolve(),until:Date.now()+6e5,unconfirmed:!1,instructions:a$1.instructions,accepted:!1};Mt.set(t,b);let R=_i({adapter:e,store:t,quote:a$1,wallet:n,path:o,paymasterUrl:r,onWalletDone:()=>{o==="paymaster"&&(b.accepted=!0),g()&&l("submitting");},onBatchAccepted:F=>{s&&Ti({invoiceId:s,batchId:F,account:n.address,instructions:a$1.instructions,connectorType:n.connectorType,methodId:a$1.methodId,at:Date.now()});},onSent:F=>{s&&_a(s),i?.({txKey:F,instructions:a$1.instructions,account:n.address,connectorType:n.connectorType});}});b.paying=R;let _=()=>{Mt.get(t)===b&&Mt.delete(t),s&&_a(s);};R.then(_,F=>{if(b$1(F)!=="sentUnconfirmed")return _();b.unconfirmed=!0,b.until=Date.now()+21e5;}),await R;}),switchNetwork:()=>x("switching",async()=>{if(!e?.switchChain||!a$1)return m("unsupported");await e.switchChain(xe(a$1.instructions));}),dismiss:()=>{f.current++,l("idle");}}}var Yu=100,Zu=300,Bi=(e,t)=>e.length>t?`${e.slice(0,t-1)}\u2026`:e;async function Oi({adapter:e,pulsar:t,payment:a,labels:n,merchant:o,invoice:r,amount:s}){if(!t||!e?.pulsarTransaction)return false;let i=r.number?c(n.pay.txDescription,{amount:s,invoice:r.number}):s,c$1=e.pulsarTransaction({...a,title:Bi(c(n.pay.txTitle,{merchant:o}),Yu),description:Bi(i,Zu),payload:{quasarInvoice:r.id}});return await t.injectExternalPendingTxs([c$1]),true}var Xu=new Set(["open","processing","underpaid"]),qi=new WeakMap,Po=e=>{let t=qi.get(e);return t||qi.set(e,t={keys:new Set,sentHere:false}),t},em=e=>e.split(":").at(-1)??e;function Ui({store:e,adapterFor:t,pulsar:a,labels:n,locale:o}){let r=useRef({adapterFor:t,pulsar:a,labels:n,locale:o});useEffect(()=>{r.current={adapterFor:t,pulsar:a,labels:n,locale:o};});let s=useCallback(i=>{let{checkout:c}=e.getState(),{adapterFor:l,pulsar:p,labels:m,locale:y}=r.current,f=Po(e);if(!c||!p||f.keys.has(i.txKey))return;f.keys.add(i.txKey);let{amount:v,decimals:d,symbol:I}=i.instructions;Oi({adapter:l(i.instructions.family),pulsar:p,payment:i,labels:m,merchant:c.merchant.name,invoice:{id:c.invoice.id,number:c.invoice.number},amount:`${ue(v,d,y)} ${I}`}).catch(()=>{});},[e]);return useEffect(()=>e.subscribe((i,c)=>{let{txHash:l,quote:p,checkout:m}=i;if(!l||l===c.txHash||!p||!m||!Xu.has(c.invoiceStatus)||Po(e).sentHere)return;let y=m.invoice.originWallet??p.payer;s({txKey:l,instructions:p.instructions,account:y?em(y):"",connectorType:""});}),[e,s]),useCallback(i=>{Po(e).sentHere=true,s(i);},[e,s])}function $i({store:e,state:t,walletTxKey:a=null}){let[n,o]=useState(null),[r,s]=useState(null),i=a!==null&&a!==r;i&&s(a);let c=t.phase,l=i||ot(t)||ht(t,t.checkout)||Ht(t,t.checkout)||c==="confirming"||c==="unconfirmed",p=n?.store===e?n:null,m=l?p&&p.error===t.error?p:{store:e,error:t.error}:p&&Lr(t.error)&&t.error!==p.error?null:n;return m!==n&&o(m),m?.store===e}function Yn(e){let{labels:t,customization:a}=pt(),n=a?.labels?.transform,[o,r]=useState(()=>h(e)),s=g(e);s&&o!==h(e)&&r(h(e));let i$1=s?h(e):o;return useEffect(()=>{if(g(e))return;let c=true;return i(e).then(l=>c&&r(l)),()=>{c=false;}},[e]),useMemo(()=>{let c=j(i$1,t);return n?n(c,{locale:e}):c},[i$1,e,t,n])}function Ki({store:e,screen:t}){let[a,n]=useState(null),o=t==="qr";return o&&a!==e&&n(e),o||a===e}function Oa(e){let t=useContext(NovaConnectProviderContext),a=pt(),n=e??a.onConnectWallet;return {canConnect:!!(t||n),connecting:t?.isConnectModalOpen??false,connect:o=>t?(t.setIsConnectModalOpen(true,{adapter:o==="solana"?OrbitAdapter.SOLANA:OrbitAdapter.EVM}),true):n?(n(o),true):false}}function Gi({box:e,content:t,isNarrow:a,isActive:n,duration:o=300}){if(typeof ResizeObserver>"u")return ()=>{};let r,s,i=0,c=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,l=()=>{s=void 0,e.style.removeProperty("overflow");},p=()=>{let f=s;l(),f?.cancel();},m=()=>{let f=t.offsetHeight,v=r;if(r=f,v===void 0||v===f)return;if(s){s.effect?.setKeyframes?.([{height:`${i}px`},{height:`${f}px`}]);return}if(!a()||!n()||c()||typeof e.animate!="function"||Math.abs(f-v)<12)return;i=v,e.style.overflow="clip";let I=e.animate([{height:`${v}px`},{height:`${f}px`}],{duration:o,easing:"cubic-bezier(0.2, 0, 0, 1)"});s=I;let h=()=>{s===I&&l();};I.onfinish=h,I.oncancel=h;},y=new ResizeObserver(m);return y.observe(t),m(),()=>{y.disconnect(),p();}}function ji({active:e,children:t}){let a=useRef(null),n=useRef(null),o=useRef(e);return useEffect(()=>{o.current=e;},[e]),useEffect(()=>{if(!a.current||!n.current||typeof window>"u"||!window.matchMedia)return;let r=window.matchMedia("(max-width: 639.98px)");return Gi({box:a.current,content:n.current,isNarrow:()=>r.matches,isActive:()=>o.current})},[]),jsx("div",{ref:a,className:"novapay:flex novapay:flex-none novapay:flex-col novapay:sm:min-h-0 novapay:sm:flex-1",children:jsx("div",{ref:n,className:"novapay:flex novapay:flex-none novapay:flex-col novapay:sm:min-h-0 novapay:sm:flex-1",children:t})})}function wn(e,t){let[a,n]=useState(null),o=useEffectEvent(t);return useEffect(()=>{if(e===null)return;let r=true,s;try{s=Promise.resolve(o());}catch(i){s=Promise.reject(i);}return s.then(i=>r&&n({key:e,value:i}),()=>r&&n({key:e,value:null})),()=>{r=false;}},[e]),a&&a.key===e?a.value:void 0}function Da(e,t,a){let[n,o]=useState(0),[r,s]=useState(null),i=useEffectEvent(t);return useEffect(()=>{if(e===null||typeof window>"u")return;let c=()=>{document.visibilityState!=="hidden"&&o(m=>m+1);},l=window,p=document;return l.addEventListener("focus",c),p.addEventListener("visibilitychange",c),()=>{l.removeEventListener("focus",c),p.removeEventListener("visibilitychange",c);}},[e]),useEffect(()=>{if(e===null)return;let c=true,l;try{l=Promise.resolve(i());}catch(p){l=Promise.reject(p);}return l.then(p=>c&&s({key:e,value:p}),()=>c&&s({key:e,value:null})),()=>{c=false;}},[e,n,a]),r&&r.key===e?r.value:void 0}var im=e=>e.charAt(0).toUpperCase()+e.slice(1);function Zi(e,t,a){let n=e.startsWith("solana:")?getSolanaCluster(e):void 0;if(!n||n==="mainnet")return null;let o={network:ve(e),cluster:im(n),wallet:t?.name??""},r=t?.family!=="solana"?void 0:t.walletId==="phantom"?a.pay.solanaHintPhantom:t.walletId==="solflare"?a.pay.solanaHintSolflare:a.pay.solanaHintOther;return {title:c(a.pay.solanaNetwork,o),text:c(a.pay.solanaNetworkText,o),...r?{hint:c(r,o)}:{}}}function Ji(e,t){let a=e.startsWith("solana:")?getSolanaCluster(e):void 0;return !a||t?.family!=="solana"||getSolanaCluster(t.chainId)===a?null:e}function Xi(e,t){let a=useContext(SatelliteStoreContext),n=Ji(e,t);useEffect(()=>{n&&a?.getState().switchNetwork?.(n);},[a,n]);}function um(e,t){return e>=1?ye(e,t):new Intl.NumberFormat(t,{maximumSignificantDigits:6}).format(e)}function mm(e,t,a,n){let o=n?.code;if(a==="declined")return c(e.pay.declined,t);if(a==="unsupported")return c(e.pay.unsupported,t);if(a==="wrongNetwork")return c(e.pay.wrongCluster,t);if(a==="switchFailed")return c(e.pay.switchFailed,t);if(a==="notAuthorized")return c(e.pay.notAuthorized,t);if(a==="alreadyPending")return c(e.walletPrompt.stillWaiting,t);if(a==="sentUnconfirmed")return c(e.pay.sentUnconfirmed,t);let r=a?null:$t(n,e,t.merchant);return r!==null?r:a==="failed"?c(e.pay.walletFailed,t):n&&o==="payment_failed"?Mn(n,e,t.network):o==="screening_unavailable"?e.pay.screeningUnavailable:o==="request_failed"?e.pay.noAnswer:o==="price_unavailable"||o==="price_no_rpc"?e.method.priceUnavailable:o==="rate_limited"?e.method.rateLimited:o==="method_not_found"||o==="amount_out_of_range"||o==="testnet_required"?e.method.methodUnavailable:n&&!fo(n)?e.error.generic:null}var dm=(...e)=>e.reduce((t,a)=>t&&!/[。!?]$/.test(t)?`${t} ${a}`:`${t}${a}`,"");function ym(e,t,a){let{wallet:n,adapterFor:o}=E(),r=t?.instructions.family,s=r?o(r):void 0,i=e.filter(l=>l.id!==t?.methodId&&je(l)===r),c=wn(a&&s&&n&&i.length?`${n.address}:${i.map(l=>l.id).join()}`:null,()=>Promise.all(i.map(l=>s.getBalance({chainId:l.chainId,account:n.address,token:wr(l)}).catch(()=>0n))));return c?i.map((l,p)=>({method:l,balance:c[p]})).filter(l=>l.balance>0n):[]}function nc(){let{checkout:e,state:t,store:a,labels:n,locale:o,now:r,wallet:s,adapterFor:i,connectWallet:c$1,backToMethods:l,onPaymentSent:p,customization:m,lockPrice:y,display:f}=E(),v=m.config?.balanceCheck!==false,d=t.quote,I=e?.methods??[],h=I.find(Me=>Me.id===d?.methodId),x=d?.instructions.family??"eip155",g=i(x),k=d?xe(d.instructions):"",C=s?.address??"",[b,R]=useState(false),_=wn(d?.gasless?.paymaster&&g?.canSponsorCalls&&s?`${k}:${C}`:null,()=>g.canSponsorCalls({chainId:k,account:C})),F=d?$r(d,{withGas:b,canSponsorCalls:_===true}):"transfer",D=Da(v&&d&&g&&s?`${k}:${C}:${d.instructions.token}`:null,()=>g.getBalance({chainId:k,account:C,token:d.instructions.token}),d?.expiresAt),A=wn(d&&F==="transfer"&&g?.estimateFee&&s?`${k}:${C}:${d.amountToSend}`:null,()=>g.estimateFee({instructions:d.instructions,account:C})),N=Mi({adapter:g,store:a,quote:d,wallet:s,path:F,paymasterUrl:t.paymasterUrl,invoiceId:e?.invoice.id,onSent:p}),w=Sa({adapter:g,store:a,wallet:s,chainId:k});Xi(k,s);let re=d?.instructions.token==="native",P=d&&typeof D=="bigint"?Gr(D,d,re&&A?A.amount:0n):null,H=(t.invoiceStatus??e?.invoice.status)==="underpaid",V=ym(I,d,v&&!!P&&!H),[be,Pe]=useState(false),Ne=w.step==="switching"||w.step==="signing"||N.status==="switching"||N.status==="submitting"||N.status==="wallet"||t.phase==="submitting",[he,pe]=Pa(Ne);if(e&&d&&!h)return jsxs(Fragment$1,{children:[jsx(de,{title:n.method.methodUnavailable,children:null}),jsx(J,{children:jsx(ae,{onClick:l,children:n.pay.back})})]});if(!e||!d||!h)return null;let L=bn(t);if(L.status!=="verified"&&t.phase!=="submitting"&&N.status==="idle")return jsx(Ea,{payee:L});let B=e.merchant.name,q=ve(k),ne=Me=>`${ue(Me,d.decimals,o)} ${d.instructions.symbol}`,ce=Kr(d),ie=N.askedInstructions,Ce=ie&&ie.amount!==d.instructions.amount?`${ue(ie.amount,ie.decimals,o)} ${ie.symbol}`:ne(ce.send),He=d.expiresAt?Date.parse(d.expiresAt)-r:Number.POSITIVE_INFINITY,Ve=He<=0,Bt=Ir(He),ut=t.phase==="quoting",mt=e.invoice.amountPaid?null:Vr(d,e.invoice.totalMinor),dt=(t.invoiceStatus??e.invoice.status)==="underpaid",Pn=f==="page",Xn=A?va(String(A.amount),A.decimals,o):null,Jt=dt?cn(d,r,n,B,o):null,Nn=e.invoice.totalMinor?ye(Re(e.invoice.totalMinor),o):null,Xt=!!(s&&d.payer&&De(s,h)===d.payer),Tn=x==="eip155"&&s&&s.chainId!==k&&!!g?.switchChain,Ot=N.status!=="idle"||t.phase==="submitting"||ut||w.step!=="idle",St=Zi(k,s,n),et=()=>{a.getState().requestQuote();},ea=t.payerProof,en=qs(ea,F),In=en?Ta(Un(t.error)?t.error:null,w.problem,n,{wallet:s?.name??"",network:q,merchant:B}):null,Dt=t.phase==="awaitingPayment"&&!(en&&Un(t.error))?t.error:void 0,Rn=mm(n,{wallet:s?.name??"",network:q,merchant:B},N.problem,Dt),ta=!N.problem&&(Dt?.code==="payment_failed"||Dt?.code==="payment_mismatch"),En=()=>{c$1(h)||Pe(true);},Ge;Ve?Ge={label:dt?n.outcome.payRest:n.pay.newPrice,run:et}:Xt?Tn?Ge={label:jsx(we,{label:n.pay.switchTo,values:{network:q}}),run:()=>{N.switchNetwork();}}:en?Ge={label:n.payerProof.confirmToPay,run:()=>{w.confirm();}}:Ge={label:ta?n.pay.payAgain:jsx(we,{label:F==="transfer"?n.pay.payAmount:n.pay.signToPay,values:{amount:ne(ce.send)}}),run:()=>{m.handlers?.onSubmit?m.handlers.onSubmit({quote:d,method:h,proceed:N.pay}):N.pay();},disabled:!!P||N.problem==="sentUnconfirmed"}:Ge={label:n.pay.connect,run:En};let ze=w.step==="switching"?"switch":w.step==="signing"?"proof":N.status==="switching"?"switch":N.status==="submitting"||t.phase==="submitting"?"submitting":N.status==="wallet"?F==="transfer"?"confirm":"sign":null,Wt=e.invoice.number??e.invoice.id,tt=s??N.askedWallet,$a={wallet:tt?.name??"",invoice:Wt,merchant:B};return jsxs("div",{className:"novapay:relative novapay:flex novapay:flex-1 novapay:flex-col",children:[jsxs("div",{ref:he,inert:Ne,className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",Ne&&"novapay:hidden"),children:[jsxs("section",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col novapay:gap-3 novapay:px-5 novapay:py-4",Pn&&"novapay-page-screen novapay-page-pay"),children:[jsx("h2",{...It,className:"novapay:sr-only",children:n.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(On,{walletId:s.walletId,icon:s.icon})}),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($,"novapay:truncate novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.walletLine,{address:shortAddress(s.address),network:ve(s.chainId)})})]}),jsx("button",{type:"button","aria-label":n.pay.changeWallet,onClick:En,className:on,children:n.pay.change})]}),Tn&&Xt&&!Ve&&jsxs("div",{role:"status",className:cn$1(sa,"novapay:flex novapay:gap-2 novapay:px-3 novapay:py-2 novapay:text-xs"),children:[jsx(ft,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),jsxs("span",{children:[jsx("strong",{className:"novapay:block",children:n.pay.wrongNetwork}),c(n.pay.wrongNetworkText,{current:ve(s.chainId),network:q})," ",n.pay.switchHint]})]}),St&&!Ve&&jsxs("div",{className:"novapay:flex 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:[jsx(ir,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0 novapay:text-[var(--tuwa-text-secondary)]"}),jsxs("span",{className:"novapay:flex novapay:flex-col novapay:gap-0.5",children:[jsx("strong",{children:St.title}),jsx("span",{children:St.text}),St.hint&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:St.hint})]})]}),jsxs("div",{children:[jsx("span",{className:cn$1(Be,"novapay:block"),children:dt?n.pay.youSendRest:n.pay.youSend}),jsxs("div",{className:cn$1("novapay:flex novapay:items-baseline novapay:gap-2",Pn&&"novapay-page-amount-row"),children:[jsx("span",{className:cn$1($,"novapay:text-[28px] novapay:font-bold novapay:leading-tight",Pn&&"novapay-page-amount"),children:ue(ce.send,d.decimals,o)}),jsx("span",{className:cn$1($,"novapay:text-sm novapay:font-semibold"),children:d.instructions.symbol}),jsx(Dn,{text:ha(ce.send,d.decimals),label:n.pay.copyAmount,copiedLabel:n.pay.copied})]}),jsxs("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:[c(n.pay.onNetwork,{network:q}),Nn&&!ce.fee&&!dt&&jsxs(Fragment$1,{children:[" \xB7 ",c(n.pay.fiatValue,{amount:Nn,currency:e.invoice.currency})]})]})]}),ce.fee&&jsxs("div",{className:"novapay:flex novapay:flex-col novapay:gap-1.5",children:[jsxs(ge,{children:[jsx(U,{name:dt?n.pay.invoiceRest:n.pay.invoiceTotal,children:ue(ce.receives,d.decimals,o)}),jsx(U,{name:c(n.pay.transferFee,{percent:ce.fee.percent}),children:ue(ce.fee.amount,d.decimals,o)}),jsx(U,{name:c(n.pay.merchantReceives,{merchant:B}),children:ne(ce.receives)})]}),jsx("p",{className:"novapay:m-0 novapay:text-[11px] novapay:text-[var(--tuwa-text-secondary)]",children:n.pay.transferFeeNote})]}),!Ve&&jsxs("div",{className:"novapay:flex novapay:items-center novapay:gap-2 novapay:text-xs",children:[jsx(sn,{"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:c(Jt?n.pay.restTimeLeft:n.pay.priceLocked,{time:st(He)})}),!dt&&jsx(gt,{disabled:ut,onClick:et,children:n.pay.refreshPrice})]}),Bt&&!Jt&&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:c(n.pay.priceEnding,{time:st(He)})}),jsx("span",{role:"status",className:"novapay:sr-only",children:c(n.pay.priceEnding,{time:st(to)})}),jsx("button",{type:"button",onClick:et,disabled:ut,className:nr,children:jsx(we,{label:n.pay.keepPrice,values:{minutes:Math.round(e.quoteTtlSeconds/60)}})})]}),Ve&&jsx(Q,{children:n.pay.priceExpired}),Jt&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:Jt}),P&&!Ve&&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:n.pay.notEnough}),c(n.pay.walletHas,{amount:ne(P.have),network:q}),"."," ",c(n.pay.shortBy,{short:ne(P.short),need:ne(P.need)})]}),V.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:n.pay.payFromBalance}),V.map(({method:Me,balance:Ka})=>jsxs("button",{type:"button",onClick:()=>{let Va=s?De(s,Me):null;a.getState().selectMethod(Me.id),a.getState().setPayer(Va),y();},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)]",se),children:[jsxs("span",{className:"novapay:font-semibold",children:[Me.symbol," \xB7 ",ve(Me.chainId)]}),jsx("span",{className:cn$1($,"novapay:text-[var(--tuwa-text-secondary)]"),children:c(n.pay.youHave,{amount:`${ue(String(Ka),Me.decimals,o)} ${Me.symbol}`})})]},Me.id))]}),e.merchant.fundingUrl&&jsxs("span",{children:[c(n.pay.topUp,{symbol:d.instructions.symbol})," ",jsxs("a",{href:e.merchant.fundingUrl,target:"_blank",rel:"noopener noreferrer",className:cn$1("novapay:text-[var(--tuwa-text-accent)] novapay:underline",se),children:[c(n.pay.getToken,{symbol:d.instructions.symbol})," \u2197"]})]})]}),jsxs(ge,{children:[mt!==null&&jsx(U,{name:n.pay.rate,children:c(n.pay.rateValue,{symbol:d.instructions.symbol,price:um(mt,o),currency:e.invoice.currency})}),jsx(U,{name:n.pay.networkFee,children:jsxs("span",{className:"novapay:inline-flex novapay:flex-col novapay:items-end novapay:gap-0.5",children:[F!=="transfer"?jsx("span",{className:"novapay:text-[var(--tuwa-success-text)]",children:c(n.pay.merchantPaysGas,{merchant:B})}):Xn?c(n.pay.gasEstimate,{amount:`${Xn} ${A?.symbol}`}):n.pay.gasFromWallet,d.gasless&&jsx(gt,{onClick:()=>R(!b),children:b?c(n.pay.payGasless,{merchant:B}):n.pay.payWithGas})]})}),jsxs(U,{name:n.pay.to,children:[jsx(We,{hash:d.instructions.to,chainId:k}),jsx("span",{className:"novapay:font-sans novapay:text-[var(--tuwa-text-secondary)]",children:B})]})]}),en&&!Ve&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:n.payerProof.payNote}),In&&jsx(Q,{children:In}),Rn&&jsx(Q,{children:Rn}),!N.problem&&jsx(da,{error:Dt}),be&&jsx(Q,{children:n.pay.connectUnavailable})]}),jsxs(J,{children:[jsx(ee,{busy:Ot,disabled:Ge.disabled,onClick:Ge.run,children:Ge.label}),jsx(ae,{disabled:ut,onClick:l,children:dt?n.pay.backFromRest:n.pay.back}),jsx(qe,{children:dm(c(n.pay.disclaimer,{merchant:B}),...Rr(e)?[c(n.pay.disclaimerScreening,{merchant:B})]:[])})]})]}),ze==="proof"&&jsx($n,{kind:"proof",walletName:tt?.name??"",walletId:tt?.walletId??"",walletIcon:tt?.icon,amount:Ce,merchant:B,network:q,to:shortAddress(d.instructions.to),priceTime:null,text:c(Na(s)?n.payerProof.promptPasskey:n.payerProof.promptText,$a),details:[...w.request?[{name:n.payerProof.site,value:w.request.domain}]:[],{name:n.payerProof.invoice,value:Wt},{name:n.payerProof.merchant,value:B}],hint:w.request?c(n.payerProof.signInRequest,{wallet:tt?.name??"",site:w.request.domain}):void 0,onRetry:()=>{w.confirm();},onCancel:w.dismiss,stepHeight:pe}),ze&&ze!=="proof"&&jsx($n,{kind:ze,walletName:tt?.name??"",walletId:tt?.walletId??"",walletIcon:tt?.icon,amount:Ce,merchant:B,network:q,to:shortAddress(d.instructions.to),priceTime:Ve?null:st(He),onRetry:F==="relay"?()=>{N.pay();}:void 0,onCancel:w.step==="switching"?w.dismiss:N.dismiss,stepHeight:pe})]})}function ac(e,t){let{to:a,token:n,chainId:o}=e;return n==="native"?`ethereum:${a}@${o}?value=${t}`:`ethereum:${n}@${o}/transfer?address=${a}&uint256=${t}`}var Eo=4;function oc(e){let{size:t,data:a}=encode(e,{ecc:"M",border:0}),n="";return a.forEach((o,r)=>o.forEach((s,i)=>{s&&(n+=`M${i+Eo} ${r+Eo}h1v1h-1z`);})),{size:t+Eo*2,path:n}}function Lo({value:e,label:t,className:a}){let n=E(),o=cn$1(a,Z(n,"qrCode")),{size:r,path:s}=useMemo(()=>oc(e),[e]),i=n.customization.components?.QrCode;return i?jsx(i,{value:e,label:t,className:o}):jsxs("svg",{role:"img","aria-label":t,viewBox:`0 0 ${r} ${r}`,shapeRendering:"crispEdges",className:cn$1("novapay:block novapay:rounded-[var(--tuwa-rounded-corners)]",o),children:[jsx("rect",{width:r,height:r,fill:"#ffffff"}),jsx("path",{d:s,fill:"#111827"})]})}function gm({payUrl:e}){let{labels:t,backToMethods:a,display:n}=E();return jsxs(Fragment$1,{children:[jsx(de,{title:t.qr.handoffTitle,subtitle:t.qr.handoffHint,children:jsxs("div",{className:"novapay:flex novapay:flex-col novapay:items-center novapay:gap-3 novapay:py-2",children:[jsx(Lo,{value:e,label:t.qr.handoffCode,className:cn$1("novapay:h-48 novapay:w-48",n==="page"&&"novapay-page-qr-handoff")}),jsx(Dn,{text:e,label:t.qr.copyLink,copiedLabel:t.pay.copied,children:t.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:t.qr.handoffNote})]})}),jsx(J,{children:jsx(ae,{onClick:a,children:t.qr.back})})]})}function sc(){let e=E(),{checkout:t,state:a,store:n,labels:o,locale:r,now:s,payUrl:i,backToMethods:c$1}=e,l=a.quote;if(!t)return null;let p=l?.instructions.family==="eip155"&&!!l.invoiceAddress;if(!l||l.instructions.family!=="solana"&&!p)return i?jsx(gm,{payUrl:i}):null;let m=bn(a);if(m.status!=="verified"&&a.phase!=="submitting")return jsx(Ea,{payee:m});let{instructions:y}=l,f=y.family==="solana",v=f?y.solanaPayUrl:ac(y,l.amountToSend),d=ve(xe(y)),I=`${ue(l.amountToSend,l.decimals,r)} ${y.symbol}`,h=l.expiresAt?Date.parse(l.expiresAt)-s:Number.POSITIVE_INFINITY,x=h<=0,g=a.phase==="quoting",k=(a.invoiceStatus??t.invoice.status)==="underpaid",C=k?cn(l,s,o,t.merchant.name,r):null,b=k?t.invoice.originWallet:null,R=b?c(o.qr.restHint,{wallet:shortAddress(At(b))}):f?o.qr.solanaHint:o.qr.evmHint;return jsxs(Fragment$1,{children:[jsxs(de,{title:f?o.qr.solanaTitle:o.qr.evmTitle,subtitle:R,children:[jsxs("div",{className:"novapay:flex novapay:flex-col novapay:items-center novapay:gap-4 novapay:@min-[440px]:flex-row novapay:@min-[440px]:items-start",children:[jsx(Lo,{value:v,label:c(f?o.qr.solanaCode:o.qr.evmCode,{amount:I}),className:cn$1("novapay:h-44 novapay:w-44 novapay:shrink-0",e.display==="page"&&"novapay-page-qr",x&&"novapay:opacity-30")}),jsxs("div",{className:"novapay:flex novapay:min-w-0 novapay:flex-col novapay:gap-2 novapay:self-stretch novapay:text-xs novapay:@min-[440px]:self-auto",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:f?o.qr.scanStep:o.qr.evmScanStep}),jsx("li",{children:o.qr.approveStep})]}),k&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:o.pay.youSendRest}),jsxs("div",{className:"novapay:flex novapay:items-baseline novapay:gap-2",children:[jsx("span",{className:cn$1($,"novapay:text-2xl novapay:font-bold"),children:ue(l.amountToSend,l.decimals,r)}),jsx(Dn,{text:ha(l.amountToSend,l.decimals),label:o.pay.copyAmount,copiedLabel:o.pay.copied})]}),jsxs("div",{"data-qr-line":true,className:cn$1($,"novapay:flex novapay:flex-wrap novapay:items-center novapay:gap-x-1 novapay:gap-y-0.5 novapay:text-[var(--tuwa-text-secondary)]"),children:[jsxs("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:[y.symbol," \xB7"]}),jsxs("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:[d," \xB7"]}),jsx("span",{"data-qr-part":true,className:"novapay:whitespace-nowrap",children:jsx(We,{hash:y.to,chainId:xe(y)})})]}),!x&&jsxs(Fragment$1,{children:[jsxs("span",{role:"status",className:"novapay:flex novapay:items-center novapay:gap-1.5",children:[jsx(QuasarLoader,{size:14,accent:"var(--tuwa-pending-icon)"}),o.qr.waiting]}),jsx("span",{role:"timer","aria-live":"off",className:"novapay:text-[var(--tuwa-text-secondary)]",children:c(C?o.pay.restTimeLeft:o.pay.priceLocked,{time:st(h)})})]})]})]}),x&&jsx(Q,{children:o.pay.priceExpired}),C&&jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:C}),f?jsxs("p",{className:cn$1(sa,"novapay:m-0 novapay:flex novapay:gap-2 novapay:px-3 novapay:py-2 novapay:text-xs"),children:[jsx(ft,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4 novapay:shrink-0"}),o.qr.exchangeWarning]}):jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:o.qr.exchangeAllowed})]}),jsxs(J,{children:[x?jsx(ee,{busy:g,onClick:()=>{n.getState().requestQuote();},children:k?o.outcome.payRest:o.pay.newPrice}):jsx("a",{href:v,className:cn$1(Rt,Z(e,"primaryButton")),children:o.qr.openInWallet}),jsx(ae,{onClick:c$1,children:k?o.pay.backFromRest:o.qr.back})]})]})}function Fo(e){switch(e){case "confirm":return "pending";case "unconfirmed":case "underpaid":return "warning";case "paid":return "success";case "failed":case "blocked":case "error":return "error";case "needs_review":case "refunded":case "expired":case "cancelled":case "replaced":return "neutral";default:return null}}function Im(){let{labels:e}=E();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(QuasarLoader,{size:48}),e.common.loading]})}function Rm(){let{labels:e,state:t,store:a}=E(),n=t.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(ft,{"aria-hidden":true,className:"novapay:h-7 novapay:w-7 novapay:text-[var(--tuwa-error-icon)]"}),jsx("h2",{...It,className:at,children:e.error.title}),jsx("p",{className:"novapay:m-0 novapay:max-w-sm novapay:text-[13px] novapay:text-[var(--tuwa-text-secondary)]",children:n?e.error.notFound:e.error.generic}),!n&&jsx(ae,{onClick:()=>{a.getState().load();},className:"novapay:w-auto novapay:px-6",children:e.common.retry})]})}var Em=new Set(["paid","partially_refunded","refunded"]);function ic(){let{screen:e,customization:t}=E(),a=t.components?.screens?.[e];return a?jsx(a,{screen:e}):e==="loading"?jsx(Im,{}):e==="error"?jsx(Rm,{}):e==="buyer"?jsx(es,{}):e==="method"?jsx(ci,{}):e==="confirmWallet"?jsx(Gs,{}):e==="pay"?jsx(nc,{}):e==="qr"?jsx(sc,{}):e==="confirm"?jsx(Os,{}):e==="failed"?jsx(ei,{}):e==="paid"?jsx(fi,{}):jsx(Js,{kind:e})}function Am({className:e,withDetails:t,leave:a}){let n=E(),{checkout:o,locale:r,labels:s,now:i,customization:c$1,display:l}=n,{Header:p=hs,Summary:m=us,CompactSummary:y=ms}=c$1.components??{},f=c$1.config?.deadlineAnnouncements,{screen:v,state:d}=n,I=useRef(null),h=(v==="pay"||v==="qr"&&(d.quote?.instructions.family==="solana"||!!d.quote?.invoiceAddress))&&d.phase!=="submitting"&&!!d.quote&&bn(d).status==="checking",x=useRef(v);useEffect(()=>{if(h)return;let N=x.current;x.current=v;let w=I.current;if(!w||N===v||N==="loading")return;let re=w.ownerDocument.activeElement;if(re&&re!==w.ownerDocument.body&&!w.contains(re))return;let P=w.querySelector("[data-novapay-scroll] [data-novapay-heading]");if(l!=="page")return P?.focus();w.getBoundingClientRect().top<0&&w.scrollIntoView({block:"start"}),P?.focus({preventScroll:true});},[v,l,h]);let[g,k]=useState(""),C=useRef(null),b=o?.invoice.dueAt?Date.parse(o.invoice.dueAt):null,R=o?Fn(o.invoice.status,v,o.invoice.restPayable)==="paying":false;useEffect(()=>{if(b===null)return;let N=b-i,w=Pr(C.current,N,f);C.current=N,w!==null&&R&&k(w===1?s.summary.oneMinuteLeft:c(s.summary.minutesLeft,{minutes:w}));},[b,i,s,f,R]);let _=l==="page",F=ar[_?"page":"default"],D=Fo(v),A=c$1.components?.StatusEdge??StatusEdge;return jsxs("div",{ref:I,lang:r,className:cn$1(F.frame,ia(l).frame,e),children:[o&&jsx("aside",{inert:!!a,className:cn$1(F.aside,Z(n,"summary")),children:jsx(m,{})}),jsxs("div",{inert:!!a,className:cn$1("novapay:relative",F.main),children:[D&&jsx(A,{tone:D,className:cn$1("novapay:z-20",Z(n,"statusEdge",{tone:D}))}),jsxs(ji,{active:!!D&&!_&&!c$1.config?.animation?.disabled,children:[jsx(p,{withDetails:t}),jsxs("div",{className:"novapay:sm:hidden",children:[o&&jsx(y,{className:Z(n,"compactSummary")}),jsx(xs,{withDetails:t})]}),jsx("div",{"data-novapay-scroll":"",className:cn$1(F.area,Z(n,"body")),children:_?jsx("div",{className:cn$1("novapay:flex novapay:flex-1 novapay:flex-col",!c$1.config?.animation?.disabled&&"novapay-page-fade"),children:jsx(ic,{})},D?"status":v):jsx(ic,{})})]})]}),jsx("div",{role:"status","aria-live":"polite",className:"novapay:sr-only",children:g}),a&&jsx(ai,{onStay:a.onStay,onLeave:a.onLeave})]})}function Zw({token:e,display:t="modal",open:a=true,onOpenChange:n,onClose:o,baseUrl:r,api:s,EventSource:i,pollMs:c$1,payUrl:l,payoutAddresses:p,onConnectWallet:m,onPaid:y,autoReturnSeconds:f$1,onContact:v,locale:d,className:I,customization:h}){let x=pt(),[g$1,k]=useState({from:e,token:e}),C=g$1.from===e?g$1.token:e,[b,R]=useState(t!=="modal"||a);!b&&(t!=="modal"||a)&&R(true);let _=useRef(x.adapters);useEffect(()=>{_.current=x.adapters;},[x.adapters]);let F=useCallback(Y=>Ri(_.current,Y),[]),D=useCallback(Y=>Ei(_.current,Y),[]),A=gi({token:C,baseUrl:r??x.baseUrl,api:s,EventSource:i,pollMs:c$1,enabled:b,payee:{verify:F,verifyInvoiceAddress:D,addresses:p}}),N=bi(A,Y=>Y),w=N.checkout,re=f(d),[P,H]=useState(null),V=Mr({picked:P,page:re,invoice:N.locale??w?.invoice.locale}),be=Yn(V),Pe=!!w&&b&&Ur(N.phase,f$1,g(V)),he=Pi(1e3,Pe)-(N.clockSkewMs??0),pe=La(),L=Oa(m),B=x.adapters,[q,ne]=useState("wallet"),[ce,ie]=useState(false),[Ce,He]=useState(null);w&&Ce?.store!==A&&He({store:A,paid:Em.has(w.invoice.status)});let[Ve,Bt]=useState(false),[ut,mt]=useState(false),[dt,Pn]=useState(C);dt!==C&&(Pn(C),ie(false),ne("wallet"),mt(false));let Xn=N.payerProof==="confirmed"&&!!N.error,Jt=N.error?.code==="payer_mismatch";ut&&(N.phase==="awaitingPayment"||Xn||Jt)&&mt(false);let Nn=(N.invoiceStatus??w?.invoice.status)==="underpaid"?w?.invoice.originWallet??null:null,Xt=Y=>!Nn||ln(Y,Nn),Tn=w?.methods.find(Y=>Y.id===N.methodId),Ot=Tn?De(pe,Tn):null,St=Tr({open:ut,storePayer:N.payer,payer:Ot,paysRest:!Ot||Xt(Ot)});St==="leave"&&mt(false);let et=useRef(null),[ea,en]=useState(false);!ea&&w&&g(V)&&en(true);let In={payWith:q,handoff:ce,confirmWallet:ut,labelsReady:ea||!w},Dt=eo(N,In),[Rn,ta]=useState(null),[En,Ge]=useState(null);Dt==="confirm"?Rn!==A&&ta(A):Rn===A&&(ta(null),N.error?.code==="payment_failed"&&Ge(N.error));let ze=En!==null&&N.error===En?eo(N,{...In,afterFailure:true}):Dt,Wt=async()=>{await Us(A,mt);},tt=ki(A),$a=Ki({store:A,screen:ze}),[Me,Ka]=useState(null),Va=$i({store:A,state:N,walletTxKey:Me?.store===A?Me.txKey:null});mi(N.phase,w?.invoice,y,Ce?.store===A&&Ce.paid),hi({state:N,screen:ze,now:he,locale:w||re?V:null,handlers:h?.handlers});let Wo=Y=>B?.find(Qe=>Qe.family===Y),qo=Ui({store:A,adapterFor:Wo,pulsar:x.pulsar,labels:be,locale:V}),Sc=useCallback(Y=>{Ka({store:A,txKey:Y.txKey}),qo(Y);},[A,qo]),Pc=useEffectEvent(()=>{if(!w)return;let{quote:Y,phase:Qe}=A.getState();if(pe&&et.current){let aa=w.methods.find(Lc=>Lc.id===et.current),ja=aa?De(pe,aa):null;if(!ja)return;et.current=null,A.getState().setPayer(ja),Xt(ja)&&Wt();return}if(Qe==="selectMethod"||Qe==="underpaid"||Qe==="blocked"){if(N.payer===null||Ot===N.payer)return;A.getState().setPayer(Ot),St==="follow"&&Wt();return}if(!pe)return;let An=w.methods.find(aa=>aa.id===Y?.methodId),na=An?De(pe,An):null,Ko=Nr({phase:Qe,quotePayer:Y?.payer,payer:na});if(Ko==="release")return A.getState().releaseQuote();Ko==="keep"||!na||(A.getState().setPayer(na),Xt(na)&&Wt());}),Nc=N.quote?.payer,Tc=!!w;useEffect(()=>Pc(),[pe?.address,pe?.chainId,pe?.connectorType,N.phase,Nc,Tc]),useEffect(()=>{L.connecting||(et.current=null);},[L.connecting]);let[Uo,Ic]=useState(false);ze==="buyer"&&!Uo&&Ic(true);let Ga=useMemo(()=>t==="modal"?()=>{n?.(false),o?.();}:o,[t,n,o]),Rc=Ga&&(()=>ao(A.getState().phase,A.getState().error,A.getState().invoiceStatus)&&!Ba(A)?Bt(true):Ga()),Ec=Ve?{onStay:()=>Bt(false),onLeave:()=>{Bt(false),A.getState().releaseQuote(),Ga?.();}}:null,Ho=h??{},Ac={store:A,state:N,checkout:w,screen:ze,locale:V,labels:be,setLocale:async Y=>{let Qe=P;H({locale:Y,page:re}),await A.getState().setLocale(Y)||H(Qe);},now:he,handedOverAt:tt,qrShown:$a,paymentSent:Va||Ba(A),close:Rc,wallet:pe,payWith:q,setPayWith:ne,payUrl:Ai(l,p),connectWallet:Y=>{let Qe=je(Y);et.current=Y.id;let An=Qe!==null&&L.connect(Qe);return An||(et.current=null),An},connectFamily:Y=>L.connect(Y),openedPaid:Ce?.store===A&&Ce.paid,adapterFor:Wo,handoff:ce,setHandoff:ie,backToMethods:()=>{ie(false),mt(false),A.getState().releaseQuote();},payAfterFailure:()=>{Ge(null),A.getState().clearError();},confirmWallet:ut,setConfirmWallet:mt,lockPrice:Wt,onPaymentSent:Sc,openInvoice:Y=>k({from:e,token:Y}),onContact:v,autoReturnSeconds:f$1??(t==="modal"?0:5),display:t,customization:Ho},za=cn$1(I,Z({customization:Ho,screen:ze,state:N,checkout:w},"container")),Qa=jsx(jo,{value:Ac,children:jsx(MotionConfig,{reducedMotion:h?.config?.animation?.disabled?"always":"user",children:jsx(Am,{withDetails:Uo,leave:Ec,className:t==="modal"?za:void 0})})});if(t==="modal")return jsx(Dialog,{open:a,onOpenChange:Y=>{if(!Y&&Ve)return Bt(false);if(!Y&&ao(A.getState().phase,A.getState().error,A.getState().invoiceStatus)&&!Ba(A))return Bt(true);n?.(Y),Y||o?.();},children:jsxs(DialogContent,{className:"novapay:w-full novapay:sm:w-auto",animateHeight:Fo(ze)===null,children:[jsx(DialogTitle,{className:"novapay:sr-only",children:c(be.common.dialogTitle,{merchant:w?.merchant.name??""})}),Qa]})});let $o=c(be.common.dialogTitle,{merchant:w?.merchant.name??""});return t==="page"?jsx(Lm,{label:$o,className:za,children:Qa}):jsx("section",{"aria-label":$o,className:cn$1("novapay:overflow-hidden novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)]",ia(t).section,za),children:Qa})}function Lm({label:e,className:t,children:a}){return jsx("div",{className:"novapay-page",children:jsx("section",{"aria-label":e,className:cn$1(ia("page").section,"novapay-page-block",t),children:a})})}function cc(e){if(!e.to)return null;let t=parseCaip19AssetId(e.assetId),a={to:e.to,token:!t||t.assetNamespace==="slip44"?"native":t.assetReference,amount:e.amount,decimals:e.decimals,symbol:e.symbol},n=vt(e.chainId);if(n==="solana")return {family:n,chainId:e.chainId,...a,reference:"",solanaPayUrl:""};let o=n==="eip155"?toEvmChainId(e.chainId):void 0;return o===void 0?null:{family:"eip155",chainId:o,...a}}function pc(e){let t=b$1(e);return t==="switchFailed"?"wrongNetwork":t==="notAuthorized"||t==="alreadyPending"||t==="sentUnconfirmed"?"failed":t}var Oo=new WeakMap,Cn=new WeakMap;function uc({store:e,invoiceId:t,invoice:a,params:n,open:o,labels:r,locale:s,onConnectWallet:i}){let c$1=useStore(e),{adapters:l,pulsar:p}=pt(),m=La(),y=Oa(i),[f,v]=useState("idle"),[d,I]=useState(null),[,h]=useState(0),x=Cn.has(e),g=useRef(0),k=useRef(o),C=c$1.sentTransaction?.txHash??c$1.refund?.txHash??null,b=c$1.instructions?cc(c$1.instructions):null,R=b?.family??null,_=b?xe(b):c$1.instructions?.chainId??null,F=l?.find(q=>q.family===R),D=m&&m.family===R?m:null,A=_?ve(_):"",N=d&&d.account===D?.address?d.problem:null,w=q=>I(q?{problem:q,account:D?.address}:null),re=!!(D&&R==="eip155"&&_&&D.chainId!==_),P=c$1.instructions,H=P?`${ue(P.amount,P.decimals,s)} ${P.symbol}`:"",V=Da(b&&D&&F?`balance|${_}|${D.address}|${b.token}`:null,()=>F.getBalance({chainId:_,account:D.address,token:b.token}),c$1.refund?.id),be=wn(b&&D&&F?.estimateFee?`fee|${_}|${D.address}|${b.token}`:null,()=>F.estimateFee({instructions:b,account:D.address}));useEffect(()=>{!n||Oo.get(e)===t||e.getState().phase!=="idle"||(Oo.set(e,t),e.getState().start(t,n));},[n,e,t]),useEffect(()=>{o&&!k.current&&!n&&e.getState().phase==="confirmed"&&e.getState().reset(),k.current=o;},[o,n,e]),useEffect(()=>(e.getState().keepFollowing(),()=>e.getState().stopFollowing()),[e]),useEffect(()=>{let q=true;return Cn.get(e)?.settled.then(()=>{q&&h(ne=>ne+1);}),()=>{q=false;}},[e]);let Pe=async(q,ne,ce)=>{if(!p||!F?.pulsarTransaction||!c$1.refund)return;let ie={invoice:a??t,amount:H};try{await p.injectExternalPendingTxs([F.pulsarTransaction({txKey:q,instructions:ce,account:ne.address,connectorType:ne.connectorType,title:c(r.refund.txTitle,ie),description:c(c$1.refund.unmatchedTransfer?r.refund.txDescriptionSender:r.refund.txDescription,ie),payload:{quasarRefund:c$1.refund.id}})]);}catch{}},Ne=async()=>{if(w(null),!(!re||!F?.switchChain))try{v("switching"),await F.switchChain(_);}catch(q){w(pc(q));}finally{v("idle");}},he=async()=>{if(w(null),!b)return w("noRecipient");if(!D||!F)return w("unsupported");if(c$1.sentTransaction){await e.getState().submit(c$1.sentTransaction);return}let q=BigInt(b.amount)+(b.token==="native"&&be?be.amount:0n);if(typeof V=="bigint"&&V<q)return w("notEnough");if(R&&b.to&&isSameAddress(R,D.address,b.to))return w("fromBuyer");if(!await e.getState().recheck()){let ie=e.getState(),Ce=ie.error?.code==="refund_repriced";ie.phase==="awaitingTransfer"&&!ie.sentTransaction&&!Ce&&w("unreachable");return}let ne=++g.current,ce=()=>g.current===ne;try{re&&F.switchChain&&(v("switching"),await F.switchChain(_)),ce()&&v("wallet");let ie=await F.sendTransfer({instructions:b,account:D.address,connection:D.connection});ce()?v("idle"):I(null),Pe(ie,D,b),await e.getState().submit({txHash:ie,from:D.address});}catch(ie){ce()?(v("idle"),w(pc(ie))):I(null);}},pe=async()=>{if(Cn.has(e))return;let q,ne={settled:new Promise(Ce=>q=Ce)},ce=()=>{Cn.get(e)===ne&&Cn.delete(e),q(),h(Ce=>Ce+1);},ie=setTimeout(ce,6e5);Cn.set(e,ne),h(Ce=>Ce+1);try{await he();}finally{clearTimeout(ie),ce();}},L=f!=="idle"?f:D?"confirm":"connect";return {step:c$1.phase==="idle"?n&&!c$1.error&&Oo.get(e)!==t?"requesting":"amount":c$1.phase==="awaitingTransfer"?L:c$1.phase,phase:c$1.phase,refund:c$1.refund,error:c$1.error,transfer:b,chainId:_,network:A,amount:H,wallet:D,wrongNetwork:re,balance:V,fee:be,problem:N??(c$1.instructions&&!b?"noRecipient":null),txKey:C,transactionUrl:q=>_?F?.explorerUrl?.({chainId:_,txKey:q}):void 0,addressUrl:q=>_?F?.explorerAddressUrl?.({chainId:_,address:q}):void 0,canConnect:y.canConnect,connecting:y.connecting,preview:async q=>{let ne=await e.getState().preview(t,q);return ne||(e.getState().error?"refused":null)},start:async q=>{w(null),await e.getState().start(t,q);},connect:()=>{R&&y.connect(R);},switchNetwork:Ne,send:pe,dismiss:()=>{g.current++,v("idle"),w("stillInWallet");},sending:x}}function Rk({label:e,className:t,disabled:a,...n}){let[o,r]=useState(false),s=Yn(n.locale??"en");return jsxs(Fragment$1,{children:[jsx("button",{type:"button",disabled:a,onClick:()=>r(true),className:cn$1(Rt,"novapay:w-auto novapay:px-4",t),children:e??s.refund.button}),jsx($m,{...n,open:o,onOpenChange:r})]})}function $m({open:e,onOpenChange:t,locale:a="en",onRefunded:n,...o}){let r=Yn(a),s=uc({store:o.store,invoiceId:o.invoiceId,invoice:o.invoice,params:e?o.params:void 0,open:e,labels:r,locale:a,onConnectWallet:o.onConnectWallet}),i=useEffectEvent(p=>n?.(p)),c$1=s.phase==="confirmed"?s.refund:null;useEffect(()=>{c$1&&i(c$1);},[c$1]);let l=o.invoice?c(r.refund.title,{invoice:o.invoice}):r.refund.button;return jsx(Dialog,{open:e,onOpenChange:t,children:jsxs(DialogContent,{className:"novapay:w-full novapay:sm:w-[440px]",children:[jsxs("div",{className:"novapay:flex novapay:items-center novapay:justify-between novapay:gap-3 novapay:border-b novapay:border-[var(--tuwa-border-primary)] novapay:px-5 novapay:py-3",children:[jsx(DialogTitle,{className:cn$1($,"novapay:m-0 novapay:truncate novapay:text-sm novapay:font-bold"),children:l}),jsx("button",{type:"button","aria-label":r.refund.close,onClick:()=>t(false),className:Tt,children:jsx(CloseIcon,{"aria-hidden":true,className:"novapay:h-4 novapay:w-4"})})]}),jsx(Km,{flow:s,labels:r,locale:a,close:()=>t(false),...o})]})})}function Km({flow:e,labels:t,locale:a,close:n,currency:o="USD",refundable:r,details:s,onRecord:i}){let c$1=t.refund,l={network:e.network,symbol:e.transfer?.symbol??e.refund?.assetId??"",amount:e.amount,wallet:e.wallet?.name??""},p=e.refund?.txHash??e.txKey,m=i&&jsxs(Fragment$1,{children:[jsx(ae,{onClick:i,children:c$1.record}),jsx(qe,{children:c$1.recordHint})]});switch(e.step){case "amount":return jsx(Jm,{flow:e,labels:t,locale:a,currency:o,refundable:r});case "requesting":case "submitting":return jsx(vc,{children:e.step==="requesting"?c$1.requesting:c$1.submitting});case "switching":case "wallet":return jsxs(Fragment$1,{children:[jsxs(vc,{walletId:e.wallet?.walletId,walletIcon:e.wallet?.icon,children:[jsx("strong",{className:cn$1($,"novapay:text-sm"),children:c(e.step==="switching"?c$1.switchTitle:c$1.walletTitle,l)}),e.step==="wallet"&&jsx("span",{children:c(c$1.walletText,l)})]}),jsx(J,{children:jsx(ae,{onClick:e.dismiss,children:t.walletPrompt.cancel})})]});case "connect":return jsxs(Fragment$1,{children:[jsxs(de,{title:c$1.connectTitle,subtitle:c(c$1.connectText,l),children:[e.problem==="noRecipient"&&jsx(Q,{children:c$1.noRecipient}),!e.canConnect&&jsx(Q,{children:c$1.connectUnavailable})]}),jsxs(J,{children:[e.canConnect&&e.problem!=="noRecipient"&&jsx(ee,{busy:e.connecting,onClick:e.connect,children:c$1.connect}),m]})]});case "confirm":return jsx(Xm,{flow:e,labels:t,locale:a,values:l,details:s?.confirm,recordAction:m});case "confirming":return jsxs(Fragment$1,{children:[jsxs(de,{title:c$1.onItsWay,children:[jsxs(ge,{children:[jsx(U,{name:c$1.status,children:c$1.pending}),p&&jsx(U,{name:c$1.transaction,children:jsx(We,{hash:p,explorerUrl:e.transactionUrl(p),labels:t})}),jsx(U,{name:c$1.network,children:c(c$1.waiting,l)})]}),fc(e.refund)&&jsx(qe,{children:c$1.slowNote})]}),jsxs(J,{children:[jsx(ae,{onClick:n,children:c$1.close}),fc(e.refund)?m:jsx(qe,{children:c$1.canClose})]})]});case "confirmed":return jsxs(Fragment$1,{children:[jsx(de,{title:c$1.refunded,children:jsxs(ge,{children:[e.refund?.creditNoteNumber&&jsx(U,{name:c$1.creditNote,children:e.refund.creditNoteNumber}),p&&jsx(U,{name:c$1.transaction,children:jsx(We,{hash:p,explorerUrl:e.transactionUrl(p),labels:t})}),s?.done]})}),jsx(J,{children:jsx(ee,{onClick:n,children:c$1.done})})]});case "failed":return jsx(Zm,{flow:e,labels:t,locale:a,values:l,recordAction:m,close:n})}}var Vm={amount_short:"failedShort",over_limit:"failedByHand",tx_of_another_refund:"failedByHand",refund_from_buyer:"failedFromBuyer",transaction_failed:"failedNotFound",dropped:"failedDropped",too_early:"failedTooEarly",no_matching_transfer:"failedNoTransfer",withdrawn:"failedWithdrawn",cancelled:"failedCancelling",cancelled_final:"failedCancelled",resend_confirmed:"failedResendConfirmed"},dc=(e,t,a)=>{let n=e?.failureReason?Vm[e.failureReason]:void 0;return n?t[n]:c(t.failedText,a)},Gm={withdrawn:"failedWithdrawnTitle",cancelled:"failedCancelledTitle",cancelled_final:"failedCancelledTitle"},yc=(e,t)=>t[e?.failureReason&&Gm[e.failureReason]||"failedTitle"],zm={refund_repriced:"movedTitle",request_failed:"unreachable",amount_exceeds_refundable:"refusedAmount",invoice_not_refundable:"refusedNotRefundable",payment_unknown:"refusedNotRefundable",unmatched_transfer_not_refundable:"refusedNotRefundable",review_refund_must_be_whole:"refusedWhole",sender_blocked:"refusedBlocked",refund_not_waiting:"refusedNotWaiting",refund_may_have_landed:"refusedMayHaveLanded",refund_from_buyer:"failedFromBuyer",method_not_priced:"refusedPrice",price_no_rpc:"refusedPrice",price_unavailable:"refusedPrice",mainnet_disabled_on_node:"refusedTestOnly"},Qm=600*1e3,fc=e=>{let t=e?.updatedAt??e?.createdAt;return !!t&&Date.now()-Date.parse(t)>Qm},Ua=(e,t)=>e.text??t[zm[e.code]??"refusedOther"],jm=e=>e?.failureReason==="over_limit"||e?.failureReason==="tx_of_another_refund",Ym=e=>{let t=e.mode==="fiat_value"||e.failureReason==="amount_short";return {mode:t?"fiat_value":e.mode,...t&&{amount:e.amount},...e.reason&&{reason:e.reason}}};function gc(e){let[t,a]=useState(false),[n,o]=useState(null),r=useRef(false);return useEffect(()=>(r.current=false,()=>{r.current=true;}),[]),{ask:async(i,c)=>{if(i?.mode==="fiat_value"){a(true);let l=await e.preview(i);if(r.current||(a(false),l==="refused"))return;if(l&&qr(c?{cryptoAmount:l.cryptoAmount,atPaymentRate:c.cryptoAmount}:l))return o({preview:l,request:i})}o(null),e.start(i);},checking:t,moved:n,back:()=>o(null)}}function bc({preview:e,request:t},a,n,o,r,s){let i=o.refund,c$1=l=>`${ue(l,e.decimals,r)} ${e.symbol}`;return jsxs(Fragment$1,{children:[jsxs(de,{title:i.movedTitle,children:[jsx("p",{className:"novapay:m-0 novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:c(i.movedText,{symbol:e.symbol})}),jsxs(ge,{children:[jsx(U,{name:i.movedSend,children:c$1(e.cryptoAmount)}),e.atPaymentRate&&jsx(U,{name:i.movedAtPayment,children:c$1(e.atPaymentRate)}),e.received&&jsx(U,{name:i.movedReceived,children:c$1(e.received)})]}),s&&e.exactPossible&&jsx(qe,{children:c(i.movedExact,{exact:i.modeExact})}),n.error&&jsx(Q,{children:Ua(n.error,i)})]}),jsxs(J,{children:[jsx(ee,{busy:a.checking,onClick:()=>{a.ask(t,e);},children:i.movedContinue}),jsx(ae,{disabled:a.checking,onClick:a.back,children:i.movedBack})]})]})}function Zm({flow:e,labels:t,locale:a,values:n,recordAction:o,close:r}){let s=t.refund,i=gc(e);return e.refund?.unmatchedTransfer?jsxs(Fragment$1,{children:[jsxs(de,{title:yc(e.refund,s),children:[jsx(Q,{children:dc(e.refund,s,n)}),jsx(qe,{children:s.failedUnmatchedNote})]}),jsx(J,{children:jsx(ee,{onClick:r,children:s.close})})]}):i.moved?bc(i.moved,i,e,t,a,false):jsxs(Fragment$1,{children:[jsxs(de,{title:yc(e.refund,s),children:[jsx(Q,{children:dc(e.refund,s,n)}),e.error&&jsx(Q,{children:Ua(e.error,s)})]}),jsxs(J,{children:[jm(e.refund)?jsx(ee,{onClick:r,children:s.close}):jsx(ee,{busy:i.checking,onClick:()=>e.refund&&void i.ask(Ym(e.refund)),children:s.sendRefund}),o]})]})}function vc({walletId:e,walletIcon:t,children:a}){return jsxs("section",{role:"status",className:"novapay:flex novapay:min-h-56 novapay:flex-col novapay:items-center novapay:justify-center novapay:gap-3 novapay:px-5 novapay:py-6 novapay:text-center",children:[jsx(ua,{walletId:e,walletIcon:t}),a]})}function Jm({flow:e,labels:t,locale:a,currency:n,refundable:o}){let r=t.refund,s=useId(),i=useId(),[c$1,l]=useState("fiat_value"),[p,m]=useState(""),[y,f]=useState(""),v=gc(e),d=c$1==="exact_received"||p.trim()===""||/^\d{1,12}(\.\d{1,2})?$/.test(p.trim()),I=[{key:"fiat_value",title:r.modeFiat,hint:c(r.modeFiatText,{currency:n})},{key:"exact_received",title:r.modeExact,hint:r.modeExactText}],h="novapay:h-10 novapay:w-full novapay:rounded-[var(--tuwa-rounded-corners)] novapay:border novapay:border-[var(--tuwa-border-primary)] novapay:bg-[var(--tuwa-bg-primary)] novapay:px-3 novapay:text-sm novapay:text-[var(--tuwa-text-primary)]",x={mode:c$1,...c$1==="fiat_value"&&p.trim()&&{amount:p.trim()},...y.trim()&&{reason:y.trim()}};return v.moved?bc(v.moved,v,e,t,a,true):jsxs(Fragment$1,{children:[jsxs(de,{title:r.amountTitle,children:[jsxs("fieldset",{disabled:v.checking,className:"novapay:contents",children:[jsx(xn,{label:r.amountTitle,items:[...I],value:c$1,getKey:g=>g.key,onChange:g=>l(g),className:"novapay:flex novapay:flex-col novapay:gap-2",itemClassName:()=>"novapay:flex novapay:flex-col novapay:gap-0.5 novapay:px-3 novapay:py-2.5",children:g=>jsxs(Fragment$1,{children:[jsx("span",{className:"novapay:text-sm novapay:font-semibold",children:g.title}),jsx("span",{className:"novapay:text-xs novapay:text-[var(--tuwa-text-secondary)]",children:g.hint})]})}),c$1==="fiat_value"&&jsxs("label",{htmlFor:s,className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-xs",children:[jsxs("span",{children:[c(r.amount,{currency:n}),jsxs("span",{"aria-hidden":"true",className:"novapay:text-[var(--tuwa-error-text)]",children:[" ","*"]})]}),jsx("input",{id:s,required:true,inputMode:"decimal",value:p,placeholder:"0.00","aria-invalid":!d||void 0,onChange:g=>m(g.target.value.replace(",",".")),className:cn$1($,h)}),o&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:c(r.amountHint,{amount:o})})]}),jsxs("label",{htmlFor:i,className:"novapay:flex novapay:flex-col novapay:gap-1 novapay:text-xs",children:[jsx("span",{children:r.reason}),jsx("input",{id:i,value:y,maxLength:500,onChange:g=>f(g.target.value),className:h})]})]}),e.error&&jsx(Q,{children:Ua(e.error,r)})]}),jsx(J,{children:jsx(ee,{busy:v.checking,disabled:!d,onClick:()=>{v.ask(x);},children:r.continue})})]})}function hc(e,t){return jsxs("span",{className:"novapay:flex novapay:flex-col novapay:items-end novapay:gap-1",children:[e,t&&jsx("span",{className:"novapay:text-[var(--tuwa-text-secondary)]",children:t})]})}function Xm({flow:e,labels:t,locale:a,values:n,details:o,recordAction:r}){let s=t.refund,i=e.transfer,c$1=typeof e.balance=="bigint"&&i?`${ue(e.balance.toString(),i.decimals,a)} ${i.symbol}`:null,l=e.fee?va(e.fee.amount.toString(),e.fee.decimals,a):null,p=e.fee&&l?`${l} ${e.fee.symbol}`:null,m={notEnough:c(s.notEnough,{...n,address:e.wallet?shortAddress(e.wallet.address):"",balance:c$1??""}),declined:c(s.declined,n),unsupported:c(s.unsupported,n),wrongNetwork:c(s.wrongNetwork,n),failed:s.failed,noRecipient:s.noRecipient,fromBuyer:s.failedFromBuyer,stillInWallet:c(t.walletPrompt.stillWaiting,n),unreachable:s.unreachable},y=!!e.problem,f=!!e.txKey;return jsxs(Fragment$1,{children:[jsxs(de,{title:y?s.notSent:s.confirmTitle,children:[jsxs(ge,{children:[jsx(U,{name:s.send,children:n.amount}),jsx(U,{name:s.network,children:n.network}),i&&jsx(U,{name:s.to,children:hc(jsx(We,{hash:i.to,explorerUrl:e.addressUrl(i.to),labels:t}),e.refund?.unmatchedTransfer?s.theSender:s.thePayer)}),e.wallet&&jsx(U,{name:s.from,children:hc(jsx(We,{hash:e.wallet.address,explorerUrl:e.addressUrl(e.wallet.address),labels:t}),c$1&&c(s.balance,{amount:c$1}))}),p&&jsx(U,{name:s.networkFee,children:c(s.feeEstimate,{amount:p})}),o]}),e.problem&&jsx(Q,{children:m[e.problem]}),e.problem&&!["noRecipient","unreachable","stillInWallet"].includes(e.problem)&&jsx(qe,{children:s.nothingSent}),f&&e.error&&jsx(Q,{children:s.notHandedOver}),!f&&e.error&&e.problem!=="unreachable"&&jsx(Q,{children:Ua(e.error,s)})]}),jsxs(J,{children:[e.problem!=="noRecipient"&&(e.wrongNetwork&&!f?jsx(ee,{onClick:()=>{e.switchNetwork();},children:jsx(we,{label:s.switchTo,values:n})}):jsx(ee,{busy:e.sending,onClick:()=>{e.send();},children:f?s.handOver:s.sendRefund})),(y||f)&&r,!y&&!f&&e.wallet&&jsx(ae,{onClick:e.connect,children:t.pay.changeWallet})]})]})}function nd(e){return e.appStore?e.novaConnect?"app":"appStore":e.ownConnection?"own":"none"}function Ha(e){let t=useContext(SatelliteStoreContext),a=useContext(NovaConnectProviderContext);return nd({appStore:t!=null,novaConnect:a!==void 0,ownConnection:e})}function rC(){let e=pt(),t=Ha(false);return e.connection??t}var od=()=>import('./OwnConnection-ET76SUMX.js').then(e=>({default:e.OwnConnection})),kc=lazy(od);var pd=()=>process.env.NODE_ENV==="development";function dC({baseUrl:e,labels:t,customization:a,adapters:n,pulsar:o,ownConnection:r,onConnectWallet:s,children:i}){let c=useContext(jn),l=Ha(!!r),[p]=useState(l),[m]=useState(r),y=p==="own"?r??m:void 0,f=(p==="app"||p==="appStore")&&c.connection!==void 0&&c.connection!=="none",v=y?y.adapters:n??(f?c.adapters:void 0),d=useMemo(()=>({baseUrl:e,labels:t,customization:a,adapters:v,pulsar:o,connection:p,onConnectWallet:s}),[e,t,a,v,o,p,s]),I=useRef(null),h=!!r,x=!!v;return useEffect(()=>{if(!pd())return;I.current??=new Set;let g=I.current,k=(C,b)=>{g.has(C)||(g.add(C),console.warn(`[NovaPaymentsProvider] ${b}`));};l!==p&&k("connection",`it keeps the wallet connection it chose on its first render ("${p}"), though the providers above now call for "${l}". Render it inside the app's SatelliteConnectProvider and NovaConnectProvider from the start.`),h&&p==="appStore"&&k("appStore","it is inside the app's SatelliteConnectProvider without NovaConnectProvider: it uses the app's wallet and never adds a second store, so `ownConnection` is not used. Connect wallets with `onConnectWallet`, or render it inside NovaConnectProvider."),h&&!x&&(p==="app"||p==="appStore")&&k("adapters","it uses the app's wallet connection, so the adapters of `ownConnection` are not used: pass `adapters` on the app's wagmi config to pay from the app's wallet.");},[l,p,h,x]),jsx(jn.Provider,{value:d,children:y?jsx(Suspense,{fallback:null,children:jsx(kc,{own:y,children:i})}):i})}export{Jm as AmountStep,es as BuyerScreen,oa as CheckoutContext,jo as CheckoutContextProvider,Am as CheckoutFrame,hs as CheckoutHeader,Lm as CheckoutPageRoot,ns as CheckoutStepper,us as CheckoutSummary,ms as CompactSummary,Os as ConfirmScreen,Xm as ConfirmStep,Gs as ConfirmWalletScreen,ho as ContactLink,ll as DEADLINE_ANNOUNCEMENTS,is as DeadlineTimer,ga as Disclosure,ei as FailedScreen,Zm as FailedStep,ai as LeaveDialog,ys as LocaleSwitcher,xa as MerchantBadge,ci as MethodScreen,xs as MobileSteps,jn as NovaPaymentsContext,dC as NovaPaymentsProvider,Fa as OPEN_REQUEST_MS,cs as OrderLines,jl as OrderTotal,Js as OutcomeScreen,fi as PaidScreen,nc as PayScreen,Ea as PayeeScreen,Zw as PaymentCheckout,to as QUOTE_WARNING_MS,sc as QrScreen,Rk as RefundButton,$m as RefundDialog,Km as RefundSteps,ic as ScreenBody,ro as SellerDetailsContent,ls as SummaryFooter,$n as WalletPrompt,At as addressOfWallet,Gr as balanceShortfall,ha as baseUnitsToDecimal,Ya as buyerFields,Jo as buyerIssues,br as canPayWithQr,Z as checkoutClassName,eo as checkoutScreen,kr as checkoutSteps,Xo as cleanBuyer,gr as connectedWallet,Br as contactHref,er as countryOptions,Pr as deadlineAnnouncement,Fn as deadlineState,ca as failedPaymentTx,vt as familyOf,st as formatCountdown,va as formatFeeAmount,ye as formatFiat,ue as formatTokenAmount,Sr as groupMethodsByToken,Ai as handOffPayUrl,Oi as handOverPayment,xe as instructionsChainId,mn as invoiceTotals,Un as isConfirmationError,Lr as isFinalPaymentFailure,ht as isInvoicePaymentOnTheWay,Ht as isInvoicePaymentUnresolved,xt as isMovedMoneyFailure,_r as isPaidElsewhere,fo as isPayerProofError,Ba as isPaymentAccepted,ot as isPaymentOnTheWay,Ir as isQuoteEnding,ln as isSameWallet,fc as isSlow,Na as isSmartWallet,Ja as isWalletIconUrl,$t as leftTheWalletText,Us as lockPrice,Nr as lockedPriceOnWallet,la as methodErrorText,je as methodFamily,wr as methodToken,Re as minorToDecimal,ao as needsLeaveConfirm,qs as needsPayerProof,Ur as needsTheClock,ve as networkName,Cr as paidSteps,_i as payInvoice,$r as payPath,bn as payeeStatus,Ii as payeeVerified,De as payerFor,Ta as payerProofErrorText,Mn as paymentFailedText,Xa as priceAdjustment,oc as qrPath,Kr as quoteAmounts,Vr as quoteRate,Wr as receivedAmount,qr as refundRateMoved,cc as refundTransfer,Ua as refusalText,cn as restRateText,Rr as screensPayingWallets,Er as sentBeforeDeadline,Mr as shownLocale,Et as unconfirmedFollowUp,Fr as unconfirmedTxKey,Dr as underpaidRest,wn as useAsyncValue,di as useAutoReturn,E as useCheckoutContext,hi as useCheckoutEvents,bi as useCheckoutState,gi as useCheckoutStore,La as useConnectedWallet,pt as useNovaPayments,Pi as useNow,Oe as useOptionalCheckoutContext,mi as usePaidCallback,Sa as usePayerProof,Mi as usePayment,fn as usePaymentFacts,Ui as usePaymentHandOver,rC as usePaymentsConnection,Yn as usePaymentsLabels,uc as useRefund,Da as useRereadValue,Oa as useWalletConnection,Ei as verifyInvoiceAddressWith,Ri as verifyPayeeWith,nl as walletLabel,Tr as walletOnConfirmStep};