@24city/web-console 0.3.11 → 0.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.12
4
+
5
+ **修复:发布期间恢复会话停在不可用页**(`AuthProvider`、`RouteGuard`、`LoginPage`)
6
+
7
+ - 恢复会话时遇到网络失败、超时或网关 502/503/504(例如 Staging 发布正在替换容器),先在加载态里隔 1、2、4 秒重试;
8
+ 仍不可达才显示不可用页,之后每 15 秒静默再查一次,服务恢复后自动回到应用。回到窗口时立即重查,并取消等待中的静默复查。
9
+ 其他失败(500、返回内容无效)和 401/403/404 不重试,行为不变。原先回到窗口时恰逢发布,页面会一直停在不可用页,直到手动刷新。
10
+ - 不可用页的文案不再说账号服务出了故障:工作台改为「服务暂时不可用 / 服务可能正在更新,请稍后重新加载;长时间无法恢复请联系
11
+ 管理员。」,登录中转页改为「服务暂时不可用 / 服务可能正在更新,请稍后重试。」。
12
+ - `@24city/web-console/runtime` 新增 `isTransientServiceError(error)`。
13
+ - 来自 SaaS Starter 的同一修复(Starter 模板的会话恢复已改由本包提供)。
14
+
3
15
  ## 0.3.11
4
16
 
5
17
  **新增:行为事件**(`@24city/web-console/account`,统一账号中心 API 1.24.0;运营在统一中心后台按行为圈人,
@@ -1,6 +1,8 @@
1
1
  import { type PropsWithChildren } from 'react';
2
2
  /**
3
3
  * 会话恢复与同步:首次加载和其他标签页的会话变化时重读会话与空间;回到窗口时后台复核,用户、空间和用途都没变就保留
4
- * 页面和缓存。给 HTTP 客户端配置 CSRF Token 和 401 处理:受保护路径下的 401 跳去登录页,其他标签页刚退出时不跳。
4
+ * 页面和缓存。服务暂时不可达(网络失败、超时、502/503/504)时先在加载态里隔 1、2、4 秒重试,仍不可达才显示不可用页,
5
+ * 之后每 15 秒静默再查,恢复后自动回到应用;其他失败不重试。给 HTTP 客户端配置 CSRF Token 和 401 处理:受保护路径下的
6
+ * 401 跳去登录页,其他标签页刚退出时不跳。
5
7
  */
6
8
  export declare const AuthProvider: ({ children }: PropsWithChildren) => import("react").JSX.Element;
@@ -1,7 +1,7 @@
1
- import { A as s, a as o, c as t, b as n, i as r, d as u, l as i, n as c, r as l, e as g, f as p, u as S, g as A, w as P } from "../chunks/logout-signal-CsnJzWTz.js";
2
- import { A as C, a as d, C as h, L as f, P as m, b as T, c as y, Q as N, R as O, S as b, d as E, T as U, U as v, e as w, p as F, f as R, g as _, h as x, u as B, y as I } from "../chunks/use-show-once-mq5WGTrX.js";
3
- import { A as q, a as D, b as K, E as Q, F as k, P as G, c as H, d as W, U as Y, e as j, W as z, f as J, g as V, h as X, i as Z, j as $, k as aa, l as ea, m as sa, n as oa, o as ta, p as na, q as ra, r as ua, s as ia, t as ca, u as la, v as ga, w as pa, x as Sa, y as Aa, z as Pa, B as La, C as Ca, D as da, G as ha, H as fa, I as ma, J as Ta, K as ya, L as Na, M as Oa, N as ba, O as Ea, Q as Ua, R as va, S as wa, T as Fa } from "../chunks/wallet-badge-3oCaCiNm.js";
4
- import { A as _a } from "../chunks/auth-provider-3AIfwcdS.js";
1
+ import { A as s, a as o, c as t, b as n, i as r, d as u, l as i, n as c, r as l, e as g, f as p, u as S, g as A, w as P } from "../chunks/logout-signal-qvHorCCF.js";
2
+ import { A as C, a as d, C as h, L as f, P as m, b as T, c as y, Q as N, R as O, S as b, d as E, T as U, U as v, e as w, p as F, f as R, g as _, h as x, u as B, y as I } from "../chunks/use-show-once-Cwj5z_Lo.js";
3
+ import { A as q, a as D, b as K, E as Q, F as k, P as G, c as H, d as W, U as Y, e as j, W as z, f as J, g as V, h as X, i as Z, j as $, k as aa, l as ea, m as sa, n as oa, o as ta, p as na, q as ra, r as ua, s as ia, t as ca, u as la, v as ga, w as pa, x as Sa, y as Aa, z as Pa, B as La, C as Ca, D as da, G as ha, H as fa, I as ma, J as Ta, K as ya, L as Na, M as Oa, N as ba, O as Ea, Q as Ua, R as va, S as wa, T as Fa } from "../chunks/wallet-badge-DnWl21es.js";
4
+ import { A as _a } from "../chunks/auth-provider-Cwib6lRM.js";
5
5
  import { notifyCustomerSessionChanged as Ba, subscribeCustomerSessionChanges as Ia } from "@24city/web-runtime/session-sync";
6
6
  export {
7
7
  q as ACCOUNT_SECTIONS,
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from 'react';
2
- /** 受保护路由:会话未恢复时整屏加载;账号服务不可用时提示重试;没有 user 会话时带回跳地址去登录页。 */
2
+ /** 受保护路由:会话未恢复时整屏加载;服务不可用时提示重新加载;没有 user 会话时带回跳地址去登录页。 */
3
3
  export declare const RouteGuard: ({ children }: {
4
4
  children: ReactNode;
5
5
  }) => import("react").JSX.Element;
@@ -0,0 +1,72 @@
1
+ import { jsx as U, Fragment as L } from "react/jsx-runtime";
2
+ import { useEffect as T } from "react";
3
+ import { useQueryClient as I } from "@tanstack/react-query";
4
+ import { b as R } from "./context-CaVim6ZO.js";
5
+ import { g as A, n as y, i as c, v as k, f as S, r as x, y as P, t as h } from "./logout-signal-qvHorCCF.js";
6
+ import { subscribeCustomerSessionChanges as _ } from "@24city/web-runtime/session-sync";
7
+ const z = (e) => !h(e, 401) && !h(e, 403) && !h(e, 404), F = (e, i) => (e == null ? void 0 : e.purpose) === i.purpose && e.globalUserId === i.globalUserId && e.activeSpaceId === i.activeSpaceId, H = [1e3, 2e3, 4e3], Q = 15e3, B = (e) => new Promise((i) => setTimeout(i, e)), D = ({ children: e }) => {
8
+ const i = I(), o = A(), { accountApi: f, config: r, http: d } = R();
9
+ return T(() => {
10
+ let a = !0, n = 0, u;
11
+ const p = () => {
12
+ clearTimeout(u), u = void 0;
13
+ }, w = async () => {
14
+ await i.cancelQueries().catch(() => {
15
+ }), i.clear();
16
+ }, m = async (t) => {
17
+ try {
18
+ const s = await S(f);
19
+ return a && n === t && (x(), o.setContext(s)), !0;
20
+ } catch (s) {
21
+ return !a || n !== t ? !0 : P(s) ? !1 : (o.clear({ unavailable: z(s) }), !0);
22
+ }
23
+ }, v = (t) => {
24
+ u = setTimeout(async () => {
25
+ u = void 0, !(!a || n !== t || c()) && (await m(t) || v(t));
26
+ }, Q);
27
+ }, l = async () => {
28
+ if (c()) return;
29
+ p();
30
+ const t = ++n;
31
+ o.setBootstrapping(), await w();
32
+ for (const s of H)
33
+ if (await m(t) || (await B(s), !a || n !== t || c())) return;
34
+ await m(t) || (o.clear({ unavailable: !0 }), v(t));
35
+ }, b = async () => {
36
+ if (c() || (n += 1, p(), await w(), o.clear(), y())) return;
37
+ const t = window.location.pathname + window.location.search;
38
+ k(window.location.pathname, r.routes.app) && window.location.assign(`${r.routes.login}?returnPath=${encodeURIComponent(t)}`);
39
+ };
40
+ d.configure({
41
+ baseUrl: r.api.baseUrl,
42
+ getCsrfToken: o.getCsrfToken,
43
+ onUnauthorized: b
44
+ });
45
+ const C = async () => {
46
+ if (c()) return;
47
+ if (!o.getState().session) return l();
48
+ const t = ++n;
49
+ try {
50
+ const s = await S(f);
51
+ if (!a || n !== t) return;
52
+ if (F(o.getState().session, s.session)) {
53
+ o.setContext(s);
54
+ return;
55
+ }
56
+ } catch {
57
+ if (!a || n !== t) return;
58
+ }
59
+ await l();
60
+ }, E = _(() => {
61
+ y(), l();
62
+ }), g = () => {
63
+ document.visibilityState !== "hidden" && C();
64
+ };
65
+ return window.addEventListener("focus", g), l(), () => {
66
+ a = !1, n += 1, p(), E(), window.removeEventListener("focus", g), d.configure({ getCsrfToken: null, onUnauthorized: null });
67
+ };
68
+ }, [f, o, r.api.baseUrl, r.routes.app, r.routes.login, d, i]), /* @__PURE__ */ U(L, { children: e });
69
+ };
70
+ export {
71
+ D as A
72
+ };
@@ -3,7 +3,7 @@ import { useEffect as z, useState as b } from "react";
3
3
  import { Layout as v, Button as f, Typography as q, Space as D, Nav as $ } from "@douyinfe/semi-ui";
4
4
  import { IconSidebar as P } from "@douyinfe/semi-icons";
5
5
  import { useLocation as F, useNavigate as Q, Outlet as Y } from "react-router";
6
- import { T as J, h as V, i as X, D as Z, q as ee, e as te, W as ne, b as ae } from "./wallet-badge-3oCaCiNm.js";
6
+ import { T as J, h as V, i as X, D as Z, q as ee, e as te, W as ne, b as ae } from "./wallet-badge-DnWl21es.js";
7
7
  import { u as R, b as oe, a as se } from "./context-CaVim6ZO.js";
8
8
  import { u as le } from "./use-media-query-DvyinWNg.js";
9
9
  import { a as re } from "./scale-smFifpMm.js";
@@ -1,9 +1,9 @@
1
1
  import { sanitizeInternalReturnPath as A } from "@24city/web-runtime/core/internal-path";
2
- import { createContext as _, useSyncExternalStore as x, useContext as F } from "react";
3
- import { summarizeCustomerError as z } from "@24city/web-runtime/error-summary";
2
+ import { createContext as x, useSyncExternalStore as F, useContext as z } from "react";
3
+ import { summarizeCustomerError as O } from "@24city/web-runtime/error-summary";
4
4
  const v = (t) => t.includes("\\") || [...t].some((e) => {
5
- const o = e.charCodeAt(0);
6
- return o <= 31 || o === 127;
5
+ const s = e.charCodeAt(0);
6
+ return s <= 31 || s === 127;
7
7
  }), it = (t) => !v(t) && t.startsWith("/") && !t.startsWith("//") && (() => {
8
8
  try {
9
9
  const e = new URL(t, "https://product.invalid");
@@ -11,44 +11,44 @@ const v = (t) => t.includes("\\") || [...t].some((e) => {
11
11
  } catch {
12
12
  return !1;
13
13
  }
14
- })(), ct = (t, e) => !v(t) && A(t, e) === t, M = (t, e) => !t || v(t) ? e : A(t, e), O = (t) => typeof t == "object" && t !== null && !Array.isArray(t), l = (t, e) => {
15
- const o = e.data;
16
- if (!O(o) || o.code !== 0 || !("data" in o))
14
+ })(), ct = (t, e) => !v(t) && A(t, e) === t, M = (t, e) => !t || v(t) ? e : A(t, e), U = (t) => typeof t == "object" && t !== null && !Array.isArray(t), l = (t, e) => {
15
+ const s = e.data;
16
+ if (!U(s) || s.code !== 0 || !("data" in s))
17
17
  throw new Error(`接口 ${t} 返回了无效响应`);
18
- return o.data;
19
- }, u = (t, e, o) => {
20
- if (!O(t)) throw new Error(`接口 ${e} 字段 ${o} 无效`);
18
+ return s.data;
19
+ }, u = (t, e, s) => {
20
+ if (!U(t)) throw new Error(`接口 ${e} 字段 ${s} 无效`);
21
21
  return t;
22
- }, s = (t, e, o) => {
22
+ }, o = (t, e, s) => {
23
23
  const r = t[e];
24
24
  if (typeof r != "string" || !r.trim())
25
- throw new Error(`接口 ${o} 字段 ${e} 无效`);
25
+ throw new Error(`接口 ${s} 字段 ${e} 无效`);
26
26
  return r;
27
- }, g = (t, e, o) => {
27
+ }, g = (t, e, s) => {
28
28
  const r = t[e];
29
29
  if (typeof r != "number" || !Number.isSafeInteger(r) || r < 0)
30
- throw new Error(`接口 ${o} 字段 ${e} 无效`);
30
+ throw new Error(`接口 ${s} 字段 ${e} 无效`);
31
31
  return r;
32
- }, d = "/account", c = `${d}/session`, E = `${d}/logout`, i = `${d}/spaces`, T = `${i}/switch`, $ = `${d}/profile`, h = `${d}/wallet`, P = `${d}/entitlements`, f = `${d}/subscription`, a = `${d}/plans`, y = `${d}/shown-prompts`, W = `${d}/events`, I = (t, e, o) => {
32
+ }, d = "/account", c = `${d}/session`, E = `${d}/logout`, i = `${d}/spaces`, T = `${i}/switch`, $ = `${d}/profile`, h = `${d}/wallet`, P = `${d}/entitlements`, f = `${d}/subscription`, a = `${d}/plans`, y = `${d}/shown-prompts`, W = `${d}/events`, I = (t, e, s) => {
33
33
  const r = t[e];
34
34
  if (r !== null && typeof r != "string")
35
- throw new Error(`接口 ${o} 字段 ${e} 无效`);
35
+ throw new Error(`接口 ${s} 字段 ${e} 无效`);
36
36
  return r;
37
- }, S = (t, e, o) => {
37
+ }, S = (t, e, s) => {
38
38
  const r = t[e];
39
39
  if (r != null) {
40
40
  if (typeof r != "string")
41
- throw new Error(`接口 ${o} 字段 ${e} 无效`);
41
+ throw new Error(`接口 ${s} 字段 ${e} 无效`);
42
42
  return r;
43
43
  }
44
- }, q = (t, e, o) => {
44
+ }, k = (t, e, s) => {
45
45
  const r = t[e];
46
- return r === null ? {} : u(r, o, e);
47
- }, k = (t) => {
48
- const e = u(t, E, "data"), o = S(e, "endSessionUrl", E);
49
- if (!o) return null;
46
+ return r === null ? {} : u(r, s, e);
47
+ }, q = (t) => {
48
+ const e = u(t, E, "data"), s = S(e, "endSessionUrl", E);
49
+ if (!s) return null;
50
50
  try {
51
- return new URL(o).protocol === "https:" ? o : null;
51
+ return new URL(s).protocol === "https:" ? s : null;
52
52
  } catch {
53
53
  return null;
54
54
  }
@@ -56,157 +56,157 @@ const v = (t) => t.includes("\\") || [...t].some((e) => {
56
56
  const e = u(t, c, "data");
57
57
  if (e.purpose !== "user") throw new Error("产品用户 Web 只接受 user Purpose 会话");
58
58
  return {
59
- globalUserId: s(e, "globalUserId", c),
59
+ globalUserId: o(e, "globalUserId", c),
60
60
  localUserId: g(e, "localUserId", c),
61
- activeSpaceId: s(e, "activeSpaceId", c),
61
+ activeSpaceId: o(e, "activeSpaceId", c),
62
62
  authorityId: g(e, "authorityId", c),
63
63
  orgId: g(e, "orgId", c),
64
64
  purpose: "user",
65
- csrfToken: s(e, "csrfToken", c),
66
- issuedAt: s(e, "issuedAt", c),
67
- lastSeenAt: s(e, "lastSeenAt", c),
68
- absoluteExpiresAt: s(e, "absoluteExpiresAt", c),
69
- lastCentralVerifiedAt: s(e, "lastCentralVerifiedAt", c),
70
- accountCenterUrl: s(e, "accountCenterUrl", c)
65
+ csrfToken: o(e, "csrfToken", c),
66
+ issuedAt: o(e, "issuedAt", c),
67
+ lastSeenAt: o(e, "lastSeenAt", c),
68
+ absoluteExpiresAt: o(e, "absoluteExpiresAt", c),
69
+ lastCentralVerifiedAt: o(e, "lastCentralVerifiedAt", c),
70
+ accountCenterUrl: o(e, "accountCenterUrl", c)
71
71
  };
72
- }, U = (t, e, o) => {
73
- const r = u(t, e, o);
72
+ }, R = (t, e, s) => {
73
+ const r = u(t, e, s);
74
74
  return {
75
- id: s(r, "id", e),
76
- entitlementCode: s(r, "entitlementCode", e),
75
+ id: o(r, "id", e),
76
+ entitlementCode: o(r, "entitlementCode", e),
77
77
  status: S(r, "status", e),
78
- startsAt: s(r, "startsAt", e),
78
+ startsAt: o(r, "startsAt", e),
79
79
  expiresAt: I(r, "expiresAt", e),
80
- metadata: q(r, "metadata", e)
80
+ metadata: k(r, "metadata", e)
81
81
  };
82
82
  }, B = (t, e) => {
83
- const o = u(t, i, `spaces[${e}]`), r = u(o.entitlementSummary, i, "entitlementSummary"), n = r.codes, m = o.entitlements;
83
+ const s = u(t, i, `spaces[${e}]`), r = u(s.entitlementSummary, i, "entitlementSummary"), n = r.codes, m = s.entitlements;
84
84
  if (!Array.isArray(n) || n.some((b) => typeof b != "string"))
85
85
  throw new Error(`接口 ${i} 字段 entitlementSummary.codes 无效`);
86
86
  if (!Array.isArray(m))
87
87
  throw new Error(`接口 ${i} 字段 entitlements 无效`);
88
88
  return {
89
- id: s(o, "id", i),
90
- name: s(o, "name", i),
91
- slug: s(o, "slug", i),
92
- type: s(o, "type", i),
93
- role: s(o, "role", i),
94
- status: s(o, "status", i),
95
- membershipStatus: s(o, "membershipStatus", i),
89
+ id: o(s, "id", i),
90
+ name: o(s, "name", i),
91
+ slug: o(s, "slug", i),
92
+ type: o(s, "type", i),
93
+ role: o(s, "role", i),
94
+ status: o(s, "status", i),
95
+ membershipStatus: o(s, "membershipStatus", i),
96
96
  entitlementSummary: {
97
97
  activeCount: g(r, "activeCount", i),
98
98
  codes: [...n]
99
99
  },
100
100
  entitlements: m.map(
101
- (b, p) => U(b, i, `entitlements[${p}]`)
101
+ (b, p) => R(b, i, `entitlements[${p}]`)
102
102
  )
103
103
  };
104
104
  }, V = (t) => {
105
- const e = u(t, i, "data"), o = s(e, "activeSpaceId", i);
105
+ const e = u(t, i, "data"), s = o(e, "activeSpaceId", i);
106
106
  if (!Array.isArray(e.spaces)) throw new Error(`接口 ${i} 字段 spaces 无效`);
107
107
  const r = e.spaces.map(B);
108
- if (!r.some((n) => n.id === o))
108
+ if (!r.some((n) => n.id === s))
109
109
  throw new Error(`接口 ${i} 的当前空间不在可用空间列表中`);
110
- return { activeSpaceId: o, spaces: r };
110
+ return { activeSpaceId: s, spaces: r };
111
111
  }, H = (t) => {
112
112
  const e = u(t, $, "data");
113
113
  return { nickName: (S(e, "nickName", $) ?? "").trim() };
114
114
  }, j = (t) => {
115
- const e = u(t, h, "data"), o = (r) => {
115
+ const e = u(t, h, "data"), s = (r) => {
116
116
  const n = e[r];
117
117
  if (typeof n != "number" || !Number.isSafeInteger(n))
118
118
  throw new Error(`接口 ${h} 字段 ${r} 无效`);
119
119
  return n;
120
120
  };
121
121
  return {
122
- spaceId: s(e, "spaceId", h),
123
- globalUserId: s(e, "globalUserId", h),
124
- productCode: s(e, "productCode", h),
125
- availablePoints: o("availablePoints"),
126
- reservedPoints: o("reservedPoints"),
127
- globalAvailablePoints: o("globalAvailablePoints"),
128
- globalReservedPoints: o("globalReservedPoints"),
129
- productAvailablePoints: o("productAvailablePoints"),
130
- productReservedPoints: o("productReservedPoints"),
131
- walletAvailablePoints: o("walletAvailablePoints"),
132
- walletReservedPoints: o("walletReservedPoints"),
122
+ spaceId: o(e, "spaceId", h),
123
+ globalUserId: o(e, "globalUserId", h),
124
+ productCode: o(e, "productCode", h),
125
+ availablePoints: s("availablePoints"),
126
+ reservedPoints: s("reservedPoints"),
127
+ globalAvailablePoints: s("globalAvailablePoints"),
128
+ globalReservedPoints: s("globalReservedPoints"),
129
+ productAvailablePoints: s("productAvailablePoints"),
130
+ productReservedPoints: s("productReservedPoints"),
131
+ walletAvailablePoints: s("walletAvailablePoints"),
132
+ walletReservedPoints: s("walletReservedPoints"),
133
133
  walletVersion: g(e, "walletVersion", h)
134
134
  };
135
135
  }, G = (t) => {
136
136
  if (t === null) return null;
137
- const e = u(t, f, "data"), o = e.tier;
138
- if (typeof o != "number" || !Number.isSafeInteger(o))
137
+ const e = u(t, f, "data"), s = e.tier;
138
+ if (typeof s != "number" || !Number.isSafeInteger(s))
139
139
  throw new Error(`接口 ${f} 字段 tier 无效`);
140
140
  if (typeof e.isDefault != "boolean")
141
141
  throw new Error(`接口 ${f} 字段 isDefault 无效`);
142
142
  return {
143
143
  subscriptionId: I(e, "subscriptionId", f),
144
- planCode: s(e, "planCode", f),
144
+ planCode: o(e, "planCode", f),
145
145
  planName: (S(e, "planName", f) ?? "").trim(),
146
- tier: o,
146
+ tier: s,
147
147
  isDefault: e.isDefault,
148
148
  spaceType: S(e, "spaceType", f) ?? "",
149
149
  currentPeriodEnd: I(e, "currentPeriodEnd", f)
150
150
  };
151
151
  }, K = /* @__PURE__ */ new Set(["month", "year", "one_time"]), X = (t, e) => {
152
- const o = u(t, a, e), r = s(o, "billingPeriod", a);
152
+ const s = u(t, a, e), r = o(s, "billingPeriod", a);
153
153
  if (!K.has(r)) throw new Error(`接口 ${a} 字段 ${e}.billingPeriod 无效`);
154
154
  return {
155
- code: s(o, "code", a),
156
- amountCents: g(o, "amountCents", a),
157
- currency: s(o, "currency", a),
155
+ code: o(s, "code", a),
156
+ amountCents: g(s, "amountCents", a),
157
+ currency: o(s, "currency", a),
158
158
  billingPeriod: r,
159
- durationDays: g(o, "durationDays", a),
160
- pointCycles: g(o, "pointCycles", a)
159
+ durationDays: g(s, "durationDays", a),
160
+ pointCycles: g(s, "pointCycles", a)
161
161
  };
162
162
  }, Y = (t, e) => {
163
- const o = u(t, a, e), r = o.limit;
163
+ const s = u(t, a, e), r = s.limit;
164
164
  if (r != null && (typeof r != "number" || !Number.isSafeInteger(r) || r < 0))
165
165
  throw new Error(`接口 ${a} 字段 ${e}.limit 无效`);
166
- const n = Array.isArray(o.discounts) ? o.discounts.filter((m) => typeof m == "string") : [];
166
+ const n = Array.isArray(s.discounts) ? s.discounts.filter((m) => typeof m == "string") : [];
167
167
  return {
168
- key: S(o, "key", a) ?? "",
169
- name: s(o, "name", a),
170
- description: S(o, "description", a) ?? "",
168
+ key: S(s, "key", a) ?? "",
169
+ name: o(s, "name", a),
170
+ description: S(s, "description", a) ?? "",
171
171
  limit: typeof r == "number" ? r : null,
172
172
  discounts: n
173
173
  };
174
174
  }, J = (t, e) => {
175
- const o = `data[${e}]`, r = u(t, a, o), n = s(r, "spaceType", a);
176
- if (n !== "personal" && n !== "team") throw new Error(`接口 ${a} 字段 ${o}.spaceType 无效`);
177
- if (typeof r.tier != "number" || !Number.isSafeInteger(r.tier)) throw new Error(`接口 ${a} 字段 ${o}.tier 无效`);
178
- if (typeof r.isDefault != "boolean") throw new Error(`接口 ${a} 字段 ${o}.isDefault 无效`);
179
- if (!Array.isArray(r.prices)) throw new Error(`接口 ${a} 字段 ${o}.prices 无效`);
175
+ const s = `data[${e}]`, r = u(t, a, s), n = o(r, "spaceType", a);
176
+ if (n !== "personal" && n !== "team") throw new Error(`接口 ${a} 字段 ${s}.spaceType 无效`);
177
+ if (typeof r.tier != "number" || !Number.isSafeInteger(r.tier)) throw new Error(`接口 ${a} 字段 ${s}.tier 无效`);
178
+ if (typeof r.isDefault != "boolean") throw new Error(`接口 ${a} 字段 ${s}.isDefault 无效`);
179
+ if (!Array.isArray(r.prices)) throw new Error(`接口 ${a} 字段 ${s}.prices 无效`);
180
180
  const m = Array.isArray(r.benefits) ? r.benefits : [], b = Array.isArray(r.otherProducts) ? r.otherProducts.filter((p) => typeof p == "string" && p.trim() !== "").map((p) => p.trim()) : [];
181
181
  return {
182
- code: s(r, "code", a),
183
- name: s(r, "name", a).trim(),
182
+ code: o(r, "code", a),
183
+ name: o(r, "name", a).trim(),
184
184
  spaceType: n,
185
185
  tier: r.tier,
186
186
  isDefault: r.isDefault,
187
187
  includedSeats: g(r, "includedSeats", a),
188
188
  monthlyPoints: g(r, "monthlyPoints", a),
189
- prices: r.prices.map((p, N) => X(p, `${o}.prices[${N}]`)),
190
- benefits: m.map((p, N) => Y(p, `${o}.benefits[${N}]`)),
189
+ prices: r.prices.map((p, N) => X(p, `${s}.prices[${N}]`)),
190
+ benefits: m.map((p, N) => Y(p, `${s}.benefits[${N}]`)),
191
191
  otherProducts: b
192
192
  };
193
193
  }, L = (t, e) => {
194
- const o = u(t, y, "data")[e];
195
- if (!Array.isArray(o) || o.some((r) => typeof r != "string"))
194
+ const s = u(t, y, "data")[e];
195
+ if (!Array.isArray(s) || s.some((r) => typeof r != "string"))
196
196
  throw new Error(`接口 ${y} 字段 ${e} 无效`);
197
- return [...o];
197
+ return [...s];
198
198
  }, Q = (t) => {
199
199
  if (!Array.isArray(t)) throw new Error(`接口 ${a} 字段 data 无效`);
200
200
  return t.map(J);
201
201
  }, ut = (t, e) => {
202
- const o = e === "/" ? "" : e;
202
+ const s = e === "/" ? "" : e;
203
203
  return {
204
204
  async reportBehaviorEvents(r) {
205
205
  r.length !== 0 && await t.post(W, { events: r });
206
206
  },
207
207
  startLogin(r, n) {
208
208
  const m = M(r, n);
209
- return `${o}${d}/startLogin?returnPath=${encodeURIComponent(m)}`;
209
+ return `${s}${d}/startLogin?returnPath=${encodeURIComponent(m)}`;
210
210
  },
211
211
  async getSession() {
212
212
  return D(l(c, await t.get(c)));
@@ -227,7 +227,7 @@ const v = (t) => t.includes("\\") || [...t].some((e) => {
227
227
  async getEntitlements() {
228
228
  const r = l(P, await t.get(P));
229
229
  if (!Array.isArray(r)) throw new Error(`接口 ${P} 字段 data 无效`);
230
- return r.map((n, m) => U(n, P, `entitlements[${m}]`));
230
+ return r.map((n, m) => R(n, P, `entitlements[${m}]`));
231
231
  },
232
232
  async getSubscription() {
233
233
  return G(l(f, await t.get(f)));
@@ -237,7 +237,7 @@ const v = (t) => t.includes("\\") || [...t].some((e) => {
237
237
  },
238
238
  async logout() {
239
239
  const r = l(E, await t.post(E));
240
- return { endSessionUrl: k(r) };
240
+ return { endSessionUrl: q(r) };
241
241
  },
242
242
  async getShownPrompts(r) {
243
243
  const n = await t.get(y, { params: { keys: r.join(",") } });
@@ -250,18 +250,18 @@ const v = (t) => t.includes("\\") || [...t].some((e) => {
250
250
  };
251
251
  }, lt = async (t) => {
252
252
  let e = await t.getSession();
253
- const o = await t.getSpaces();
254
- if (o.activeSpaceId !== e.activeSpaceId && (e = await t.getSession()), o.activeSpaceId !== e.activeSpaceId)
253
+ const s = await t.getSpaces();
254
+ if (s.activeSpaceId !== e.activeSpaceId && (e = await t.getSession()), s.activeSpaceId !== e.activeSpaceId)
255
255
  throw new Error("产品会话与统一空间上下文不一致");
256
- return { session: e, spaces: o.spaces };
256
+ return { session: e, spaces: s.spaces };
257
257
  }, dt = (t) => t == null || !Number.isFinite(t) ? "暂无" : t >= 1e8 ? `${(Math.floor(t / 1e7) / 10).toFixed(1)}亿` : t >= 1e4 ? `${(Math.floor(t / 1e3) / 10).toFixed(1)}万` : t.toLocaleString("zh-CN"), mt = (t) => t.toLocaleString("zh-CN", { maximumFractionDigits: 0 }), pt = (t) => t > 0 && t < 0.01 ? "<0.01" : t.toLocaleString("zh-CN", { maximumFractionDigits: 2 }), ft = (t) => t ? `¥${(t / 100).toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}` : "暂无", gt = (t) => {
258
258
  if (t === void 0 || t <= 0) return "";
259
- const e = Math.floor(t / 60), o = Math.floor(t % 60);
260
- return `${e}:${String(o).padStart(2, "0")}`;
259
+ const e = Math.floor(t / 60), s = Math.floor(t % 60);
260
+ return `${e}:${String(s).padStart(2, "0")}`;
261
261
  }, wt = (t) => {
262
262
  if (t === void 0 || t <= 0) return "暂无";
263
- const e = Math.floor(t / 3600), o = Math.floor(t % 3600 / 60), r = t % 60;
264
- return e > 0 ? `${e}小时${o}分` : o > 0 ? `${o}分${r}秒` : `${r}秒`;
263
+ const e = Math.floor(t / 3600), s = Math.floor(t % 3600 / 60), r = t % 60;
264
+ return e > 0 ? `${e}小时${s}分` : s > 0 ? `${s}分${r}秒` : `${r}秒`;
265
265
  }, ht = (t) => {
266
266
  const e = new Date(t);
267
267
  return Number.isNaN(e.getTime()) ? "暂无" : new Intl.DateTimeFormat("zh-CN", { dateStyle: "short", timeStyle: "short" }).format(e);
@@ -276,7 +276,7 @@ const v = (t) => t.includes("\\") || [...t].some((e) => {
276
276
  serviceUnavailable: !1
277
277
  }), yt = () => {
278
278
  let t = Z();
279
- const e = /* @__PURE__ */ new Set(), o = (r) => {
279
+ const e = /* @__PURE__ */ new Set(), s = (r) => {
280
280
  t = r, e.forEach((n) => n());
281
281
  };
282
282
  return {
@@ -289,23 +289,26 @@ const v = (t) => t.includes("\\") || [...t].some((e) => {
289
289
  return ((r = t.session) == null ? void 0 : r.csrfToken) ?? null;
290
290
  },
291
291
  setContext(r) {
292
- o({ session: r.session, spaces: [...r.spaces], bootstrapped: !0, serviceUnavailable: !1 });
292
+ s({ session: r.session, spaces: [...r.spaces], bootstrapped: !0, serviceUnavailable: !1 });
293
293
  },
294
294
  setBootstrapping() {
295
- o({ ...t, bootstrapped: !1, serviceUnavailable: !1 });
295
+ s({ ...t, bootstrapped: !1, serviceUnavailable: !1 });
296
296
  },
297
297
  clear(r = {}) {
298
- o({ session: null, spaces: [], bootstrapped: !0, serviceUnavailable: r.unavailable ?? !1 });
298
+ s({ session: null, spaces: [], bootstrapped: !0, serviceUnavailable: r.unavailable ?? !1 });
299
299
  }
300
300
  };
301
- }, R = _(null), bt = R.Provider, tt = () => {
302
- const t = F(R);
301
+ }, _ = x(null), bt = _.Provider, tt = () => {
302
+ const t = z(_);
303
303
  if (!t) throw new Error("AuthStoreProvider 尚未初始化");
304
304
  return t;
305
305
  }, Pt = () => {
306
306
  const t = tt();
307
- return x(t.subscribe, t.getState, t.getState);
308
- }, Et = (t) => t instanceof Error && t.message.trim() ? t.message : "请稍后重试;如问题持续,请联系管理员。", $t = (t, e) => z(t).status === e, C = "24city.console.logout-at", et = 15e3;
307
+ return F(t.subscribe, t.getState, t.getState);
308
+ }, Et = (t) => t instanceof Error && t.message.trim() ? t.message : "请稍后重试;如问题持续,请联系管理员。", $t = (t, e) => O(t).status === e, Nt = (t) => {
309
+ const { category: e, status: s } = O(t);
310
+ return e === "network" || e === "timeout" || s === 502 || s === 503 || s === 504;
311
+ }, C = "24city.console.logout-at", et = 15e3;
309
312
  let w = null;
310
313
  const rt = () => {
311
314
  try {
@@ -314,68 +317,69 @@ const rt = () => {
314
317
  return Number.NaN;
315
318
  }
316
319
  };
317
- function Nt(t = Date.now()) {
320
+ function It(t = Date.now()) {
318
321
  try {
319
322
  window.localStorage.setItem(C, String(t));
320
323
  } catch {
321
324
  }
322
325
  }
323
- function ot() {
326
+ function st() {
324
327
  try {
325
328
  window.localStorage.removeItem(C);
326
329
  } catch {
327
330
  }
328
331
  }
329
- function It() {
332
+ function At() {
330
333
  w = "leaving";
331
334
  }
332
- function At() {
335
+ function vt() {
333
336
  return w === "leaving";
334
337
  }
335
- function vt(t = Date.now()) {
338
+ function Ct(t = Date.now()) {
336
339
  if (w === "leaving") return !1;
337
340
  const e = t - rt();
338
341
  return e >= 0 && e < et && (w = "logged-out"), w === "logged-out";
339
342
  }
340
- function Ct() {
343
+ function Tt() {
341
344
  return w === "logged-out";
342
345
  }
343
- function Tt() {
346
+ function Dt() {
344
347
  w === "logged-out" && (w = null);
345
348
  }
346
- function Dt() {
347
- w = null, ot();
349
+ function Lt() {
350
+ w = null, st();
348
351
  }
349
352
  export {
350
353
  bt as A,
351
- s as B,
352
- M as C,
353
- Et as D,
354
- l as E,
355
- Nt as a,
354
+ u as B,
355
+ o as C,
356
+ M as D,
357
+ Et as E,
358
+ l as F,
359
+ It as a,
356
360
  yt as b,
357
361
  ut as c,
358
- Ct as d,
359
- Dt as e,
362
+ Tt as d,
363
+ Lt as e,
360
364
  lt as f,
361
365
  tt as g,
362
366
  pt as h,
363
- At as i,
367
+ vt as i,
364
368
  gt as j,
365
369
  St as k,
366
- It as l,
370
+ At as l,
367
371
  ht as m,
368
- vt as n,
372
+ Ct as n,
369
373
  wt as o,
370
374
  dt as p,
371
375
  mt as q,
372
- Tt as r,
376
+ Dt as r,
373
377
  ft as s,
374
378
  $t as t,
375
379
  Pt as u,
376
380
  ct as v,
377
- ot as w,
381
+ st as w,
378
382
  it as x,
379
- g as y,
380
- u as z
383
+ Nt as y,
384
+ g as z
381
385
  };
@@ -2,8 +2,8 @@ import { jsx as t } from "react/jsx-runtime";
2
2
  import { QueryClient as c, QueryClientProvider as l } from "@tanstack/react-query";
3
3
  import { useMemo as i } from "react";
4
4
  import { CustomerRuntimeConfigProvider as f } from "@24city/web-runtime/runtime-config-provider";
5
- import { A as d } from "./auth-provider-3AIfwcdS.js";
6
- import { b as m, A as p } from "./logout-signal-CsnJzWTz.js";
5
+ import { A as d } from "./auth-provider-Cwib6lRM.js";
6
+ import { b as m, A as p } from "./logout-signal-qvHorCCF.js";
7
7
  import { U as C, E as y } from "./unsupported-browser-Dwq1mNRy.js";
8
8
  import { C as h } from "./context-CaVim6ZO.js";
9
9
  import { parseCustomerRuntimeConfig as R, loadCustomerRuntimeConfig as v } from "@24city/web-runtime/core/runtime-config";