@24city/web-console 0.3.11 → 0.3.13

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.
@@ -0,0 +1,700 @@
1
+ import { jsx as o, jsxs as f, Fragment as ke } from "react/jsx-runtime";
2
+ import { useState as M, useRef as be, useCallback as ve, useEffect as te } from "react";
3
+ import { Skeleton as pe, Button as g, Toast as Ne, Modal as Me, Avatar as Ue, Popover as Re, Tooltip as Fe } from "@douyinfe/semi-ui";
4
+ import { IconUser as U, IconCrown as Ve, IconGift as ze, IconChevronRight as Q, IconUserGroup as me, IconChevronUp as Ke, IconChevronDown as We, IconTick as je, IconMoon as Ge } from "@douyinfe/semi-icons";
5
+ import { useNavigate as ne, useLocation as Ye } from "react-router";
6
+ import { C as qe } from "./color-mode-switch-BinpVuZ0.js";
7
+ import { a as Se, b as w } from "./context-CaVim6ZO.js";
8
+ import { u as He } from "./color-mode-DC4KIKya.js";
9
+ import { q as N, k as Qe, a as Xe, t as Te, w as Ze, l as Je, u as I, g as et, f as _e } from "./logout-signal-XyvlxcEc.js";
10
+ import { useQueryClient as Ce, useQuery as L } from "@tanstack/react-query";
11
+ import { notifyCustomerSessionChanged as Ae } from "@24city/web-runtime/session-sync";
12
+ const tt = "_trigger_w6k09_7", nt = "_avatarWrap_w6k09_28", at = "_avatar_w6k09_28", st = "_card_w6k09_81", ot = "_identity_w6k09_91", rt = "_who_w6k09_99", ct = "_nameRow_w6k09_108", it = "_name_w6k09_108", lt = "_planChip_w6k09_125", dt = "_diamond_w6k09_155", ut = "_spaceToggle_w6k09_163", pt = "_spaceStatic_w6k09_164", mt = "_spaceSwitchText_w6k09_185", _t = "_spaceName_w6k09_191", ft = "_spaceType_w6k09_197", ht = "_spaceList_w6k09_207", yt = "_spaceOption_w6k09_216", gt = "_spaceCheck_w6k09_238", wt = "_plan_w6k09_125", kt = "_allowance_w6k09_249", bt = "_links_w6k09_259", vt = "_link_w6k09_259", Nt = "_linkIcon_w6k09_297", St = "_linkLabel_w6k09_308", Tt = "_linkArrow_w6k09_313", Ct = "_appearance_w6k09_320", At = "_divider_w6k09_330", Lt = "_logout_w6k09_336", u = {
13
+ trigger: tt,
14
+ avatarWrap: nt,
15
+ avatar: at,
16
+ card: st,
17
+ identity: ot,
18
+ who: rt,
19
+ nameRow: ct,
20
+ name: it,
21
+ planChip: lt,
22
+ diamond: dt,
23
+ spaceToggle: ut,
24
+ spaceStatic: pt,
25
+ spaceSwitchText: mt,
26
+ spaceName: _t,
27
+ spaceType: ft,
28
+ spaceList: ht,
29
+ spaceOption: yt,
30
+ spaceCheck: gt,
31
+ plan: wt,
32
+ allowance: kt,
33
+ links: bt,
34
+ link: vt,
35
+ linkIcon: Nt,
36
+ linkLabel: St,
37
+ linkArrow: Tt,
38
+ appearance: Ct,
39
+ divider: At,
40
+ logout: Lt
41
+ }, Et = ["profile", "subscription", "points"], Pt = (e) => Et.includes(e), v = (e, t) => `${e}/account/${t}`, da = (e, t) => t === `${e}/account` || t.startsWith(`${e}/account/`), D = (e) => `account-${e}`, E = {
42
+ profile: D("profile"),
43
+ subscription: D("subscription"),
44
+ points: D("points")
45
+ }, It = /^[a-z][a-z0-9-]{0,31}$/, xt = (e) => {
46
+ const t = e.accountSections ?? [], a = /* @__PURE__ */ new Set();
47
+ for (const n of t) {
48
+ if (!It.test(n.key))
49
+ throw new Error(`个人中心分区 key 不合法:${n.key}(小写字母开头,只含小写字母、数字和连字符)`);
50
+ if (Pt(n.key)) throw new Error(`个人中心分区 key 与内置分区重名:${n.key}`);
51
+ if (a.has(n.key)) throw new Error(`个人中心分区 key 重复:${n.key}`);
52
+ a.add(n.key);
53
+ }
54
+ return t;
55
+ }, $t = (e, t = []) => ({
56
+ key: "personal",
57
+ label: "个人中心",
58
+ items: [
59
+ { key: E.profile, label: "账号与安全", to: v(e, "profile"), icon: U },
60
+ { key: E.subscription, label: "订阅与套餐", to: v(e, "subscription"), icon: Ve },
61
+ { key: E.points, label: "积分与明细", to: v(e, "points"), icon: ze },
62
+ ...t.map(
63
+ (a) => ({
64
+ key: D(a.key),
65
+ label: a.label,
66
+ to: v(e, a.key),
67
+ icon: a.icon
68
+ })
69
+ )
70
+ ]
71
+ }), Ot = 1e6, ae = (e) => e != null && e >= Ot, ua = (e) => !!e && e.limit !== null && e.used >= e.limit, pa = (e, t) => e.limit === null ? `已有 ${e.used} ${t}` : e.limit === 0 && e.used === 0 ? "套餐未包含" : ae(e.limit) ? `已有 ${e.used} ${t} · 不限` : `已用 ${e.used}/${e.limit}`, ma = (e, t) => (a) => a !== null && ae(a) ? t : e(N(a ?? 0)), Le = (e, t) => e.find((a) => a.key === t), fe = (e, t) => {
72
+ const a = e.findIndex((n) => n.key === t);
73
+ return a === -1 ? e.length : a;
74
+ }, Bt = (e, t) => {
75
+ const a = Le(e, t.key), n = a ? a.on(t.limit) : t.limit === null ? t.name : `${t.name} ${ae(t.limit) ? "不限" : N(t.limit)}`;
76
+ return t.discounts.length ? `${n}(${t.discounts.join("、")})` : n;
77
+ }, Dt = (e) => {
78
+ if (e.length < 2) return /* @__PURE__ */ new Set();
79
+ const t = new Set(e.flatMap((a) => a.benefits.filter((n) => n.limit === null).map((n) => n.key)));
80
+ return new Set(
81
+ [...t].filter((a) => e.every((n) => n.benefits.some((s) => s.key === a && s.limit === null)))
82
+ );
83
+ }, Mt = (e, t = [], a = {}) => {
84
+ var l;
85
+ const n = a.benefitCopy ?? [], s = Dt(t), r = [];
86
+ for (const i of [...e.benefits, ...t.flatMap((m) => m.benefits)])
87
+ !r.includes(i.key) && !s.has(i.key) && r.push(i.key);
88
+ const c = [];
89
+ for (const i of [...r].sort((m, d) => fe(n, m) - fe(n, d) || r.indexOf(m) - r.indexOf(d))) {
90
+ const m = e.benefits.find((_) => _.key === i);
91
+ if (m) {
92
+ c.push({ text: Bt(n, m), included: !0 });
93
+ continue;
94
+ }
95
+ const d = (l = Le(n, i)) == null ? void 0 : l.off;
96
+ d && c.push({ text: d, included: !1 });
97
+ }
98
+ return c;
99
+ }, X = (e) => e.planName || e.planCode, Ut = (e) => e.isDefault || !e.currentPeriodEnd ? "长期有效" : `有效期至 ${Qe(e.currentPeriodEnd)}`, Rt = 1440 * 60 * 1e3, Ft = (e, t = Date.now()) => {
100
+ if (e.isDefault || !e.currentPeriodEnd) return null;
101
+ const a = Date.parse(e.currentPeriodEnd);
102
+ return Number.isFinite(a) ? Math.max(0, Math.ceil((a - t) / Rt)) : null;
103
+ }, Vt = 7, zt = { month: "/月", year: "/年", one_time: "" }, Kt = (e) => {
104
+ const t = (e.amountCents / 100).toLocaleString("zh-CN", { maximumFractionDigits: 2 });
105
+ return e.currency === "CNY" ? `¥${t}` : `${e.currency} ${t}`;
106
+ }, _a = (e) => e ? { focusPlan: e } : void 0, fa = (e) => {
107
+ if (typeof e != "object" || e === null) return;
108
+ const t = e.focusPlan;
109
+ return typeof t == "string" && t ? t : void 0;
110
+ }, Wt = (e) => `${Kt(e)}${zt[e.billingPeriod]}`, jt = (e) => {
111
+ const t = e.prices.filter((s) => s.amountCents > 0), a = t.filter((s) => s.billingPeriod === "month");
112
+ return (a.length ? a : t).reduce((s, r) => !s || r.amountCents < s.amountCents ? r : s, null);
113
+ }, Gt = (e, t, a) => {
114
+ const s = (e ?? []).filter(
115
+ (r) => r.spaceType === t && !r.isDefault && (a === null || r.tier > a)
116
+ ).map((r) => ({ plan: r, price: jt(r) }));
117
+ return s.sort(
118
+ (r, c) => {
119
+ var l, i;
120
+ return r.plan.tier - c.plan.tier || (((l = r.price) == null ? void 0 : l.amountCents) ?? Number.MAX_SAFE_INTEGER) - (((i = c.price) == null ? void 0 : i.amountCents) ?? Number.MAX_SAFE_INTEGER);
121
+ }
122
+ ), s[0] ?? null;
123
+ }, ha = (e) => e == null ? void 0 : e.filter((t) => t.spaceType === "team" && !t.isDefault).sort((t, a) => t.tier - a.tier)[0], Yt = (e, t) => e == null ? void 0 : e.find((a) => a.code === t.planCode), qt = (e, t = [], a = {}) => {
124
+ if (!e) return ["积分按月发放", "24.city 全产品通用"];
125
+ const n = [];
126
+ e.monthlyPoints > 0 && n.push(`每月 ${N(e.monthlyPoints)} 积分`);
127
+ for (const s of Mt(e, t, a).filter((r) => r.included).slice(0, 2)) n.push(s.text);
128
+ return n.length < 2 && n.push("24.city 全产品通用"), n;
129
+ }, Ht = "_promo_uc5su_6", Qt = "_member_uc5su_7", Xt = "_plain_uc5su_8", Zt = "_promoArt_uc5su_28", Jt = "_promoBody_uc5su_38", en = "_promoTitle_uc5su_44", tn = "_promoText_uc5su_55", nn = "_cta_uc5su_63", an = "_ctaButton_uc5su_69", sn = "_ctaTag_uc5su_89", on = "_ownerOnly_uc5su_106", rn = "_memberArt_uc5su_122", cn = "_memberBody_uc5su_132", ln = "_memberEyebrow_uc5su_139", dn = "_memberTitle_uc5su_145", un = "_memberMeta_uc5su_159", pn = "_memberCta_uc5su_166", mn = "_plainBody_uc5su_200", _n = "_plainText_uc5su_207", fn = "_retry_uc5su_212", hn = "_loading_uc5su_216", yn = "_assets_uc5su_224", gn = "_asset_uc5su_224", wn = "_coin_uc5su_279", kn = "_assetLabel_uc5su_287", bn = "_assetValue_uc5su_291", vn = "_assetArrow_uc5su_299", Nn = "_assetDivider_uc5su_312", p = {
130
+ promo: Ht,
131
+ member: Qt,
132
+ plain: Xt,
133
+ promoArt: Zt,
134
+ promoBody: Jt,
135
+ promoTitle: en,
136
+ promoText: tn,
137
+ cta: nn,
138
+ ctaButton: an,
139
+ ctaTag: sn,
140
+ ownerOnly: on,
141
+ memberArt: rn,
142
+ memberBody: cn,
143
+ memberEyebrow: ln,
144
+ memberTitle: dn,
145
+ memberMeta: un,
146
+ memberCta: pn,
147
+ plainBody: mn,
148
+ plainText: _n,
149
+ retry: fn,
150
+ loading: hn,
151
+ assets: yn,
152
+ asset: gn,
153
+ coin: wn,
154
+ assetLabel: kn,
155
+ assetValue: bn,
156
+ assetArrow: vn,
157
+ assetDivider: Nn
158
+ }, Sn = E.points, se = E.subscription, Tn = ({ membership: e, text: t, onOpen: a }) => {
159
+ const { canBuy: n, offer: s } = e;
160
+ return n ? /* @__PURE__ */ f("span", { className: p.cta, children: [
161
+ /* @__PURE__ */ o(g, { theme: "light", type: "tertiary", block: !0, className: p.ctaButton, onClick: () => a(se), children: t }),
162
+ s != null && s.price ? /* @__PURE__ */ f("span", { className: p.ctaTag, children: [
163
+ Wt(s.price),
164
+ "起"
165
+ ] }) : null
166
+ ] }) : /* @__PURE__ */ o("span", { className: p.ownerOnly, children: "请团队所有者在统一账号中心续费" });
167
+ }, W = ({
168
+ membership: e,
169
+ extra: t,
170
+ onOpen: a
171
+ }) => {
172
+ const { wallet: n } = e, s = n.isPending ? "…" : n.data ? N(n.data.availablePoints) : "暂不可用";
173
+ return /* @__PURE__ */ f("div", { className: p.assets, children: [
174
+ /* @__PURE__ */ f(g, { theme: "borderless", type: "tertiary", className: p.asset, "aria-label": `可用积分 ${s},查看积分与明细`, onClick: () => a(Sn), children: [
175
+ /* @__PURE__ */ o("span", { className: p.coin, "aria-hidden": "true" }),
176
+ /* @__PURE__ */ o("span", { className: p.assetLabel, children: "积分" }),
177
+ /* @__PURE__ */ o("span", { className: p.assetValue, children: s }),
178
+ /* @__PURE__ */ o(Q, { className: p.assetArrow, "aria-hidden": "true" })
179
+ ] }),
180
+ t ? /* @__PURE__ */ f(ke, { children: [
181
+ /* @__PURE__ */ o("span", { className: p.assetDivider, "aria-hidden": "true" }),
182
+ /* @__PURE__ */ f(g, { theme: "borderless", type: "tertiary", className: p.asset, "data-tone": t.tone, onClick: t.onClick ?? (() => a(se)), children: [
183
+ /* @__PURE__ */ o("span", { className: p.assetValue, children: t.label }),
184
+ /* @__PURE__ */ o(Q, { className: p.assetArrow, "aria-hidden": "true" })
185
+ ] })
186
+ ] }) : null
187
+ ] });
188
+ }, Cn = ({ membership: e, onOpen: t }) => {
189
+ const a = Se(), { state: n, offer: s, currentPlan: r, subscription: c } = e;
190
+ if (n.kind === "loading")
191
+ return /* @__PURE__ */ o("div", { className: p.loading, children: /* @__PURE__ */ o(pe, { loading: !0, active: !0, placeholder: /* @__PURE__ */ o(pe.Paragraph, { rows: 3 }) }) });
192
+ if (n.kind === "error")
193
+ return /* @__PURE__ */ f("div", { className: p.plain, children: [
194
+ /* @__PURE__ */ f("div", { className: p.plainBody, children: [
195
+ /* @__PURE__ */ o("span", { className: p.plainText, children: "套餐信息暂时读不到" }),
196
+ /* @__PURE__ */ o(g, { theme: "borderless", type: "tertiary", size: "small", className: p.retry, onClick: () => void c.refetch(), children: "重试" })
197
+ ] }),
198
+ /* @__PURE__ */ o(W, { membership: e, onOpen: t })
199
+ ] });
200
+ if (n.kind === "member") {
201
+ const { subscription: _, daysLeft: y } = n, T = y !== null && y <= Vt, C = (r == null ? void 0 : r.monthlyPoints) ?? 0;
202
+ return /* @__PURE__ */ f("div", { className: `${p.member} semi-always-light`, "data-expiring": T ? "true" : "false", children: [
203
+ /* @__PURE__ */ o("span", { className: p.memberArt, "aria-hidden": "true" }),
204
+ /* @__PURE__ */ f("div", { className: p.memberBody, children: [
205
+ /* @__PURE__ */ f("span", { className: p.memberEyebrow, children: [
206
+ "当前会员",
207
+ C > 0 ? ` · 每月 ${N(C)} 积分` : ""
208
+ ] }),
209
+ /* @__PURE__ */ o("span", { className: p.memberTitle, children: X(_) }),
210
+ /* @__PURE__ */ o("span", { className: p.memberMeta, children: Ut(_) }),
211
+ e.canBuy ? /* @__PURE__ */ o(g, { theme: "light", type: "tertiary", size: "small", className: p.memberCta, onClick: () => t(se), children: T ? "立即续费" : s ? "续费或升级" : "续费" }) : null
212
+ ] }),
213
+ /* @__PURE__ */ o(
214
+ W,
215
+ {
216
+ membership: e,
217
+ onOpen: t,
218
+ extra: y === null ? void 0 : { label: y === 0 ? "今天到期" : `剩余 ${y} 天`, tone: T ? "warning" : void 0 }
219
+ }
220
+ )
221
+ ] });
222
+ }
223
+ const l = n.kind === "team-expired", i = l ? "团队版已到期" : s ? `升级${s.plan.name},畅享更多` : "开通会员畅享", m = l ? "续费后团队成员继续共用套餐和积分" : qt(s == null ? void 0 : s.plan, e.plans.data ?? [], a).join(" · "), d = l ? 0 : (r == null ? void 0 : r.monthlyPoints) ?? 0;
224
+ return /* @__PURE__ */ f("div", { className: p.promo, "data-tone": l ? "team" : "free", children: [
225
+ /* @__PURE__ */ o("span", { className: p.promoArt, "aria-hidden": "true" }),
226
+ /* @__PURE__ */ f("div", { className: p.promoBody, children: [
227
+ /* @__PURE__ */ o("span", { className: p.promoTitle, children: i }),
228
+ /* @__PURE__ */ o("span", { className: p.promoText, children: m }),
229
+ /* @__PURE__ */ o(Tn, { membership: e, text: l ? "续费团队版" : "立即开通会员", onOpen: t })
230
+ ] }),
231
+ /* @__PURE__ */ o(W, { membership: e, onOpen: t, extra: d > 0 ? { label: `免费版每月赠 ${N(d)}` } : void 0 })
232
+ ] });
233
+ }, An = "个人空间", R = (e) => e.type === "team", Z = (e) => e.type === "personal" ? An : e.name || e.slug, Ln = { owner: "所有者", admin: "管理员", member: "成员" }, ya = (e) => e ? Ln[e] ?? "" : "", En = (e) => !!(e && (e.type === "personal" || e.role === "owner")), Pn = () => {
234
+ const [e, t] = M(!1), a = Ce(), { accountApi: n, config: s } = w(), r = async () => {
235
+ if (e) return;
236
+ t(!0), Xe();
237
+ let l = s.routes.publicHome;
238
+ try {
239
+ const { endSessionUrl: i } = await n.logout();
240
+ i && (l = i);
241
+ } catch (i) {
242
+ if (!Te(i, 401)) {
243
+ Ze(), Ne.error("退出失败,请重试"), t(!1);
244
+ return;
245
+ }
246
+ }
247
+ return Je(), await a.cancelQueries().catch(() => {
248
+ }), Ae(), window.location.assign(l), new Promise(() => {
249
+ });
250
+ };
251
+ return { confirmLogout: () => {
252
+ e || Me.confirm({
253
+ title: "退出登录",
254
+ content: "将同时退出 24.city 统一账号并回到首页,再次进入工作台需要重新登录。",
255
+ okText: "退出登录",
256
+ cancelText: "取消",
257
+ okButtonProps: { type: "danger" },
258
+ onOk: r
259
+ });
260
+ }, logout: r, pending: e };
261
+ }, j = (e) => typeof e == "object" && e !== null && !Array.isArray(e), In = (e) => {
262
+ if (!Te(e, 403) || !j(e) || !j(e.response)) return !1;
263
+ const t = e.response.data;
264
+ return j(t) && t.reason === "team_subscription_required";
265
+ }, P = {
266
+ profile: (e) => ["product-profile", e],
267
+ wallet: (e, t) => ["product-wallet", e, t],
268
+ subscription: (e, t) => ["product-subscription", e, t],
269
+ plans: ["product-plans"]
270
+ }, xn = () => {
271
+ const { accountApi: e } = w(), { session: t, spaces: a } = I(), n = (t == null ? void 0 : t.activeSpaceId) ?? "", s = (t == null ? void 0 : t.globalUserId) ?? "", r = (t == null ? void 0 : t.purpose) === "user" && !!(n && s), c = a.find((d) => d.id === n), l = L({
272
+ queryKey: P.profile(s),
273
+ queryFn: () => e.getProfile(),
274
+ enabled: !!s,
275
+ staleTime: 1 / 0
276
+ }), i = L({
277
+ queryKey: P.wallet(n, s),
278
+ queryFn: () => e.getWallet(),
279
+ enabled: r
280
+ }), m = L({
281
+ queryKey: P.subscription(n, s),
282
+ queryFn: () => e.getSubscription(),
283
+ enabled: r
284
+ });
285
+ return { session: t, allowed: r, activeSpace: c, activeSpaceId: n, globalUserId: s, profile: l, wallet: i, subscription: m };
286
+ }, $n = 5 * 6e4, On = (e) => {
287
+ const { accountApi: t } = w();
288
+ return L({
289
+ queryKey: P.plans,
290
+ queryFn: () => t.getPlans(),
291
+ enabled: e,
292
+ staleTime: $n
293
+ });
294
+ }, Ee = () => {
295
+ var y;
296
+ const { config: e } = w(), t = xn(), { activeSpace: a, subscription: n, allowed: s } = t, r = On(s), c = a ? R(a) : !1, l = c ? "team" : "personal";
297
+ let i;
298
+ !s || n.isPending ? i = { kind: "loading" } : n.isError ? i = In(n.error) ? { kind: "team-expired" } : { kind: "error" } : !n.data || n.data.isDefault ? i = { kind: "free", subscription: n.data ?? null } : i = { kind: "member", subscription: n.data, daysLeft: Ft(n.data) };
299
+ const m = i.kind === "free" || i.kind === "member" ? ((y = i.subscription) == null ? void 0 : y.tier) ?? null : null, d = i.kind === "free" || i.kind === "member" || i.kind === "team-expired" ? Gt(r.data, l, m) : null, _ = (i.kind === "free" || i.kind === "member") && i.subscription ? Yt(r.data, i.subscription) : void 0;
300
+ return {
301
+ ...t,
302
+ plans: r,
303
+ state: i,
304
+ offer: d,
305
+ currentPlan: _,
306
+ team: c,
307
+ /** 个人空间是自己的;团队空间只有所有者能买(STD-BILLING-001) */
308
+ canBuy: En(a),
309
+ /** 「订阅与套餐」的站内地址 */
310
+ subscriptionPath: v(e.routes.app, "subscription")
311
+ };
312
+ }, Bn = () => {
313
+ const e = Ce(), t = et(), { session: a } = I(), { accountApi: n } = w(), [s, r] = M(!1), c = be(0), l = a == null ? void 0 : a.activeSpaceId, i = ve(
314
+ async (m) => {
315
+ if (!m || m === l || s) return;
316
+ const d = ++c.current;
317
+ r(!0);
318
+ try {
319
+ if (await e.cancelQueries(), e.clear(), (await n.switchSpace(m)).activeSpaceId !== m) throw new Error("空间切换响应与请求不一致");
320
+ const y = await _e(n);
321
+ if (c.current !== d) return;
322
+ t.setContext(y), Ae();
323
+ } catch {
324
+ if (c.current !== d) return;
325
+ try {
326
+ const _ = await _e(n);
327
+ e.clear(), t.setContext(_), _.session.activeSpaceId !== m && Ne.error("空间切换失败,请稍后重试");
328
+ } catch {
329
+ e.clear(), t.clear({ unavailable: !0 });
330
+ }
331
+ } finally {
332
+ c.current === d && r(!1);
333
+ }
334
+ },
335
+ [n, l, t, e, s]
336
+ );
337
+ return { switching: s, switchSpace: i };
338
+ }, G = "我的账号", Dn = 80, Mn = 200, Y = ({ space: e }) => /* @__PURE__ */ f(ke, { children: [
339
+ /* @__PURE__ */ o("span", { className: u.spaceName, children: Z(e) }),
340
+ R(e) ? /* @__PURE__ */ o("span", { className: u.spaceType, children: "团队" }) : null
341
+ ] }), he = ({ nickName: e, member: t, size: a }) => /* @__PURE__ */ o("span", { className: u.avatarWrap, "data-member": t ? "true" : "false", "data-size": a > 40 ? "large" : "small", children: /* @__PURE__ */ o(Ue, { size: "small", shape: "circle", className: u.avatar, style: { width: a, height: a }, children: e ? Array.from(e)[0] : /* @__PURE__ */ o(U, { "aria-hidden": "true" }) }) }), Un = ({ state: e }) => e.kind === "member" ? /* @__PURE__ */ f("span", { className: u.planChip, "data-tone": "member", children: [
342
+ /* @__PURE__ */ o("span", { className: u.diamond, "aria-hidden": "true" }),
343
+ X(e.subscription)
344
+ ] }) : e.kind === "free" ? /* @__PURE__ */ o("span", { className: u.planChip, "data-tone": "free", children: e.subscription ? X(e.subscription) : "未开通" }) : e.kind === "team-expired" ? /* @__PURE__ */ o("span", { className: u.planChip, "data-tone": "warning", children: "团队版已到期" }) : null, ga = ({ personal: e, selectedKey: t, onOpen: a }) => {
345
+ var ue;
346
+ const { config: n } = w(), s = Se(), r = ne(), c = e ?? $t(n.routes.app, xt(s)), l = Ee(), { profile: i, state: m } = l, { session: d, spaces: _ } = I(), { confirmLogout: y, pending: T } = Pn(), { switching: C, switchSpace: xe } = Bn(), { darkAvailable: $e } = He(), [V, x] = M(!1), [z, $] = M(!1), A = be(void 0), K = ((ue = i.data) == null ? void 0 : ue.nickName) ?? "", O = K || (i.isPending ? "" : G), oe = (d == null ? void 0 : d.activeSpaceId) ?? "", k = _.find((h) => h.id === oe), re = _.length > 1, ce = m.kind === "member", { AccountAllowance: ie } = s, S = () => {
347
+ A.current !== void 0 && (window.clearTimeout(A.current), A.current = void 0);
348
+ };
349
+ te(() => S, []);
350
+ const B = () => {
351
+ S(), x(!1), $(!1);
352
+ }, Oe = () => {
353
+ S(), A.current = window.setTimeout(() => x(!0), Dn);
354
+ }, le = () => {
355
+ S(), A.current = window.setTimeout(() => {
356
+ x(!1), $(!1);
357
+ }, Mn);
358
+ }, de = (h) => {
359
+ if (B(), a) {
360
+ a(h);
361
+ return;
362
+ }
363
+ const b = c.items.find((De) => De.key === h);
364
+ b && r(b.to);
365
+ }, Be = /* @__PURE__ */ f("div", { className: u.card, role: "dialog", "aria-label": "账号", onMouseEnter: S, onMouseLeave: le, children: [
366
+ /* @__PURE__ */ f("div", { className: u.identity, children: [
367
+ /* @__PURE__ */ o(he, { nickName: K, member: ce, size: 52 }),
368
+ /* @__PURE__ */ f("div", { className: u.who, children: [
369
+ /* @__PURE__ */ f("div", { className: u.nameRow, children: [
370
+ /* @__PURE__ */ o("span", { className: u.name, title: O || G, children: O || G }),
371
+ /* @__PURE__ */ o(Un, { state: m })
372
+ ] }),
373
+ k ? re ? /* @__PURE__ */ f(
374
+ g,
375
+ {
376
+ theme: "borderless",
377
+ type: "tertiary",
378
+ size: "small",
379
+ className: u.spaceToggle,
380
+ "aria-expanded": z,
381
+ "aria-label": `当前空间:${Z(k)},切换空间`,
382
+ onClick: () => $((h) => !h),
383
+ children: [
384
+ R(k) ? /* @__PURE__ */ o(me, { "aria-hidden": "true" }) : /* @__PURE__ */ o(U, { "aria-hidden": "true" }),
385
+ /* @__PURE__ */ o(Y, { space: k }),
386
+ /* @__PURE__ */ o("span", { className: u.spaceSwitchText, children: "切换" }),
387
+ z ? /* @__PURE__ */ o(Ke, { "aria-hidden": "true" }) : /* @__PURE__ */ o(We, { "aria-hidden": "true" })
388
+ ]
389
+ }
390
+ ) : /* @__PURE__ */ f("span", { className: u.spaceStatic, "aria-label": `当前空间:${Z(k)}`, children: [
391
+ R(k) ? /* @__PURE__ */ o(me, { "aria-hidden": "true" }) : /* @__PURE__ */ o(U, { "aria-hidden": "true" }),
392
+ /* @__PURE__ */ o(Y, { space: k })
393
+ ] }) : null
394
+ ] })
395
+ ] }),
396
+ re && z ? /* @__PURE__ */ o("div", { className: u.spaceList, role: "group", "aria-label": "切换空间", children: _.map((h) => {
397
+ const b = h.id === oe;
398
+ return /* @__PURE__ */ f(
399
+ g,
400
+ {
401
+ theme: "borderless",
402
+ type: "tertiary",
403
+ block: !0,
404
+ className: u.spaceOption,
405
+ "aria-current": b ? "true" : void 0,
406
+ disabled: C && !b,
407
+ onClick: () => {
408
+ b || (B(), xe(h.id));
409
+ },
410
+ children: [
411
+ /* @__PURE__ */ o("span", { className: u.spaceCheck, children: b ? /* @__PURE__ */ o(je, { "aria-hidden": "true" }) : null }),
412
+ /* @__PURE__ */ o(Y, { space: h })
413
+ ]
414
+ },
415
+ h.id
416
+ );
417
+ }) }) : null,
418
+ /* @__PURE__ */ o("div", { className: u.plan, children: /* @__PURE__ */ o(Cn, { membership: l, onOpen: de }) }),
419
+ ie && d ? /* @__PURE__ */ o("div", { className: u.allowance, children: /* @__PURE__ */ o(ie, { activeSpaceId: d.activeSpaceId, globalUserId: d.globalUserId }) }) : null,
420
+ /* @__PURE__ */ o("div", { className: u.links, role: "group", "aria-label": c.label, children: c.items.map((h) => /* @__PURE__ */ f(
421
+ g,
422
+ {
423
+ theme: "borderless",
424
+ type: "tertiary",
425
+ block: !0,
426
+ className: u.link,
427
+ "aria-current": h.key === t ? "page" : void 0,
428
+ onClick: () => de(h.key),
429
+ children: [
430
+ h.icon ? /* @__PURE__ */ o("span", { className: u.linkIcon, "aria-hidden": "true", children: /* @__PURE__ */ o(h.icon, {}) }) : null,
431
+ /* @__PURE__ */ o("span", { className: u.linkLabel, children: h.label }),
432
+ /* @__PURE__ */ o(Q, { className: u.linkArrow, "aria-hidden": "true" })
433
+ ]
434
+ },
435
+ h.key
436
+ )) }),
437
+ $e ? /* @__PURE__ */ f("div", { className: u.appearance, children: [
438
+ /* @__PURE__ */ o("span", { className: u.linkIcon, "aria-hidden": "true", children: /* @__PURE__ */ o(Ge, {}) }),
439
+ /* @__PURE__ */ o("span", { className: u.linkLabel, children: "外观" }),
440
+ /* @__PURE__ */ o(qe, {})
441
+ ] }) : null,
442
+ /* @__PURE__ */ o("div", { className: u.divider, "aria-hidden": "true" }),
443
+ /* @__PURE__ */ o(
444
+ g,
445
+ {
446
+ theme: "borderless",
447
+ type: "tertiary",
448
+ block: !0,
449
+ className: u.logout,
450
+ disabled: T,
451
+ onClick: () => {
452
+ B(), y();
453
+ },
454
+ children: "退出登录"
455
+ }
456
+ )
457
+ ] });
458
+ return /* @__PURE__ */ o(
459
+ Re,
460
+ {
461
+ trigger: "custom",
462
+ visible: V,
463
+ position: "bottomRight",
464
+ showArrow: !1,
465
+ spacing: 8,
466
+ className: u.popover,
467
+ content: Be,
468
+ onClickOutSide: B,
469
+ children: /* @__PURE__ */ o(
470
+ g,
471
+ {
472
+ theme: "borderless",
473
+ type: "tertiary",
474
+ className: u.trigger,
475
+ "aria-label": O ? `${O},账号菜单` : "账号菜单",
476
+ "aria-haspopup": "dialog",
477
+ "aria-expanded": V,
478
+ loading: C,
479
+ onMouseEnter: Oe,
480
+ onMouseLeave: le,
481
+ onClick: () => {
482
+ S(), x((h) => !h), V && $(!1);
483
+ },
484
+ children: /* @__PURE__ */ o(he, { nickName: K, member: ce, size: 34 })
485
+ }
486
+ )
487
+ }
488
+ );
489
+ }, J = "page.viewed", ee = 2e3, F = 20, Rn = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `evt-${Date.now()}-${Math.random().toString(36).slice(2, 12)}`, Pe = (e) => {
490
+ var t;
491
+ return typeof e == "object" && e !== null && "response" in e ? (t = e.response) == null ? void 0 : t.status : void 0;
492
+ }, Fn = (e, t) => {
493
+ let a;
494
+ try {
495
+ a = new URL(e);
496
+ } catch {
497
+ return;
498
+ }
499
+ const n = (c) => (a.searchParams.get(c) ?? "").trim().slice(0, 64);
500
+ let s = "";
501
+ try {
502
+ const c = t ? new URL(t) : void 0;
503
+ c && c.host !== a.host && (s = c.hostname);
504
+ } catch {
505
+ s = "";
506
+ }
507
+ const r = {};
508
+ return s && (r.referrerHost = s), n("utm_source") && (r.utmSource = n("utm_source")), n("utm_medium") && (r.utmMedium = n("utm_medium")), n("utm_campaign") && (r.utmCampaign = n("utm_campaign")), Object.keys(r).length > 0 ? r : void 0;
509
+ };
510
+ let ye = typeof window < "u" ? Fn(window.location.href, document.referrer) : void 0;
511
+ const Vn = () => {
512
+ const e = ye;
513
+ return ye = void 0, e;
514
+ }, zn = (e, t) => {
515
+ let a = [], n, s = !1, r = t === void 0 ? Vn() : t ?? void 0;
516
+ const c = async () => {
517
+ if (n && clearTimeout(n), n = void 0, s || a.length === 0) return;
518
+ const i = a.splice(0, F);
519
+ try {
520
+ await e(i);
521
+ } catch (m) {
522
+ Pe(m) === 404 && (s = !0, a = []);
523
+ }
524
+ a.length > 0 && c();
525
+ }, l = (i, m = (/* @__PURE__ */ new Date()).toISOString()) => {
526
+ if (!s) {
527
+ if (a.push({ path: i, occurredAt: m, ...r ?? {} }), r = void 0, a.length >= F) {
528
+ c();
529
+ return;
530
+ }
531
+ n || (n = setTimeout(() => void c(), ee));
532
+ }
533
+ };
534
+ return typeof window < "u" && window.addEventListener("pagehide", () => void c()), { pageView: l, flush: c };
535
+ }, Kn = (e, t = !0, a) => {
536
+ let n = [], s, r = !1, c = t;
537
+ const l = async () => {
538
+ if (s && clearTimeout(s), s = void 0, r || c !== !0 || n.length === 0) return;
539
+ const d = n.splice(0, F);
540
+ try {
541
+ await e(d);
542
+ } catch (_) {
543
+ Pe(_) === 404 && (r = !0, n = []);
544
+ }
545
+ n.length > 0 && l();
546
+ }, i = (d, _ = {}) => {
547
+ if (c === !1) {
548
+ d === J && (a == null || a.pageView(_.target || "/"));
549
+ return;
550
+ }
551
+ if (r) return;
552
+ const y = { eventId: Rn(), name: d, occurredAt: (/* @__PURE__ */ new Date()).toISOString() };
553
+ if (_.target && (y.target = _.target), _.props && Object.keys(_.props).length > 0 && (y.props = _.props), n.push(y), n.length >= F) {
554
+ l();
555
+ return;
556
+ }
557
+ s || (s = setTimeout(() => void l(), ee));
558
+ }, m = (d) => {
559
+ if (d !== c) {
560
+ if (c = d, d === !1) {
561
+ for (const _ of n)
562
+ _.name === J && (a == null || a.pageView(_.target || "/", _.occurredAt));
563
+ n = [];
564
+ }
565
+ d === !0 && n.length > 0 && !s && (s = setTimeout(() => void l(), ee));
566
+ }
567
+ };
568
+ return typeof window < "u" && window.addEventListener("pagehide", () => void l()), { track: i, flush: l, setSignedIn: m };
569
+ }, ge = /* @__PURE__ */ new WeakMap(), we = (e) => {
570
+ const t = e.reportBehaviorEvents, a = e.reportVisits;
571
+ if (!t && !a) return;
572
+ let n = ge.get(e);
573
+ if (!n) {
574
+ const s = a ? zn((r) => a.call(e, r)) : void 0;
575
+ n = Kn(
576
+ t ? (r) => t.call(e, r) : () => Promise.resolve(),
577
+ void 0,
578
+ s
579
+ ), ge.set(e, n);
580
+ }
581
+ return n;
582
+ }, Ie = () => {
583
+ const { accountApi: e } = w(), { session: t, bootstrapped: a } = I(), n = a ? !!t : void 0;
584
+ return te(() => {
585
+ var s;
586
+ (s = we(e)) == null || s.setSignedIn(n);
587
+ }, [e, n]), ve((s, r) => {
588
+ var c;
589
+ return (c = we(e)) == null ? void 0 : c.track(s, r);
590
+ }, [e]);
591
+ }, wa = () => {
592
+ const { pathname: e } = Ye(), t = Ie();
593
+ te(() => {
594
+ t(J, { target: Gn(e) });
595
+ }, [e, t]);
596
+ }, Wn = /^(?:\d{2,}|[0-9a-f]{12,}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|(?=[A-Za-z0-9_-]*\d)[A-Za-z0-9_-]{16,})$/i, jn = /^[A-Za-z0-9_.-]*$/, Gn = (e) => (e.split("/").map((n) => Wn.test(n) || !jn.test(n) ? ":id" : n).join("/").replace(/\/+$/, "") || "/").slice(0, 128), Yn = "_upgrade_1dxl7_2", qn = "_crown_1dxl7_25", Hn = "_text_1dxl7_37", q = {
597
+ upgrade: Yn,
598
+ crown: qn,
599
+ text: Hn
600
+ }, ka = () => {
601
+ const { config: e } = w(), t = ne(), { state: a, canBuy: n } = Ee(), s = Ie();
602
+ if (!n || a.kind !== "free" && a.kind !== "team-expired") return null;
603
+ const r = a.kind === "team-expired" ? "续费团队版" : "开通会员";
604
+ return /* @__PURE__ */ f(
605
+ g,
606
+ {
607
+ theme: "light",
608
+ type: "tertiary",
609
+ className: q.upgrade,
610
+ onClick: () => {
611
+ s("upgrade_entry.clicked", { target: a.kind }), t(v(e.routes.app, "subscription"));
612
+ },
613
+ children: [
614
+ /* @__PURE__ */ o("span", { className: q.crown, "aria-hidden": "true" }),
615
+ /* @__PURE__ */ o("span", { className: q.text, children: r })
616
+ ]
617
+ }
618
+ );
619
+ }, Qn = "_wallet_e6uma_2", Xn = "_coin_e6uma_25", Zn = "_value_e6uma_32", H = {
620
+ wallet: Qn,
621
+ coin: Xn,
622
+ value: Zn
623
+ }, ba = () => {
624
+ const { accountApi: e, config: t } = w(), { session: a } = I(), n = ne(), s = (a == null ? void 0 : a.activeSpaceId) ?? "", r = (a == null ? void 0 : a.globalUserId) ?? "", c = L({
625
+ queryKey: P.wallet(s, r),
626
+ queryFn: () => e.getWallet(),
627
+ enabled: !!a,
628
+ refetchOnWindowFocus: !0
629
+ });
630
+ if (!a) return null;
631
+ const l = c.isPending ? "读取中" : c.data ? N(c.data.availablePoints) : "积分暂不可用";
632
+ return /* @__PURE__ */ o(Fe, { content: "当前空间可用积分,由统一账号中心记账", children: /* @__PURE__ */ f(
633
+ g,
634
+ {
635
+ theme: "light",
636
+ type: "tertiary",
637
+ className: H.wallet,
638
+ "aria-label": c.data ? `积分 ${l}` : l,
639
+ onClick: () => n(v(t.routes.app, "points")),
640
+ children: [
641
+ /* @__PURE__ */ o("span", { className: H.coin, "aria-hidden": "true" }),
642
+ /* @__PURE__ */ o("span", { className: H.value, children: l })
643
+ ]
644
+ }
645
+ ) });
646
+ };
647
+ export {
648
+ Et as A,
649
+ fa as B,
650
+ _a as C,
651
+ Ut as D,
652
+ Vt as E,
653
+ G as F,
654
+ X as G,
655
+ xt as H,
656
+ ma as I,
657
+ ua as J,
658
+ pa as K,
659
+ Fn as L,
660
+ Z as M,
661
+ ya as N,
662
+ jt as O,
663
+ J as P,
664
+ Gt as Q,
665
+ xn as R,
666
+ Pn as S,
667
+ Ee as T,
668
+ Ot as U,
669
+ On as V,
670
+ ba as W,
671
+ Bn as X,
672
+ Ie as Y,
673
+ wa as Z,
674
+ he as a,
675
+ ga as b,
676
+ E as c,
677
+ An as d,
678
+ Cn as e,
679
+ ka as f,
680
+ P as g,
681
+ v as h,
682
+ Gn as i,
683
+ $t as j,
684
+ En as k,
685
+ Yt as l,
686
+ Kn as m,
687
+ zn as n,
688
+ ha as o,
689
+ Mt as p,
690
+ Kt as q,
691
+ Wt as r,
692
+ da as s,
693
+ Pt as t,
694
+ R as u,
695
+ In as v,
696
+ ae as w,
697
+ qt as x,
698
+ D as y,
699
+ Ft as z
700
+ };