@24city/web-console 0.3.13 → 0.3.14

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