@24city/web-console 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.
@@ -0,0 +1,565 @@
1
+ import { jsx as s, jsxs as m, Fragment as me } from "react/jsx-runtime";
2
+ import { useState as B, useRef as pe, useCallback as Se, useEffect as Te } from "react";
3
+ import { Skeleton as re, Button as b, Toast as _e, Modal as Ae, Avatar as Pe, Popover as xe, Tooltip as Le } from "@douyinfe/semi-ui";
4
+ import { IconUser as D, IconCrown as Ee, IconGift as Ie, IconChevronRight as V, IconUserGroup as ie, IconChevronUp as $e, IconChevronDown as ze, IconTick as Oe } from "@douyinfe/semi-icons";
5
+ import { useNavigate as J } from "react-router";
6
+ import { a as fe, b as g } from "./context-CaVim6ZO.js";
7
+ import { q as v, k as Be, a as De, t as he, w as Me, l as Fe, u as F, g as Re, f as le } from "./logout-signal-CiD_zY5M.js";
8
+ import { useQueryClient as ye, useQuery as P } from "@tanstack/react-query";
9
+ import { notifyCustomerSessionChanged as be } from "@24city/web-runtime/session-sync";
10
+ const Ue = "_trigger_am2co_6", Ke = "_avatarWrap_am2co_27", qe = "_avatar_am2co_27", We = "_card_am2co_74", Ye = "_identity_am2co_84", Ge = "_who_am2co_92", je = "_nameRow_am2co_101", Qe = "_name_am2co_101", Ve = "_planChip_am2co_118", He = "_diamond_am2co_148", Xe = "_spaceToggle_am2co_156", Je = "_spaceStatic_am2co_157", Ze = "_spaceSwitchText_am2co_178", et = "_spaceName_am2co_184", tt = "_spaceType_am2co_190", nt = "_spaceList_am2co_200", at = "_spaceOption_am2co_209", st = "_spaceCheck_am2co_231", ot = "_plan_am2co_118", ct = "_links_am2co_243", rt = "_link_am2co_243", it = "_linkIcon_am2co_281", lt = "_linkLabel_am2co_292", dt = "_linkArrow_am2co_297", ut = "_divider_am2co_303", mt = "_logout_am2co_309", l = {
11
+ trigger: Ue,
12
+ avatarWrap: Ke,
13
+ avatar: qe,
14
+ card: We,
15
+ identity: Ye,
16
+ who: Ge,
17
+ nameRow: je,
18
+ name: Qe,
19
+ planChip: Ve,
20
+ diamond: He,
21
+ spaceToggle: Xe,
22
+ spaceStatic: Je,
23
+ spaceSwitchText: Ze,
24
+ spaceName: et,
25
+ spaceType: tt,
26
+ spaceList: nt,
27
+ spaceOption: at,
28
+ spaceCheck: st,
29
+ plan: ot,
30
+ links: ct,
31
+ link: rt,
32
+ linkIcon: it,
33
+ linkLabel: lt,
34
+ linkArrow: dt,
35
+ divider: ut,
36
+ logout: mt
37
+ }, pt = ["profile", "subscription", "points"], _t = (e) => pt.includes(e), N = (e, t) => `${e}/account/${t}`, Mn = (e, t) => t === `${e}/account` || t.startsWith(`${e}/account/`), O = (e) => `account-${e}`, x = {
38
+ profile: O("profile"),
39
+ subscription: O("subscription"),
40
+ points: O("points")
41
+ }, ft = /^[a-z][a-z0-9-]{0,31}$/, ht = (e) => {
42
+ const t = e.accountSections ?? [], n = /* @__PURE__ */ new Set();
43
+ for (const a of t) {
44
+ if (!ft.test(a.key))
45
+ throw new Error(`个人中心分区 key 不合法:${a.key}(小写字母开头,只含小写字母、数字和连字符)`);
46
+ if (_t(a.key)) throw new Error(`个人中心分区 key 与内置分区重名:${a.key}`);
47
+ if (n.has(a.key)) throw new Error(`个人中心分区 key 重复:${a.key}`);
48
+ n.add(a.key);
49
+ }
50
+ return t;
51
+ }, yt = (e, t = []) => ({
52
+ key: "personal",
53
+ label: "个人中心",
54
+ items: [
55
+ { key: x.profile, label: "账号与安全", to: N(e, "profile"), icon: D },
56
+ { key: x.subscription, label: "订阅与套餐", to: N(e, "subscription"), icon: Ee },
57
+ { key: x.points, label: "积分与明细", to: N(e, "points"), icon: Ie },
58
+ ...t.map(
59
+ (n) => ({
60
+ key: O(n.key),
61
+ label: n.label,
62
+ to: N(e, n.key),
63
+ icon: n.icon
64
+ })
65
+ )
66
+ ]
67
+ }), bt = 1e6, Z = (e) => e != null && e >= bt, Fn = (e) => !!e && e.limit !== null && e.used >= e.limit, Rn = (e, t) => e.limit === null ? `已有 ${e.used} ${t}` : e.limit === 0 && e.used === 0 ? "套餐未包含" : Z(e.limit) ? `已有 ${e.used} ${t} · 不限` : `已用 ${e.used}/${e.limit}`, Un = (e, t) => (n) => n !== null && Z(n) ? t : e(v(n ?? 0)), ge = (e, t) => e.find((n) => n.key === t), de = (e, t) => {
68
+ const n = e.findIndex((a) => a.key === t);
69
+ return n === -1 ? e.length : n;
70
+ }, gt = (e, t) => {
71
+ const n = ge(e, t.key), a = n ? n.on(t.limit) : t.limit === null ? t.name : `${t.name} ${Z(t.limit) ? "不限" : v(t.limit)}`;
72
+ return t.discounts.length ? `${a}(${t.discounts.join("、")})` : a;
73
+ }, kt = (e) => {
74
+ if (e.length < 2) return /* @__PURE__ */ new Set();
75
+ const t = new Set(e.flatMap((n) => n.benefits.filter((a) => a.limit === null).map((a) => a.key)));
76
+ return new Set(
77
+ [...t].filter((n) => e.every((a) => a.benefits.some((o) => o.key === n && o.limit === null)))
78
+ );
79
+ }, wt = (e, t = [], n = {}) => {
80
+ var u;
81
+ const a = n.benefitCopy ?? [], o = kt(t), c = [];
82
+ for (const r of [...e.benefits, ...t.flatMap((p) => p.benefits)])
83
+ !c.includes(r.key) && !o.has(r.key) && c.push(r.key);
84
+ const d = [];
85
+ for (const r of [...c].sort((p, _) => de(a, p) - de(a, _) || c.indexOf(p) - c.indexOf(_))) {
86
+ const p = e.benefits.find((h) => h.key === r);
87
+ if (p) {
88
+ d.push({ text: gt(a, p), included: !0 });
89
+ continue;
90
+ }
91
+ const _ = (u = ge(a, r)) == null ? void 0 : u.off;
92
+ _ && d.push({ text: _, included: !1 });
93
+ }
94
+ return d;
95
+ }, H = (e) => e.planName || e.planCode, Nt = (e) => e.isDefault || !e.currentPeriodEnd ? "长期有效" : `有效期至 ${Be(e.currentPeriodEnd)}`, vt = 1440 * 60 * 1e3, Ct = (e, t = Date.now()) => {
96
+ if (e.isDefault || !e.currentPeriodEnd) return null;
97
+ const n = Date.parse(e.currentPeriodEnd);
98
+ return Number.isFinite(n) ? Math.max(0, Math.ceil((n - t) / vt)) : null;
99
+ }, St = 7, Tt = { month: "/月", year: "/年", one_time: "" }, At = (e) => {
100
+ const t = (e.amountCents / 100).toLocaleString("zh-CN", { maximumFractionDigits: 2 });
101
+ return e.currency === "CNY" ? `¥${t}` : `${e.currency} ${t}`;
102
+ }, Kn = (e) => e ? { focusPlan: e } : void 0, qn = (e) => {
103
+ if (typeof e != "object" || e === null) return;
104
+ const t = e.focusPlan;
105
+ return typeof t == "string" && t ? t : void 0;
106
+ }, Pt = (e) => `${At(e)}${Tt[e.billingPeriod]}`, xt = (e) => {
107
+ const t = e.prices.filter((o) => o.amountCents > 0), n = t.filter((o) => o.billingPeriod === "month");
108
+ return (n.length ? n : t).reduce((o, c) => !o || c.amountCents < o.amountCents ? c : o, null);
109
+ }, Lt = (e, t, n) => {
110
+ const o = (e ?? []).filter(
111
+ (c) => c.spaceType === t && !c.isDefault && (n === null || c.tier > n)
112
+ ).map((c) => ({ plan: c, price: xt(c) }));
113
+ return o.sort(
114
+ (c, d) => {
115
+ var u, r;
116
+ return c.plan.tier - d.plan.tier || (((u = c.price) == null ? void 0 : u.amountCents) ?? Number.MAX_SAFE_INTEGER) - (((r = d.price) == null ? void 0 : r.amountCents) ?? Number.MAX_SAFE_INTEGER);
117
+ }
118
+ ), o[0] ?? null;
119
+ }, Wn = (e) => e == null ? void 0 : e.filter((t) => t.spaceType === "team" && !t.isDefault).sort((t, n) => t.tier - n.tier)[0], Et = (e, t) => e == null ? void 0 : e.find((n) => n.code === t.planCode), It = (e, t = [], n = {}) => {
120
+ if (!e) return ["积分按月发放", "24.city 全产品通用"];
121
+ const a = [];
122
+ e.monthlyPoints > 0 && a.push(`每月 ${v(e.monthlyPoints)} 积分`);
123
+ for (const o of wt(e, t, n).filter((c) => c.included).slice(0, 2)) a.push(o.text);
124
+ return a.length < 2 && a.push("24.city 全产品通用"), a;
125
+ }, $t = "_promo_10uzf_6", zt = "_member_10uzf_7", Ot = "_plain_10uzf_8", Bt = "_promoArt_10uzf_28", Dt = "_promoBody_10uzf_38", Mt = "_promoTitle_10uzf_44", Ft = "_promoText_10uzf_55", Rt = "_cta_10uzf_63", Ut = "_ctaButton_10uzf_69", Kt = "_ctaTag_10uzf_89", qt = "_ownerOnly_10uzf_106", Wt = "_memberArt_10uzf_122", Yt = "_memberBody_10uzf_132", Gt = "_memberEyebrow_10uzf_139", jt = "_memberTitle_10uzf_145", Qt = "_memberMeta_10uzf_159", Vt = "_memberCta_10uzf_166", Ht = "_plainBody_10uzf_200", Xt = "_plainText_10uzf_207", Jt = "_retry_10uzf_212", Zt = "_loading_10uzf_216", en = "_assets_10uzf_224", tn = "_asset_10uzf_224", nn = "_coin_10uzf_279", an = "_assetLabel_10uzf_287", sn = "_assetValue_10uzf_291", on = "_assetArrow_10uzf_299", cn = "_assetDivider_10uzf_312", i = {
126
+ promo: $t,
127
+ member: zt,
128
+ plain: Ot,
129
+ promoArt: Bt,
130
+ promoBody: Dt,
131
+ promoTitle: Mt,
132
+ promoText: Ft,
133
+ cta: Rt,
134
+ ctaButton: Ut,
135
+ ctaTag: Kt,
136
+ ownerOnly: qt,
137
+ memberArt: Wt,
138
+ memberBody: Yt,
139
+ memberEyebrow: Gt,
140
+ memberTitle: jt,
141
+ memberMeta: Qt,
142
+ memberCta: Vt,
143
+ plainBody: Ht,
144
+ plainText: Xt,
145
+ retry: Jt,
146
+ loading: Zt,
147
+ assets: en,
148
+ asset: tn,
149
+ coin: nn,
150
+ assetLabel: an,
151
+ assetValue: sn,
152
+ assetArrow: on,
153
+ assetDivider: cn
154
+ }, rn = x.points, ee = x.subscription, ln = ({ membership: e, text: t, onOpen: n }) => {
155
+ const { canBuy: a, offer: o } = e;
156
+ return a ? /* @__PURE__ */ m("span", { className: i.cta, children: [
157
+ /* @__PURE__ */ s(b, { theme: "light", type: "tertiary", block: !0, className: i.ctaButton, onClick: () => n(ee), children: t }),
158
+ o != null && o.price ? /* @__PURE__ */ m("span", { className: i.ctaTag, children: [
159
+ Pt(o.price),
160
+ "起"
161
+ ] }) : null
162
+ ] }) : /* @__PURE__ */ s("span", { className: i.ownerOnly, children: "请团队所有者在统一账号中心续费" });
163
+ }, q = ({
164
+ membership: e,
165
+ extra: t,
166
+ onOpen: n
167
+ }) => {
168
+ const { wallet: a } = e, o = a.isPending ? "…" : a.data ? v(a.data.availablePoints) : "暂不可用";
169
+ return /* @__PURE__ */ m("div", { className: i.assets, children: [
170
+ /* @__PURE__ */ m(b, { theme: "borderless", type: "tertiary", className: i.asset, "aria-label": `可用积分 ${o},查看积分与明细`, onClick: () => n(rn), children: [
171
+ /* @__PURE__ */ s("span", { className: i.coin, "aria-hidden": "true" }),
172
+ /* @__PURE__ */ s("span", { className: i.assetLabel, children: "积分" }),
173
+ /* @__PURE__ */ s("span", { className: i.assetValue, children: o }),
174
+ /* @__PURE__ */ s(V, { className: i.assetArrow, "aria-hidden": "true" })
175
+ ] }),
176
+ t ? /* @__PURE__ */ m(me, { children: [
177
+ /* @__PURE__ */ s("span", { className: i.assetDivider, "aria-hidden": "true" }),
178
+ /* @__PURE__ */ m(b, { theme: "borderless", type: "tertiary", className: i.asset, "data-tone": t.tone, onClick: t.onClick ?? (() => n(ee)), children: [
179
+ /* @__PURE__ */ s("span", { className: i.assetValue, children: t.label }),
180
+ /* @__PURE__ */ s(V, { className: i.assetArrow, "aria-hidden": "true" })
181
+ ] })
182
+ ] }) : null
183
+ ] });
184
+ }, dn = ({ membership: e, onOpen: t }) => {
185
+ const n = fe(), { state: a, offer: o, currentPlan: c, subscription: d } = e;
186
+ if (a.kind === "loading")
187
+ return /* @__PURE__ */ s("div", { className: i.loading, children: /* @__PURE__ */ s(re, { loading: !0, active: !0, placeholder: /* @__PURE__ */ s(re.Paragraph, { rows: 3 }) }) });
188
+ if (a.kind === "error")
189
+ return /* @__PURE__ */ m("div", { className: i.plain, children: [
190
+ /* @__PURE__ */ m("div", { className: i.plainBody, children: [
191
+ /* @__PURE__ */ s("span", { className: i.plainText, children: "套餐信息暂时读不到" }),
192
+ /* @__PURE__ */ s(b, { theme: "borderless", type: "tertiary", size: "small", className: i.retry, onClick: () => void d.refetch(), children: "重试" })
193
+ ] }),
194
+ /* @__PURE__ */ s(q, { membership: e, onOpen: t })
195
+ ] });
196
+ if (a.kind === "member") {
197
+ const { subscription: h, daysLeft: y } = a, S = y !== null && y <= St, T = (c == null ? void 0 : c.monthlyPoints) ?? 0;
198
+ return /* @__PURE__ */ m("div", { className: i.member, "data-expiring": S ? "true" : "false", children: [
199
+ /* @__PURE__ */ s("span", { className: i.memberArt, "aria-hidden": "true" }),
200
+ /* @__PURE__ */ m("div", { className: i.memberBody, children: [
201
+ /* @__PURE__ */ m("span", { className: i.memberEyebrow, children: [
202
+ "当前会员",
203
+ T > 0 ? ` · 每月 ${v(T)} 积分` : ""
204
+ ] }),
205
+ /* @__PURE__ */ s("span", { className: i.memberTitle, children: H(h) }),
206
+ /* @__PURE__ */ s("span", { className: i.memberMeta, children: Nt(h) }),
207
+ e.canBuy ? /* @__PURE__ */ s(b, { theme: "light", type: "tertiary", size: "small", className: i.memberCta, onClick: () => t(ee), children: S ? "立即续费" : o ? "续费或升级" : "续费" }) : null
208
+ ] }),
209
+ /* @__PURE__ */ s(
210
+ q,
211
+ {
212
+ membership: e,
213
+ onOpen: t,
214
+ extra: y === null ? void 0 : { label: y === 0 ? "今天到期" : `剩余 ${y} 天`, tone: S ? "warning" : void 0 }
215
+ }
216
+ )
217
+ ] });
218
+ }
219
+ const u = a.kind === "team-expired", r = u ? "团队版已到期" : o ? `升级${o.plan.name},畅享更多` : "开通会员畅享", p = u ? "续费后团队成员继续共用套餐和积分" : It(o == null ? void 0 : o.plan, e.plans.data ?? [], n).join(" · "), _ = u ? 0 : (c == null ? void 0 : c.monthlyPoints) ?? 0;
220
+ return /* @__PURE__ */ m("div", { className: i.promo, "data-tone": u ? "team" : "free", children: [
221
+ /* @__PURE__ */ s("span", { className: i.promoArt, "aria-hidden": "true" }),
222
+ /* @__PURE__ */ m("div", { className: i.promoBody, children: [
223
+ /* @__PURE__ */ s("span", { className: i.promoTitle, children: r }),
224
+ /* @__PURE__ */ s("span", { className: i.promoText, children: p }),
225
+ /* @__PURE__ */ s(ln, { membership: e, text: u ? "续费团队版" : "立即开通会员", onOpen: t })
226
+ ] }),
227
+ /* @__PURE__ */ s(q, { membership: e, onOpen: t, extra: _ > 0 ? { label: `免费版每月赠 ${v(_)}` } : void 0 })
228
+ ] });
229
+ }, un = "个人空间", M = (e) => e.type === "team", X = (e) => e.type === "personal" ? un : e.name || e.slug, mn = { owner: "所有者", admin: "管理员", member: "成员" }, Yn = (e) => e ? mn[e] ?? "" : "", pn = (e) => !!(e && (e.type === "personal" || e.role === "owner")), _n = () => {
230
+ const [e, t] = B(!1), n = ye(), { accountApi: a, config: o } = g(), c = async () => {
231
+ if (e) return;
232
+ t(!0), De();
233
+ let u = o.routes.publicHome;
234
+ try {
235
+ const { endSessionUrl: r } = await a.logout();
236
+ r && (u = r);
237
+ } catch (r) {
238
+ if (!he(r, 401)) {
239
+ Me(), _e.error("退出失败,请重试"), t(!1);
240
+ return;
241
+ }
242
+ }
243
+ return Fe(), await n.cancelQueries().catch(() => {
244
+ }), be(), window.location.assign(u), new Promise(() => {
245
+ });
246
+ };
247
+ return { confirmLogout: () => {
248
+ e || Ae.confirm({
249
+ title: "退出登录",
250
+ content: "将同时退出 24.city 统一账号并回到首页,再次进入工作台需要重新登录。",
251
+ okText: "退出登录",
252
+ cancelText: "取消",
253
+ okButtonProps: { type: "danger" },
254
+ onOk: c
255
+ });
256
+ }, logout: c, pending: e };
257
+ }, W = (e) => typeof e == "object" && e !== null && !Array.isArray(e), fn = (e) => {
258
+ if (!he(e, 403) || !W(e) || !W(e.response)) return !1;
259
+ const t = e.response.data;
260
+ return W(t) && t.reason === "team_subscription_required";
261
+ }, L = {
262
+ profile: (e) => ["product-profile", e],
263
+ wallet: (e, t) => ["product-wallet", e, t],
264
+ subscription: (e, t) => ["product-subscription", e, t],
265
+ plans: ["product-plans"]
266
+ }, hn = () => {
267
+ const { accountApi: e } = g(), { session: t, spaces: n } = F(), a = (t == null ? void 0 : t.activeSpaceId) ?? "", o = (t == null ? void 0 : t.globalUserId) ?? "", c = (t == null ? void 0 : t.purpose) === "user" && !!(a && o), d = n.find((_) => _.id === a), u = P({
268
+ queryKey: L.profile(o),
269
+ queryFn: () => e.getProfile(),
270
+ enabled: !!o,
271
+ staleTime: 1 / 0
272
+ }), r = P({
273
+ queryKey: L.wallet(a, o),
274
+ queryFn: () => e.getWallet(),
275
+ enabled: c
276
+ }), p = P({
277
+ queryKey: L.subscription(a, o),
278
+ queryFn: () => e.getSubscription(),
279
+ enabled: c
280
+ });
281
+ return { session: t, allowed: c, activeSpace: d, activeSpaceId: a, globalUserId: o, profile: u, wallet: r, subscription: p };
282
+ }, yn = 5 * 6e4, bn = (e) => {
283
+ const { accountApi: t } = g();
284
+ return P({
285
+ queryKey: L.plans,
286
+ queryFn: () => t.getPlans(),
287
+ enabled: e,
288
+ staleTime: yn
289
+ });
290
+ }, ke = () => {
291
+ var y;
292
+ const { config: e } = g(), t = hn(), { activeSpace: n, subscription: a, allowed: o } = t, c = bn(o), d = n ? M(n) : !1, u = d ? "team" : "personal";
293
+ let r;
294
+ !o || a.isPending ? r = { kind: "loading" } : a.isError ? r = fn(a.error) ? { kind: "team-expired" } : { kind: "error" } : !a.data || a.data.isDefault ? r = { kind: "free", subscription: a.data ?? null } : r = { kind: "member", subscription: a.data, daysLeft: Ct(a.data) };
295
+ const p = r.kind === "free" || r.kind === "member" ? ((y = r.subscription) == null ? void 0 : y.tier) ?? null : null, _ = r.kind === "free" || r.kind === "member" || r.kind === "team-expired" ? Lt(c.data, u, p) : null, h = (r.kind === "free" || r.kind === "member") && r.subscription ? Et(c.data, r.subscription) : void 0;
296
+ return {
297
+ ...t,
298
+ plans: c,
299
+ state: r,
300
+ offer: _,
301
+ currentPlan: h,
302
+ team: d,
303
+ /** 个人空间是自己的;团队空间只有所有者能买(STD-BILLING-001) */
304
+ canBuy: pn(n),
305
+ /** 「订阅与套餐」的站内地址 */
306
+ subscriptionPath: N(e.routes.app, "subscription")
307
+ };
308
+ }, gn = () => {
309
+ const e = ye(), t = Re(), { session: n } = F(), { accountApi: a } = g(), [o, c] = B(!1), d = pe(0), u = n == null ? void 0 : n.activeSpaceId, r = Se(
310
+ async (p) => {
311
+ if (!p || p === u || o) return;
312
+ const _ = ++d.current;
313
+ c(!0);
314
+ try {
315
+ if (await e.cancelQueries(), e.clear(), (await a.switchSpace(p)).activeSpaceId !== p) throw new Error("空间切换响应与请求不一致");
316
+ const y = await le(a);
317
+ if (d.current !== _) return;
318
+ t.setContext(y), be();
319
+ } catch {
320
+ if (d.current !== _) return;
321
+ try {
322
+ const h = await le(a);
323
+ e.clear(), t.setContext(h), h.session.activeSpaceId !== p && _e.error("空间切换失败,请稍后重试");
324
+ } catch {
325
+ e.clear(), t.clear({ unavailable: !0 });
326
+ }
327
+ } finally {
328
+ d.current === _ && c(!1);
329
+ }
330
+ },
331
+ [a, u, t, e, o]
332
+ );
333
+ return { switching: o, switchSpace: r };
334
+ }, Y = "我的账号", kn = 80, wn = 200, G = ({ space: e }) => /* @__PURE__ */ m(me, { children: [
335
+ /* @__PURE__ */ s("span", { className: l.spaceName, children: X(e) }),
336
+ M(e) ? /* @__PURE__ */ s("span", { className: l.spaceType, children: "团队" }) : null
337
+ ] }), ue = ({ nickName: e, member: t, size: n }) => /* @__PURE__ */ s("span", { className: l.avatarWrap, "data-member": t ? "true" : "false", "data-size": n > 40 ? "large" : "small", children: /* @__PURE__ */ s(Pe, { size: "small", shape: "circle", className: l.avatar, style: { width: n, height: n }, children: e ? Array.from(e)[0] : /* @__PURE__ */ s(D, { "aria-hidden": "true" }) }) }), Nn = ({ state: e }) => e.kind === "member" ? /* @__PURE__ */ m("span", { className: l.planChip, "data-tone": "member", children: [
338
+ /* @__PURE__ */ s("span", { className: l.diamond, "aria-hidden": "true" }),
339
+ H(e.subscription)
340
+ ] }) : e.kind === "free" ? /* @__PURE__ */ s("span", { className: l.planChip, "data-tone": "free", children: e.subscription ? H(e.subscription) : "未开通" }) : e.kind === "team-expired" ? /* @__PURE__ */ s("span", { className: l.planChip, "data-tone": "warning", children: "团队版已到期" }) : null, Gn = ({ personal: e, selectedKey: t, onOpen: n }) => {
341
+ var ce;
342
+ const { config: a } = g(), o = fe(), c = J(), d = e ?? yt(a.routes.app, ht(o)), u = ke(), { profile: r, state: p } = u, { session: _, spaces: h } = F(), { confirmLogout: y, pending: S } = _n(), { switching: T, switchSpace: we } = gn(), [R, E] = B(!1), [U, I] = B(!1), A = pe(void 0), K = ((ce = r.data) == null ? void 0 : ce.nickName) ?? "", $ = K || (r.isPending ? "" : Y), te = (_ == null ? void 0 : _.activeSpaceId) ?? "", k = h.find((f) => f.id === te), ne = h.length > 1, ae = p.kind === "member", C = () => {
343
+ A.current !== void 0 && (window.clearTimeout(A.current), A.current = void 0);
344
+ };
345
+ Te(() => C, []);
346
+ const z = () => {
347
+ C(), E(!1), I(!1);
348
+ }, Ne = () => {
349
+ C(), A.current = window.setTimeout(() => E(!0), kn);
350
+ }, se = () => {
351
+ C(), A.current = window.setTimeout(() => {
352
+ E(!1), I(!1);
353
+ }, wn);
354
+ }, oe = (f) => {
355
+ if (z(), n) {
356
+ n(f);
357
+ return;
358
+ }
359
+ const w = d.items.find((Ce) => Ce.key === f);
360
+ w && c(w.to);
361
+ }, ve = /* @__PURE__ */ m("div", { className: l.card, role: "dialog", "aria-label": "账号", onMouseEnter: C, onMouseLeave: se, children: [
362
+ /* @__PURE__ */ m("div", { className: l.identity, children: [
363
+ /* @__PURE__ */ s(ue, { nickName: K, member: ae, size: 52 }),
364
+ /* @__PURE__ */ m("div", { className: l.who, children: [
365
+ /* @__PURE__ */ m("div", { className: l.nameRow, children: [
366
+ /* @__PURE__ */ s("span", { className: l.name, title: $ || Y, children: $ || Y }),
367
+ /* @__PURE__ */ s(Nn, { state: p })
368
+ ] }),
369
+ k ? ne ? /* @__PURE__ */ m(
370
+ b,
371
+ {
372
+ theme: "borderless",
373
+ type: "tertiary",
374
+ size: "small",
375
+ className: l.spaceToggle,
376
+ "aria-expanded": U,
377
+ "aria-label": `当前空间:${X(k)},切换空间`,
378
+ onClick: () => I((f) => !f),
379
+ children: [
380
+ M(k) ? /* @__PURE__ */ s(ie, { "aria-hidden": "true" }) : /* @__PURE__ */ s(D, { "aria-hidden": "true" }),
381
+ /* @__PURE__ */ s(G, { space: k }),
382
+ /* @__PURE__ */ s("span", { className: l.spaceSwitchText, children: "切换" }),
383
+ U ? /* @__PURE__ */ s($e, { "aria-hidden": "true" }) : /* @__PURE__ */ s(ze, { "aria-hidden": "true" })
384
+ ]
385
+ }
386
+ ) : /* @__PURE__ */ m("span", { className: l.spaceStatic, "aria-label": `当前空间:${X(k)}`, children: [
387
+ M(k) ? /* @__PURE__ */ s(ie, { "aria-hidden": "true" }) : /* @__PURE__ */ s(D, { "aria-hidden": "true" }),
388
+ /* @__PURE__ */ s(G, { space: k })
389
+ ] }) : null
390
+ ] })
391
+ ] }),
392
+ ne && U ? /* @__PURE__ */ s("div", { className: l.spaceList, role: "group", "aria-label": "切换空间", children: h.map((f) => {
393
+ const w = f.id === te;
394
+ return /* @__PURE__ */ m(
395
+ b,
396
+ {
397
+ theme: "borderless",
398
+ type: "tertiary",
399
+ block: !0,
400
+ className: l.spaceOption,
401
+ "aria-current": w ? "true" : void 0,
402
+ disabled: T && !w,
403
+ onClick: () => {
404
+ w || (z(), we(f.id));
405
+ },
406
+ children: [
407
+ /* @__PURE__ */ s("span", { className: l.spaceCheck, children: w ? /* @__PURE__ */ s(Oe, { "aria-hidden": "true" }) : null }),
408
+ /* @__PURE__ */ s(G, { space: f })
409
+ ]
410
+ },
411
+ f.id
412
+ );
413
+ }) }) : null,
414
+ /* @__PURE__ */ s("div", { className: l.plan, children: /* @__PURE__ */ s(dn, { membership: u, onOpen: oe }) }),
415
+ /* @__PURE__ */ s("div", { className: l.links, role: "group", "aria-label": d.label, children: d.items.map((f) => /* @__PURE__ */ m(
416
+ b,
417
+ {
418
+ theme: "borderless",
419
+ type: "tertiary",
420
+ block: !0,
421
+ className: l.link,
422
+ "aria-current": f.key === t ? "page" : void 0,
423
+ onClick: () => oe(f.key),
424
+ children: [
425
+ f.icon ? /* @__PURE__ */ s("span", { className: l.linkIcon, "aria-hidden": "true", children: /* @__PURE__ */ s(f.icon, {}) }) : null,
426
+ /* @__PURE__ */ s("span", { className: l.linkLabel, children: f.label }),
427
+ /* @__PURE__ */ s(V, { className: l.linkArrow, "aria-hidden": "true" })
428
+ ]
429
+ },
430
+ f.key
431
+ )) }),
432
+ /* @__PURE__ */ s("div", { className: l.divider, "aria-hidden": "true" }),
433
+ /* @__PURE__ */ s(
434
+ b,
435
+ {
436
+ theme: "borderless",
437
+ type: "tertiary",
438
+ block: !0,
439
+ className: l.logout,
440
+ disabled: S,
441
+ onClick: () => {
442
+ z(), y();
443
+ },
444
+ children: "退出登录"
445
+ }
446
+ )
447
+ ] });
448
+ return /* @__PURE__ */ s(
449
+ xe,
450
+ {
451
+ trigger: "custom",
452
+ visible: R,
453
+ position: "bottomRight",
454
+ showArrow: !1,
455
+ spacing: 8,
456
+ className: l.popover,
457
+ content: ve,
458
+ onClickOutSide: z,
459
+ children: /* @__PURE__ */ s(
460
+ b,
461
+ {
462
+ theme: "borderless",
463
+ type: "tertiary",
464
+ className: l.trigger,
465
+ "aria-label": $ ? `${$},账号菜单` : "账号菜单",
466
+ "aria-haspopup": "dialog",
467
+ "aria-expanded": R,
468
+ loading: T,
469
+ onMouseEnter: Ne,
470
+ onMouseLeave: se,
471
+ onClick: () => {
472
+ C(), E((f) => !f), R && I(!1);
473
+ },
474
+ children: /* @__PURE__ */ s(ue, { nickName: K, member: ae, size: 34 })
475
+ }
476
+ )
477
+ }
478
+ );
479
+ }, vn = "_upgrade_ea6lf_2", Cn = "_crown_ea6lf_25", Sn = "_text_ea6lf_37", j = {
480
+ upgrade: vn,
481
+ crown: Cn,
482
+ text: Sn
483
+ }, jn = () => {
484
+ const { config: e } = g(), t = J(), { state: n, canBuy: a } = ke();
485
+ if (!a || n.kind !== "free" && n.kind !== "team-expired") return null;
486
+ const o = n.kind === "team-expired" ? "续费团队版" : "开通会员";
487
+ return /* @__PURE__ */ m(b, { theme: "light", type: "tertiary", className: j.upgrade, onClick: () => t(N(e.routes.app, "subscription")), children: [
488
+ /* @__PURE__ */ s("span", { className: j.crown, "aria-hidden": "true" }),
489
+ /* @__PURE__ */ s("span", { className: j.text, children: o })
490
+ ] });
491
+ }, Tn = "_wallet_weimr_2", An = "_coin_weimr_25", Pn = "_value_weimr_32", Q = {
492
+ wallet: Tn,
493
+ coin: An,
494
+ value: Pn
495
+ }, Qn = () => {
496
+ const { accountApi: e, config: t } = g(), { session: n } = F(), a = J(), o = (n == null ? void 0 : n.activeSpaceId) ?? "", c = (n == null ? void 0 : n.globalUserId) ?? "", d = P({
497
+ queryKey: L.wallet(o, c),
498
+ queryFn: () => e.getWallet(),
499
+ enabled: !!n,
500
+ refetchOnWindowFocus: !0
501
+ });
502
+ if (!n) return null;
503
+ const u = d.isPending ? "读取中" : d.data ? v(d.data.availablePoints) : "积分暂不可用";
504
+ return /* @__PURE__ */ s(Le, { content: "当前空间可用积分,由统一账号中心记账", children: /* @__PURE__ */ m(
505
+ b,
506
+ {
507
+ theme: "light",
508
+ type: "tertiary",
509
+ className: Q.wallet,
510
+ "aria-label": d.data ? `积分 ${u}` : u,
511
+ onClick: () => a(N(t.routes.app, "points")),
512
+ children: [
513
+ /* @__PURE__ */ s("span", { className: Q.coin, "aria-hidden": "true" }),
514
+ /* @__PURE__ */ s("span", { className: Q.value, children: u })
515
+ ]
516
+ }
517
+ ) });
518
+ };
519
+ export {
520
+ pt as A,
521
+ ht as B,
522
+ Un as C,
523
+ Fn as D,
524
+ St as E,
525
+ Y as F,
526
+ Rn as G,
527
+ X as H,
528
+ Yn as I,
529
+ xt as J,
530
+ Lt as K,
531
+ hn as L,
532
+ _n as M,
533
+ ke as N,
534
+ bn as O,
535
+ x as P,
536
+ gn as Q,
537
+ bt as U,
538
+ Qn as W,
539
+ ue as a,
540
+ Gn as b,
541
+ un as c,
542
+ dn as d,
543
+ jn as e,
544
+ L as f,
545
+ N as g,
546
+ yt as h,
547
+ pn as i,
548
+ Et as j,
549
+ Wn as k,
550
+ wt as l,
551
+ At as m,
552
+ Pt as n,
553
+ Mn as o,
554
+ _t as p,
555
+ M as q,
556
+ fn as r,
557
+ Z as s,
558
+ It as t,
559
+ O as u,
560
+ Ct as v,
561
+ qn as w,
562
+ Kn as x,
563
+ Nt as y,
564
+ H as z
565
+ };
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { A as s, a as o, c as t, b as r, h as n, j as i, k as u, m as l, o as c, p, q as m, s as d, t as f, i as g, d as C, v as P, x as S, l as A, n as L, r as h, y as R, z as y, B as E, e as N, f as x, C as B, D as T, E as O, u as b, g as _, w as v } from "./chunks/logout-signal-CiD_zY5M.js";
2
- import { A as U, C as I, L as D, P as M, a as k, b as q, Q as w, R as Q, S as z, c as K, T as H, U as G, d as V, p as W, e as j, f as Y, g as J, y as X } from "./chunks/upgrade-modal-BbsM2VE2.js";
3
- import { A as $, a as aa, b as ea, E as sa, F as oa, P as ta, c as ra, d as na, U as ia, e as ua, W as la, f as ca, g as pa, h as ma, i as da, j as fa, k as ga, l as Ca, m as Pa, n as Sa, o as Aa, p as La, q as ha, r as Ra, s as ya, t as Ea, u as Na, v as xa, w as Ba, x as Ta, y as Oa, z as ba, B as _a, C as va, D as Fa, G as Ua, H as Ia, I as Da, J as Ma, K as ka, L as qa, M as wa, N as Qa, O as za, Q as Ka } from "./chunks/wallet-badge-D7AFqTLx.js";
2
+ import { A as U, C as I, L as D, P as M, a as k, b as q, Q as w, R as Q, S as z, c as K, T as H, U as G, d as V, p as W, e as j, f as Y, g as J, y as X } from "./chunks/upgrade-modal-_psMAWRK.js";
3
+ import { A as $, a as aa, b as ea, E as sa, F as oa, P as ta, c as ra, d as na, U as ia, e as ua, W as la, f as ca, g as pa, h as ma, i as da, j as fa, k as ga, l as Ca, m as Pa, n as Sa, o as Aa, p as La, q as ha, r as Ra, s as ya, t as Ea, u as Na, v as xa, w as Ba, x as Ta, y as Oa, z as ba, B as _a, C as va, D as Fa, G as Ua, H as Ia, I as Da, J as Ma, K as ka, L as qa, M as wa, N as Qa, O as za, Q as Ka } from "./chunks/wallet-badge-CnyMLpUO.js";
4
4
  import { A as Ga } from "./chunks/auth-provider-CqiyTeOt.js";
5
5
  import { ConsoleSemiProvider as Wa, MODAL_BUTTON_PROPS as ja, modalButtonProps as Ya } from "./semi.js";
6
- import { B as Xa, C as Za, f as $a, a as ae, i as ee } from "./chunks/console-layout-CcUiJPf0.js";
7
- import { E as oe, R as te } from "./chunks/error-boundary-BgTZsJA_.js";
6
+ import { B as Xa, C as Za, f as $a, a as ae, i as ee } from "./chunks/console-layout-BibioK5M.js";
7
+ import { E as oe, R as te } from "./chunks/error-boundary-D3qiD7ov.js";
8
8
  import { L as ne } from "./chunks/link-button-giJEcTmG.js";
9
- import { N as ue, S as le, T as ce } from "./chunks/text-link-7A--UEc3.js";
10
- import { E as me, a as de, F as fe, b as ge, L as Ce, P as Pe, S as Se, c as Ae, T as Le } from "./chunks/page-BhfOrziX.js";
9
+ import { N as ue, S as le, T as ce } from "./chunks/text-link-FTsBp_QU.js";
10
+ import { E as me, a as de, F as fe, b as ge, L as Ce, P as Pe, S as Se, c as Ae, T as Le } from "./chunks/page-BaitnD--.js";
11
11
  import { C as Re, u as ye, a as Ee, b as Ne } from "./chunks/context-CaVim6ZO.js";
12
12
  import { c as Be } from "./chunks/http-B3mTs9KZ.js";
13
- import { C as Oe, R as be, c as _e, e as ve, k as Fe, l as Ue, p as Ie, a as De, r as Me } from "./chunks/stale-build-D4N21gap.js";
13
+ import { C as Oe, R as be, c as _e, e as ve, k as Fe, l as Ue, p as Ie, a as De, r as Me } from "./chunks/stale-build-DUKkQHuu.js";
14
14
  import { u as qe } from "./chunks/use-media-query-DvyinWNg.js";
15
15
  import { BRAND_VARIABLES as Qe, SEMI_BRAND_VARIABLES as ze, applyBrand as Ke, brandPalette as He } from "./theme/index.js";
16
16
  import { notifyCustomerSessionChanged as Ve, subscribeCustomerSessionChanges as We } from "@24city/web-runtime/session-sync";
@@ -1,4 +1,4 @@
1
- import { B as s, C as i, f as o, a as t, i as d } from "../chunks/console-layout-CcUiJPf0.js";
1
+ import { B as s, C as i, f as o, a as t, i as d } from "../chunks/console-layout-BibioK5M.js";
2
2
  export {
3
3
  s as BrandMark,
4
4
  i as ConsoleLayout,
@@ -1,7 +1,7 @@
1
- import { E as o, R as s } from "../chunks/error-boundary-BgTZsJA_.js";
1
+ import { E as o, R as s } from "../chunks/error-boundary-D3qiD7ov.js";
2
2
  import { L as e } from "../chunks/link-button-giJEcTmG.js";
3
- import { N as n, S as d, T as l } from "../chunks/text-link-7A--UEc3.js";
4
- import { E, a as P, F as i, b as p, L, P as m, S as x, c as S, T as f } from "../chunks/page-BhfOrziX.js";
3
+ import { N as n, S as d, T as l } from "../chunks/text-link-FTsBp_QU.js";
4
+ import { E, a as P, F as i, b as p, L, P as m, S as x, c as S, T as f } from "../chunks/page-BaitnD--.js";
5
5
  export {
6
6
  E as EmptyCard,
7
7
  o as ErrorBoundary,
@@ -1,7 +1,7 @@
1
1
  import { C as r, u as s, a as o, b as t } from "../chunks/context-CaVim6ZO.js";
2
2
  import { h as n, j as u, k as m, m as f, o as p, p as C, q as l, s as R, t as d, v as c, x as g, y as h, z as x, B as P, C as y, D as z, E as N } from "../chunks/logout-signal-CiD_zY5M.js";
3
3
  import { c as k } from "../chunks/http-B3mTs9KZ.js";
4
- import { C as B, R as D, c as E, e as I, k as v, l as O, p as Q, a as b, r as A } from "../chunks/stale-build-D4N21gap.js";
4
+ import { C as B, R as D, c as E, e as I, k as v, l as O, p as Q, a as b, r as A } from "../chunks/stale-build-DUKkQHuu.js";
5
5
  import { u as H } from "../chunks/use-media-query-DvyinWNg.js";
6
6
  import { summarizeCustomerError as M } from "@24city/web-runtime/error-summary";
7
7
  export {