@tbox.cn/app-module-mall-core 0.4.4 → 1.0.0-alpha.10

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.
Files changed (33) hide show
  1. package/AGENTS.md +3 -3
  2. package/README.md +4 -4
  3. package/dist/{chunk-QPBYZO27.js → chunk-ZBHJWURF.js} +1399 -1611
  4. package/dist/{chunk-FIHBQMON.js → chunk-ZVXAPBVE.js} +1 -1
  5. package/dist/client/index.d.ts +0 -11
  6. package/dist/client/index.js +1 -1
  7. package/dist/index.js +2 -2
  8. package/dist/server/index.d.ts +16 -16
  9. package/dist/server/index.js +1 -1
  10. package/package.json +7 -7
  11. package/src/client/HomeActivityDetailDialog.tsx +21 -81
  12. package/src/client/MallHome.tsx +109 -54
  13. package/src/client/cards/overrides/BumpInActivityChatCard.tsx +1 -1
  14. package/src/client/components/ActivityDetailPresentation/index.tsx +102 -9
  15. package/src/client/components/MemberGateSheet/index.tsx +38 -92
  16. package/src/client/home-slot.tsx +8 -64
  17. package/src/client/index.ts +4 -3
  18. package/src/client/member-gate-overlay.tsx +89 -0
  19. package/src/server/module-ports.ts +1 -1
  20. package/tbox.module.json +1 -2
  21. package/tests/MemberGateSheet.test.tsx +9 -0
  22. package/tests/home-slot.test.tsx +110 -30
  23. package/tsup.config.ts +0 -1
  24. package/dist/HomeActivityDetailDialog-2GJFYSMZ.less +0 -178
  25. package/dist/MallHome-PABCNS6D.less +0 -623
  26. package/dist/home-slot-WBZ6ONDP.less +0 -4
  27. package/dist/index-ELJ55M66.less +0 -256
  28. package/dist/index-U5YRUY7P.less +0 -352
  29. package/src/client/HomeActivityDetailDialog.less +0 -178
  30. package/src/client/MallHome.less +0 -623
  31. package/src/client/components/ActivityDetailPresentation/index.less +0 -352
  32. package/src/client/components/MemberGateSheet/index.less +0 -256
  33. package/src/client/home-slot.less +0 -4
@@ -1,1704 +1,1492 @@
1
- // src/client/home-slot.tsx
2
- import { useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo2, useRef as useRef4, useState as useState3 } from "react";
3
- import { createLogger, getAuthClient, getLoginState, isInAlipayShell as isInAlipayShell2, waitForSocketOpen } from "@tbox.cn/app-agent-sdk-client";
4
- import { RawCardRenderer, toast, useChatStore, useChatStoreApi } from "@tbox.cn/app-agent-ui-kit";
1
+ // src/client/index.ts
2
+ import { createElement } from "react";
3
+
4
+ // src/client/member-gate-overlay.tsx
5
+ import { useEffect as useEffect2, useMemo } from "react";
6
+ import { createLogger, getAuthClient, getLoginState, isInAlipayShell, waitForSocketOpen } from "@tbox.cn/app-agent-sdk-client";
7
+ import { toast, useChatStore, useChatStoreApi } from "@tbox.cn/app-agent-ui-kit";
5
8
  import { readMallIdFromUrl } from "@tbox.cn/app-contracts-mall";
6
9
 
7
- // src/client/MallHome.tsx
8
- import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
9
- import {
10
- BookOpen,
11
- Buildings,
12
- Car,
13
- CaretRight,
14
- Check,
15
- Coins,
16
- Gift,
17
- Headset,
18
- IdentificationCard,
19
- LockSimple,
20
- SignIn,
21
- Sparkle,
22
- Storefront,
23
- Ticket,
24
- UserPlus
25
- } from "@phosphor-icons/react";
26
- import memberServiceIcon from "./member-service-icon-SIGSRKE3.svg";
27
- import parkingServiceIcon from "./parking-service-icon-3A2TGUUM.svg";
28
- import welcomeSparkle from "./welcome-sparkle-transparent-v07-75RL4QUU.png";
29
- import { callJsapi, isInAlipayShell } from "@tbox.cn/app-agent-sdk-client";
10
+ // src/client/components/MemberGateSheet/index.tsx
11
+ import { useEffect, useRef, useState } from "react";
12
+ import { X } from "@phosphor-icons/react";
13
+ import { Overlay } from "@tbox.cn/app-agent-ui-kit/overlay";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ var DEFAULT_TITLE = {
16
+ login: "\u767B\u5F55\u540E\u7EE7\u7EED",
17
+ enroll: "\u5165\u4F1A\u540E\u7EE7\u7EED"
18
+ };
19
+ var DEFAULT_DESCRIPTION = {
20
+ login: "\u767B\u5F55\u540E\u53EF\u67E5\u79EF\u5206\u3001\u9886\u6743\u76CA\u3001\u7F34\u8F66\u8D39",
21
+ enroll: "\u5165\u4F1A\u540E\u53EF\u83B7\u5F97\u79EF\u5206\u3001\u9886\u6743\u76CA\u3001\u7F34\u8F66\u8D39"
22
+ };
23
+ var CONFIRM_LABEL = {
24
+ login: "\u7ACB\u5373\u767B\u5F55",
25
+ enroll: "\u7ACB\u5373\u5165\u4F1A"
26
+ };
27
+ function MemberGateSheet({
28
+ context,
29
+ phase,
30
+ message,
31
+ busy,
32
+ onConfirm,
33
+ onRetry,
34
+ onDismiss
35
+ }) {
36
+ const closeRef = useRef(null);
37
+ const confirmButtonRef = useRef(null);
38
+ const openingRef = useRef(false);
39
+ const [closing, setClosing] = useState(false);
40
+ const requestDismiss = () => setClosing(true);
41
+ const contextId = context.id;
42
+ const titleId = `member-login-sheet-title-${contextId}`;
43
+ const descriptionId = `member-login-sheet-description-${contextId}`;
44
+ const isTerminal = phase === "not-enrolled" || phase === "failed";
45
+ const heroTitle = isTerminal ? phase === "not-enrolled" ? context.kind === "enroll" ? "\u5C1A\u672A\u5B8C\u6210\u5165\u4F1A" : "\u5C1A\u672A\u5B8C\u6210\u767B\u5F55" : "\u64CD\u4F5C\u672A\u5B8C\u6210" : context.title ?? DEFAULT_TITLE[context.kind];
46
+ const description = isTerminal ? phase === "not-enrolled" ? "\u82E5\u4F60\u521A\u5728\u5546\u573A\u5C0F\u7A0B\u5E8F\u5B8C\u6210\u8FC7\u64CD\u4F5C\uFF0C\u53EF\u80FD\u9700\u8981\u4E00\u70B9\u65F6\u95F4\u540C\u6B65" : message ?? "\u8BF7\u7A0D\u540E\u91CD\u8BD5" : context.subtitle ?? DEFAULT_DESCRIPTION[context.kind];
47
+ useEffect(() => {
48
+ if (phase === "idle") {
49
+ openingRef.current = false;
50
+ }
51
+ }, [phase, contextId]);
52
+ useEffect(() => {
53
+ setClosing(false);
54
+ closeRef.current?.focus({ preventScroll: true });
55
+ }, [contextId]);
56
+ const performConfirm = () => {
57
+ if (openingRef.current) return;
58
+ openingRef.current = true;
59
+ onConfirm();
60
+ };
61
+ const confirmLabel = busy ? "\u56DE\u7B54\u751F\u6210\u4E2D\u2026" : phase === "opening" ? "\u6B63\u5728\u6253\u5F00\u5546\u573A\u5C0F\u7A0B\u5E8F\u2026" : CONFIRM_LABEL[context.kind];
62
+ const confirmDisabled = busy || phase !== "idle";
63
+ return /* @__PURE__ */ jsxs(
64
+ Overlay,
65
+ {
66
+ open: !closing,
67
+ onDismiss: requestDismiss,
68
+ onExited: onDismiss,
69
+ exitMs: 220,
70
+ placement: "bottom",
71
+ labelledBy: titleId,
72
+ describedBy: descriptionId,
73
+ initialFocus: closeRef,
74
+ rootClassName: "member-login-sheet group",
75
+ maskClassName: "bg-scrim animate-[member-login-mask-in_180ms_ease-out_both] group-data-[state=closed]:animate-[member-login-mask-out_160ms_ease-in_both] motion-reduce:animate-none",
76
+ panelClassName: "member-login-sheet__panel flex h-[58vh] min-h-0 w-full max-w-[560px] flex-col overflow-hidden rounded-t-[28px] bg-card shadow-[0_-14px_44px_rgba(35,47,28,0.16)] animate-[member-login-sheet-in_260ms_cubic-bezier(0.22,0.72,0.24,1)_both] [@media(max-height:620px)]:h-[64vh] [@media(max-height:620px)]:supports-[height:100dvh]:h-[64dvh] landscape:[@media(max-height:500px)]:h-[88vh] landscape:[@media(max-height:500px)]:supports-[height:100dvh]:h-[88dvh] max-h-[calc(100vh-env(safe-area-inset-top)-12px)] supports-[height:100dvh]:max-h-[calc(100dvh-env(safe-area-inset-top)-12px)] group-data-[state=closed]:animate-[member-login-sheet-out_200ms_ease-in_both] motion-reduce:animate-none",
77
+ children: [
78
+ /* @__PURE__ */ jsx("div", { className: "member-login-sheet__handle absolute left-1/2 top-2.25 z-10 h-1 w-9.5 -translate-x-1/2 rounded-full bg-neutral-soft", "aria-hidden": "true" }),
79
+ /* @__PURE__ */ jsx(
80
+ "button",
81
+ {
82
+ ref: closeRef,
83
+ type: "button",
84
+ className: "member-login-sheet__close absolute right-4.5 top-4.5 z-20 grid size-9 place-items-center rounded-full border border-border bg-card p-0 text-foreground shadow-md outline-none focus-visible:ring-3 focus-visible:ring-focus-ring",
85
+ "aria-label": "\u5173\u95ED\u767B\u5F55\u63D0\u793A",
86
+ onClick: requestDismiss,
87
+ children: /* @__PURE__ */ jsx(X, { size: 18, weight: "bold", "aria-hidden": "true" })
88
+ }
89
+ ),
90
+ /* @__PURE__ */ jsxs("div", { className: "member-login-sheet__scroll flex min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain pb-[env(safe-area-inset-bottom)] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", children: [
91
+ /* @__PURE__ */ jsx("div", { className: "member-login-sheet__hero relative min-h-40 w-full flex-[1_1_190px] overflow-hidden member-hero [@media(max-height:620px)]:min-h-29 [@media(max-height:620px)]:flex-[0_0_116px]", "aria-hidden": "true" }),
92
+ /* @__PURE__ */ jsx("div", { className: "member-login-sheet__tear relative z-10 -mt-3.75 h-4 w-full shrink-0 bg-card [clip-path:polygon(0_70%,8%_28%,15%_72%,24%_22%,33%_66%,43%_18%,53%_72%,63%_25%,72%_68%,82%_20%,91%_64%,100%_32%,100%_100%,0_100%)]", "aria-hidden": "true" }),
93
+ /* @__PURE__ */ jsxs("div", { className: "member-login-sheet__content shrink-0 px-3 pb-[calc(14px+env(safe-area-inset-bottom))] pt-3 text-center [@media(max-height:620px)]:pt-2 [&_h2]:m-0 [&_h2]:text-xl [&_h2]:font-bold [&_h2]:leading-tight [&_h2]:text-foreground", children: [
94
+ /* @__PURE__ */ jsx("h2", { id: titleId, children: heroTitle }),
95
+ /* @__PURE__ */ jsx("p", { id: descriptionId, className: "member-login-sheet__description mt-1.5 text-sm leading-normal text-muted-foreground", children: description }),
96
+ isTerminal ? /* @__PURE__ */ jsxs("div", { className: "member-login-sheet__status-actions mx-auto mt-2 grid w-[min(100%,292px)] grid-cols-2 gap-2.5 [&_button]:min-h-11 [&_button]:rounded-xl [&_button]:border-0 [&_button]:bg-muted [&_button]:px-2.5 [&_button]:text-sm [&_button]:font-semibold [&_button]:text-secondary-foreground [&_button:last-child]:bg-member-accent [&_button:last-child]:text-white [&_button:disabled]:cursor-not-allowed [&_button:disabled]:opacity-68 [&_button:focus-visible]:ring-3 [&_button:focus-visible]:ring-focus-ring [&_button:active:not(:disabled)]:scale-98", children: [
97
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: requestDismiss, children: "\u6682\u4E0D" }),
98
+ /* @__PURE__ */ jsx(
99
+ "button",
100
+ {
101
+ ref: confirmButtonRef,
102
+ type: "button",
103
+ disabled: busy,
104
+ onClick: () => onRetry(),
105
+ children: busy ? "\u56DE\u7B54\u751F\u6210\u4E2D\u2026" : phase === "not-enrolled" ? "\u91CD\u8BD5\u5165\u4F1A" : "\u91CD\u8BD5"
106
+ }
107
+ )
108
+ ] }) : /* @__PURE__ */ jsx(
109
+ "button",
110
+ {
111
+ ref: confirmButtonRef,
112
+ type: "button",
113
+ className: "member-login-sheet__login mx-auto mt-2 flex min-h-11 w-[min(100%,292px)] items-center justify-center rounded-xl border-0 bg-member-accent px-4 text-sm font-semibold leading-none text-white shadow-md transition active:scale-98 disabled:cursor-not-allowed disabled:opacity-68",
114
+ disabled: confirmDisabled,
115
+ onClick: performConfirm,
116
+ children: phase === "syncing" ? "\u8EAB\u4EFD\u540C\u6B65\u4E2D\u2026" : confirmLabel
117
+ }
118
+ )
119
+ ] })
120
+ ] })
121
+ ]
122
+ }
123
+ );
124
+ }
30
125
 
31
- // src/client/home-runtime.ts
32
- function parseBumpInDetailCard(value) {
33
- if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
34
- const card = value;
35
- if (typeof card.id !== "string" || !card.id.trim() || card.cardType !== "promotion-bumpin-activity" || card.status !== "ready" || !card.data || typeof card.data !== "object" || Array.isArray(card.data) || card.data["mode"] !== "detail" || typeof card.data["activityRef"] !== "string" || !card.data["activityRef"].trim() || typeof card.data["title"] !== "string" || !card.data["title"].trim() || typeof card.data["actStatus"] !== "string" || !Array.isArray(card.data["vouchers"])) return void 0;
36
- return card;
126
+ // src/client/components/MemberGateSheet/model.ts
127
+ var MEMBER_GATE_CARD_TYPES = ["member-login-cta", "member-enrollment-cta"];
128
+ function isMemberGateCard(card) {
129
+ return MEMBER_GATE_CARD_TYPES.includes(card.cardType);
37
130
  }
38
- var PLATE_PATTERN = /^[\u3400-\u9fff][A-HJ-NP-Z][A-HJ-NP-Z0-9]{5,6}$/;
39
- function parseMemberState(value) {
40
- if (!value || typeof value !== "object") return { status: "unavailable" };
41
- const member = value;
42
- if (member.authState === "unauthenticated" && member.state === "unknown") {
43
- return { status: "unauthenticated" };
44
- }
45
- if (member.authState !== "authenticated") return { status: "error" };
46
- if (member.state === "not_enrolled") return { status: "not_enrolled" };
47
- if (member.state === "closed") return { status: "closed" };
48
- if (member.state === "unknown") return { status: "unknown" };
49
- if (member.state !== "active") return { status: "error" };
50
- const balance = Number.isSafeInteger(member.balance) && member.balance >= 0 ? member.balance : void 0;
51
- const membershipLabel = typeof member.membershipLabel === "string" && member.membershipLabel.trim() ? member.membershipLabel.trim() : void 0;
131
+ function filterInlineCards(cards2) {
132
+ return cards2.filter((card) => !isMemberGateCard(card));
133
+ }
134
+ function selectLatestMemberGateCard(liveMessageIds, cardsByMessageId, orphanCards) {
135
+ const candidates = [
136
+ ...liveMessageIds.flatMap((messageId) => cardsByMessageId[messageId] ?? []),
137
+ ...orphanCards
138
+ ].filter((card) => isMemberGateCard(card) && !card.isHistory);
139
+ return candidates.reduce((latest, card) => {
140
+ if (!latest) return card;
141
+ const latestCreatedAt = latest.meta?.createdAt ?? Number.NEGATIVE_INFINITY;
142
+ const cardCreatedAt = card.meta?.createdAt ?? Number.NEGATIVE_INFINITY;
143
+ return cardCreatedAt >= latestCreatedAt ? card : latest;
144
+ }, null);
145
+ }
146
+
147
+ // src/client/member-gate.ts
148
+ import { useSyncExternalStore } from "react";
149
+ var GATE_CANCEL_TOAST = "\u5DF2\u53D6\u6D88\uFF0C\u672A\u5B8C\u6210\u5165\u4F1A";
150
+ var GATE_NOT_ENROLLED_TOAST = "\u5C1A\u672A\u5B8C\u6210\u5165\u4F1A";
151
+ var GATE_UNAVAILABLE_TOAST = "\u6B63\u5728\u6253\u5F00\u652F\u4ED8\u5B9D\u2026";
152
+ var GATE_UNAVAILABLE_FALLBACK = "\u5F53\u524D\u73AF\u5883\u6682\u4E0D\u652F\u6301\u8DF3\u8F6C\uFF0C\u8BF7\u5728\u652F\u4ED8\u5B9D\u5185\u6253\u5F00\u5C0F\u7A0B\u5E8F";
153
+ var GATE_RELOGIN_FAILED = "\u767B\u5F55\u72B6\u6001\u540C\u6B65\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";
154
+ var GATE_OPEN_FAILED = "\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\u5546\u573A\u5C0F\u7A0B\u5E8F\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5";
155
+ var GATE_PANEL_FAILED = "\u4F1A\u5458\u72B6\u6001\u540C\u6B65\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";
156
+ function gateContextFromCard(card) {
157
+ const isEnroll = card.cardType === "member-enrollment-cta";
158
+ const url = isEnroll ? typeof card.data.enrollUrl === "string" ? card.data.enrollUrl : "" : typeof card.data.loginUrl === "string" ? card.data.loginUrl : "";
52
159
  return {
53
- status: "active",
54
- ...balance !== void 0 ? { balance } : {},
55
- ...membershipLabel ? { membershipLabel } : {}
160
+ id: card.id,
161
+ kind: isEnroll ? "enroll" : "login",
162
+ source: "card",
163
+ ...url ? { url } : {},
164
+ ...typeof card.data.title === "string" && card.data.title ? { title: card.data.title } : {},
165
+ ...typeof card.data.subtitle === "string" && card.data.subtitle ? { subtitle: card.data.subtitle } : {}
56
166
  };
57
167
  }
58
- function parseParkingState(value) {
59
- if (!value || typeof value !== "object") return { status: "unavailable" };
60
- const parking = value;
61
- if (parking.status === "unauthenticated") return { status: "unauthenticated" };
62
- if (parking.status === "membership_required") return { status: "membership_required" };
63
- if (parking.status === "empty") return { status: "empty" };
64
- if (parking.status === "unavailable") return { status: "unavailable" };
65
- if (parking.status === "error") return { status: "error" };
66
- if (parking.status === "ready" && typeof parking.primaryPlate === "string" && PLATE_PATTERN.test(parking.primaryPlate) && Number.isSafeInteger(parking.plateCount) && parking.plateCount > 0) {
67
- const freeMinutesRemaining = Number.isSafeInteger(parking.freeMinutesRemaining) && parking.freeMinutesRemaining >= 0 ? parking.freeMinutesRemaining : void 0;
68
- const parkedMinutes = Number.isSafeInteger(parking.parkedMinutes) && parking.parkedMinutes > 0 ? parking.parkedMinutes : void 0;
69
- const parkedPlates = Array.isArray(parking.parkedPlates) ? parking.parkedPlates.filter((p) => typeof p === "string" && PLATE_PATTERN.test(p)) : void 0;
70
- return {
71
- status: "ready",
72
- primaryPlate: parking.primaryPlate,
73
- plateCount: parking.plateCount,
74
- ...parkedPlates && parkedPlates.length > 0 ? { parkedPlates } : {},
75
- ...freeMinutesRemaining !== void 0 ? { freeMinutesRemaining } : {},
76
- ...parkedMinutes !== void 0 ? { parkedMinutes } : {}
77
- };
78
- }
79
- return { status: "error" };
80
- }
81
- async function fetchLinkedPanelState(token, mallId, fetcher = fetch, signal) {
82
- if (!token) {
83
- return {
84
- member: { status: "unauthenticated" },
85
- parking: { status: "unauthenticated" },
86
- enrollUrl: null
87
- };
88
- }
89
- if (!mallId) {
90
- return {
91
- member: { status: "unavailable" },
92
- parking: { status: "unavailable" },
93
- enrollUrl: null
94
- };
95
- }
96
- try {
97
- const response = await fetcher(`${MALL_CORE_API}/linked-panel?mallId=${encodeURIComponent(mallId)}`, {
98
- headers: { Authorization: `Bearer ${token}` },
99
- ...signal ? { signal } : {}
100
- });
101
- if (response.status === 401) {
102
- return {
103
- member: { status: "unauthenticated" },
104
- parking: { status: "unauthenticated" },
105
- enrollUrl: null
106
- };
168
+ var INITIAL_STATE = { phase: "idle", sheetVisible: false };
169
+ function createMemberGate(deps) {
170
+ let state = INITIAL_STATE;
171
+ const listeners = /* @__PURE__ */ new Set();
172
+ let pendingReplay = null;
173
+ let flightSeq = 0;
174
+ const log = (message) => {
175
+ deps.log?.(message);
176
+ };
177
+ const setState = (partial) => {
178
+ state = { ...state, ...partial };
179
+ for (const notify of listeners) notify();
180
+ };
181
+ const inFlight = () => state.phase === "opening" || state.phase === "syncing";
182
+ const hideContextCard = () => {
183
+ if (state.card && !state.card.synthetic) deps.hideCard(state.card.id);
184
+ };
185
+ const closeSheet = () => {
186
+ setState({ sheetVisible: false });
187
+ };
188
+ const settleUpgraded = async () => {
189
+ setState({ phase: "idle" });
190
+ closeSheet();
191
+ hideContextCard();
192
+ deps.refreshPanel();
193
+ const replay = pendingReplay;
194
+ pendingReplay = null;
195
+ if (!replay) {
196
+ log("replay skipped:reason=none");
197
+ return;
107
198
  }
108
- if (response.status === 403) {
109
- return {
110
- member: { status: "unavailable" },
111
- parking: { status: "unavailable" },
112
- enrollUrl: null
113
- };
199
+ const socketOpen = await deps.waitForSocketOpen(5e3);
200
+ if (!socketOpen) {
201
+ log("replay skipped:reason=socket-timeout");
202
+ return;
114
203
  }
115
- if (!response.ok) {
116
- return { member: { status: "error" }, parking: { status: "error" }, enrollUrl: null };
204
+ if (deps.isGenerating()) {
205
+ log("replay skipped:reason=generating");
206
+ return;
117
207
  }
118
- const payload = await response.json();
119
- const enrollUrl = typeof payload.member?.enrollUrl === "string" && payload.member.enrollUrl.trim() ? payload.member.enrollUrl.trim() : null;
120
- return {
121
- member: parseMemberState(payload.member),
122
- parking: parseParkingState(payload.parking),
123
- enrollUrl
124
- };
125
- } catch (error) {
126
- if (error.name === "AbortError") throw error;
127
- return { member: { status: "error" }, parking: { status: "error" }, enrollUrl: null };
128
- }
129
- }
130
- var MALL_CORE_API = "/api/m/mall-core";
131
- function pickMallId(helloMallId, urlMallId) {
132
- return helloMallId ?? urlMallId;
133
- }
134
- async function fetchLinkedOrderState(token, fetcher = fetch, signal) {
135
- if (!token) return { status: "unauthenticated" };
136
- try {
137
- const response = await fetcher(`${MALL_CORE_API}/bumpin-banner`, {
138
- headers: { Authorization: `Bearer ${token}` },
139
- ...signal ? { signal } : {}
140
- });
141
- if (response.status === 401) return { status: "unauthenticated" };
142
- if (response.status === 403) return { status: "forbidden" };
143
- if (!response.ok) return { status: "error" };
144
- const payload = await response.json();
145
- if (!payload.supported || !payload.banner) return { status: "unavailable" };
146
- const detailCard = parseBumpInDetailCard(payload.detailCard);
147
- return {
148
- status: "ready",
149
- banner: payload.banner,
150
- ...detailCard ? { detailCard } : {}
151
- };
152
- } catch (error) {
153
- if (error.name === "AbortError") throw error;
154
- return { status: "error" };
155
- }
156
- }
157
- function throwIfAborted(signal) {
158
- if (signal?.aborted) {
159
- throw new DOMException("The operation was aborted.", "AbortError");
160
- }
161
- }
162
- async function loadLinkedOrderState(auth, fetcher = fetch, signal, onAuthRefreshed) {
163
- const initialAuth = await auth.ensureAuth();
164
- const first = await fetchLinkedOrderState(initialAuth.token, fetcher, signal);
165
- if (first.status !== "unauthenticated" || !initialAuth.token) return first;
166
- throwIfAborted(signal);
167
- const refreshedAuth = await auth.refreshAuth();
168
- throwIfAborted(signal);
169
- await onAuthRefreshed?.();
170
- throwIfAborted(signal);
171
- return fetchLinkedOrderState(refreshedAuth.token, fetcher, signal);
172
- }
173
- async function loadLinkedPanelState(auth, mallId, fetcher = fetch, signal, onAuthRefreshed) {
174
- const initialAuth = await auth.ensureAuth();
175
- const first = await fetchLinkedPanelState(initialAuth.token, mallId, fetcher, signal);
176
- if (first.member.status !== "unauthenticated" || !initialAuth.token) return first;
177
- throwIfAborted(signal);
178
- const refreshedAuth = await auth.refreshAuth();
179
- throwIfAborted(signal);
180
- await onAuthRefreshed?.();
181
- throwIfAborted(signal);
182
- return fetchLinkedPanelState(refreshedAuth.token, mallId, fetcher, signal);
183
- }
184
- function parseHomeConfig(value) {
185
- if (!value || typeof value !== "object" || Array.isArray(value)) return { showDevServices: false };
186
- return { showDevServices: value.showDevServices === true };
187
- }
188
- async function fetchHomeConfigOnce(token, fetcher, signal) {
189
- if (!token) return { showDevServices: false };
190
- try {
191
- const response = await fetcher(`${MALL_CORE_API}/config`, {
192
- headers: { Authorization: `Bearer ${token}` },
193
- ...signal ? { signal } : {}
194
- });
195
- if (response.status === 401) return "unauthenticated";
196
- if (!response.ok) return { showDevServices: false };
197
- return parseHomeConfig(await response.json());
198
- } catch (error) {
199
- if (error.name === "AbortError") throw error;
200
- return { showDevServices: false };
201
- }
202
- }
203
- async function loadHomeConfig(auth, fetcher = fetch, signal, onAuthRefreshed) {
204
- const initialAuth = await auth.ensureAuth();
205
- const first = await fetchHomeConfigOnce(initialAuth.token, fetcher, signal);
206
- if (first !== "unauthenticated") return first;
207
- throwIfAborted(signal);
208
- const refreshedAuth = await auth.refreshAuth();
209
- throwIfAborted(signal);
210
- await onAuthRefreshed?.();
211
- throwIfAborted(signal);
212
- const retried = await fetchHomeConfigOnce(refreshedAuth.token, fetcher, signal);
213
- return retried === "unauthenticated" ? { showDevServices: false } : retried;
214
- }
215
- function parseProgressInteger(value) {
216
- const normalized = value?.trim() ?? "";
217
- if (!/^\d+$/.test(normalized)) return null;
218
- const parsed = Number(normalized);
219
- return Number.isSafeInteger(parsed) ? parsed : null;
220
- }
221
- function deriveLinkedOrderProgress(banner) {
222
- if (!banner || banner.progressStyle !== "steps") return null;
223
- const target = parseProgressInteger(banner.totalProgress);
224
- const current = parseProgressInteger(banner.currentProgress);
225
- const unit = banner.progressUnit?.trim();
226
- if (target === null || current === null || target < 1 || current > target || !unit) return null;
227
- return {
228
- completed: current,
229
- target,
230
- unit
231
- };
232
- }
233
- function getLinkedOrderRailFill(completed, target) {
234
- if (target <= 1 || completed <= 1) return "0%";
235
- return `${Math.min(100, (completed - 1) / (target - 1) * 100)}%`;
236
- }
237
-
238
- // src/client/HomeActivityDetailDialog.tsx
239
- import {
240
- useCallback,
241
- useEffect,
242
- useId,
243
- useMemo,
244
- useRef,
245
- useState
246
- } from "react";
247
- import { createPortal } from "react-dom";
248
- import { X } from "@phosphor-icons/react";
249
-
250
- // src/client/components/ActivityDetailPresentation/index.tsx
251
- import "./index-U5YRUY7P.less";
252
- import { jsx, jsxs } from "react/jsx-runtime";
253
- function ActivityDetailHero({ variant = "page" }) {
254
- const className = variant === "strip" ? "activity-detail-presentation__poster activity-detail-presentation__poster--stage" : "activity-detail-presentation__poster";
255
- return /* @__PURE__ */ jsx("span", { className, role: "img", "aria-label": "\u53C2\u4E0E\u8054\u5355\uFF0C\u78B0\u51FA\u60CA\u559C" });
256
- }
257
- function ActivityDetailPresentation({
258
- children,
259
- variant
260
- }) {
261
- return /* @__PURE__ */ jsxs("div", { className: `activity-detail-presentation activity-detail-presentation--${variant}`, children: [
262
- /* @__PURE__ */ jsx("div", { className: `activity-detail-presentation__hero activity-detail-presentation__hero--${variant}`, children: /* @__PURE__ */ jsx(ActivityDetailHero, { variant: variant === "inline" ? "strip" : "page" }) }),
263
- /* @__PURE__ */ jsx("div", { className: "activity-detail-presentation__body", children })
264
- ] });
265
- }
266
-
267
- // src/client/HomeActivityDetailDialog.tsx
268
- import "./HomeActivityDetailDialog-2GJFYSMZ.less";
269
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
270
- var FOCUSABLE_SELECTOR = [
271
- "button:not([disabled])",
272
- "[href]",
273
- "input:not([disabled])",
274
- "select:not([disabled])",
275
- "textarea:not([disabled])",
276
- '[tabindex]:not([tabindex="-1"])'
277
- ].join(",");
278
- var MORPH_DURATION_MS = 300;
279
- function getHomeActivityDialogId(cardId) {
280
- return `home-activity-detail-${cardId.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
281
- }
282
- function rectOf(value) {
283
- return { top: value.top, left: value.left, width: value.width, height: value.height };
284
- }
285
- function targetRect() {
286
- const viewportWidth = window.innerWidth;
287
- const viewportHeight = window.innerHeight;
288
- if (viewportWidth <= 600) return { top: 0, left: 0, width: viewportWidth, height: viewportHeight };
289
- const width = Math.min(620, viewportWidth - 32);
290
- const height = Math.min(820, viewportHeight - 24);
291
- return {
292
- top: (viewportHeight - height) / 2,
293
- left: (viewportWidth - width) / 2,
294
- width,
295
- height
296
- };
297
- }
298
- function isVisibleOrigin(rect) {
299
- return rect.width > 0 && rect.height > 0 && rect.top < window.innerHeight && rect.left < window.innerWidth && rect.top + rect.height > 0 && rect.left + rect.width > 0;
300
- }
301
- function prefersReducedMotion() {
302
- return window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false;
303
- }
304
- function HomeActivityDetailDialog({
305
- card,
306
- origin,
307
- triggerRef,
308
- transitionVisual,
309
- motion = "morph",
310
- children,
311
- onClosed
312
- }) {
313
- const [phase, setPhase] = useState("opening");
314
- const [destination, setDestination] = useState(() => targetRect());
315
- const [closingOrigin, setClosingOrigin] = useState(origin);
316
- const [returnToOrigin, setReturnToOrigin] = useState(true);
317
- const closeRef = useRef(null);
318
- const panelRef = useRef(null);
319
- const closeTimerRef = useRef(null);
320
- const phaseRef = useRef("opening");
321
- const onClosedRef = useRef(onClosed);
322
- const titleId = useId();
323
- const rawTitle = typeof card.data["mainTitle"] === "string" ? card.data["mainTitle"] : typeof card.data["title"] === "string" ? card.data["title"] : "";
324
- const title = rawTitle.trim() || "\u6D3B\u52A8\u8BE6\u60C5";
325
- onClosedRef.current = onClosed;
326
- const finishClose = useCallback(() => {
327
- if (closeTimerRef.current !== null) window.clearTimeout(closeTimerRef.current);
328
- closeTimerRef.current = null;
329
- onClosedRef.current();
330
- }, []);
331
- const requestClose = useCallback(() => {
332
- if (phaseRef.current === "closing") return;
333
- const triggerRect = triggerRef.current?.getBoundingClientRect();
334
- const nextOrigin = triggerRect ? rectOf(triggerRect) : origin;
335
- const canReturnToOrigin = motion === "morph" && isVisibleOrigin(nextOrigin);
336
- if (canReturnToOrigin) setClosingOrigin(nextOrigin);
337
- setReturnToOrigin(canReturnToOrigin);
338
- phaseRef.current = "closing";
339
- setPhase("closing");
340
- closeTimerRef.current = window.setTimeout(
341
- finishClose,
342
- prefersReducedMotion() ? 0 : MORPH_DURATION_MS
343
- );
344
- }, [finishClose, motion, origin, triggerRef]);
345
- useEffect(() => {
346
- const frame = window.requestAnimationFrame(() => {
347
- if (phaseRef.current !== "opening") return;
348
- phaseRef.current = "open";
349
- setPhase("open");
350
- });
351
- return () => window.cancelAnimationFrame(frame);
352
- }, []);
353
- useEffect(() => {
354
- const updateDestination = () => setDestination(targetRect());
355
- window.addEventListener("resize", updateDestination);
356
- return () => window.removeEventListener("resize", updateDestination);
357
- }, []);
358
- useEffect(() => {
359
- const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
360
- const previousBodyOverflow = document.body.style.overflow;
361
- const appRoot = document.getElementById("root");
362
- const previousAriaHidden = appRoot?.getAttribute("aria-hidden") ?? null;
363
- const previousInert = appRoot?.inert ?? false;
364
- const scrollHost = triggerRef.current?.closest(".chat-page__body") ?? null;
365
- const previousScrollOverflow = scrollHost?.style.overflow ?? "";
366
- const previousOverscroll = scrollHost?.style.overscrollBehavior ?? "";
367
- document.body.style.overflow = "hidden";
368
- if (scrollHost) {
369
- scrollHost.style.overflow = "hidden";
370
- scrollHost.style.overscrollBehavior = "none";
208
+ const currentAnchor = deps.lastUserMessage()?.id ?? null;
209
+ if (currentAnchor !== replay.anchorMessageId) {
210
+ log("replay skipped:reason=stale");
211
+ return;
371
212
  }
372
- if (appRoot) {
373
- appRoot.setAttribute("aria-hidden", "true");
374
- appRoot.inert = true;
213
+ deps.sendMessage(replay.query);
214
+ log("replay sent");
215
+ };
216
+ const reloginAndJudge = async (myFlight) => {
217
+ setState({ phase: "syncing" });
218
+ try {
219
+ await deps.retryBootstrap(true);
220
+ } catch {
221
+ log("relogin fail");
222
+ if (flightSeq !== myFlight) return;
223
+ setState({ phase: "failed", message: GATE_RELOGIN_FAILED });
224
+ return;
375
225
  }
376
- closeRef.current?.focus();
377
- const handleKeyDown = (event) => {
378
- if (event.key === "Escape") {
379
- event.preventDefault();
380
- requestClose();
226
+ log("relogin ok");
227
+ if (flightSeq !== myFlight) return;
228
+ const identitySource = deps.getAuthState()?.identity.source;
229
+ const identityOk = identitySource !== void 0 && identitySource !== "anonymous";
230
+ let upgraded;
231
+ if (state.card?.kind === "login") {
232
+ if (flightSeq !== myFlight) return;
233
+ upgraded = identityOk;
234
+ if (!upgraded) {
235
+ setState({ phase: "failed", message: GATE_RELOGIN_FAILED });
381
236
  return;
382
237
  }
383
- if (event.key !== "Tab") return;
384
- const focusable = Array.from(
385
- panelRef.current?.querySelectorAll(FOCUSABLE_SELECTOR) ?? []
386
- );
387
- if (focusable.length === 0) {
388
- event.preventDefault();
389
- panelRef.current?.focus();
238
+ } else {
239
+ const judgeMallId = deps.readMallId();
240
+ let panel;
241
+ try {
242
+ panel = await deps.loadPanel(judgeMallId);
243
+ } catch {
244
+ if (flightSeq !== myFlight) return;
245
+ log(`judge panel-throw mallId=${judgeMallId ?? "none"}`);
246
+ setState({ phase: "failed", message: GATE_PANEL_FAILED });
390
247
  return;
391
248
  }
392
- const first = focusable[0];
393
- const last = focusable[focusable.length - 1];
394
- if (event.shiftKey && document.activeElement === first) {
395
- event.preventDefault();
396
- last.focus();
397
- } else if (!event.shiftKey && document.activeElement === last) {
398
- event.preventDefault();
399
- first.focus();
249
+ if (flightSeq !== myFlight) return;
250
+ const panelStatus = panel.member.status;
251
+ log(`judge panel status=${panelStatus} mallId=${judgeMallId ?? "none"}`);
252
+ if (panelStatus === "unavailable" || panelStatus === "error" || panelStatus === "unknown" || panelStatus === "unauthenticated") {
253
+ setState({ phase: "failed", message: GATE_PANEL_FAILED });
254
+ return;
400
255
  }
401
- };
402
- document.addEventListener("keydown", handleKeyDown);
403
- return () => {
404
- document.removeEventListener("keydown", handleKeyDown);
405
- if (closeTimerRef.current !== null) window.clearTimeout(closeTimerRef.current);
406
- document.body.style.overflow = previousBodyOverflow;
407
- if (scrollHost) {
408
- scrollHost.style.overflow = previousScrollOverflow;
409
- scrollHost.style.overscrollBehavior = previousOverscroll;
256
+ upgraded = identityOk && panelStatus === "active";
257
+ }
258
+ log(`judge ${upgraded ? "active" : "not-enrolled"}`);
259
+ if (upgraded) {
260
+ await settleUpgraded();
261
+ return;
262
+ }
263
+ if (state.sheetVisible) {
264
+ setState({ phase: "not-enrolled" });
265
+ return;
266
+ }
267
+ setState({ phase: "idle" });
268
+ hideContextCard();
269
+ deps.toast(GATE_NOT_ENROLLED_TOAST);
270
+ };
271
+ const runGate = async (myFlight) => {
272
+ setState({ phase: "opening" });
273
+ let receipt;
274
+ try {
275
+ receipt = await deps.getLoginState({ userId: deps.getAuthState()?.identity.userId });
276
+ } catch (error) {
277
+ if (error?.code === "BRIDGE_UNAVAILABLE") {
278
+ log("receipt unavailable");
279
+ const context = state.card;
280
+ if (context?.url) {
281
+ deps.sendUiAction(context.id, { type: "openLink", url: context.url });
282
+ deps.toast(GATE_UNAVAILABLE_TOAST);
283
+ setState({ phase: "idle" });
284
+ closeSheet();
285
+ hideContextCard();
286
+ } else {
287
+ setState({ phase: "failed", message: GATE_UNAVAILABLE_FALLBACK });
288
+ }
289
+ return;
410
290
  }
411
- if (appRoot) {
412
- appRoot.inert = previousInert;
413
- if (previousAriaHidden === null) appRoot.removeAttribute("aria-hidden");
414
- else appRoot.setAttribute("aria-hidden", previousAriaHidden);
291
+ setState({ phase: "failed", message: GATE_OPEN_FAILED });
292
+ return;
293
+ }
294
+ if (flightSeq !== myFlight) return;
295
+ log(`receipt loginStatus=${receipt.loginStatus}`);
296
+ if (receipt.loginStatus === "cancel") {
297
+ deps.toast(GATE_CANCEL_TOAST);
298
+ setState({ phase: "idle" });
299
+ closeSheet();
300
+ hideContextCard();
301
+ return;
302
+ }
303
+ if (receipt.loginStatus === "fail") {
304
+ const message = receipt.message ?? "\u767B\u5F55\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";
305
+ if (state.sheetVisible) setState({ phase: "failed", message });
306
+ else {
307
+ setState({ phase: "idle" });
308
+ hideContextCard();
309
+ deps.toast(message);
415
310
  }
416
- (triggerRef.current ?? previousFocus)?.focus({ preventScroll: true });
417
- };
418
- }, [requestClose, triggerRef]);
419
- const surfaceRect = motion === "fade" ? destination : phase === "opening" ? origin : phase === "closing" ? returnToOrigin ? closingOrigin : destination : destination;
420
- const surfaceStyle = useMemo(() => ({
421
- top: `${surfaceRect.top}px`,
422
- left: `${surfaceRect.left}px`,
423
- width: `${surfaceRect.width}px`,
424
- height: `${surfaceRect.height}px`
425
- }), [surfaceRect]);
426
- return createPortal(
427
- /* @__PURE__ */ jsxs2(
428
- "div",
429
- {
430
- className: "home-activity-detail",
431
- "data-motion": motion,
432
- "data-phase": phase,
433
- "data-return-origin": returnToOrigin ? "true" : "false",
434
- children: [
435
- /* @__PURE__ */ jsx2("button", { type: "button", className: "home-activity-detail__mask", "aria-label": "\u5173\u95ED\u6D3B\u52A8\u8BE6\u60C5", onClick: requestClose }),
436
- /* @__PURE__ */ jsxs2(
437
- "section",
438
- {
439
- ref: panelRef,
440
- id: getHomeActivityDialogId(card.id),
441
- className: "home-activity-detail__surface",
442
- style: surfaceStyle,
443
- role: "dialog",
444
- "aria-modal": "true",
445
- "aria-labelledby": titleId,
446
- tabIndex: -1,
447
- children: [
448
- /* @__PURE__ */ jsx2("h2", { id: titleId, className: "home-activity-detail__sr-title", children: title }),
449
- transitionVisual && /* @__PURE__ */ jsx2("div", { className: "home-activity-detail__transition-visual", "aria-hidden": "true", children: transitionVisual }),
450
- /* @__PURE__ */ jsx2("div", { className: "home-activity-detail__content", children: /* @__PURE__ */ jsx2(ActivityDetailPresentation, { variant: "page", children }) }),
451
- /* @__PURE__ */ jsx2("button", { ref: closeRef, type: "button", className: "home-activity-detail__close", "aria-label": "\u5173\u95ED\u6D3B\u52A8\u8BE6\u60C5\uFF0C\u8FD4\u56DE\u9996\u9875", onClick: requestClose, children: /* @__PURE__ */ jsx2(X, { size: 21, weight: "bold", "aria-hidden": "true" }) })
452
- ]
453
- }
454
- )
455
- ]
311
+ return;
312
+ }
313
+ await reloginAndJudge(myFlight);
314
+ };
315
+ const arm = (context, replayQuery) => {
316
+ if (inFlight()) return;
317
+ if (state.card?.id === context.id && state.sheetVisible) return;
318
+ log(`open source=${context.source ?? "card"}`);
319
+ const anchor = deps.lastUserMessage();
320
+ const query = replayQuery ?? anchor?.content;
321
+ pendingReplay = query === void 0 ? null : { query, anchorMessageId: anchor?.id ?? null };
322
+ setState({ phase: "idle", message: void 0, card: context, sheetVisible: true });
323
+ };
324
+ return {
325
+ getState: () => state,
326
+ subscribe(fn) {
327
+ listeners.add(fn);
328
+ return () => {
329
+ listeners.delete(fn);
330
+ };
331
+ },
332
+ trigger(card, replayQuery) {
333
+ arm(gateContextFromCard(card), replayQuery);
334
+ },
335
+ openGate(context, replayQuery) {
336
+ arm(context, replayQuery);
337
+ },
338
+ confirm() {
339
+ if (state.phase !== "idle" || deps.isGenerating()) return;
340
+ flightSeq += 1;
341
+ void runGate(flightSeq);
342
+ },
343
+ retry() {
344
+ if (deps.isGenerating()) return;
345
+ if (state.phase === "failed") {
346
+ flightSeq += 1;
347
+ void reloginAndJudge(flightSeq);
348
+ return;
456
349
  }
457
- ),
458
- document.body
459
- );
350
+ if (state.phase === "not-enrolled") {
351
+ flightSeq += 1;
352
+ setState({ sheetVisible: true });
353
+ void runGate(flightSeq);
354
+ }
355
+ },
356
+ dismiss() {
357
+ closeSheet();
358
+ if (!inFlight()) hideContextCard();
359
+ }
360
+ };
361
+ }
362
+ function useMemberGate(gate) {
363
+ return useSyncExternalStore(gate.subscribe, gate.getState);
460
364
  }
461
365
 
462
- // src/client/MallHome.tsx
463
- import "./MallHome-PABCNS6D.less";
464
- import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
465
- function HomeServiceCard({
466
- tone,
467
- label,
468
- iconSrc,
469
- primary,
470
- primaryMonospace,
471
- meta,
472
- loading,
473
- loadingLabel,
474
- disabled,
475
- onClick
476
- }) {
477
- const labelId = `mall-home-${tone}-label`;
478
- const valueId = `mall-home-${tone}-value`;
479
- const metaId = `mall-home-${tone}-meta`;
480
- return /* @__PURE__ */ jsx3("section", { className: `mall-home__service-card mall-home__service-card--${tone}`, "aria-label": label, children: /* @__PURE__ */ jsxs3(
481
- "button",
482
- {
483
- className: "mall-home__service-card-main",
484
- type: "button",
485
- disabled,
486
- onClick,
487
- "aria-busy": loading || void 0,
488
- "aria-labelledby": `${labelId} ${valueId}`,
489
- "aria-describedby": metaId,
490
- children: [
491
- /* @__PURE__ */ jsx3("img", { className: "mall-home__service-card-icon", src: iconSrc, alt: "", "aria-hidden": "true" }),
492
- /* @__PURE__ */ jsx3("span", { id: labelId, className: "mall-home__service-card-eyebrow", children: label }),
493
- /* @__PURE__ */ jsx3("span", { id: valueId, className: "mall-home__service-card-value", "aria-live": "polite", children: loading ? /* @__PURE__ */ jsxs3(Fragment, { children: [
494
- /* @__PURE__ */ jsx3(
495
- "span",
496
- {
497
- className: "mall-home__service-card-skeleton mall-home__service-card-skeleton--value",
498
- "aria-hidden": "true"
499
- }
500
- ),
501
- /* @__PURE__ */ jsx3("span", { className: "mall-home__service-card-loading-label", children: loadingLabel })
502
- ] }) : /* @__PURE__ */ jsx3("strong", { className: primaryMonospace ? "mall-home__plate" : void 0, children: primary }) }),
503
- /* @__PURE__ */ jsx3("span", { id: metaId, className: "mall-home__service-card-meta", children: loading ? /* @__PURE__ */ jsx3(
504
- "span",
505
- {
506
- className: "mall-home__service-card-skeleton mall-home__service-card-skeleton--meta",
507
- "aria-hidden": "true"
508
- }
509
- ) : meta })
510
- ]
366
+ // src/client/mock-direct-gate.ts
367
+ import { httpPost } from "@tbox.cn/app-agent-sdk-client";
368
+ var MOCK_DIRECT_ENROLL_PATHS = [
369
+ "/api/m/provider-mock/demo/member-enroll",
370
+ "/api/m/provider-mocktest/demo/member-enroll"
371
+ ];
372
+ var DIRECT_GATE_TIMEOUT_MS = 1e4;
373
+ function timeoutSignal() {
374
+ return typeof AbortSignal !== "undefined" && "timeout" in AbortSignal ? AbortSignal.timeout(DIRECT_GATE_TIMEOUT_MS) : void 0;
375
+ }
376
+ function mapDirectEnrollReceipt(status) {
377
+ if (status === 200) return { loginStatus: "success", message: "\u767B\u5F55\u6210\u529F" };
378
+ if (status === 401) return { loginStatus: "fail", message: "\u8BF7\u5148\u767B\u5F55" };
379
+ if (status === 404) return { loginStatus: "fail", message: "\u5F53\u524D\u73AF\u5883\u672A\u63D0\u4F9B\u5165\u4F1A\u670D\u52A1\uFF0C\u8BF7\u5728\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F\u5185\u6253\u5F00" };
380
+ return { loginStatus: "fail", message: "\u767B\u5F55\u72B6\u6001\u540C\u6B65\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5" };
381
+ }
382
+ async function directLoginGate() {
383
+ for (const path of MOCK_DIRECT_ENROLL_PATHS) {
384
+ try {
385
+ const { status } = await httpPost(path, void 0, { signal: timeoutSignal() });
386
+ if (status === 404) continue;
387
+ return mapDirectEnrollReceipt(status);
388
+ } catch {
389
+ return { loginStatus: "fail", message: "\u767B\u5F55\u72B6\u6001\u540C\u6B65\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5" };
511
390
  }
512
- ) });
391
+ }
392
+ return mapDirectEnrollReceipt(404);
513
393
  }
514
- function MemberServiceCard({
515
- member,
516
- onMemberPointsQuery,
517
- onMemberEnrollmentQuery,
518
- onReloadMember,
519
- onReauthorizeMember
520
- }) {
521
- const copy = member.status === "active" ? {
522
- primary: member.balance === void 0 ? "\u79EF\u5206\u6682\u4E0D\u53EF\u7528" : `${member.balance.toLocaleString("zh-CN")} \u79EF\u5206`,
523
- meta: member.membershipLabel ?? "\u67E5\u770B\u79EF\u5206\u4E0E\u4F1A\u5458\u670D\u52A1"
524
- } : member.status === "not_enrolled" ? { primary: "\u7ACB\u5373\u52A0\u5165\u4F1A\u5458", meta: "\u5165\u4F1A\u540E\u67E5\u770B\u79EF\u5206" } : member.status === "closed" ? { primary: "\u91CD\u65B0\u52A0\u5165\u4F1A\u5458", meta: "\u6062\u590D\u4F1A\u5458\u540E\u67E5\u770B\u79EF\u5206\u4E0E\u670D\u52A1" } : member.status === "loading" ? { primary: "", meta: "" } : member.status === "unauthenticated" ? { primary: "\u767B\u5F55\u540E\u67E5\u770B\u4F1A\u5458", meta: "\u6388\u6743\u540E\u53EF\u67E5\u770B\u4F1A\u5458\u4FE1\u606F" } : member.status === "unknown" ? { primary: "\u4F1A\u5458\u72B6\u6001\u5F85\u786E\u8BA4", meta: "\u70B9\u51FB\u91CD\u65B0\u540C\u6B65\u4F1A\u5458\u72B6\u6001" } : member.status === "error" ? { primary: "\u4F1A\u5458\u4FE1\u606F\u52A0\u8F7D\u5931\u8D25", meta: "\u70B9\u51FB\u91CD\u65B0\u52A0\u8F7D" } : { primary: "\u4F1A\u5458\u670D\u52A1\u6682\u4E0D\u53EF\u7528", meta: "\u53EF\u7A0D\u540E\u91CD\u8BD5" };
525
- const handleAction = () => {
526
- if (member.status === "active") onMemberPointsQuery?.();
527
- if (member.status === "not_enrolled" || member.status === "closed") onMemberEnrollmentQuery?.();
528
- if (member.status === "unauthenticated") onReauthorizeMember?.();
529
- if (member.status === "unknown" || member.status === "error" || member.status === "unavailable") onReloadMember?.();
394
+
395
+ // src/client/home-runtime.ts
396
+ var PLATE_PATTERN = /^[\u3400-\u9fff][A-HJ-NP-Z][A-HJ-NP-Z0-9]{5,6}$/;
397
+ function parseMemberState(value) {
398
+ if (!value || typeof value !== "object") return { status: "unavailable" };
399
+ const member = value;
400
+ if (member.authState === "unauthenticated" && member.state === "unknown") {
401
+ return { status: "unauthenticated" };
402
+ }
403
+ if (member.authState !== "authenticated") return { status: "error" };
404
+ if (member.state === "not_enrolled") return { status: "not_enrolled" };
405
+ if (member.state === "closed") return { status: "closed" };
406
+ if (member.state === "unknown") return { status: "unknown" };
407
+ if (member.state !== "active") return { status: "error" };
408
+ const balance = Number.isSafeInteger(member.balance) && member.balance >= 0 ? member.balance : void 0;
409
+ const membershipLabel = typeof member.membershipLabel === "string" && member.membershipLabel.trim() ? member.membershipLabel.trim() : void 0;
410
+ return {
411
+ status: "active",
412
+ ...balance !== void 0 ? { balance } : {},
413
+ ...membershipLabel ? { membershipLabel } : {}
530
414
  };
531
- return /* @__PURE__ */ jsx3(
532
- HomeServiceCard,
533
- {
534
- tone: "member",
535
- label: "\u4F1A\u5458\u79EF\u5206",
536
- iconSrc: memberServiceIcon,
537
- primary: copy.primary,
538
- meta: copy.meta,
539
- loading: member.status === "loading",
540
- loadingLabel: "\u4F1A\u5458\u4FE1\u606F\u52A0\u8F7D\u4E2D",
541
- disabled: member.status === "loading",
542
- onClick: handleAction
543
- }
544
- );
545
415
  }
546
- function openEnrollMiniProgram(enrollUrl) {
547
- if (!isInAlipayShell()) return false;
548
- if (!enrollUrl) return false;
549
- try {
550
- const parsed = new URL(enrollUrl);
551
- const appId = parsed.searchParams.get("appId") ?? "";
552
- const path = parsed.searchParams.get("page") ?? void 0;
553
- const query = parsed.searchParams.get("query") ?? void 0;
554
- void callJsapi("navigateToMiniProgram", {
555
- appId,
556
- ...path ? { path } : {},
557
- ...query ? { query } : {}
558
- }).catch((err) => console.warn("[MallHome] navigateToMiniProgram failed", err));
559
- return true;
560
- } catch {
561
- console.warn("[MallHome] enrollUrl parse failed", enrollUrl);
562
- return false;
416
+ function parseParkingState(value) {
417
+ if (!value || typeof value !== "object") return { status: "unavailable" };
418
+ const parking = value;
419
+ if (parking.status === "unauthenticated") return { status: "unauthenticated" };
420
+ if (parking.status === "membership_required") return { status: "membership_required" };
421
+ if (parking.status === "empty") return { status: "empty" };
422
+ if (parking.status === "unavailable") return { status: "unavailable" };
423
+ if (parking.status === "error") return { status: "error" };
424
+ if (parking.status === "ready" && typeof parking.primaryPlate === "string" && PLATE_PATTERN.test(parking.primaryPlate) && Number.isSafeInteger(parking.plateCount) && parking.plateCount > 0) {
425
+ const freeMinutesRemaining = Number.isSafeInteger(parking.freeMinutesRemaining) && parking.freeMinutesRemaining >= 0 ? parking.freeMinutesRemaining : void 0;
426
+ const parkedMinutes = Number.isSafeInteger(parking.parkedMinutes) && parking.parkedMinutes > 0 ? parking.parkedMinutes : void 0;
427
+ const parkedPlates = Array.isArray(parking.parkedPlates) ? parking.parkedPlates.filter((p) => typeof p === "string" && PLATE_PATTERN.test(p)) : void 0;
428
+ return {
429
+ status: "ready",
430
+ primaryPlate: parking.primaryPlate,
431
+ plateCount: parking.plateCount,
432
+ ...parkedPlates && parkedPlates.length > 0 ? { parkedPlates } : {},
433
+ ...freeMinutesRemaining !== void 0 ? { freeMinutesRemaining } : {},
434
+ ...parkedMinutes !== void 0 ? { parkedMinutes } : {}
435
+ };
563
436
  }
437
+ return { status: "error" };
564
438
  }
565
- var BUSINESS_AREAS = Object.freeze([
566
- Object.freeze({
567
- moduleId: "shopping-guide",
568
- title: "\u95E8\u5E97\u5BFC\u89C8",
569
- description: "\u627E\u95E8\u5E97\u3001\u770B\u697C\u5C42\u548C\u67E5\u5546\u573A\u653F\u7B56",
570
- tone: "guide",
571
- icon: Storefront,
572
- actions: Object.freeze([
573
- Object.freeze({ label: "\u901B\u4EC0\u4E48", description: "\u5148\u770B\u770B\u5546\u573A\u91CC\u6709\u4EC0\u4E48\u597D\u901B\u7684", query: "\u968F\u4FBF\u901B\u901B\uFF0C\u5546\u573A\u91CC\u6709\u4EC0\u4E48\u597D\u901B\u7684\uFF1F", icon: Buildings }),
574
- Object.freeze({ label: "\u627E\u95E8\u5E97", description: "\u67E5\u54C1\u724C\u95E8\u5E97\u7684\u4F4D\u7F6E", query: "adidas\u5E97\u5728\u54EA\u513F\uFF1F", icon: Storefront }),
575
- Object.freeze({ label: "\u8425\u4E1A\u65F6\u95F4", description: "\u67E5\u770B\u5546\u573A\u5F00\u95ED\u5E97\u65F6\u95F4", query: "\u5546\u573A\u51E0\u70B9\u5F00\u95E8\uFF1F", icon: Headset }),
576
- Object.freeze({ label: "\u9000\u6362\u8D27\u653F\u7B56", description: "\u4E86\u89E3\u9000\u6362\u8D27\u89C4\u5219", query: "\u5546\u573A\u9000\u6362\u8D27\u600E\u4E48\u89C4\u5B9A\uFF1F", icon: Headset }),
577
- // 多意图验证入口(2026-08-31):复合句并行调工具 + 多卡承接
578
- Object.freeze({ label: "\u95E8\u5E97+\u9886\u5238", description: "\u53CC\u57DF\u5E76\u884C\uFF1Ashop-list+\u5238\u5361", query: "\u63A8\u8350\u4E00\u4E0B\u9910\u996E\u95E8\u5E97\uFF0C\u987A\u4FBF\u770B\u770B\u6709\u4EC0\u4E48\u4F18\u60E0\u5238\u53EF\u4EE5\u9886", icon: Storefront }),
579
- Object.freeze({ label: "\u4E70\u8863+\u5496\u5561", description: "\u540C\u5DE5\u5177\u591A\u53C2\u5E76\u884C\uFF08\u540C\u578B\u6298\u53E0 1 \u5361\uFF09", query: "\u60F3\u7ED9\u5A03\u4E70\u8863\u670D\uFF0C\u518D\u627E\u5BB6\u5496\u5561\u5E97\u5750\u5750", icon: Buildings })
580
- ])
581
- }),
582
- Object.freeze({
583
- moduleId: "member",
584
- title: "\u4F1A\u5458\u670D\u52A1",
585
- description: "\u4F1A\u5458\u5361\u3001\u79EF\u5206\u548C\u4E13\u5C5E\u6743\u76CA",
586
- tone: "member",
587
- icon: IdentificationCard,
588
- actions: Object.freeze([
589
- Object.freeze({ label: "\u4F1A\u5458\u4E2D\u5FC3", description: "\u67E5\u770B\u4F1A\u5458\u5361\u548C\u4F1A\u5458\u670D\u52A1", query: "\u67E5\u770B\u6211\u7684\u4F1A\u5458\u5361", icon: IdentificationCard }),
590
- Object.freeze({ label: "\u67E5\u79EF\u5206", description: "\u4F59\u989D\u548C\u6700\u8FD1\u8BB0\u5F55", query: "\u67E5\u8BE2\u6211\u7684\u4F1A\u5458\u79EF\u5206\u4F59\u989D\u548C\u6700\u8FD1\u79EF\u5206\u8BB0\u5F55", icon: Coins }),
591
- Object.freeze({ label: "\u5F00\u5361\u5165\u4F1A", description: "\u5FEB\u901F\u52A0\u5165\u5546\u573A\u4F1A\u5458", query: "\u6211\u8981\u52A0\u5165\u5546\u573A\u4F1A\u5458\uFF0C\u8BF7\u5E2E\u6211\u5B8C\u6210\u5F00\u5361\u5165\u4F1A", icon: UserPlus, enroll: true }),
592
- // 未登录链路的联调入口:mock provider 恒返回已登录,走正常路径永远看不到登录卡。
593
- // 这里直说「还没登录」,让模型走 queryLoginCta 把登录引导卡带出来。
594
- Object.freeze({ label: "\u5F00\u5361\u5165\u4F1A\uFF08\u672A\u767B\u5F55\uFF09", description: "\u6A21\u62DF\u672A\u767B\u5F55\u65F6\u7684\u767B\u5F55\u5F15\u5BFC", query: "\u6211\u8FD8\u6CA1\u6709\u767B\u5F55\uFF0C\u8BF7\u7ED9\u6211\u767B\u5F55\u5165\u53E3", icon: SignIn }),
595
- Object.freeze({ label: "\u79EF\u5206+\u4F18\u60E0", description: "\u53CC\u57DF\u5E76\u884C\uFF1A\u4F1A\u5458\u5361+\u5238\u5361", query: "\u6211\u7684\u79EF\u5206\u8FD8\u6709\u591A\u5C11\uFF1F\u53EF\u4EE5\u7528\u79EF\u5206\u6362\u4EC0\u4E48\u4F18\u60E0", icon: Coins }),
596
- Object.freeze({ label: "\u653F\u7B56+\u79EF\u5206", description: "FAQ \u653F\u7B56 vs \u5B9E\u65F6\u6570\u5B57\uFF08\u8BED\u4E49\u533A\u5206\uFF09", query: "\u9000\u6362\u8D27\u653F\u7B56\u662F\u4EC0\u4E48\uFF1F\u6211\u73B0\u5728\u6709\u591A\u5C11\u79EF\u5206", icon: IdentificationCard })
597
- ])
598
- }),
599
- Object.freeze({
600
- moduleId: "promotion",
601
- title: "\u6D3B\u52A8\u4F18\u60E0",
602
- description: "\u9886\u5238\u3001\u6211\u7684\u5238\u548C\u4F18\u60E0\u6D3B\u52A8",
603
- tone: "marketing",
604
- icon: Gift,
605
- actions: Object.freeze([
606
- Object.freeze({ label: "\u9886\u5238", description: "\u770B\u770B\u6709\u4EC0\u4E48\u53EF\u9886\u4F18\u60E0", query: "\u6709\u4EC0\u4E48\u4F18\u60E0\u53EF\u4EE5\u9886\u53D6\uFF1F\u5E2E\u6211\u627E\u627E\u53EF\u9886\u7684\u4F18\u60E0\u5238", icon: Ticket }),
607
- Object.freeze({ label: "\u6211\u7684\u5238", description: "\u5361\u5305\u91CC\u7684\u5238\u548C\u5238\u7801", query: "\u67E5\u4E00\u4E0B\u6211\u7684\u4F18\u60E0\u5238", icon: Ticket }),
608
- Object.freeze({ label: "\u6D3B\u52A8", description: "\u8FD1\u671F\u6D3B\u52A8\u548C\u573A\u6B21\u5B89\u6392", query: "\u6700\u8FD1\u6709\u4EC0\u4E48\u8425\u9500\u6D3B\u52A8\uFF1F", icon: Sparkle }),
609
- Object.freeze({ label: "\u5238+\u78B0\u4E00\u78B0", description: "\u53CC\u57DF\u5E76\u884C\uFF1A\u5238\u5361+bumpin \u5361", query: "\u73B0\u5728\u6709\u4EC0\u4E48\u5238\u53EF\u9886\uFF1F\u78B0\u4E00\u78B0\u6D3B\u52A8\u8FDB\u5EA6\u600E\u4E48\u6837", icon: Ticket }),
610
- Object.freeze({ label: "\u6D3B\u52A8+\u9910\u5385", description: "\u53CC\u57DF\u5E76\u884C\uFF1Aactivity-list+shop-list", query: "\u770B\u770B\u6700\u8FD1\u6709\u4EC0\u4E48\u6D3B\u52A8\uFF0C\u987A\u4FBF\u63A8\u8350\u51E0\u5BB6 5F \u7684\u9910\u5385", icon: Gift })
611
- ])
612
- }),
613
- Object.freeze({
614
- moduleId: "parking",
615
- title: "\u505C\u8F66\u670D\u52A1",
616
- description: "\u7F34\u8D39\u3001\u5BFB\u8F66\u548C\u8F66\u8F86\u7BA1\u7406",
617
- tone: "parking",
618
- icon: Car,
619
- actions: Object.freeze([
620
- Object.freeze({ label: "\u505C\u8F66\u7F34\u8D39", description: "\u67E5\u8BE2\u8D39\u7528\u5E76\u652F\u4ED8", query: "\u5E2E\u6211\u67E5\u4E00\u4E0B\u505C\u8F66\u8D39", icon: Coins }),
621
- Object.freeze({ label: "\u8F66\u8F86\u7ED1\u5B9A", description: "\u7ED1\u5B9A\u6216\u7BA1\u7406\u8F66\u724C", query: "\u67E5\u770B\u6211\u7684\u7ED1\u5B9A\u8F66\u8F86", icon: Car }),
622
- Object.freeze({ label: "\u7F34\u8D39\u8BB0\u5F55", description: "\u5386\u53F2\u505C\u8F66\u8BA2\u5355", query: "\u67E5\u4E00\u4E0B\u6211\u7684\u505C\u8F66\u7F34\u8D39\u8BB0\u5F55", icon: BookOpen }),
623
- Object.freeze({ label: "\u505C\u8F66\u8D44\u8BAF", description: "\u4F59\u4F4D\u548C\u6536\u8D39\u89C4\u5219", query: "\u505C\u8F66\u573A\u8FD8\u6709\u7A7A\u4F4D\u5417\uFF1F\u6536\u8D39\u6807\u51C6\u662F\u4EC0\u4E48\uFF1F", icon: Buildings }),
624
- Object.freeze({ label: "\u505C\u8F66\u8D39+\u62B5\u6263", description: "\u53CC\u57DF\u5E76\u884C\uFF1A\u62A5\u4EF7\u5361+\u505C\u8F66\u6743\u76CA", query: "\u67E5\u4E0B\u505C\u8F66\u8D39\u8BE5\u4EA4\u591A\u5C11\uFF0C\u80FD\u7528\u8F66\u5185\u79EF\u5206\u62B5\u6263\u5417", icon: Coins }),
625
- Object.freeze({ label: "\u5BFB\u8F66+B1\u7F8E\u98DF", description: "\u53CC\u57DF\u5E76\u884C\uFF1AlocateVehicle+shop-list", query: "\u6211\u7684\u8F66\u505C\u54EA\u4E86\uFF1F\u987A\u4FBF\u63A8\u8350\u4E0B B1 \u7684\u7F8E\u98DF", icon: Car })
626
- ])
627
- })
628
- ]);
629
- function LinkedOrderStatus({
630
- linkedOrder,
631
- onReloadLinkedOrder,
632
- onReauthorizeLinkedOrder
633
- }) {
634
- if (linkedOrder.status === "loading") {
635
- return /* @__PURE__ */ jsx3("div", { className: "mall-home__progress-message", role: "status", children: "\u6B63\u5728\u540C\u6B65\u8054\u5355\u8FDB\u5EA6\u2026" });
636
- }
637
- if (linkedOrder.status === "unauthenticated") {
638
- return /* @__PURE__ */ jsxs3("div", { className: "mall-home__progress-message", children: [
639
- /* @__PURE__ */ jsx3("span", { children: "\u767B\u5F55\u652F\u4ED8\u5B9D\u540E\u67E5\u770B\u8054\u5355\u8FDB\u5EA6" }),
640
- /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => onReauthorizeLinkedOrder?.(), children: "\u91CD\u65B0\u6388\u6743" })
641
- ] });
439
+ async function fetchLinkedPanelState(token, mallId, fetcher = fetch, signal) {
440
+ if (!token) {
441
+ return {
442
+ member: { status: "unauthenticated" },
443
+ parking: { status: "unauthenticated" },
444
+ enrollUrl: null
445
+ };
642
446
  }
643
- if (linkedOrder.status === "forbidden") {
644
- return /* @__PURE__ */ jsx3("div", { className: "mall-home__progress-message", children: "\u5F53\u524D\u8D26\u53F7\u6682\u65F6\u65E0\u6CD5\u67E5\u770B\u8054\u5355\u8FDB\u5EA6" });
447
+ if (!mallId) {
448
+ return {
449
+ member: { status: "unavailable" },
450
+ parking: { status: "unavailable" },
451
+ enrollUrl: null
452
+ };
645
453
  }
646
- if (linkedOrder.status === "error") {
647
- return /* @__PURE__ */ jsxs3("div", { className: "mall-home__progress-message", role: "alert", children: [
648
- /* @__PURE__ */ jsx3("span", { children: "\u8054\u5355\u8FDB\u5EA6\u6682\u65F6\u65E0\u6CD5\u540C\u6B65" }),
649
- /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => onReloadLinkedOrder?.(), children: "\u91CD\u65B0\u52A0\u8F7D" })
650
- ] });
454
+ try {
455
+ const response = await fetcher(`${MALL_CORE_API}/linked-panel?mallId=${encodeURIComponent(mallId)}`, {
456
+ headers: { Authorization: `Bearer ${token}` },
457
+ ...signal ? { signal } : {}
458
+ });
459
+ if (response.status === 401) {
460
+ return {
461
+ member: { status: "unauthenticated" },
462
+ parking: { status: "unauthenticated" },
463
+ enrollUrl: null
464
+ };
465
+ }
466
+ if (response.status === 403) {
467
+ return {
468
+ member: { status: "unavailable" },
469
+ parking: { status: "unavailable" },
470
+ enrollUrl: null
471
+ };
472
+ }
473
+ if (!response.ok) {
474
+ return { member: { status: "error" }, parking: { status: "error" }, enrollUrl: null };
475
+ }
476
+ const payload = await response.json();
477
+ const enrollUrl = typeof payload.member?.enrollUrl === "string" && payload.member.enrollUrl.trim() ? payload.member.enrollUrl.trim() : null;
478
+ return {
479
+ member: parseMemberState(payload.member),
480
+ parking: parseParkingState(payload.parking),
481
+ enrollUrl
482
+ };
483
+ } catch (error) {
484
+ if (error.name === "AbortError") throw error;
485
+ return { member: { status: "error" }, parking: { status: "error" }, enrollUrl: null };
651
486
  }
652
- const progress = linkedOrder.status === "ready" ? deriveLinkedOrderProgress(linkedOrder.banner) : null;
653
- if (!progress) {
654
- return /* @__PURE__ */ jsx3("div", { className: "mall-home__progress-message", children: "\u5F53\u524D\u6682\u65E0\u53EF\u67E5\u770B\u7684\u8054\u5355\u6D3B\u52A8" });
487
+ }
488
+ var MALL_CORE_API = "/api/m/mall-core";
489
+ function pickMallId(helloMallId, urlMallId) {
490
+ return helloMallId ?? urlMallId;
491
+ }
492
+ function throwIfAborted(signal) {
493
+ if (signal?.aborted) {
494
+ throw new DOMException("The operation was aborted.", "AbortError");
655
495
  }
656
- const nodes = progress.target <= 10 ? Array.from({ length: progress.target }, (_, index) => index + 1) : [];
657
- const railFill = getLinkedOrderRailFill(progress.completed, progress.target);
658
- return /* @__PURE__ */ jsxs3(
659
- "div",
496
+ }
497
+ async function loadLinkedPanelState(auth, mallId, fetcher = fetch, signal, onAuthRefreshed) {
498
+ const initialAuth = await auth.ensureAuth();
499
+ const first = await fetchLinkedPanelState(initialAuth.token, mallId, fetcher, signal);
500
+ if (first.member.status !== "unauthenticated" || !initialAuth.token) return first;
501
+ throwIfAborted(signal);
502
+ const refreshedAuth = await auth.refreshAuth();
503
+ throwIfAborted(signal);
504
+ await onAuthRefreshed?.();
505
+ throwIfAborted(signal);
506
+ return fetchLinkedPanelState(refreshedAuth.token, mallId, fetcher, signal);
507
+ }
508
+ function parseProgressInteger(value) {
509
+ const normalized = value?.trim() ?? "";
510
+ if (!/^\d+$/.test(normalized)) return null;
511
+ const parsed = Number(normalized);
512
+ return Number.isSafeInteger(parsed) ? parsed : null;
513
+ }
514
+ function deriveLinkedOrderProgress(banner) {
515
+ if (!banner || banner.progressStyle !== "steps") return null;
516
+ const target = parseProgressInteger(banner.totalProgress);
517
+ const current = parseProgressInteger(banner.currentProgress);
518
+ const unit = banner.progressUnit?.trim();
519
+ if (target === null || current === null || target < 1 || current > target || !unit) return null;
520
+ return {
521
+ completed: current,
522
+ target,
523
+ unit
524
+ };
525
+ }
526
+ function getLinkedOrderRailFill(completed, target) {
527
+ if (target <= 1 || completed <= 1) return "0%";
528
+ return `${Math.min(100, (completed - 1) / (target - 1) * 100)}%`;
529
+ }
530
+
531
+ // src/client/member-gate-overlay.tsx
532
+ import { jsx as jsx2 } from "react/jsx-runtime";
533
+ var gateLogger = createLogger("MEMBER-GATE");
534
+ var ignorePanelRefresh = () => {
535
+ };
536
+ function useMemberGateController(refreshPanel = ignorePanelRefresh) {
537
+ const store = useChatStoreApi();
538
+ const messages = useChatStore((s) => s.messages);
539
+ const orphanCards = useChatStore((s) => s.orphanCards);
540
+ const cardsByMessageId = useChatStore((s) => s.cardsByMessageId);
541
+ const isGenerating = useChatStore((s) => s.isGenerating);
542
+ const gateCard = useMemo(
543
+ () => selectLatestMemberGateCard(messages.map((message) => message.id), cardsByMessageId, orphanCards),
544
+ [messages, cardsByMessageId, orphanCards]
545
+ );
546
+ const gate = useMemo(
547
+ () => createMemberGate({
548
+ // 壳内走桥(容器 mock-enrollment/真实厂商 gate 页);非壳(扫码直开/浏览器)走 H5 直连 mock 入会
549
+ getLoginState: (params) => isInAlipayShell() ? getLoginState(params) : directLoginGate(),
550
+ retryBootstrap: (refreshAuth) => store.getState().retryBootstrap(refreshAuth),
551
+ loadPanel: async (panelMallId) => {
552
+ const panel = await loadLinkedPanelState(getAuthClient(), panelMallId, fetch);
553
+ return { member: { status: panel.member.status } };
554
+ },
555
+ waitForSocketOpen,
556
+ getAuthState: () => getAuthClient().getAuthState(),
557
+ sendMessage: (input) => store.getState().sendMessage(input),
558
+ sendUiAction: (surfaceId, action) => store.getState().sendUiAction(surfaceId, action),
559
+ hideCard: (cardId) => store.getState().hideCard(cardId),
560
+ toast: (content) => {
561
+ void toast(content);
562
+ },
563
+ isGenerating: () => store.getState().isGenerating,
564
+ lastUserMessage: () => {
565
+ const live = store.getState().messages;
566
+ for (let i = live.length - 1; i >= 0; i -= 1) {
567
+ if (live[i]?.role === "user") return { id: live[i].id, content: live[i].content };
568
+ }
569
+ return null;
570
+ },
571
+ readMallId: () => pickMallId(store.getState().helloAck?.mallScope?.mallId, readMallIdFromUrl()),
572
+ refreshPanel,
573
+ log: (message) => {
574
+ gateLogger.info(message);
575
+ }
576
+ }),
577
+ [store, refreshPanel]
578
+ );
579
+ const gateState = useMemberGate(gate);
580
+ useEffect2(() => {
581
+ if (!gateCard) return;
582
+ const { phase, card } = gate.getState();
583
+ if (phase === "opening" || phase === "syncing") return;
584
+ if (card?.id === gateCard.id) return;
585
+ gate.trigger(gateCard, void 0);
586
+ }, [gateCard, gate, gateState.phase]);
587
+ return { gate, gateState, isGenerating };
588
+ }
589
+ function MemberGateOverlay() {
590
+ const { gate, gateState, isGenerating } = useMemberGateController();
591
+ if (!gateState.sheetVisible || !gateState.card) return null;
592
+ return /* @__PURE__ */ jsx2(
593
+ MemberGateSheet,
660
594
  {
661
- className: "mall-home__progress-content",
662
- "aria-label": `\u8054\u5355\u652F\u4ED8\u8FDB\u5EA6 ${progress.completed} / ${progress.target} ${progress.unit}`,
663
- children: [
664
- /* @__PURE__ */ jsx3("strong", { className: "mall-home__progress-label", children: "\u8054\u5355\u8FDB\u5EA6" }),
665
- /* @__PURE__ */ jsxs3("div", { className: `mall-home__nodes${nodes.length === 0 ? " mall-home__nodes--summary" : ""}`, "aria-hidden": "true", children: [
666
- /* @__PURE__ */ jsx3("span", { className: "mall-home__rail" }),
667
- /* @__PURE__ */ jsx3("span", { className: "mall-home__rail-fill", style: { width: railFill } }),
668
- nodes.length === 0 && /* @__PURE__ */ jsxs3("span", { className: "mall-home__nodes-summary", children: [
669
- "\u5DF2\u5B8C\u6210 ",
670
- progress.completed,
671
- " ",
672
- progress.unit
673
- ] }),
674
- nodes.map((node) => {
675
- const completed = node <= progress.completed;
676
- const milestone = node === progress.target;
677
- return /* @__PURE__ */ jsx3(
678
- "span",
679
- {
680
- className: `mall-home__node${completed ? " mall-home__node--completed" : ""}${milestone ? " mall-home__node--milestone" : ""}`,
681
- children: completed ? /* @__PURE__ */ jsx3(Check, { size: 15, weight: "bold" }) : milestone ? /* @__PURE__ */ jsx3(LockSimple, { size: 13, weight: "bold" }) : /* @__PURE__ */ jsx3("span", { children: node })
682
- },
683
- node
684
- );
685
- })
686
- ] }),
687
- /* @__PURE__ */ jsxs3("strong", { className: "mall-home__progress-value", children: [
688
- progress.completed,
689
- "/",
690
- progress.target
691
- ] })
692
- ]
595
+ context: gateState.card,
596
+ phase: gateState.phase,
597
+ message: gateState.message,
598
+ busy: isGenerating,
599
+ onConfirm: () => gate.confirm(),
600
+ onRetry: () => gate.retry(),
601
+ onDismiss: () => gate.dismiss()
693
602
  }
694
603
  );
695
604
  }
696
- function ParkingServiceCard({
697
- parking,
698
- onParkingFeeQuery,
699
- onParkingVehicleQuery,
700
- onParkingMembershipQuery,
701
- onParkingServiceQuery,
702
- onReloadParking,
703
- onReauthorizeParking
605
+
606
+ // src/client/cards/overrides/BumpInActivityChatCard.tsx
607
+ import { useCallback as useCallback2, useRef as useRef3, useState as useState3 } from "react";
608
+ import { CaretRight } from "@phosphor-icons/react";
609
+
610
+ // src/client/components/ActivityDetailPresentation/index.tsx
611
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
612
+ var POSTER_BASE = "activity-detail-presentation__poster block h-full w-full bg-cover bg-center";
613
+ var POSTER_STAGE = "bg-[image:var(--tbox-asset-home-poster-stage,linear-gradient(135deg,#eaf3ff,#d7e7fd))]";
614
+ var POSTER_COMPACT = "max-[392px]:bg-[image:var(--tbox-asset-home-poster-compact,linear-gradient(135deg,#eaf3ff,#d7e7fd))]";
615
+ var EMBED_SKIN = [
616
+ // ① 卡框抹平:外边距/裁切/描边/圆角/阴影/入场动画全部让位
617
+ "[&_.tbox-card]:m-0 [&_.tbox-card]:animate-none [&_.tbox-card]:overflow-visible",
618
+ "[&_.tbox-card]:rounded-none [&_.tbox-card]:border-0 [&_.tbox-card]:bg-transparent [&_.tbox-card]:shadow-none",
619
+ // ② 头部:白底平铺,隐藏封面与遮罩伪元素,压掉深蓝渐变与最小高度
620
+ "[&_.promotion-bumpin]:m-0 [&_.promotion-bumpin]:overflow-visible [&_.promotion-bumpin]:rounded-none",
621
+ "[&_.promotion-bumpin]:border-0 [&_.promotion-bumpin]:bg-card [&_.promotion-bumpin]:shadow-none",
622
+ "[&_.promotion-bumpin__header]:block [&_.promotion-bumpin__header]:min-h-0",
623
+ "[&_.promotion-bumpin__header]:bg-card! [&_.promotion-bumpin__header]:bg-none!",
624
+ "[&_.promotion-bumpin__header]:px-[11px] [&_.promotion-bumpin__header]:pt-[10px] [&_.promotion-bumpin__header]:pb-[7px]",
625
+ "[&_.promotion-bumpin__header]:before:hidden",
626
+ "[&_.promotion-bumpin__cover]:hidden [&_.promotion-bumpin__cover-placeholder]:hidden",
627
+ "[&_.promotion-bumpin__header-copy]:relative [&_.promotion-bumpin__header-copy]:z-[1]",
628
+ "[&_.promotion-bumpin__header-copy]:grid [&_.promotion-bumpin__header-copy]:max-w-full [&_.promotion-bumpin__header-copy]:gap-[3.5px]",
629
+ // 标签 / 标题 / 时段:改浅底深字,与详情页正文同一套字号档位
630
+ "[&_.promotion-bumpin__tag]:justify-self-start [&_.promotion-bumpin__tag]:rounded-full",
631
+ "[&_.promotion-bumpin__tag]:border-0 [&_.promotion-bumpin__tag]:bg-[#edf8f1]",
632
+ "[&_.promotion-bumpin__tag]:px-[10px] [&_.promotion-bumpin__tag]:py-[3px]",
633
+ "[&_.promotion-bumpin__tag]:text-sm [&_.promotion-bumpin__tag]:leading-[19px] [&_.promotion-bumpin__tag]:text-[#19744a]",
634
+ "[&_.promotion-bumpin__title]:m-0 [&_.promotion-bumpin__title]:text-xl [&_.promotion-bumpin__title]:leading-[28px]",
635
+ "[&_.promotion-bumpin__title]:font-[750] [&_.promotion-bumpin__title]:text-[#263022]",
636
+ "[&_.promotion-bumpin__period]:justify-self-start [&_.promotion-bumpin__period]:bg-transparent [&_.promotion-bumpin__period]:px-0 [&_.promotion-bumpin__period]:py-0",
637
+ "[&_.promotion-bumpin__period]:text-sm [&_.promotion-bumpin__period]:leading-[21px] [&_.promotion-bumpin__period]:text-[#6f7969]",
638
+ "[&_.promotion-bumpin__subtitle]:justify-self-start [&_.promotion-bumpin__subtitle]:bg-transparent [&_.promotion-bumpin__subtitle]:px-0 [&_.promotion-bumpin__subtitle]:py-0",
639
+ "[&_.promotion-bumpin__subtitle]:text-sm [&_.promotion-bumpin__subtitle]:leading-[21px] [&_.promotion-bumpin__subtitle]:text-[#6f7969]",
640
+ // 进度:浅蓝底内嵌块 + 蓝系节点,与首页联单进度同一套色
641
+ "[&_.promotion-bumpin__progress]:mx-4 [&_.promotion-bumpin__progress]:gap-1 [&_.promotion-bumpin__progress]:overflow-hidden",
642
+ "[&_.promotion-bumpin__progress]:rounded-[14px] [&_.promotion-bumpin__progress]:border [&_.promotion-bumpin__progress]:border-[rgba(10,110,184,0.12)]",
643
+ "[&_.promotion-bumpin__progress]:bg-[#f2f8fc] [&_.promotion-bumpin__progress]:px-3.5 [&_.promotion-bumpin__progress]:pt-1.5 [&_.promotion-bumpin__progress]:pb-[5px]",
644
+ "[&_.promotion-bumpin__steps]:px-1.5 [&_.promotion-bumpin__step-item]:gap-0.5",
645
+ "[&_.promotion-bumpin__step-node]:size-[22px] [&_.promotion-bumpin__step-node]:text-xs",
646
+ "[&_.promotion-bumpin__step-node]:border-[#1682cb] [&_.promotion-bumpin__step-node]:bg-[#eaf8ff] [&_.promotion-bumpin__step-node]:text-[#0d6fae]",
647
+ "[&_.promotion-bumpin__step-node_svg]:size-3",
648
+ "[&_.promotion-bumpin__step-node--done]:border-[#0a6eb8] [&_.promotion-bumpin__step-node--done]:bg-[#0a6eb8] [&_.promotion-bumpin__step-node--done]:text-white",
649
+ "[&_.promotion-bumpin__step-node--done]:shadow-[0_3px_9px_rgba(10,110,184,0.22)]",
650
+ "[&_.promotion-bumpin__step-node--locked]:border-[#ffdc6a] [&_.promotion-bumpin__step-node--locked]:bg-[#1475b6] [&_.promotion-bumpin__step-node--locked]:text-white",
651
+ "[&_.promotion-bumpin__step-line]:top-[11px] [&_.promotion-bumpin__step-line]:h-[2px] [&_.promotion-bumpin__step-line]:bg-[rgba(22,126,194,0.22)]",
652
+ "[&_.promotion-bumpin__step-line--done]:bg-[#0a6eb8] [&_.promotion-bumpin__step-line--done]:shadow-none",
653
+ "[&_.promotion-bumpin__progress-fill]:bg-[#0a6eb8] [&_.promotion-bumpin__progress-fill]:shadow-none",
654
+ "[&_.promotion-bumpin__step-label]:text-xs [&_.promotion-bumpin__step-label]:leading-[13px] [&_.promotion-bumpin__step-label]:text-[#6f7969]",
655
+ "[&_.promotion-bumpin__progress-text]:text-xs [&_.promotion-bumpin__progress-text]:leading-[13px] [&_.promotion-bumpin__progress-text]:text-[#6f7969]",
656
+ "[&_.promotion-bumpin__progress-bar]:h-2 [&_.promotion-bumpin__progress-bar]:bg-[rgba(10,110,184,0.14)]",
657
+ // 奖励池 / 活动规则:白卡片 + 细描边,标题与条目按详情页正文排版
658
+ "[&_.promotion-bumpin__prizes]:mx-4 [&_.promotion-bumpin__prizes]:mt-4 [&_.promotion-bumpin__prizes]:overflow-hidden",
659
+ "[&_.promotion-bumpin__prizes]:rounded-[14px] [&_.promotion-bumpin__prizes]:border [&_.promotion-bumpin__prizes]:border-[rgba(106,119,137,0.16)]",
660
+ "[&_.promotion-bumpin__prizes]:bg-card [&_.promotion-bumpin__prizes]:shadow-[0_3px_12px_rgba(70,91,122,0.06)]",
661
+ "[&_.promotion-bumpin__rules]:mx-4 [&_.promotion-bumpin__rules]:mt-4 [&_.promotion-bumpin__rules]:overflow-hidden",
662
+ "[&_.promotion-bumpin__rules]:rounded-[14px] [&_.promotion-bumpin__rules]:border [&_.promotion-bumpin__rules]:border-[rgba(106,119,137,0.16)]",
663
+ "[&_.promotion-bumpin__rules]:bg-card [&_.promotion-bumpin__rules]:shadow-[0_3px_12px_rgba(70,91,122,0.06)]",
664
+ "[&_.promotion-bumpin__prizes-header]:gap-2 [&_.promotion-bumpin__prizes-header]:border-b [&_.promotion-bumpin__prizes-header]:border-[rgba(106,119,137,0.12)]",
665
+ "[&_.promotion-bumpin__prizes-header]:px-3.5 [&_.promotion-bumpin__prizes-header]:pt-3 [&_.promotion-bumpin__prizes-header]:pb-2.5",
666
+ "[&_.promotion-bumpin__prizes-header]:text-base [&_.promotion-bumpin__prizes-header]:font-semibold",
667
+ "[&_.promotion-bumpin__prizes-header]:leading-[22px] [&_.promotion-bumpin__prizes-header]:text-[#263022]",
668
+ "[&_.promotion-bumpin__rules-header]:border-b [&_.promotion-bumpin__rules-header]:border-[rgba(106,119,137,0.12)]",
669
+ "[&_.promotion-bumpin__rules-header]:px-3.5 [&_.promotion-bumpin__rules-header]:pt-3 [&_.promotion-bumpin__rules-header]:pb-2.5",
670
+ "[&_.promotion-bumpin__rules-header]:text-base [&_.promotion-bumpin__rules-header]:font-semibold",
671
+ "[&_.promotion-bumpin__rules-header]:leading-[22px] [&_.promotion-bumpin__rules-header]:text-[#263022]",
672
+ "[&_.promotion-bumpin__prizes-header_svg]:size-[26px] [&_.promotion-bumpin__prizes-header_svg]:rounded-[8px]",
673
+ "[&_.promotion-bumpin__prizes-header_svg]:bg-[#edf6ff] [&_.promotion-bumpin__prizes-header_svg]:p-1.5 [&_.promotion-bumpin__prizes-header_svg]:text-[#0a6eb8]",
674
+ "[&_.promotion-bumpin__prize-item]:gap-3 [&_.promotion-bumpin__prize-item]:border-b [&_.promotion-bumpin__prize-item]:border-[rgba(106,119,137,0.1)]",
675
+ "[&_.promotion-bumpin__prize-item]:bg-card [&_.promotion-bumpin__prize-item]:px-3.5 [&_.promotion-bumpin__prize-item]:py-3",
676
+ "[&_.promotion-bumpin__prize-logo]:size-[42px] [&_.promotion-bumpin__prize-logo]:rounded-[12px]",
677
+ "[&_.promotion-bumpin__prize-logo-placeholder]:size-[42px] [&_.promotion-bumpin__prize-logo-placeholder]:rounded-[12px]",
678
+ "[&_.promotion-bumpin__prize-copy_strong]:text-base [&_.promotion-bumpin__prize-copy_strong]:leading-[22px] [&_.promotion-bumpin__prize-copy_strong]:text-[#263022]",
679
+ "[&_.promotion-bumpin__prize-copy_small]:text-sm [&_.promotion-bumpin__prize-copy_small]:leading-5 [&_.promotion-bumpin__prize-copy_small]:text-[#6f7969]",
680
+ "[&_.promotion-bumpin__prize-amount]:text-sm [&_.promotion-bumpin__prize-amount]:leading-5 [&_.promotion-bumpin__prize-amount]:text-[#6f7969]",
681
+ "[&_.promotion-bumpin__prizes-toggle]:border-t [&_.promotion-bumpin__prizes-toggle]:border-[rgba(106,119,137,0.1)]",
682
+ "[&_.promotion-bumpin__prizes-toggle]:bg-[#f8fafc] [&_.promotion-bumpin__prizes-toggle]:px-3.5 [&_.promotion-bumpin__prizes-toggle]:py-[11px]",
683
+ "[&_.promotion-bumpin__prizes-toggle]:text-sm [&_.promotion-bumpin__prizes-toggle]:leading-5 [&_.promotion-bumpin__prizes-toggle]:text-[#6f7969]",
684
+ "[&_.promotion-bumpin__rules-content]:px-3.5 [&_.promotion-bumpin__rules-content]:pt-3 [&_.promotion-bumpin__rules-content]:pb-3.5",
685
+ "[&_.promotion-bumpin__rules-content]:text-sm [&_.promotion-bumpin__rules-content]:leading-6 [&_.promotion-bumpin__rules-content]:text-[#6f7969]"
686
+ ].join(" ");
687
+ function ActivityDetailHero({ variant = "page" }) {
688
+ const className = variant === "strip" ? `${POSTER_BASE} activity-detail-presentation__poster--stage ${POSTER_STAGE}` : `${POSTER_BASE} ${POSTER_STAGE} ${POSTER_COMPACT}`;
689
+ return /* @__PURE__ */ jsx3("span", { className, role: "img", "aria-label": "\u53C2\u4E0E\u8054\u5355\uFF0C\u78B0\u51FA\u60CA\u559C" });
690
+ }
691
+ function ActivityDetailPresentation({
692
+ children,
693
+ variant
704
694
  }) {
705
- const formatPlate = (plate) => `${plate.slice(0, 2)}\xB7${plate.slice(2)}`;
706
- const formatParkedTime = (minutes) => {
707
- const hours = Math.floor(minutes / 60);
708
- const remainingMinutes = minutes % 60;
709
- return [
710
- hours > 0 ? `${hours} \u65F6` : "",
711
- remainingMinutes > 0 ? `${remainingMinutes} \u5206` : ""
712
- ].filter(Boolean).join(" ") || "0 \u5206";
713
- };
714
- const formatFreeTime = (minutes) => {
715
- const hours = Math.floor(minutes / 60);
716
- const remainingMinutes = minutes % 60;
717
- return [
718
- hours > 0 ? `${hours} \u5C0F\u65F6` : "",
719
- remainingMinutes > 0 ? `${remainingMinutes} \u5206` : ""
720
- ].filter(Boolean).join(" ");
721
- };
722
- const parkedIn = parking.status === "ready" && parking.freeMinutesRemaining !== void 0;
723
- const parkedCount = parking.status === "ready" ? parking.parkedPlates?.length ?? 0 : 0;
724
- const copy = parking.status === "ready" ? parkedIn ? parkedCount >= 2 ? {
725
- eyebrow: "\u505C\u8F66\u670D\u52A1",
726
- primary: `${parkedCount} \u8F86\u8F66\u5165\u573A`,
727
- meta: "\u70B9\u51FB\u67E5\u8BE2\u505C\u8F66\u8D39"
728
- } : {
729
- eyebrow: "\u505C\u8F66\u670D\u52A1",
730
- primary: formatPlate(parking.primaryPlate),
731
- meta: parking.freeMinutesRemaining ? `\u514D\u8D39\u65F6\u95F4\u5269\u4F59 ${formatFreeTime(parking.freeMinutesRemaining)}` : parking.parkedMinutes ? `\u5DF2\u505C ${formatParkedTime(parking.parkedMinutes)}\uFF0C\u67E5\u8BE2\u8D39\u7528` : "\u70B9\u51FB\u67E5\u8BE2\u505C\u8F66\u8D39"
732
- } : { eyebrow: "\u505C\u8F66\u670D\u52A1", primary: "\u8F66\u8F86\u672A\u5165\u573A", meta: "\u70B9\u51FB\u7BA1\u7406\u8F66\u8F86" } : parking.status === "empty" ? { eyebrow: "\u505C\u8F66\u670D\u52A1", primary: "\u70B9\u51FB\u6DFB\u52A0\u8F66\u8F86", meta: "\u6DFB\u52A0\u8F66\u8F86\u540E\u53EF\u67E5\u8BE2\u6216\u7F34\u8D39" } : parking.status === "loading" ? { eyebrow: "\u505C\u8F66\u670D\u52A1", primary: "", meta: "" } : parking.status === "unauthenticated" ? { eyebrow: "\u505C\u8F66\u670D\u52A1", primary: "\u767B\u5F55\u540E\u67E5\u770B\u8F66\u8F86", meta: "\u6388\u6743\u540E\u53EF\u67E5\u8BE2\u505C\u8F66\u8D39\u7528" } : parking.status === "membership_required" ? { eyebrow: "\u505C\u8F66\u670D\u52A1", primary: "\u5165\u4F1A\u540E\u67E5\u770B\u8F66\u8F86", meta: "\u5165\u4F1A\u540E\u53EF\u4EAB\u53D7\u79EF\u5206\u505C\u8F66" } : parking.status === "error" ? { eyebrow: "\u505C\u8F66\u670D\u52A1", primary: "\u505C\u8F66\u4FE1\u606F\u52A0\u8F7D\u5931\u8D25", meta: "\u8BF7\u7A0D\u540E\u91CD\u8BD5" } : { eyebrow: "\u505C\u8F66\u670D\u52A1", primary: "\u505C\u8F66\u670D\u52A1\u6682\u4E0D\u53EF\u7528", meta: "\u8BF7\u7A0D\u540E\u91CD\u8BD5" };
733
- const handleAction = () => {
734
- if (parking.status === "ready") (parkedIn ? () => onParkingFeeQuery?.(parking.parkedPlates) : onParkingVehicleQuery)?.();
735
- if (parking.status === "empty") onParkingVehicleQuery?.();
736
- if (parking.status === "unauthenticated") onReauthorizeParking?.();
737
- if (parking.status === "membership_required") onParkingMembershipQuery?.();
738
- if (parking.status === "error") onReloadParking?.();
739
- if (parking.status === "unavailable") onParkingServiceQuery?.();
740
- };
741
- return /* @__PURE__ */ jsx3(
742
- HomeServiceCard,
695
+ const isPage = variant === "page";
696
+ return /* @__PURE__ */ jsxs2(
697
+ "div",
743
698
  {
744
- tone: "parking",
745
- label: copy.eyebrow,
746
- iconSrc: parkingServiceIcon,
747
- primary: copy.primary,
748
- primaryMonospace: parkedIn,
749
- meta: copy.meta,
750
- loading: parking.status === "loading",
751
- loadingLabel: "\u8F66\u8F86\u4FE1\u606F\u52A0\u8F7D\u4E2D",
752
- disabled: parking.status === "loading",
753
- onClick: handleAction
699
+ className: `activity-detail-presentation activity-detail-presentation--${variant} w-full min-w-0 overflow-hidden bg-card text-[#263022] ${isPage ? "" : "@container/activity rounded-[14px] [contain:layout_paint]"}`,
700
+ children: [
701
+ /* @__PURE__ */ jsx3(
702
+ "div",
703
+ {
704
+ className: `activity-detail-presentation__hero activity-detail-presentation__hero--${variant} relative w-full overflow-hidden bg-[#fff8e9] ${isPage ? "aspect-[353/240]" : "aspect-auto h-[152px]"}`,
705
+ children: /* @__PURE__ */ jsx3(ActivityDetailHero, { variant: isPage ? "page" : "strip" })
706
+ }
707
+ ),
708
+ /* @__PURE__ */ jsx3(
709
+ "div",
710
+ {
711
+ className: `activity-detail-presentation__body relative z-[1] min-w-0 bg-card [&>*]:w-full ${isPage ? "-mt-[50px] rounded-t-[22px] px-0 pt-1 pb-4.5 shadow-[0_-10px_28px_rgba(38,48,34,0.08)]" : "-mt-3.5 rounded-t-[16px] px-0 pt-0 pb-2 shadow-none"} ${EMBED_SKIN}`,
712
+ children
713
+ }
714
+ )
715
+ ]
754
716
  }
755
717
  );
756
718
  }
757
- function MallHome({
758
- mallName,
759
- linkedOrder,
760
- member,
761
- parking,
762
- enrollUrl,
763
- showDevServices,
764
- onSend,
765
- renderActivityDetail,
766
- onReloadLinkedOrder,
767
- onReauthorizeLinkedOrder,
768
- onParkingFeeQuery,
769
- onParkingVehicleQuery,
770
- onParkingMembershipQuery,
771
- onParkingServiceQuery,
772
- onReloadParking,
773
- onReauthorizeParking,
774
- onMemberPointsQuery,
775
- onMemberEnrollmentQuery,
776
- onReloadMember,
777
- onReauthorizeMember
719
+
720
+ // src/client/HomeActivityDetailDialog.tsx
721
+ import {
722
+ useCallback,
723
+ useEffect as useEffect3,
724
+ useId,
725
+ useMemo as useMemo2,
726
+ useRef as useRef2,
727
+ useState as useState2
728
+ } from "react";
729
+ import { createPortal } from "react-dom";
730
+ import { X as X2 } from "@phosphor-icons/react";
731
+ import { OVERLAY_LAYER_CLASS, useOverlay } from "@tbox.cn/app-agent-ui-kit/overlay";
732
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
733
+ var MORPH_DURATION_MS = 300;
734
+ function getHomeActivityDialogId(cardId) {
735
+ return `home-activity-detail-${cardId.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
736
+ }
737
+ function rectOf(value) {
738
+ return { top: value.top, left: value.left, width: value.width, height: value.height };
739
+ }
740
+ function targetRect() {
741
+ const viewportWidth = window.innerWidth;
742
+ const viewportHeight = window.innerHeight;
743
+ if (viewportWidth <= 600) return { top: 0, left: 0, width: viewportWidth, height: viewportHeight };
744
+ const width = Math.min(620, viewportWidth - 32);
745
+ const height = Math.min(820, viewportHeight - 24);
746
+ return {
747
+ top: (viewportHeight - height) / 2,
748
+ left: (viewportWidth - width) / 2,
749
+ width,
750
+ height
751
+ };
752
+ }
753
+ function isVisibleOrigin(rect) {
754
+ return rect.width > 0 && rect.height > 0 && rect.top < window.innerHeight && rect.left < window.innerWidth && rect.top + rect.height > 0 && rect.left + rect.width > 0;
755
+ }
756
+ function prefersReducedMotion() {
757
+ return window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false;
758
+ }
759
+ function HomeActivityDetailDialog({
760
+ card,
761
+ origin,
762
+ triggerRef,
763
+ transitionVisual,
764
+ motion = "morph",
765
+ children,
766
+ onClosed
778
767
  }) {
779
- const displayMallName = mallName || "\u5546\u573A";
780
- const activityTriggerRef = useRef2(null);
781
- const activityCard = linkedOrder.status === "ready" ? linkedOrder.detailCard : void 0;
782
- const canOpenActivity = Boolean(activityCard && renderActivityDetail);
783
- const [activityDetail, setActivityDetail] = useState2(null);
784
- const closeActivityDetail = useCallback2(() => setActivityDetail(null), []);
785
- const linkedOrderVisual = /* @__PURE__ */ jsxs3(Fragment, { children: [
786
- /* @__PURE__ */ jsx3(
787
- "span",
768
+ const [phase, setPhase] = useState2("opening");
769
+ const [destination, setDestination] = useState2(() => targetRect());
770
+ const [closingOrigin, setClosingOrigin] = useState2(origin);
771
+ const [returnToOrigin, setReturnToOrigin] = useState2(true);
772
+ const closeRef = useRef2(null);
773
+ const panelRef = useRef2(null);
774
+ const closeTimerRef = useRef2(null);
775
+ const phaseRef = useRef2("opening");
776
+ const onClosedRef = useRef2(onClosed);
777
+ const titleId = useId();
778
+ const rawTitle = typeof card.data["mainTitle"] === "string" ? card.data["mainTitle"] : typeof card.data["title"] === "string" ? card.data["title"] : "";
779
+ const title = rawTitle.trim() || "\u6D3B\u52A8\u8BE6\u60C5";
780
+ onClosedRef.current = onClosed;
781
+ const finishClose = useCallback(() => {
782
+ if (closeTimerRef.current !== null) window.clearTimeout(closeTimerRef.current);
783
+ closeTimerRef.current = null;
784
+ onClosedRef.current();
785
+ }, []);
786
+ const requestClose = useCallback(() => {
787
+ if (phaseRef.current === "closing") return;
788
+ const triggerRect = triggerRef.current?.getBoundingClientRect();
789
+ const nextOrigin = triggerRect ? rectOf(triggerRect) : origin;
790
+ const canReturnToOrigin = motion === "morph" && isVisibleOrigin(nextOrigin);
791
+ if (canReturnToOrigin) setClosingOrigin(nextOrigin);
792
+ setReturnToOrigin(canReturnToOrigin);
793
+ phaseRef.current = "closing";
794
+ setPhase("closing");
795
+ closeTimerRef.current = window.setTimeout(
796
+ finishClose,
797
+ prefersReducedMotion() ? 0 : MORPH_DURATION_MS
798
+ );
799
+ }, [finishClose, motion, origin, triggerRef]);
800
+ useEffect3(() => {
801
+ const frame = window.requestAnimationFrame(() => {
802
+ if (phaseRef.current !== "opening") return;
803
+ phaseRef.current = "open";
804
+ setPhase("open");
805
+ });
806
+ return () => window.cancelAnimationFrame(frame);
807
+ }, []);
808
+ useEffect3(() => {
809
+ const updateDestination = () => setDestination(targetRect());
810
+ window.addEventListener("resize", updateDestination);
811
+ return () => window.removeEventListener("resize", updateDestination);
812
+ }, []);
813
+ useOverlay({
814
+ active: true,
815
+ onDismiss: () => requestClose(),
816
+ panelRef,
817
+ initialFocus: closeRef,
818
+ restoreFocus: triggerRef.current ? { current: triggerRef.current } : "previous"
819
+ });
820
+ useEffect3(() => () => {
821
+ if (closeTimerRef.current !== null) window.clearTimeout(closeTimerRef.current);
822
+ }, []);
823
+ const surfaceRect = motion === "fade" ? destination : phase === "opening" ? origin : phase === "closing" ? returnToOrigin ? closingOrigin : destination : destination;
824
+ const surfaceStyle = useMemo2(() => ({
825
+ top: `${surfaceRect.top}px`,
826
+ left: `${surfaceRect.left}px`,
827
+ width: `${surfaceRect.width}px`,
828
+ height: `${surfaceRect.height}px`
829
+ }), [surfaceRect]);
830
+ return createPortal(
831
+ /* @__PURE__ */ jsxs3(
832
+ "div",
788
833
  {
789
- className: "mall-home__linked-order-poster",
790
- ...canOpenActivity ? { "aria-hidden": true } : { role: "img", "aria-label": "\u53C2\u4E0E\u8054\u5355\uFF0C\u78B0\u51FA\u60CA\u559C" }
834
+ className: `home-activity-detail group/detail fixed inset-0 ${OVERLAY_LAYER_CLASS.modal}`,
835
+ "data-motion": motion,
836
+ "data-phase": phase,
837
+ "data-return-origin": returnToOrigin ? "true" : "false",
838
+ children: [
839
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "home-activity-detail__mask absolute inset-0 size-full border-0 bg-transparent p-0 transition-colors duration-200 group-data-[phase=open]/detail:bg-scrim", "aria-label": "\u5173\u95ED\u6D3B\u52A8\u8BE6\u60C5", onClick: requestClose }),
840
+ /* @__PURE__ */ jsxs3(
841
+ "section",
842
+ {
843
+ ref: panelRef,
844
+ id: getHomeActivityDialogId(card.id),
845
+ className: "home-activity-detail__surface fixed z-10 min-h-0 min-w-0 overflow-hidden rounded-xl bg-card shadow-[0_20px_60px_rgba(22,42,30,0.22)] contain-[layout_paint] transition-all duration-300 will-change-[top,left,width,height,border-radius,transform] group-data-[phase=open]/detail:rounded-2xl group-data-[motion=fade]/detail:group-data-[phase=opening]/detail:scale-[0.985] group-data-[motion=fade]/detail:group-data-[phase=opening]/detail:opacity-0 group-data-[motion=fade]/detail:group-data-[phase=open]/detail:scale-100 group-data-[motion=fade]/detail:group-data-[phase=open]/detail:opacity-100 group-data-[phase=closing]/detail:group-data-[return-origin=false]/detail:scale-[0.98] group-data-[phase=closing]/detail:group-data-[return-origin=false]/detail:opacity-0 max-[600px]:h-screen! max-[600px]:supports-[height:100dvh]:h-dvh! max-[600px]:w-screen! max-[600px]:rounded-none! motion-reduce:transition-none",
846
+ style: surfaceStyle,
847
+ role: "dialog",
848
+ "aria-modal": "true",
849
+ "aria-labelledby": titleId,
850
+ tabIndex: -1,
851
+ children: [
852
+ /* @__PURE__ */ jsx4("h2", { id: titleId, className: "home-activity-detail__sr-title sr-only", children: title }),
853
+ transitionVisual && /* @__PURE__ */ jsx4("div", { className: "home-activity-detail__transition-visual absolute inset-0 z-20 overflow-hidden bg-warn-surface transition-opacity duration-150 group-data-[phase=open]/detail:pointer-events-none group-data-[phase=open]/detail:opacity-0 group-data-[phase=open]/detail:delay-150 [&_.mall-home__linked-order]:m-0 [&_.mall-home__linked-order]:aspect-[353/240] [&_.mall-home__linked-order]:h-auto [&_.mall-home__linked-order]:w-full [&_.mall-home__linked-order]:rounded-none [&_.mall-home__linked-order]:shadow-none", "aria-hidden": "true", children: transitionVisual }),
854
+ /* @__PURE__ */ jsx4("div", { className: "home-activity-detail__content absolute inset-0 z-10 min-h-0 translate-y-3 overflow-y-auto overscroll-contain bg-card pb-[env(safe-area-inset-bottom)] opacity-0 transition-[opacity,transform] duration-150 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden group-data-[phase=open]/detail:translate-y-0 group-data-[phase=open]/detail:opacity-100 group-data-[phase=open]/detail:delay-150 group-data-[motion=fade]/detail:group-data-[phase=open]/detail:delay-0 motion-reduce:transition-none", children: /* @__PURE__ */ jsx4(ActivityDetailPresentation, { variant: "page", children }) }),
855
+ /* @__PURE__ */ jsx4("button", { ref: closeRef, type: "button", className: "home-activity-detail__close absolute right-3.5 top-[max(14px,env(safe-area-inset-top))] z-30 grid size-10.5 place-items-center rounded-full border border-border bg-card p-0 text-foreground opacity-0 shadow-lg transition-opacity duration-150 group-data-[phase=open]/detail:opacity-100 group-data-[phase=open]/detail:delay-150 focus-visible:outline-3 focus-visible:outline-offset-2 focus-visible:outline-focus-ring motion-reduce:transition-none", "aria-label": "\u5173\u95ED\u6D3B\u52A8\u8BE6\u60C5\uFF0C\u8FD4\u56DE\u9996\u9875", onClick: requestClose, children: /* @__PURE__ */ jsx4(X2, { size: 21, weight: "bold", "aria-hidden": "true" }) })
856
+ ]
857
+ }
858
+ )
859
+ ]
791
860
  }
792
861
  ),
793
- /* @__PURE__ */ jsx3("div", { className: "mall-home__progress", children: /* @__PURE__ */ jsx3(
794
- LinkedOrderStatus,
795
- {
796
- linkedOrder,
797
- onReloadLinkedOrder,
798
- onReauthorizeLinkedOrder
799
- }
800
- ) })
801
- ] });
802
- useEffect2(() => {
803
- if (activityDetail && (activityCard !== activityDetail.card || renderActivityDetail !== activityDetail.renderDetail)) setActivityDetail(null);
804
- }, [activityCard, activityDetail, renderActivityDetail]);
805
- const openActivityDetail = useCallback2(() => {
806
- const trigger = activityTriggerRef.current;
807
- if (!trigger || !activityCard || !renderActivityDetail || activityDetail) return;
862
+ document.body
863
+ );
864
+ }
865
+
866
+ // src/client/cards/overrides/BumpInActivityChatCard.tsx
867
+ import { useChatRawCards } from "@tbox.cn/app-agent-ui-kit";
868
+ import { Fragment, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
869
+ var BUMPIN_CARD_TYPE = "promotion-bumpin-activity";
870
+ var BumpInActivityChatCard = (props) => {
871
+ const triggerRef = useRef3(null);
872
+ const [detailOrigin, setDetailOrigin] = useState3(null);
873
+ const rawCards = useChatRawCards();
874
+ const Base = rawCards[BUMPIN_CARD_TYPE];
875
+ const { data, cardId, isHistory, actionTokens } = props;
876
+ const closeDetail = useCallback2(() => setDetailOrigin(null), []);
877
+ if (!Base) return null;
878
+ const mode = data && typeof data === "object" && !Array.isArray(data) ? data["mode"] : void 0;
879
+ if (mode !== "detail") {
880
+ return /* @__PURE__ */ jsx5(Base, { data, cardId, isHistory, actionTokens });
881
+ }
882
+ const detailData = data;
883
+ const inlineData = { ...detailData };
884
+ delete inlineData["description"];
885
+ delete inlineData["tagLabel"];
886
+ if (Array.isArray(detailData["vouchers"])) inlineData["vouchers"] = [];
887
+ const openDetail = () => {
888
+ const trigger = triggerRef.current;
889
+ if (!trigger || detailOrigin) return;
808
890
  const rect = trigger.getBoundingClientRect();
809
- setActivityDetail({
810
- card: activityCard,
811
- renderDetail: renderActivityDetail,
812
- transitionVisual: /* @__PURE__ */ jsx3("section", { className: "mall-home__linked-order", "aria-hidden": "true", children: linkedOrderVisual }),
813
- origin: { top: rect.top, left: rect.left, width: rect.width, height: rect.height }
814
- });
815
- }, [activityCard, activityDetail, linkedOrderVisual, renderActivityDetail]);
816
- return /* @__PURE__ */ jsxs3("main", { className: "mall-home", "aria-label": "\u5546\u573A\u667A\u80FD\u670D\u52A1\u9996\u9875", children: [
817
- /* @__PURE__ */ jsxs3("header", { className: "mall-home__welcome", children: [
818
- /* @__PURE__ */ jsx3(
819
- "img",
820
- {
821
- className: "mall-home__welcome-sparkle",
822
- src: welcomeSparkle,
823
- alt: "",
824
- "aria-hidden": "true"
825
- }
826
- ),
827
- /* @__PURE__ */ jsxs3("h1", { children: [
828
- "\u6B22\u8FCE\u6765\u5230",
829
- displayMallName
830
- ] }),
831
- /* @__PURE__ */ jsx3("p", { children: "\u6211\u53EF\u4EE5\u5E2E\u4F60\u770B\u8054\u5355\u8FDB\u5EA6\u3001\u67E5\u505C\u8F66\u3001\u770B\u4F1A\u5458\u4E0E\u6D3B\u52A8\u670D\u52A1" })
832
- ] }),
833
- /* @__PURE__ */ jsxs3("section", { className: "mall-home__linked-order", "aria-label": "\u78B0\u4E00\u4E0B\u8054\u5355\u6D3B\u52A8", children: [
834
- linkedOrderVisual,
835
- canOpenActivity && activityCard && /* @__PURE__ */ jsx3(
891
+ setDetailOrigin({ top: rect.top, left: rect.left, width: rect.width, height: rect.height });
892
+ };
893
+ return /* @__PURE__ */ jsxs4(Fragment, { children: [
894
+ /* @__PURE__ */ jsxs4(ActivityDetailPresentation, { variant: "inline", children: [
895
+ /* @__PURE__ */ jsx5(Base, { data: inlineData, cardId, isHistory, actionTokens }),
896
+ /* @__PURE__ */ jsxs4(
836
897
  "button",
837
898
  {
838
- ref: activityTriggerRef,
899
+ ref: triggerRef,
839
900
  type: "button",
840
- className: "mall-home__linked-order-trigger",
841
- "aria-label": `\u67E5\u770B${linkedOrder.status === "ready" ? linkedOrder.banner.title || "\u8054\u5355\u6D3B\u52A8" : "\u8054\u5355\u6D3B\u52A8"}\u8BE6\u60C5`,
901
+ className: "activity-detail-presentation__detail-trigger mt-2 mb-0 flex min-h-8 w-full cursor-pointer items-center justify-center gap-0.5 rounded-none border-0 bg-transparent p-0 text-xs font-normal leading-[18px] text-[#686d69] shadow-none [font-family:inherit] [&_svg]:shrink-0 active:opacity-[0.68] focus-visible:rounded-[5px] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[rgba(9,107,250,0.28)]",
842
902
  "aria-haspopup": "dialog",
843
- "aria-expanded": Boolean(activityDetail),
844
- "aria-controls": getHomeActivityDialogId(activityDetail?.card.id ?? activityCard.id),
845
- onClick: openActivityDetail
903
+ "aria-expanded": detailOrigin !== null,
904
+ "aria-controls": getHomeActivityDialogId(cardId),
905
+ onClick: openDetail,
906
+ children: [
907
+ /* @__PURE__ */ jsx5("span", { children: "\u67E5\u770B\u6D3B\u52A8\u8BE6\u60C5" }),
908
+ /* @__PURE__ */ jsx5(CaretRight, { size: 17, "aria-hidden": "true" })
909
+ ]
846
910
  }
847
911
  )
848
912
  ] }),
849
- activityDetail && /* @__PURE__ */ jsx3(
913
+ detailOrigin && /* @__PURE__ */ jsx5(
850
914
  HomeActivityDetailDialog,
851
915
  {
852
- card: activityDetail.card,
853
- origin: activityDetail.origin,
854
- triggerRef: activityTriggerRef,
855
- transitionVisual: activityDetail.transitionVisual,
856
- onClosed: closeActivityDetail,
857
- children: activityDetail.renderDetail(activityDetail.card)
916
+ card: { id: cardId, data: detailData },
917
+ origin: detailOrigin,
918
+ triggerRef,
919
+ motion: "fade",
920
+ onClosed: closeDetail,
921
+ children: /* @__PURE__ */ jsx5(Base, { data: detailData, cardId, isHistory, actionTokens })
858
922
  }
859
- ),
860
- /* @__PURE__ */ jsxs3("div", { className: "mall-home__service-pair", children: [
861
- /* @__PURE__ */ jsx3(
862
- MemberServiceCard,
863
- {
864
- member,
865
- onMemberPointsQuery,
866
- onMemberEnrollmentQuery,
867
- onReloadMember,
868
- onReauthorizeMember
869
- }
870
- ),
871
- /* @__PURE__ */ jsx3(
872
- ParkingServiceCard,
873
- {
874
- parking,
875
- onParkingFeeQuery,
876
- onParkingVehicleQuery,
877
- onParkingMembershipQuery,
878
- onParkingServiceQuery,
879
- onReloadParking,
880
- onReauthorizeParking
881
- }
882
- )
883
- ] }),
884
- showDevServices && /* @__PURE__ */ jsxs3("section", { className: "mall-home__services", "aria-labelledby": "mall-home-services-title", children: [
885
- /* @__PURE__ */ jsx3("header", { className: "mall-home__section-header", children: /* @__PURE__ */ jsxs3("div", { children: [
886
- /* @__PURE__ */ jsx3("h2", { id: "mall-home-services-title", children: "\u5E38\u7528\u670D\u52A1" }),
887
- /* @__PURE__ */ jsx3("span", { className: "mall-home__section-kicker", children: "\u4EE5\u4E0B\u90E8\u5206\u4E3A\u5F00\u53D1\u6D4B\u8BD5\u5165\u53E3\uFF0C\u4E0D\u5BF9\u6B63\u5F0F\u7528\u6237\u900F\u51FA" })
888
- ] }) }),
889
- /* @__PURE__ */ jsx3("div", { className: "mall-home__areas", children: BUSINESS_AREAS.map((area) => {
890
- const AreaIcon = area.icon;
891
- return /* @__PURE__ */ jsxs3(
892
- "section",
893
- {
894
- className: `mall-home__area mall-home__area--${area.tone}`,
895
- "aria-labelledby": `mall-home-${area.moduleId}`,
896
- children: [
897
- /* @__PURE__ */ jsxs3("header", { className: "mall-home__area-header", children: [
898
- /* @__PURE__ */ jsxs3("span", { className: "mall-home__area-copy", children: [
899
- /* @__PURE__ */ jsx3("h3", { id: `mall-home-${area.moduleId}`, children: area.title }),
900
- /* @__PURE__ */ jsx3("p", { children: area.description })
901
- ] }),
902
- /* @__PURE__ */ jsx3("span", { className: "mall-home__area-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx3(AreaIcon, { size: 22, weight: "regular" }) })
903
- ] }),
904
- /* @__PURE__ */ jsx3("div", { className: "mall-home__action-grid", children: area.actions.map((action) => {
905
- return /* @__PURE__ */ jsxs3(
906
- "button",
907
- {
908
- className: "mall-home__action",
909
- type: "button",
910
- onClick: () => {
911
- if (action.enroll && openEnrollMiniProgram(enrollUrl)) return;
912
- onSend(action.query);
913
- },
914
- children: [
915
- /* @__PURE__ */ jsxs3("span", { className: "mall-home__action-copy", children: [
916
- /* @__PURE__ */ jsx3("strong", { children: action.label }),
917
- /* @__PURE__ */ jsx3("small", { children: action.description })
918
- ] }),
919
- /* @__PURE__ */ jsx3(CaretRight, { size: 14, weight: "bold", "aria-hidden": "true" })
920
- ]
921
- },
922
- action.label
923
- );
924
- }) })
925
- ]
926
- },
927
- area.moduleId
928
- );
929
- }) })
930
- ] })
923
+ )
931
924
  ] });
932
- }
925
+ };
933
926
 
934
- // src/client/components/MemberGateSheet/index.tsx
935
- import { useEffect as useEffect3, useRef as useRef3 } from "react";
936
- import { createPortal as createPortal2 } from "react-dom";
937
- import { X as X2 } from "@phosphor-icons/react";
938
- import "./index-ELJ55M66.less";
939
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
940
- var FOCUSABLE_SELECTOR2 = [
941
- "button:not([disabled])",
942
- "[href]",
943
- "input:not([disabled])",
944
- "select:not([disabled])",
945
- "textarea:not([disabled])",
946
- '[tabindex]:not([tabindex="-1"])'
947
- ].join(",");
948
- var DEFAULT_TITLE = {
949
- login: "\u767B\u5F55\u540E\u7EE7\u7EED",
950
- enroll: "\u5165\u4F1A\u540E\u7EE7\u7EED"
951
- };
952
- var DEFAULT_DESCRIPTION = {
953
- login: "\u767B\u5F55\u540E\u53EF\u67E5\u79EF\u5206\u3001\u9886\u6743\u76CA\u3001\u7F34\u8F66\u8D39",
954
- enroll: "\u5165\u4F1A\u540E\u53EF\u83B7\u5F97\u79EF\u5206\u3001\u9886\u6743\u76CA\u3001\u7F34\u8F66\u8D39"
955
- };
956
- var CONFIRM_LABEL = {
957
- login: "\u7ACB\u5373\u767B\u5F55",
958
- enroll: "\u7ACB\u5373\u5165\u4F1A"
959
- };
960
- function MemberGateSheet({
961
- context,
962
- phase,
963
- message,
964
- busy,
965
- onConfirm,
966
- onRetry,
967
- onDismiss
927
+ // src/client/MallHome.tsx
928
+ import { useCallback as useCallback3, useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
929
+ import {
930
+ BookOpen,
931
+ Buildings,
932
+ Car,
933
+ CaretRight as CaretRight2,
934
+ Check,
935
+ Coins,
936
+ Gift,
937
+ Headset,
938
+ IdentificationCard,
939
+ LockSimple,
940
+ SignIn,
941
+ Sparkle,
942
+ Storefront,
943
+ Ticket,
944
+ UserPlus
945
+ } from "@phosphor-icons/react";
946
+ import memberServiceIcon from "./member-service-icon-SIGSRKE3.svg";
947
+ import parkingServiceIcon from "./parking-service-icon-3A2TGUUM.svg";
948
+ import welcomeSparkle from "./welcome-sparkle-transparent-v07-75RL4QUU.png";
949
+ import { callJsapi, isInAlipayShell as isInAlipayShell2 } from "@tbox.cn/app-agent-sdk-client";
950
+ import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
951
+ function HomeServiceCard({
952
+ tone,
953
+ label,
954
+ iconSrc,
955
+ primary,
956
+ primaryMonospace,
957
+ meta,
958
+ loading,
959
+ loadingLabel,
960
+ disabled,
961
+ onClick
968
962
  }) {
969
- const sheetRef = useRef3(null);
970
- const closeRef = useRef3(null);
971
- const confirmButtonRef = useRef3(null);
972
- const openingRef = useRef3(false);
973
- const contextId = context.id;
974
- const titleId = `member-login-sheet-title-${contextId}`;
975
- const descriptionId = `member-login-sheet-description-${contextId}`;
976
- const isTerminal = phase === "not-enrolled" || phase === "failed";
977
- const heroTitle = isTerminal ? phase === "not-enrolled" ? context.kind === "enroll" ? "\u5C1A\u672A\u5B8C\u6210\u5165\u4F1A" : "\u5C1A\u672A\u5B8C\u6210\u767B\u5F55" : "\u64CD\u4F5C\u672A\u5B8C\u6210" : context.title ?? DEFAULT_TITLE[context.kind];
978
- const description = isTerminal ? phase === "not-enrolled" ? "\u82E5\u4F60\u521A\u5728\u5546\u573A\u5C0F\u7A0B\u5E8F\u5B8C\u6210\u8FC7\u64CD\u4F5C\uFF0C\u53EF\u80FD\u9700\u8981\u4E00\u70B9\u65F6\u95F4\u540C\u6B65" : message ?? "\u8BF7\u7A0D\u540E\u91CD\u8BD5" : context.subtitle ?? DEFAULT_DESCRIPTION[context.kind];
979
- useEffect3(() => {
980
- const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
981
- const previousOverflow = document.body.style.overflow;
982
- const appRoot = document.getElementById("root");
983
- const previousAriaHidden = appRoot?.getAttribute("aria-hidden") ?? null;
984
- const previousInert = appRoot?.inert ?? false;
985
- document.body.style.overflow = "hidden";
986
- if (appRoot) {
987
- appRoot.setAttribute("aria-hidden", "true");
988
- appRoot.inert = true;
989
- }
990
- closeRef.current?.focus();
991
- const handleKeyDown = (event) => {
992
- if (event.key === "Escape") {
993
- event.preventDefault();
994
- onDismiss();
995
- return;
996
- }
997
- if (event.key !== "Tab") return;
998
- const focusable = Array.from(
999
- sheetRef.current?.querySelectorAll(FOCUSABLE_SELECTOR2) ?? []
1000
- );
1001
- if (focusable.length === 0) {
1002
- event.preventDefault();
1003
- return;
1004
- }
1005
- const first = focusable[0];
1006
- const last = focusable[focusable.length - 1];
1007
- if (event.shiftKey && document.activeElement === first) {
1008
- event.preventDefault();
1009
- last.focus();
1010
- } else if (!event.shiftKey && document.activeElement === last) {
1011
- event.preventDefault();
1012
- first.focus();
1013
- }
1014
- };
1015
- document.addEventListener("keydown", handleKeyDown);
1016
- return () => {
1017
- document.removeEventListener("keydown", handleKeyDown);
1018
- document.body.style.overflow = previousOverflow;
1019
- if (appRoot) {
1020
- appRoot.inert = previousInert;
1021
- if (previousAriaHidden === null) appRoot.removeAttribute("aria-hidden");
1022
- else appRoot.setAttribute("aria-hidden", previousAriaHidden);
1023
- }
1024
- previousFocus?.focus();
1025
- };
1026
- }, [contextId, onDismiss]);
1027
- useEffect3(() => {
1028
- if (phase === "idle") {
1029
- openingRef.current = false;
1030
- }
1031
- }, [phase, contextId]);
1032
- const performConfirm = () => {
1033
- if (openingRef.current) return;
1034
- openingRef.current = true;
1035
- onConfirm();
1036
- };
1037
- const confirmLabel = busy ? "\u56DE\u7B54\u751F\u6210\u4E2D\u2026" : phase === "opening" ? "\u6B63\u5728\u6253\u5F00\u5546\u573A\u5C0F\u7A0B\u5E8F\u2026" : CONFIRM_LABEL[context.kind];
1038
- const confirmDisabled = busy || phase !== "idle";
1039
- return createPortal2(
1040
- /* @__PURE__ */ jsxs4("div", { className: "member-login-sheet", role: "presentation", children: [
1041
- /* @__PURE__ */ jsx4("div", { className: "member-login-sheet__mask", "aria-hidden": "true", onClick: () => onDismiss() }),
1042
- /* @__PURE__ */ jsxs4(
1043
- "section",
963
+ const labelId = `mall-home-${tone}-label`;
964
+ const valueId = `mall-home-${tone}-value`;
965
+ const metaId = `mall-home-${tone}-meta`;
966
+ return /* @__PURE__ */ jsx6(
967
+ "section",
968
+ {
969
+ className: `mall-home__service-card mall-home__service-card--${tone} relative min-w-0 overflow-hidden rounded-[16px] border-[0.5px] border-border bg-card shadow-[0_2px_16px_rgba(106,119,137,0.08)]`,
970
+ "aria-label": label,
971
+ children: /* @__PURE__ */ jsxs5(
972
+ "button",
1044
973
  {
1045
- ref: sheetRef,
1046
- className: "member-login-sheet__panel",
1047
- role: "dialog",
1048
- "aria-modal": "true",
1049
- "aria-labelledby": titleId,
1050
- "aria-describedby": descriptionId,
974
+ className: "mall-home__service-card-main relative flex h-full min-h-[95px] w-full cursor-pointer flex-col gap-1.5 border-0 bg-transparent p-3 text-left text-inherit [font-family:inherit] disabled:cursor-default disabled:opacity-[0.72] max-[360px]:px-2.5",
975
+ type: "button",
976
+ disabled,
977
+ onClick,
978
+ "aria-busy": loading || void 0,
979
+ "aria-labelledby": `${labelId} ${valueId}`,
980
+ "aria-describedby": metaId,
1051
981
  children: [
1052
- /* @__PURE__ */ jsx4("div", { className: "member-login-sheet__handle", "aria-hidden": "true" }),
1053
- /* @__PURE__ */ jsx4(
1054
- "button",
982
+ /* @__PURE__ */ jsx6(
983
+ "img",
1055
984
  {
1056
- ref: closeRef,
1057
- type: "button",
1058
- className: "member-login-sheet__close",
1059
- "aria-label": "\u5173\u95ED\u767B\u5F55\u63D0\u793A",
1060
- onClick: () => onDismiss(),
1061
- children: /* @__PURE__ */ jsx4(X2, { size: 18, weight: "bold", "aria-hidden": "true" })
985
+ className: "mall-home__service-card-icon absolute top-3 right-3 z-[1] block h-8 w-[33.18px] object-contain max-[360px]:right-2.5",
986
+ src: iconSrc,
987
+ alt: "",
988
+ "aria-hidden": "true"
1062
989
  }
1063
990
  ),
1064
- /* @__PURE__ */ jsxs4("div", { className: "member-login-sheet__scroll", children: [
1065
- /* @__PURE__ */ jsx4("div", { className: "member-login-sheet__hero", "aria-hidden": "true" }),
1066
- /* @__PURE__ */ jsx4("div", { className: "member-login-sheet__tear", "aria-hidden": "true" }),
1067
- /* @__PURE__ */ jsxs4("div", { className: "member-login-sheet__content", children: [
1068
- /* @__PURE__ */ jsx4("h2", { id: titleId, children: heroTitle }),
1069
- /* @__PURE__ */ jsx4("p", { id: descriptionId, className: "member-login-sheet__description", children: description }),
1070
- isTerminal ? /* @__PURE__ */ jsxs4("div", { className: "member-login-sheet__status-actions", children: [
1071
- /* @__PURE__ */ jsx4("button", { type: "button", onClick: () => onDismiss(), children: "\u6682\u4E0D" }),
1072
- /* @__PURE__ */ jsx4(
1073
- "button",
1074
- {
1075
- ref: confirmButtonRef,
1076
- type: "button",
1077
- disabled: busy,
1078
- onClick: () => onRetry(),
1079
- children: busy ? "\u56DE\u7B54\u751F\u6210\u4E2D\u2026" : phase === "not-enrolled" ? "\u91CD\u8BD5\u5165\u4F1A" : "\u91CD\u8BD5"
1080
- }
1081
- )
1082
- ] }) : /* @__PURE__ */ jsx4(
1083
- "button",
1084
- {
1085
- ref: confirmButtonRef,
1086
- type: "button",
1087
- className: "member-login-sheet__login",
1088
- disabled: confirmDisabled,
1089
- onClick: performConfirm,
1090
- children: phase === "syncing" ? "\u8EAB\u4EFD\u540C\u6B65\u4E2D\u2026" : confirmLabel
1091
- }
1092
- )
1093
- ] })
1094
- ] })
991
+ /* @__PURE__ */ jsx6("span", { id: labelId, className: "mall-home__service-card-eyebrow truncate pr-9 text-sm leading-5 text-foreground", children: label }),
992
+ /* @__PURE__ */ jsx6("span", { id: valueId, className: "mall-home__service-card-value flex min-h-[22px] min-w-0 items-center", "aria-live": "polite", children: loading ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
993
+ /* @__PURE__ */ jsx6(
994
+ "span",
995
+ {
996
+ className: "mall-home__service-card-skeleton mall-home__service-card-skeleton--value block h-[18px] w-[72%] shrink-0 rounded-[5px] bg-[linear-gradient(90deg,rgba(20,50,91,0.08),rgba(20,50,91,0.15),rgba(20,50,91,0.08))]",
997
+ "aria-hidden": "true"
998
+ }
999
+ ),
1000
+ /* @__PURE__ */ jsx6("span", { className: "sr-only", children: loadingLabel })
1001
+ ] }) : /* @__PURE__ */ jsx6(
1002
+ "strong",
1003
+ {
1004
+ className: `line-clamp-2 text-base font-semibold leading-[22px] text-foreground ${primaryMonospace ? " mall-home__plate font-mono tracking-[0.02em] tabular-nums" : ""}`,
1005
+ children: primary
1006
+ }
1007
+ ) }),
1008
+ /* @__PURE__ */ jsx6("span", { id: metaId, className: "mall-home__service-card-meta line-clamp-2 min-h-[17px] text-left text-xs leading-[17px] text-secondary-foreground", children: loading ? /* @__PURE__ */ jsx6(
1009
+ "span",
1010
+ {
1011
+ className: "mall-home__service-card-skeleton mall-home__service-card-skeleton--meta block h-[13px] w-[88%] shrink-0 rounded-[5px] bg-[linear-gradient(90deg,rgba(20,50,91,0.08),rgba(20,50,91,0.15),rgba(20,50,91,0.08))]",
1012
+ "aria-hidden": "true"
1013
+ }
1014
+ ) : meta })
1095
1015
  ]
1096
1016
  }
1097
1017
  )
1098
- ] }),
1099
- document.body
1018
+ }
1100
1019
  );
1101
1020
  }
1102
-
1103
- // src/client/components/MemberGateSheet/model.ts
1104
- var MEMBER_GATE_CARD_TYPES = ["member-login-cta", "member-enrollment-cta"];
1105
- function isMemberGateCard(card) {
1106
- return MEMBER_GATE_CARD_TYPES.includes(card.cardType);
1107
- }
1108
- function filterInlineCards(cards2) {
1109
- return cards2.filter((card) => !isMemberGateCard(card));
1110
- }
1111
- function selectLatestMemberGateCard(liveMessageIds, cardsByMessageId, orphanCards) {
1112
- const candidates = [
1113
- ...liveMessageIds.flatMap((messageId) => cardsByMessageId[messageId] ?? []),
1114
- ...orphanCards
1115
- ].filter((card) => isMemberGateCard(card) && !card.isHistory);
1116
- return candidates.reduce((latest, card) => {
1117
- if (!latest) return card;
1118
- const latestCreatedAt = latest.meta?.createdAt ?? Number.NEGATIVE_INFINITY;
1119
- const cardCreatedAt = card.meta?.createdAt ?? Number.NEGATIVE_INFINITY;
1120
- return cardCreatedAt >= latestCreatedAt ? card : latest;
1121
- }, null);
1122
- }
1123
-
1124
- // src/client/member-gate.ts
1125
- import { useSyncExternalStore } from "react";
1126
- var GATE_CANCEL_TOAST = "\u5DF2\u53D6\u6D88\uFF0C\u672A\u5B8C\u6210\u5165\u4F1A";
1127
- var GATE_NOT_ENROLLED_TOAST = "\u5C1A\u672A\u5B8C\u6210\u5165\u4F1A";
1128
- var GATE_UNAVAILABLE_TOAST = "\u6B63\u5728\u6253\u5F00\u652F\u4ED8\u5B9D\u2026";
1129
- var GATE_UNAVAILABLE_FALLBACK = "\u5F53\u524D\u73AF\u5883\u6682\u4E0D\u652F\u6301\u8DF3\u8F6C\uFF0C\u8BF7\u5728\u652F\u4ED8\u5B9D\u5185\u6253\u5F00\u5C0F\u7A0B\u5E8F";
1130
- var GATE_RELOGIN_FAILED = "\u767B\u5F55\u72B6\u6001\u540C\u6B65\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";
1131
- var GATE_OPEN_FAILED = "\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\u5546\u573A\u5C0F\u7A0B\u5E8F\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5";
1132
- var GATE_PANEL_FAILED = "\u4F1A\u5458\u72B6\u6001\u540C\u6B65\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";
1133
- function gateContextFromCard(card) {
1134
- const isEnroll = card.cardType === "member-enrollment-cta";
1135
- const url = isEnroll ? typeof card.data.enrollUrl === "string" ? card.data.enrollUrl : "" : typeof card.data.loginUrl === "string" ? card.data.loginUrl : "";
1136
- return {
1137
- id: card.id,
1138
- kind: isEnroll ? "enroll" : "login",
1139
- source: "card",
1140
- ...url ? { url } : {},
1141
- ...typeof card.data.title === "string" && card.data.title ? { title: card.data.title } : {},
1142
- ...typeof card.data.subtitle === "string" && card.data.subtitle ? { subtitle: card.data.subtitle } : {}
1143
- };
1144
- }
1145
- var INITIAL_STATE = { phase: "idle", sheetVisible: false };
1146
- function createMemberGate(deps) {
1147
- let state = INITIAL_STATE;
1148
- const listeners = /* @__PURE__ */ new Set();
1149
- let pendingReplay = null;
1150
- let flightSeq = 0;
1151
- const log = (message) => {
1152
- deps.log?.(message);
1153
- };
1154
- const setState = (partial) => {
1155
- state = { ...state, ...partial };
1156
- for (const notify of listeners) notify();
1157
- };
1158
- const inFlight = () => state.phase === "opening" || state.phase === "syncing";
1159
- const hideContextCard = () => {
1160
- if (state.card && !state.card.synthetic) deps.hideCard(state.card.id);
1161
- };
1162
- const closeSheet = () => {
1163
- setState({ sheetVisible: false });
1164
- };
1165
- const settleUpgraded = async () => {
1166
- setState({ phase: "idle" });
1167
- closeSheet();
1168
- hideContextCard();
1169
- deps.refreshPanel();
1170
- const replay = pendingReplay;
1171
- pendingReplay = null;
1172
- if (!replay) {
1173
- log("replay skipped:reason=none");
1174
- return;
1175
- }
1176
- const socketOpen = await deps.waitForSocketOpen(5e3);
1177
- if (!socketOpen) {
1178
- log("replay skipped:reason=socket-timeout");
1179
- return;
1180
- }
1181
- if (deps.isGenerating()) {
1182
- log("replay skipped:reason=generating");
1183
- return;
1184
- }
1185
- const currentAnchor = deps.lastUserMessage()?.id ?? null;
1186
- if (currentAnchor !== replay.anchorMessageId) {
1187
- log("replay skipped:reason=stale");
1188
- return;
1189
- }
1190
- deps.sendMessage(replay.query);
1191
- log("replay sent");
1021
+ function MemberServiceCard({
1022
+ member,
1023
+ onMemberPointsQuery,
1024
+ onMemberEnrollmentQuery,
1025
+ onReloadMember,
1026
+ onReauthorizeMember
1027
+ }) {
1028
+ const copy = member.status === "active" ? {
1029
+ primary: member.balance === void 0 ? "\u79EF\u5206\u6682\u4E0D\u53EF\u7528" : `${member.balance.toLocaleString("zh-CN")} \u79EF\u5206`,
1030
+ meta: member.membershipLabel ?? "\u67E5\u770B\u79EF\u5206\u4E0E\u4F1A\u5458\u670D\u52A1"
1031
+ } : member.status === "not_enrolled" ? { primary: "\u7ACB\u5373\u52A0\u5165\u4F1A\u5458", meta: "\u5165\u4F1A\u540E\u67E5\u770B\u79EF\u5206" } : member.status === "closed" ? { primary: "\u91CD\u65B0\u52A0\u5165\u4F1A\u5458", meta: "\u6062\u590D\u4F1A\u5458\u540E\u67E5\u770B\u79EF\u5206\u4E0E\u670D\u52A1" } : member.status === "loading" ? { primary: "", meta: "" } : member.status === "unauthenticated" ? { primary: "\u767B\u5F55\u540E\u67E5\u770B\u4F1A\u5458", meta: "\u6388\u6743\u540E\u53EF\u67E5\u770B\u4F1A\u5458\u4FE1\u606F" } : member.status === "unknown" ? { primary: "\u4F1A\u5458\u72B6\u6001\u5F85\u786E\u8BA4", meta: "\u70B9\u51FB\u91CD\u65B0\u540C\u6B65\u4F1A\u5458\u72B6\u6001" } : member.status === "error" ? { primary: "\u4F1A\u5458\u4FE1\u606F\u52A0\u8F7D\u5931\u8D25", meta: "\u70B9\u51FB\u91CD\u65B0\u52A0\u8F7D" } : { primary: "\u4F1A\u5458\u670D\u52A1\u6682\u4E0D\u53EF\u7528", meta: "\u53EF\u7A0D\u540E\u91CD\u8BD5" };
1032
+ const handleAction = () => {
1033
+ if (member.status === "active") onMemberPointsQuery?.();
1034
+ if (member.status === "not_enrolled" || member.status === "closed") onMemberEnrollmentQuery?.();
1035
+ if (member.status === "unauthenticated") onReauthorizeMember?.();
1036
+ if (member.status === "unknown" || member.status === "error" || member.status === "unavailable") onReloadMember?.();
1192
1037
  };
1193
- const reloginAndJudge = async (myFlight) => {
1194
- setState({ phase: "syncing" });
1195
- try {
1196
- await deps.retryBootstrap(true);
1197
- } catch {
1198
- log("relogin fail");
1199
- if (flightSeq !== myFlight) return;
1200
- setState({ phase: "failed", message: GATE_RELOGIN_FAILED });
1201
- return;
1038
+ return /* @__PURE__ */ jsx6(
1039
+ HomeServiceCard,
1040
+ {
1041
+ tone: "member",
1042
+ label: "\u4F1A\u5458\u79EF\u5206",
1043
+ iconSrc: memberServiceIcon,
1044
+ primary: copy.primary,
1045
+ meta: copy.meta,
1046
+ loading: member.status === "loading",
1047
+ loadingLabel: "\u4F1A\u5458\u4FE1\u606F\u52A0\u8F7D\u4E2D",
1048
+ disabled: member.status === "loading",
1049
+ onClick: handleAction
1202
1050
  }
1203
- log("relogin ok");
1204
- if (flightSeq !== myFlight) return;
1205
- const identitySource = deps.getAuthState()?.identity.source;
1206
- const identityOk = identitySource !== void 0 && identitySource !== "anonymous";
1207
- let upgraded;
1208
- if (state.card?.kind === "login") {
1209
- if (flightSeq !== myFlight) return;
1210
- upgraded = identityOk;
1211
- if (!upgraded) {
1212
- setState({ phase: "failed", message: GATE_RELOGIN_FAILED });
1213
- return;
1214
- }
1215
- } else {
1216
- const judgeMallId = deps.readMallId();
1217
- let panel;
1218
- try {
1219
- panel = await deps.loadPanel(judgeMallId);
1220
- } catch {
1221
- if (flightSeq !== myFlight) return;
1222
- log(`judge panel-throw mallId=${judgeMallId ?? "none"}`);
1223
- setState({ phase: "failed", message: GATE_PANEL_FAILED });
1224
- return;
1225
- }
1226
- if (flightSeq !== myFlight) return;
1227
- const panelStatus = panel.member.status;
1228
- log(`judge panel status=${panelStatus} mallId=${judgeMallId ?? "none"}`);
1229
- if (panelStatus === "unavailable" || panelStatus === "error" || panelStatus === "unknown" || panelStatus === "unauthenticated") {
1230
- setState({ phase: "failed", message: GATE_PANEL_FAILED });
1231
- return;
1232
- }
1233
- upgraded = identityOk && panelStatus === "active";
1234
- }
1235
- log(`judge ${upgraded ? "active" : "not-enrolled"}`);
1236
- if (upgraded) {
1237
- await settleUpgraded();
1238
- return;
1239
- }
1240
- if (state.sheetVisible) {
1241
- setState({ phase: "not-enrolled" });
1242
- return;
1243
- }
1244
- setState({ phase: "idle" });
1245
- hideContextCard();
1246
- deps.toast(GATE_NOT_ENROLLED_TOAST);
1247
- };
1248
- const runGate = async (myFlight) => {
1249
- setState({ phase: "opening" });
1250
- let receipt;
1251
- try {
1252
- receipt = await deps.getLoginState({ userId: deps.getAuthState()?.identity.userId });
1253
- } catch (error) {
1254
- if (error?.code === "BRIDGE_UNAVAILABLE") {
1255
- log("receipt unavailable");
1256
- const context = state.card;
1257
- if (context?.url) {
1258
- deps.sendUiAction(context.id, { type: "openLink", url: context.url });
1259
- deps.toast(GATE_UNAVAILABLE_TOAST);
1260
- setState({ phase: "idle" });
1261
- closeSheet();
1262
- hideContextCard();
1263
- } else {
1264
- setState({ phase: "failed", message: GATE_UNAVAILABLE_FALLBACK });
1265
- }
1266
- return;
1267
- }
1268
- setState({ phase: "failed", message: GATE_OPEN_FAILED });
1269
- return;
1270
- }
1271
- if (flightSeq !== myFlight) return;
1272
- log(`receipt loginStatus=${receipt.loginStatus}`);
1273
- if (receipt.loginStatus === "cancel") {
1274
- deps.toast(GATE_CANCEL_TOAST);
1275
- setState({ phase: "idle" });
1276
- closeSheet();
1277
- hideContextCard();
1278
- return;
1279
- }
1280
- if (receipt.loginStatus === "fail") {
1281
- const message = receipt.message ?? "\u767B\u5F55\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";
1282
- if (state.sheetVisible) setState({ phase: "failed", message });
1283
- else {
1284
- setState({ phase: "idle" });
1285
- hideContextCard();
1286
- deps.toast(message);
1287
- }
1288
- return;
1289
- }
1290
- await reloginAndJudge(myFlight);
1291
- };
1292
- const arm = (context, replayQuery) => {
1293
- if (inFlight()) return;
1294
- if (state.card?.id === context.id && state.sheetVisible) return;
1295
- log(`open source=${context.source ?? "card"}`);
1296
- const anchor = deps.lastUserMessage();
1297
- const query = replayQuery ?? anchor?.content;
1298
- pendingReplay = query === void 0 ? null : { query, anchorMessageId: anchor?.id ?? null };
1299
- setState({ phase: "idle", message: void 0, card: context, sheetVisible: true });
1300
- };
1301
- return {
1302
- getState: () => state,
1303
- subscribe(fn) {
1304
- listeners.add(fn);
1305
- return () => {
1306
- listeners.delete(fn);
1307
- };
1308
- },
1309
- trigger(card, replayQuery) {
1310
- arm(gateContextFromCard(card), replayQuery);
1311
- },
1312
- openGate(context, replayQuery) {
1313
- arm(context, replayQuery);
1314
- },
1315
- confirm() {
1316
- if (state.phase !== "idle" || deps.isGenerating()) return;
1317
- flightSeq += 1;
1318
- void runGate(flightSeq);
1319
- },
1320
- retry() {
1321
- if (deps.isGenerating()) return;
1322
- if (state.phase === "failed") {
1323
- flightSeq += 1;
1324
- void reloginAndJudge(flightSeq);
1325
- return;
1326
- }
1327
- if (state.phase === "not-enrolled") {
1328
- flightSeq += 1;
1329
- setState({ sheetVisible: true });
1330
- void runGate(flightSeq);
1331
- }
1332
- },
1333
- dismiss() {
1334
- closeSheet();
1335
- if (!inFlight()) hideContextCard();
1336
- }
1337
- };
1338
- }
1339
- function useMemberGate(gate) {
1340
- return useSyncExternalStore(gate.subscribe, gate.getState);
1341
- }
1342
-
1343
- // src/client/mock-direct-gate.ts
1344
- import { httpPost } from "@tbox.cn/app-agent-sdk-client";
1345
- var MOCK_DIRECT_ENROLL_PATHS = [
1346
- "/api/m/provider-mock/demo/member-enroll",
1347
- "/api/m/provider-mocktest/demo/member-enroll"
1348
- ];
1349
- var DIRECT_GATE_TIMEOUT_MS = 1e4;
1350
- function timeoutSignal() {
1351
- return typeof AbortSignal !== "undefined" && "timeout" in AbortSignal ? AbortSignal.timeout(DIRECT_GATE_TIMEOUT_MS) : void 0;
1352
- }
1353
- function mapDirectEnrollReceipt(status) {
1354
- if (status === 200) return { loginStatus: "success", message: "\u767B\u5F55\u6210\u529F" };
1355
- if (status === 401) return { loginStatus: "fail", message: "\u8BF7\u5148\u767B\u5F55" };
1356
- if (status === 404) return { loginStatus: "fail", message: "\u5F53\u524D\u73AF\u5883\u672A\u63D0\u4F9B\u5165\u4F1A\u670D\u52A1\uFF0C\u8BF7\u5728\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F\u5185\u6253\u5F00" };
1357
- return { loginStatus: "fail", message: "\u767B\u5F55\u72B6\u6001\u540C\u6B65\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5" };
1051
+ );
1358
1052
  }
1359
- async function directLoginGate() {
1360
- for (const path of MOCK_DIRECT_ENROLL_PATHS) {
1361
- try {
1362
- const { status } = await httpPost(path, void 0, { signal: timeoutSignal() });
1363
- if (status === 404) continue;
1364
- return mapDirectEnrollReceipt(status);
1365
- } catch {
1366
- return { loginStatus: "fail", message: "\u767B\u5F55\u72B6\u6001\u540C\u6B65\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5" };
1367
- }
1053
+ function openEnrollMiniProgram(enrollUrl) {
1054
+ if (!isInAlipayShell2()) return false;
1055
+ if (!enrollUrl) return false;
1056
+ try {
1057
+ const parsed = new URL(enrollUrl);
1058
+ const appId = parsed.searchParams.get("appId") ?? "";
1059
+ const path = parsed.searchParams.get("page") ?? void 0;
1060
+ const query = parsed.searchParams.get("query") ?? void 0;
1061
+ void callJsapi("navigateToMiniProgram", {
1062
+ appId,
1063
+ ...path ? { path } : {},
1064
+ ...query ? { query } : {}
1065
+ }).catch((err) => console.warn("[MallHome] navigateToMiniProgram failed", err));
1066
+ return true;
1067
+ } catch {
1068
+ console.warn("[MallHome] enrollUrl parse failed", enrollUrl);
1069
+ return false;
1368
1070
  }
1369
- return mapDirectEnrollReceipt(404);
1370
- }
1371
-
1372
- // src/client/home-slot.tsx
1373
- import "./home-slot-WBZ6ONDP.less";
1374
- import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1375
- var PARKING_FEE_QUERY = "\u67E5\u8BE2\u505C\u8F66\u8D39";
1376
- var PARKING_VEHICLE_QUERY = "\u6211\u7684\u8F66\u8F86";
1377
- var PARKING_SERVICE_QUERY = "\u505C\u8F66\u670D\u52A1";
1378
- var MEMBER_POINTS_QUERY = "\u67E5\u770B\u6211\u7684\u4F1A\u5458\u5361\u53CA\u79EF\u5206\u60C5\u51B5";
1379
- function renderHomeActivityDetail(card) {
1380
- return /* @__PURE__ */ jsx5(RawCardRenderer, { card });
1381
1071
  }
1382
- var gateLogger = createLogger("MEMBER-GATE");
1383
- function HomeSlotContent({ onSend, mallName }) {
1384
- const store = useChatStoreApi();
1385
- const messages = useChatStore((s) => s.messages);
1386
- const orphanCards = useChatStore((s) => s.orphanCards);
1387
- const cardsByMessageId = useChatStore((s) => s.cardsByMessageId);
1388
- const retryBootstrap = useChatStore((s) => s.retryBootstrap);
1389
- const isGenerating = useChatStore((s) => s.isGenerating);
1390
- const helloMallId = useChatStore((s) => s.helloAck?.mallScope?.mallId);
1391
- const mallId = pickMallId(helloMallId, readMallIdFromUrl());
1392
- const [linkedOrder, setLinkedOrder] = useState3({ status: "loading" });
1393
- const [linkedOrderReloadEpoch, setLinkedOrderReloadEpoch] = useState3(0);
1394
- const [member, setMember] = useState3({ status: "loading" });
1395
- const [parking, setParking] = useState3({ status: "loading" });
1396
- const [linkedPanelReloadEpoch, setLinkedPanelReloadEpoch] = useState3(0);
1397
- const [enrollUrl, setEnrollUrl] = useState3(null);
1398
- const [homeConfig, setHomeConfig] = useState3({ showDevServices: false });
1399
- const prevParkingBoundByCardRef = useRef4(/* @__PURE__ */ new Map());
1400
- const gateCard = useMemo2(
1401
- () => selectLatestMemberGateCard(messages.map((message) => message.id), cardsByMessageId, orphanCards),
1402
- [messages, cardsByMessageId, orphanCards]
1403
- );
1404
- const gate = useMemo2(
1405
- () => createMemberGate({
1406
- // 壳内走桥(容器 mock-enrollment/真实厂商 gate 页);非壳(扫码直开/浏览器)走 H5 直连 mock 入会
1407
- getLoginState: (params) => isInAlipayShell2() ? getLoginState(params) : directLoginGate(),
1408
- retryBootstrap: (refreshAuth) => store.getState().retryBootstrap(refreshAuth),
1409
- loadPanel: async (panelMallId) => {
1410
- const panel = await loadLinkedPanelState(getAuthClient(), panelMallId, fetch);
1411
- return { member: { status: panel.member.status } };
1412
- },
1413
- waitForSocketOpen,
1414
- getAuthState: () => getAuthClient().getAuthState(),
1415
- sendMessage: (input) => store.getState().sendMessage(input),
1416
- sendUiAction: (surfaceId, action) => store.getState().sendUiAction(surfaceId, action),
1417
- hideCard: (cardId) => store.getState().hideCard(cardId),
1418
- toast: (content) => {
1419
- void toast(content);
1420
- },
1421
- isGenerating: () => store.getState().isGenerating,
1422
- lastUserMessage: () => {
1423
- const live = store.getState().messages;
1424
- for (let i = live.length - 1; i >= 0; i -= 1) {
1425
- if (live[i]?.role === "user") return { id: live[i].id, content: live[i].content };
1072
+ var AREA_TONE_CLASS = Object.freeze({
1073
+ guide: Object.freeze({ icon: "bg-[#edf6ff] text-[#1679df]", focus: "focus-visible:outline-[#1679df]" }),
1074
+ member: Object.freeze({ icon: "bg-[#fff7e7] text-[#bd7200]", focus: "focus-visible:outline-[#bd7200]" }),
1075
+ marketing: Object.freeze({ icon: "bg-[#fff1ef] text-[#db4e45]", focus: "focus-visible:outline-[#db4e45]" }),
1076
+ parking: Object.freeze({ icon: "bg-[#edf3fb] text-[#173e78]", focus: "focus-visible:outline-[#173e78]" })
1077
+ });
1078
+ var PROGRESS_MESSAGE_CLASS = "mall-home__progress-message flex h-full w-full items-center justify-center gap-2 rounded-[16px] bg-[rgba(244,252,255,0.94)] px-2.5 text-center text-xs font-bold leading-[1.2] text-[#0a6eb8]";
1079
+ var BUSINESS_AREAS = Object.freeze([
1080
+ Object.freeze({
1081
+ moduleId: "shopping-guide",
1082
+ title: "\u95E8\u5E97\u5BFC\u89C8",
1083
+ description: "\u627E\u95E8\u5E97\u3001\u770B\u697C\u5C42\u548C\u67E5\u5546\u573A\u653F\u7B56",
1084
+ tone: "guide",
1085
+ icon: Storefront,
1086
+ actions: Object.freeze([
1087
+ Object.freeze({ label: "\u901B\u4EC0\u4E48", description: "\u5148\u770B\u770B\u5546\u573A\u91CC\u6709\u4EC0\u4E48\u597D\u901B\u7684", query: "\u968F\u4FBF\u901B\u901B\uFF0C\u5546\u573A\u91CC\u6709\u4EC0\u4E48\u597D\u901B\u7684\uFF1F", icon: Buildings }),
1088
+ Object.freeze({ label: "\u627E\u95E8\u5E97", description: "\u67E5\u54C1\u724C\u95E8\u5E97\u7684\u4F4D\u7F6E", query: "adidas\u5E97\u5728\u54EA\u513F\uFF1F", icon: Storefront }),
1089
+ Object.freeze({ label: "\u8425\u4E1A\u65F6\u95F4", description: "\u67E5\u770B\u5546\u573A\u5F00\u95ED\u5E97\u65F6\u95F4", query: "\u5546\u573A\u51E0\u70B9\u5F00\u95E8\uFF1F", icon: Headset }),
1090
+ Object.freeze({ label: "\u9000\u6362\u8D27\u653F\u7B56", description: "\u4E86\u89E3\u9000\u6362\u8D27\u89C4\u5219", query: "\u5546\u573A\u9000\u6362\u8D27\u600E\u4E48\u89C4\u5B9A\uFF1F", icon: Headset }),
1091
+ // 多意图验证入口(2026-08-31):复合句并行调工具 + 多卡承接
1092
+ Object.freeze({ label: "\u95E8\u5E97+\u9886\u5238", description: "\u53CC\u57DF\u5E76\u884C\uFF1Ashop-list+\u5238\u5361", query: "\u63A8\u8350\u4E00\u4E0B\u9910\u996E\u95E8\u5E97\uFF0C\u987A\u4FBF\u770B\u770B\u6709\u4EC0\u4E48\u4F18\u60E0\u5238\u53EF\u4EE5\u9886", icon: Storefront }),
1093
+ Object.freeze({ label: "\u4E70\u8863+\u5496\u5561", description: "\u540C\u5DE5\u5177\u591A\u53C2\u5E76\u884C\uFF08\u540C\u578B\u6298\u53E0 1 \u5361\uFF09", query: "\u60F3\u7ED9\u5A03\u4E70\u8863\u670D\uFF0C\u518D\u627E\u5BB6\u5496\u5561\u5E97\u5750\u5750", icon: Buildings })
1094
+ ])
1095
+ }),
1096
+ Object.freeze({
1097
+ moduleId: "member",
1098
+ title: "\u4F1A\u5458\u670D\u52A1",
1099
+ description: "\u4F1A\u5458\u5361\u3001\u79EF\u5206\u548C\u4E13\u5C5E\u6743\u76CA",
1100
+ tone: "member",
1101
+ icon: IdentificationCard,
1102
+ actions: Object.freeze([
1103
+ Object.freeze({ label: "\u4F1A\u5458\u4E2D\u5FC3", description: "\u67E5\u770B\u4F1A\u5458\u5361\u548C\u4F1A\u5458\u670D\u52A1", query: "\u67E5\u770B\u6211\u7684\u4F1A\u5458\u5361", icon: IdentificationCard }),
1104
+ Object.freeze({ label: "\u67E5\u79EF\u5206", description: "\u4F59\u989D\u548C\u6700\u8FD1\u8BB0\u5F55", query: "\u67E5\u8BE2\u6211\u7684\u4F1A\u5458\u79EF\u5206\u4F59\u989D\u548C\u6700\u8FD1\u79EF\u5206\u8BB0\u5F55", icon: Coins }),
1105
+ Object.freeze({ label: "\u5F00\u5361\u5165\u4F1A", description: "\u5FEB\u901F\u52A0\u5165\u5546\u573A\u4F1A\u5458", query: "\u6211\u8981\u52A0\u5165\u5546\u573A\u4F1A\u5458\uFF0C\u8BF7\u5E2E\u6211\u5B8C\u6210\u5F00\u5361\u5165\u4F1A", icon: UserPlus, enroll: true }),
1106
+ // 未登录链路的联调入口:mock provider 恒返回已登录,走正常路径永远看不到登录卡。
1107
+ // 这里直说「还没登录」,让模型走 queryLoginCta 把登录引导卡带出来。
1108
+ Object.freeze({ label: "\u5F00\u5361\u5165\u4F1A\uFF08\u672A\u767B\u5F55\uFF09", description: "\u6A21\u62DF\u672A\u767B\u5F55\u65F6\u7684\u767B\u5F55\u5F15\u5BFC", query: "\u6211\u8FD8\u6CA1\u6709\u767B\u5F55\uFF0C\u8BF7\u7ED9\u6211\u767B\u5F55\u5165\u53E3", icon: SignIn }),
1109
+ Object.freeze({ label: "\u79EF\u5206+\u4F18\u60E0", description: "\u53CC\u57DF\u5E76\u884C\uFF1A\u4F1A\u5458\u5361+\u5238\u5361", query: "\u6211\u7684\u79EF\u5206\u8FD8\u6709\u591A\u5C11\uFF1F\u53EF\u4EE5\u7528\u79EF\u5206\u6362\u4EC0\u4E48\u4F18\u60E0", icon: Coins }),
1110
+ Object.freeze({ label: "\u653F\u7B56+\u79EF\u5206", description: "FAQ \u653F\u7B56 vs \u5B9E\u65F6\u6570\u5B57\uFF08\u8BED\u4E49\u533A\u5206\uFF09", query: "\u9000\u6362\u8D27\u653F\u7B56\u662F\u4EC0\u4E48\uFF1F\u6211\u73B0\u5728\u6709\u591A\u5C11\u79EF\u5206", icon: IdentificationCard })
1111
+ ])
1112
+ }),
1113
+ Object.freeze({
1114
+ moduleId: "promotion",
1115
+ title: "\u6D3B\u52A8\u4F18\u60E0",
1116
+ description: "\u9886\u5238\u3001\u6211\u7684\u5238\u548C\u4F18\u60E0\u6D3B\u52A8",
1117
+ tone: "marketing",
1118
+ icon: Gift,
1119
+ actions: Object.freeze([
1120
+ Object.freeze({ label: "\u9886\u5238", description: "\u770B\u770B\u6709\u4EC0\u4E48\u53EF\u9886\u4F18\u60E0", query: "\u6709\u4EC0\u4E48\u4F18\u60E0\u53EF\u4EE5\u9886\u53D6\uFF1F\u5E2E\u6211\u627E\u627E\u53EF\u9886\u7684\u4F18\u60E0\u5238", icon: Ticket }),
1121
+ Object.freeze({ label: "\u6211\u7684\u5238", description: "\u5361\u5305\u91CC\u7684\u5238\u548C\u5238\u7801", query: "\u67E5\u4E00\u4E0B\u6211\u7684\u4F18\u60E0\u5238", icon: Ticket }),
1122
+ Object.freeze({ label: "\u6D3B\u52A8", description: "\u8FD1\u671F\u6D3B\u52A8\u548C\u573A\u6B21\u5B89\u6392", query: "\u6700\u8FD1\u6709\u4EC0\u4E48\u8425\u9500\u6D3B\u52A8\uFF1F", icon: Sparkle }),
1123
+ Object.freeze({ label: "\u5238+\u78B0\u4E00\u78B0", description: "\u53CC\u57DF\u5E76\u884C\uFF1A\u5238\u5361+bumpin \u5361", query: "\u73B0\u5728\u6709\u4EC0\u4E48\u5238\u53EF\u9886\uFF1F\u78B0\u4E00\u78B0\u6D3B\u52A8\u8FDB\u5EA6\u600E\u4E48\u6837", icon: Ticket }),
1124
+ Object.freeze({ label: "\u6D3B\u52A8+\u9910\u5385", description: "\u53CC\u57DF\u5E76\u884C\uFF1Aactivity-list+shop-list", query: "\u770B\u770B\u6700\u8FD1\u6709\u4EC0\u4E48\u6D3B\u52A8\uFF0C\u987A\u4FBF\u63A8\u8350\u51E0\u5BB6 5F \u7684\u9910\u5385", icon: Gift })
1125
+ ])
1126
+ }),
1127
+ Object.freeze({
1128
+ moduleId: "parking",
1129
+ title: "\u505C\u8F66\u670D\u52A1",
1130
+ description: "\u7F34\u8D39\u3001\u5BFB\u8F66\u548C\u8F66\u8F86\u7BA1\u7406",
1131
+ tone: "parking",
1132
+ icon: Car,
1133
+ actions: Object.freeze([
1134
+ Object.freeze({ label: "\u505C\u8F66\u7F34\u8D39", description: "\u67E5\u8BE2\u8D39\u7528\u5E76\u652F\u4ED8", query: "\u5E2E\u6211\u67E5\u4E00\u4E0B\u505C\u8F66\u8D39", icon: Coins }),
1135
+ Object.freeze({ label: "\u8F66\u8F86\u7ED1\u5B9A", description: "\u7ED1\u5B9A\u6216\u7BA1\u7406\u8F66\u724C", query: "\u67E5\u770B\u6211\u7684\u7ED1\u5B9A\u8F66\u8F86", icon: Car }),
1136
+ Object.freeze({ label: "\u7F34\u8D39\u8BB0\u5F55", description: "\u5386\u53F2\u505C\u8F66\u8BA2\u5355", query: "\u67E5\u4E00\u4E0B\u6211\u7684\u505C\u8F66\u7F34\u8D39\u8BB0\u5F55", icon: BookOpen }),
1137
+ Object.freeze({ label: "\u505C\u8F66\u8D44\u8BAF", description: "\u4F59\u4F4D\u548C\u6536\u8D39\u89C4\u5219", query: "\u505C\u8F66\u573A\u8FD8\u6709\u7A7A\u4F4D\u5417\uFF1F\u6536\u8D39\u6807\u51C6\u662F\u4EC0\u4E48\uFF1F", icon: Buildings }),
1138
+ Object.freeze({ label: "\u505C\u8F66\u8D39+\u62B5\u6263", description: "\u53CC\u57DF\u5E76\u884C\uFF1A\u62A5\u4EF7\u5361+\u505C\u8F66\u6743\u76CA", query: "\u67E5\u4E0B\u505C\u8F66\u8D39\u8BE5\u4EA4\u591A\u5C11\uFF0C\u80FD\u7528\u8F66\u5185\u79EF\u5206\u62B5\u6263\u5417", icon: Coins }),
1139
+ Object.freeze({ label: "\u5BFB\u8F66+B1\u7F8E\u98DF", description: "\u53CC\u57DF\u5E76\u884C\uFF1AlocateVehicle+shop-list", query: "\u6211\u7684\u8F66\u505C\u54EA\u4E86\uFF1F\u987A\u4FBF\u63A8\u8350\u4E0B B1 \u7684\u7F8E\u98DF", icon: Car })
1140
+ ])
1141
+ })
1142
+ ]);
1143
+ function LinkedOrderStatus({
1144
+ linkedOrder,
1145
+ onReloadLinkedOrder,
1146
+ onReauthorizeLinkedOrder
1147
+ }) {
1148
+ if (linkedOrder.status === "loading") {
1149
+ return /* @__PURE__ */ jsx6("div", { className: PROGRESS_MESSAGE_CLASS, role: "status", children: "\u6B63\u5728\u540C\u6B65\u8054\u5355\u8FDB\u5EA6\u2026" });
1150
+ }
1151
+ if (linkedOrder.status === "unauthenticated") {
1152
+ return /* @__PURE__ */ jsxs5("div", { className: PROGRESS_MESSAGE_CLASS, children: [
1153
+ /* @__PURE__ */ jsx6("span", { children: "\u767B\u5F55\u652F\u4ED8\u5B9D\u540E\u67E5\u770B\u8054\u5355\u8FDB\u5EA6" }),
1154
+ /* @__PURE__ */ jsx6(
1155
+ "button",
1156
+ {
1157
+ className: "shrink-0 cursor-pointer rounded-[10px] border-0 bg-[#137dc4] px-2 py-[3px] text-xs leading-[1.2] text-white [font-family:inherit]",
1158
+ type: "button",
1159
+ onClick: () => onReauthorizeLinkedOrder?.(),
1160
+ children: "\u91CD\u65B0\u6388\u6743"
1426
1161
  }
1427
- return null;
1428
- },
1429
- readMallId: () => pickMallId(store.getState().helloAck?.mallScope?.mallId, readMallIdFromUrl()),
1430
- refreshPanel: () => setLinkedPanelReloadEpoch((epoch) => epoch + 1),
1431
- log: (message) => {
1432
- gateLogger.info(message);
1433
- }
1434
- }),
1435
- // eslint-disable-next-line react-hooks/exhaustive-deps
1436
- []
1437
- );
1438
- const gateState = useMemberGate(gate);
1439
- useEffect4(() => {
1440
- if (!gateCard) return;
1441
- const { phase, card } = gate.getState();
1442
- if (phase === "opening" || phase === "syncing") return;
1443
- if (card?.id === gateCard.id) return;
1444
- gate.trigger(gateCard, void 0);
1445
- }, [gateCard, gate, gateState.phase]);
1446
- useEffect4(() => {
1447
- const controller = new AbortController();
1448
- loadHomeConfig(getAuthClient(), fetch, controller.signal, () => retryBootstrap(false)).then((config) => {
1449
- if (!controller.signal.aborted) setHomeConfig(config);
1450
- }).catch((error) => {
1451
- if (!controller.signal.aborted && error.name !== "AbortError") {
1452
- setHomeConfig({ showDevServices: false });
1453
- }
1454
- });
1455
- return () => controller.abort();
1456
- }, [retryBootstrap]);
1457
- useEffect4(() => {
1458
- const controller = new AbortController();
1459
- setLinkedOrder({ status: "loading" });
1460
- loadLinkedOrderState(
1461
- getAuthClient(),
1462
- fetch,
1463
- controller.signal,
1464
- () => retryBootstrap(false)
1465
- ).then((state) => {
1466
- if (!controller.signal.aborted) setLinkedOrder(state);
1467
- }).catch((error) => {
1468
- if (!controller.signal.aborted && error.name !== "AbortError") {
1469
- setLinkedOrder({ status: "error" });
1470
- }
1471
- });
1472
- return () => controller.abort();
1473
- }, [linkedOrderReloadEpoch, retryBootstrap]);
1474
- const reloadLinkedOrder = useCallback3(() => {
1475
- setLinkedOrderReloadEpoch((epoch) => epoch + 1);
1476
- }, []);
1477
- const reauthorizeLinkedOrder = useCallback3(async () => {
1478
- setLinkedOrder({ status: "loading" });
1479
- await retryBootstrap();
1480
- setLinkedOrderReloadEpoch((epoch) => epoch + 1);
1481
- }, [retryBootstrap]);
1482
- useEffect4(() => {
1483
- if (!mallId) {
1484
- setMember((current) => current.status === "loading" ? current : { status: "loading" });
1485
- setParking((current) => current.status === "loading" ? current : { status: "loading" });
1486
- setEnrollUrl(null);
1487
- return void 0;
1488
- }
1489
- const controller = new AbortController();
1490
- setMember({ status: "loading" });
1491
- setParking({ status: "loading" });
1492
- loadLinkedPanelState(
1493
- getAuthClient(),
1494
- mallId,
1495
- fetch,
1496
- controller.signal,
1497
- () => retryBootstrap(false)
1498
- ).then((state) => {
1499
- if (!controller.signal.aborted) {
1500
- setMember(state.member);
1501
- setParking(state.parking);
1502
- setEnrollUrl(state.enrollUrl);
1503
- }
1504
- }).catch((error) => {
1505
- if (!controller.signal.aborted && error.name !== "AbortError") {
1506
- setMember({ status: "error" });
1507
- setParking({ status: "error" });
1508
- }
1509
- });
1510
- return () => controller.abort();
1511
- }, [mallId, linkedPanelReloadEpoch, retryBootstrap]);
1512
- useEffect4(() => {
1513
- const cards2 = [
1514
- ...orphanCards,
1515
- ...messages.flatMap((msg) => cardsByMessageId[msg.id] ?? [])
1516
- ];
1517
- const current = /* @__PURE__ */ new Map();
1518
- for (const card of cards2) {
1519
- if (card.cardType !== "parking-vehicle-management" || card.status !== "ready") continue;
1520
- const bound = card.data.bound;
1521
- if (Array.isArray(bound)) current.set(card.id, bound.length);
1522
- }
1523
- let changed = false;
1524
- for (const [id, count] of current) {
1525
- const prev = prevParkingBoundByCardRef.current.get(id);
1526
- if (prev !== void 0 && prev !== count) {
1527
- changed = true;
1528
- break;
1529
- }
1162
+ )
1163
+ ] });
1164
+ }
1165
+ if (linkedOrder.status === "forbidden") {
1166
+ return /* @__PURE__ */ jsx6("div", { className: PROGRESS_MESSAGE_CLASS, children: "\u5F53\u524D\u8D26\u53F7\u6682\u65F6\u65E0\u6CD5\u67E5\u770B\u8054\u5355\u8FDB\u5EA6" });
1167
+ }
1168
+ if (linkedOrder.status === "error") {
1169
+ return /* @__PURE__ */ jsxs5("div", { className: PROGRESS_MESSAGE_CLASS, role: "alert", children: [
1170
+ /* @__PURE__ */ jsx6("span", { children: "\u8054\u5355\u8FDB\u5EA6\u6682\u65F6\u65E0\u6CD5\u540C\u6B65" }),
1171
+ /* @__PURE__ */ jsx6(
1172
+ "button",
1173
+ {
1174
+ className: "shrink-0 cursor-pointer rounded-[10px] border-0 bg-[#137dc4] px-2 py-[3px] text-xs leading-[1.2] text-white [font-family:inherit]",
1175
+ type: "button",
1176
+ onClick: () => onReloadLinkedOrder?.(),
1177
+ children: "\u91CD\u65B0\u52A0\u8F7D"
1178
+ }
1179
+ )
1180
+ ] });
1181
+ }
1182
+ const progress = linkedOrder.status === "ready" ? deriveLinkedOrderProgress(linkedOrder.banner) : null;
1183
+ if (!progress) {
1184
+ return /* @__PURE__ */ jsx6("div", { className: PROGRESS_MESSAGE_CLASS, children: "\u5F53\u524D\u6682\u65E0\u53EF\u67E5\u770B\u7684\u8054\u5355\u6D3B\u52A8" });
1185
+ }
1186
+ const nodes = progress.target <= 10 ? Array.from({ length: progress.target }, (_, index) => index + 1) : [];
1187
+ const railFill = getLinkedOrderRailFill(progress.completed, progress.target);
1188
+ return /* @__PURE__ */ jsxs5(
1189
+ "div",
1190
+ {
1191
+ className: "mall-home__progress-content flex h-full w-full items-center justify-between",
1192
+ "aria-label": `\u8054\u5355\u652F\u4ED8\u8FDB\u5EA6 ${progress.completed} / ${progress.target} ${progress.unit}`,
1193
+ children: [
1194
+ /* @__PURE__ */ jsx6("strong", { className: "mall-home__progress-label shrink-0 text-xs font-extrabold leading-none whitespace-nowrap text-[#0a6eb8] [text-shadow:0_1px_0_rgba(255,255,255,0.72)]", children: "\u8054\u5355\u8FDB\u5EA6" }),
1195
+ /* @__PURE__ */ jsxs5(
1196
+ "div",
1197
+ {
1198
+ className: `mall-home__nodes relative mx-2.5 flex min-w-0 flex-1 justify-between ${nodes.length === 0 ? " mall-home__nodes--summary h-[22px] justify-center" : ""}`,
1199
+ "aria-hidden": "true",
1200
+ children: [
1201
+ /* @__PURE__ */ jsx6("span", { className: "mall-home__rail absolute top-1/2 right-2 left-2 h-[3px] -translate-y-1/2 rounded-[2px] bg-[rgba(22,126,194,0.3)]" }),
1202
+ /* @__PURE__ */ jsx6(
1203
+ "span",
1204
+ {
1205
+ className: "mall-home__rail-fill absolute top-1/2 left-2 z-[1] h-[3px] max-w-[calc(100%_-_16px)] -translate-y-1/2 rounded-[2px] bg-[#087dd0] shadow-[0_0_6px_rgba(0,104,190,0.34)]",
1206
+ style: { width: railFill }
1207
+ }
1208
+ ),
1209
+ nodes.length === 0 && /* @__PURE__ */ jsxs5("span", { className: "mall-home__nodes-summary relative z-[2] rounded-[9px] bg-[rgba(234,248,255,0.94)] px-[7px] py-0.5 text-xs font-bold leading-[1.2] text-[#0a6eb8]", children: [
1210
+ "\u5DF2\u5B8C\u6210 ",
1211
+ progress.completed,
1212
+ " ",
1213
+ progress.unit
1214
+ ] }),
1215
+ nodes.map((node) => {
1216
+ const completed = node <= progress.completed;
1217
+ const milestone = node === progress.target;
1218
+ return /* @__PURE__ */ jsx6(
1219
+ "span",
1220
+ {
1221
+ className: `mall-home__node relative z-[2] flex size-[22px] shrink-0 items-center justify-center rounded-full border-[1.5px] border-[#1682cb] bg-[#eaf8ff] text-xs font-extrabold leading-none text-[#0d6fae] shadow-[0_2px_5px_rgba(0,83,151,0.22)] ${completed ? " mall-home__node--completed border-white bg-[#91dcf2] text-[#0068e8]" : milestone ? " mall-home__node--milestone border-[#ffdc6a] bg-[#1475b6] text-white" : ""}`,
1222
+ children: completed ? /* @__PURE__ */ jsx6(Check, { size: 15, weight: "bold" }) : milestone ? /* @__PURE__ */ jsx6(LockSimple, { size: 13, weight: "bold" }) : /* @__PURE__ */ jsx6("span", { children: node })
1223
+ },
1224
+ node
1225
+ );
1226
+ })
1227
+ ]
1228
+ }
1229
+ ),
1230
+ /* @__PURE__ */ jsxs5("strong", { className: "mall-home__progress-value shrink-0 text-xs font-extrabold leading-none whitespace-nowrap text-[#0a6eb8] [text-shadow:0_1px_0_rgba(255,255,255,0.72)]", children: [
1231
+ progress.completed,
1232
+ "/",
1233
+ progress.target
1234
+ ] })
1235
+ ]
1530
1236
  }
1531
- prevParkingBoundByCardRef.current = current;
1532
- if (changed) setLinkedPanelReloadEpoch((epoch) => epoch + 1);
1533
- }, [orphanCards, messages, cardsByMessageId]);
1534
- const reloadParking = useCallback3(() => {
1535
- setLinkedPanelReloadEpoch((epoch) => epoch + 1);
1536
- }, []);
1537
- const reloadMember = useCallback3(() => {
1538
- setLinkedPanelReloadEpoch((epoch) => epoch + 1);
1539
- }, []);
1540
- const reauthorizeLinkedPanel = useCallback3(async () => {
1541
- setMember({ status: "loading" });
1542
- setParking({ status: "loading" });
1543
- await retryBootstrap();
1544
- setLinkedPanelReloadEpoch((epoch) => epoch + 1);
1545
- }, [retryBootstrap]);
1546
- const queryMemberPoints = useCallback3(() => {
1547
- onSend(MEMBER_POINTS_QUERY);
1548
- }, [onSend]);
1549
- const openMemberEnrollment = useCallback3(() => {
1550
- gate.openGate(
1551
- {
1552
- id: "home-gate-member",
1553
- kind: "enroll",
1554
- synthetic: true,
1555
- source: "home-member",
1556
- ...enrollUrl ? { url: enrollUrl } : {},
1557
- title: "\u5165\u4F1A\u540E\u7EE7\u7EED"
1558
- },
1559
- MEMBER_POINTS_QUERY
1560
- );
1561
- }, [gate, enrollUrl]);
1562
- const queryParkingFee = useCallback3((plateNos) => {
1563
- if (plateNos && plateNos.length > 0) {
1564
- const plateList = plateNos.join("\u3001");
1565
- onSend(`\u67E5\u8BE2${plateList}\u7684\u505C\u8F66\u8D39`);
1566
- } else {
1567
- onSend(PARKING_FEE_QUERY);
1237
+ );
1238
+ }
1239
+ function ParkingServiceCard({
1240
+ parking,
1241
+ onParkingFeeQuery,
1242
+ onParkingVehicleQuery,
1243
+ onParkingMembershipQuery,
1244
+ onParkingServiceQuery,
1245
+ onReloadParking,
1246
+ onReauthorizeParking
1247
+ }) {
1248
+ const formatPlate = (plate) => `${plate.slice(0, 2)}\xB7${plate.slice(2)}`;
1249
+ const formatParkedTime = (minutes) => {
1250
+ const hours = Math.floor(minutes / 60);
1251
+ const remainingMinutes = minutes % 60;
1252
+ return [
1253
+ hours > 0 ? `${hours} \u65F6` : "",
1254
+ remainingMinutes > 0 ? `${remainingMinutes} \u5206` : ""
1255
+ ].filter(Boolean).join(" ") || "0 \u5206";
1256
+ };
1257
+ const formatFreeTime = (minutes) => {
1258
+ const hours = Math.floor(minutes / 60);
1259
+ const remainingMinutes = minutes % 60;
1260
+ return [
1261
+ hours > 0 ? `${hours} \u5C0F\u65F6` : "",
1262
+ remainingMinutes > 0 ? `${remainingMinutes} \u5206` : ""
1263
+ ].filter(Boolean).join(" ");
1264
+ };
1265
+ const parkedIn = parking.status === "ready" && parking.freeMinutesRemaining !== void 0;
1266
+ const parkedCount = parking.status === "ready" ? parking.parkedPlates?.length ?? 0 : 0;
1267
+ const copy = parking.status === "ready" ? parkedIn ? parkedCount >= 2 ? {
1268
+ eyebrow: "\u505C\u8F66\u670D\u52A1",
1269
+ primary: `${parkedCount} \u8F86\u8F66\u5165\u573A`,
1270
+ meta: "\u70B9\u51FB\u67E5\u8BE2\u505C\u8F66\u8D39"
1271
+ } : {
1272
+ eyebrow: "\u505C\u8F66\u670D\u52A1",
1273
+ primary: formatPlate(parking.primaryPlate),
1274
+ meta: parking.freeMinutesRemaining ? `\u514D\u8D39\u65F6\u95F4\u5269\u4F59 ${formatFreeTime(parking.freeMinutesRemaining)}` : parking.parkedMinutes ? `\u5DF2\u505C ${formatParkedTime(parking.parkedMinutes)}\uFF0C\u67E5\u8BE2\u8D39\u7528` : "\u70B9\u51FB\u67E5\u8BE2\u505C\u8F66\u8D39"
1275
+ } : { eyebrow: "\u505C\u8F66\u670D\u52A1", primary: "\u8F66\u8F86\u672A\u5165\u573A", meta: "\u70B9\u51FB\u7BA1\u7406\u8F66\u8F86" } : parking.status === "empty" ? { eyebrow: "\u505C\u8F66\u670D\u52A1", primary: "\u70B9\u51FB\u6DFB\u52A0\u8F66\u8F86", meta: "\u6DFB\u52A0\u8F66\u8F86\u540E\u53EF\u67E5\u8BE2\u6216\u7F34\u8D39" } : parking.status === "loading" ? { eyebrow: "\u505C\u8F66\u670D\u52A1", primary: "", meta: "" } : parking.status === "unauthenticated" ? { eyebrow: "\u505C\u8F66\u670D\u52A1", primary: "\u767B\u5F55\u540E\u67E5\u770B\u8F66\u8F86", meta: "\u6388\u6743\u540E\u53EF\u67E5\u8BE2\u505C\u8F66\u8D39\u7528" } : parking.status === "membership_required" ? { eyebrow: "\u505C\u8F66\u670D\u52A1", primary: "\u5165\u4F1A\u540E\u67E5\u770B\u8F66\u8F86", meta: "\u5165\u4F1A\u540E\u53EF\u4EAB\u53D7\u79EF\u5206\u505C\u8F66" } : parking.status === "error" ? { eyebrow: "\u505C\u8F66\u670D\u52A1", primary: "\u505C\u8F66\u4FE1\u606F\u52A0\u8F7D\u5931\u8D25", meta: "\u8BF7\u7A0D\u540E\u91CD\u8BD5" } : { eyebrow: "\u505C\u8F66\u670D\u52A1", primary: "\u505C\u8F66\u670D\u52A1\u6682\u4E0D\u53EF\u7528", meta: "\u8BF7\u7A0D\u540E\u91CD\u8BD5" };
1276
+ const handleAction = () => {
1277
+ if (parking.status === "ready") (parkedIn ? () => onParkingFeeQuery?.(parking.parkedPlates) : onParkingVehicleQuery)?.();
1278
+ if (parking.status === "empty") onParkingVehicleQuery?.();
1279
+ if (parking.status === "unauthenticated") onReauthorizeParking?.();
1280
+ if (parking.status === "membership_required") onParkingMembershipQuery?.();
1281
+ if (parking.status === "error") onReloadParking?.();
1282
+ if (parking.status === "unavailable") onParkingServiceQuery?.();
1283
+ };
1284
+ return /* @__PURE__ */ jsx6(
1285
+ HomeServiceCard,
1286
+ {
1287
+ tone: "parking",
1288
+ label: copy.eyebrow,
1289
+ iconSrc: parkingServiceIcon,
1290
+ primary: copy.primary,
1291
+ primaryMonospace: parkedIn,
1292
+ meta: copy.meta,
1293
+ loading: parking.status === "loading",
1294
+ loadingLabel: "\u8F66\u8F86\u4FE1\u606F\u52A0\u8F7D\u4E2D",
1295
+ disabled: parking.status === "loading",
1296
+ onClick: handleAction
1568
1297
  }
1569
- }, [onSend]);
1570
- const queryParkingVehicles = useCallback3(() => {
1571
- onSend(PARKING_VEHICLE_QUERY);
1572
- }, [onSend]);
1573
- const openParkingMembership = useCallback3(() => {
1574
- gate.openGate(
1575
- {
1576
- id: "home-gate-parking",
1577
- kind: "enroll",
1578
- synthetic: true,
1579
- source: "home-parking",
1580
- ...enrollUrl ? { url: enrollUrl } : {},
1581
- title: "\u5165\u4F1A\u540E\u7EE7\u7EED"
1582
- },
1583
- PARKING_VEHICLE_QUERY
1584
- );
1585
- }, [gate, enrollUrl]);
1586
- const queryParkingService = useCallback3(() => {
1587
- onSend(PARKING_SERVICE_QUERY);
1588
- }, [onSend]);
1589
- const dismissGate = useCallback3(() => {
1590
- gate.dismiss();
1591
- }, [gate]);
1592
- const confirmGate = useCallback3(() => {
1593
- gate.confirm();
1594
- }, [gate]);
1595
- const retryGate = useCallback3(() => {
1596
- gate.retry();
1597
- }, [gate]);
1598
- return /* @__PURE__ */ jsxs5(Fragment2, { children: [
1599
- /* @__PURE__ */ jsx5(
1600
- MallHome,
1298
+ );
1299
+ }
1300
+ function MallHome({
1301
+ mallName,
1302
+ linkedOrder,
1303
+ member,
1304
+ parking,
1305
+ enrollUrl,
1306
+ showDevServices,
1307
+ onSend,
1308
+ renderActivityDetail,
1309
+ onReloadLinkedOrder,
1310
+ onReauthorizeLinkedOrder,
1311
+ onParkingFeeQuery,
1312
+ onParkingVehicleQuery,
1313
+ onParkingMembershipQuery,
1314
+ onParkingServiceQuery,
1315
+ onReloadParking,
1316
+ onReauthorizeParking,
1317
+ onMemberPointsQuery,
1318
+ onMemberEnrollmentQuery,
1319
+ onReloadMember,
1320
+ onReauthorizeMember
1321
+ }) {
1322
+ const displayMallName = mallName || "\u5546\u573A";
1323
+ const activityTriggerRef = useRef4(null);
1324
+ const activityCard = linkedOrder.status === "ready" ? linkedOrder.detailCard : void 0;
1325
+ const canOpenActivity = Boolean(activityCard && renderActivityDetail);
1326
+ const [activityDetail, setActivityDetail] = useState4(null);
1327
+ const closeActivityDetail = useCallback3(() => setActivityDetail(null), []);
1328
+ const linkedOrderVisual = /* @__PURE__ */ jsxs5(Fragment2, { children: [
1329
+ /* @__PURE__ */ jsx6(
1330
+ "span",
1601
1331
  {
1602
- mallName,
1603
- linkedOrder,
1604
- member,
1605
- parking,
1606
- enrollUrl,
1607
- showDevServices: homeConfig.showDevServices,
1608
- onSend,
1609
- renderActivityDetail: renderHomeActivityDetail,
1610
- onReloadLinkedOrder: reloadLinkedOrder,
1611
- onReauthorizeLinkedOrder: () => void reauthorizeLinkedOrder(),
1612
- onParkingFeeQuery: queryParkingFee,
1613
- onParkingVehicleQuery: queryParkingVehicles,
1614
- onParkingMembershipQuery: openParkingMembership,
1615
- onParkingServiceQuery: queryParkingService,
1616
- onReloadParking: reloadParking,
1617
- onReauthorizeParking: () => void reauthorizeLinkedPanel(),
1618
- onMemberPointsQuery: queryMemberPoints,
1619
- onMemberEnrollmentQuery: openMemberEnrollment,
1620
- onReloadMember: reloadMember,
1621
- onReauthorizeMember: () => void reauthorizeLinkedPanel()
1332
+ className: "mall-home__linked-order-poster absolute top-0 left-1/2 block h-full w-full -translate-x-1/2 bg-cover bg-center bg-[image:var(--tbox-asset-home-poster-stage,linear-gradient(135deg,#eaf3ff,#d7e7fd))] max-[392px]:bg-[image:var(--tbox-asset-home-poster-compact,linear-gradient(135deg,#eaf3ff,#d7e7fd))]",
1333
+ ...canOpenActivity ? { "aria-hidden": true } : { role: "img", "aria-label": "\u53C2\u4E0E\u8054\u5355\uFF0C\u78B0\u51FA\u60CA\u559C" }
1622
1334
  }
1623
1335
  ),
1624
- gateState.sheetVisible && gateState.card && /* @__PURE__ */ jsx5(
1625
- MemberGateSheet,
1336
+ /* @__PURE__ */ jsx6("div", { className: "mall-home__progress absolute bottom-[18px] left-1/2 z-[2] h-8 w-[300px] -translate-x-1/2 max-[392px]:bottom-[7%] max-[392px]:h-[13.33%] max-[392px]:w-[85%]", children: /* @__PURE__ */ jsx6(
1337
+ LinkedOrderStatus,
1626
1338
  {
1627
- context: gateState.card,
1628
- phase: gateState.phase,
1629
- message: gateState.message,
1630
- busy: isGenerating,
1631
- onConfirm: confirmGate,
1632
- onRetry: retryGate,
1633
- onDismiss: dismissGate
1339
+ linkedOrder,
1340
+ onReloadLinkedOrder,
1341
+ onReauthorizeLinkedOrder
1634
1342
  }
1635
- )
1343
+ ) })
1636
1344
  ] });
1637
- }
1638
- var homeSlotValue = ({ onSend, mallName }) => /* @__PURE__ */ jsx5(HomeSlotContent, { onSend, mallName });
1639
-
1640
- // src/client/cards/overrides/BumpInActivityChatCard.tsx
1641
- import { useCallback as useCallback4, useRef as useRef5, useState as useState4 } from "react";
1642
- import { CaretRight as CaretRight2 } from "@phosphor-icons/react";
1643
- import { useChatRawCards } from "@tbox.cn/app-agent-ui-kit";
1644
- import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1645
- var BUMPIN_CARD_TYPE = "promotion-bumpin-activity";
1646
- var BumpInActivityChatCard = (props) => {
1647
- const triggerRef = useRef5(null);
1648
- const [detailOrigin, setDetailOrigin] = useState4(null);
1649
- const rawCards = useChatRawCards();
1650
- const Base = rawCards[BUMPIN_CARD_TYPE];
1651
- const { data, cardId, isHistory, actionTokens } = props;
1652
- const closeDetail = useCallback4(() => setDetailOrigin(null), []);
1653
- if (!Base) return null;
1654
- const mode = data && typeof data === "object" && !Array.isArray(data) ? data["mode"] : void 0;
1655
- if (mode !== "detail") {
1656
- return /* @__PURE__ */ jsx6(Base, { data, cardId, isHistory, actionTokens });
1657
- }
1658
- const detailData = data;
1659
- const inlineData = { ...detailData };
1660
- delete inlineData["description"];
1661
- delete inlineData["tagLabel"];
1662
- if (Array.isArray(detailData["vouchers"])) inlineData["vouchers"] = [];
1663
- const openDetail = () => {
1664
- const trigger = triggerRef.current;
1665
- if (!trigger || detailOrigin) return;
1345
+ useEffect4(() => {
1346
+ if (activityDetail && (activityCard !== activityDetail.card || renderActivityDetail !== activityDetail.renderDetail)) setActivityDetail(null);
1347
+ }, [activityCard, activityDetail, renderActivityDetail]);
1348
+ const openActivityDetail = useCallback3(() => {
1349
+ const trigger = activityTriggerRef.current;
1350
+ if (!trigger || !activityCard || !renderActivityDetail || activityDetail) return;
1666
1351
  const rect = trigger.getBoundingClientRect();
1667
- setDetailOrigin({ top: rect.top, left: rect.left, width: rect.width, height: rect.height });
1668
- };
1669
- return /* @__PURE__ */ jsxs6(Fragment3, { children: [
1670
- /* @__PURE__ */ jsxs6(ActivityDetailPresentation, { variant: "inline", children: [
1671
- /* @__PURE__ */ jsx6(Base, { data: inlineData, cardId, isHistory, actionTokens }),
1672
- /* @__PURE__ */ jsxs6(
1673
- "button",
1352
+ setActivityDetail({
1353
+ card: activityCard,
1354
+ renderDetail: renderActivityDetail,
1355
+ transitionVisual: /* @__PURE__ */ jsx6("section", { className: "mall-home__linked-order relative mx-page h-60 overflow-hidden rounded-[14px] bg-[#fff8e9] leading-[0] shadow-[0_10px_24px_rgba(47,88,121,0.1)] max-[392px]:aspect-[353/240] max-[392px]:h-auto", "aria-hidden": "true", children: linkedOrderVisual }),
1356
+ origin: { top: rect.top, left: rect.left, width: rect.width, height: rect.height }
1357
+ });
1358
+ }, [activityCard, activityDetail, linkedOrderVisual, renderActivityDetail]);
1359
+ return /* @__PURE__ */ jsxs5("main", { className: "mall-home @container/mall-home w-full pt-2 pb-8.5 text-foreground", "aria-label": "\u5546\u573A\u667A\u80FD\u670D\u52A1\u9996\u9875", children: [
1360
+ /* @__PURE__ */ jsxs5("header", { className: "mall-home__welcome px-page pb-5.5 pt-1", children: [
1361
+ /* @__PURE__ */ jsx6(
1362
+ "img",
1674
1363
  {
1675
- ref: triggerRef,
1676
- type: "button",
1677
- className: "activity-detail-presentation__detail-trigger",
1678
- "aria-haspopup": "dialog",
1679
- "aria-expanded": detailOrigin !== null,
1680
- "aria-controls": getHomeActivityDialogId(cardId),
1681
- onClick: openDetail,
1682
- children: [
1683
- /* @__PURE__ */ jsx6("span", { children: "\u67E5\u770B\u6D3B\u52A8\u8BE6\u60C5" }),
1684
- /* @__PURE__ */ jsx6(CaretRight2, { size: 17, "aria-hidden": "true" })
1685
- ]
1364
+ className: "mall-home__welcome-sparkle block h-[25.5px] w-9 object-contain",
1365
+ src: welcomeSparkle,
1366
+ alt: "",
1367
+ "aria-hidden": "true"
1686
1368
  }
1687
- )
1369
+ ),
1370
+ /* @__PURE__ */ jsxs5("h1", { className: "mt-1 text-xl font-bold leading-7 tracking-tight text-foreground", children: [
1371
+ "\u6B22\u8FCE\u6765\u5230",
1372
+ displayMallName
1373
+ ] }),
1374
+ /* @__PURE__ */ jsx6("p", { className: "mt-1 text-xs leading-4.75 text-secondary-foreground", children: "\u6211\u53EF\u4EE5\u5E2E\u4F60\u770B\u8054\u5355\u8FDB\u5EA6\u3001\u67E5\u505C\u8F66\u3001\u770B\u4F1A\u5458\u4E0E\u6D3B\u52A8\u670D\u52A1" })
1688
1375
  ] }),
1689
- detailOrigin && /* @__PURE__ */ jsx6(
1376
+ /* @__PURE__ */ jsxs5(
1377
+ "section",
1378
+ {
1379
+ className: "mall-home__linked-order relative mx-page h-60 overflow-hidden rounded-[14px] bg-[#fff8e9] leading-[0] shadow-[0_10px_24px_rgba(47,88,121,0.1)] max-[392px]:aspect-[353/240] max-[392px]:h-auto",
1380
+ "aria-label": "\u78B0\u4E00\u4E0B\u8054\u5355\u6D3B\u52A8",
1381
+ children: [
1382
+ linkedOrderVisual,
1383
+ canOpenActivity && activityCard && /* @__PURE__ */ jsx6(
1384
+ "button",
1385
+ {
1386
+ ref: activityTriggerRef,
1387
+ type: "button",
1388
+ className: "mall-home__linked-order-trigger absolute inset-0 z-[3] h-full w-full cursor-pointer rounded-[inherit] border-0 bg-transparent p-0 outline-none focus-visible:shadow-[inset_0_0_0_3px_rgba(82,126,56,0.5)]",
1389
+ "aria-label": `\u67E5\u770B${linkedOrder.status === "ready" ? linkedOrder.banner.title || "\u8054\u5355\u6D3B\u52A8" : "\u8054\u5355\u6D3B\u52A8"}\u8BE6\u60C5`,
1390
+ "aria-haspopup": "dialog",
1391
+ "aria-expanded": Boolean(activityDetail),
1392
+ "aria-controls": getHomeActivityDialogId(activityDetail?.card.id ?? activityCard.id),
1393
+ onClick: openActivityDetail
1394
+ }
1395
+ )
1396
+ ]
1397
+ }
1398
+ ),
1399
+ activityDetail && /* @__PURE__ */ jsx6(
1690
1400
  HomeActivityDetailDialog,
1691
1401
  {
1692
- card: { id: cardId, data: detailData },
1693
- origin: detailOrigin,
1694
- triggerRef,
1695
- motion: "fade",
1696
- onClosed: closeDetail,
1697
- children: /* @__PURE__ */ jsx6(Base, { data: detailData, cardId, isHistory, actionTokens })
1402
+ card: activityDetail.card,
1403
+ origin: activityDetail.origin,
1404
+ triggerRef: activityTriggerRef,
1405
+ transitionVisual: activityDetail.transitionVisual,
1406
+ onClosed: closeActivityDetail,
1407
+ children: activityDetail.renderDetail(activityDetail.card)
1698
1408
  }
1699
- )
1409
+ ),
1410
+ /* @__PURE__ */ jsxs5("div", { className: "mall-home__service-pair mx-page mt-4 grid grid-cols-2 items-stretch gap-3", children: [
1411
+ /* @__PURE__ */ jsx6(
1412
+ MemberServiceCard,
1413
+ {
1414
+ member,
1415
+ onMemberPointsQuery,
1416
+ onMemberEnrollmentQuery,
1417
+ onReloadMember,
1418
+ onReauthorizeMember
1419
+ }
1420
+ ),
1421
+ /* @__PURE__ */ jsx6(
1422
+ ParkingServiceCard,
1423
+ {
1424
+ parking,
1425
+ onParkingFeeQuery,
1426
+ onParkingVehicleQuery,
1427
+ onParkingMembershipQuery,
1428
+ onParkingServiceQuery,
1429
+ onReloadParking,
1430
+ onReauthorizeParking
1431
+ }
1432
+ )
1433
+ ] }),
1434
+ showDevServices && /* @__PURE__ */ jsxs5("section", { className: "mall-home__services mx-page mt-5.5", "aria-labelledby": "mall-home-services-title", children: [
1435
+ /* @__PURE__ */ jsx6("header", { className: "mall-home__section-header mb-3 flex items-end justify-between gap-2", children: /* @__PURE__ */ jsxs5("div", { children: [
1436
+ /* @__PURE__ */ jsx6("h2", { id: "mall-home-services-title", className: "text-lg font-bold leading-6 text-foreground", children: "\u5E38\u7528\u670D\u52A1" }),
1437
+ /* @__PURE__ */ jsx6("span", { className: "mall-home__section-kicker mt-0.5 block text-xs leading-4 text-secondary-foreground", children: "\u4EE5\u4E0B\u90E8\u5206\u4E3A\u5F00\u53D1\u6D4B\u8BD5\u5165\u53E3\uFF0C\u4E0D\u5BF9\u6B63\u5F0F\u7528\u6237\u900F\u51FA" })
1438
+ ] }) }),
1439
+ /* @__PURE__ */ jsx6("div", { className: "mall-home__areas grid grid-cols-1 gap-3 @min-[820px]/mall-home:grid-cols-2", children: BUSINESS_AREAS.map((area) => {
1440
+ const AreaIcon = area.icon;
1441
+ return /* @__PURE__ */ jsxs5(
1442
+ "section",
1443
+ {
1444
+ className: `mall-home__area mall-home__area--${area.tone} min-w-0 rounded-[16px] border-[0.5px] border-border bg-card p-3 shadow-[0_2px_16px_rgba(106,119,137,0.08)]`,
1445
+ "aria-labelledby": `mall-home-${area.moduleId}`,
1446
+ children: [
1447
+ /* @__PURE__ */ jsxs5("header", { className: "mall-home__area-header mb-3 flex items-center justify-between gap-2", children: [
1448
+ /* @__PURE__ */ jsxs5("span", { className: "mall-home__area-copy min-w-0", children: [
1449
+ /* @__PURE__ */ jsx6("h3", { id: `mall-home-${area.moduleId}`, className: "text-sm font-semibold leading-5 text-foreground", children: area.title }),
1450
+ /* @__PURE__ */ jsx6("p", { className: "text-xs leading-[17px] text-secondary-foreground", children: area.description })
1451
+ ] }),
1452
+ /* @__PURE__ */ jsx6(
1453
+ "span",
1454
+ {
1455
+ className: `mall-home__area-icon flex size-8 shrink-0 items-center justify-center rounded-[10px] ${AREA_TONE_CLASS[area.tone].icon}`,
1456
+ "aria-hidden": "true",
1457
+ children: /* @__PURE__ */ jsx6(AreaIcon, { size: 22, weight: "regular" })
1458
+ }
1459
+ )
1460
+ ] }),
1461
+ /* @__PURE__ */ jsx6("div", { className: "mall-home__action-grid grid grid-cols-[repeat(auto-fit,minmax(min(150px,100%),1fr))] gap-2", children: area.actions.map((action) => {
1462
+ return /* @__PURE__ */ jsxs5(
1463
+ "button",
1464
+ {
1465
+ className: `mall-home__action grid min-h-[72px] w-full min-w-0 cursor-pointer grid-cols-[minmax(0,1fr)_12px] items-center gap-2 rounded-[14px] border-[0.5px] border-border bg-card p-2.5 text-left text-foreground shadow-[0_2px_12px_rgba(106,119,137,0.05)] [font-family:inherit] active:scale-[0.99] active:bg-[rgba(11,15,23,0.02)] focus-visible:outline-2 focus-visible:outline-offset-2 ${AREA_TONE_CLASS[area.tone].focus}`,
1466
+ type: "button",
1467
+ onClick: () => {
1468
+ if (action.enroll && openEnrollMiniProgram(enrollUrl)) return;
1469
+ onSend(action.query);
1470
+ },
1471
+ children: [
1472
+ /* @__PURE__ */ jsxs5("span", { className: "mall-home__action-copy min-w-0", children: [
1473
+ /* @__PURE__ */ jsx6("strong", { className: "block text-sm font-semibold leading-[18px] [overflow-wrap:anywhere]", children: action.label }),
1474
+ /* @__PURE__ */ jsx6("small", { className: "mt-[3px] block text-xs leading-4 text-secondary-foreground [overflow-wrap:anywhere]", children: action.description })
1475
+ ] }),
1476
+ /* @__PURE__ */ jsx6(CaretRight2, { className: "shrink-0 text-secondary-foreground", size: 14, weight: "bold", "aria-hidden": "true" })
1477
+ ]
1478
+ },
1479
+ action.label
1480
+ );
1481
+ }) })
1482
+ ]
1483
+ },
1484
+ area.moduleId
1485
+ );
1486
+ }) })
1487
+ ] })
1700
1488
  ] });
1701
- };
1489
+ }
1702
1490
 
1703
1491
  // src/client/cards/mall-home/index.tsx
1704
1492
  import { jsx as jsx7 } from "react/jsx-runtime";
@@ -1726,7 +1514,7 @@ var cards = {
1726
1514
  var clientModule = {
1727
1515
  cards,
1728
1516
  register(ctx) {
1729
- ctx.slots.register("home", homeSlotValue);
1517
+ ctx.slots.register("conversationOverlay", () => createElement(MemberGateOverlay));
1730
1518
  ctx.cards.registerMap(cards);
1731
1519
  ctx.cards.registerOverride("promotion-bumpin-activity", BumpInActivityChatCard);
1732
1520
  ctx.cards.registerInlineFilter(filterInlineCards);