mantur-components 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,57 +1,67 @@
1
1
  # mantur-components
2
2
 
3
- Reusable Mantur React component library for React and Arco Design.
3
+ Mantur React 组件库,基于 React Arco Design
4
4
 
5
- ## Install
5
+ ## 安装
6
6
 
7
7
  ```bash
8
8
  npm install mantur-components
9
9
  ```
10
10
 
11
- Required peer dependencies:
11
+ 需要宿主项目提供以下 peer dependencies
12
12
 
13
13
  ```bash
14
14
  npm install react react-dom @arco-design/web-react next-themes react-i18next
15
15
  ```
16
16
 
17
- The library uses Tailwind utility classes and does not export a standalone CSS file.
17
+
18
18
 
19
19
  ## ManturHeader
20
20
 
21
- `ManturHeader` is the shared Mantur user header. It owns the header UI and the API calls for:
21
+ `ManturHeader` Mantur 用户端共用 Header。组件内部已经封装以下能力:
22
22
 
23
- - tenant list
24
- - current tenant
25
- - tenant switching
26
- - user points
27
- - profile update
28
- - logout
29
- - language switch
30
- - theme switch
23
+ - 获取团队列表
24
+ - 获取当前团队
25
+ - 切换团队
26
+ - 获取用户积分
27
+ - 个人资料更新
28
+ - 退出登录
29
+ - 语言切换
30
+ - 主题切换
31
31
 
32
- Basic usage:
32
+ ### 基础使用
33
33
 
34
34
  ```tsx
35
35
  import { ManturHeader } from "mantur-components";
36
36
 
37
- export function Header({ userInfo }: { userInfo: { username?: string; nickname?: string; avatar?: string } | null }) {
37
+ export function Header({
38
+ userInfo,
39
+ }: {
40
+ userInfo: { username?: string; nickname?: string; avatar?: string } | null;
41
+ }) {
38
42
  return <ManturHeader user={userInfo} />;
39
43
  }
40
44
  ```
41
45
 
42
- With disabled tenant switching and custom slots:
46
+ ### 禁用团队切换和自定义插槽
43
47
 
44
48
  ```tsx
45
49
  import { ManturHeader } from "mantur-components";
46
50
 
47
- export function Header({ userInfo, disabled }: { userInfo: UserInfo | null; disabled?: boolean }) {
51
+ export function Header({
52
+ userInfo,
53
+ disabled,
54
+ }: {
55
+ userInfo: UserInfo | null;
56
+ disabled?: boolean;
57
+ }) {
48
58
  return (
49
59
  <ManturHeader
50
60
  user={userInfo}
51
61
  disabled={disabled}
52
- brandSlot={<span className="text-lg font-bold">Custom Brand</span>}
62
+ brandSlot={<span className="text-lg font-bold">自定义品牌</span>}
53
63
  >
54
- <div className="px-4">Custom center content</div>
64
+ <div className="px-4">自定义中间内容</div>
55
65
  </ManturHeader>
56
66
  );
57
67
  }
@@ -65,18 +75,21 @@ interface ManturHeaderProps {
65
75
  disabled?: boolean;
66
76
  brandSlot?: React.ReactNode;
67
77
  children?: React.ReactNode;
78
+ onTenantContextChange?: (detail: ManturTenantContextDetail) => void;
68
79
  }
69
80
  ```
70
81
 
71
- `user`: Current user shown in the right user menu.
82
+ `user`:右侧用户菜单展示的当前用户信息。
83
+
84
+ `disabled`:是否禁用团队切换。为 `true` 时,团队选择器展示为禁用态,无法展开和切换。
72
85
 
73
- `disabled`: Disables tenant switching. When true, the tenant selector is shown as disabled and cannot be opened or switched.
86
+ `brandSlot`:Logo 右侧品牌标题插槽。传入后显示传入内容;不传则显示默认国际化标题。
74
87
 
75
- `brandSlot`: Replaces the default brand title next to the logo. If omitted, the default localized title is shown.
88
+ `children`:Header 中间弹性区域插槽。传入后显示传入内容;不传则保持为空。
76
89
 
77
- `children`: Renders custom content in the middle flexible header area. If omitted, the area stays empty.
90
+ `onTenantContextChange`:Header 完成团队上下文初始化或切换团队成功后触发,直接透出当前选中团队、团队列表和当前团队认证上下文。宿主项目需要同步自己的 store 时优先使用这个回调。
78
91
 
79
- ### User Type
92
+ ### 用户类型
80
93
 
81
94
  ```ts
82
95
  interface ManturHeaderUser {
@@ -88,56 +101,47 @@ interface ManturHeaderUser {
88
101
  }
89
102
  ```
90
103
 
91
- ### API Base
104
+ ## API 配置
92
105
 
93
- By default, API requests use `import.meta.env.VITE_API` and fall back to `/api`.
106
+ 默认情况下,组件库接口请求使用 `import.meta.env.VITE_API`,如果没有配置则回退到 `/api`。
94
107
 
95
- You can override it before rendering:
108
+ 可以在渲染组件前通过全局变量覆盖:
96
109
 
97
110
  ```ts
98
111
  window.__MANTUR_COMPONENTS_API_BASE__ = "/api";
99
112
  ```
100
113
 
101
- Points endpoint defaults to `/users/me/points`. It can be overridden:
114
+ 积分接口默认是 `/users/me/points`,也可以覆盖:
102
115
 
103
116
  ```ts
104
117
  window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__ = "/users/me/points";
105
118
  ```
106
119
 
107
- ### Tenant Context Event
120
+ ## 团队上下文同步
108
121
 
109
- The header fetches and switches tenants internally. If the host app needs to sync local stores, listen to `MANTUR_TENANT_CONTEXT_CHANGE_EVENT`.
122
+ 团队列表、当前团队、切换团队都由 `ManturHeader` 内部处理。
123
+
124
+ 如果宿主项目需要同步自己的 store,例如 `activeTenantId`、权限、角色、已开通应用,优先通过 `ManturHeader` 的 `onTenantContextChange` 回调获取当前团队上下文。
110
125
 
111
126
  ```tsx
112
- import {
113
- getManturTenantContextSnapshot,
114
- MANTUR_TENANT_CONTEXT_CHANGE_EVENT,
115
- type ManturTenantContextDetail,
116
- } from "mantur-components";
127
+ import { ManturHeader, type ManturTenantContextDetail } from "mantur-components";
117
128
 
118
129
  function applyTenantContext(detail: ManturTenantContextDetail) {
119
130
  const tenantId = detail.auth?.tenantId || detail.currentTenant?.tenantId;
120
131
 
121
- // Sync host app stores here.
132
+ // 在这里同步宿主项目的状态。
122
133
  // setActiveTenantId(tenantId)
123
134
  // setPermissions(detail.auth?.permissions || [])
124
135
  // setRoles(detail.auth?.roles || [])
125
136
  // setEnabledApps(detail.auth?.enabledApps || [])
126
137
  }
127
138
 
128
- window.addEventListener(MANTUR_TENANT_CONTEXT_CHANGE_EVENT, (event) => {
129
- if (event instanceof CustomEvent) {
130
- applyTenantContext(event.detail as ManturTenantContextDetail);
131
- }
132
- });
133
-
134
- const snapshot = getManturTenantContextSnapshot();
135
- if (snapshot) {
136
- applyTenantContext(snapshot);
139
+ function Header({ userInfo }: { userInfo: UserInfo | null }) {
140
+ return <ManturHeader user={userInfo} onTenantContextChange={applyTenantContext} />;
137
141
  }
138
142
  ```
139
143
 
140
- Tenant context detail:
144
+ 团队上下文数据结构:
141
145
 
142
146
  ```ts
143
147
  interface ManturTenantContextDetail {
@@ -154,7 +158,7 @@ interface ManturTenantContextDetail {
154
158
  }
155
159
  ```
156
160
 
157
- ### Exported Helpers
161
+ ## 导出的工具方法
158
162
 
159
163
  ```ts
160
164
  import {
@@ -171,7 +175,7 @@ import {
171
175
  } from "mantur-components";
172
176
  ```
173
177
 
174
- ## Build
178
+ ## 构建
175
179
 
176
180
  ```bash
177
181
  npm run build
@@ -1,2 +1,2 @@
1
1
  import type { ManturHeaderProps } from "../types";
2
- export declare function ManturHeader({ user, disabled, brandSlot, children, }: ManturHeaderProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function ManturHeader({ user, disabled, brandSlot, children, onTenantContextChange, }: ManturHeaderProps): import("react/jsx-runtime").JSX.Element;
@@ -1,44 +1,44 @@
1
1
  import { useCallback as e, useEffect as t, useMemo as n, useRef as r, useState as i } from "react";
2
2
  import { Avatar as a, Button as o, Card as s, DatePicker as c, Divider as l, Dropdown as u, Form as d, Grid as f, Input as p, Menu as m, Message as h, Modal as g, Pagination as _, Select as v, Table as y, Tabs as b, Tag as x, Typography as S, Upload as C } from "@arco-design/web-react";
3
- import { IconCheckCircleFill as w, IconDown as T, IconEdit as E, IconFile as D, IconLanguage as O, IconMoonFill as k, IconPlus as A, IconPoweroff as j, IconSunFill as M, IconUpload as N } from "@arco-design/web-react/icon";
4
- import { useTranslation as ee } from "react-i18next";
3
+ import { IconCheckCircleFill as w, IconDown as T, IconEdit as E, IconFile as D, IconLanguage as O, IconMoonFill as ee, IconPlus as k, IconPoweroff as A, IconSunFill as j, IconUpload as M } from "@arco-design/web-react/icon";
4
+ import { useTranslation as N } from "react-i18next";
5
5
  import { jsx as P, jsxs as F } from "react/jsx-runtime";
6
- import { useTheme as te } from "next-themes";
6
+ import { useTheme as I } from "next-themes";
7
7
  //#region src/api.ts
8
- var ne = "/api", I = "/users/me/points", L = "mantur-points-refresh", R = "mantur-tenant-context-change";
9
- function re() {
10
- return typeof window < "u" && window.__MANTUR_COMPONENTS_API_BASE__ ? window.__MANTUR_COMPONENTS_API_BASE__ : ne;
8
+ var L = "/api", te = "/users/me/points", R = "mantur-points-refresh", z = "mantur-tenant-context-change";
9
+ function ne() {
10
+ return typeof window < "u" && window.__MANTUR_COMPONENTS_API_BASE__ ? window.__MANTUR_COMPONENTS_API_BASE__ : L;
11
11
  }
12
- function ie() {
13
- return typeof window < "u" && window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__ ? window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__ : I;
12
+ function re() {
13
+ return typeof window < "u" && window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__ ? window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__ : te;
14
14
  }
15
- function z(e) {
15
+ function B(e) {
16
16
  if (typeof document > "u") return;
17
17
  let t = `${encodeURIComponent(e)}=`;
18
18
  return document.cookie.split("; ").find((e) => e.startsWith(t))?.slice(t.length);
19
19
  }
20
- function B(e) {
20
+ function V(e) {
21
21
  if (typeof document > "u") return;
22
22
  let t = encodeURIComponent(e), n = window.location.hostname, r = [void 0, n], i = n.split(".");
23
23
  i.length >= 2 && r.push(`.${i.slice(-2).join(".")}`), r.forEach((e) => {
24
24
  document.cookie = `${t}=; path=/; max-age=0${e ? `; domain=${e}` : ""}`;
25
25
  });
26
26
  }
27
- function ae(e) {
27
+ function H(e) {
28
28
  let t = JSON.parse(e || "null");
29
29
  if (!t) throw Error("Request failed");
30
30
  if (t.code !== 0) throw Error(t.message || "Request failed");
31
31
  return t;
32
32
  }
33
- async function V(e, t = {}) {
34
- let n = z("front-token"), r = z("Accept-Language"), i = t.headers || {};
33
+ async function U(e, t = {}) {
34
+ let n = B("front-token"), r = B("Accept-Language"), i = t.headers || {};
35
35
  return n && (i.Authorization = decodeURIComponent(n)), r && (i["Accept-Language"] = decodeURIComponent(r)), new Promise((n, r) => {
36
36
  let a = new XMLHttpRequest();
37
- a.open(t.method || "GET", `${re()}${e}`, !0), a.timeout = t.timeout || 1e4, Object.entries(i).forEach(([e, t]) => {
37
+ a.open(t.method || "GET", `${ne()}${e}`, !0), a.timeout = t.timeout || 1e4, Object.entries(i).forEach(([e, t]) => {
38
38
  a.setRequestHeader(e, t);
39
39
  }), a.onload = () => {
40
40
  try {
41
- let e = ae(a.responseText);
41
+ let e = H(a.responseText);
42
42
  if (a.status < 200 || a.status >= 300) {
43
43
  r(Error(e.message || a.statusText));
44
44
  return;
@@ -50,31 +50,31 @@ async function V(e, t = {}) {
50
50
  }, a.onerror = () => r(/* @__PURE__ */ Error("Network request failed")), a.ontimeout = () => r(/* @__PURE__ */ Error("Network request timed out")), a.send(t.body ?? null);
51
51
  });
52
52
  }
53
- async function oe() {
53
+ async function ie() {
54
54
  try {
55
- await V("/auth/front-logout", { method: "DELETE" });
55
+ await U("/auth/front-logout", { method: "DELETE" });
56
56
  } catch (e) {
57
57
  console.warn("Logout request failed, continuing local logout.", e);
58
58
  } finally {
59
- B("front-token"), B("refreshToken"), typeof window < "u" && window.location.reload();
59
+ V("front-token"), V("refreshToken"), typeof window < "u" && window.location.reload();
60
60
  }
61
61
  }
62
- async function se(e) {
62
+ async function ae(e) {
63
63
  let t;
64
64
  if (e.avatarFile) {
65
65
  let n = new FormData();
66
- n.append("file", e.avatarFile), t = (await V("/users/me/avatar", {
66
+ n.append("file", e.avatarFile), t = (await U("/users/me/avatar", {
67
67
  method: "POST",
68
68
  body: n
69
69
  })).data;
70
70
  }
71
- return (await V("/users/me", {
71
+ return (await U("/users/me", {
72
72
  method: "PUT",
73
73
  headers: { "Content-Type": "application/json;charset=utf-8" },
74
74
  body: JSON.stringify({ nickname: e.nickname })
75
75
  })).data || t;
76
76
  }
77
- function ce(e) {
77
+ function oe(e) {
78
78
  let t = (...t) => {
79
79
  let n = t.map((t) => e?.[t]).find((e) => e !== void 0);
80
80
  return typeof n == "number" ? n : Number(n || 0);
@@ -85,14 +85,14 @@ function ce(e) {
85
85
  gifted: t("gifted", "giftedPoints", "bonusPoints")
86
86
  };
87
87
  }
88
- async function H() {
89
- return ce((await V(ie())).data);
88
+ async function W() {
89
+ return oe((await U(re())).data);
90
90
  }
91
- async function U() {
92
- let e = await H();
93
- return typeof window < "u" && window.dispatchEvent(new CustomEvent(L, { detail: e })), e;
91
+ async function G() {
92
+ let e = await W();
93
+ return typeof window < "u" && window.dispatchEvent(new CustomEvent(R, { detail: e })), e;
94
94
  }
95
- function W(e, t) {
95
+ function se(e, t) {
96
96
  return t?.tenantId ? e.find((e) => e.tenantId === t.tenantId) || {
97
97
  tenantId: t.tenantId,
98
98
  tenantName: t.tenantName || t.tenantId,
@@ -102,38 +102,38 @@ function W(e, t) {
102
102
  }))
103
103
  } : e.find((e) => e.isOwner) || e[0];
104
104
  }
105
- function G(e) {
106
- typeof window < "u" && (window.__MANTUR_COMPONENTS_TENANT_CONTEXT__ = e, window.dispatchEvent(new CustomEvent(R, { detail: e })));
105
+ function ce(e) {
106
+ typeof window < "u" && (window.__MANTUR_COMPONENTS_TENANT_CONTEXT__ = e, window.dispatchEvent(new CustomEvent(z, { detail: e })));
107
107
  }
108
108
  function le() {
109
109
  if (!(typeof window > "u")) return window.__MANTUR_COMPONENTS_TENANT_CONTEXT__;
110
110
  }
111
111
  async function K() {
112
- return (await V("/users/me/tenants")).data || [];
112
+ return (await U("/users/me/tenants")).data || [];
113
113
  }
114
114
  async function q() {
115
- return (await V("/auth/current-tenant")).data;
115
+ return (await U("/auth/current-tenant")).data;
116
116
  }
117
117
  async function ue(e) {
118
- return (await V(`/auth/current-tenant/${e}`, { method: "PUT" })).data;
118
+ return (await U(`/auth/current-tenant/${e}`, { method: "PUT" })).data;
119
119
  }
120
120
  async function de(e = "refresh") {
121
121
  let [t, n] = await Promise.all([K(), q()]), r = {
122
122
  tenants: t,
123
- currentTenant: W(t, n),
123
+ currentTenant: se(t, n),
124
124
  auth: n,
125
125
  reason: e
126
126
  };
127
- return G(r), r;
127
+ return ce(r), r;
128
128
  }
129
129
  async function fe(e) {
130
130
  let t = await ue(e), n = await K(), r = {
131
131
  tenants: n,
132
- currentTenant: W(n, t),
132
+ currentTenant: se(n, t),
133
133
  auth: t,
134
134
  reason: "switch"
135
135
  };
136
- return G(r), r;
136
+ return ce(r), r;
137
137
  }
138
138
  //#endregion
139
139
  //#region src/labels.ts
@@ -278,7 +278,7 @@ function be(e, t) {
278
278
  document.cookie = `${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=/`;
279
279
  }
280
280
  function xe() {
281
- let { i18n: e } = ee(), [n, r] = i(() => X()), a = Z(n);
281
+ let { i18n: e } = N(), [n, r] = i(() => X()), a = Z(n);
282
282
  return t(() => {
283
283
  r(Y(e.language));
284
284
  }, [e.language]), /* @__PURE__ */ P(u, {
@@ -301,10 +301,10 @@ function xe() {
301
301
  //#endregion
302
302
  //#region src/theme-switch/ThemeSwitch.tsx
303
303
  function Se() {
304
- let { resolvedTheme: e, setTheme: t } = te();
304
+ let { resolvedTheme: e, setTheme: t } = I();
305
305
  return /* @__PURE__ */ P(o, {
306
306
  shape: "circle",
307
- icon: P(e === "light" ? k : M, {}),
307
+ icon: P(e === "light" ? ee : j, {}),
308
308
  onClick: () => {
309
309
  t(e === "light" ? "dark" : "light");
310
310
  }
@@ -469,7 +469,7 @@ function Oe({ visible: e, points: t, text: r, onCancel: a, onRecharge: c }) {
469
469
  children: r.close
470
470
  }), /* @__PURE__ */ P(o, {
471
471
  type: "primary",
472
- icon: /* @__PURE__ */ P(A, {}),
472
+ icon: /* @__PURE__ */ P(k, {}),
473
473
  onClick: () => {
474
474
  a(), c();
475
475
  },
@@ -727,7 +727,7 @@ function Me({ visible: e, user: n, labels: s, onCancel: c, onSubmit: l }) {
727
727
  children: /* @__PURE__ */ P(o, {
728
728
  type: "outline",
729
729
  size: "small",
730
- icon: /* @__PURE__ */ P(N, {}),
730
+ icon: /* @__PURE__ */ P(M, {}),
731
731
  children: u.profileUploadAvatar
732
732
  })
733
733
  })]
@@ -935,7 +935,7 @@ function Fe({ user: e, points: t, text: n, onEditProfile: r, onRecharge: i, onPo
935
935
  children: [/* @__PURE__ */ P(o, {
936
936
  type: "primary",
937
937
  long: !0,
938
- icon: /* @__PURE__ */ P(A, {}),
938
+ icon: /* @__PURE__ */ P(k, {}),
939
939
  className: "h-10! rounded-md! font-semibold!",
940
940
  onClick: i,
941
941
  children: n.recharge
@@ -951,7 +951,7 @@ function Fe({ user: e, points: t, text: n, onEditProfile: r, onRecharge: i, onPo
951
951
  /* @__PURE__ */ P("div", {
952
952
  className: "px-6 py-4",
953
953
  children: /* @__PURE__ */ P(o, {
954
- icon: /* @__PURE__ */ P(j, {}),
954
+ icon: /* @__PURE__ */ P(A, {}),
955
955
  type: "text",
956
956
  status: "danger",
957
957
  long: !0,
@@ -981,83 +981,81 @@ function Be(e, t, n) {
981
981
  let r = e?.roles?.map((e) => e.roleName).filter(Boolean);
982
982
  return r?.length ? r.join(", ") : e?.isOwner ? t : n;
983
983
  }
984
- function Ve({ user: r, disabled: a = !1, brandSlot: o, children: s }) {
985
- let [c, l] = i(() => X()), d = Z(c), [f, p] = i(!1), [g, _] = i(!1), [v, y] = i(!1), [b, x] = i(r), [S, C] = i([]), [w, E] = i(), [D, O] = i(!1), [k, A] = i({
984
+ function Ve({ user: a, disabled: o = !1, brandSlot: s, children: c, onTenantContextChange: l }) {
985
+ let [d, f] = i(() => X()), p = Z(d), [g, _] = i(!1), [v, y] = i(!1), [b, x] = i(!1), [S, C] = i(a), [w, E] = i([]), [D, O] = i(), [ee, k] = i(!1), A = r(l), [j, M] = i({
986
986
  total: 0,
987
987
  recharge: 0,
988
988
  gifted: 0
989
- }), j = w?.tenantId || "", M = a, N = {
990
- total: k.total ?? 0,
991
- recharge: k.recharge ?? 0,
992
- gifted: k.gifted ?? 0
993
- }, ee = async (e) => {
994
- let t = await se(e);
995
- return t && x(t), t;
989
+ }), N = D?.tenantId || "", I = o, L = {
990
+ total: j.total ?? 0,
991
+ recharge: j.recharge ?? 0,
992
+ gifted: j.gifted ?? 0
993
+ }, te = async (e) => {
994
+ let t = await ae(e);
995
+ return t && C(t), t;
996
996
  };
997
997
  t(() => {
998
- x(r);
999
- }, [r]), t(() => {
1000
- let e = (e) => {
1001
- C(e.tenants), E(e.currentTenant);
1002
- }, t = (t) => {
1003
- t instanceof CustomEvent && e(t.detail);
1004
- };
1005
- return window.addEventListener(R, t), O(!0), de().then(e).catch((e) => {
1006
- console.warn("Failed to refresh Mantur tenant context.", e), h.error(d.error);
1007
- }).finally(() => O(!1)), () => {
1008
- window.removeEventListener(R, t);
1009
- };
1010
- }, [d.error]), t(() => {
998
+ C(a);
999
+ }, [a]), t(() => {
1000
+ A.current = l;
1001
+ }, [l]);
1002
+ let z = e((e) => {
1003
+ E(e.tenants), O(e.currentTenant), A.current?.(e);
1004
+ }, []);
1005
+ t(() => {
1006
+ k(!0), de().then(z).catch((e) => {
1007
+ console.warn("Failed to refresh Mantur tenant context.", e), h.error(p.error);
1008
+ }).finally(() => k(!1));
1009
+ }, [z, p.error]), t(() => {
1011
1010
  let e = (e) => {
1012
- e instanceof CustomEvent && A(e.detail);
1011
+ e instanceof CustomEvent && M(e.detail);
1013
1012
  };
1014
- return window.addEventListener(L, e), U().catch((e) => {
1013
+ return window.addEventListener(R, e), G().catch((e) => {
1015
1014
  console.warn("Failed to refresh Mantur user points.", e);
1016
1015
  }), () => {
1017
- window.removeEventListener(L, e);
1016
+ window.removeEventListener(R, e);
1018
1017
  };
1019
1018
  }, []), t(() => {
1020
1019
  let e = (e) => {
1021
- l(e instanceof CustomEvent ? Y(e.detail) : X());
1020
+ f(e instanceof CustomEvent ? Y(e.detail) : X());
1022
1021
  };
1023
1022
  return window.addEventListener(J, e), window.addEventListener("storage", e), () => {
1024
1023
  window.removeEventListener(J, e), window.removeEventListener("storage", e);
1025
1024
  };
1026
1025
  }, []);
1027
- let te = (e) => {
1026
+ let ne = (e) => {
1028
1027
  h.success(e);
1029
- }, ne = (e, t) => {
1028
+ }, re = (e, t) => {
1030
1029
  console.error(t), h.error(e);
1031
- }, I = e(async (e) => {
1032
- if (!M && e !== j) try {
1033
- O(!0);
1034
- let t = await fe(e);
1035
- C(t.tenants), E(t.currentTenant), te(d.switchedToTeam);
1030
+ }, B = e(async (e) => {
1031
+ if (!I && e !== N) try {
1032
+ k(!0), z(await fe(e)), ne(p.switchedToTeam);
1036
1033
  } catch (e) {
1037
- ne(d.error, e);
1034
+ re(p.error, e);
1038
1035
  } finally {
1039
- O(!1);
1036
+ k(!1);
1040
1037
  }
1041
1038
  }, [
1042
- j,
1043
- M,
1044
- d.error,
1045
- d.switchedToTeam
1046
- ]), re = (e) => {
1039
+ z,
1040
+ N,
1041
+ I,
1042
+ p.error,
1043
+ p.switchedToTeam
1044
+ ]), V = (e) => {
1047
1045
  let t = {
1048
- total: N.total + e.points,
1049
- recharge: N.recharge + e.points,
1050
- gifted: N.gifted
1046
+ total: L.total + e.points,
1047
+ recharge: L.recharge + e.points,
1048
+ gifted: L.gifted
1051
1049
  };
1052
- A(t), window.dispatchEvent(new CustomEvent(L, { detail: t })), h.success(d.rechargeSuccess), _(!1);
1053
- }, ie = n(() => /* @__PURE__ */ F(m, {
1050
+ M(t), window.dispatchEvent(new CustomEvent(R, { detail: t })), h.success(p.rechargeSuccess), y(!1);
1051
+ }, H = n(() => /* @__PURE__ */ F(m, {
1054
1052
  className: "w-56 rounded-xl bg-arco-bg-popup shadow-[0_10px_28px_rgb(0_0_0/12%)] [&_.arco-menu-inner]:px-2 [&_.arco-menu-inner]:py-1",
1055
- selectedKeys: j ? [j] : [],
1056
- onClickMenuItem: I,
1053
+ selectedKeys: N ? [N] : [],
1054
+ onClickMenuItem: B,
1057
1055
  children: [/* @__PURE__ */ P("div", {
1058
1056
  className: "px-3 py-2 text-xs font-semibold tracking-[0.04em] text-arco-text-4 uppercase",
1059
- children: d.switchTeam
1060
- }), S.map((e, t) => /* @__PURE__ */ P(m.Item, {
1057
+ children: p.switchTeam
1058
+ }), w.map((e, t) => /* @__PURE__ */ P(m.Item, {
1061
1059
  className: "mb-1 h-auto! min-h-10! overflow-visible! rounded-lg! px-2! py-1! leading-normal!",
1062
1060
  children: /* @__PURE__ */ F("div", {
1063
1061
  className: "flex w-full items-center gap-3 leading-normal",
@@ -1071,25 +1069,25 @@ function Ve({ user: r, disabled: a = !1, brandSlot: o, children: s }) {
1071
1069
  children: e.tenantName
1072
1070
  }), /* @__PURE__ */ P("span", {
1073
1071
  className: "text-xs leading-4 text-arco-text-3",
1074
- children: Be(e, d.owner, d.member)
1072
+ children: Be(e, p.owner, p.member)
1075
1073
  })]
1076
1074
  })]
1077
1075
  })
1078
1076
  }, e.tenantId))]
1079
1077
  }), [
1080
- I,
1081
- j,
1082
- S,
1083
- d
1084
- ]), z = /* @__PURE__ */ P(Fe, {
1085
- user: b,
1086
- points: N,
1087
- text: d,
1088
- onEditProfile: () => p(!0),
1089
- onRecharge: () => _(!0),
1090
- onPointsDetail: () => y(!0),
1091
- onLogout: oe
1092
- }), B = Math.max(0, S.findIndex((e) => e.tenantId === w?.tenantId));
1078
+ B,
1079
+ N,
1080
+ w,
1081
+ p
1082
+ ]), U = /* @__PURE__ */ P(Fe, {
1083
+ user: S,
1084
+ points: L,
1085
+ text: p,
1086
+ onEditProfile: () => _(!0),
1087
+ onRecharge: () => y(!0),
1088
+ onPointsDetail: () => x(!0),
1089
+ onLogout: ie
1090
+ }), oe = Math.max(0, w.findIndex((e) => e.tenantId === D?.tenantId));
1093
1091
  return /* @__PURE__ */ F("div", {
1094
1092
  className: "flex h-20 items-center justify-between bg-transparent pr-8 shadow-[0_2px_10px_rgb(0_0_0/2%)] backdrop-blur-md max-md:pr-4",
1095
1093
  children: [
@@ -1107,31 +1105,31 @@ function Ve({ user: r, disabled: a = !1, brandSlot: o, children: s }) {
1107
1105
  e.currentTarget.style.display = "none";
1108
1106
  }
1109
1107
  })
1110
- }), o ?? /* @__PURE__ */ P("span", {
1108
+ }), s ?? /* @__PURE__ */ P("span", {
1111
1109
  className: "text-lg font-bold tracking-normal text-arco-text-1",
1112
- children: d.title
1110
+ children: p.title
1113
1111
  })]
1114
1112
  }), /* @__PURE__ */ P(u, {
1115
- droplist: ie,
1113
+ droplist: H,
1116
1114
  trigger: "click",
1117
1115
  position: "bl",
1118
- disabled: M,
1116
+ disabled: I,
1119
1117
  children: /* @__PURE__ */ F("div", {
1120
- "aria-disabled": M,
1121
- className: `flex items-center gap-3 rounded-full border border-arco-border-1 bg-arco-bg-1 px-2 py-1.5 transition-all ${M ? "cursor-not-allowed opacity-60" : "cursor-pointer hover:bg-arco-fill-2 hover:shadow-[0_4px_12px_rgb(0_0_0/8%)]"}`,
1118
+ "aria-disabled": I,
1119
+ className: `flex items-center gap-3 rounded-full border border-arco-border-1 bg-arco-bg-1 px-2 py-1.5 transition-all ${I ? "cursor-not-allowed opacity-60" : "cursor-pointer hover:bg-arco-fill-2 hover:shadow-[0_4px_12px_rgb(0_0_0/8%)]"}`,
1122
1120
  children: [
1123
1121
  /* @__PURE__ */ P("div", {
1124
- className: Re(B, !0),
1125
- children: ze(w)
1122
+ className: Re(oe, !0),
1123
+ children: ze(D)
1126
1124
  }),
1127
1125
  /* @__PURE__ */ F("div", {
1128
1126
  className: "flex min-w-0 flex-col",
1129
1127
  children: [/* @__PURE__ */ P("span", {
1130
1128
  className: "text-xs leading-none font-bold text-arco-text-1",
1131
- children: D ? d.loading : w?.tenantName || d.loading
1129
+ children: ee ? p.loading : D?.tenantName || p.loading
1132
1130
  }), /* @__PURE__ */ P("span", {
1133
1131
  className: "mt-1 text-[10px] leading-none text-arco-text-3",
1134
- children: Be(w, d.owner, d.member)
1132
+ children: Be(D, p.owner, p.member)
1135
1133
  })]
1136
1134
  }),
1137
1135
  /* @__PURE__ */ P(T, { className: "ml-1 text-arco-text-3" })
@@ -1141,7 +1139,7 @@ function Ve({ user: r, disabled: a = !1, brandSlot: o, children: s }) {
1141
1139
  }),
1142
1140
  /* @__PURE__ */ P("div", {
1143
1141
  className: "flex-1",
1144
- children: s
1142
+ children: c
1145
1143
  }),
1146
1144
  /* @__PURE__ */ F("div", {
1147
1145
  className: "flex items-center gap-4",
@@ -1149,11 +1147,11 @@ function Ve({ user: r, disabled: a = !1, brandSlot: o, children: s }) {
1149
1147
  className: "flex items-center gap-4",
1150
1148
  children: [/* @__PURE__ */ P(Se, {}), /* @__PURE__ */ P(xe, {})]
1151
1149
  }), /* @__PURE__ */ P(u, {
1152
- droplist: z,
1150
+ droplist: U,
1153
1151
  trigger: "click",
1154
1152
  position: "br",
1155
1153
  onVisibleChange: (e) => {
1156
- e && U().catch((e) => {
1154
+ e && G().catch((e) => {
1157
1155
  console.warn("Failed to refresh Mantur user points.", e);
1158
1156
  });
1159
1157
  },
@@ -1163,7 +1161,7 @@ function Ve({ user: r, disabled: a = !1, brandSlot: o, children: s }) {
1163
1161
  /* @__PURE__ */ F("div", {
1164
1162
  className: "from-arco-primary to-transparent relative rounded-full bg-linear-to-br p-0.5 shadow-sm",
1165
1163
  children: [/* @__PURE__ */ P($, {
1166
- user: b,
1164
+ user: S,
1167
1165
  size: 36
1168
1166
  }), /* @__PURE__ */ P("div", { className: "bg-arco-success border-arco-bg-white absolute right-0 bottom-0 h-3 w-3 rounded-full border-2 shadow-sm" })]
1169
1167
  }),
@@ -1171,7 +1169,7 @@ function Ve({ user: r, disabled: a = !1, brandSlot: o, children: s }) {
1171
1169
  className: "hidden flex-col md:flex",
1172
1170
  children: /* @__PURE__ */ P("span", {
1173
1171
  className: "text-arco-text-1 text-sm font-medium",
1174
- children: b?.nickname || b?.username
1172
+ children: S?.nickname || S?.username
1175
1173
  })
1176
1174
  }),
1177
1175
  /* @__PURE__ */ P(T, { className: "text-arco-text-3 ml-1" })
@@ -1180,29 +1178,29 @@ function Ve({ user: r, disabled: a = !1, brandSlot: o, children: s }) {
1180
1178
  })]
1181
1179
  }),
1182
1180
  /* @__PURE__ */ P(Me, {
1183
- visible: f,
1184
- user: b,
1185
- labels: d,
1186
- onCancel: () => p(!1),
1187
- onSubmit: ee
1188
- }),
1189
- /* @__PURE__ */ P(Pe, {
1190
1181
  visible: g,
1191
- user: b,
1192
- points: N,
1193
- text: d,
1182
+ user: S,
1183
+ labels: p,
1194
1184
  onCancel: () => _(!1),
1195
- onPay: re
1185
+ onSubmit: te
1196
1186
  }),
1197
- /* @__PURE__ */ P(Oe, {
1187
+ /* @__PURE__ */ P(Pe, {
1198
1188
  visible: v,
1199
- points: N,
1200
- text: d,
1189
+ user: S,
1190
+ points: L,
1191
+ text: p,
1201
1192
  onCancel: () => y(!1),
1202
- onRecharge: () => _(!0)
1193
+ onPay: V
1194
+ }),
1195
+ /* @__PURE__ */ P(Oe, {
1196
+ visible: b,
1197
+ points: L,
1198
+ text: p,
1199
+ onCancel: () => x(!1),
1200
+ onRecharge: () => y(!0)
1203
1201
  })
1204
1202
  ]
1205
1203
  });
1206
1204
  }
1207
1205
  //#endregion
1208
- export { ye as LANGUAGE_SOURCE_STORAGE_KEY, ve as LANGUAGE_STORAGE_KEY, xe as LangSwitch, J as MANTUR_LANGUAGE_CHANGE_EVENT, ge as MANTUR_LANGUAGE_SOURCE_STORAGE_KEY, he as MANTUR_LANGUAGE_STORAGE_KEY, _e as MANTUR_MESSAGES, L as MANTUR_POINTS_REFRESH_EVENT, R as MANTUR_TENANT_CONTEXT_CHANGE_EVENT, Ve as ManturHeader, Se as ThemeSwitch, q as getManturCurrentTenant, Z as getManturMessages, le as getManturTenantContextSnapshot, K as getManturTenants, H as getManturUserPoints, X as getStoredManturLocale, Y as normalizeManturLocale, de as refreshManturTenantContext, U as refreshManturUserPoints, fe as switchAndRefreshManturTenant, ue as switchManturTenant };
1206
+ export { ye as LANGUAGE_SOURCE_STORAGE_KEY, ve as LANGUAGE_STORAGE_KEY, xe as LangSwitch, J as MANTUR_LANGUAGE_CHANGE_EVENT, ge as MANTUR_LANGUAGE_SOURCE_STORAGE_KEY, he as MANTUR_LANGUAGE_STORAGE_KEY, _e as MANTUR_MESSAGES, R as MANTUR_POINTS_REFRESH_EVENT, z as MANTUR_TENANT_CONTEXT_CHANGE_EVENT, Ve as ManturHeader, Se as ThemeSwitch, q as getManturCurrentTenant, Z as getManturMessages, le as getManturTenantContextSnapshot, K as getManturTenants, W as getManturUserPoints, X as getStoredManturLocale, Y as normalizeManturLocale, de as refreshManturTenantContext, G as refreshManturUserPoints, fe as switchAndRefreshManturTenant, ue as switchManturTenant };
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`@arco-design/web-react`),require(`@arco-design/web-react/icon`),require(`react-i18next`),require(`react/jsx-runtime`),require(`next-themes`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`@arco-design/web-react`,`@arco-design/web-react/icon`,`react-i18next`,`react/jsx-runtime`,`next-themes`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ManturComponents={},e.React,e.ArcoDesign,e.ArcoDesignIcon,e.ReactI18next,e.jsxRuntime,e.nextThemes))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=`/api`,c=`/users/me/points`,l=`mantur-points-refresh`,u=`mantur-tenant-context-change`;function d(){return typeof window<`u`&&window.__MANTUR_COMPONENTS_API_BASE__?window.__MANTUR_COMPONENTS_API_BASE__:s}function f(){return typeof window<`u`&&window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__?window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__:c}function p(e){if(typeof document>`u`)return;let t=`${encodeURIComponent(e)}=`;return document.cookie.split(`; `).find(e=>e.startsWith(t))?.slice(t.length)}function m(e){if(typeof document>`u`)return;let t=encodeURIComponent(e),n=window.location.hostname,r=[void 0,n],i=n.split(`.`);i.length>=2&&r.push(`.${i.slice(-2).join(`.`)}`),r.forEach(e=>{document.cookie=`${t}=; path=/; max-age=0${e?`; domain=${e}`:``}`})}function h(e){let t=JSON.parse(e||`null`);if(!t)throw Error(`Request failed`);if(t.code!==0)throw Error(t.message||`Request failed`);return t}async function g(e,t={}){let n=p(`front-token`),r=p(`Accept-Language`),i=t.headers||{};return n&&(i.Authorization=decodeURIComponent(n)),r&&(i[`Accept-Language`]=decodeURIComponent(r)),new Promise((n,r)=>{let a=new XMLHttpRequest;a.open(t.method||`GET`,`${d()}${e}`,!0),a.timeout=t.timeout||1e4,Object.entries(i).forEach(([e,t])=>{a.setRequestHeader(e,t)}),a.onload=()=>{try{let e=h(a.responseText);if(a.status<200||a.status>=300){r(Error(e.message||a.statusText));return}n(e)}catch(e){r(e)}},a.onerror=()=>r(Error(`Network request failed`)),a.ontimeout=()=>r(Error(`Network request timed out`)),a.send(t.body??null)})}async function _(){try{await g(`/auth/front-logout`,{method:`DELETE`})}catch(e){console.warn(`Logout request failed, continuing local logout.`,e)}finally{m(`front-token`),m(`refreshToken`),typeof window<`u`&&window.location.reload()}}async function v(e){let t;if(e.avatarFile){let n=new FormData;n.append(`file`,e.avatarFile),t=(await g(`/users/me/avatar`,{method:`POST`,body:n})).data}return(await g(`/users/me`,{method:`PUT`,headers:{"Content-Type":`application/json;charset=utf-8`},body:JSON.stringify({nickname:e.nickname})})).data||t}function y(e){let t=(...t)=>{let n=t.map(t=>e?.[t]).find(e=>e!==void 0);return typeof n==`number`?n:Number(n||0)};return{total:t(`total`,`totalPoints`,`balance`,`points`),recharge:t(`recharge`,`rechargePoints`,`paidPoints`),gifted:t(`gifted`,`giftedPoints`,`bonusPoints`)}}async function b(){return y((await g(f())).data)}async function x(){let e=await b();return typeof window<`u`&&window.dispatchEvent(new CustomEvent(l,{detail:e})),e}function S(e,t){return t?.tenantId?e.find(e=>e.tenantId===t.tenantId)||{tenantId:t.tenantId,tenantName:t.tenantName||t.tenantId,roles:t.roles?.map(e=>({roleCode:e,roleName:e}))}:e.find(e=>e.isOwner)||e[0]}function C(e){typeof window<`u`&&(window.__MANTUR_COMPONENTS_TENANT_CONTEXT__=e,window.dispatchEvent(new CustomEvent(u,{detail:e})))}function w(){if(!(typeof window>`u`))return window.__MANTUR_COMPONENTS_TENANT_CONTEXT__}async function T(){return(await g(`/users/me/tenants`)).data||[]}async function E(){return(await g(`/auth/current-tenant`)).data}async function D(e){return(await g(`/auth/current-tenant/${e}`,{method:`PUT`})).data}async function O(e=`refresh`){let[t,n]=await Promise.all([T(),E()]),r={tenants:t,currentTenant:S(t,n),auth:n,reason:e};return C(r),r}async function k(e){let t=await D(e),n=await T(),r={tenants:n,currentTenant:S(n,t),auth:t,reason:`switch`};return C(r),r}var A={title:`Mantur`,switchTeam:`Switch Team`,personalSettings:`Personal Settings`,logout:`Logout`,loading:`Loading...`,owner:`Owner`,member:`Member`,createTeam:`Create Team`,createTeamComingSoon:`Create team is coming soon`,switchedToTeam:`Switched team`,error:`Request failed`,profileTitle:`Profile`,profileNickname:`Nickname`,profileNicknamePlaceholder:`Please enter nickname`,profileAvatar:`Avatar`,profileUploadAvatar:`Upload Avatar`,profileAvatarHint:`JPG/PNG/WebP, max 2MB, max 2048px.`,profileAvatarTooLarge:`Avatar must be less than 2MB`,profileAvatarDimensionExceeded:`Avatar dimensions must be within 2048px`,profileAvatarInvalidImage:`Invalid image`,profileUpdateSuccess:`Profile updated`,profileSave:`Save`,profileCancel:`Cancel`,myPoints:`My Points`,totalBalance:`Total Balance`,rechargePoints:`Recharge Points`,giftedPoints:`Gifted Points`,recharge:`Recharge`,rechargeTitle:`Recharge Points`,pointsDetail:`Points Detail`,close:`Close`,currentBalance:`Current Balance`,pointsUnit:`points`,rechargeHint:`Recharge points are valid for 2 years after arrival.`,payNow:`Pay Now`,rechargeSuccess:`Recharge successful`,all:`All`,income:`Income`,expense:`Expense`,source:`Source`,sourceAll:`All Sources`,sourceRecharge:`Recharge`,sourceGifted:`Gifted`,dateRange:`Date Range`,startDate:`Start Date`,endDate:`End Date`,dateTo:`to`,query:`Query`,refreshed:`Refreshed`,pointsDeductionTip:`Points expiring soon are deducted first.`,pointsNoteTitle:`Note`,pointsAccountNote:`Points are attached to your personal account. You recharge, consume, and manage them yourself. Others cannot recharge or use them for you. Recharge points are valid for 2 years; gifted points follow the validity set by operations.`};function j(e){return{...A,...e}}var M=`i18nextLng`,N=`manturLanguageSource`,P=`mantur-language-change`,F={"zh-CN":{title:`漫途`,switchTeam:`切换团队`,personalSettings:`个人设置`,logout:`退出登录`,loading:`加载中...`,owner:`管理员`,member:`成员`,createTeam:`创建团队`,createTeamComingSoon:`创建团队功能即将上线`,switchedToTeam:`已切换团队`,error:`请求失败`,profileTitle:`个人资料`,profileNickname:`昵称`,profileNicknamePlaceholder:`请输入昵称`,profileAvatar:`头像`,profileUploadAvatar:`上传头像`,profileAvatarHint:`支持 JPG/PNG/WebP,最大 2MB,尺寸不超过 2048px。`,profileAvatarTooLarge:`头像不能超过 2MB`,profileAvatarDimensionExceeded:`头像尺寸不能超过 2048px`,profileAvatarInvalidImage:`图片无效`,profileUpdateSuccess:`个人资料已更新`,profileSave:`保存`,profileCancel:`取消`,myPoints:`我的积分`,totalBalance:`总余额`,rechargePoints:`充值积分`,giftedPoints:`赠送积分`,recharge:`去充值`,rechargeTitle:`充值积分`,pointsDetail:`积分明细`,close:`关闭`,currentBalance:`当前余额`,pointsUnit:`积分`,rechargeHint:`充值积分有效期 2 年(自到账日起算),支付后不可退换。`,payNow:`立即支付`,rechargeSuccess:`充值成功`,all:`全部`,income:`获得`,expense:`消耗`,source:`来源`,sourceAll:`全部来源`,sourceRecharge:`充值`,sourceGifted:`赠送`,dateRange:`日期查询`,startDate:`开始日期`,endDate:`结束日期`,dateTo:`至`,query:`查询`,refreshed:`已刷新`,pointsDeductionTip:`优先扣减即将到期的积分`,pointsNoteTitle:`说明`,pointsAccountNote:`积分账户挂在你的个人账号上,自己充值、自己消耗、自己负责;他人不能代充、不能代用。充值积分有效期固定 2 年;赠送积分有效期由后台运营发放时设置。`,languageZh:`中文`,languageEn:`English`},"en-US":{...A,languageZh:`中文`,languageEn:`English`}};function I(e){return e?.toLowerCase().startsWith(`en`)?`en-US`:`zh-CN`}function L(){return typeof window>`u`?`zh-CN`:I(window.localStorage.getItem(`i18nextLng`)||document.documentElement.lang||navigator.language)}function R(e){return F[I(e)]}var z=M,B=N;function V(e,t){document.cookie=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=/`}function H(){let{i18n:e}=(0,i.useTranslation)(),[o,s]=(0,t.useState)(()=>L()),c=R(o);return(0,t.useEffect)(()=>{s(I(e.language))},[e.language]),(0,a.jsx)(n.Dropdown,{droplist:(0,a.jsxs)(n.Menu,{selectedKeys:[o],onClickMenuItem:t=>{let n=I(t);localStorage.setItem(z,t),localStorage.setItem(B,`manual`),s(n),e.changeLanguage(t),V(`Accept-Language`,t),window.dispatchEvent(new CustomEvent(P,{detail:n})),window.location.reload()},children:[(0,a.jsx)(n.Menu.Item,{children:c.languageZh},`zh-CN`),(0,a.jsx)(n.Menu.Item,{children:c.languageEn},`en-US`)]}),trigger:`click`,position:`br`,children:(0,a.jsx)(n.Button,{shape:`circle`,icon:(0,a.jsx)(r.IconLanguage,{})})})}function U(){let{resolvedTheme:e,setTheme:t}=(0,o.useTheme)();return(0,a.jsx)(n.Button,{shape:`circle`,icon:e===`light`?(0,a.jsx)(r.IconMoonFill,{}):(0,a.jsx)(r.IconSunFill,{}),onClick:()=>{t(e===`light`?`dark`:`light`)}})}var W=[{id:`points-500`,points:500,price:5},{id:`points-1000`,points:1e3,price:10},{id:`points-5500`,points:5500,price:50,recommended:!0},{id:`points-24000`,points:24e3,price:200}],G=[{id:`recharge-1`,type:`income`,source:`recharge`,name:`积分充值`,meta:`2026-05-10 14:00:00 · 订单号 R20260510140000 · 套餐 $50`,date:`2026-05-10`,amount:5500,badgeKind:`recharge`,badgeText:`充值`},{id:`gift-1`,type:`income`,source:`gift`,name:`系统赠送 · 新人礼包`,meta:`2026-05-08 09:00:00 · 有效期 30 天`,date:`2026-05-08`,amount:1e3,badgeKind:`gift`,badgeText:`赠送`},{id:`expense-1`,type:`expense`,name:`视频生成 — Sora 40秒 4K`,meta:`2026-05-10 16:45:22 · 制作中心`,date:`2026-05-10`,amount:-400,badgeKind:`deducted`,badgeText:`已扣除`},{id:`expense-2`,type:`expense`,name:`视频生成 — Sora 25秒 1080p`,meta:`2026-05-11 09:15:42 · 制作中心`,date:`2026-05-11`,amount:-250,badgeKind:`deducted`,badgeText:`已扣除`},{id:`expire-1`,type:`expense`,name:`积分过期`,meta:`2026-05-01 00:00:00 · 2026-04 批次到期未使用`,date:`2026-05-01`,amount:-100,badgeKind:`expired`,badgeText:`自然过期`},{id:`expense-3`,type:`expense`,name:`AI 对话 — GPT-4o 5轮`,meta:`2026-05-07 10:08:55 · 剧本中心`,date:`2026-05-07`,amount:-10,badgeKind:`deducted`,badgeText:`已扣除`},{id:`expense-4`,type:`expense`,name:`图片生成 — DALL-E 5张`,meta:`2026-05-04 14:20:11 · 制作中心`,date:`2026-05-04`,amount:-75,badgeKind:`deducted`,badgeText:`已扣除`}],{RangePicker:K}=n.DatePicker,q=21,J=7;function Y(e){return e===`recharge`?`arcoblue`:e===`gift`?`cyan`:e===`expired`?`gray`:`orange`}function ee({visible:e,points:i,text:o,onCancel:s,onRecharge:c}){let[l,u]=(0,t.useState)(`all`),[d,f]=(0,t.useState)(`all`),[p,m]=(0,t.useState)([`2026-04-15`,`2026-05-15`]),[h,g]=(0,t.useState)(1),_=e=>new Intl.NumberFormat().format(e),v=(0,t.useMemo)(()=>{let[e,t]=p;return G.filter(n=>{let r=l===`all`||n.type===l,i=d===`all`||n.source===d,a=!e||n.date>=e,o=!t||n.date<=t;return r&&i&&a&&o})},[p,d,l]),y=[{title:o.pointsDetail,dataIndex:`name`,render:(e,t)=>(0,a.jsxs)(`div`,{className:`min-w-0`,children:[(0,a.jsx)(n.Typography.Text,{className:`font-medium!`,children:t.name}),(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`mt-1 block! text-xs!`,children:t.meta})]})},{title:o.pointsUnit,dataIndex:`amount`,width:120,align:`right`,render:(e,t)=>(0,a.jsxs)(n.Typography.Text,{className:`font-semibold! ${t.amount>0?`text-arco-success-6!`:`text-arco-danger-6!`}`,children:[t.amount>0?`+`:``,_(t.amount)]})},{title:o.source,dataIndex:`badgeText`,width:110,align:`right`,render:(e,t)=>(0,a.jsx)(n.Tag,{color:Y(t.badgeKind),children:t.badgeText})}];return(0,a.jsx)(n.Modal,{title:o.pointsDetail,visible:e,footer:(0,a.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,a.jsx)(n.Button,{onClick:s,children:o.close}),(0,a.jsx)(n.Button,{type:`primary`,icon:(0,a.jsx)(r.IconPlus,{}),onClick:()=>{s(),c()},children:o.recharge})]}),onCancel:s,style:{width:780,maxWidth:`calc(100vw - 48px)`},children:(0,a.jsxs)(`div`,{className:`max-h-[70vh] overflow-y-auto`,children:[(0,a.jsxs)(n.Card,{bordered:!1,className:`from-arco-primary-light-1/40 to-cyan-400/5 rounded-none! bg-linear-to-br!`,children:[(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`text-xs!`,children:o.totalBalance}),(0,a.jsxs)(`div`,{className:`mt-1.5 mb-3.5 `,children:[(0,a.jsx)(n.Typography.Text,{className:`text-3xl! font-bold!`,children:_(i.total)}),(0,a.jsxs)(n.Typography.Text,{type:`secondary`,className:`ml-2 text-sm! `,children:[`🪙 `,o.pointsUnit]})]}),(0,a.jsxs)(n.Grid.Row,{gutter:12,children:[(0,a.jsx)(n.Grid.Col,{span:12,children:(0,a.jsxs)(n.Card,{size:`small`,children:[(0,a.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`text-xs!`,children:o.rechargePoints}),(0,a.jsx)(n.Tag,{color:`arcoblue`,children:o.sourceRecharge})]}),(0,a.jsx)(n.Typography.Text,{className:`text-lg! font-semibold!`,children:_(i.recharge)})]})}),(0,a.jsx)(n.Grid.Col,{span:12,children:(0,a.jsxs)(n.Card,{size:`small`,children:[(0,a.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`text-xs!`,children:o.giftedPoints}),(0,a.jsx)(n.Tag,{color:`success`,children:o.sourceGifted})]}),(0,a.jsx)(n.Typography.Text,{className:`text-lg! font-semibold!`,children:_(i.gifted)})]})})]}),(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`mt-2.5 block! text-xs!`,children:o.pointsDeductionTip})]}),(0,a.jsxs)(`div`,{className:`px-6 py-4`,children:[(0,a.jsxs)(n.Tabs,{activeTab:l,onChange:e=>u(e),children:[(0,a.jsx)(n.Tabs.TabPane,{title:o.all},`all`),(0,a.jsx)(n.Tabs.TabPane,{title:o.income},`income`),(0,a.jsx)(n.Tabs.TabPane,{title:o.expense},`expense`)]}),(0,a.jsxs)(`div`,{className:`mt-2 mb-3.5 flex flex-wrap items-center gap-2.5`,children:[(0,a.jsxs)(n.Select,{value:d,style:{width:140},onChange:e=>f(e),children:[(0,a.jsx)(n.Select.Option,{value:`all`,children:o.sourceAll}),(0,a.jsx)(n.Select.Option,{value:`recharge`,children:o.sourceRecharge}),(0,a.jsx)(n.Select.Option,{value:`gift`,children:o.sourceGifted})]}),(0,a.jsx)(K,{value:p,onChange:e=>m(e),style:{width:260}}),(0,a.jsx)(n.Button,{onClick:()=>n.Message.success(o.refreshed),children:o.query})]}),(0,a.jsx)(n.Table,{rowKey:`id`,columns:y,data:v,pagination:!1,border:!1}),(0,a.jsx)(n.Pagination,{className:`mt-3 flex justify-center!`,current:h,pageSize:J,total:q,onChange:g})]}),(0,a.jsx)(n.Card,{bordered:!1,className:`bg-arco-primary-light-1/30 rounded-none!`,children:(0,a.jsxs)(n.Typography.Text,{type:`secondary`,className:`text-xs! leading-6!`,children:[(0,a.jsxs)(`strong`,{children:[o.pointsNoteTitle,`:`]}),o.pointsAccountNote]})})]})})}var X=2048,te=2*1024*1024;function ne(e){return new Promise((t,n)=>{let r=URL.createObjectURL(e),i=new Image;i.onload=()=>{URL.revokeObjectURL(r),t({width:i.naturalWidth,height:i.naturalHeight})},i.onerror=()=>{URL.revokeObjectURL(r),n(Error(`invalid image`))},i.src=r})}function re({visible:e,user:i,labels:o,onCancel:s,onSubmit:c}){let l=j(o),[u]=n.Form.useForm(),[d,f]=(0,t.useState)(!1),[p,m]=(0,t.useState)(null),[h,g]=(0,t.useState)(null),_=(0,t.useRef)(null);(0,t.useEffect)(()=>()=>{_.current&&=(URL.revokeObjectURL(_.current),null)},[]),(0,t.useEffect)(()=>{e&&(u.setFieldsValue({nickname:i?.nickname||i?.username||``}),m(null),g(e=>(e&&URL.revokeObjectURL(e),_.current=null,null)))},[e,i,u]);let v=(e,t)=>{console.error(t),n.Message.error(e)},y=e=>{n.Message.success(e)};return(0,a.jsx)(n.Modal,{title:l.profileTitle,visible:e,onOk:async()=>{try{let e=await u.validate();f(!0),await c({nickname:e.nickname,avatarFile:p}),y(l.profileUpdateSuccess),s()}catch(e){e instanceof Error&&v(e.message||l.error,e)}finally{f(!1)}},onCancel:s,confirmLoading:d,okText:l.profileSave,cancelText:l.profileCancel,children:(0,a.jsxs)(n.Form,{form:u,layout:`vertical`,children:[(0,a.jsx)(n.Form.Item,{label:l.profileNickname,field:`nickname`,rules:[{required:!0,message:l.profileNicknamePlaceholder}],children:(0,a.jsx)(n.Input,{placeholder:l.profileNicknamePlaceholder,allowClear:!0})}),(0,a.jsx)(n.Form.Item,{label:l.profileAvatar,children:(0,a.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,a.jsx)(n.Avatar,{size:64,className:`shrink-0 bg-arco-primary-light-1!`,children:h||i?.avatar?(0,a.jsx)(`img`,{src:h||i?.avatar,alt:``,className:`block h-full w-full object-cover`}):i?.nickname?.[0]||i?.username?.[0]||`U`}),(0,a.jsx)(n.Upload,{accept:`image/*`,showUploadList:!1,beforeUpload:async e=>{if(e.size>te)return v(l.profileAvatarTooLarge),!1;try{let{width:t,height:n}=await ne(e);if(t>X||n>X)return v(l.profileAvatarDimensionExceeded),!1}catch(e){return v(l.profileAvatarInvalidImage,e),!1}return g(t=>{t&&URL.revokeObjectURL(t);let n=URL.createObjectURL(e);return _.current=n,n}),m(e),!1},children:(0,a.jsx)(n.Button,{type:`outline`,size:`small`,icon:(0,a.jsx)(r.IconUpload,{}),children:l.profileUploadAvatar})})]}),(0,a.jsx)(`span`,{className:`text-xs text-arco-text-3`,children:l.profileAvatarHint})]})})]})})}function ie(e){return e?.nickname?.[0]||e?.username?.[0]||`U`}function Z({user:e,size:t,className:r=``}){return(0,a.jsx)(n.Avatar,{size:t,className:`bg-arco-primary/20! text-arco-primary-6 border-2 font-bold ${r}`,children:e?.avatar?(0,a.jsx)(`img`,{src:e.avatar,alt:`avatar`,className:`h-full w-full object-cover`}):ie(e)})}function ae({visible:e,user:i,points:o,text:s,onCancel:c,onPay:l}){let[u,d]=(0,t.useState)(W[2].id),f=e=>new Intl.NumberFormat().format(e),p=W.find(e=>e.id===u)||W[0];return(0,a.jsx)(n.Modal,{title:s.rechargeTitle,visible:e,footer:(0,a.jsxs)(`div`,{className:`mx-auto flex max-w-7xl items-center justify-between gap-5`,children:[(0,a.jsx)(`span`,{className:`text-arco-text-2 text-sm leading-6`,children:s.rechargeHint}),(0,a.jsxs)(n.Button,{type:`primary`,size:`large`,className:`min-w-48! font-bold!`,onClick:()=>l(p),children:[s.payNow,` · $`,p.price]})]}),onCancel:c,alignCenter:!1,wrapClassName:`overflow-hidden!`,style:{width:`100vw`,maxWidth:`100vw`,top:0,paddingBottom:0},className:`top-0! m-0! flex! h-screen! w-screen! max-w-none! flex-col! [&_.arco-modal-body]:min-h-0! [&_.arco-modal-body]:flex-1! [&_.arco-modal-body]:overflow-hidden! [&_.arco-modal-body]:p-0! [&_.arco-modal-close-icon]:top-1.5! [&_.arco-modal-close-icon]:right-4! [&_.arco-modal-close-icon]:inline-flex! [&_.arco-modal-close-icon]:h-9! [&_.arco-modal-close-icon]:w-9! [&_.arco-modal-close-icon]:items-center! [&_.arco-modal-close-icon]:justify-center! [&_.arco-modal-close-icon]:rounded-lg! [&_.arco-modal-close-icon]:text-lg! [&_.arco-modal-close-icon]:leading-9! [&_.arco-modal-close-icon]:transition-colors [&_.arco-modal-close-icon:hover]:bg-arco-fill-2 [&_.arco-modal-close-icon:hover]:text-arco-primary-6 [&_.arco-modal-close-icon_svg]:h-[18px]! [&_.arco-modal-close-icon_svg]:w-[18px]! [&_.arco-modal-content]:flex! [&_.arco-modal-content]:h-auto! [&_.arco-modal-content]:min-h-0! [&_.arco-modal-content]:flex-1! [&_.arco-modal-content]:flex-col! [&_.arco-modal-content]:overflow-hidden! [&_.arco-modal-content]:rounded-none! [&_.arco-modal-footer]:shrink-0! [&_.arco-modal-header]:shrink-0!`,children:(0,a.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-7xl flex-col items-center `,children:[(0,a.jsxs)(`div`,{className:`w-full border-arco-border-1 bg-arco-fill-1 text-arco-text-2 flex items-center gap-2.5 rounded-lg border px-3.5 py-3 text-sm`,children:[(0,a.jsx)(Z,{user:i,size:32,className:`shrink-0`}),(0,a.jsxs)(`span`,{children:[i?.nickname||i?.username,` · `,s.currentBalance,` `,(0,a.jsx)(`strong`,{className:`text-arco-text-1`,children:f(o.total)}),` `,s.pointsUnit]})]}),(0,a.jsx)(`div`,{className:`mt-6 w-full`,children:(0,a.jsx)(n.Grid.Row,{gutter:[16,16],children:W.map(e=>(0,a.jsx)(n.Grid.Col,{xs:24,sm:12,lg:6,children:(0,a.jsxs)(n.Card,{hoverable:!0,role:`button`,tabIndex:0,onClick:()=>d(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&d(e.id)},bodyStyle:{minHeight:192,display:`flex`,flexDirection:`column`,justifyContent:`space-between`},className:`border-arco-border-2! bg-arco-bg-2! relative cursor-pointer overflow-hidden rounded-lg! shadow-sm! transition-all duration-200 before:absolute before:inset-x-0 before:top-0 before:h-1 before:bg-linear-to-r before:from-arco-primary before:to-transparent hover:shadow-md! ${u===e.id?`border-arco-primary-6! bg-arco-primary-light-1/40! ring-arco-primary-6/20 ring-2! shadow-[0_18px_38px_rgb(var(--primary-6)/22%)]!`:`hover:border-arco-primary-6!`}`,children:[u===e.id?(0,a.jsx)(r.IconCheckCircleFill,{className:`text-arco-primary-6! absolute bottom-4 left-4 text-xl`}):null,`recommended`in e&&e.recommended?(0,a.jsx)(n.Tag,{color:`arcoblue`,className:`absolute top-4 right-4 text-xs! font-bold!`,children:`HOT`}):null,(0,a.jsxs)(`div`,{className:`min-w-0 pr-16`,children:[(0,a.jsxs)(n.Typography.Text,{className:`flex items-center text-3xl! leading-tight! font-bold!`,children:[f(e.points),(0,a.jsx)(`span`,{className:`ml-1 text-2xl`,children:`🪙`})]}),(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`mt-1 block! text-sm!`,children:s.pointsUnit})]}),(0,a.jsx)(`div`,{className:`mt-7 flex w-full justify-end`,children:(0,a.jsxs)(n.Typography.Text,{className:`text-arco-primary-6! text-right text-2xl! leading-tight! font-bold!`,children:[`$`,e.price]})})]})},e.id))})})]})})}function oe({user:e,points:t,text:i,onEditProfile:o,onRecharge:s,onPointsDetail:c,onLogout:l}){let u=e=>new Intl.NumberFormat().format(e);return(0,a.jsxs)(`div`,{className:`w-80 overflow-hidden rounded-xl border border-arco-border-2 bg-arco-bg-popup shadow-[0_10px_28px_rgb(0_0_0/12%)]`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-3 px-6 pt-5 pb-4`,children:[(0,a.jsx)(Z,{user:e,size:48,className:`shrink-0`}),(0,a.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`text-arco-text-1 truncate text-base leading-6 font-bold`,children:e?.nickname||e?.username}),(0,a.jsx)(n.Button,{type:`text`,size:`mini`,icon:(0,a.jsx)(r.IconEdit,{}),className:`text-arco-text-3 h-6! min-w-6! px-0!`,onClick:o})]}),e?.email?(0,a.jsx)(`span`,{className:`text-arco-text-3 truncate text-xs leading-5`,children:e.email}):null]})]}),(0,a.jsx)(n.Divider,{className:`m-0!`}),(0,a.jsxs)(`ul`,{className:`flex flex-col gap-3.5 px-6 py-4`,children:[(0,a.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,a.jsx)(`span`,{children:i.myPoints}),(0,a.jsx)(`strong`,{className:`text-arco-primary-6 text-base font-bold`,children:u(t.total)})]}),(0,a.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,a.jsx)(`span`,{children:i.rechargePoints}),(0,a.jsx)(`strong`,{className:`text-arco-text-1 text-base font-bold`,children:u(t.recharge)})]}),(0,a.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,a.jsx)(`span`,{children:i.giftedPoints}),(0,a.jsx)(`strong`,{className:`text-arco-text-1 text-base font-bold`,children:u(t.gifted)})]})]}),(0,a.jsx)(n.Divider,{className:`m-0!`}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-2 px-6 py-4`,children:[(0,a.jsx)(n.Button,{type:`primary`,long:!0,icon:(0,a.jsx)(r.IconPlus,{}),className:`h-10! rounded-md! font-semibold!`,onClick:s,children:i.recharge}),(0,a.jsx)(n.Button,{long:!0,icon:(0,a.jsx)(r.IconFile,{}),className:`border-arco-border-2! bg-arco-fill-1! text-arco-text-1! h-10! rounded-md! font-semibold!`,onClick:c,children:i.pointsDetail})]}),(0,a.jsx)(n.Divider,{className:`m-0!`}),(0,a.jsx)(`div`,{className:`px-6 py-4`,children:(0,a.jsx)(n.Button,{icon:(0,a.jsx)(r.IconPoweroff,{}),type:`text`,status:`danger`,long:!0,className:`flex! items-center justify-start gap-2 text-sm text-arco-text-2`,onClick:()=>void l?.(),children:i.logout})})]})}var se=`https://mantur.ai/images/logo.png`,Q=[`from-arco-primary-light-1 to-arco-primary-light-2 text-arco-primary-6`,`from-arco-success-light-1 to-arco-success-light-2 text-arco-success-6`,`from-arco-warning-light-1 to-arco-warning-light-2 text-arco-warning-6`,`from-arco-danger-light-1 to-arco-danger-light-2 text-arco-danger-6`];function $(e,t=!1){return`flex h-8 min-h-8 w-8 min-w-8 flex-none items-center justify-center rounded-lg bg-linear-to-br font-bold leading-none ${Q[e%Q.length]} ${t?`shadow-[inset_0_1px_3px_rgb(0_0_0/8%)]`:``}`}function ce(e){return e?.tenantName?.[0]?.toUpperCase()||`T`}function le(e,t,n){let r=e?.roles?.map(e=>e.roleName).filter(Boolean);return r?.length?r.join(`, `):e?.isOwner?t:n}function ue({user:e,disabled:i=!1,brandSlot:o,children:s}){let[c,d]=(0,t.useState)(()=>L()),f=R(c),[p,m]=(0,t.useState)(!1),[h,g]=(0,t.useState)(!1),[y,b]=(0,t.useState)(!1),[S,C]=(0,t.useState)(e),[w,T]=(0,t.useState)([]),[E,D]=(0,t.useState)(),[A,j]=(0,t.useState)(!1),[M,N]=(0,t.useState)({total:0,recharge:0,gifted:0}),F=E?.tenantId||``,z=i,B={total:M.total??0,recharge:M.recharge??0,gifted:M.gifted??0},V=async e=>{let t=await v(e);return t&&C(t),t};(0,t.useEffect)(()=>{C(e)},[e]),(0,t.useEffect)(()=>{let e=e=>{T(e.tenants),D(e.currentTenant)},t=t=>{t instanceof CustomEvent&&e(t.detail)};return window.addEventListener(u,t),j(!0),O().then(e).catch(e=>{console.warn(`Failed to refresh Mantur tenant context.`,e),n.Message.error(f.error)}).finally(()=>j(!1)),()=>{window.removeEventListener(u,t)}},[f.error]),(0,t.useEffect)(()=>{let e=e=>{e instanceof CustomEvent&&N(e.detail)};return window.addEventListener(l,e),x().catch(e=>{console.warn(`Failed to refresh Mantur user points.`,e)}),()=>{window.removeEventListener(l,e)}},[]),(0,t.useEffect)(()=>{let e=e=>{d(e instanceof CustomEvent?I(e.detail):L())};return window.addEventListener(P,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(P,e),window.removeEventListener(`storage`,e)}},[]);let W=e=>{n.Message.success(e)},G=(e,t)=>{console.error(t),n.Message.error(e)},K=(0,t.useCallback)(async e=>{if(!z&&e!==F)try{j(!0);let t=await k(e);T(t.tenants),D(t.currentTenant),W(f.switchedToTeam)}catch(e){G(f.error,e)}finally{j(!1)}},[F,z,f.error,f.switchedToTeam]),q=e=>{let t={total:B.total+e.points,recharge:B.recharge+e.points,gifted:B.gifted};N(t),window.dispatchEvent(new CustomEvent(l,{detail:t})),n.Message.success(f.rechargeSuccess),g(!1)},J=(0,t.useMemo)(()=>(0,a.jsxs)(n.Menu,{className:`w-56 rounded-xl bg-arco-bg-popup shadow-[0_10px_28px_rgb(0_0_0/12%)] [&_.arco-menu-inner]:px-2 [&_.arco-menu-inner]:py-1`,selectedKeys:F?[F]:[],onClickMenuItem:K,children:[(0,a.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold tracking-[0.04em] text-arco-text-4 uppercase`,children:f.switchTeam}),w.map((e,t)=>(0,a.jsx)(n.Menu.Item,{className:`mb-1 h-auto! min-h-10! overflow-visible! rounded-lg! px-2! py-1! leading-normal!`,children:(0,a.jsxs)(`div`,{className:`flex w-full items-center gap-3 leading-normal`,children:[(0,a.jsx)(`div`,{className:$(t),children:ce(e)}),(0,a.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center gap-0.75`,children:[(0,a.jsx)(`span`,{className:`text-sm leading-5 font-medium text-arco-text-1`,children:e.tenantName}),(0,a.jsx)(`span`,{className:`text-xs leading-4 text-arco-text-3`,children:le(e,f.owner,f.member)})]})]})},e.tenantId))]}),[K,F,w,f]),Y=(0,a.jsx)(oe,{user:S,points:B,text:f,onEditProfile:()=>m(!0),onRecharge:()=>g(!0),onPointsDetail:()=>b(!0),onLogout:_}),X=Math.max(0,w.findIndex(e=>e.tenantId===E?.tenantId));return(0,a.jsxs)(`div`,{className:`flex h-20 items-center justify-between bg-transparent pr-8 shadow-[0_2px_10px_rgb(0_0_0/2%)] backdrop-blur-md max-md:pr-4`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,a.jsxs)(`div`,{className:`flex w-65 items-center gap-3 px-8 max-md:w-auto max-md:px-4`,children:[(0,a.jsx)(`div`,{className:`relative flex w-12 items-center justify-center overflow-hidden `,children:(0,a.jsx)(`img`,{src:se,alt:`logo`,className:`w-full object-contain`,onError:e=>{e.currentTarget.style.display=`none`}})}),o??(0,a.jsx)(`span`,{className:`text-lg font-bold tracking-normal text-arco-text-1`,children:f.title})]}),(0,a.jsx)(n.Dropdown,{droplist:J,trigger:`click`,position:`bl`,disabled:z,children:(0,a.jsxs)(`div`,{"aria-disabled":z,className:`flex items-center gap-3 rounded-full border border-arco-border-1 bg-arco-bg-1 px-2 py-1.5 transition-all ${z?`cursor-not-allowed opacity-60`:`cursor-pointer hover:bg-arco-fill-2 hover:shadow-[0_4px_12px_rgb(0_0_0/8%)]`}`,children:[(0,a.jsx)(`div`,{className:$(X,!0),children:ce(E)}),(0,a.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,a.jsx)(`span`,{className:`text-xs leading-none font-bold text-arco-text-1`,children:A?f.loading:E?.tenantName||f.loading}),(0,a.jsx)(`span`,{className:`mt-1 text-[10px] leading-none text-arco-text-3`,children:le(E,f.owner,f.member)})]}),(0,a.jsx)(r.IconDown,{className:`ml-1 text-arco-text-3`})]})})]}),(0,a.jsx)(`div`,{className:`flex-1`,children:s}),(0,a.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,a.jsx)(U,{}),(0,a.jsx)(H,{})]}),(0,a.jsx)(n.Dropdown,{droplist:Y,trigger:`click`,position:`br`,onVisibleChange:e=>{e&&x().catch(e=>{console.warn(`Failed to refresh Mantur user points.`,e)})},children:(0,a.jsxs)(`div`,{className:`hover:bg-arco-fill-2 flex cursor-pointer items-center gap-2.5 rounded-full border border-transparent p-1 pr-2 transition-all`,children:[(0,a.jsxs)(`div`,{className:`from-arco-primary to-transparent relative rounded-full bg-linear-to-br p-0.5 shadow-sm`,children:[(0,a.jsx)(Z,{user:S,size:36}),(0,a.jsx)(`div`,{className:`bg-arco-success border-arco-bg-white absolute right-0 bottom-0 h-3 w-3 rounded-full border-2 shadow-sm`})]}),(0,a.jsx)(`div`,{className:`hidden flex-col md:flex`,children:(0,a.jsx)(`span`,{className:`text-arco-text-1 text-sm font-medium`,children:S?.nickname||S?.username})}),(0,a.jsx)(r.IconDown,{className:`text-arco-text-3 ml-1`})]})})]}),(0,a.jsx)(re,{visible:p,user:S,labels:f,onCancel:()=>m(!1),onSubmit:V}),(0,a.jsx)(ae,{visible:h,user:S,points:B,text:f,onCancel:()=>g(!1),onPay:q}),(0,a.jsx)(ee,{visible:y,points:B,text:f,onCancel:()=>b(!1),onRecharge:()=>g(!0)})]})}e.LANGUAGE_SOURCE_STORAGE_KEY=B,e.LANGUAGE_STORAGE_KEY=z,e.LangSwitch=H,e.MANTUR_LANGUAGE_CHANGE_EVENT=P,e.MANTUR_LANGUAGE_SOURCE_STORAGE_KEY=N,e.MANTUR_LANGUAGE_STORAGE_KEY=M,e.MANTUR_MESSAGES=F,e.MANTUR_POINTS_REFRESH_EVENT=l,e.MANTUR_TENANT_CONTEXT_CHANGE_EVENT=u,e.ManturHeader=ue,e.ThemeSwitch=U,e.getManturCurrentTenant=E,e.getManturMessages=R,e.getManturTenantContextSnapshot=w,e.getManturTenants=T,e.getManturUserPoints=b,e.getStoredManturLocale=L,e.normalizeManturLocale=I,e.refreshManturTenantContext=O,e.refreshManturUserPoints=x,e.switchAndRefreshManturTenant=k,e.switchManturTenant=D});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`@arco-design/web-react`),require(`@arco-design/web-react/icon`),require(`react-i18next`),require(`react/jsx-runtime`),require(`next-themes`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`@arco-design/web-react`,`@arco-design/web-react/icon`,`react-i18next`,`react/jsx-runtime`,`next-themes`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ManturComponents={},e.React,e.ArcoDesign,e.ArcoDesignIcon,e.ReactI18next,e.jsxRuntime,e.nextThemes))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=`/api`,c=`/users/me/points`,l=`mantur-points-refresh`,u=`mantur-tenant-context-change`;function d(){return typeof window<`u`&&window.__MANTUR_COMPONENTS_API_BASE__?window.__MANTUR_COMPONENTS_API_BASE__:s}function f(){return typeof window<`u`&&window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__?window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__:c}function p(e){if(typeof document>`u`)return;let t=`${encodeURIComponent(e)}=`;return document.cookie.split(`; `).find(e=>e.startsWith(t))?.slice(t.length)}function m(e){if(typeof document>`u`)return;let t=encodeURIComponent(e),n=window.location.hostname,r=[void 0,n],i=n.split(`.`);i.length>=2&&r.push(`.${i.slice(-2).join(`.`)}`),r.forEach(e=>{document.cookie=`${t}=; path=/; max-age=0${e?`; domain=${e}`:``}`})}function h(e){let t=JSON.parse(e||`null`);if(!t)throw Error(`Request failed`);if(t.code!==0)throw Error(t.message||`Request failed`);return t}async function g(e,t={}){let n=p(`front-token`),r=p(`Accept-Language`),i=t.headers||{};return n&&(i.Authorization=decodeURIComponent(n)),r&&(i[`Accept-Language`]=decodeURIComponent(r)),new Promise((n,r)=>{let a=new XMLHttpRequest;a.open(t.method||`GET`,`${d()}${e}`,!0),a.timeout=t.timeout||1e4,Object.entries(i).forEach(([e,t])=>{a.setRequestHeader(e,t)}),a.onload=()=>{try{let e=h(a.responseText);if(a.status<200||a.status>=300){r(Error(e.message||a.statusText));return}n(e)}catch(e){r(e)}},a.onerror=()=>r(Error(`Network request failed`)),a.ontimeout=()=>r(Error(`Network request timed out`)),a.send(t.body??null)})}async function _(){try{await g(`/auth/front-logout`,{method:`DELETE`})}catch(e){console.warn(`Logout request failed, continuing local logout.`,e)}finally{m(`front-token`),m(`refreshToken`),typeof window<`u`&&window.location.reload()}}async function v(e){let t;if(e.avatarFile){let n=new FormData;n.append(`file`,e.avatarFile),t=(await g(`/users/me/avatar`,{method:`POST`,body:n})).data}return(await g(`/users/me`,{method:`PUT`,headers:{"Content-Type":`application/json;charset=utf-8`},body:JSON.stringify({nickname:e.nickname})})).data||t}function y(e){let t=(...t)=>{let n=t.map(t=>e?.[t]).find(e=>e!==void 0);return typeof n==`number`?n:Number(n||0)};return{total:t(`total`,`totalPoints`,`balance`,`points`),recharge:t(`recharge`,`rechargePoints`,`paidPoints`),gifted:t(`gifted`,`giftedPoints`,`bonusPoints`)}}async function b(){return y((await g(f())).data)}async function x(){let e=await b();return typeof window<`u`&&window.dispatchEvent(new CustomEvent(l,{detail:e})),e}function S(e,t){return t?.tenantId?e.find(e=>e.tenantId===t.tenantId)||{tenantId:t.tenantId,tenantName:t.tenantName||t.tenantId,roles:t.roles?.map(e=>({roleCode:e,roleName:e}))}:e.find(e=>e.isOwner)||e[0]}function C(e){typeof window<`u`&&(window.__MANTUR_COMPONENTS_TENANT_CONTEXT__=e,window.dispatchEvent(new CustomEvent(u,{detail:e})))}function w(){if(!(typeof window>`u`))return window.__MANTUR_COMPONENTS_TENANT_CONTEXT__}async function T(){return(await g(`/users/me/tenants`)).data||[]}async function E(){return(await g(`/auth/current-tenant`)).data}async function D(e){return(await g(`/auth/current-tenant/${e}`,{method:`PUT`})).data}async function O(e=`refresh`){let[t,n]=await Promise.all([T(),E()]),r={tenants:t,currentTenant:S(t,n),auth:n,reason:e};return C(r),r}async function k(e){let t=await D(e),n=await T(),r={tenants:n,currentTenant:S(n,t),auth:t,reason:`switch`};return C(r),r}var A={title:`Mantur`,switchTeam:`Switch Team`,personalSettings:`Personal Settings`,logout:`Logout`,loading:`Loading...`,owner:`Owner`,member:`Member`,createTeam:`Create Team`,createTeamComingSoon:`Create team is coming soon`,switchedToTeam:`Switched team`,error:`Request failed`,profileTitle:`Profile`,profileNickname:`Nickname`,profileNicknamePlaceholder:`Please enter nickname`,profileAvatar:`Avatar`,profileUploadAvatar:`Upload Avatar`,profileAvatarHint:`JPG/PNG/WebP, max 2MB, max 2048px.`,profileAvatarTooLarge:`Avatar must be less than 2MB`,profileAvatarDimensionExceeded:`Avatar dimensions must be within 2048px`,profileAvatarInvalidImage:`Invalid image`,profileUpdateSuccess:`Profile updated`,profileSave:`Save`,profileCancel:`Cancel`,myPoints:`My Points`,totalBalance:`Total Balance`,rechargePoints:`Recharge Points`,giftedPoints:`Gifted Points`,recharge:`Recharge`,rechargeTitle:`Recharge Points`,pointsDetail:`Points Detail`,close:`Close`,currentBalance:`Current Balance`,pointsUnit:`points`,rechargeHint:`Recharge points are valid for 2 years after arrival.`,payNow:`Pay Now`,rechargeSuccess:`Recharge successful`,all:`All`,income:`Income`,expense:`Expense`,source:`Source`,sourceAll:`All Sources`,sourceRecharge:`Recharge`,sourceGifted:`Gifted`,dateRange:`Date Range`,startDate:`Start Date`,endDate:`End Date`,dateTo:`to`,query:`Query`,refreshed:`Refreshed`,pointsDeductionTip:`Points expiring soon are deducted first.`,pointsNoteTitle:`Note`,pointsAccountNote:`Points are attached to your personal account. You recharge, consume, and manage them yourself. Others cannot recharge or use them for you. Recharge points are valid for 2 years; gifted points follow the validity set by operations.`};function j(e){return{...A,...e}}var M=`i18nextLng`,N=`manturLanguageSource`,P=`mantur-language-change`,F={"zh-CN":{title:`漫途`,switchTeam:`切换团队`,personalSettings:`个人设置`,logout:`退出登录`,loading:`加载中...`,owner:`管理员`,member:`成员`,createTeam:`创建团队`,createTeamComingSoon:`创建团队功能即将上线`,switchedToTeam:`已切换团队`,error:`请求失败`,profileTitle:`个人资料`,profileNickname:`昵称`,profileNicknamePlaceholder:`请输入昵称`,profileAvatar:`头像`,profileUploadAvatar:`上传头像`,profileAvatarHint:`支持 JPG/PNG/WebP,最大 2MB,尺寸不超过 2048px。`,profileAvatarTooLarge:`头像不能超过 2MB`,profileAvatarDimensionExceeded:`头像尺寸不能超过 2048px`,profileAvatarInvalidImage:`图片无效`,profileUpdateSuccess:`个人资料已更新`,profileSave:`保存`,profileCancel:`取消`,myPoints:`我的积分`,totalBalance:`总余额`,rechargePoints:`充值积分`,giftedPoints:`赠送积分`,recharge:`去充值`,rechargeTitle:`充值积分`,pointsDetail:`积分明细`,close:`关闭`,currentBalance:`当前余额`,pointsUnit:`积分`,rechargeHint:`充值积分有效期 2 年(自到账日起算),支付后不可退换。`,payNow:`立即支付`,rechargeSuccess:`充值成功`,all:`全部`,income:`获得`,expense:`消耗`,source:`来源`,sourceAll:`全部来源`,sourceRecharge:`充值`,sourceGifted:`赠送`,dateRange:`日期查询`,startDate:`开始日期`,endDate:`结束日期`,dateTo:`至`,query:`查询`,refreshed:`已刷新`,pointsDeductionTip:`优先扣减即将到期的积分`,pointsNoteTitle:`说明`,pointsAccountNote:`积分账户挂在你的个人账号上,自己充值、自己消耗、自己负责;他人不能代充、不能代用。充值积分有效期固定 2 年;赠送积分有效期由后台运营发放时设置。`,languageZh:`中文`,languageEn:`English`},"en-US":{...A,languageZh:`中文`,languageEn:`English`}};function I(e){return e?.toLowerCase().startsWith(`en`)?`en-US`:`zh-CN`}function L(){return typeof window>`u`?`zh-CN`:I(window.localStorage.getItem(`i18nextLng`)||document.documentElement.lang||navigator.language)}function R(e){return F[I(e)]}var z=M,B=N;function V(e,t){document.cookie=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=/`}function H(){let{i18n:e}=(0,i.useTranslation)(),[o,s]=(0,t.useState)(()=>L()),c=R(o);return(0,t.useEffect)(()=>{s(I(e.language))},[e.language]),(0,a.jsx)(n.Dropdown,{droplist:(0,a.jsxs)(n.Menu,{selectedKeys:[o],onClickMenuItem:t=>{let n=I(t);localStorage.setItem(z,t),localStorage.setItem(B,`manual`),s(n),e.changeLanguage(t),V(`Accept-Language`,t),window.dispatchEvent(new CustomEvent(P,{detail:n})),window.location.reload()},children:[(0,a.jsx)(n.Menu.Item,{children:c.languageZh},`zh-CN`),(0,a.jsx)(n.Menu.Item,{children:c.languageEn},`en-US`)]}),trigger:`click`,position:`br`,children:(0,a.jsx)(n.Button,{shape:`circle`,icon:(0,a.jsx)(r.IconLanguage,{})})})}function U(){let{resolvedTheme:e,setTheme:t}=(0,o.useTheme)();return(0,a.jsx)(n.Button,{shape:`circle`,icon:e===`light`?(0,a.jsx)(r.IconMoonFill,{}):(0,a.jsx)(r.IconSunFill,{}),onClick:()=>{t(e===`light`?`dark`:`light`)}})}var W=[{id:`points-500`,points:500,price:5},{id:`points-1000`,points:1e3,price:10},{id:`points-5500`,points:5500,price:50,recommended:!0},{id:`points-24000`,points:24e3,price:200}],G=[{id:`recharge-1`,type:`income`,source:`recharge`,name:`积分充值`,meta:`2026-05-10 14:00:00 · 订单号 R20260510140000 · 套餐 $50`,date:`2026-05-10`,amount:5500,badgeKind:`recharge`,badgeText:`充值`},{id:`gift-1`,type:`income`,source:`gift`,name:`系统赠送 · 新人礼包`,meta:`2026-05-08 09:00:00 · 有效期 30 天`,date:`2026-05-08`,amount:1e3,badgeKind:`gift`,badgeText:`赠送`},{id:`expense-1`,type:`expense`,name:`视频生成 — Sora 40秒 4K`,meta:`2026-05-10 16:45:22 · 制作中心`,date:`2026-05-10`,amount:-400,badgeKind:`deducted`,badgeText:`已扣除`},{id:`expense-2`,type:`expense`,name:`视频生成 — Sora 25秒 1080p`,meta:`2026-05-11 09:15:42 · 制作中心`,date:`2026-05-11`,amount:-250,badgeKind:`deducted`,badgeText:`已扣除`},{id:`expire-1`,type:`expense`,name:`积分过期`,meta:`2026-05-01 00:00:00 · 2026-04 批次到期未使用`,date:`2026-05-01`,amount:-100,badgeKind:`expired`,badgeText:`自然过期`},{id:`expense-3`,type:`expense`,name:`AI 对话 — GPT-4o 5轮`,meta:`2026-05-07 10:08:55 · 剧本中心`,date:`2026-05-07`,amount:-10,badgeKind:`deducted`,badgeText:`已扣除`},{id:`expense-4`,type:`expense`,name:`图片生成 — DALL-E 5张`,meta:`2026-05-04 14:20:11 · 制作中心`,date:`2026-05-04`,amount:-75,badgeKind:`deducted`,badgeText:`已扣除`}],{RangePicker:K}=n.DatePicker,q=21,J=7;function Y(e){return e===`recharge`?`arcoblue`:e===`gift`?`cyan`:e===`expired`?`gray`:`orange`}function ee({visible:e,points:i,text:o,onCancel:s,onRecharge:c}){let[l,u]=(0,t.useState)(`all`),[d,f]=(0,t.useState)(`all`),[p,m]=(0,t.useState)([`2026-04-15`,`2026-05-15`]),[h,g]=(0,t.useState)(1),_=e=>new Intl.NumberFormat().format(e),v=(0,t.useMemo)(()=>{let[e,t]=p;return G.filter(n=>{let r=l===`all`||n.type===l,i=d===`all`||n.source===d,a=!e||n.date>=e,o=!t||n.date<=t;return r&&i&&a&&o})},[p,d,l]),y=[{title:o.pointsDetail,dataIndex:`name`,render:(e,t)=>(0,a.jsxs)(`div`,{className:`min-w-0`,children:[(0,a.jsx)(n.Typography.Text,{className:`font-medium!`,children:t.name}),(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`mt-1 block! text-xs!`,children:t.meta})]})},{title:o.pointsUnit,dataIndex:`amount`,width:120,align:`right`,render:(e,t)=>(0,a.jsxs)(n.Typography.Text,{className:`font-semibold! ${t.amount>0?`text-arco-success-6!`:`text-arco-danger-6!`}`,children:[t.amount>0?`+`:``,_(t.amount)]})},{title:o.source,dataIndex:`badgeText`,width:110,align:`right`,render:(e,t)=>(0,a.jsx)(n.Tag,{color:Y(t.badgeKind),children:t.badgeText})}];return(0,a.jsx)(n.Modal,{title:o.pointsDetail,visible:e,footer:(0,a.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,a.jsx)(n.Button,{onClick:s,children:o.close}),(0,a.jsx)(n.Button,{type:`primary`,icon:(0,a.jsx)(r.IconPlus,{}),onClick:()=>{s(),c()},children:o.recharge})]}),onCancel:s,style:{width:780,maxWidth:`calc(100vw - 48px)`},children:(0,a.jsxs)(`div`,{className:`max-h-[70vh] overflow-y-auto`,children:[(0,a.jsxs)(n.Card,{bordered:!1,className:`from-arco-primary-light-1/40 to-cyan-400/5 rounded-none! bg-linear-to-br!`,children:[(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`text-xs!`,children:o.totalBalance}),(0,a.jsxs)(`div`,{className:`mt-1.5 mb-3.5 `,children:[(0,a.jsx)(n.Typography.Text,{className:`text-3xl! font-bold!`,children:_(i.total)}),(0,a.jsxs)(n.Typography.Text,{type:`secondary`,className:`ml-2 text-sm! `,children:[`🪙 `,o.pointsUnit]})]}),(0,a.jsxs)(n.Grid.Row,{gutter:12,children:[(0,a.jsx)(n.Grid.Col,{span:12,children:(0,a.jsxs)(n.Card,{size:`small`,children:[(0,a.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`text-xs!`,children:o.rechargePoints}),(0,a.jsx)(n.Tag,{color:`arcoblue`,children:o.sourceRecharge})]}),(0,a.jsx)(n.Typography.Text,{className:`text-lg! font-semibold!`,children:_(i.recharge)})]})}),(0,a.jsx)(n.Grid.Col,{span:12,children:(0,a.jsxs)(n.Card,{size:`small`,children:[(0,a.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`text-xs!`,children:o.giftedPoints}),(0,a.jsx)(n.Tag,{color:`success`,children:o.sourceGifted})]}),(0,a.jsx)(n.Typography.Text,{className:`text-lg! font-semibold!`,children:_(i.gifted)})]})})]}),(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`mt-2.5 block! text-xs!`,children:o.pointsDeductionTip})]}),(0,a.jsxs)(`div`,{className:`px-6 py-4`,children:[(0,a.jsxs)(n.Tabs,{activeTab:l,onChange:e=>u(e),children:[(0,a.jsx)(n.Tabs.TabPane,{title:o.all},`all`),(0,a.jsx)(n.Tabs.TabPane,{title:o.income},`income`),(0,a.jsx)(n.Tabs.TabPane,{title:o.expense},`expense`)]}),(0,a.jsxs)(`div`,{className:`mt-2 mb-3.5 flex flex-wrap items-center gap-2.5`,children:[(0,a.jsxs)(n.Select,{value:d,style:{width:140},onChange:e=>f(e),children:[(0,a.jsx)(n.Select.Option,{value:`all`,children:o.sourceAll}),(0,a.jsx)(n.Select.Option,{value:`recharge`,children:o.sourceRecharge}),(0,a.jsx)(n.Select.Option,{value:`gift`,children:o.sourceGifted})]}),(0,a.jsx)(K,{value:p,onChange:e=>m(e),style:{width:260}}),(0,a.jsx)(n.Button,{onClick:()=>n.Message.success(o.refreshed),children:o.query})]}),(0,a.jsx)(n.Table,{rowKey:`id`,columns:y,data:v,pagination:!1,border:!1}),(0,a.jsx)(n.Pagination,{className:`mt-3 flex justify-center!`,current:h,pageSize:J,total:q,onChange:g})]}),(0,a.jsx)(n.Card,{bordered:!1,className:`bg-arco-primary-light-1/30 rounded-none!`,children:(0,a.jsxs)(n.Typography.Text,{type:`secondary`,className:`text-xs! leading-6!`,children:[(0,a.jsxs)(`strong`,{children:[o.pointsNoteTitle,`:`]}),o.pointsAccountNote]})})]})})}var X=2048,Z=2*1024*1024;function Q(e){return new Promise((t,n)=>{let r=URL.createObjectURL(e),i=new Image;i.onload=()=>{URL.revokeObjectURL(r),t({width:i.naturalWidth,height:i.naturalHeight})},i.onerror=()=>{URL.revokeObjectURL(r),n(Error(`invalid image`))},i.src=r})}function te({visible:e,user:i,labels:o,onCancel:s,onSubmit:c}){let l=j(o),[u]=n.Form.useForm(),[d,f]=(0,t.useState)(!1),[p,m]=(0,t.useState)(null),[h,g]=(0,t.useState)(null),_=(0,t.useRef)(null);(0,t.useEffect)(()=>()=>{_.current&&=(URL.revokeObjectURL(_.current),null)},[]),(0,t.useEffect)(()=>{e&&(u.setFieldsValue({nickname:i?.nickname||i?.username||``}),m(null),g(e=>(e&&URL.revokeObjectURL(e),_.current=null,null)))},[e,i,u]);let v=(e,t)=>{console.error(t),n.Message.error(e)},y=e=>{n.Message.success(e)};return(0,a.jsx)(n.Modal,{title:l.profileTitle,visible:e,onOk:async()=>{try{let e=await u.validate();f(!0),await c({nickname:e.nickname,avatarFile:p}),y(l.profileUpdateSuccess),s()}catch(e){e instanceof Error&&v(e.message||l.error,e)}finally{f(!1)}},onCancel:s,confirmLoading:d,okText:l.profileSave,cancelText:l.profileCancel,children:(0,a.jsxs)(n.Form,{form:u,layout:`vertical`,children:[(0,a.jsx)(n.Form.Item,{label:l.profileNickname,field:`nickname`,rules:[{required:!0,message:l.profileNicknamePlaceholder}],children:(0,a.jsx)(n.Input,{placeholder:l.profileNicknamePlaceholder,allowClear:!0})}),(0,a.jsx)(n.Form.Item,{label:l.profileAvatar,children:(0,a.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,a.jsx)(n.Avatar,{size:64,className:`shrink-0 bg-arco-primary-light-1!`,children:h||i?.avatar?(0,a.jsx)(`img`,{src:h||i?.avatar,alt:``,className:`block h-full w-full object-cover`}):i?.nickname?.[0]||i?.username?.[0]||`U`}),(0,a.jsx)(n.Upload,{accept:`image/*`,showUploadList:!1,beforeUpload:async e=>{if(e.size>Z)return v(l.profileAvatarTooLarge),!1;try{let{width:t,height:n}=await Q(e);if(t>X||n>X)return v(l.profileAvatarDimensionExceeded),!1}catch(e){return v(l.profileAvatarInvalidImage,e),!1}return g(t=>{t&&URL.revokeObjectURL(t);let n=URL.createObjectURL(e);return _.current=n,n}),m(e),!1},children:(0,a.jsx)(n.Button,{type:`outline`,size:`small`,icon:(0,a.jsx)(r.IconUpload,{}),children:l.profileUploadAvatar})})]}),(0,a.jsx)(`span`,{className:`text-xs text-arco-text-3`,children:l.profileAvatarHint})]})})]})})}function ne(e){return e?.nickname?.[0]||e?.username?.[0]||`U`}function $({user:e,size:t,className:r=``}){return(0,a.jsx)(n.Avatar,{size:t,className:`bg-arco-primary/20! text-arco-primary-6 border-2 font-bold ${r}`,children:e?.avatar?(0,a.jsx)(`img`,{src:e.avatar,alt:`avatar`,className:`h-full w-full object-cover`}):ne(e)})}function re({visible:e,user:i,points:o,text:s,onCancel:c,onPay:l}){let[u,d]=(0,t.useState)(W[2].id),f=e=>new Intl.NumberFormat().format(e),p=W.find(e=>e.id===u)||W[0];return(0,a.jsx)(n.Modal,{title:s.rechargeTitle,visible:e,footer:(0,a.jsxs)(`div`,{className:`mx-auto flex max-w-7xl items-center justify-between gap-5`,children:[(0,a.jsx)(`span`,{className:`text-arco-text-2 text-sm leading-6`,children:s.rechargeHint}),(0,a.jsxs)(n.Button,{type:`primary`,size:`large`,className:`min-w-48! font-bold!`,onClick:()=>l(p),children:[s.payNow,` · $`,p.price]})]}),onCancel:c,alignCenter:!1,wrapClassName:`overflow-hidden!`,style:{width:`100vw`,maxWidth:`100vw`,top:0,paddingBottom:0},className:`top-0! m-0! flex! h-screen! w-screen! max-w-none! flex-col! [&_.arco-modal-body]:min-h-0! [&_.arco-modal-body]:flex-1! [&_.arco-modal-body]:overflow-hidden! [&_.arco-modal-body]:p-0! [&_.arco-modal-close-icon]:top-1.5! [&_.arco-modal-close-icon]:right-4! [&_.arco-modal-close-icon]:inline-flex! [&_.arco-modal-close-icon]:h-9! [&_.arco-modal-close-icon]:w-9! [&_.arco-modal-close-icon]:items-center! [&_.arco-modal-close-icon]:justify-center! [&_.arco-modal-close-icon]:rounded-lg! [&_.arco-modal-close-icon]:text-lg! [&_.arco-modal-close-icon]:leading-9! [&_.arco-modal-close-icon]:transition-colors [&_.arco-modal-close-icon:hover]:bg-arco-fill-2 [&_.arco-modal-close-icon:hover]:text-arco-primary-6 [&_.arco-modal-close-icon_svg]:h-[18px]! [&_.arco-modal-close-icon_svg]:w-[18px]! [&_.arco-modal-content]:flex! [&_.arco-modal-content]:h-auto! [&_.arco-modal-content]:min-h-0! [&_.arco-modal-content]:flex-1! [&_.arco-modal-content]:flex-col! [&_.arco-modal-content]:overflow-hidden! [&_.arco-modal-content]:rounded-none! [&_.arco-modal-footer]:shrink-0! [&_.arco-modal-header]:shrink-0!`,children:(0,a.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-7xl flex-col items-center `,children:[(0,a.jsxs)(`div`,{className:`w-full border-arco-border-1 bg-arco-fill-1 text-arco-text-2 flex items-center gap-2.5 rounded-lg border px-3.5 py-3 text-sm`,children:[(0,a.jsx)($,{user:i,size:32,className:`shrink-0`}),(0,a.jsxs)(`span`,{children:[i?.nickname||i?.username,` · `,s.currentBalance,` `,(0,a.jsx)(`strong`,{className:`text-arco-text-1`,children:f(o.total)}),` `,s.pointsUnit]})]}),(0,a.jsx)(`div`,{className:`mt-6 w-full`,children:(0,a.jsx)(n.Grid.Row,{gutter:[16,16],children:W.map(e=>(0,a.jsx)(n.Grid.Col,{xs:24,sm:12,lg:6,children:(0,a.jsxs)(n.Card,{hoverable:!0,role:`button`,tabIndex:0,onClick:()=>d(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&d(e.id)},bodyStyle:{minHeight:192,display:`flex`,flexDirection:`column`,justifyContent:`space-between`},className:`border-arco-border-2! bg-arco-bg-2! relative cursor-pointer overflow-hidden rounded-lg! shadow-sm! transition-all duration-200 before:absolute before:inset-x-0 before:top-0 before:h-1 before:bg-linear-to-r before:from-arco-primary before:to-transparent hover:shadow-md! ${u===e.id?`border-arco-primary-6! bg-arco-primary-light-1/40! ring-arco-primary-6/20 ring-2! shadow-[0_18px_38px_rgb(var(--primary-6)/22%)]!`:`hover:border-arco-primary-6!`}`,children:[u===e.id?(0,a.jsx)(r.IconCheckCircleFill,{className:`text-arco-primary-6! absolute bottom-4 left-4 text-xl`}):null,`recommended`in e&&e.recommended?(0,a.jsx)(n.Tag,{color:`arcoblue`,className:`absolute top-4 right-4 text-xs! font-bold!`,children:`HOT`}):null,(0,a.jsxs)(`div`,{className:`min-w-0 pr-16`,children:[(0,a.jsxs)(n.Typography.Text,{className:`flex items-center text-3xl! leading-tight! font-bold!`,children:[f(e.points),(0,a.jsx)(`span`,{className:`ml-1 text-2xl`,children:`🪙`})]}),(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`mt-1 block! text-sm!`,children:s.pointsUnit})]}),(0,a.jsx)(`div`,{className:`mt-7 flex w-full justify-end`,children:(0,a.jsxs)(n.Typography.Text,{className:`text-arco-primary-6! text-right text-2xl! leading-tight! font-bold!`,children:[`$`,e.price]})})]})},e.id))})})]})})}function ie({user:e,points:t,text:i,onEditProfile:o,onRecharge:s,onPointsDetail:c,onLogout:l}){let u=e=>new Intl.NumberFormat().format(e);return(0,a.jsxs)(`div`,{className:`w-80 overflow-hidden rounded-xl border border-arco-border-2 bg-arco-bg-popup shadow-[0_10px_28px_rgb(0_0_0/12%)]`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-3 px-6 pt-5 pb-4`,children:[(0,a.jsx)($,{user:e,size:48,className:`shrink-0`}),(0,a.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`text-arco-text-1 truncate text-base leading-6 font-bold`,children:e?.nickname||e?.username}),(0,a.jsx)(n.Button,{type:`text`,size:`mini`,icon:(0,a.jsx)(r.IconEdit,{}),className:`text-arco-text-3 h-6! min-w-6! px-0!`,onClick:o})]}),e?.email?(0,a.jsx)(`span`,{className:`text-arco-text-3 truncate text-xs leading-5`,children:e.email}):null]})]}),(0,a.jsx)(n.Divider,{className:`m-0!`}),(0,a.jsxs)(`ul`,{className:`flex flex-col gap-3.5 px-6 py-4`,children:[(0,a.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,a.jsx)(`span`,{children:i.myPoints}),(0,a.jsx)(`strong`,{className:`text-arco-primary-6 text-base font-bold`,children:u(t.total)})]}),(0,a.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,a.jsx)(`span`,{children:i.rechargePoints}),(0,a.jsx)(`strong`,{className:`text-arco-text-1 text-base font-bold`,children:u(t.recharge)})]}),(0,a.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,a.jsx)(`span`,{children:i.giftedPoints}),(0,a.jsx)(`strong`,{className:`text-arco-text-1 text-base font-bold`,children:u(t.gifted)})]})]}),(0,a.jsx)(n.Divider,{className:`m-0!`}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-2 px-6 py-4`,children:[(0,a.jsx)(n.Button,{type:`primary`,long:!0,icon:(0,a.jsx)(r.IconPlus,{}),className:`h-10! rounded-md! font-semibold!`,onClick:s,children:i.recharge}),(0,a.jsx)(n.Button,{long:!0,icon:(0,a.jsx)(r.IconFile,{}),className:`border-arco-border-2! bg-arco-fill-1! text-arco-text-1! h-10! rounded-md! font-semibold!`,onClick:c,children:i.pointsDetail})]}),(0,a.jsx)(n.Divider,{className:`m-0!`}),(0,a.jsx)(`div`,{className:`px-6 py-4`,children:(0,a.jsx)(n.Button,{icon:(0,a.jsx)(r.IconPoweroff,{}),type:`text`,status:`danger`,long:!0,className:`flex! items-center justify-start gap-2 text-sm text-arco-text-2`,onClick:()=>void l?.(),children:i.logout})})]})}var ae=`https://mantur.ai/images/logo.png`,oe=[`from-arco-primary-light-1 to-arco-primary-light-2 text-arco-primary-6`,`from-arco-success-light-1 to-arco-success-light-2 text-arco-success-6`,`from-arco-warning-light-1 to-arco-warning-light-2 text-arco-warning-6`,`from-arco-danger-light-1 to-arco-danger-light-2 text-arco-danger-6`];function se(e,t=!1){return`flex h-8 min-h-8 w-8 min-w-8 flex-none items-center justify-center rounded-lg bg-linear-to-br font-bold leading-none ${oe[e%oe.length]} ${t?`shadow-[inset_0_1px_3px_rgb(0_0_0/8%)]`:``}`}function ce(e){return e?.tenantName?.[0]?.toUpperCase()||`T`}function le(e,t,n){let r=e?.roles?.map(e=>e.roleName).filter(Boolean);return r?.length?r.join(`, `):e?.isOwner?t:n}function ue({user:e,disabled:i=!1,brandSlot:o,children:s,onTenantContextChange:c}){let[u,d]=(0,t.useState)(()=>L()),f=R(u),[p,m]=(0,t.useState)(!1),[h,g]=(0,t.useState)(!1),[y,b]=(0,t.useState)(!1),[S,C]=(0,t.useState)(e),[w,T]=(0,t.useState)([]),[E,D]=(0,t.useState)(),[A,j]=(0,t.useState)(!1),M=(0,t.useRef)(c),[N,F]=(0,t.useState)({total:0,recharge:0,gifted:0}),z=E?.tenantId||``,B=i,V={total:N.total??0,recharge:N.recharge??0,gifted:N.gifted??0},W=async e=>{let t=await v(e);return t&&C(t),t};(0,t.useEffect)(()=>{C(e)},[e]),(0,t.useEffect)(()=>{M.current=c},[c]);let G=(0,t.useCallback)(e=>{T(e.tenants),D(e.currentTenant),M.current?.(e)},[]);(0,t.useEffect)(()=>{j(!0),O().then(G).catch(e=>{console.warn(`Failed to refresh Mantur tenant context.`,e),n.Message.error(f.error)}).finally(()=>j(!1))},[G,f.error]),(0,t.useEffect)(()=>{let e=e=>{e instanceof CustomEvent&&F(e.detail)};return window.addEventListener(l,e),x().catch(e=>{console.warn(`Failed to refresh Mantur user points.`,e)}),()=>{window.removeEventListener(l,e)}},[]),(0,t.useEffect)(()=>{let e=e=>{d(e instanceof CustomEvent?I(e.detail):L())};return window.addEventListener(P,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(P,e),window.removeEventListener(`storage`,e)}},[]);let K=e=>{n.Message.success(e)},q=(e,t)=>{console.error(t),n.Message.error(e)},J=(0,t.useCallback)(async e=>{if(!B&&e!==z)try{j(!0),G(await k(e)),K(f.switchedToTeam)}catch(e){q(f.error,e)}finally{j(!1)}},[G,z,B,f.error,f.switchedToTeam]),Y=e=>{let t={total:V.total+e.points,recharge:V.recharge+e.points,gifted:V.gifted};F(t),window.dispatchEvent(new CustomEvent(l,{detail:t})),n.Message.success(f.rechargeSuccess),g(!1)},X=(0,t.useMemo)(()=>(0,a.jsxs)(n.Menu,{className:`w-56 rounded-xl bg-arco-bg-popup shadow-[0_10px_28px_rgb(0_0_0/12%)] [&_.arco-menu-inner]:px-2 [&_.arco-menu-inner]:py-1`,selectedKeys:z?[z]:[],onClickMenuItem:J,children:[(0,a.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold tracking-[0.04em] text-arco-text-4 uppercase`,children:f.switchTeam}),w.map((e,t)=>(0,a.jsx)(n.Menu.Item,{className:`mb-1 h-auto! min-h-10! overflow-visible! rounded-lg! px-2! py-1! leading-normal!`,children:(0,a.jsxs)(`div`,{className:`flex w-full items-center gap-3 leading-normal`,children:[(0,a.jsx)(`div`,{className:se(t),children:ce(e)}),(0,a.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center gap-0.75`,children:[(0,a.jsx)(`span`,{className:`text-sm leading-5 font-medium text-arco-text-1`,children:e.tenantName}),(0,a.jsx)(`span`,{className:`text-xs leading-4 text-arco-text-3`,children:le(e,f.owner,f.member)})]})]})},e.tenantId))]}),[J,z,w,f]),Z=(0,a.jsx)(ie,{user:S,points:V,text:f,onEditProfile:()=>m(!0),onRecharge:()=>g(!0),onPointsDetail:()=>b(!0),onLogout:_}),Q=Math.max(0,w.findIndex(e=>e.tenantId===E?.tenantId));return(0,a.jsxs)(`div`,{className:`flex h-20 items-center justify-between bg-transparent pr-8 shadow-[0_2px_10px_rgb(0_0_0/2%)] backdrop-blur-md max-md:pr-4`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,a.jsxs)(`div`,{className:`flex w-65 items-center gap-3 px-8 max-md:w-auto max-md:px-4`,children:[(0,a.jsx)(`div`,{className:`relative flex w-12 items-center justify-center overflow-hidden `,children:(0,a.jsx)(`img`,{src:ae,alt:`logo`,className:`w-full object-contain`,onError:e=>{e.currentTarget.style.display=`none`}})}),o??(0,a.jsx)(`span`,{className:`text-lg font-bold tracking-normal text-arco-text-1`,children:f.title})]}),(0,a.jsx)(n.Dropdown,{droplist:X,trigger:`click`,position:`bl`,disabled:B,children:(0,a.jsxs)(`div`,{"aria-disabled":B,className:`flex items-center gap-3 rounded-full border border-arco-border-1 bg-arco-bg-1 px-2 py-1.5 transition-all ${B?`cursor-not-allowed opacity-60`:`cursor-pointer hover:bg-arco-fill-2 hover:shadow-[0_4px_12px_rgb(0_0_0/8%)]`}`,children:[(0,a.jsx)(`div`,{className:se(Q,!0),children:ce(E)}),(0,a.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,a.jsx)(`span`,{className:`text-xs leading-none font-bold text-arco-text-1`,children:A?f.loading:E?.tenantName||f.loading}),(0,a.jsx)(`span`,{className:`mt-1 text-[10px] leading-none text-arco-text-3`,children:le(E,f.owner,f.member)})]}),(0,a.jsx)(r.IconDown,{className:`ml-1 text-arco-text-3`})]})})]}),(0,a.jsx)(`div`,{className:`flex-1`,children:s}),(0,a.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,a.jsx)(U,{}),(0,a.jsx)(H,{})]}),(0,a.jsx)(n.Dropdown,{droplist:Z,trigger:`click`,position:`br`,onVisibleChange:e=>{e&&x().catch(e=>{console.warn(`Failed to refresh Mantur user points.`,e)})},children:(0,a.jsxs)(`div`,{className:`hover:bg-arco-fill-2 flex cursor-pointer items-center gap-2.5 rounded-full border border-transparent p-1 pr-2 transition-all`,children:[(0,a.jsxs)(`div`,{className:`from-arco-primary to-transparent relative rounded-full bg-linear-to-br p-0.5 shadow-sm`,children:[(0,a.jsx)($,{user:S,size:36}),(0,a.jsx)(`div`,{className:`bg-arco-success border-arco-bg-white absolute right-0 bottom-0 h-3 w-3 rounded-full border-2 shadow-sm`})]}),(0,a.jsx)(`div`,{className:`hidden flex-col md:flex`,children:(0,a.jsx)(`span`,{className:`text-arco-text-1 text-sm font-medium`,children:S?.nickname||S?.username})}),(0,a.jsx)(r.IconDown,{className:`text-arco-text-3 ml-1`})]})})]}),(0,a.jsx)(te,{visible:p,user:S,labels:f,onCancel:()=>m(!1),onSubmit:W}),(0,a.jsx)(re,{visible:h,user:S,points:V,text:f,onCancel:()=>g(!1),onPay:Y}),(0,a.jsx)(ee,{visible:y,points:V,text:f,onCancel:()=>b(!1),onRecharge:()=>g(!0)})]})}e.LANGUAGE_SOURCE_STORAGE_KEY=B,e.LANGUAGE_STORAGE_KEY=z,e.LangSwitch=H,e.MANTUR_LANGUAGE_CHANGE_EVENT=P,e.MANTUR_LANGUAGE_SOURCE_STORAGE_KEY=N,e.MANTUR_LANGUAGE_STORAGE_KEY=M,e.MANTUR_MESSAGES=F,e.MANTUR_POINTS_REFRESH_EVENT=l,e.MANTUR_TENANT_CONTEXT_CHANGE_EVENT=u,e.ManturHeader=ue,e.ThemeSwitch=U,e.getManturCurrentTenant=E,e.getManturMessages=R,e.getManturTenantContextSnapshot=w,e.getManturTenants=T,e.getManturUserPoints=b,e.getStoredManturLocale=L,e.normalizeManturLocale=I,e.refreshManturTenantContext=O,e.refreshManturUserPoints=x,e.switchAndRefreshManturTenant=k,e.switchManturTenant=D});
package/dist/types.d.ts CHANGED
@@ -103,6 +103,7 @@ export interface ManturHeaderProps {
103
103
  disabled?: boolean;
104
104
  brandSlot?: ReactNode;
105
105
  children?: ReactNode;
106
+ onTenantContextChange?: (detail: ManturTenantContextDetail) => void;
106
107
  }
107
108
  export interface ProfileModalProps {
108
109
  visible: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mantur-components",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Reusable Mantur React component library.",
5
5
  "type": "module",
6
6
  "main": "./dist/mantur-components.umd.cjs",