@pollar/react 0.12.1-rc.22 → 0.12.1-rc.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { AUTH_ERROR_CODES, authErrorMessage, rampLegTitle, rampRequirementCopy, rampTrustlineAsset, rampWalletStep, rampResolutionText, rampRailLabel, describeRampAction, rampStepTitle, rampLegStatus, rampNextApproval, rampOrderStopped, rampOrderReceive, countryName, rampNoRouteText, rampFieldError, rampFieldValid, rampFailureReason, rampLegNote, rampStepStatusText, rampLegTimeLeft, rampOrderResolutionText, rampFailureNeedsSupport, rampSupportCopy, rampCountries, rampQuoteFields, isPollarApiError, transactionErrorMessage, WalletType, bridgeSourceChains, bridgeTargetChains, isBridgeSettled, isPollarClient, PollarClient, isInteractiveAuthAdapter, isAuthEntryAdapterStep, completeAuthEntryStep, isKycSettled, rampTrustlineErrorText, isPollarNetworkError, toBaseUnits, resolveLanguage, languageFromTag, localizedText, appUnavailableMessage, fromBaseUnits, cosignRefusalMessage, assertRampStellarSigner } from '@pollar/core';
2
+ import { AUTH_ERROR_CODES, authErrorMessage, rampLegTitle, rampRequirementCopy, rampTrustlineAsset, rampWalletStep, rampResolutionText, rampRailLabel, describeRampAction, rampStepTitle, rampLegStatus, rampOrderStopped, rampOrderReceive, rampLegNote, countryName, rampNoRouteText, rampFieldError, rampFieldValid, rampFailureReason, rampLegTimeLeft, rampStepStatusText, rampOrderResolutionText, rampFailureNeedsSupport, rampSupportCopy, rampCountries, rampQuoteFields, isPollarApiError, rampNextApproval, rampSupportContact, transactionErrorMessage, WalletType, bridgeSourceChains, bridgeTargetChains, isBridgeSettled, isPollarNetworkError, isPollarClient, PollarClient, isInteractiveAuthAdapter, isAuthEntryAdapterStep, completeAuthEntryStep, isKycSettled, rampTrustlineErrorText, toBaseUnits, resolveLanguage, languageFromTag, localizedText, appUnavailableMessage, fromBaseUnits, cosignRefusalMessage, assertRampStellarSigner } from '@pollar/core';
3
3
  import { createContext, forwardRef, useState, useCallback, useEffect, useMemo, useRef, useContext, useSyncExternalStore, useId, useLayoutEffect, Component } from 'react';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
5
  import { createPortal } from 'react-dom';
@@ -1309,7 +1309,7 @@ var PollarModalFooter = ({ language: languageProp }) => {
1309
1309
  /* @__PURE__ */ jsx("img", { src: LOGO_POLLAR_WORDMARK_ON_DARK, alt: "Pollar", className: "pollar-footer-logo pollar-logo-on-dark" }),
1310
1310
  /* @__PURE__ */ jsxs("span", { className: "pollar-footer-version", children: [
1311
1311
  "v",
1312
- "0.12.1-rc.22"
1312
+ "0.12.1-rc.25"
1313
1313
  ] })
1314
1314
  ] });
1315
1315
  };
@@ -3554,6 +3554,21 @@ function useInlineConfirmation(active) {
3554
3554
  useEffect(() => active ? registerConfirmationHost() : void 0, [active, registerConfirmationHost]);
3555
3555
  return active ? confirmations[0] ?? null : null;
3556
3556
  }
3557
+ function useDeclineOnClose(confirmation) {
3558
+ const pending = useRef(0);
3559
+ const track = useCallback(async (call) => {
3560
+ pending.current += 1;
3561
+ try {
3562
+ return await call;
3563
+ } finally {
3564
+ pending.current -= 1;
3565
+ }
3566
+ }, []);
3567
+ const declineOnClose = useCallback(() => {
3568
+ if (pending.current > 0) confirmation?.reject();
3569
+ }, [confirmation]);
3570
+ return { track, declineOnClose };
3571
+ }
3557
3572
  function assetKey2(record) {
3558
3573
  return record.code + (record.issuer ?? "");
3559
3574
  }
@@ -3663,12 +3678,14 @@ var KYC_COPY = {
3663
3678
  en: {
3664
3679
  errors: {
3665
3680
  SDK_KYC_NOT_CONFIGURED: "Identity verification is not available for this app yet.",
3681
+ // The vendor's account ran out of credits: the operator tops it up, the app's setup is fine.
3682
+ "SDK_KYC_NOT_CONFIGURED:provider_credits_exhausted": "Identity verification is temporarily unavailable. Please try again later.",
3666
3683
  SDK_KYC_PROVIDER_ERROR: "The verification service is not responding right now. Please try again in a moment.",
3667
3684
  SDK_KYC_SESSION_EXPIRED: "Your previous verification session expired. Select the provider to start a new one.",
3668
3685
  SDK_KYC_PROVIDER_NOT_FOUND: "This verification option is no longer available. Refresh to see the current options.",
3669
3686
  SDK_KYC_PROVIDER_NOT_ENABLED: "This verification option is no longer available. Refresh to see the current options.",
3670
3687
  SDK_RAMPS_PROVIDER_NOT_CONFIGURED: "This route is not set up for identity verification yet.",
3671
- VALIDATION_ERROR: "This verification option is not available for your country."
3688
+ VALIDATION_ERROR: "This verification option could not be started. Please try again or choose another option."
3672
3689
  },
3673
3690
  loadFailed: "Could not load verification options. Please refresh to try again.",
3674
3691
  startFailed: "Could not start verification. Please try again.",
@@ -3728,12 +3745,13 @@ var KYC_COPY = {
3728
3745
  es: {
3729
3746
  errors: {
3730
3747
  SDK_KYC_NOT_CONFIGURED: "La verificaci\xF3n de identidad todav\xEDa no est\xE1 disponible para esta app.",
3748
+ "SDK_KYC_NOT_CONFIGURED:provider_credits_exhausted": "La verificaci\xF3n de identidad no est\xE1 disponible temporalmente. Intenta de nuevo m\xE1s tarde.",
3731
3749
  SDK_KYC_PROVIDER_ERROR: "El servicio de verificaci\xF3n no responde en este momento. Intenta de nuevo en un momento.",
3732
3750
  SDK_KYC_SESSION_EXPIRED: "Tu sesi\xF3n de verificaci\xF3n anterior venci\xF3. Elige el proveedor para iniciar una nueva.",
3733
3751
  SDK_KYC_PROVIDER_NOT_FOUND: "Esta opci\xF3n de verificaci\xF3n ya no est\xE1 disponible. Actualiza para ver las opciones actuales.",
3734
3752
  SDK_KYC_PROVIDER_NOT_ENABLED: "Esta opci\xF3n de verificaci\xF3n ya no est\xE1 disponible. Actualiza para ver las opciones actuales.",
3735
3753
  SDK_RAMPS_PROVIDER_NOT_CONFIGURED: "Esta ruta todav\xEDa no est\xE1 configurada para la verificaci\xF3n de identidad.",
3736
- VALIDATION_ERROR: "Esta opci\xF3n de verificaci\xF3n no est\xE1 disponible para tu pa\xEDs."
3754
+ VALIDATION_ERROR: "No se pudo iniciar esta opci\xF3n de verificaci\xF3n. Intenta de nuevo o elige otra opci\xF3n."
3737
3755
  },
3738
3756
  loadFailed: "No se pudieron cargar las opciones de verificaci\xF3n. Actualiza para intentar de nuevo.",
3739
3757
  startFailed: "No se pudo iniciar la verificaci\xF3n. Intenta de nuevo.",
@@ -3793,12 +3811,13 @@ var KYC_COPY = {
3793
3811
  pt: {
3794
3812
  errors: {
3795
3813
  SDK_KYC_NOT_CONFIGURED: "A verifica\xE7\xE3o de identidade ainda n\xE3o est\xE1 dispon\xEDvel para este app.",
3814
+ "SDK_KYC_NOT_CONFIGURED:provider_credits_exhausted": "A verifica\xE7\xE3o de identidade est\xE1 temporariamente indispon\xEDvel. Tente de novo mais tarde.",
3796
3815
  SDK_KYC_PROVIDER_ERROR: "O servi\xE7o de verifica\xE7\xE3o n\xE3o est\xE1 respondendo agora. Tente de novo em instantes.",
3797
3816
  SDK_KYC_SESSION_EXPIRED: "Sua sess\xE3o de verifica\xE7\xE3o anterior expirou. Escolha o provedor para iniciar uma nova.",
3798
3817
  SDK_KYC_PROVIDER_NOT_FOUND: "Esta op\xE7\xE3o de verifica\xE7\xE3o n\xE3o est\xE1 mais dispon\xEDvel. Atualize para ver as op\xE7\xF5es atuais.",
3799
3818
  SDK_KYC_PROVIDER_NOT_ENABLED: "Esta op\xE7\xE3o de verifica\xE7\xE3o n\xE3o est\xE1 mais dispon\xEDvel. Atualize para ver as op\xE7\xF5es atuais.",
3800
3819
  SDK_RAMPS_PROVIDER_NOT_CONFIGURED: "Esta rota ainda n\xE3o est\xE1 configurada para a verifica\xE7\xE3o de identidade.",
3801
- VALIDATION_ERROR: "Esta op\xE7\xE3o de verifica\xE7\xE3o n\xE3o est\xE1 dispon\xEDvel para o seu pa\xEDs."
3820
+ VALIDATION_ERROR: "N\xE3o foi poss\xEDvel iniciar esta op\xE7\xE3o de verifica\xE7\xE3o. Tente de novo ou escolha outra op\xE7\xE3o."
3802
3821
  },
3803
3822
  loadFailed: "N\xE3o foi poss\xEDvel carregar as op\xE7\xF5es de verifica\xE7\xE3o. Atualize para tentar de novo.",
3804
3823
  startFailed: "N\xE3o foi poss\xEDvel iniciar a verifica\xE7\xE3o. Tente de novo.",
@@ -3879,12 +3898,11 @@ function KycStatus({ status, label, className, language: languageProp }) {
3879
3898
  }
3880
3899
  );
3881
3900
  }
3882
-
3883
- // src/components/kyc-modal/kyc-messages.ts
3884
3901
  function kycErrorMessage(error, phase, language = "en") {
3885
3902
  const copy = KYC_COPY[language];
3886
3903
  const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
3887
- const known = typeof code === "string" ? copy.errors[code] : void 0;
3904
+ const reason = isPollarApiError(error) && typeof error.body.reason === "string" ? error.body.reason : void 0;
3905
+ const known = typeof code === "string" ? reason && copy.errors[`${code}:${reason}`] || copy.errors[code] : void 0;
3888
3906
  if (known) return known;
3889
3907
  return phase === "load" ? copy.loadFailed : copy.startFailed;
3890
3908
  }
@@ -4885,6 +4903,22 @@ function WalletAdapterButtons({
4885
4903
  a.id
4886
4904
  )) });
4887
4905
  }
4906
+ function CloseButton({ onClick, label }) {
4907
+ return /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-close-btn", onClick, "aria-label": label, children: /* @__PURE__ */ jsx(
4908
+ "svg",
4909
+ {
4910
+ width: "18",
4911
+ height: "18",
4912
+ viewBox: "0 0 24 24",
4913
+ fill: "none",
4914
+ stroke: "currentColor",
4915
+ strokeWidth: "2.5",
4916
+ strokeLinecap: "round",
4917
+ strokeLinejoin: "round",
4918
+ children: /* @__PURE__ */ jsx("path", { d: "M18 6L6 18M6 6l12 12" })
4919
+ }
4920
+ ) });
4921
+ }
4888
4922
  function authStateToStatus(step) {
4889
4923
  const loading = [
4890
4924
  "creating_session",
@@ -4929,7 +4963,8 @@ function LoginModalTemplate({
4929
4963
  onBack,
4930
4964
  onCancel,
4931
4965
  onRetry,
4932
- language: languageProp
4966
+ language: languageProp,
4967
+ inline = false
4933
4968
  }) {
4934
4969
  const language = useInheritedLanguage(languageProp);
4935
4970
  const copy = LOGIN_COPY[language];
@@ -4965,160 +5000,155 @@ function LoginModalTemplate({
4965
5000
  children: /* @__PURE__ */ jsx("path", { d: "M15 19l-7-7 7-7" })
4966
5001
  }
4967
5002
  ) });
4968
- return /* @__PURE__ */ jsxs("div", { className: "pollar-modal-card pollar-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
4969
- /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-close-btn", onClick: onCancel, "aria-label": copy.close, children: /* @__PURE__ */ jsx(
4970
- "svg",
4971
- {
4972
- width: "18",
4973
- height: "18",
4974
- viewBox: "0 0 24 24",
4975
- fill: "none",
4976
- stroke: "currentColor",
4977
- strokeWidth: "2.5",
4978
- strokeLinecap: "round",
4979
- strokeLinejoin: "round",
4980
- children: /* @__PURE__ */ jsx("path", { d: "M18 6L6 18M6 6l12 12" })
4981
- }
4982
- ) }),
4983
- /* @__PURE__ */ jsxs("div", { className: "pollar-header", children: [
4984
- /* @__PURE__ */ jsx("div", { className: "pollar-logo-wrap", children: /* @__PURE__ */ jsx(ModalLogo, { logoUrl }) }),
4985
- /* @__PURE__ */ jsx("h2", { className: "pollar-title", children: appName }),
4986
- /* @__PURE__ */ jsx("p", { className: "pollar-subtitle", children: copy.subtitle })
4987
- ] }),
4988
- awaitingEmailCode ? /* @__PURE__ */ jsxs(Fragment, { children: [
4989
- /* @__PURE__ */ jsx(BackButton, { onClick: onBack }),
4990
- /* @__PURE__ */ jsx(EmailCodeInput, { email, onSubmit: onCodeSubmit ?? (() => {
4991
- }), language }, codeInputKey)
4992
- ] }) : activeGroup ? /* @__PURE__ */ jsxs(Fragment, { children: [
4993
- /* @__PURE__ */ jsx(BackButton, { onClick: () => setActiveGroup(null) }),
4994
- /* @__PURE__ */ jsx(
4995
- WalletAdapterButtons,
4996
- {
4997
- walletAdapters: activeGroupAdapters,
4998
- onConnect: onWalletConnect ?? (() => {
4999
- }),
5000
- isLoading
5001
- }
5002
- )
5003
- ] }) : showPasskeyChooser ? /* @__PURE__ */ jsxs(Fragment, { children: [
5004
- /* @__PURE__ */ jsx(BackButton, { onClick: () => setShowPasskeyChooser(false) }),
5005
- /* @__PURE__ */ jsxs("div", { className: "pollar-wallet-section", children: [
5006
- /* @__PURE__ */ jsx("button", { type: "button", disabled: isLoading, className: "pollar-btn-primary", onClick: onCreateSmartWallet, children: copy.createNewWallet }),
5007
- /* @__PURE__ */ jsx("button", { type: "button", disabled: isLoading, className: "pollar-wallet-entry-btn", onClick: onLoginSmartWallet, children: copy.loginExistingWallet })
5008
- ] })
5009
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
5010
- emailEnabled && /* @__PURE__ */ jsxs("div", { className: "pollar-email-section", children: [
5011
- /* @__PURE__ */ jsx(
5012
- "input",
5013
- {
5014
- type: "email",
5015
- placeholder: copy.emailPlaceholder,
5016
- value: email,
5017
- disabled: isLoading,
5018
- className: "pollar-input",
5019
- onChange: (e) => onEmailChange?.(e.target.value),
5020
- onKeyDown: (e) => e.key === "Enter" && onEmailSubmit?.()
5021
- }
5022
- ),
5023
- /* @__PURE__ */ jsx(
5024
- "button",
5025
- {
5026
- type: "button",
5027
- disabled: isLoading || !email,
5028
- className: "pollar-btn-primary",
5029
- style: { marginTop: "0.75rem" },
5030
- onClick: onEmailSubmit,
5031
- children: copy.submit
5032
- }
5033
- )
5034
- ] }),
5035
- emailEnabled && enabledSocial.length > 0 && /* @__PURE__ */ jsxs("div", { className: "pollar-divider", children: [
5036
- /* @__PURE__ */ jsx("div", { className: "pollar-divider-line" }),
5037
- /* @__PURE__ */ jsx("div", { className: "pollar-divider-label", children: /* @__PURE__ */ jsx("span", { className: "pollar-divider-text", children: copy.orContinueWith }) })
5038
- ] }),
5039
- enabledSocial.length > 0 && /* @__PURE__ */ jsxs("div", { className: "pollar-social-list", children: [
5040
- enabledSocial.some(([key]) => key === "google") && /* @__PURE__ */ jsx(GoogleButton, { disabled: isLoading, onClick: () => onSocialLogin?.("google") }),
5041
- enabledSocial.some(([key]) => key === "github") && /* @__PURE__ */ jsx(GithubButton, { disabled: isLoading, onClick: () => onSocialLogin?.("github") })
5042
- ] }),
5043
- (embeddedWallets || smartWallet) && /* @__PURE__ */ jsxs("div", { className: "pollar-wallet-section", children: [
5044
- embeddedWallets && /* @__PURE__ */ jsxs(Fragment, { children: [
5045
- walletGroups.map((g) => /* @__PURE__ */ jsxs(
5046
- "button",
5047
- {
5048
- type: "button",
5049
- disabled: isLoading,
5050
- className: "pollar-wallet-entry-btn",
5051
- onClick: () => setActiveGroup(g.label),
5052
- children: [
5053
- /* @__PURE__ */ jsx(
5054
- "svg",
5055
- {
5056
- width: "18",
5057
- height: "20",
5058
- viewBox: "0 0 24 24",
5059
- fill: "none",
5060
- stroke: "currentColor",
5061
- strokeWidth: "2",
5062
- strokeLinecap: "round",
5063
- strokeLinejoin: "round",
5064
- children: /* @__PURE__ */ jsx("path", { d: "M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z" })
5065
- }
5066
- ),
5067
- g.label
5068
- ]
5069
- },
5070
- g.label
5071
- )),
5072
- rootAdapters.length > 0 && /* @__PURE__ */ jsx(
5003
+ return /* @__PURE__ */ jsxs(
5004
+ "div",
5005
+ {
5006
+ className: `pollar-modal-card pollar-modal ${inline ? "pollar-modal-card--inline" : ""}`,
5007
+ style: cssVars,
5008
+ onClick: (e) => e.stopPropagation(),
5009
+ children: [
5010
+ !inline && /* @__PURE__ */ jsx(CloseButton, { onClick: onCancel, label: copy.close }),
5011
+ /* @__PURE__ */ jsxs("div", { className: "pollar-header", children: [
5012
+ /* @__PURE__ */ jsx("div", { className: "pollar-logo-wrap", children: /* @__PURE__ */ jsx(ModalLogo, { logoUrl }) }),
5013
+ /* @__PURE__ */ jsx("h2", { className: "pollar-title", children: appName }),
5014
+ /* @__PURE__ */ jsx("p", { className: "pollar-subtitle", children: copy.subtitle })
5015
+ ] }),
5016
+ awaitingEmailCode ? /* @__PURE__ */ jsxs(Fragment, { children: [
5017
+ /* @__PURE__ */ jsx(BackButton, { onClick: onBack }),
5018
+ /* @__PURE__ */ jsx(EmailCodeInput, { email, onSubmit: onCodeSubmit ?? (() => {
5019
+ }), language }, codeInputKey)
5020
+ ] }) : activeGroup ? /* @__PURE__ */ jsxs(Fragment, { children: [
5021
+ /* @__PURE__ */ jsx(BackButton, { onClick: () => setActiveGroup(null) }),
5022
+ /* @__PURE__ */ jsx(
5073
5023
  WalletAdapterButtons,
5074
5024
  {
5075
- walletAdapters: rootAdapters,
5025
+ walletAdapters: activeGroupAdapters,
5076
5026
  onConnect: onWalletConnect ?? (() => {
5077
5027
  }),
5078
- isLoading,
5079
- variant: "entry"
5028
+ isLoading
5080
5029
  }
5081
5030
  )
5082
- ] }),
5083
- smartWallet && /* @__PURE__ */ jsxs(
5084
- "button",
5085
- {
5086
- type: "button",
5087
- disabled: isLoading,
5088
- className: "pollar-wallet-entry-btn",
5089
- onClick: () => setShowPasskeyChooser(true),
5090
- children: [
5091
- /* @__PURE__ */ jsx(
5092
- "svg",
5031
+ ] }) : showPasskeyChooser ? /* @__PURE__ */ jsxs(Fragment, { children: [
5032
+ /* @__PURE__ */ jsx(BackButton, { onClick: () => setShowPasskeyChooser(false) }),
5033
+ /* @__PURE__ */ jsxs("div", { className: "pollar-wallet-section", children: [
5034
+ /* @__PURE__ */ jsx("button", { type: "button", disabled: isLoading, className: "pollar-btn-primary", onClick: onCreateSmartWallet, children: copy.createNewWallet }),
5035
+ /* @__PURE__ */ jsx("button", { type: "button", disabled: isLoading, className: "pollar-wallet-entry-btn", onClick: onLoginSmartWallet, children: copy.loginExistingWallet })
5036
+ ] })
5037
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
5038
+ emailEnabled && /* @__PURE__ */ jsxs("div", { className: "pollar-email-section", children: [
5039
+ /* @__PURE__ */ jsx(
5040
+ "input",
5041
+ {
5042
+ type: "email",
5043
+ placeholder: copy.emailPlaceholder,
5044
+ value: email,
5045
+ disabled: isLoading,
5046
+ className: "pollar-input",
5047
+ onChange: (e) => onEmailChange?.(e.target.value),
5048
+ onKeyDown: (e) => e.key === "Enter" && onEmailSubmit?.()
5049
+ }
5050
+ ),
5051
+ /* @__PURE__ */ jsx(
5052
+ "button",
5053
+ {
5054
+ type: "button",
5055
+ disabled: isLoading || !email,
5056
+ className: "pollar-btn-primary",
5057
+ style: { marginTop: "0.75rem" },
5058
+ onClick: onEmailSubmit,
5059
+ children: copy.submit
5060
+ }
5061
+ )
5062
+ ] }),
5063
+ emailEnabled && enabledSocial.length > 0 && /* @__PURE__ */ jsxs("div", { className: "pollar-divider", children: [
5064
+ /* @__PURE__ */ jsx("div", { className: "pollar-divider-line" }),
5065
+ /* @__PURE__ */ jsx("div", { className: "pollar-divider-label", children: /* @__PURE__ */ jsx("span", { className: "pollar-divider-text", children: copy.orContinueWith }) })
5066
+ ] }),
5067
+ enabledSocial.length > 0 && /* @__PURE__ */ jsxs("div", { className: "pollar-social-list", children: [
5068
+ enabledSocial.some(([key]) => key === "google") && /* @__PURE__ */ jsx(GoogleButton, { disabled: isLoading, onClick: () => onSocialLogin?.("google") }),
5069
+ enabledSocial.some(([key]) => key === "github") && /* @__PURE__ */ jsx(GithubButton, { disabled: isLoading, onClick: () => onSocialLogin?.("github") })
5070
+ ] }),
5071
+ (embeddedWallets || smartWallet) && /* @__PURE__ */ jsxs("div", { className: "pollar-wallet-section", children: [
5072
+ embeddedWallets && /* @__PURE__ */ jsxs(Fragment, { children: [
5073
+ walletGroups.map((g) => /* @__PURE__ */ jsxs(
5074
+ "button",
5093
5075
  {
5094
- width: "18",
5095
- height: "20",
5096
- viewBox: "0 0 24 24",
5097
- fill: "none",
5098
- stroke: "currentColor",
5099
- strokeWidth: "2",
5100
- strokeLinecap: "round",
5101
- strokeLinejoin: "round",
5102
- children: /* @__PURE__ */ jsx("path", { d: "M16 8V6a4 4 0 00-8 0v2M5 8h14a1 1 0 011 1v10a1 1 0 01-1 1H5a1 1 0 01-1-1V9a1 1 0 011-1zm7 5v2" })
5076
+ type: "button",
5077
+ disabled: isLoading,
5078
+ className: "pollar-wallet-entry-btn",
5079
+ onClick: () => setActiveGroup(g.label),
5080
+ children: [
5081
+ /* @__PURE__ */ jsx(
5082
+ "svg",
5083
+ {
5084
+ width: "18",
5085
+ height: "20",
5086
+ viewBox: "0 0 24 24",
5087
+ fill: "none",
5088
+ stroke: "currentColor",
5089
+ strokeWidth: "2",
5090
+ strokeLinecap: "round",
5091
+ strokeLinejoin: "round",
5092
+ children: /* @__PURE__ */ jsx("path", { d: "M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z" })
5093
+ }
5094
+ ),
5095
+ g.label
5096
+ ]
5097
+ },
5098
+ g.label
5099
+ )),
5100
+ rootAdapters.length > 0 && /* @__PURE__ */ jsx(
5101
+ WalletAdapterButtons,
5102
+ {
5103
+ walletAdapters: rootAdapters,
5104
+ onConnect: onWalletConnect ?? (() => {
5105
+ }),
5106
+ isLoading,
5107
+ variant: "entry"
5103
5108
  }
5104
- ),
5105
- "Smart Wallet"
5106
- ]
5109
+ )
5110
+ ] }),
5111
+ smartWallet && /* @__PURE__ */ jsxs(
5112
+ "button",
5113
+ {
5114
+ type: "button",
5115
+ disabled: isLoading,
5116
+ className: "pollar-wallet-entry-btn",
5117
+ onClick: () => setShowPasskeyChooser(true),
5118
+ children: [
5119
+ /* @__PURE__ */ jsx(
5120
+ "svg",
5121
+ {
5122
+ width: "18",
5123
+ height: "20",
5124
+ viewBox: "0 0 24 24",
5125
+ fill: "none",
5126
+ stroke: "currentColor",
5127
+ strokeWidth: "2",
5128
+ strokeLinecap: "round",
5129
+ strokeLinejoin: "round",
5130
+ children: /* @__PURE__ */ jsx("path", { d: "M16 8V6a4 4 0 00-8 0v2M5 8h14a1 1 0 011 1v10a1 1 0 01-1 1H5a1 1 0 01-1-1V9a1 1 0 011-1zm7 5v2" })
5131
+ }
5132
+ ),
5133
+ "Smart Wallet"
5134
+ ]
5135
+ }
5136
+ )
5137
+ ] })
5138
+ ] }),
5139
+ /* @__PURE__ */ jsx(
5140
+ ModalStatusBanner,
5141
+ {
5142
+ message: statusMessage,
5143
+ status,
5144
+ onCancel,
5145
+ onRetry: isEmailCodeError ? void 0 : onRetry
5107
5146
  }
5108
- )
5109
- ] })
5110
- ] }),
5111
- /* @__PURE__ */ jsx(
5112
- ModalStatusBanner,
5113
- {
5114
- message: statusMessage,
5115
- status,
5116
- onCancel,
5117
- onRetry: isEmailCodeError ? void 0 : onRetry
5118
- }
5119
- ),
5120
- /* @__PURE__ */ jsx(PollarModalFooter, {})
5121
- ] });
5147
+ ),
5148
+ /* @__PURE__ */ jsx(PollarModalFooter, {})
5149
+ ]
5150
+ }
5151
+ );
5122
5152
  }
5123
5153
  function LoginModalStatus({
5124
5154
  status,
@@ -5129,40 +5159,36 @@ function LoginModalStatus({
5129
5159
  appName,
5130
5160
  onRetry,
5131
5161
  onCancel,
5132
- language: languageProp
5162
+ language: languageProp,
5163
+ inline = false
5133
5164
  }) {
5134
5165
  const language = useInheritedLanguage(languageProp);
5135
5166
  const copy = LOGIN_COPY[language];
5136
5167
  const cssVars = buildModalCssVars(theme, accentColor, styleOverrides, "hero");
5137
- return /* @__PURE__ */ jsxs("div", { className: "pollar-modal-card pollar-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
5138
- /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-close-btn", onClick: onCancel, "aria-label": copy.close, children: /* @__PURE__ */ jsx(
5139
- "svg",
5140
- {
5141
- width: "18",
5142
- height: "18",
5143
- viewBox: "0 0 24 24",
5144
- fill: "none",
5145
- stroke: "currentColor",
5146
- strokeWidth: "2.5",
5147
- strokeLinecap: "round",
5148
- strokeLinejoin: "round",
5149
- children: /* @__PURE__ */ jsx("path", { d: "M18 6L6 18M6 6l12 12" })
5150
- }
5151
- ) }),
5152
- /* @__PURE__ */ jsxs("div", { className: "pollar-header", children: [
5153
- /* @__PURE__ */ jsx("div", { className: "pollar-logo-wrap", children: /* @__PURE__ */ jsx(ModalLogo, { logoUrl }) }),
5154
- /* @__PURE__ */ jsx("h2", { className: "pollar-title", children: appName }),
5155
- /* @__PURE__ */ jsx("p", { className: "pollar-subtitle", children: copy.subtitle })
5156
- ] }),
5157
- status === "loading" ? /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
5158
- /* @__PURE__ */ jsx("div", { className: "pollar-spinner" }),
5159
- /* @__PURE__ */ jsx("span", { children: copy.loading })
5160
- ] }) : /* @__PURE__ */ jsxs("div", { className: "pollar-wallet-section", children: [
5161
- /* @__PURE__ */ jsx("p", { className: "pollar-modal-error", children: copy.loadError }),
5162
- /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-primary", onClick: onRetry, children: copy.tryAgain })
5163
- ] }),
5164
- /* @__PURE__ */ jsx(PollarModalFooter, {})
5165
- ] });
5168
+ return /* @__PURE__ */ jsxs(
5169
+ "div",
5170
+ {
5171
+ className: `pollar-modal-card pollar-modal ${inline ? "pollar-modal-card--inline" : ""}`,
5172
+ style: cssVars,
5173
+ onClick: (e) => e.stopPropagation(),
5174
+ children: [
5175
+ !inline && /* @__PURE__ */ jsx(CloseButton, { onClick: onCancel, label: copy.close }),
5176
+ /* @__PURE__ */ jsxs("div", { className: "pollar-header", children: [
5177
+ /* @__PURE__ */ jsx("div", { className: "pollar-logo-wrap", children: /* @__PURE__ */ jsx(ModalLogo, { logoUrl }) }),
5178
+ /* @__PURE__ */ jsx("h2", { className: "pollar-title", children: appName }),
5179
+ /* @__PURE__ */ jsx("p", { className: "pollar-subtitle", children: copy.subtitle })
5180
+ ] }),
5181
+ status === "loading" ? /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
5182
+ /* @__PURE__ */ jsx("div", { className: "pollar-spinner" }),
5183
+ /* @__PURE__ */ jsx("span", { children: copy.loading })
5184
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "pollar-wallet-section", children: [
5185
+ /* @__PURE__ */ jsx("p", { className: "pollar-modal-error", children: copy.loadError }),
5186
+ /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-primary", onClick: onRetry, children: copy.tryAgain })
5187
+ ] }),
5188
+ /* @__PURE__ */ jsx(PollarModalFooter, {})
5189
+ ]
5190
+ }
5191
+ );
5166
5192
  }
5167
5193
  function PrivyLoginSubmodal({
5168
5194
  adapter,
@@ -5174,7 +5200,8 @@ function PrivyLoginSubmodal({
5174
5200
  onBack,
5175
5201
  onCancel,
5176
5202
  onAuthenticated,
5177
- language
5203
+ language,
5204
+ inline = false
5178
5205
  }) {
5179
5206
  const copy = LOGIN_COPY[language];
5180
5207
  const options = useMemo(() => adapter.getAuthOptions(), [adapter]);
@@ -5238,70 +5265,65 @@ function PrivyLoginSubmodal({
5238
5265
  const showEmail = options.includes("email");
5239
5266
  const showGoogle = options.includes("google");
5240
5267
  const showGithub = options.includes("github");
5241
- return /* @__PURE__ */ jsxs("div", { className: "pollar-modal-card pollar-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
5242
- /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-close-btn", onClick: onCancel, "aria-label": copy.close, children: /* @__PURE__ */ jsx(
5243
- "svg",
5244
- {
5245
- width: "18",
5246
- height: "18",
5247
- viewBox: "0 0 24 24",
5248
- fill: "none",
5249
- stroke: "currentColor",
5250
- strokeWidth: "2.5",
5251
- strokeLinecap: "round",
5252
- strokeLinejoin: "round",
5253
- children: /* @__PURE__ */ jsx("path", { d: "M18 6L6 18M6 6l12 12" })
5254
- }
5255
- ) }),
5256
- /* @__PURE__ */ jsxs("div", { className: "pollar-header", children: [
5257
- /* @__PURE__ */ jsx("div", { className: "pollar-logo-wrap", children: /* @__PURE__ */ jsx(ModalLogo, { logoUrl }) }),
5258
- /* @__PURE__ */ jsx("h2", { className: "pollar-title", children: appName }),
5259
- /* @__PURE__ */ jsx("p", { className: "pollar-subtitle", children: adapter.meta.label })
5260
- ] }),
5261
- view === "email-code" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5262
- /* @__PURE__ */ jsx(BackButton, { onClick: () => setView("root") }),
5263
- /* @__PURE__ */ jsx(EmailCodeInput, { email, onSubmit: handleCodeSubmit, language })
5264
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
5265
- /* @__PURE__ */ jsx(BackButton, { onClick: onBack }),
5266
- showEmail && /* @__PURE__ */ jsxs("div", { className: "pollar-email-section", children: [
5267
- /* @__PURE__ */ jsx(
5268
- "input",
5269
- {
5270
- type: "email",
5271
- placeholder: copy.emailPlaceholder,
5272
- value: email,
5273
- disabled: isLoading,
5274
- className: "pollar-input",
5275
- onChange: (e) => setEmail(e.target.value),
5276
- onKeyDown: (e) => e.key === "Enter" && handleEmailSubmit()
5277
- }
5278
- ),
5279
- /* @__PURE__ */ jsx(
5280
- "button",
5281
- {
5282
- type: "button",
5283
- disabled: isLoading || !email,
5284
- className: "pollar-btn-primary",
5285
- style: { marginTop: "0.75rem" },
5286
- onClick: handleEmailSubmit,
5287
- children: copy.submit
5288
- }
5289
- )
5290
- ] }),
5291
- showEmail && (showGoogle || showGithub) && /* @__PURE__ */ jsxs("div", { className: "pollar-divider", children: [
5292
- /* @__PURE__ */ jsx("div", { className: "pollar-divider-line" }),
5293
- /* @__PURE__ */ jsx("div", { className: "pollar-divider-label", children: /* @__PURE__ */ jsx("span", { className: "pollar-divider-text", children: copy.orContinueWith }) })
5294
- ] }),
5295
- (showGoogle || showGithub) && /* @__PURE__ */ jsxs("div", { className: "pollar-social-list", children: [
5296
- showGoogle && /* @__PURE__ */ jsx(GoogleButton, { disabled: isLoading, onClick: () => handleOAuth("google") }),
5297
- showGithub && /* @__PURE__ */ jsx(GithubButton, { disabled: isLoading, onClick: () => handleOAuth("github") })
5298
- ] })
5299
- ] }),
5300
- /* @__PURE__ */ jsx(ModalStatusBanner, { message, status, onCancel, onRetry: void 0 }),
5301
- /* @__PURE__ */ jsx(PollarModalFooter, {})
5302
- ] });
5268
+ return /* @__PURE__ */ jsxs(
5269
+ "div",
5270
+ {
5271
+ className: `pollar-modal-card pollar-modal ${inline ? "pollar-modal-card--inline" : ""}`,
5272
+ style: cssVars,
5273
+ onClick: (e) => e.stopPropagation(),
5274
+ children: [
5275
+ !inline && /* @__PURE__ */ jsx(CloseButton, { onClick: onCancel, label: copy.close }),
5276
+ /* @__PURE__ */ jsxs("div", { className: "pollar-header", children: [
5277
+ /* @__PURE__ */ jsx("div", { className: "pollar-logo-wrap", children: /* @__PURE__ */ jsx(ModalLogo, { logoUrl }) }),
5278
+ /* @__PURE__ */ jsx("h2", { className: "pollar-title", children: appName }),
5279
+ /* @__PURE__ */ jsx("p", { className: "pollar-subtitle", children: adapter.meta.label })
5280
+ ] }),
5281
+ view === "email-code" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5282
+ /* @__PURE__ */ jsx(BackButton, { onClick: () => setView("root") }),
5283
+ /* @__PURE__ */ jsx(EmailCodeInput, { email, onSubmit: handleCodeSubmit, language })
5284
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
5285
+ /* @__PURE__ */ jsx(BackButton, { onClick: onBack }),
5286
+ showEmail && /* @__PURE__ */ jsxs("div", { className: "pollar-email-section", children: [
5287
+ /* @__PURE__ */ jsx(
5288
+ "input",
5289
+ {
5290
+ type: "email",
5291
+ placeholder: copy.emailPlaceholder,
5292
+ value: email,
5293
+ disabled: isLoading,
5294
+ className: "pollar-input",
5295
+ onChange: (e) => setEmail(e.target.value),
5296
+ onKeyDown: (e) => e.key === "Enter" && handleEmailSubmit()
5297
+ }
5298
+ ),
5299
+ /* @__PURE__ */ jsx(
5300
+ "button",
5301
+ {
5302
+ type: "button",
5303
+ disabled: isLoading || !email,
5304
+ className: "pollar-btn-primary",
5305
+ style: { marginTop: "0.75rem" },
5306
+ onClick: handleEmailSubmit,
5307
+ children: copy.submit
5308
+ }
5309
+ )
5310
+ ] }),
5311
+ showEmail && (showGoogle || showGithub) && /* @__PURE__ */ jsxs("div", { className: "pollar-divider", children: [
5312
+ /* @__PURE__ */ jsx("div", { className: "pollar-divider-line" }),
5313
+ /* @__PURE__ */ jsx("div", { className: "pollar-divider-label", children: /* @__PURE__ */ jsx("span", { className: "pollar-divider-text", children: copy.orContinueWith }) })
5314
+ ] }),
5315
+ (showGoogle || showGithub) && /* @__PURE__ */ jsxs("div", { className: "pollar-social-list", children: [
5316
+ showGoogle && /* @__PURE__ */ jsx(GoogleButton, { disabled: isLoading, onClick: () => handleOAuth("google") }),
5317
+ showGithub && /* @__PURE__ */ jsx(GithubButton, { disabled: isLoading, onClick: () => handleOAuth("github") })
5318
+ ] })
5319
+ ] }),
5320
+ /* @__PURE__ */ jsx(ModalStatusBanner, { message, status, onCancel, onRetry: void 0 }),
5321
+ /* @__PURE__ */ jsx(PollarModalFooter, {})
5322
+ ]
5323
+ }
5324
+ );
5303
5325
  }
5304
- function LoginModal({ onClose }) {
5326
+ function LoginModal({ onClose, inline = false }) {
5305
5327
  const [email, setEmail] = useState("");
5306
5328
  const { getClient, styles, appConfig: config, configStatus, retryConfig } = usePollar();
5307
5329
  const [authState, setAuthState] = useState(() => getClient().getAuthState());
@@ -5396,7 +5418,7 @@ function LoginModal({ onClose }) {
5396
5418
  getClient().login({ provider });
5397
5419
  }
5398
5420
  }
5399
- return /* @__PURE__ */ jsx(PollarOverlay, { style: overlayStyle, onClick: handleClose, children: configStatus !== "ready" ? /* @__PURE__ */ jsx(
5421
+ return /* @__PURE__ */ jsx(ModalFrame, { inline, overlayStyle, onClose: handleClose, children: configStatus !== "ready" ? /* @__PURE__ */ jsx(
5400
5422
  LoginModalStatus,
5401
5423
  {
5402
5424
  status: configStatus === "error" ? "error" : "loading",
@@ -5407,7 +5429,8 @@ function LoginModal({ onClose }) {
5407
5429
  appName: modalTitle,
5408
5430
  onRetry: retryConfig,
5409
5431
  onCancel: handleClose,
5410
- language
5432
+ language,
5433
+ inline
5411
5434
  }
5412
5435
  ) : interactiveAdapter ? /* @__PURE__ */ jsx(
5413
5436
  PrivyLoginSubmodal,
@@ -5421,7 +5444,8 @@ function LoginModal({ onClose }) {
5421
5444
  onBack: () => setInteractiveAdapter(null),
5422
5445
  onCancel: handleClose,
5423
5446
  onAuthenticated: handleInteractiveAuthenticated,
5424
- language
5447
+ language,
5448
+ inline
5425
5449
  }
5426
5450
  ) : /* @__PURE__ */ jsx(
5427
5451
  LoginModalTemplate,
@@ -5455,7 +5479,8 @@ function LoginModal({ onClose }) {
5455
5479
  onBack: handleBack,
5456
5480
  onCancel: handleClose,
5457
5481
  onRetry: handleRetry,
5458
- language
5482
+ language,
5483
+ inline
5459
5484
  }
5460
5485
  ) });
5461
5486
  }
@@ -5603,6 +5628,21 @@ var RAMP_COPY = {
5603
5628
  startAnother: "Start another operation",
5604
5629
  newQuote: "Get a new quote",
5605
5630
  keepsGoing: "This one keeps going; you can resume it later.",
5631
+ screens: {
5632
+ pay: (amount, currency) => `Pay ${amount} ${currency}`,
5633
+ send: (amount, code) => `Send ${amount} ${code}`,
5634
+ delivering: (code) => `Your ${code} is on its way`,
5635
+ payingOut: (currency) => `Your ${currency} is on its way to your account`,
5636
+ done: "Done",
5637
+ toCurrent: "Go to the current step",
5638
+ updatesItself: "This screen updates on its own.",
5639
+ preparing: "Preparing your payment\u2026",
5640
+ received: (amount) => `+${amount}`,
5641
+ arrived: (chain) => `It reached your wallet on ${chain}.`,
5642
+ paidOut: "It was sent to your account.",
5643
+ finish: "Done",
5644
+ details: "Details"
5645
+ },
5606
5646
  somethingWrong: "Something went wrong.",
5607
5647
  routeSteps: (count) => count === 1 ? "1 step" : `${count} steps`,
5608
5648
  feesIncluded: "fees included",
@@ -5734,6 +5774,21 @@ var RAMP_COPY = {
5734
5774
  startAnother: "Iniciar otra operaci\xF3n",
5735
5775
  newQuote: "Pedir nueva cotizaci\xF3n",
5736
5776
  keepsGoing: "Esta sigue en curso; puedes retomarla m\xE1s tarde.",
5777
+ screens: {
5778
+ pay: (amount, currency) => `Paga ${amount} ${currency}`,
5779
+ send: (amount, code) => `Env\xEDa ${amount} ${code}`,
5780
+ delivering: (code) => `Tu ${code} est\xE1 en camino`,
5781
+ payingOut: (currency) => `Tus ${currency} van en camino a tu cuenta`,
5782
+ done: "Hecho",
5783
+ toCurrent: "Ir al paso actual",
5784
+ updatesItself: "Esta pantalla se actualiza sola.",
5785
+ preparing: "Preparando tu pago\u2026",
5786
+ received: (amount) => `+${amount}`,
5787
+ arrived: (chain) => `Lleg\xF3 a tu wallet en ${chain}.`,
5788
+ paidOut: "Se envi\xF3 a tu cuenta.",
5789
+ finish: "Listo",
5790
+ details: "Detalles"
5791
+ },
5737
5792
  somethingWrong: "Algo sali\xF3 mal.",
5738
5793
  routeSteps: (count) => count === 1 ? "1 paso" : `${count} pasos`,
5739
5794
  feesIncluded: "comisiones incluidas",
@@ -5865,6 +5920,21 @@ var RAMP_COPY = {
5865
5920
  startAnother: "Iniciar outra opera\xE7\xE3o",
5866
5921
  newQuote: "Pedir nova cota\xE7\xE3o",
5867
5922
  keepsGoing: "Esta continua em andamento; voc\xEA pode retom\xE1-la depois.",
5923
+ screens: {
5924
+ pay: (amount, currency) => `Pague ${amount} ${currency}`,
5925
+ send: (amount, code) => `Envie ${amount} ${code}`,
5926
+ delivering: (code) => `Seu ${code} est\xE1 a caminho`,
5927
+ payingOut: (currency) => `Seus ${currency} est\xE3o a caminho da sua conta`,
5928
+ done: "Conclu\xEDdo",
5929
+ toCurrent: "Ir para a etapa atual",
5930
+ updatesItself: "Esta tela se atualiza sozinha.",
5931
+ preparing: "Preparando o seu pagamento\u2026",
5932
+ received: (amount) => `+${amount}`,
5933
+ arrived: (chain) => `Chegou \xE0 sua carteira na ${chain}.`,
5934
+ paidOut: "Foi enviado para a sua conta.",
5935
+ finish: "Pronto",
5936
+ details: "Detalhes"
5937
+ },
5868
5938
  somethingWrong: "Algo deu errado.",
5869
5939
  routeSteps: (count) => count === 1 ? "1 etapa" : `${count} etapas`,
5870
5940
  feesIncluded: "taxas inclu\xEDdas",
@@ -6013,6 +6083,93 @@ function routeKey(quote) {
6013
6083
  const node = (n) => n.kind === "asset" ? `${n.code}:${n.chain}` : `${n.currency}:${n.rail}`;
6014
6084
  return quote.legs.map((leg) => `${leg.kind}:${node(leg.from)}>${node(leg.to)}`).join("|");
6015
6085
  }
6086
+ var amountText = (value, language) => {
6087
+ const n = Number(value);
6088
+ return Number.isFinite(n) ? n.toLocaleString(language, { maximumFractionDigits: 7 }) : value;
6089
+ };
6090
+ function rampOrderScreens(order, language) {
6091
+ const copy = RAMP_COPY[language].screens;
6092
+ const parts = [];
6093
+ const waitsOn = (leg) => order.pendingAction?.legIndex === leg.index && order.pendingAction.kind !== "NONE";
6094
+ for (const leg of order.legs) {
6095
+ const legStatus = rampLegStatus(leg);
6096
+ const legDone = legStatus === "done";
6097
+ if (leg.steps?.length) {
6098
+ let running = [];
6099
+ const flush = () => {
6100
+ if (!running.length) return;
6101
+ parts.push({
6102
+ key: `${leg.index}:${running[0].kind}`,
6103
+ kind: "wait",
6104
+ leg,
6105
+ steps: running,
6106
+ title: rampLegTitle(leg, language),
6107
+ done: legDone || running.every((s) => s.status === "done")
6108
+ });
6109
+ running = [];
6110
+ };
6111
+ for (const step of leg.steps) {
6112
+ if (!step.signs) {
6113
+ running.push(step);
6114
+ continue;
6115
+ }
6116
+ flush();
6117
+ parts.push({
6118
+ key: `${leg.index}:${step.kind}`,
6119
+ kind: "action",
6120
+ leg,
6121
+ steps: [step],
6122
+ title: rampStepTitle(step, leg, language),
6123
+ done: legDone || step.status === "done"
6124
+ });
6125
+ }
6126
+ flush();
6127
+ continue;
6128
+ }
6129
+ if (leg.kind === "PROVIDER_ONRAMP" || leg.kind === "PROVIDER_OFFRAMP") {
6130
+ const onramp = leg.kind === "PROVIDER_ONRAMP";
6131
+ const unitIn = leg.from.kind === "fiat" ? leg.from.currency : leg.from.code;
6132
+ const unitOut = leg.to.kind === "fiat" ? leg.to.currency : leg.to.code;
6133
+ const payment = leg.paymentStatus;
6134
+ const paid = payment === void 0 ? legStatus === "active" && !waitsOn(leg) : payment === "received";
6135
+ const amount = amountText(leg.amountInPlanned, language);
6136
+ parts.push({
6137
+ key: `${leg.index}:pay`,
6138
+ kind: "action",
6139
+ leg,
6140
+ steps: [],
6141
+ title: onramp ? copy.pay(amount, unitIn) : copy.send(amount, unitIn),
6142
+ done: legDone || paid,
6143
+ preparing: payment === "not_requested" && !waitsOn(leg)
6144
+ });
6145
+ parts.push({
6146
+ key: `${leg.index}:deliver`,
6147
+ kind: "wait",
6148
+ leg,
6149
+ steps: [],
6150
+ title: onramp ? copy.delivering(unitOut) : copy.payingOut(unitOut),
6151
+ done: legDone
6152
+ });
6153
+ continue;
6154
+ }
6155
+ parts.push({
6156
+ key: `${leg.index}`,
6157
+ kind: leg.signingMode ? "action" : "wait",
6158
+ leg,
6159
+ steps: [],
6160
+ title: rampLegTitle(leg, language),
6161
+ done: legDone
6162
+ });
6163
+ }
6164
+ const stopped = ["failed", "refunded"].includes(order.state);
6165
+ let currentFound = false;
6166
+ return parts.map(({ done, ...screen }) => {
6167
+ if (done) return { ...screen, status: "done" };
6168
+ if (currentFound) return { ...screen, status: "upcoming" };
6169
+ currentFound = true;
6170
+ return { ...screen, status: stopped || rampLegStatus(screen.leg) === "failed" ? "failed" : "current" };
6171
+ });
6172
+ }
6016
6173
  function scannableImageSrc(image) {
6017
6174
  return image.encoding === "base64" ? `data:${image.mediaType};base64,${image.data}` : `data:${image.mediaType};charset=utf-8,${encodeURIComponent(image.data)}`;
6018
6175
  }
@@ -6152,6 +6309,8 @@ function RampWidgetTemplate({
6152
6309
  const onramp = direction === "ONRAMP";
6153
6310
  const sendUnit = onramp ? fiat?.currency : asset?.code;
6154
6311
  const [detailsOpen, setDetailsOpen] = useState(false);
6312
+ const [viewing, setViewing] = useState(null);
6313
+ useEffect(() => setViewing(null), [order?.id]);
6155
6314
  const routeName = (quote) => quote.legs.map((leg) => rampLegTitle(leg, language)).join(" \xB7 ");
6156
6315
  const rate = (() => {
6157
6316
  if (!chosenQuote) return null;
@@ -6223,7 +6382,6 @@ function RampWidgetTemplate({
6223
6382
  ] : [];
6224
6383
  const running = order?.legs.find((leg) => rampLegStatus(leg) === "active" && order.pendingAction?.legIndex !== leg.index);
6225
6384
  const now = useNowEverySecond(step === "status" && !settled && !!running && running.etaSeconds !== null);
6226
- const nextApproval = order && !settled ? rampNextApproval(order, language) : null;
6227
6385
  const stopped = order ? rampOrderStopped(order) : false;
6228
6386
  const receive = order ? rampOrderReceive(order) : null;
6229
6387
  const waitsOnRecovery = order?.failure?.resolutionAction === "set_up_recovery";
@@ -6231,12 +6389,41 @@ function RampWidgetTemplate({
6231
6389
  const payBy = view?.action?.kind === "FIAT_PAYMENT" && view.expiresAt ? Date.parse(view.expiresAt) : null;
6232
6390
  useRenderAt(view?.canSign && view.expiresAt ? Date.parse(view.expiresAt) : null);
6233
6391
  const stepsOpen = !!onStepSelect && step !== "status" && !isLoading && startingQuoteId === null && trustingAsset === null && walletBusy === null;
6392
+ const screens = order ? rampOrderScreens(order, language) : [];
6393
+ const completed = order?.state === "completed";
6394
+ const firstOpen = screens.findIndex((s) => s.status !== "done");
6395
+ const currentScreen = completed ? screens.length : firstOpen === -1 ? Math.max(0, screens.length - 1) : firstOpen;
6396
+ const shownScreen = viewing !== null && viewing < currentScreen ? viewing : currentScreen;
6397
+ const shown = screens[shownScreen];
6398
+ const askedInstead = order?.pendingAction?.kind === "KYC" || !!shown?.key.endsWith(":pay") && order?.pendingAction?.legIndex === shown.leg.index && !["FIAT_PAYMENT", "NONE"].includes(order.pendingAction.kind);
6399
+ const firstLeg = order?.legs[0];
6400
+ const orderSummary = firstLeg && receive ? `${amountText(firstLeg.amountInPlanned, language)} ${firstLeg.from.kind === "fiat" ? firstLeg.from.currency : firstLeg.from.code} \u2192 ${receive.estimated ? "~" : ""}${amountText(receive.amount, language)} ${receive.unit}` : null;
6401
+ const lastLeg = order?.legs[order.legs.length - 1];
6402
+ const arrivedText = lastLeg?.to.kind === "asset" ? copy.screens.arrived(CHAIN_NAME[lastLeg.to.chain] ?? lastLeg.to.chain) : copy.screens.paidOut;
6403
+ const finalNote = order?.legs.map((leg) => rampLegNote(leg, language)).find((note) => note !== null) ?? null;
6404
+ const screenRows = (screen) => screen.steps.length ? screen.steps.flatMap(
6405
+ (st) => st.hash ? [
6406
+ {
6407
+ label: rampStepTitle(st, screen.leg, language),
6408
+ value: shortHash(st.hash),
6409
+ href: explorerTxUrl2(stepChain(st.kind, screen.leg), st.hash, network),
6410
+ copyValue: st.hash
6411
+ }
6412
+ ] : []
6413
+ ) : screen.leg.onchainTxHash && !screen.key.endsWith(":pay") ? [
6414
+ {
6415
+ label: rampLegTitle(screen.leg, language),
6416
+ value: shortHash(screen.leg.onchainTxHash),
6417
+ href: explorerTxUrl2(legChain(screen.leg), screen.leg.onchainTxHash, network),
6418
+ copyValue: screen.leg.onchainTxHash
6419
+ }
6420
+ ] : [];
6234
6421
  const stepTitle = {
6235
6422
  input: onramp ? copy.title.buy : copy.title.sell,
6236
6423
  loading_quote: copy.title.finding,
6237
6424
  select_route: copy.title.chooseRoute,
6238
6425
  contact: copy.title.details,
6239
- status: order?.state === "completed" ? copy.title.completed : onramp ? copy.title.purchase : copy.title.sale,
6426
+ status: onramp ? copy.title.purchase : copy.title.sale,
6240
6427
  error: copy.title.error
6241
6428
  };
6242
6429
  const stepSubtitle = {
@@ -6249,7 +6436,7 @@ function RampWidgetTemplate({
6249
6436
  copy
6250
6437
  )
6251
6438
  ),
6252
- status: view?.title ?? copy.subtitle.processing,
6439
+ status: orderSummary ?? copy.subtitle.processing,
6253
6440
  error: copy.subtitle.error
6254
6441
  };
6255
6442
  return /* @__PURE__ */ jsxs("div", { className: "pollar-modal-card pollar-ramp-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
@@ -6264,6 +6451,16 @@ function RampWidgetTemplate({
6264
6451
  children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M10 3 5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
6265
6452
  }
6266
6453
  ),
6454
+ step === "status" && shownScreen > 0 && shownScreen <= currentScreen && /* @__PURE__ */ jsx(
6455
+ "button",
6456
+ {
6457
+ type: "button",
6458
+ className: "pollar-back-btn pollar-ramp-back",
6459
+ onClick: () => setViewing(shownScreen - 1),
6460
+ "aria-label": copy.back,
6461
+ children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M10 3 5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
6462
+ }
6463
+ ),
6267
6464
  /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-header-text", children: [
6268
6465
  /* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: stepTitle[step] }),
6269
6466
  /* @__PURE__ */ jsx("p", { className: "pollar-ramp-subtitle", children: stepSubtitle[step] })
@@ -6320,6 +6517,15 @@ function RampWidgetTemplate({
6320
6517
  }
6321
6518
  ) }, label)) })
6322
6519
  ] }),
6520
+ step === "status" && screens.length > 0 && /* @__PURE__ */ jsx("ol", { className: "pollar-ramp-screens-bar", "aria-label": copy.progress, children: [...screens.map((s) => s.key), "final"].map((key, i) => /* @__PURE__ */ jsx(
6521
+ "li",
6522
+ {
6523
+ "data-done": i < currentScreen || completed && i === screens.length || void 0,
6524
+ "data-shown": i === shownScreen || void 0,
6525
+ "data-failed": screens[i]?.status === "failed" || void 0
6526
+ },
6527
+ key
6528
+ )) }),
6323
6529
  step === "input" && pendingOrders.length > 0 && /* @__PURE__ */ jsxs("section", { className: "pollar-ramp-payment pollar-ramp-saved", "aria-label": copy.pendingAria, children: [
6324
6530
  /* @__PURE__ */ jsx("p", { className: "pollar-ramp-payment-note", children: copy.pendingNote }),
6325
6531
  pendingOrders.map((pending) => /* @__PURE__ */ jsx("div", { className: "pollar-ramp-saved-row", children: /* @__PURE__ */ jsx(
@@ -6607,37 +6813,62 @@ function RampWidgetTemplate({
6607
6813
  }
6608
6814
  ) })
6609
6815
  ] }),
6610
- step === "status" && order && view && /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-payment", children: [
6611
- /* @__PURE__ */ jsx("ol", { className: "pollar-ramp-legs", "aria-label": copy.progress, children: order.legs.map((leg) => {
6612
- const status = rampLegStatus(leg);
6613
- const note = (status === "failed" && leg.failure ? rampFailureReason(leg.failure, language) : null) ?? rampLegNote(leg, language);
6614
- return /* @__PURE__ */ jsxs("li", { className: "pollar-ramp-leg", "data-status": status, children: [
6615
- /* @__PURE__ */ jsx("span", { className: "pollar-ramp-leg-dot", "aria-hidden": true }),
6616
- /* @__PURE__ */ jsx("span", { className: "pollar-ramp-leg-title", children: rampLegTitle(leg, language) }),
6617
- status === "active" && !settled && /* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-label": copy.inProgress }),
6618
- note && /* @__PURE__ */ jsx("span", { className: "pollar-ramp-leg-note", children: note }),
6619
- status === "active" && !settled && !!leg.steps?.length && /* @__PURE__ */ jsx("ol", { className: "pollar-ramp-steps", children: leg.steps.map((s) => /* @__PURE__ */ jsxs("li", { className: "pollar-ramp-step", "data-status": s.status, children: [
6620
- /* @__PURE__ */ jsx("span", { className: "pollar-ramp-step-title", children: rampStepTitle(s, leg, language) }),
6621
- /* @__PURE__ */ jsxs("span", { className: "pollar-ramp-step-state", children: [
6622
- s.status === "confirming" && /* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-hidden": true }),
6623
- rampStepStatusText(s, language)
6624
- ] })
6625
- ] }, s.kind)) }),
6626
- running === leg && !settled && rampLegTimeLeft(leg, now) !== null && /* @__PURE__ */ jsx("span", { className: "pollar-ramp-leg-eta", children: copy.timeLeft(rampLegTimeLeft(leg, now)) })
6627
- ] }, leg.index);
6628
- }) }),
6629
- confirmation && /* @__PURE__ */ jsx(InlineConfirm, { confirmation, language, network }),
6630
- /* @__PURE__ */ jsx(TxReview, { data: { title: "", kind: "other", rows: orderRows }, language }),
6631
- nextApproval && !order.pendingAction && /* @__PURE__ */ jsx("p", { className: "pollar-ramp-next", children: copy.next(nextApproval) }),
6632
- receive && /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-payment-field", children: [
6633
- /* @__PURE__ */ jsx("span", { className: "pollar-ramp-payment-label", children: order.state === "completed" ? copy.youReceived : copy.youReceive }),
6634
- /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-payment-value", children: [
6635
- receive.estimated && "~",
6636
- receive.amount,
6637
- " ",
6638
- receive.unit
6639
- ] })
6816
+ step === "status" && order && view && /* @__PURE__ */ jsx("div", { className: "pollar-ramp-payment", children: shownScreen === screens.length ? /* @__PURE__ */ jsxs(Fragment, { children: [
6817
+ /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-final", children: [
6818
+ /* @__PURE__ */ jsx("span", { className: "pollar-ramp-final-mark", "aria-hidden": true, children: /* @__PURE__ */ jsx("svg", { width: "28", height: "28", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsx(
6819
+ "path",
6820
+ {
6821
+ d: "M3 8.5 6.5 12 13 4.5",
6822
+ stroke: "currentColor",
6823
+ strokeWidth: "2",
6824
+ strokeLinecap: "round",
6825
+ strokeLinejoin: "round"
6826
+ }
6827
+ ) }) }),
6828
+ receive && /* @__PURE__ */ jsx("p", { className: "pollar-ramp-final-amount", children: copy.screens.received(`${amountText(receive.amount, language)} ${receive.unit}`) }),
6829
+ /* @__PURE__ */ jsx("p", { className: "pollar-ramp-payment-note", children: arrivedText }),
6830
+ finalNote && /* @__PURE__ */ jsx("p", { className: "pollar-ramp-payment-note", children: finalNote })
6640
6831
  ] }),
6832
+ /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-primary", onClick: onClose, children: copy.screens.finish }),
6833
+ /* @__PURE__ */ jsx(TxReview, { data: { title: "", kind: "other", rows: orderRows }, language })
6834
+ ] }) : shownScreen < currentScreen ? /* @__PURE__ */ jsxs(Fragment, { children: [
6835
+ /* @__PURE__ */ jsx("h3", { className: "pollar-ramp-screen-title", children: screens[shownScreen].title }),
6836
+ /* @__PURE__ */ jsxs("p", { className: "pollar-ramp-screen-state", children: [
6837
+ /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx(
6838
+ "path",
6839
+ {
6840
+ d: "M3 8.5 6.5 12 13 4.5",
6841
+ stroke: "currentColor",
6842
+ strokeWidth: "2",
6843
+ strokeLinecap: "round",
6844
+ strokeLinejoin: "round"
6845
+ }
6846
+ ) }),
6847
+ copy.screens.done
6848
+ ] }),
6849
+ screenRows(screens[shownScreen]).length > 0 && /* @__PURE__ */ jsx(TxReview, { data: { title: "", kind: "other", rows: screenRows(screens[shownScreen]) }, language }),
6850
+ /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: () => setViewing(null), children: copy.screens.toCurrent })
6851
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
6852
+ shown && /* @__PURE__ */ jsx("h3", { className: "pollar-ramp-screen-title", "data-status": shown.status, children: askedInstead ? view.title : shown.title }),
6853
+ shown?.status === "failed" && shown.leg.failure && /* @__PURE__ */ jsx("p", { className: "pollar-ramp-field-error", children: rampFailureReason(shown.leg.failure, language) }),
6854
+ shown?.preparing && !settled && !order.failure && /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-wait", children: [
6855
+ /* @__PURE__ */ jsx("span", { className: "pollar-spinner", "aria-label": copy.inProgress }),
6856
+ /* @__PURE__ */ jsx("p", { className: "pollar-ramp-payment-note", children: copy.screens.preparing })
6857
+ ] }),
6858
+ shown?.kind === "wait" && !settled && !order.failure && /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-wait", children: [
6859
+ /* @__PURE__ */ jsx("span", { className: "pollar-spinner", "aria-label": copy.inProgress }),
6860
+ rampLegTimeLeft(shown.leg, now) !== null && /* @__PURE__ */ jsx("span", { className: "pollar-ramp-leg-eta", children: copy.timeLeft(rampLegTimeLeft(shown.leg, now)) }),
6861
+ rampLegNote(shown.leg, language) && /* @__PURE__ */ jsx("p", { className: "pollar-ramp-payment-note", children: rampLegNote(shown.leg, language) }),
6862
+ /* @__PURE__ */ jsx("p", { className: "pollar-ramp-payment-note", children: copy.screens.updatesItself })
6863
+ ] }),
6864
+ shown && shown.steps.length > 1 && !settled && /* @__PURE__ */ jsx("ol", { className: "pollar-ramp-screen-steps", children: shown.steps.map((s) => /* @__PURE__ */ jsxs("li", { className: "pollar-ramp-step", "data-status": s.status, children: [
6865
+ /* @__PURE__ */ jsx("span", { className: "pollar-ramp-step-title", children: rampStepTitle(s, shown.leg, language) }),
6866
+ /* @__PURE__ */ jsxs("span", { className: "pollar-ramp-step-state", children: [
6867
+ s.status === "confirming" && /* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-hidden": true }),
6868
+ rampStepStatusText(s, language)
6869
+ ] })
6870
+ ] }, s.kind)) }),
6871
+ confirmation && /* @__PURE__ */ jsx(InlineConfirm, { confirmation, language, network }),
6641
6872
  order.failure && /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-payment-field", children: [
6642
6873
  /* @__PURE__ */ jsx("span", { className: "pollar-ramp-payment-label", children: copy.whatToDo }),
6643
6874
  /* @__PURE__ */ jsx("p", { className: "pollar-ramp-payment-note", children: rampOrderResolutionText(order, language) }),
@@ -6698,7 +6929,14 @@ function RampWidgetTemplate({
6698
6929
  /* @__PURE__ */ jsx("span", { className: "pollar-ramp-payment-label", children: view.pasteCode.label }),
6699
6930
  /* @__PURE__ */ jsx("div", { className: "pollar-ramp-payment-value", children: /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
6700
6931
  /* @__PURE__ */ jsx("code", { style: { flex: 1, wordBreak: "break-all" }, children: view.pasteCode.value }),
6701
- /* @__PURE__ */ jsx(CopyButton, { value: view.pasteCode.value, label: copy.copyLabel(view.pasteCode.label), language })
6932
+ /* @__PURE__ */ jsx(
6933
+ CopyButton,
6934
+ {
6935
+ value: view.pasteCode.value,
6936
+ label: copy.copyLabel(view.pasteCode.label),
6937
+ language
6938
+ }
6939
+ )
6702
6940
  ] }) })
6703
6941
  ] }),
6704
6942
  !settled && view.details.map((d) => /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-payment-field", children: [
@@ -6730,11 +6968,8 @@ function RampWidgetTemplate({
6730
6968
  !settled && order.pendingAction?.kind === "KYC" && !view.link && /* @__PURE__ */ jsx("p", { className: "pollar-ramp-payment-note", children: view.note ?? copy.providerReviewing }),
6731
6969
  pollTrouble && !settled && /* @__PURE__ */ jsx("p", { className: "pollar-ramp-payment-note", children: copy.serverTrouble }),
6732
6970
  errorMsg && /* @__PURE__ */ jsx("p", { className: "pollar-ramp-field-error", children: errorMsg }),
6733
- /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-explore", children: [
6734
- /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onNewOrder, children: copy.startAnother }),
6735
- !stopped && /* @__PURE__ */ jsx("p", { className: "pollar-ramp-payment-note", children: copy.keepsGoing })
6736
- ] })
6737
- ] }),
6971
+ !settled && /* @__PURE__ */ jsx("div", { className: "pollar-ramp-explore", children: /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onNewOrder, children: copy.startAnother }) })
6972
+ ] }) }),
6738
6973
  step === "error" && /* @__PURE__ */ jsxs(Fragment, { children: [
6739
6974
  /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: errorMsg ?? copy.somethingWrong }),
6740
6975
  /* @__PURE__ */ jsxs("div", { className: "pollar-modal-actions", children: [
@@ -6788,6 +7023,7 @@ var REGISTRY_COPY = {
6788
7023
  rejected: "The registry did not confirm: {fields}. Check how they are written and try again.",
6789
7024
  loadError: "Could not load your details. Please try again.",
6790
7025
  submitError: "Could not check your details. Please try again.",
7026
+ registryDown: "The civil registry is not responding right now. Please try again in a few minutes.",
6791
7027
  step: "Step {n} of {total}"
6792
7028
  },
6793
7029
  es: {
@@ -6810,6 +7046,7 @@ var REGISTRY_COPY = {
6810
7046
  rejected: "El registro no confirm\xF3: {fields}. Revisa c\xF3mo est\xE1n escritos e intenta de nuevo.",
6811
7047
  loadError: "No se pudieron cargar tus datos. Intenta de nuevo.",
6812
7048
  submitError: "No se pudieron validar tus datos. Intenta de nuevo.",
7049
+ registryDown: "El registro civil no responde en este momento. Intenta de nuevo en unos minutos.",
6813
7050
  step: "Paso {n} de {total}"
6814
7051
  },
6815
7052
  pt: {
@@ -6832,6 +7069,7 @@ var REGISTRY_COPY = {
6832
7069
  rejected: "O registro n\xE3o confirmou: {fields}. Verifique como est\xE3o escritos e tente novamente.",
6833
7070
  loadError: "N\xE3o foi poss\xEDvel carregar seus dados. Tente novamente.",
6834
7071
  submitError: "N\xE3o foi poss\xEDvel validar seus dados. Tente novamente.",
7072
+ registryDown: "O registro civil n\xE3o est\xE1 respondendo agora. Tente novamente em alguns minutos.",
6835
7073
  step: "Passo {n} de {total}"
6836
7074
  }
6837
7075
  };
@@ -6994,6 +7232,10 @@ var errorBody = (error) => {
6994
7232
  const body = typeof error === "object" && error !== null && "body" in error ? error.body : void 0;
6995
7233
  return typeof body === "object" && body !== null ? body : void 0;
6996
7234
  };
7235
+ var isRegistryDown = (error) => {
7236
+ const body = errorBody(error);
7237
+ return errorCode(error) === "SDK_KYC_PROVIDER_ERROR" && !!body && "retryable" in body && body.retryable === true;
7238
+ };
6997
7239
  function missingFieldsOf(error) {
6998
7240
  const body = errorBody(error);
6999
7241
  const missing = body && "missing" in body ? body.missing : void 0;
@@ -7088,6 +7330,7 @@ function RegistryCheckModal({
7088
7330
  if (code === "KYC_REGISTRY_NAME_MISMATCH") {
7089
7331
  setError(copy.nameMismatch.replace("{full}", [prefill.surname1, prefill.surname2].filter(Boolean).join(" ")));
7090
7332
  } else if (code === "SDK_KYC_UNDER_REVIEW") setReview(true);
7333
+ else if (isRegistryDown(e)) setError(copy.registryDown);
7091
7334
  else setError(copy.submitError);
7092
7335
  } finally {
7093
7336
  if (mounted.current) setSubmitting(false);
@@ -7891,8 +8134,7 @@ function RampWidget({ onClose, language: languageProp, initial }) {
7891
8134
  const flowSteps = fields.length || quotes.some((q) => rampQuoteFields(q).length) ? [copy.steps.route, copy.steps.details, copy.steps.complete] : [copy.steps.route, copy.steps.complete];
7892
8135
  const stepLabel = {
7893
8136
  select_route: copy.steps.route,
7894
- contact: copy.steps.details,
7895
- status: copy.steps.complete
8137
+ contact: copy.steps.details
7896
8138
  };
7897
8139
  const label = stepLabel[step];
7898
8140
  if (verifying) {
@@ -8016,7 +8258,7 @@ function RampWidget({ onClose, language: languageProp, initial }) {
8016
8258
  onRequote: () => void handleRequote(),
8017
8259
  onSetUpRecovery: openRecoveryModal,
8018
8260
  recoveryMissing: recovery === null ? null : recoveryLocked,
8019
- support: client.getSupportContact(),
8261
+ support: rampSupportContact(client.getSupportContact(), appConfig.application?.support),
8020
8262
  pollTrouble,
8021
8263
  checkingPayment: paymentCheckUntil !== null,
8022
8264
  onCheckPayment: () => void handleCheckPayment(),
@@ -9213,6 +9455,7 @@ function SendModal({ onClose, initial }) {
9213
9455
  const copy = SEND_COPY[language];
9214
9456
  const [step, setStep] = useState("form");
9215
9457
  const confirmation = useInlineConfirmation(step === "tx");
9458
+ const { track, declineOnClose } = useDeclineOnClose(confirmation);
9216
9459
  const [createsAccount, setCreatesAccount] = useState(false);
9217
9460
  const [checkingDestination, setCheckingDestination] = useState(false);
9218
9461
  const [amount, setAmount] = useState(() => seededAmount(initial?.amount));
@@ -9344,14 +9587,16 @@ function SendModal({ onClose, initial }) {
9344
9587
  setCreatesAccount(false);
9345
9588
  setStep("tx");
9346
9589
  if (selectedChain === "SOLANA" || selectedChain === "POLYGON") {
9347
- await sendPayment({
9348
- chain: selectedChain,
9349
- destination: destination.trim(),
9350
- amount: sendAmount,
9351
- // A native coin carries no token id; an SPL mint or ERC-20 contract rides
9352
- // in `issuer`, which the guard above proved is present.
9353
- ...isNativeAsset ? {} : { mint: selectedAsset.issuer }
9354
- });
9590
+ await track(
9591
+ sendPayment({
9592
+ chain: selectedChain,
9593
+ destination: destination.trim(),
9594
+ amount: sendAmount,
9595
+ // A native coin carries no token id; an SPL mint or ERC-20 contract rides
9596
+ // in `issuer`, which the guard above proved is present.
9597
+ ...isNativeAsset ? {} : { mint: selectedAsset.issuer }
9598
+ })
9599
+ );
9355
9600
  return;
9356
9601
  }
9357
9602
  await buildTx(
@@ -9373,7 +9618,7 @@ function SendModal({ onClose, initial }) {
9373
9618
  }
9374
9619
  function handleSignAndSend() {
9375
9620
  if (transaction.step === "built") {
9376
- void signAndSubmitTx(transaction.buildData.unsignedXdr);
9621
+ void track(signAndSubmitTx(transaction.buildData.unsignedXdr));
9377
9622
  }
9378
9623
  }
9379
9624
  function handleMax() {
@@ -9420,16 +9665,20 @@ function SendModal({ onClose, initial }) {
9420
9665
  }
9421
9666
  async function handleRetry() {
9422
9667
  if (transaction.step === "error" && transaction.buildData) {
9423
- await signAndSubmitTx(transaction.buildData.unsignedXdr);
9668
+ await track(signAndSubmitTx(transaction.buildData.unsignedXdr));
9424
9669
  }
9425
9670
  }
9671
+ function handleClose() {
9672
+ declineOnClose();
9673
+ onClose();
9674
+ }
9426
9675
  function handleBack() {
9427
9676
  setStep("form");
9428
9677
  setCreatesAccount(false);
9429
9678
  setShowXdr(false);
9430
9679
  setCopied(false);
9431
9680
  }
9432
- return /* @__PURE__ */ jsx(PollarOverlay, { style: overlayStyle, onClick: step !== "tx" && !isInProgress ? onClose : void 0, children: /* @__PURE__ */ jsx(
9681
+ return /* @__PURE__ */ jsx(PollarOverlay, { style: overlayStyle, onClick: step !== "tx" && !isInProgress ? handleClose : void 0, children: /* @__PURE__ */ jsx(
9433
9682
  SendModalTemplate,
9434
9683
  {
9435
9684
  theme,
@@ -9458,7 +9707,7 @@ function SendModal({ onClose, initial }) {
9458
9707
  walletType,
9459
9708
  showBack,
9460
9709
  isInProgress,
9461
- onClose,
9710
+ onClose: handleClose,
9462
9711
  onBack: handleBack,
9463
9712
  onRefresh: () => void refreshWalletBalance(),
9464
9713
  onSelectAsset: setSelectedAsset,
@@ -10260,6 +10509,7 @@ function SwapModal({ onClose, initial }) {
10260
10509
  const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
10261
10510
  const [step, setStep] = useState("form");
10262
10511
  const confirmation = useInlineConfirmation(step === "tx");
10512
+ const { track, declineOnClose } = useDeclineOnClose(confirmation);
10263
10513
  const [selectedSell, setSelectedSell] = useState(null);
10264
10514
  const [selectedBuy, setSelectedBuy] = useState(null);
10265
10515
  const [amount, setAmount] = useState(() => seededAmount(initial?.amount));
@@ -10289,8 +10539,6 @@ function SwapModal({ onClose, initial }) {
10289
10539
  void refreshAssets();
10290
10540
  }, [refreshWalletBalance, refreshAssets]);
10291
10541
  const loadConfig = useCallback(() => {
10292
- setVenues(null);
10293
- setSolanaVenues(null);
10294
10542
  return Promise.all([
10295
10543
  getSwapConfig().then(setVenues).catch(() => setVenues([])),
10296
10544
  // treat a failed config as "unavailable"
@@ -10428,10 +10676,12 @@ function SwapModal({ onClose, initial }) {
10428
10676
  setSelectedBuy(seeded);
10429
10677
  return;
10430
10678
  }
10431
- if (!selectedBuy || !buyOptions.some((o) => optKey(o) === optKey(selectedBuy))) {
10432
- setSelectedBuy(buyOptions[0]);
10679
+ const sellKey = selectedSell ? optKey(selectedSell) : "";
10680
+ if (!selectedBuy || optKey(selectedBuy) === sellKey || !buyOptions.some((o) => optKey(o) === optKey(selectedBuy))) {
10681
+ const next = buyOptions.find((o) => optKey(o) !== sellKey) ?? null;
10682
+ if (next !== selectedBuy) setSelectedBuy(next);
10433
10683
  }
10434
- }, [buyOptions, selectedBuy, isLoadingData]);
10684
+ }, [buyOptions, selectedBuy, selectedSell, isLoadingData]);
10435
10685
  function addCustomToken(code, issuer) {
10436
10686
  const c = code.trim().toUpperCase();
10437
10687
  const i = issuer.trim();
@@ -10491,8 +10741,13 @@ function SwapModal({ onClose, initial }) {
10491
10741
  };
10492
10742
  }, [quotedSolana, step]);
10493
10743
  useEffect(() => {
10494
- if (chains.length > 0 && !chains.includes(chain)) setChain(chains[0]);
10495
- }, [chains, chain]);
10744
+ if (configLoading) return;
10745
+ if (chains.length === 0 || chains.includes(chain)) return;
10746
+ setChain(chains[0]);
10747
+ setProvider("auto");
10748
+ setQuotes([]);
10749
+ setSolanaQuotes([]);
10750
+ }, [chains, chain, configLoading]);
10496
10751
  function handleChainChange(next) {
10497
10752
  sellSeed.current = void 0;
10498
10753
  buySeed.current = void 0;
@@ -10685,7 +10940,7 @@ function SwapModal({ onClose, initial }) {
10685
10940
  setSettlement(toward && toward !== "SOLANA" ? { key, chain: toward, value: null } : null);
10686
10941
  setSentSolana({ quote: solanaQuote, sell: selectedSell, buy: selectedBuy });
10687
10942
  setStep("tx");
10688
- await swapSolana(solanaQuote, { slippageBps, idempotencyKey: key });
10943
+ await track(swapSolana(solanaQuote, { slippageBps, idempotencyKey: key }));
10689
10944
  return;
10690
10945
  }
10691
10946
  if (!quote) {
@@ -10694,7 +10949,7 @@ function SwapModal({ onClose, initial }) {
10694
10949
  }
10695
10950
  setSentSolana(null);
10696
10951
  setStep("tx");
10697
- await swap(quote);
10952
+ await track(swap(quote));
10698
10953
  }
10699
10954
  async function handleRetry() {
10700
10955
  if (transaction.step !== "error") return;
@@ -10704,10 +10959,10 @@ function SwapModal({ onClose, initial }) {
10704
10959
  const toward = solanaQuote.destinationChain;
10705
10960
  setSettlement(toward && toward !== "SOLANA" ? { key, chain: toward, value: null } : null);
10706
10961
  if (selectedSell && selectedBuy) setSentSolana({ quote: solanaQuote, sell: selectedSell, buy: selectedBuy });
10707
- await swapSolana(solanaQuote, { slippageBps, idempotencyKey: key });
10962
+ await track(swapSolana(solanaQuote, { slippageBps, idempotencyKey: key }));
10708
10963
  return;
10709
10964
  }
10710
- if (quote) await swap(quote);
10965
+ if (quote) await track(swap(quote));
10711
10966
  }
10712
10967
  function handleMax() {
10713
10968
  if (selectedSell?.available !== void 0) setAmount(selectedSell.available);
@@ -10731,6 +10986,10 @@ function SwapModal({ onClose, initial }) {
10731
10986
  }, 2e3);
10732
10987
  });
10733
10988
  }
10989
+ function handleClose() {
10990
+ declineOnClose();
10991
+ onClose();
10992
+ }
10734
10993
  function handleBack() {
10735
10994
  setSettlement(null);
10736
10995
  setSentSolana(null);
@@ -10738,7 +10997,7 @@ function SwapModal({ onClose, initial }) {
10738
10997
  setShowXdr(false);
10739
10998
  setCopied(false);
10740
10999
  }
10741
- return /* @__PURE__ */ jsx(PollarOverlay, { style: overlayStyle, onClick: step !== "tx" && !isInProgress ? onClose : void 0, children: /* @__PURE__ */ jsx(
11000
+ return /* @__PURE__ */ jsx(PollarOverlay, { style: overlayStyle, onClick: step !== "tx" && !isInProgress ? handleClose : void 0, children: /* @__PURE__ */ jsx(
10742
11001
  SwapModalTemplate,
10743
11002
  {
10744
11003
  theme,
@@ -10779,7 +11038,7 @@ function SwapModal({ onClose, initial }) {
10779
11038
  showBack,
10780
11039
  isInProgress,
10781
11040
  language,
10782
- onClose,
11041
+ onClose: handleClose,
10783
11042
  onBack: handleBack,
10784
11043
  onRefresh: handleRefresh,
10785
11044
  onSelectSell: (option) => {
@@ -11681,6 +11940,7 @@ function EarnModal({ onClose, initial }) {
11681
11940
  const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
11682
11941
  const [step, setStep] = useState("form");
11683
11942
  const confirmation = useInlineConfirmation(step === "tx");
11943
+ const { track, declineOnClose } = useDeclineOnClose(confirmation);
11684
11944
  const [tab, setTab] = useState(
11685
11945
  () => oneOf(["deposit", "withdraw"], initial?.tab) ?? "deposit"
11686
11946
  );
@@ -11853,7 +12113,7 @@ function EarnModal({ onClose, initial }) {
11853
12113
  });
11854
12114
  setStep("tx");
11855
12115
  if (tab === "deposit" && depositNeedsTrustline && selectedOpportunity?.asset.issuer) {
11856
- const tl = await setTrustline({ code: assetCode, issuer: selectedOpportunity.asset.issuer });
12116
+ const tl = await track(setTrustline({ code: assetCode, issuer: selectedOpportunity.asset.issuer }));
11857
12117
  if (tl.status === "error") {
11858
12118
  setFormError(copy.trustlineFailed(assetCode, tl.details ?? copy.unknownError));
11859
12119
  setStep("form");
@@ -11872,11 +12132,15 @@ function EarnModal({ onClose, initial }) {
11872
12132
  function runEarn() {
11873
12133
  if (onSolana) {
11874
12134
  const params2 = { opportunity: opportunityId, amount };
11875
- return tab === "deposit" ? earnSolanaDeposit(params2) : earnSolanaWithdraw(params2);
12135
+ return track(tab === "deposit" ? earnSolanaDeposit(params2) : earnSolanaWithdraw(params2));
11876
12136
  }
11877
12137
  if (!provider) return null;
11878
12138
  const params = { provider, opportunity: opportunityId, amount };
11879
- return tab === "deposit" ? earnDeposit(params) : earnWithdraw(params);
12139
+ return track(tab === "deposit" ? earnDeposit(params) : earnWithdraw(params));
12140
+ }
12141
+ function handleClose() {
12142
+ declineOnClose();
12143
+ onClose();
11880
12144
  }
11881
12145
  async function handleRetry() {
11882
12146
  if (transaction.step !== "error" || !opportunityId) return;
@@ -11958,7 +12222,7 @@ function EarnModal({ onClose, initial }) {
11958
12222
  rows: [{ label: copy.yourPosition, value: position.balance }]
11959
12223
  }
11960
12224
  ) : null;
11961
- return /* @__PURE__ */ jsx(PollarOverlay, { style: overlayStyle, onClick: step !== "tx" && !isInProgress ? onClose : void 0, children: /* @__PURE__ */ jsxs(
12225
+ return /* @__PURE__ */ jsx(PollarOverlay, { style: overlayStyle, onClick: step !== "tx" && !isInProgress ? handleClose : void 0, children: /* @__PURE__ */ jsxs(
11962
12226
  "div",
11963
12227
  {
11964
12228
  className: "pollar-modal-card pollar-send-modal",
@@ -12032,7 +12296,7 @@ function EarnModal({ onClose, initial }) {
12032
12296
  )
12033
12297
  }
12034
12298
  ),
12035
- !isInProgress && /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": copy.close, children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
12299
+ !isInProgress && /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: handleClose, "aria-label": copy.close, children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
12036
12300
  ] })
12037
12301
  ] }),
12038
12302
  step === "form" && earnUnavailable && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: copy.unavailable }),
@@ -13945,6 +14209,7 @@ var COSIGN_COPY = {
13945
14209
  approve: "Approve",
13946
14210
  approving: "Approving...",
13947
14211
  genericError: "Something went wrong. Please try again.",
14212
+ unreachable: "We could not reach Pollar, so nothing was approved. Check your connection and approve again.",
13948
14213
  deviceNotLinked: "This device isn't linked to your wallet yet, so it can't approve. Add it with a device that already is, your passkey or your email.",
13949
14214
  linkDevice: "Link this device",
13950
14215
  transaction: "Transaction",
@@ -13998,6 +14263,7 @@ var COSIGN_COPY = {
13998
14263
  approve: "Aprobar",
13999
14264
  approving: "Aprobando...",
14000
14265
  genericError: "Algo sali\xF3 mal. Intenta de nuevo.",
14266
+ unreachable: "No pudimos conectar con Pollar, as\xED que no se aprob\xF3 nada. Revisa tu conexi\xF3n y aprueba de nuevo.",
14001
14267
  deviceNotLinked: "Este dispositivo a\xFAn no est\xE1 vinculado a tu billetera, as\xED que no puede aprobar. Agr\xE9galo con un dispositivo que ya lo est\xE9, tu passkey o tu email.",
14002
14268
  linkDevice: "Vincular este dispositivo",
14003
14269
  transaction: "Transacci\xF3n",
@@ -14051,6 +14317,7 @@ var COSIGN_COPY = {
14051
14317
  approve: "Aprovar",
14052
14318
  approving: "Aprovando...",
14053
14319
  genericError: "Algo deu errado. Tente novamente.",
14320
+ unreachable: "N\xE3o conseguimos conectar \xE0 Pollar, ent\xE3o nada foi aprovado. Verifique sua conex\xE3o e aprove novamente.",
14054
14321
  deviceNotLinked: "Este dispositivo ainda n\xE3o est\xE1 vinculado \xE0 sua carteira, ent\xE3o n\xE3o pode aprovar. Adicione-o com um dispositivo que j\xE1 esteja, sua passkey ou seu email.",
14055
14322
  linkDevice: "Vincular este dispositivo",
14056
14323
  transaction: "Transa\xE7\xE3o",
@@ -14404,6 +14671,11 @@ function CosignModal({ nextStep = null, onClose }) {
14404
14671
  try {
14405
14672
  await action(request);
14406
14673
  } catch (err) {
14674
+ if (isPollarNetworkError(err) || err instanceof TypeError) {
14675
+ setError(COSIGN_COPY[language].unreachable);
14676
+ void refresh().catch(() => void 0);
14677
+ return;
14678
+ }
14407
14679
  setError(
14408
14680
  transactionErrorMessage(isPollarApiError(err) ? err.code : null, err instanceof Error ? err.message : null, language)
14409
14681
  );
@@ -14413,7 +14685,7 @@ function CosignModal({ nextStep = null, onClose }) {
14413
14685
  setBusy(null);
14414
14686
  }
14415
14687
  },
14416
- []
14688
+ [language, refresh]
14417
14689
  );
14418
14690
  return /* @__PURE__ */ jsx(PollarOverlay, { style: overlayStyle, children: /* @__PURE__ */ jsx(
14419
14691
  CosignModalTemplate,
@@ -14644,6 +14916,9 @@ var RECOVERY_COPY = {
14644
14916
  acceptRisks: "I understand and accept these risks",
14645
14917
  recoverEmailIntro: (address) => `We'll email a code to ${address}. The code goes straight to the wallet provider, encrypted on this device.`,
14646
14918
  sendCode: "Send code",
14919
+ sendCodeIn: (seconds) => `Send code in ${seconds}s`,
14920
+ resendCode: "Send a new code",
14921
+ resendCodeIn: (seconds) => `Send a new code in ${seconds}s`,
14647
14922
  recover: "Recover",
14648
14923
  back: "Back",
14649
14924
  emailIntro: "Confirm an email you control. If you lose this device, a code sent there lets you add a new one. Anyone who controls this inbox could do the same, so use one that is well protected.",
@@ -14696,6 +14971,9 @@ var RECOVERY_COPY = {
14696
14971
  acceptRisks: "Entiendo y acepto estos riesgos",
14697
14972
  recoverEmailIntro: (address) => `Te enviaremos un c\xF3digo a ${address}. El c\xF3digo va directo al proveedor de la billetera, cifrado en este dispositivo.`,
14698
14973
  sendCode: "Enviar c\xF3digo",
14974
+ sendCodeIn: (seconds) => `Enviar c\xF3digo en ${seconds} s`,
14975
+ resendCode: "Enviar otro c\xF3digo",
14976
+ resendCodeIn: (seconds) => `Enviar otro c\xF3digo en ${seconds} s`,
14699
14977
  recover: "Recuperar",
14700
14978
  back: "Atr\xE1s",
14701
14979
  emailIntro: "Confirma un correo que controles. Si pierdes este dispositivo, un c\xF3digo enviado ah\xED te permite agregar uno nuevo. Cualquiera que controle esa bandeja de entrada podr\xEDa hacer lo mismo, as\xED que usa una que est\xE9 bien protegida.",
@@ -14748,6 +15026,9 @@ var RECOVERY_COPY = {
14748
15026
  acceptRisks: "Entendo e aceito esses riscos",
14749
15027
  recoverEmailIntro: (address) => `Vamos enviar um c\xF3digo para ${address}. O c\xF3digo vai direto para o provedor da carteira, criptografado neste dispositivo.`,
14750
15028
  sendCode: "Enviar c\xF3digo",
15029
+ sendCodeIn: (seconds) => `Enviar c\xF3digo em ${seconds} s`,
15030
+ resendCode: "Enviar outro c\xF3digo",
15031
+ resendCodeIn: (seconds) => `Enviar outro c\xF3digo em ${seconds} s`,
14751
15032
  recover: "Recuperar",
14752
15033
  back: "Voltar",
14753
15034
  emailIntro: "Confirme um e-mail que voc\xEA controla. Se voc\xEA perder este dispositivo, um c\xF3digo enviado para ele permite adicionar um novo. Qualquer pessoa que controle essa caixa de entrada poderia fazer o mesmo, ent\xE3o use uma que esteja bem protegida.",
@@ -14903,11 +15184,25 @@ function RecoveryModalTemplate(p) {
14903
15184
  copy,
14904
15185
  busy: p.busy,
14905
15186
  id: "recover-send",
14906
- label: copy.sendCode,
15187
+ label: p.sendWaitSeconds ? copy.sendCodeIn(p.sendWaitSeconds) : copy.sendCode,
14907
15188
  kind: "primary",
14908
- onClick: p.onSendRecoveryCode
15189
+ onClick: p.onSendRecoveryCode,
15190
+ disabled: p.sendWaitSeconds > 0
14909
15191
  }
14910
- ) : /* @__PURE__ */ jsx(CodeForm, { copy, busy: p.busy, id: "recover-code", label: copy.recover, onSubmit: p.onRecoverWithCode }),
15192
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
15193
+ /* @__PURE__ */ jsx(CodeForm, { copy, busy: p.busy, id: "recover-code", label: copy.recover, onSubmit: p.onRecoverWithCode }),
15194
+ /* @__PURE__ */ jsx(
15195
+ Button,
15196
+ {
15197
+ copy,
15198
+ busy: p.busy,
15199
+ id: "recover-send",
15200
+ label: p.sendWaitSeconds ? copy.resendCodeIn(p.sendWaitSeconds) : copy.resendCode,
15201
+ onClick: p.onSendRecoveryCode,
15202
+ disabled: p.sendWaitSeconds > 0
15203
+ }
15204
+ )
15205
+ ] }),
14911
15206
  /* @__PURE__ */ jsx(Button, { copy, busy: p.busy, id: "back", label: copy.back, onClick: () => p.onView("overview") })
14912
15207
  ] });
14913
15208
  } else if (p.view === "email") {
@@ -14919,7 +15214,7 @@ function RecoveryModalTemplate(p) {
14919
15214
  className: "pollar-recovery-row",
14920
15215
  onSubmit: (e) => {
14921
15216
  e.preventDefault();
14922
- p.onSendEmailCode();
15217
+ if (!p.sendWaitSeconds) p.onSendEmailCode();
14923
15218
  },
14924
15219
  children: [
14925
15220
  /* @__PURE__ */ jsx(
@@ -14939,15 +15234,28 @@ function RecoveryModalTemplate(p) {
14939
15234
  copy,
14940
15235
  busy: p.busy,
14941
15236
  id: "email-send",
14942
- label: copy.sendCode,
15237
+ label: p.sendWaitSeconds ? copy.sendCodeIn(p.sendWaitSeconds) : copy.sendCode,
14943
15238
  kind: "primary",
14944
15239
  onClick: p.onSendEmailCode,
14945
- disabled: !p.emailDraft.trim()
15240
+ disabled: !p.emailDraft.trim() || p.sendWaitSeconds > 0
14946
15241
  }
14947
15242
  )
14948
15243
  ]
14949
15244
  }
14950
- ) : /* @__PURE__ */ jsx(CodeForm, { copy, busy: p.busy, id: "email-confirm", label: copy.confirm, onSubmit: p.onConfirmEmail }),
15245
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
15246
+ /* @__PURE__ */ jsx(CodeForm, { copy, busy: p.busy, id: "email-confirm", label: copy.confirm, onSubmit: p.onConfirmEmail }),
15247
+ /* @__PURE__ */ jsx(
15248
+ Button,
15249
+ {
15250
+ copy,
15251
+ busy: p.busy,
15252
+ id: "email-send",
15253
+ label: p.sendWaitSeconds ? copy.resendCodeIn(p.sendWaitSeconds) : copy.resendCode,
15254
+ onClick: p.onSendEmailCode,
15255
+ disabled: p.sendWaitSeconds > 0
15256
+ }
15257
+ )
15258
+ ] }),
14951
15259
  /* @__PURE__ */ jsx(Button, { copy, busy: p.busy, id: "back", label: copy.back, onClick: () => p.onView("overview") })
14952
15260
  ] });
14953
15261
  } else if (p.view === "export") {
@@ -15090,6 +15398,7 @@ function RecoveryModal({ onClose }) {
15090
15398
  const [emailDraft, setEmailDraft] = useState("");
15091
15399
  const [codeSent, setCodeSent] = useState(false);
15092
15400
  const [phrase, setPhrase] = useState(null);
15401
+ const [now, setNow] = useState(() => Date.now());
15093
15402
  const load = useCallback(async () => {
15094
15403
  const client = getClient();
15095
15404
  const [nextState, nextDevices, key] = await Promise.all([
@@ -15132,6 +15441,14 @@ function RecoveryModal({ onClose }) {
15132
15441
  },
15133
15442
  [load]
15134
15443
  );
15444
+ const codeEmail = view === "recover-email" ? state?.email.address ?? "" : emailDraft.trim();
15445
+ const codeAvailableAt = codeEmail ? recovery.codeAvailableAt(codeEmail) : 0;
15446
+ const sendWaitSeconds = codeAvailableAt > now ? Math.ceil((codeAvailableAt - now) / 1e3) : 0;
15447
+ useEffect(() => {
15448
+ if (!codeAvailableAt) return;
15449
+ const timer = setInterval(() => setNow(Date.now()), 1e3);
15450
+ return () => clearInterval(timer);
15451
+ }, [codeAvailableAt]);
15135
15452
  const enrolled = !!thisDeviceKey && !!devices?.devices.some((d) => d.publicKey.toLowerCase() === thisDeviceKey);
15136
15453
  const [awaitingApproval, setAwaitingApproval] = useState(false);
15137
15454
  useEffect(() => {
@@ -15166,6 +15483,7 @@ function RecoveryModal({ onClose }) {
15166
15483
  notice,
15167
15484
  emailDraft,
15168
15485
  codeSent,
15486
+ sendWaitSeconds,
15169
15487
  phrase,
15170
15488
  onView: (next) => {
15171
15489
  setError(null);
@@ -15178,8 +15496,12 @@ function RecoveryModal({ onClose }) {
15178
15496
  onAddPasskey: () => void run("passkey", () => recovery.addPasskey(), { notice: copy.passkeyAdded }),
15179
15497
  onRemovePasskey: (id) => void run(`passkey:${id}`, () => recovery.removePasskey(id)),
15180
15498
  onSendEmailCode: () => void run("email-send", async () => {
15181
- await recovery.startEmail(emailDraft.trim());
15182
- setCodeSent(true);
15499
+ try {
15500
+ await recovery.startEmail(emailDraft.trim());
15501
+ setCodeSent(true);
15502
+ } finally {
15503
+ setNow(Date.now());
15504
+ }
15183
15505
  }),
15184
15506
  onConfirmEmail: (code) => void run("email-confirm", () => recovery.confirmEmail(code.trim()), { notice: copy.emailConfirmed, view: "overview" }),
15185
15507
  onApproveDevice: (id) => void run(`approve:${id}`, () => recovery.approveDevice(id), { notice: copy.deviceAdded }),
@@ -15196,8 +15518,12 @@ function RecoveryModal({ onClose }) {
15196
15518
  notice: copy.recovered
15197
15519
  }),
15198
15520
  onSendRecoveryCode: () => void run("recover-send", async () => {
15199
- await recovery.startEmailRecovery();
15200
- setCodeSent(true);
15521
+ try {
15522
+ await recovery.startEmailRecovery();
15523
+ setCodeSent(true);
15524
+ } finally {
15525
+ setNow(Date.now());
15526
+ }
15201
15527
  }),
15202
15528
  onRecoverWithCode: (code) => void run("recover-code", () => recovery.recoverWithEmailCode(code.trim()), {
15203
15529
  notice: copy.recovered,
@@ -16420,31 +16746,58 @@ function PollarProvider({
16420
16746
  }, [pollarClient, hasSession, walletAddress, custodyMigrationTick]);
16421
16747
  const refreshWalletBalance = useCallback(() => pollarClient.refreshBalance(), [pollarClient, walletAddress]);
16422
16748
  const refreshAssets = useCallback(() => pollarClient.refreshAssets(), [pollarClient, walletAddress]);
16749
+ const clientMethods = useMemo(
16750
+ () => ({
16751
+ createWallet: (options) => pollarClient.createWallet(options),
16752
+ login: (options) => pollarClient.login(options),
16753
+ logout: () => pollarClient.logout(),
16754
+ buildTx: (operation, params, options) => pollarClient.buildTx(operation, params, options),
16755
+ signAndSubmitTx: (unsignedXdr) => pollarClient.signAndSubmitTx(unsignedXdr),
16756
+ signTx: (unsignedXdr) => pollarClient.signTx(unsignedXdr),
16757
+ submitTx: (signedXdr) => pollarClient.submitTx(signedXdr),
16758
+ buildAndSignAndSubmitTx: (operation, params, options) => pollarClient.buildAndSignAndSubmitTx(operation, params, options),
16759
+ runTx: (operation, params, options) => pollarClient.runTx(operation, params, options),
16760
+ sendPayment: (params) => pollarClient.sendPayment(params),
16761
+ setTrustline: (asset, opts) => pollarClient.setTrustline(asset, opts),
16762
+ getSwapConfig: () => pollarClient.getSwapConfig(),
16763
+ getSwapTokens: () => pollarClient.getSwapTokens(),
16764
+ getSwapQuote: (params) => pollarClient.getSwapQuote(params),
16765
+ swap: (quote, opts) => pollarClient.swap(quote, opts),
16766
+ getSolanaSwapConfig: () => pollarClient.getSolanaSwapConfig(),
16767
+ getSolanaSwapQuote: (params) => pollarClient.getSolanaSwapQuote(params),
16768
+ swapSolana: (quote, opts) => pollarClient.swapSolana(quote, opts),
16769
+ getSolanaSwapOptions: () => pollarClient.getSolanaSwapOptions(),
16770
+ getSwapStatus: (idempotencyKey) => pollarClient.getSwapStatus(idempotencyKey),
16771
+ getEarnProviders: () => pollarClient.getEarnProviders(),
16772
+ getEarnOpportunities: (provider) => pollarClient.getEarnOpportunities(provider).then(remembered),
16773
+ getEarnPosition: (params) => pollarClient.getEarnPosition(params),
16774
+ earnDeposit: (params) => pollarClient.earnDeposit(params),
16775
+ earnWithdraw: (params) => pollarClient.earnWithdraw(params),
16776
+ getSolanaEarnProviders: () => pollarClient.getSolanaEarnProviders(),
16777
+ getSolanaEarnOpportunities: () => pollarClient.getSolanaEarnOpportunities().then(remembered),
16778
+ getSolanaEarnPosition: (opportunity) => pollarClient.getSolanaEarnPosition(opportunity),
16779
+ earnSolanaDeposit: (params) => pollarClient.earnSolanaDeposit(params),
16780
+ earnSolanaWithdraw: (params) => pollarClient.earnSolanaWithdraw(params),
16781
+ setNetwork: (network) => pollarClient.setNetwork(network)
16782
+ }),
16783
+ [pollarClient]
16784
+ );
16423
16785
  const contextValue = useMemo(() => {
16424
16786
  const styles = resolvedConfig.styles ?? {};
16425
16787
  return {
16788
+ ...clientMethods,
16426
16789
  // session
16427
16790
  wallet: pollarClient.getWallet(),
16428
16791
  wallets: pollarClient.getWallets(),
16429
16792
  isAuthenticated: hasSession,
16430
16793
  hasWallet: pollarClient.hasWallet(),
16431
- createWallet: (options) => pollarClient.createWallet(options),
16432
16794
  verified,
16433
16795
  // client
16434
16796
  getClient,
16435
16797
  // auth
16436
- login: (options) => pollarClient.login(options),
16437
- logout: () => pollarClient.logout(),
16438
16798
  openLoginModal: () => setLoginModalOpen(true),
16439
16799
  // transactions
16440
16800
  tx: transaction,
16441
- buildTx: (operation, params, options) => pollarClient.buildTx(operation, params, options),
16442
- signAndSubmitTx: (unsignedXdr) => pollarClient.signAndSubmitTx(unsignedXdr),
16443
- signTx: (unsignedXdr) => pollarClient.signTx(unsignedXdr),
16444
- submitTx: (signedXdr) => pollarClient.submitTx(signedXdr),
16445
- buildAndSignAndSubmitTx: (operation, params, options) => pollarClient.buildAndSignAndSubmitTx(operation, params, options),
16446
- runTx: (operation, params, options) => pollarClient.runTx(operation, params, options),
16447
- sendPayment: (params) => pollarClient.sendPayment(params),
16448
16801
  openTxModal: () => setTransactionModalOpen(true),
16449
16802
  // tx history
16450
16803
  txHistory,
@@ -16459,7 +16812,6 @@ function PollarProvider({
16459
16812
  // enabled assets
16460
16813
  enabledAssets,
16461
16814
  refreshAssets,
16462
- setTrustline: (asset, opts) => pollarClient.setTrustline(asset, opts),
16463
16815
  openEnabledAssetsModal: () => setEnabledAssetsModalOpen(true),
16464
16816
  // send / receive
16465
16817
  openSendModal: (options) => {
@@ -16473,15 +16825,6 @@ function PollarProvider({
16473
16825
  setReceiveModalOpen(true);
16474
16826
  },
16475
16827
  // swap
16476
- getSwapConfig: () => pollarClient.getSwapConfig(),
16477
- getSwapTokens: () => pollarClient.getSwapTokens(),
16478
- getSwapQuote: (params) => pollarClient.getSwapQuote(params),
16479
- swap: (quote, opts) => pollarClient.swap(quote, opts),
16480
- getSolanaSwapConfig: () => pollarClient.getSolanaSwapConfig(),
16481
- getSolanaSwapQuote: (params) => pollarClient.getSolanaSwapQuote(params),
16482
- swapSolana: (quote, opts) => pollarClient.swapSolana(quote, opts),
16483
- getSolanaSwapOptions: () => pollarClient.getSolanaSwapOptions(),
16484
- getSwapStatus: (idempotencyKey) => pollarClient.getSwapStatus(idempotencyKey),
16485
16828
  openSwapModal: (options) => {
16486
16829
  setSwapModalOptions(options);
16487
16830
  pollarClient.resetTransactionState();
@@ -16494,16 +16837,6 @@ function PollarProvider({
16494
16837
  setBridgeModalOpen(true);
16495
16838
  },
16496
16839
  // earn
16497
- getEarnProviders: () => pollarClient.getEarnProviders(),
16498
- getEarnOpportunities: (provider) => pollarClient.getEarnOpportunities(provider).then(remembered),
16499
- getEarnPosition: (params) => pollarClient.getEarnPosition(params),
16500
- earnDeposit: (params) => pollarClient.earnDeposit(params),
16501
- earnWithdraw: (params) => pollarClient.earnWithdraw(params),
16502
- getSolanaEarnProviders: () => pollarClient.getSolanaEarnProviders(),
16503
- getSolanaEarnOpportunities: () => pollarClient.getSolanaEarnOpportunities().then(remembered),
16504
- getSolanaEarnPosition: (opportunity) => pollarClient.getSolanaEarnPosition(opportunity),
16505
- earnSolanaDeposit: (params) => pollarClient.earnSolanaDeposit(params),
16506
- earnSolanaWithdraw: (params) => pollarClient.earnSolanaWithdraw(params),
16507
16840
  openEarnModal: (options) => {
16508
16841
  setEarnModalOptions(options);
16509
16842
  pollarClient.resetTransactionState();
@@ -16535,7 +16868,6 @@ function PollarProvider({
16535
16868
  openDistributionRulesModal: () => setDistributionRulesModalOpen(true),
16536
16869
  // network
16537
16870
  network: networkState.step === "connected" ? networkState.network : "testnet",
16538
- setNetwork: (network) => pollarClient.setNetwork(network),
16539
16871
  // kyc
16540
16872
  openKycModal: (options = {}) => {
16541
16873
  setKycModalOptions(options);
@@ -16554,6 +16886,7 @@ function PollarProvider({
16554
16886
  adapters
16555
16887
  };
16556
16888
  }, [
16889
+ clientMethods,
16557
16890
  walletAddress,
16558
16891
  walletProvisioning,
16559
16892
  recovery,
@@ -17445,7 +17778,12 @@ function KycFlow({ onApproved, country, level }) {
17445
17778
  }
17446
17779
  );
17447
17780
  }
17781
+ var stay2 = () => {
17782
+ };
17783
+ function LoginFlow() {
17784
+ return /* @__PURE__ */ jsx(LoginModal, { inline: true, onClose: stay2 });
17785
+ }
17448
17786
 
17449
- export { BridgeModal, BridgeModalTemplate, CardModal, ChainSelect, CosignModal, CosignModalTemplate, CustodyMigrationModal, CustodyMigrationModalTemplate, DistributionRulesModal, DistributionRulesModalTemplate, EarnModal, EnabledAssetsModal, EnabledAssetsModalTemplate, KycFlow, KycModal, KycModalTemplate, KycStatus, LoginModalTemplate, PollarProvider, ProviderRegistrationModal, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, RecoveryModal, RecoveryModalTemplate, RegistryCheckModal, RejectedRouteDisplay, RequirementFormModal, RouteDisplay, SendModal, SendModalTemplate, SessionsModal, SessionsModalTemplate, SwapModal, SwapModalTemplate, TransactionModalTemplate, TxHistoryModalTemplate, TxStatusView, WalletBalanceModal, WalletBalanceModalTemplate, WalletButton, WalletButtonTemplate, addressForChain, browserPasskeyCeremony, browserPasskeySigner, browserRecoveryPasskey, buildModalCssVars, chainsOf, createPollarAdapterHook, modalChrome, readableTextOn, resolveChain, useChains, useCosign, usePollar, walletNotReadyReason };
17787
+ export { BridgeModal, BridgeModalTemplate, CardModal, ChainSelect, CosignModal, CosignModalTemplate, CustodyMigrationModal, CustodyMigrationModalTemplate, DistributionRulesModal, DistributionRulesModalTemplate, EarnModal, EnabledAssetsModal, EnabledAssetsModalTemplate, KycFlow, KycModal, KycModalTemplate, KycStatus, LoginFlow, LoginModalTemplate, PollarProvider, ProviderRegistrationModal, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, RecoveryModal, RecoveryModalTemplate, RegistryCheckModal, RejectedRouteDisplay, RequirementFormModal, RouteDisplay, SendModal, SendModalTemplate, SessionsModal, SessionsModalTemplate, SwapModal, SwapModalTemplate, TransactionModalTemplate, TxHistoryModalTemplate, TxStatusView, WalletBalanceModal, WalletBalanceModalTemplate, WalletButton, WalletButtonTemplate, addressForChain, browserPasskeyCeremony, browserPasskeySigner, browserRecoveryPasskey, buildModalCssVars, chainsOf, createPollarAdapterHook, modalChrome, readableTextOn, resolveChain, useChains, useCosign, usePollar, walletNotReadyReason };
17450
17788
  //# sourceMappingURL=index.mjs.map
17451
17789
  //# sourceMappingURL=index.mjs.map