@blocklet/payment-react 1.25.9 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/es/checkout-v2/checkout-v2.d.ts +2 -0
  2. package/es/checkout-v2/checkout-v2.js +121 -0
  3. package/es/checkout-v2/components/dialogs/checkout-dialogs.d.ts +1 -0
  4. package/es/checkout-v2/components/dialogs/checkout-dialogs.js +106 -0
  5. package/es/checkout-v2/components/left/billing-toggle.d.ts +6 -0
  6. package/es/checkout-v2/components/left/billing-toggle.js +118 -0
  7. package/es/checkout-v2/components/left/cross-sell-card.d.ts +10 -0
  8. package/es/checkout-v2/components/left/cross-sell-card.js +167 -0
  9. package/es/checkout-v2/components/left/product-item-card.d.ts +26 -0
  10. package/es/checkout-v2/components/left/product-item-card.js +571 -0
  11. package/es/checkout-v2/components/left/promotion-input.d.ts +19 -0
  12. package/es/checkout-v2/components/left/promotion-input.js +178 -0
  13. package/es/checkout-v2/components/left/staking-breakdown.d.ts +9 -0
  14. package/es/checkout-v2/components/left/staking-breakdown.js +48 -0
  15. package/es/checkout-v2/components/left/trial-info.d.ts +13 -0
  16. package/es/checkout-v2/components/left/trial-info.js +48 -0
  17. package/es/checkout-v2/components/right/currency-grid.d.ts +8 -0
  18. package/es/checkout-v2/components/right/currency-grid.js +48 -0
  19. package/es/checkout-v2/components/right/customer-info-card.d.ts +17 -0
  20. package/es/checkout-v2/components/right/customer-info-card.js +156 -0
  21. package/es/checkout-v2/components/right/status-feedback.d.ts +7 -0
  22. package/es/checkout-v2/components/right/status-feedback.js +17 -0
  23. package/es/checkout-v2/components/right/submit-button.d.ts +10 -0
  24. package/es/checkout-v2/components/right/submit-button.js +29 -0
  25. package/es/checkout-v2/components/right/subscription-disclaimer.d.ts +11 -0
  26. package/es/checkout-v2/components/right/subscription-disclaimer.js +8 -0
  27. package/es/checkout-v2/components/shared/exchange-rate-footer.d.ts +23 -0
  28. package/es/checkout-v2/components/shared/exchange-rate-footer.js +182 -0
  29. package/es/checkout-v2/components/shared/scenario-badge.d.ts +6 -0
  30. package/es/checkout-v2/components/shared/scenario-badge.js +47 -0
  31. package/es/checkout-v2/components/shared/total-display.d.ts +7 -0
  32. package/es/checkout-v2/components/shared/total-display.js +84 -0
  33. package/es/checkout-v2/index.d.ts +2 -0
  34. package/es/checkout-v2/index.js +1 -0
  35. package/es/checkout-v2/layouts/checkout-layout.d.ts +7 -0
  36. package/es/checkout-v2/layouts/checkout-layout.js +226 -0
  37. package/es/checkout-v2/panels/left/composite-panel.d.ts +1 -0
  38. package/es/checkout-v2/panels/left/composite-panel.js +423 -0
  39. package/es/checkout-v2/panels/left/credit-topup-panel.d.ts +1 -0
  40. package/es/checkout-v2/panels/left/credit-topup-panel.js +615 -0
  41. package/es/checkout-v2/panels/left/scenario-router.d.ts +1 -0
  42. package/es/checkout-v2/panels/left/scenario-router.js +19 -0
  43. package/es/checkout-v2/panels/right/payment-panel.d.ts +1 -0
  44. package/es/checkout-v2/panels/right/payment-panel.js +644 -0
  45. package/es/checkout-v2/types.d.ts +15 -0
  46. package/es/checkout-v2/types.js +0 -0
  47. package/es/checkout-v2/utils/format.d.ts +59 -0
  48. package/es/checkout-v2/utils/format.js +125 -0
  49. package/es/checkout-v2/utils/scenario-detector.d.ts +3 -0
  50. package/es/checkout-v2/utils/scenario-detector.js +17 -0
  51. package/es/checkout-v2/views/error-view.d.ts +7 -0
  52. package/es/checkout-v2/views/error-view.js +269 -0
  53. package/es/checkout-v2/views/loading-view.d.ts +5 -0
  54. package/es/checkout-v2/views/loading-view.js +158 -0
  55. package/es/checkout-v2/views/success-view.d.ts +29 -0
  56. package/es/checkout-v2/views/success-view.js +614 -0
  57. package/es/components/phone-field.d.ts +14 -0
  58. package/es/components/phone-field.js +96 -0
  59. package/es/index.d.ts +3 -1
  60. package/es/index.js +3 -1
  61. package/es/locales/en.js +45 -6
  62. package/es/locales/zh.js +45 -6
  63. package/es/payment/form/index.js +10 -1
  64. package/lib/checkout-v2/checkout-v2.d.ts +2 -0
  65. package/lib/checkout-v2/checkout-v2.js +151 -0
  66. package/lib/checkout-v2/components/dialogs/checkout-dialogs.d.ts +1 -0
  67. package/lib/checkout-v2/components/dialogs/checkout-dialogs.js +131 -0
  68. package/lib/checkout-v2/components/left/billing-toggle.d.ts +6 -0
  69. package/lib/checkout-v2/components/left/billing-toggle.js +126 -0
  70. package/lib/checkout-v2/components/left/cross-sell-card.d.ts +10 -0
  71. package/lib/checkout-v2/components/left/cross-sell-card.js +257 -0
  72. package/lib/checkout-v2/components/left/product-item-card.d.ts +26 -0
  73. package/lib/checkout-v2/components/left/product-item-card.js +738 -0
  74. package/lib/checkout-v2/components/left/promotion-input.d.ts +19 -0
  75. package/lib/checkout-v2/components/left/promotion-input.js +220 -0
  76. package/lib/checkout-v2/components/left/staking-breakdown.d.ts +9 -0
  77. package/lib/checkout-v2/components/left/staking-breakdown.js +96 -0
  78. package/lib/checkout-v2/components/left/trial-info.d.ts +13 -0
  79. package/lib/checkout-v2/components/left/trial-info.js +82 -0
  80. package/lib/checkout-v2/components/right/currency-grid.d.ts +8 -0
  81. package/lib/checkout-v2/components/right/currency-grid.js +96 -0
  82. package/lib/checkout-v2/components/right/customer-info-card.d.ts +17 -0
  83. package/lib/checkout-v2/components/right/customer-info-card.js +246 -0
  84. package/lib/checkout-v2/components/right/status-feedback.d.ts +7 -0
  85. package/lib/checkout-v2/components/right/status-feedback.js +30 -0
  86. package/lib/checkout-v2/components/right/submit-button.d.ts +10 -0
  87. package/lib/checkout-v2/components/right/submit-button.js +35 -0
  88. package/lib/checkout-v2/components/right/subscription-disclaimer.d.ts +11 -0
  89. package/lib/checkout-v2/components/right/subscription-disclaimer.js +33 -0
  90. package/lib/checkout-v2/components/shared/exchange-rate-footer.d.ts +23 -0
  91. package/lib/checkout-v2/components/shared/exchange-rate-footer.js +282 -0
  92. package/lib/checkout-v2/components/shared/scenario-badge.d.ts +6 -0
  93. package/lib/checkout-v2/components/shared/scenario-badge.js +57 -0
  94. package/lib/checkout-v2/components/shared/total-display.d.ts +7 -0
  95. package/lib/checkout-v2/components/shared/total-display.js +154 -0
  96. package/lib/checkout-v2/index.d.ts +2 -0
  97. package/lib/checkout-v2/index.js +13 -0
  98. package/lib/checkout-v2/layouts/checkout-layout.d.ts +7 -0
  99. package/lib/checkout-v2/layouts/checkout-layout.js +308 -0
  100. package/lib/checkout-v2/panels/left/composite-panel.d.ts +1 -0
  101. package/lib/checkout-v2/panels/left/composite-panel.js +515 -0
  102. package/lib/checkout-v2/panels/left/credit-topup-panel.d.ts +1 -0
  103. package/lib/checkout-v2/panels/left/credit-topup-panel.js +799 -0
  104. package/lib/checkout-v2/panels/left/scenario-router.d.ts +1 -0
  105. package/lib/checkout-v2/panels/left/scenario-router.js +29 -0
  106. package/lib/checkout-v2/panels/right/payment-panel.d.ts +1 -0
  107. package/lib/checkout-v2/panels/right/payment-panel.js +906 -0
  108. package/lib/checkout-v2/types.d.ts +15 -0
  109. package/lib/checkout-v2/types.js +1 -0
  110. package/lib/checkout-v2/utils/format.d.ts +59 -0
  111. package/lib/checkout-v2/utils/format.js +158 -0
  112. package/lib/checkout-v2/utils/scenario-detector.d.ts +3 -0
  113. package/lib/checkout-v2/utils/scenario-detector.js +23 -0
  114. package/lib/checkout-v2/views/error-view.d.ts +7 -0
  115. package/lib/checkout-v2/views/error-view.js +321 -0
  116. package/lib/checkout-v2/views/loading-view.d.ts +5 -0
  117. package/lib/checkout-v2/views/loading-view.js +168 -0
  118. package/lib/checkout-v2/views/success-view.d.ts +29 -0
  119. package/lib/checkout-v2/views/success-view.js +735 -0
  120. package/lib/components/phone-field.d.ts +14 -0
  121. package/lib/components/phone-field.js +130 -0
  122. package/lib/index.d.ts +3 -1
  123. package/lib/index.js +8 -0
  124. package/lib/locales/en.js +45 -6
  125. package/lib/locales/zh.js +45 -6
  126. package/lib/payment/form/index.js +10 -1
  127. package/package.json +10 -9
  128. package/src/checkout-v2/checkout-v2.tsx +155 -0
  129. package/src/checkout-v2/components/dialogs/checkout-dialogs.tsx +134 -0
  130. package/src/checkout-v2/components/left/billing-toggle.tsx +122 -0
  131. package/src/checkout-v2/components/left/cross-sell-card.tsx +170 -0
  132. package/src/checkout-v2/components/left/product-item-card.tsx +634 -0
  133. package/src/checkout-v2/components/left/promotion-input.tsx +207 -0
  134. package/src/checkout-v2/components/left/staking-breakdown.tsx +57 -0
  135. package/src/checkout-v2/components/left/trial-info.tsx +63 -0
  136. package/src/checkout-v2/components/right/currency-grid.tsx +59 -0
  137. package/src/checkout-v2/components/right/customer-info-card.tsx +214 -0
  138. package/src/checkout-v2/components/right/status-feedback.tsx +35 -0
  139. package/src/checkout-v2/components/right/submit-button.tsx +37 -0
  140. package/src/checkout-v2/components/right/subscription-disclaimer.tsx +27 -0
  141. package/src/checkout-v2/components/shared/exchange-rate-footer.tsx +221 -0
  142. package/src/checkout-v2/components/shared/scenario-badge.tsx +51 -0
  143. package/src/checkout-v2/components/shared/total-display.tsx +112 -0
  144. package/src/checkout-v2/index.ts +2 -0
  145. package/src/checkout-v2/layouts/checkout-layout.tsx +232 -0
  146. package/src/checkout-v2/panels/left/composite-panel.tsx +465 -0
  147. package/src/checkout-v2/panels/left/credit-topup-panel.tsx +681 -0
  148. package/src/checkout-v2/panels/left/scenario-router.tsx +22 -0
  149. package/src/checkout-v2/panels/right/payment-panel.tsx +703 -0
  150. package/src/checkout-v2/types.ts +18 -0
  151. package/src/checkout-v2/utils/format.ts +204 -0
  152. package/src/checkout-v2/utils/scenario-detector.ts +30 -0
  153. package/src/checkout-v2/views/error-view.tsx +293 -0
  154. package/src/checkout-v2/views/loading-view.tsx +162 -0
  155. package/src/checkout-v2/views/success-view.tsx +770 -0
  156. package/src/components/phone-field.tsx +119 -0
  157. package/src/index.ts +3 -0
  158. package/src/locales/en.tsx +45 -4
  159. package/src/locales/zh.tsx +43 -4
  160. package/src/payment/form/index.tsx +16 -1
@@ -0,0 +1,15 @@
1
+ import type { ThemeOptions, SxProps } from '@mui/material';
2
+ import type { LiteralUnion } from 'type-fest';
3
+ export type CheckoutScenario = 'credit-topup' | 'subscription' | 'composite';
4
+ export type PaymentThemeOptions = ThemeOptions & {
5
+ sx?: SxProps;
6
+ };
7
+ export interface CheckoutV2Props {
8
+ id: string;
9
+ onPaid?: (result: any) => void;
10
+ onError?: (err: Error) => void;
11
+ goBack?: () => void;
12
+ theme?: 'default' | 'inherit' | PaymentThemeOptions;
13
+ mode?: LiteralUnion<'standalone' | 'inline', string>;
14
+ extraParams?: Record<string, string>;
15
+ }
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,59 @@
1
+ import type { TPaymentCurrency } from '@blocklet/payment-types';
2
+ export declare const INTERVAL_LOCALE_KEY: Record<string, string>;
3
+ export declare function countryCodeToFlag(code: string): string;
4
+ export declare function formatTokenAmount(unitAmount: string | number | bigint, currency: TPaymentCurrency | null): string;
5
+ interface CurrencyOption {
6
+ currency_id: string;
7
+ unit_amount: string;
8
+ custom_unit_amount?: {
9
+ preset?: string;
10
+ presets?: string[];
11
+ } | null;
12
+ }
13
+ interface PriceWithDynamic {
14
+ pricing_type?: string;
15
+ base_amount?: string;
16
+ unit_amount?: string;
17
+ base_currency?: string;
18
+ currency_id?: string;
19
+ currency_options?: CurrencyOption[];
20
+ price_currency_options?: CurrencyOption[];
21
+ }
22
+ export declare function getUnitAmountForCurrency(price: PriceWithDynamic | null | undefined, currency: TPaymentCurrency | null): string;
23
+ export declare function formatDynamicUnitPrice(price: PriceWithDynamic | null | undefined, currency: TPaymentCurrency | null, exchangeRate: string | null): string | null;
24
+ export declare function tSafe(t: (key: string, params?: any) => string, key: string, fallback: string): string;
25
+ export declare const whiteTooltipSx: {
26
+ '& .MuiTooltip-tooltip': {
27
+ bgcolor: string;
28
+ color: string;
29
+ border: string;
30
+ borderColor: string;
31
+ borderRadius: string;
32
+ boxShadow: string;
33
+ p: number;
34
+ maxWidth: number;
35
+ fontSize: number;
36
+ };
37
+ '& .MuiTooltip-arrow': {
38
+ color: string;
39
+ '&::before': {
40
+ border: string;
41
+ borderColor: string;
42
+ };
43
+ };
44
+ };
45
+ export declare function formatTrialText(t: (key: string) => string, days: number, interval: string): string;
46
+ type TFn = (key: string, params?: Record<string, any>) => string;
47
+ export type ItemTypeBadge = 'subscription' | 'topup' | 'oneTime';
48
+ interface ItemMeta {
49
+ badge: ItemTypeBadge;
50
+ badgeLabel: string;
51
+ title: string;
52
+ subtitle: string;
53
+ }
54
+ /**
55
+ * Derive structured badge / title / subtitle for a checkout session header.
56
+ * Works for the "primary product" header above the item list.
57
+ */
58
+ export declare function getSessionHeaderMeta(t: TFn, session: any, product: any, items: any[]): ItemMeta;
59
+ export {};
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.INTERVAL_LOCALE_KEY = void 0;
7
+ exports.countryCodeToFlag = countryCodeToFlag;
8
+ exports.formatDynamicUnitPrice = formatDynamicUnitPrice;
9
+ exports.formatTokenAmount = formatTokenAmount;
10
+ exports.formatTrialText = formatTrialText;
11
+ exports.getSessionHeaderMeta = getSessionHeaderMeta;
12
+ exports.getUnitAmountForCurrency = getUnitAmountForCurrency;
13
+ exports.tSafe = tSafe;
14
+ exports.whiteTooltipSx = void 0;
15
+ var _util = require("@ocap/util");
16
+ const INTERVAL_LOCALE_KEY = exports.INTERVAL_LOCALE_KEY = {
17
+ day: "common.daily",
18
+ week: "common.weekly",
19
+ month: "common.monthly",
20
+ year: "common.yearly"
21
+ };
22
+ function countryCodeToFlag(code) {
23
+ if (!code || code.length !== 2) return "";
24
+ return String.fromCodePoint(...code.toUpperCase().split("").map(c => 127397 + c.charCodeAt(0)));
25
+ }
26
+ function formatTokenAmount(unitAmount, currency) {
27
+ if (!unitAmount || !currency) return "0";
28
+ try {
29
+ const tokenAmount = (0, _util.fromUnitToToken)(String(unitAmount), currency.decimal || 0);
30
+ const num = Number(tokenAmount);
31
+ if (!Number.isFinite(num)) return "0";
32
+ const abs = Math.abs(num);
33
+ const precision = abs > 0 && abs < 0.01 ? 6 : 2;
34
+ const formatted = num.toLocaleString("en-US", {
35
+ minimumFractionDigits: 0,
36
+ maximumFractionDigits: precision
37
+ });
38
+ return formatted.replace(/\.?0+$/, "") || "0";
39
+ } catch {
40
+ return "0";
41
+ }
42
+ }
43
+ function getUnitAmountForCurrency(price, currency) {
44
+ if (!price || !currency) return "0";
45
+ const options = price.price_currency_options || price.currency_options || [];
46
+ const option = options.find(x => x.currency_id === currency.id);
47
+ if (option) {
48
+ if (option.custom_unit_amount) {
49
+ return option.custom_unit_amount.preset || option.custom_unit_amount.presets?.[0] || option.unit_amount;
50
+ }
51
+ return option.unit_amount;
52
+ }
53
+ if (price.currency_id === currency.id) {
54
+ return price.unit_amount || "0";
55
+ }
56
+ return "0";
57
+ }
58
+ function formatDynamicUnitPrice(price, currency, exchangeRate) {
59
+ if (!price || !currency) return null;
60
+ const isDynamic = price.pricing_type === "dynamic";
61
+ if (isDynamic && exchangeRate && price.base_amount) {
62
+ const rate = Number(exchangeRate);
63
+ if (rate > 0 && Number.isFinite(rate)) {
64
+ const baseUsd = Number(price.base_amount);
65
+ if (baseUsd > 0 && Number.isFinite(baseUsd)) {
66
+ const tokenAmount = baseUsd / rate;
67
+ const abs = Math.abs(tokenAmount);
68
+ const precision = abs > 0 && abs < 0.01 ? 6 : 2;
69
+ return tokenAmount.toLocaleString("en-US", {
70
+ minimumFractionDigits: 0,
71
+ maximumFractionDigits: precision
72
+ }).replace(/\.?0+$/, "") || "0";
73
+ }
74
+ }
75
+ }
76
+ if (!exchangeRate && price.base_amount != null) {
77
+ const baseUsd = Number(price.base_amount);
78
+ if (baseUsd >= 0 && Number.isFinite(baseUsd)) {
79
+ return baseUsd.toLocaleString("en-US", {
80
+ minimumFractionDigits: 2,
81
+ maximumFractionDigits: 2
82
+ });
83
+ }
84
+ }
85
+ return formatTokenAmount(getUnitAmountForCurrency(price, currency), currency);
86
+ }
87
+ function tSafe(t, key, fallback) {
88
+ const v = t(key);
89
+ return v && !v.includes(".") ? v : fallback;
90
+ }
91
+ const whiteTooltipSx = exports.whiteTooltipSx = {
92
+ "& .MuiTooltip-tooltip": {
93
+ bgcolor: "background.paper",
94
+ color: "text.primary",
95
+ border: "1px solid",
96
+ borderColor: "divider",
97
+ borderRadius: "10px",
98
+ boxShadow: "0 8px 24px rgba(0,0,0,0.12)",
99
+ p: 1.5,
100
+ maxWidth: 280,
101
+ fontSize: 12
102
+ },
103
+ "& .MuiTooltip-arrow": {
104
+ color: "background.paper",
105
+ "&::before": {
106
+ border: "1px solid",
107
+ borderColor: "divider"
108
+ }
109
+ }
110
+ };
111
+ function formatTrialText(t, days, interval) {
112
+ const intervalLabel = t(`common.${interval || "day"}`);
113
+ return `${days} ${intervalLabel}${days > 1 ? "s" : ""} free`;
114
+ }
115
+ function getSessionHeaderMeta(t, session, product, items) {
116
+ const mode = session?.mode || "payment";
117
+ const isSubscription = ["subscription", "setup"].includes(mode);
118
+ const isCreditTopup = items.length === 1 && mode === "payment" && items[0]?.price?.product?.type === "credit" && items[0]?.price?.metadata?.credit_config;
119
+ let badge;
120
+ if (isCreditTopup) {
121
+ badge = "topup";
122
+ } else if (isSubscription) {
123
+ badge = "subscription";
124
+ } else {
125
+ badge = "oneTime";
126
+ }
127
+ const badgeLabel = t(`payment.checkout.typeBadge.${badge}`);
128
+ const productName = product?.name || items[0]?.price?.product?.name || "";
129
+ let title = productName;
130
+ if (productName) {
131
+ if (isSubscription) {
132
+ title = t("payment.checkout.headerTitle.subscribe", {
133
+ name: productName
134
+ });
135
+ } else if (!isCreditTopup) {
136
+ title = t("payment.checkout.headerTitle.purchase", {
137
+ name: productName
138
+ });
139
+ }
140
+ }
141
+ let subtitle = "";
142
+ if (isCreditTopup) {
143
+ subtitle = t("payment.checkout.subtitle.creditsTopup");
144
+ } else if (isSubscription) {
145
+ const planName = product?.metadata?.plan_name || product?.metadata?.plan_display_name;
146
+ if (planName) {
147
+ subtitle = planName;
148
+ }
149
+ } else {
150
+ subtitle = t("payment.checkout.subtitle.oneTime");
151
+ }
152
+ return {
153
+ badge,
154
+ badgeLabel,
155
+ title,
156
+ subtitle
157
+ };
158
+ }
@@ -0,0 +1,3 @@
1
+ import type { TCheckoutSessionExpanded, TLineItemExpanded } from '@blocklet/payment-types';
2
+ import type { CheckoutScenario } from '../types';
3
+ export declare function detectScenario(session: TCheckoutSessionExpanded | null | undefined, items: TLineItemExpanded[]): CheckoutScenario;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.detectScenario = detectScenario;
7
+ function detectScenario(session, items) {
8
+ if (!session) return "composite";
9
+ const isSingleItem = items.length === 1;
10
+ const isPaymentMode = session.mode === "payment";
11
+ const isSubscriptionMode = ["subscription", "setup"].includes(session.mode || "");
12
+ if (isSingleItem && isPaymentMode) {
13
+ const item = items[0];
14
+ const product = item.price?.product;
15
+ if (product?.type === "credit" && item.price?.metadata?.credit_config) {
16
+ return "credit-topup";
17
+ }
18
+ }
19
+ if (isSingleItem && isSubscriptionMode && !items.some(i => i.cross_sell)) {
20
+ return "subscription";
21
+ }
22
+ return "composite";
23
+ }
@@ -0,0 +1,7 @@
1
+ interface ErrorViewProps {
2
+ error: string;
3
+ errorCode?: 'SESSION_EXPIRED' | 'EMPTY_LINE_ITEMS' | null;
4
+ mode?: string;
5
+ }
6
+ export default function ErrorView({ error, errorCode, mode }: ErrorViewProps): import("react").JSX.Element;
7
+ export {};
@@ -0,0 +1,321 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ module.exports = ErrorView;
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ var _material = require("@mui/material");
9
+ var _styles = require("@mui/material/styles");
10
+ var _ArrowBack = _interopRequireDefault(require("@mui/icons-material/ArrowBack"));
11
+ var _Header = _interopRequireDefault(require("@blocklet/ui-react/lib/Header"));
12
+ var _context = require("@arcblock/ux/lib/Locale/context");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ function GeometricDecoration() {
15
+ const theme = (0, _styles.useTheme)();
16
+ const gridColor = (0, _styles.alpha)(theme.palette.primary.main, 0.06);
17
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
18
+ sx: {
19
+ position: "relative",
20
+ width: {
21
+ xs: 200,
22
+ md: 260
23
+ },
24
+ height: {
25
+ xs: 200,
26
+ md: 260
27
+ },
28
+ mb: {
29
+ xs: 4,
30
+ md: 6
31
+ }
32
+ },
33
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
34
+ sx: {
35
+ position: "absolute",
36
+ inset: 0,
37
+ borderRadius: "38% 62% 63% 37% / 41% 44% 56% 59%",
38
+ background: t => `linear-gradient(45deg, ${(0, _styles.alpha)(t.palette.primary.main, 0.1)}, ${(0, _styles.alpha)(t.palette.primary.main, 0.03)})`,
39
+ filter: "blur(1px)",
40
+ animation: "spin 20s linear infinite",
41
+ "@keyframes spin": {
42
+ from: {
43
+ transform: "rotate(0deg)"
44
+ },
45
+ to: {
46
+ transform: "rotate(360deg)"
47
+ }
48
+ }
49
+ }
50
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
51
+ sx: {
52
+ position: "absolute",
53
+ inset: 0,
54
+ borderRadius: "38% 62% 63% 37% / 41% 44% 56% 59%",
55
+ background: t => `linear-gradient(135deg, ${(0, _styles.alpha)(t.palette.primary.main, 0.07)}, ${(0, _styles.alpha)(t.palette.primary.main, 0.01)})`,
56
+ filter: "blur(1px)",
57
+ transform: "scale(0.88)",
58
+ opacity: 0.6,
59
+ animation: "spinReverse 15s linear infinite",
60
+ "@keyframes spinReverse": {
61
+ from: {
62
+ transform: "scale(0.88) rotate(0deg)"
63
+ },
64
+ to: {
65
+ transform: "scale(0.88) rotate(-360deg)"
66
+ }
67
+ }
68
+ }
69
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
70
+ sx: {
71
+ position: "absolute",
72
+ inset: 0,
73
+ borderRadius: "38% 62% 63% 37% / 41% 44% 56% 59%",
74
+ overflow: "hidden",
75
+ animation: "spin 20s linear infinite"
76
+ },
77
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)("svg", {
78
+ width: "100%",
79
+ height: "100%",
80
+ viewBox: "0 0 260 260",
81
+ fill: "none",
82
+ xmlns: "http://www.w3.org/2000/svg",
83
+ style: {
84
+ position: "absolute",
85
+ inset: 0
86
+ },
87
+ children: [[52, 87, 122, 157, 192].map(y => /* @__PURE__ */(0, _jsxRuntime.jsx)("line", {
88
+ x1: "30",
89
+ y1: y,
90
+ x2: "230",
91
+ y2: y,
92
+ stroke: gridColor,
93
+ strokeWidth: "0.5"
94
+ }, `h${y}`)), [52, 87, 122, 157, 192].map(x => /* @__PURE__ */(0, _jsxRuntime.jsx)("line", {
95
+ x1: x,
96
+ y1: "30",
97
+ x2: x,
98
+ y2: "230",
99
+ stroke: gridColor,
100
+ strokeWidth: "0.5"
101
+ }, `v${x}`)), /* @__PURE__ */(0, _jsxRuntime.jsx)("line", {
102
+ x1: "52",
103
+ y1: "52",
104
+ x2: "192",
105
+ y2: "192",
106
+ stroke: gridColor,
107
+ strokeWidth: "0.5"
108
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)("line", {
109
+ x1: "192",
110
+ y1: "52",
111
+ x2: "52",
112
+ y2: "192",
113
+ stroke: gridColor,
114
+ strokeWidth: "0.5"
115
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)("circle", {
116
+ cx: "130",
117
+ cy: "130",
118
+ r: "40",
119
+ stroke: gridColor,
120
+ strokeWidth: "0.5"
121
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)("circle", {
122
+ cx: "130",
123
+ cy: "130",
124
+ r: "75",
125
+ stroke: gridColor,
126
+ strokeWidth: "0.5"
127
+ }), [[122, 87], [157, 87], [87, 122], [122, 122], [157, 122], [192, 122], [87, 157], [122, 157], [157, 157], [122, 192], [157, 192]].map(([cx, cy]) => /* @__PURE__ */(0, _jsxRuntime.jsx)("circle", {
128
+ cx,
129
+ cy,
130
+ r: "1.5",
131
+ fill: gridColor
132
+ }, `d${cx}-${cy}`))]
133
+ })
134
+ })]
135
+ });
136
+ }
137
+ function getErrorConfig(errorCode, error, t) {
138
+ if (errorCode === "SESSION_EXPIRED") {
139
+ return {
140
+ title: t("payment.checkout.expired.title"),
141
+ description: t("payment.checkout.expired.description"),
142
+ color: "#f59e0b"
143
+ };
144
+ }
145
+ if (errorCode === "EMPTY_LINE_ITEMS") {
146
+ return {
147
+ title: t("payment.checkout.emptyItems.title"),
148
+ description: t("payment.checkout.emptyItems.description"),
149
+ color: "#94a3b8"
150
+ };
151
+ }
152
+ return {
153
+ title: t("payment.checkout.error.title"),
154
+ description: error,
155
+ color: "#ef4444"
156
+ };
157
+ }
158
+ function ErrorContent({
159
+ error,
160
+ errorCode = void 0
161
+ }) {
162
+ const {
163
+ t
164
+ } = (0, _context.useLocaleContext)();
165
+ const theme = (0, _styles.useTheme)();
166
+ const {
167
+ title,
168
+ description
169
+ } = getErrorConfig(errorCode, error, t);
170
+ const primaryColor = theme.palette.primary.main;
171
+ const appUrl = typeof window !== "undefined" ? window.blocklet?.appUrl : "/";
172
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
173
+ alignItems: "center",
174
+ justifyContent: "center",
175
+ sx: {
176
+ flex: 1,
177
+ textAlign: "center",
178
+ px: 3
179
+ },
180
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(GeometricDecoration, {}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
181
+ component: "h1",
182
+ sx: {
183
+ fontWeight: 800,
184
+ fontSize: {
185
+ xs: 36,
186
+ md: 52
187
+ },
188
+ lineHeight: 1.05,
189
+ letterSpacing: "-0.03em",
190
+ color: "text.primary",
191
+ mb: 2
192
+ },
193
+ children: title
194
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
195
+ sx: {
196
+ color: "text.secondary",
197
+ fontSize: {
198
+ xs: 15,
199
+ md: 17
200
+ },
201
+ fontWeight: 300,
202
+ lineHeight: 1.7,
203
+ maxWidth: 420,
204
+ letterSpacing: "0.01em"
205
+ },
206
+ children: description
207
+ }), appUrl && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
208
+ href: appUrl,
209
+ variant: "contained",
210
+ disableElevation: true,
211
+ startIcon: /* @__PURE__ */(0, _jsxRuntime.jsx)(_ArrowBack.default, {
212
+ sx: {
213
+ fontSize: "20px !important"
214
+ }
215
+ }),
216
+ sx: {
217
+ mt: 5,
218
+ minWidth: 240,
219
+ height: 56,
220
+ px: 6,
221
+ borderRadius: "9999px",
222
+ textTransform: "none",
223
+ fontWeight: 600,
224
+ fontSize: 16,
225
+ letterSpacing: "0.02em",
226
+ boxShadow: `0 8px 32px -4px ${(0, _styles.alpha)(primaryColor, 0.3)}`,
227
+ "&:hover": {
228
+ boxShadow: `0 12px 40px -4px ${(0, _styles.alpha)(primaryColor, 0.4)}`,
229
+ transform: "translateY(-1px)"
230
+ },
231
+ transition: "all 0.2s ease"
232
+ },
233
+ children: t("common.back")
234
+ })]
235
+ });
236
+ }
237
+ function ErrorView({
238
+ error,
239
+ errorCode = void 0,
240
+ mode = "inline"
241
+ }) {
242
+ const theme = (0, _styles.useTheme)();
243
+ const primaryColor = theme.palette.primary.main;
244
+ const isFullScreen = mode === "standalone";
245
+ const meshBg = {
246
+ bgcolor: t => t.palette.mode === "dark" ? "background.default" : "#f8faff",
247
+ backgroundImage: t => t.palette.mode === "dark" ? "none" : `radial-gradient(at 0% 0%, ${(0, _styles.alpha)(primaryColor, 0.06)} 0px, transparent 50%),
248
+ radial-gradient(at 100% 0%, ${(0, _styles.alpha)(primaryColor, 0.04)} 0px, transparent 50%),
249
+ radial-gradient(at 100% 100%, ${(0, _styles.alpha)(primaryColor, 0.06)} 0px, transparent 50%),
250
+ radial-gradient(at 0% 100%, rgba(203,213,225,0.3) 0px, transparent 50%)`
251
+ };
252
+ if (!isFullScreen) {
253
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
254
+ sx: {
255
+ display: "flex",
256
+ width: "100%",
257
+ minHeight: {
258
+ xs: 400,
259
+ md: 520
260
+ },
261
+ maxWidth: 1120,
262
+ mx: "auto",
263
+ borderRadius: "16px",
264
+ overflow: "hidden",
265
+ boxShadow: 1,
266
+ border: 1,
267
+ borderColor: "divider",
268
+ ...meshBg
269
+ },
270
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
271
+ sx: {
272
+ flex: 1,
273
+ p: {
274
+ xs: 4,
275
+ md: 6
276
+ },
277
+ display: "flex",
278
+ flexDirection: "column",
279
+ justifyContent: "center",
280
+ alignItems: "center"
281
+ },
282
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(ErrorContent, {
283
+ error,
284
+ errorCode
285
+ })
286
+ })
287
+ });
288
+ }
289
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
290
+ sx: {
291
+ width: "100%",
292
+ height: "100vh",
293
+ minHeight: "100vh",
294
+ display: "flex",
295
+ flexDirection: "column",
296
+ position: "relative",
297
+ overflow: "hidden",
298
+ ...meshBg
299
+ },
300
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_Header.default, {
301
+ sx: {
302
+ position: "absolute",
303
+ top: 20,
304
+ left: 0,
305
+ right: 0,
306
+ zIndex: 10,
307
+ background: "transparent",
308
+ "& .header-container": {
309
+ height: "auto"
310
+ }
311
+ },
312
+ hideNavMenu: true,
313
+ brand: null,
314
+ description: null,
315
+ addons: buildIns => buildIns.filter(addon => ["locale-selector", "theme-mode-toggle", "session-user"].includes(addon.key))
316
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(ErrorContent, {
317
+ error,
318
+ errorCode
319
+ })]
320
+ });
321
+ }
@@ -0,0 +1,5 @@
1
+ interface LoadingViewProps {
2
+ mode?: string;
3
+ }
4
+ export default function LoadingView({ mode }: LoadingViewProps): import("react").JSX.Element;
5
+ export {};