@tbox.cn/app-module-shopping-guide 0.2.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/AGENTS.md +16 -0
  2. package/README.md +96 -0
  3. package/dist/chunk-AYQZO2FV.js +1496 -0
  4. package/dist/chunk-QDTU2FRN.js +1682 -0
  5. package/dist/client/index.d.ts +3 -3
  6. package/dist/client/index.js +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +2 -8
  9. package/dist/server/index.d.ts +2512 -608
  10. package/dist/server/index.js +1 -7
  11. package/dist/shop-guide-header-art-pea-v2-OME4MKBW.jpg +0 -0
  12. package/dist/shopping-guide-OQ2SSHXL.css +2593 -0
  13. package/package.json +25 -16
  14. package/skills/shopping-guide/SKILL.md +127 -24
  15. package/src/client/assets/shop-guide-header-art-pea-v2.jpg +0 -0
  16. package/src/client/assets/shop-guide-header-art.png +0 -0
  17. package/src/client/assets.d.ts +10 -0
  18. package/src/client/cards/category-list/index.tsx +113 -0
  19. package/src/client/cards/human-guide-list/index.tsx +72 -0
  20. package/src/client/cards/index.ts +14 -0
  21. package/src/client/cards/location-handoff/index.tsx +52 -0
  22. package/src/client/cards/mall-directory/index.tsx +77 -0
  23. package/src/client/cards/nearby-mall-list/index.tsx +40 -0
  24. package/src/client/cards/product-comparison/index.tsx +100 -0
  25. package/src/client/cards/product-detail/index.tsx +97 -0
  26. package/src/client/cards/product-list/index.tsx +223 -0
  27. package/src/client/cards/recommend-merchants/index.tsx +147 -0
  28. package/src/client/cards/shop-detail/index.tsx +133 -0
  29. package/src/client/cards/shop-list/index.tsx +216 -0
  30. package/src/client/cards/view.ts +147 -0
  31. package/src/client/categories.ts +38 -0
  32. package/src/client/components/ImageWithFallback.tsx +34 -0
  33. package/src/client/components/MerchantRow.tsx +78 -0
  34. package/src/client/components/ShopDetailSheet.tsx +383 -0
  35. package/src/client/components/ShopGuideHeader.tsx +24 -0
  36. package/src/client/components/ShopGuideSectionLabel.tsx +10 -0
  37. package/src/client/components/ShopListSheet.tsx +293 -0
  38. package/src/client/index.ts +8 -6
  39. package/src/client/styles/shopping-guide.css +2593 -0
  40. package/src/client/types/css.d.ts +2 -0
  41. package/src/server/cards/category-list/meta.ts +0 -2
  42. package/src/server/cards/human-guide-list/meta.ts +0 -2
  43. package/src/server/cards/index.ts +10 -10
  44. package/src/server/cards/location-handoff/meta.ts +0 -2
  45. package/src/server/cards/mall-directory/meta.ts +0 -2
  46. package/src/server/cards/nearby-mall-list/meta.ts +1 -3
  47. package/src/server/cards/product-comparison/meta.ts +0 -2
  48. package/src/server/cards/product-detail/meta.ts +0 -2
  49. package/src/server/cards/product-list/meta.ts +0 -2
  50. package/src/server/cards/recommend-merchants/meta.ts +37 -0
  51. package/src/server/cards/recommend-merchants/samples.ts +189 -0
  52. package/src/server/cards/{merchant-detail → shop-detail}/meta.ts +6 -6
  53. package/src/server/cards/shop-detail/samples.ts +72 -0
  54. package/src/server/cards/{merchant-list → shop-list}/meta.ts +9 -9
  55. package/src/server/cards/shop-list/samples.ts +154 -0
  56. package/src/server/domain/value-objects.ts +1 -2
  57. package/src/server/handler.ts +63 -0
  58. package/src/server/index.ts +161 -101
  59. package/src/server/ports/index.ts +120 -91
  60. package/src/server/ports/local-adapters.ts +5 -55
  61. package/src/server/projections/index.ts +159 -41
  62. package/src/server/tools/index.ts +590 -315
  63. package/tbox.module.json +137 -0
  64. package/tests/cards-render.test.tsx +830 -0
  65. package/tests/floor-pretool.test.ts +275 -0
  66. package/tests/handler.test.ts +259 -0
  67. package/tests/merchant-list-limit.test.ts +53 -0
  68. package/tests/ports-resolve.test.ts +112 -0
  69. package/tests/samples.test.ts +71 -0
  70. package/tests/shopping-guide.test.ts +402 -234
  71. package/tests/skill.test.ts +86 -0
  72. package/tests/view.test.ts +42 -0
  73. package/tsup.config.ts +9 -1
  74. package/dist/chunk-AGBLC6XI.js +0 -1294
  75. package/dist/chunk-U4WDS5PQ.js +0 -173
  76. package/skills/shopping-guide/references/comparison-format.md +0 -5
  77. package/skills/shopping-guide/references/faq-answers.md +0 -5
  78. package/skills/shopping-guide/references/floor-directory.md +0 -4
  79. package/skills/shopping-guide/references/intent-patterns.md +0 -5
  80. package/skills/shopping-guide/references/location-format.md +0 -5
  81. package/skills/shopping-guide/references/policy-lookup.md +0 -5
  82. package/skills/shopping-guide/references/product-search-tips.md +0 -6
  83. package/skills/shopping-guide/references/recommendation-style.md +0 -5
  84. package/src/client/cards/index.tsx +0 -267
  85. package/src/server/cards/customer-service-faq/meta.ts +0 -18
  86. package/src/server/integrations/joycity/adapter.ts +0 -226
  87. package/src/server/integrations/joycity/auth-strategy.ts +0 -38
  88. package/src/server/integrations/joycity/gateway.ts +0 -128
  89. package/tbox.component.json +0 -48
@@ -0,0 +1,1682 @@
1
+ // src/client/index.ts
2
+ import "./shopping-guide-OQ2SSHXL.css";
3
+
4
+ // src/client/cards/product-list/index.tsx
5
+ import { useState as useState2 } from "react";
6
+ import { createPortal } from "react-dom";
7
+ import { X } from "@phosphor-icons/react";
8
+ import { ItemActionsRow, sendCardAction } from "@tbox.cn/app-sdk/client";
9
+
10
+ // src/client/components/ImageWithFallback.tsx
11
+ import { useState } from "react";
12
+ import { ImageSquare } from "@phosphor-icons/react";
13
+ import { jsx } from "react/jsx-runtime";
14
+ function ImageWithFallback(props) {
15
+ const { src, alt, className, size = 40 } = props;
16
+ const [failed, setFailed] = useState(false);
17
+ if (!src || failed) {
18
+ return /* @__PURE__ */ jsx("div", { className: `img-fallback ${className ?? ""}`.trim(), "aria-label": alt, role: "img", children: /* @__PURE__ */ jsx(ImageSquare, { weight: "duotone", size: Math.round(size * 0.45) }) });
19
+ }
20
+ return /* @__PURE__ */ jsx(
21
+ "img",
22
+ {
23
+ className,
24
+ src,
25
+ alt,
26
+ loading: "lazy",
27
+ referrerPolicy: "no-referrer",
28
+ onError: () => setFailed(true)
29
+ }
30
+ );
31
+ }
32
+
33
+ // src/client/cards/product-list/index.tsx
34
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
35
+ function ProductDetailSheet({
36
+ item,
37
+ cardId,
38
+ isHistory,
39
+ onClose
40
+ }) {
41
+ return createPortal(
42
+ /* @__PURE__ */ jsxs("div", { className: "sg-product-sheet", role: "dialog", "aria-modal": "true", "aria-label": item.name, children: [
43
+ /* @__PURE__ */ jsx2("div", { className: "sg-product-sheet__mask", onClick: onClose }),
44
+ /* @__PURE__ */ jsxs("div", { className: "sg-product-sheet__panel", children: [
45
+ /* @__PURE__ */ jsxs("div", { className: "sg-product-sheet__header", children: [
46
+ /* @__PURE__ */ jsx2("span", { className: "sg-product-sheet__title", children: "\u5546\u54C1\u8BE6\u60C5" }),
47
+ /* @__PURE__ */ jsx2("button", { type: "button", className: "sg-product-sheet__close", onClick: onClose, "aria-label": "\u5173\u95ED", children: /* @__PURE__ */ jsx2(X, { size: 18 }) })
48
+ ] }),
49
+ /* @__PURE__ */ jsxs("div", { className: "sg-product-sheet__body", children: [
50
+ item.imageUrl && /* @__PURE__ */ jsx2(
51
+ ImageWithFallback,
52
+ {
53
+ src: item.imageUrl,
54
+ alt: item.name,
55
+ className: "sg-product-sheet__cover",
56
+ size: 240
57
+ }
58
+ ),
59
+ /* @__PURE__ */ jsxs("div", { className: "sg-product-sheet__main", children: [
60
+ item.badges.length > 0 && /* @__PURE__ */ jsx2("div", { className: "sg-badges", children: item.badges.map((b) => /* @__PURE__ */ jsx2("span", { className: "sg-badge", children: b }, b)) }),
61
+ /* @__PURE__ */ jsx2("div", { className: "sg-product-sheet__name", children: item.name }),
62
+ item.brand && /* @__PURE__ */ jsx2("div", { className: "sg-product-sheet__brand", children: item.brand }),
63
+ /* @__PURE__ */ jsxs("div", { className: "sg-product-sheet__price-row", children: [
64
+ item.price.sale && /* @__PURE__ */ jsx2("span", { className: "sg-price-sale", children: item.price.sale.display }),
65
+ item.price.original && item.price.sale && /* @__PURE__ */ jsx2("span", { className: "sg-price-original", children: item.price.original.display }),
66
+ item.price.promotion && /* @__PURE__ */ jsx2("span", { className: "sg-price-promotion", children: item.price.promotion.display }),
67
+ !item.price.sale && !item.price.original && !item.price.promotion && /* @__PURE__ */ jsx2("span", { className: "sg-price-unavailable", children: "\u4EF7\u683C\u6682\u65E0" })
68
+ ] }),
69
+ /* @__PURE__ */ jsx2("div", { className: `sg-availability sg-availability-${item.availability.status}`, children: item.availability.label }),
70
+ /* @__PURE__ */ jsxs("div", { className: "sg-product-sheet__merchant", children: [
71
+ /* @__PURE__ */ jsx2("span", { children: item.merchant.name }),
72
+ item.merchant.location?.displayText && /* @__PURE__ */ jsxs("span", { className: "sg-merchant-location", children: [
73
+ " \xB7 ",
74
+ item.merchant.location.displayText
75
+ ] })
76
+ ] }),
77
+ item.reasons && item.reasons.length > 0 && /* @__PURE__ */ jsx2("div", { className: "sg-reasons", children: item.reasons.map((r) => /* @__PURE__ */ jsx2("span", { className: "sg-reason-tag", children: r.label }, r.code)) }),
78
+ item.caveats.length > 0 && /* @__PURE__ */ jsx2("div", { className: "sg-item-caveats", children: item.caveats.map((c, i) => /* @__PURE__ */ jsxs("div", { className: "sg-caveat-item", children: [
79
+ "\u26A0\uFE0F ",
80
+ c
81
+ ] }, i)) })
82
+ ] }),
83
+ item.availability.marketable && /* @__PURE__ */ jsx2("div", { className: "sg-product-sheet__actions", children: /* @__PURE__ */ jsx2(
84
+ ItemActionsRow,
85
+ {
86
+ actions: item.itemActions,
87
+ cardId,
88
+ isHistory,
89
+ className: "sg-product-sheet__action-row",
90
+ chipClassName: "sg-product-sheet__chip"
91
+ }
92
+ ) })
93
+ ] })
94
+ ] })
95
+ ] }),
96
+ document.body
97
+ );
98
+ }
99
+ function ProductListCard(props) {
100
+ const { data, cardId, isHistory } = props;
101
+ const [activeItem, setActiveItem] = useState2(null);
102
+ return /* @__PURE__ */ jsxs("section", { className: "sg-card sg-product-list", children: [
103
+ data.summary && /* @__PURE__ */ jsx2("div", { className: "sg-card-summary", children: data.summary }),
104
+ data.items.length === 0 ? /* @__PURE__ */ jsx2("div", { className: "sg-empty", children: data.noResultsReason ?? "\u6682\u65E0\u76F8\u5173\u5546\u54C1" }) : /* @__PURE__ */ jsx2("ul", { className: "sg-product-list-items", children: data.items.map((item) => /* @__PURE__ */ jsxs(
105
+ "li",
106
+ {
107
+ className: "sg-product-item sg-product-item--clickable",
108
+ onClick: () => setActiveItem(item),
109
+ role: "button",
110
+ tabIndex: 0,
111
+ onKeyDown: (e) => e.key === "Enter" && setActiveItem(item),
112
+ children: [
113
+ /* @__PURE__ */ jsx2(
114
+ ImageWithFallback,
115
+ {
116
+ src: item.imageUrl,
117
+ alt: item.name,
118
+ className: "sg-product-image",
119
+ size: 44
120
+ }
121
+ ),
122
+ /* @__PURE__ */ jsxs("div", { className: "sg-product-info", children: [
123
+ item.badges.length > 0 && /* @__PURE__ */ jsx2("div", { className: "sg-badges", children: item.badges.map((b) => /* @__PURE__ */ jsx2("span", { className: "sg-badge", children: b }, b)) }),
124
+ /* @__PURE__ */ jsx2("div", { className: "sg-product-name", children: item.name }),
125
+ item.brand && /* @__PURE__ */ jsx2("div", { className: "sg-product-brand", children: item.brand }),
126
+ /* @__PURE__ */ jsxs("div", { className: "sg-price-block", children: [
127
+ item.price.sale && /* @__PURE__ */ jsx2("span", { className: "sg-price-sale", children: item.price.sale.display }),
128
+ item.price.original && item.price.sale && /* @__PURE__ */ jsx2("span", { className: "sg-price-original", children: item.price.original.display }),
129
+ item.price.promotion && /* @__PURE__ */ jsx2("span", { className: "sg-price-promotion", children: item.price.promotion.display }),
130
+ !item.price.sale && !item.price.original && !item.price.promotion && /* @__PURE__ */ jsx2("span", { className: "sg-price-unavailable", children: "\u4EF7\u683C\u6682\u65E0" })
131
+ ] }),
132
+ /* @__PURE__ */ jsxs("div", { className: "sg-product-sheet__merchant", children: [
133
+ /* @__PURE__ */ jsx2("span", { children: item.merchant.name }),
134
+ item.merchant.location?.displayText && /* @__PURE__ */ jsxs("span", { className: "sg-merchant-location", children: [
135
+ " \xB7 ",
136
+ item.merchant.location.displayText
137
+ ] })
138
+ ] })
139
+ ] }),
140
+ /* @__PURE__ */ jsx2("div", { className: "sg-product-item__arrow", "aria-hidden": "true", children: "\u203A" })
141
+ ]
142
+ },
143
+ item.productId
144
+ )) }),
145
+ data.pageInfo?.hasMore && /* @__PURE__ */ jsxs("div", { className: "sg-page-info", children: [
146
+ "\u5DF2\u5C55\u793A ",
147
+ data.items.length,
148
+ " / ",
149
+ data.pageInfo.total,
150
+ " \u4EF6\u5546\u54C1"
151
+ ] }),
152
+ data.refinements.length > 0 && /* @__PURE__ */ jsx2("div", { className: "sg-refinements", children: data.refinements.map((r, i) => /* @__PURE__ */ jsx2(
153
+ "button",
154
+ {
155
+ type: "button",
156
+ className: "sg-refinement-chip",
157
+ disabled: isHistory,
158
+ onClick: () => {
159
+ if (isHistory) return;
160
+ sendCardAction(cardId, { type: "sendMessage", value: r.queryText || r.label, visible: true });
161
+ },
162
+ children: r.label
163
+ },
164
+ i
165
+ )) }),
166
+ activeItem && /* @__PURE__ */ jsx2(
167
+ ProductDetailSheet,
168
+ {
169
+ item: activeItem,
170
+ cardId,
171
+ isHistory,
172
+ onClose: () => setActiveItem(null)
173
+ }
174
+ )
175
+ ] });
176
+ }
177
+ var product_list_default = ProductListCard;
178
+
179
+ // src/client/cards/product-detail/index.tsx
180
+ import { useState as useState3 } from "react";
181
+ import { ItemActionsRow as ItemActionsRow2 } from "@tbox.cn/app-sdk/client";
182
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
183
+ function ProductDetailCard(props) {
184
+ const { data, cardId, isHistory } = props;
185
+ const [active, setActive] = useState3(0);
186
+ const images = data.imageUrls;
187
+ const current = Math.min(active, Math.max(images.length - 1, 0));
188
+ return /* @__PURE__ */ jsxs2("section", { className: "sg-card sg-product-detail", children: [
189
+ /* @__PURE__ */ jsx3("div", { className: "sg-card-title", children: data.name }),
190
+ data.brand && /* @__PURE__ */ jsx3("div", { className: "sg-card-subtitle", children: data.brand }),
191
+ images.length > 0 && /* @__PURE__ */ jsxs2("div", { className: "sg-carousel", children: [
192
+ /* @__PURE__ */ jsx3(ImageWithFallback, { src: images[current], alt: data.name, className: "sg-carousel__stage", size: 72 }),
193
+ images.length > 1 && /* @__PURE__ */ jsxs2("span", { className: "sg-carousel__count", children: [
194
+ current + 1,
195
+ "/",
196
+ images.length
197
+ ] }),
198
+ images.length > 1 && /* @__PURE__ */ jsx3("div", { className: "sg-carousel__thumbs", children: images.map((src, i) => /* @__PURE__ */ jsx3(
199
+ "button",
200
+ {
201
+ type: "button",
202
+ className: "sg-carousel__thumb",
203
+ "aria-current": i === current,
204
+ "aria-label": `\u67E5\u770B\u7B2C ${i + 1} \u5F20\u56FE`,
205
+ onClick: () => setActive(i),
206
+ children: /* @__PURE__ */ jsx3("img", { src, alt: "", loading: "lazy", referrerPolicy: "no-referrer" })
207
+ },
208
+ i
209
+ )) })
210
+ ] }),
211
+ /* @__PURE__ */ jsxs2("div", { className: "sg-price-block sg-price-block--detail", children: [
212
+ data.price.sale && /* @__PURE__ */ jsx3("span", { className: "sg-price-sale sg-price-sale--lg", children: data.price.sale.display }),
213
+ data.price.original && data.price.sale && /* @__PURE__ */ jsx3("span", { className: "sg-price-original", children: data.price.original.display }),
214
+ data.price.promotion && /* @__PURE__ */ jsx3("span", { className: "sg-price-promotion", children: data.price.promotion.display })
215
+ ] }),
216
+ /* @__PURE__ */ jsxs2("div", { className: `sg-availability sg-availability-${data.availability.status}`, children: [
217
+ data.availability.label,
218
+ data.humanGuideAvailable && /* @__PURE__ */ jsx3("span", { className: "sg-availability__guide", children: "\u652F\u6301\u4EBA\u5DE5\u5BFC\u8D2D" })
219
+ ] }),
220
+ data.description && /* @__PURE__ */ jsx3("div", { className: "sg-product-desc", children: data.description }),
221
+ /* @__PURE__ */ jsx3("dl", { className: "sg-attr-table", children: data.attributes.map((a) => /* @__PURE__ */ jsxs2("div", { className: "sg-attr-row", children: [
222
+ /* @__PURE__ */ jsx3("dt", { children: a.name }),
223
+ /* @__PURE__ */ jsx3("dd", { children: a.value })
224
+ ] }, a.name)) }),
225
+ /* @__PURE__ */ jsxs2("div", { className: "sg-product-merchant", children: [
226
+ data.merchant.name,
227
+ data.merchant.location?.displayText && /* @__PURE__ */ jsxs2("span", { className: "sg-merchant-location", children: [
228
+ " \xB7 ",
229
+ data.merchant.location.displayText
230
+ ] })
231
+ ] }),
232
+ data.promotionFacts.map((p) => /* @__PURE__ */ jsx3("div", { className: "sg-promo-fact", children: p }, p)),
233
+ data.categoryPath.length > 0 && /* @__PURE__ */ jsx3("div", { className: "sg-category-path", children: data.categoryPath.join(" / ") }),
234
+ /* @__PURE__ */ jsx3(ItemActionsRow2, { actions: data.itemActions, cardId, isHistory, className: "sg-item-actions", chipClassName: "sg-chip" })
235
+ ] });
236
+ }
237
+ var product_detail_default = ProductDetailCard;
238
+
239
+ // src/client/cards/shop-list/index.tsx
240
+ import { useCallback as useCallback3, useMemo as useMemo2, useRef as useRef3, useState as useState6 } from "react";
241
+ import { CaretRight } from "@phosphor-icons/react";
242
+ import { markSelfRendering } from "@tbox.cn/app-sdk/client";
243
+
244
+ // src/client/components/ShopDetailSheet.tsx
245
+ import { useCallback, useEffect, useId, useRef, useState as useState4 } from "react";
246
+ import { createPortal as createPortal2 } from "react-dom";
247
+ import { Clock, MapPin, Phone, Star, Tag, X as X2 } from "@phosphor-icons/react";
248
+ import { ItemActionsRow as ItemActionsRow3, navigateToAlipayPage, sendCardAction as sendCardAction2 } from "@tbox.cn/app-sdk/client";
249
+ import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
250
+ var HIDDEN_DETAIL_ACTION_LABELS = /* @__PURE__ */ new Set(["\u67E5\u770B\u8BE6\u60C5", "\u5BFC\u822A", "\u95EE\u95EE\u5BFC\u8D2D"]);
251
+ function ShopDetailSheet(props) {
252
+ const { open, data, loading = false, cardId, isHistory, onClose, actionTokens, claimActionId } = props;
253
+ const [closing, setClosing] = useState4(false);
254
+ const [claimingRef, setClaimingRef] = useState4(null);
255
+ const [claimedRefs, setClaimedRefs] = useState4(() => /* @__PURE__ */ new Set());
256
+ const panelRef = useRef(null);
257
+ const closeButtonRef = useRef(null);
258
+ const closingRef = useRef(false);
259
+ const closeTimerRef = useRef();
260
+ const onCloseRef = useRef(onClose);
261
+ onCloseRef.current = onClose;
262
+ const titleId = useId();
263
+ const finishClose = useCallback(() => {
264
+ if (!closingRef.current) return;
265
+ window.clearTimeout(closeTimerRef.current);
266
+ closingRef.current = false;
267
+ setClosing(false);
268
+ onCloseRef.current();
269
+ }, []);
270
+ useEffect(() => {
271
+ if (!cardId || typeof window === "undefined") return void 0;
272
+ const onNotice = (event) => {
273
+ const detail = event.detail;
274
+ if (!detail?.text || detail.surfaceId && detail.surfaceId !== cardId) return;
275
+ const ref = claimingRef;
276
+ if (!ref) return;
277
+ setClaimingRef(null);
278
+ if (detail.level === "success" || /领取成功|已存入卡包|已领取/.test(detail.text)) {
279
+ setClaimedRefs((current) => new Set(current).add(ref));
280
+ }
281
+ };
282
+ window.addEventListener("tbox:notice", onNotice);
283
+ return () => window.removeEventListener("tbox:notice", onNotice);
284
+ }, [cardId, claimingRef]);
285
+ const claimCoupon = useCallback(
286
+ (offerRef) => {
287
+ if (!claimActionId) return;
288
+ const token = actionTokens?.[claimActionId];
289
+ if (!token) return;
290
+ setClaimingRef(offerRef);
291
+ sendCardAction2(cardId, { type: "moduleAction", actionId: claimActionId, contextToken: token }, { offerRef });
292
+ },
293
+ [actionTokens, cardId, claimActionId]
294
+ );
295
+ const requestClose = useCallback(() => {
296
+ if (closingRef.current) return;
297
+ closingRef.current = true;
298
+ setClosing(true);
299
+ const reducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches ?? false;
300
+ closeTimerRef.current = window.setTimeout(finishClose, reducedMotion ? 1 : 200);
301
+ }, [finishClose]);
302
+ useEffect(() => {
303
+ if (!open || !data) return;
304
+ closingRef.current = false;
305
+ setClosing(false);
306
+ const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
307
+ const previousOverflow = document.body.style.overflow;
308
+ document.body.style.overflow = "hidden";
309
+ closeButtonRef.current?.focus();
310
+ const onKeyDown = (event) => {
311
+ if (event.key === "Escape") {
312
+ event.preventDefault();
313
+ requestClose();
314
+ return;
315
+ }
316
+ if (event.key !== "Tab") return;
317
+ const focusable = panelRef.current?.querySelectorAll(
318
+ 'button:not(:disabled), a[href], input:not(:disabled), [tabindex]:not([tabindex="-1"])'
319
+ );
320
+ if (!focusable || focusable.length === 0) return;
321
+ const first = focusable[0];
322
+ const last = focusable[focusable.length - 1];
323
+ if (event.shiftKey && document.activeElement === first) {
324
+ event.preventDefault();
325
+ last.focus();
326
+ } else if (!event.shiftKey && document.activeElement === last) {
327
+ event.preventDefault();
328
+ first.focus();
329
+ }
330
+ };
331
+ document.addEventListener("keydown", onKeyDown);
332
+ return () => {
333
+ document.removeEventListener("keydown", onKeyDown);
334
+ document.body.style.overflow = previousOverflow;
335
+ previousFocus?.focus();
336
+ };
337
+ }, [open, requestClose]);
338
+ useEffect(() => () => window.clearTimeout(closeTimerRef.current), []);
339
+ if (!open || !data || typeof document === "undefined") return null;
340
+ const phone = data.contactInfo?.find((item) => /phone|电话/i.test(item.channel));
341
+ const hoursText = data.contactInfo?.find((item) => /hours|营业时间/i.test(item.channel))?.value ?? "\u5468\u4E00-\u5468\u65E5 10:00-22:00";
342
+ const detailActions = data.itemActions?.filter(
343
+ (action) => !HIDDEN_DETAIL_ACTION_LABELS.has(action.label.trim())
344
+ ) ?? [];
345
+ return createPortal2(
346
+ /* @__PURE__ */ jsxs3(
347
+ "div",
348
+ {
349
+ className: `sg-shop-sheet${closing ? " sg-shop-sheet--closing" : ""}`,
350
+ role: "presentation",
351
+ onAnimationEnd: (event) => {
352
+ if (closing && event.target === event.currentTarget) finishClose();
353
+ },
354
+ children: [
355
+ /* @__PURE__ */ jsx4("div", { className: "sg-shop-sheet__mask", "aria-hidden": "true", onClick: requestClose }),
356
+ /* @__PURE__ */ jsxs3(
357
+ "section",
358
+ {
359
+ ref: panelRef,
360
+ className: "sg-shop-sheet__panel",
361
+ role: "dialog",
362
+ "aria-modal": "true",
363
+ "aria-labelledby": titleId,
364
+ "aria-busy": loading || void 0,
365
+ children: [
366
+ /* @__PURE__ */ jsxs3("header", { className: "sg-shop-sheet__header", children: [
367
+ /* @__PURE__ */ jsx4("h2", { id: titleId, children: "\u95E8\u5E97\u8BE6\u60C5" }),
368
+ /* @__PURE__ */ jsx4(
369
+ "button",
370
+ {
371
+ ref: closeButtonRef,
372
+ type: "button",
373
+ className: "sg-shop-sheet__close",
374
+ "aria-label": "\u5173\u95ED\u95E8\u5E97\u8BE6\u60C5",
375
+ onClick: requestClose,
376
+ children: /* @__PURE__ */ jsx4(X2, { size: 20, weight: "bold" })
377
+ }
378
+ )
379
+ ] }),
380
+ /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__body", children: [
381
+ (data.coverUrl || data.logoUrl) && /* @__PURE__ */ jsx4(
382
+ ImageWithFallback,
383
+ {
384
+ src: data.coverUrl ?? data.logoUrl,
385
+ alt: "",
386
+ className: "sg-shop-sheet__cover",
387
+ size: 176
388
+ }
389
+ ),
390
+ /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__identity", children: [
391
+ /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__identity-copy", children: [
392
+ /* @__PURE__ */ jsx4("div", { className: "sg-shop-sheet__name-row", children: /* @__PURE__ */ jsx4("h3", { children: data.name }) }),
393
+ (data.rating || data.avgSpend || data.status.code !== "unknown" && data.status.label || loading) && /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__stats", children: [
394
+ data.rating && /* @__PURE__ */ jsxs3("span", { className: "sg-shop-sheet__rating", children: [
395
+ /* @__PURE__ */ jsx4(Star, { size: 15, weight: "fill" }),
396
+ data.rating
397
+ ] }),
398
+ data.avgSpend && /* @__PURE__ */ jsxs3("span", { children: [
399
+ "\u4EBA\u5747 ",
400
+ data.avgSpend
401
+ ] }),
402
+ loading ? /* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__skeleton sg-shop-sheet__skeleton--status", "aria-hidden": "true" }) : data.status.code !== "unknown" && /* @__PURE__ */ jsx4("span", { className: `sg-status sg-status-${data.status.code}`, children: data.status.label })
403
+ ] })
404
+ ] }),
405
+ loading ? /* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__phone-skeleton", "aria-hidden": "true" }) : phone && /* @__PURE__ */ jsxs3(
406
+ "a",
407
+ {
408
+ className: "sg-shop-sheet__phone",
409
+ href: phone.value.startsWith("tel:") ? phone.value : `tel:${phone.value}`,
410
+ "aria-label": `\u62E8\u6253${data.name}\u7535\u8BDD`,
411
+ children: [
412
+ /* @__PURE__ */ jsx4(Phone, { size: 20, weight: "fill" }),
413
+ /* @__PURE__ */ jsx4("span", { children: "\u7535\u8BDD" })
414
+ ]
415
+ }
416
+ )
417
+ ] }),
418
+ /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__facts", children: [
419
+ /* @__PURE__ */ jsxs3("div", { children: [
420
+ data.businessCategories.length > 0 && /* @__PURE__ */ jsx4("span", { children: data.businessCategories.join(" \xB7 ") }),
421
+ /* @__PURE__ */ jsx4(MapPin, { size: 17, weight: "fill" }),
422
+ /* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__location", children: data.location.displayText })
423
+ ] }),
424
+ !loading && data.operatingStatus && /* @__PURE__ */ jsx4("div", { children: data.operatingStatus }),
425
+ !loading && /* @__PURE__ */ jsxs3("div", { children: [
426
+ /* @__PURE__ */ jsx4(Clock, { size: 18 }),
427
+ /* @__PURE__ */ jsx4("span", { children: hoursText })
428
+ ] }),
429
+ !loading && data.services && data.services.length > 0 && /* @__PURE__ */ jsxs3("div", { children: [
430
+ "\u652F\u6301",
431
+ data.services.join("\u3001")
432
+ ] }),
433
+ loading && /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__facts-skeleton", role: "status", "aria-label": "\u95E8\u5E97\u8BE6\u60C5\u52A0\u8F7D\u4E2D", children: [
434
+ /* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__skeleton sg-shop-sheet__skeleton--fact", "aria-hidden": "true" }),
435
+ /* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__skeleton sg-shop-sheet__skeleton--fact-short", "aria-hidden": "true" })
436
+ ] })
437
+ ] }),
438
+ loading && /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__details-skeleton", "aria-hidden": "true", children: [
439
+ /* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__skeleton sg-shop-sheet__skeleton--detail-line" }),
440
+ /* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__skeleton sg-shop-sheet__skeleton--detail-line-short" }),
441
+ /* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__skeleton sg-shop-sheet__skeleton--detail-block" })
442
+ ] }),
443
+ !loading && data.description && /* @__PURE__ */ jsx4("p", { className: "sg-shop-sheet__description", children: data.description }),
444
+ !loading && data.coupons && data.coupons.length > 0 && /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__coupons", "aria-label": "\u95E8\u5E97\u4F18\u60E0", children: [
445
+ /* @__PURE__ */ jsxs3("h3", { className: "sg-shop-sheet__section-title", children: [
446
+ /* @__PURE__ */ jsx4(Tag, { size: 16, weight: "fill", "aria-hidden": "true" }),
447
+ "\u4F18\u60E0\u6D3B\u52A8"
448
+ ] }),
449
+ /* @__PURE__ */ jsx4("div", { className: "sg-shop-sheet__coupon-list", children: data.coupons.map((coupon, index) => {
450
+ const purchaseOnly = coupon.salePrice !== void 0 && coupon.salePrice > 0;
451
+ const redirectOnly = purchaseOnly || coupon.freeCouponClaimMode === "REDIRECT";
452
+ const claimToken = coupon.offerRef && claimActionId ? actionTokens?.[claimActionId] : void 0;
453
+ const claimable = Boolean(!redirectOnly && coupon.offerRef && claimToken && !isHistory);
454
+ const redirectAction = redirectOnly && Boolean(coupon.offerRef || coupon.purchaseUrl);
455
+ const claimed = coupon.offerRef !== void 0 && claimedRefs.has(coupon.offerRef);
456
+ return /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__coupon-row", children: [
457
+ coupon.applicableCategories && coupon.applicableCategories.length > 0 && /* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__coupon-tag", children: coupon.applicableCategories.join("\u3001") }),
458
+ coupon.imageUrl && /* @__PURE__ */ jsx4(
459
+ ImageWithFallback,
460
+ {
461
+ src: coupon.imageUrl,
462
+ alt: coupon.name,
463
+ className: "sg-shop-sheet__coupon-img",
464
+ size: 112
465
+ }
466
+ ),
467
+ /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__coupon-body", children: [
468
+ /* @__PURE__ */ jsx4("strong", { className: "sg-shop-sheet__coupon-name", children: coupon.name }),
469
+ coupon.faceValue !== void 0 && /* @__PURE__ */ jsx4("p", { className: "sg-shop-sheet__coupon-price", children: coupon.salePrice === 0 ? /* @__PURE__ */ jsxs3(Fragment, { children: [
470
+ /* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__coupon-free", children: "\u514D\u8D39" }),
471
+ /* @__PURE__ */ jsxs3("s", { className: "sg-shop-sheet__coupon-face--strike", children: [
472
+ "\xA5",
473
+ coupon.faceValue
474
+ ] })
475
+ ] }) : coupon.salePrice !== void 0 ? /* @__PURE__ */ jsxs3(Fragment, { children: [
476
+ /* @__PURE__ */ jsxs3("span", { className: "sg-shop-sheet__coupon-face", children: [
477
+ "\xA5",
478
+ coupon.salePrice
479
+ ] }),
480
+ /* @__PURE__ */ jsxs3("s", { className: "sg-shop-sheet__coupon-face--strike", children: [
481
+ "\xA5",
482
+ coupon.faceValue
483
+ ] })
484
+ ] }) : /* @__PURE__ */ jsxs3("span", { className: "sg-shop-sheet__coupon-face", children: [
485
+ "\xA5",
486
+ coupon.faceValue
487
+ ] }) }),
488
+ coupon.usageTimeText && /* @__PURE__ */ jsx4("p", { className: "sg-shop-sheet__coupon-sub", children: coupon.usageTimeText })
489
+ ] }),
490
+ redirectAction ? /* @__PURE__ */ jsx4(
491
+ "button",
492
+ {
493
+ type: "button",
494
+ className: "sg-shop-sheet__coupon-claim",
495
+ disabled: !coupon.purchaseUrl,
496
+ onClick: () => {
497
+ if (!coupon.purchaseUrl) return;
498
+ void navigateToAlipayPage(coupon.purchaseUrl).catch((err) => {
499
+ console.warn("[ShopDetailSheet] navigateTo failed", err);
500
+ });
501
+ },
502
+ children: coupon.purchaseUrl ? `\u53BB\u5C0F\u7A0B\u5E8F${purchaseOnly ? "\u62A2\u8D2D" : "\u9886\u53D6"}` : `${purchaseOnly ? "\u62A2\u8D2D" : "\u9886\u53D6"}\u94FE\u63A5\u6682\u4E0D\u53EF\u7528`
503
+ }
504
+ ) : claimable && coupon.offerRef ? /* @__PURE__ */ jsx4(
505
+ "button",
506
+ {
507
+ type: "button",
508
+ className: "sg-shop-sheet__coupon-claim",
509
+ onClick: () => claimCoupon(coupon.offerRef),
510
+ disabled: claimingRef === coupon.offerRef || claimed,
511
+ children: claimed ? "\u5DF2\u9886\u53D6" : claimingRef === coupon.offerRef ? "\u9886\u53D6\u4E2D\uFF0C\u8BF7\u7A0D\u5019\u2026" : "\u9886\u53D6"
512
+ }
513
+ ) : null
514
+ ] }, index);
515
+ }) })
516
+ ] }),
517
+ !loading && detailActions.length > 0 && /* @__PURE__ */ jsx4(
518
+ ItemActionsRow3,
519
+ {
520
+ actions: detailActions,
521
+ cardId,
522
+ isHistory,
523
+ className: "sg-shop-sheet__actions",
524
+ chipClassName: "sg-shop-sheet__action"
525
+ }
526
+ )
527
+ ] })
528
+ ]
529
+ }
530
+ )
531
+ ]
532
+ }
533
+ ),
534
+ document.body
535
+ );
536
+ }
537
+
538
+ // src/client/components/MerchantRow.tsx
539
+ import { MapPin as MapPin2, Star as Star2 } from "@phosphor-icons/react";
540
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
541
+ function MerchantRow(props) {
542
+ const { merchant, disabled = false, className, onSelect } = props;
543
+ return /* @__PURE__ */ jsxs4(
544
+ "button",
545
+ {
546
+ type: "button",
547
+ className: ["sg-rm-item-head", "sg-merchant-row", className].filter(Boolean).join(" "),
548
+ "aria-label": `\u67E5\u770B${merchant.name}\u8BE6\u60C5`,
549
+ disabled,
550
+ onClick: onSelect,
551
+ children: [
552
+ /* @__PURE__ */ jsx5(ImageWithFallback, { src: merchant.logoUrl, alt: "", className: "sg-rm-item-image", size: 96 }),
553
+ /* @__PURE__ */ jsxs4("div", { className: "sg-rm-item-meta", children: [
554
+ /* @__PURE__ */ jsx5("div", { className: "sg-rm-item-name-row", children: /* @__PURE__ */ jsx5("span", { className: "sg-rm-item-name", children: merchant.name }) }),
555
+ (merchant.rating || merchant.avgSpend) && /* @__PURE__ */ jsxs4("div", { className: "sg-rm-item-stats", children: [
556
+ merchant.rating && /* @__PURE__ */ jsxs4("span", { className: "sg-rm-item-rating", children: [
557
+ /* @__PURE__ */ jsx5(Star2, { size: 14, weight: "fill" }),
558
+ merchant.rating
559
+ ] }),
560
+ merchant.avgSpend && /* @__PURE__ */ jsxs4("span", { className: "sg-rm-item-avg-spend", children: [
561
+ "\u4EBA\u5747 ",
562
+ merchant.avgSpend
563
+ ] })
564
+ ] }),
565
+ merchant.businessCategories.length > 0 && /* @__PURE__ */ jsx5("div", { className: "sg-rm-item-tags", "aria-label": "\u95E8\u5E97\u4E1A\u6001", children: merchant.businessCategories.map((category) => /* @__PURE__ */ jsx5("span", { className: "sg-rm-item-tag", children: category }, category)) }),
566
+ /* @__PURE__ */ jsxs4("div", { className: "sg-rm-item-location", children: [
567
+ /* @__PURE__ */ jsx5(MapPin2, { size: 13, weight: "fill" }),
568
+ /* @__PURE__ */ jsx5("span", { children: merchant.location.displayText })
569
+ ] })
570
+ ] })
571
+ ]
572
+ }
573
+ );
574
+ }
575
+
576
+ // src/client/categories.ts
577
+ function resolveCategoryTabs(categoryTabs, items) {
578
+ const result = [];
579
+ const seenNames = /* @__PURE__ */ new Set();
580
+ for (const tab of categoryTabs ?? []) {
581
+ const name = tab.name.trim();
582
+ if (!name || seenNames.has(name)) continue;
583
+ seenNames.add(name);
584
+ result.push({ code: tab.code, name });
585
+ }
586
+ for (const item of items) {
587
+ for (const category of item.businessCategories) {
588
+ const name = category.trim();
589
+ if (!name || seenNames.has(name)) continue;
590
+ seenNames.add(name);
591
+ result.push({ code: `derived-${name}`, name });
592
+ }
593
+ }
594
+ return result;
595
+ }
596
+
597
+ // src/client/components/ShopGuideHeader.tsx
598
+ import { Storefront } from "@phosphor-icons/react";
599
+
600
+ // src/client/assets/shop-guide-header-art-pea-v2.jpg
601
+ var shop_guide_header_art_pea_v2_default = "./shop-guide-header-art-pea-v2-OME4MKBW.jpg";
602
+
603
+ // src/client/components/ShopGuideHeader.tsx
604
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
605
+ function ShopGuideHeader(props) {
606
+ return /* @__PURE__ */ jsxs5("header", { className: "sg-rm-header", children: [
607
+ /* @__PURE__ */ jsx6("img", { src: shop_guide_header_art_pea_v2_default, alt: "", className: "sg-rm-header-art", "aria-hidden": "true" }),
608
+ /* @__PURE__ */ jsxs5("div", { className: "sg-rm-header-copy", children: [
609
+ /* @__PURE__ */ jsxs5("div", { className: "sg-rm-header-title-row", children: [
610
+ /* @__PURE__ */ jsx6(Storefront, { size: 22, weight: "fill" }),
611
+ /* @__PURE__ */ jsx6("h3", { className: "sg-rm-header-title", children: "\u95E8\u5E97\u5BFC\u89C8" })
612
+ ] }),
613
+ /* @__PURE__ */ jsx6("p", { className: "sg-rm-header-subtitle", children: props.subtitle })
614
+ ] }),
615
+ /* @__PURE__ */ jsx6("span", { className: "sg-rm-header-badge", children: "\u5546\u573A\u5BFC\u89C8" })
616
+ ] });
617
+ }
618
+
619
+ // src/client/components/ShopGuideSectionLabel.tsx
620
+ import { jsx as jsx7 } from "react/jsx-runtime";
621
+ function ShopGuideSectionLabel() {
622
+ return /* @__PURE__ */ jsx7("div", { className: "sg-rm-section-label", children: "\u95E8\u5E97" });
623
+ }
624
+
625
+ // src/client/components/ShopListSheet.tsx
626
+ import { useCallback as useCallback2, useEffect as useEffect2, useId as useId2, useMemo, useRef as useRef2, useState as useState5 } from "react";
627
+ import { createPortal as createPortal3 } from "react-dom";
628
+ import { MagnifyingGlass, X as X3 } from "@phosphor-icons/react";
629
+ import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
630
+ function normalizeSearchText(value) {
631
+ return value.trim().toLocaleLowerCase();
632
+ }
633
+ function floorOrder(a, b) {
634
+ const parse = (value) => {
635
+ const normalized = value.trim().toUpperCase();
636
+ const basement = normalized.match(/^B(\d+)$/);
637
+ if (basement) return -Number(basement[1]);
638
+ const aboveGround = normalized.match(/^(?:L|F)?(\d+)F?$/);
639
+ if (aboveGround) return Number(aboveGround[1]);
640
+ return Number.POSITIVE_INFINITY;
641
+ };
642
+ const numeric = parse(a) - parse(b);
643
+ return Number.isNaN(numeric) || numeric === 0 ? a.localeCompare(b, "zh-CN", { numeric: true }) : numeric;
644
+ }
645
+ function ShopListSheet(props) {
646
+ const { open, items, categoryTabs, activeTabCode, onSelect, onClose } = props;
647
+ const [query, setQuery] = useState5("");
648
+ const [sheetTabCode, setSheetTabCode] = useState5("");
649
+ const [activeFloor, setActiveFloor] = useState5("");
650
+ const [closing, setClosing] = useState5(false);
651
+ const panelRef = useRef2(null);
652
+ const bodyRef = useRef2(null);
653
+ const closeButtonRef = useRef2(null);
654
+ const closingRef = useRef2(false);
655
+ const closeTimerRef = useRef2();
656
+ const onCloseRef = useRef2(onClose);
657
+ onCloseRef.current = onClose;
658
+ const titleId = useId2();
659
+ const searchId = useId2();
660
+ const finishClose = useCallback2(() => {
661
+ if (!closingRef.current) return;
662
+ window.clearTimeout(closeTimerRef.current);
663
+ closingRef.current = false;
664
+ setClosing(false);
665
+ onCloseRef.current();
666
+ }, []);
667
+ const requestClose = useCallback2(() => {
668
+ if (closingRef.current) return;
669
+ closingRef.current = true;
670
+ setClosing(true);
671
+ const reducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches ?? false;
672
+ closeTimerRef.current = window.setTimeout(finishClose, reducedMotion ? 1 : 200);
673
+ }, [finishClose]);
674
+ const allCategories = useMemo(() => resolveCategoryTabs(categoryTabs, items), [categoryTabs, items]);
675
+ const activeCategory = allCategories.find((tab) => tab.code === sheetTabCode)?.name;
676
+ const matchedItems = useMemo(() => {
677
+ const normalizedQuery = normalizeSearchText(query);
678
+ return items.filter((item) => {
679
+ if (activeCategory && !item.businessCategories.includes(activeCategory)) return false;
680
+ if (!normalizedQuery) return true;
681
+ return normalizeSearchText([
682
+ item.name,
683
+ item.brand,
684
+ ...item.businessCategories,
685
+ item.location.displayText
686
+ ].filter(Boolean).join(" ")).includes(normalizedQuery);
687
+ });
688
+ }, [activeCategory, items, query]);
689
+ const floorNames = useMemo(() => [...new Set(
690
+ matchedItems.map((item) => item.location.floorName?.trim()).filter((floor) => Boolean(floor))
691
+ )].sort((a, b) => floorOrder(b, a)), [matchedItems]);
692
+ const showFloorRail = floorNames.length >= 2 && matchedItems.length >= 5;
693
+ const filteredItems = useMemo(
694
+ () => activeFloor ? matchedItems.filter((item) => item.location.floorName?.trim() === activeFloor) : matchedItems,
695
+ [activeFloor, matchedItems]
696
+ );
697
+ useEffect2(() => {
698
+ bodyRef.current?.scrollTo({ top: 0 });
699
+ }, [sheetTabCode, activeFloor, query]);
700
+ useEffect2(() => {
701
+ setActiveFloor((current) => current && floorNames.includes(current) ? current : "");
702
+ }, [floorNames]);
703
+ useEffect2(() => {
704
+ if (!open) return;
705
+ setQuery("");
706
+ setSheetTabCode(allCategories.some((tab) => tab.code === activeTabCode) ? activeTabCode : "");
707
+ closingRef.current = false;
708
+ setClosing(false);
709
+ const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
710
+ const previousOverflow = document.body.style.overflow;
711
+ document.body.style.overflow = "hidden";
712
+ closeButtonRef.current?.focus();
713
+ const onKeyDown = (event) => {
714
+ if (event.key === "Escape") {
715
+ event.preventDefault();
716
+ requestClose();
717
+ return;
718
+ }
719
+ if (event.key !== "Tab") return;
720
+ const focusable = panelRef.current?.querySelectorAll(
721
+ 'button:not(:disabled), input:not(:disabled), a[href], [tabindex]:not([tabindex="-1"])'
722
+ );
723
+ if (!focusable || focusable.length === 0) return;
724
+ const first = focusable[0];
725
+ const last = focusable[focusable.length - 1];
726
+ if (event.shiftKey && document.activeElement === first) {
727
+ event.preventDefault();
728
+ last.focus();
729
+ } else if (!event.shiftKey && document.activeElement === last) {
730
+ event.preventDefault();
731
+ first.focus();
732
+ }
733
+ };
734
+ document.addEventListener("keydown", onKeyDown);
735
+ return () => {
736
+ document.removeEventListener("keydown", onKeyDown);
737
+ document.body.style.overflow = previousOverflow;
738
+ previousFocus?.focus();
739
+ };
740
+ }, [activeTabCode, allCategories, open, requestClose]);
741
+ useEffect2(() => () => window.clearTimeout(closeTimerRef.current), []);
742
+ if (!open || typeof document === "undefined") return null;
743
+ return createPortal3(
744
+ /* @__PURE__ */ jsxs6(
745
+ "div",
746
+ {
747
+ className: `sg-store-list-sheet${closing ? " sg-store-list-sheet--closing" : ""}`,
748
+ role: "presentation",
749
+ onAnimationEnd: (event) => {
750
+ if (closing && event.target === event.currentTarget) finishClose();
751
+ },
752
+ children: [
753
+ /* @__PURE__ */ jsx8("div", { className: "sg-store-list-sheet__mask", "aria-hidden": "true", onClick: requestClose }),
754
+ /* @__PURE__ */ jsxs6("section", { ref: panelRef, className: "sg-store-list-sheet__panel", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, children: [
755
+ /* @__PURE__ */ jsxs6("header", { className: "sg-store-list-sheet__header", children: [
756
+ /* @__PURE__ */ jsx8("h2", { id: titleId, children: "\u95E8\u5E97\u5BFC\u89C8" }),
757
+ /* @__PURE__ */ jsx8("button", { ref: closeButtonRef, type: "button", className: "sg-store-list-sheet__close", "aria-label": "\u5173\u95ED\u95E8\u5E97\u5217\u8868", onClick: requestClose, children: /* @__PURE__ */ jsx8(X3, { size: 20, weight: "bold" }) })
758
+ ] }),
759
+ /* @__PURE__ */ jsxs6("div", { className: "sg-store-list-sheet__search", children: [
760
+ /* @__PURE__ */ jsx8("label", { className: "sg-visually-hidden", htmlFor: searchId, children: "\u641C\u7D22\u95E8\u5E97" }),
761
+ /* @__PURE__ */ jsx8(MagnifyingGlass, { size: 18, "aria-hidden": "true" }),
762
+ /* @__PURE__ */ jsx8(
763
+ "input",
764
+ {
765
+ id: searchId,
766
+ type: "search",
767
+ value: query,
768
+ placeholder: "\u8BF7\u8F93\u5165\u8981\u641C\u7D22\u7684\u5E97\u94FA\u540D",
769
+ onChange: (event) => setQuery(event.target.value)
770
+ }
771
+ ),
772
+ query && /* @__PURE__ */ jsx8("button", { type: "button", "aria-label": "\u6E05\u7A7A\u95E8\u5E97\u641C\u7D22", onClick: () => setQuery(""), children: /* @__PURE__ */ jsx8(X3, { size: 14, weight: "bold" }) })
773
+ ] }),
774
+ /* @__PURE__ */ jsxs6("div", { className: "sg-store-list-sheet__content", children: [
775
+ /* @__PURE__ */ jsxs6("nav", { className: "sg-store-list-sheet__categories", "aria-label": "\u6309\u95E8\u5E97\u4E1A\u6001\u7B5B\u9009", children: [
776
+ /* @__PURE__ */ jsx8(
777
+ "button",
778
+ {
779
+ type: "button",
780
+ className: !sheetTabCode ? "is-active" : void 0,
781
+ "aria-pressed": !sheetTabCode,
782
+ onClick: () => setSheetTabCode(""),
783
+ children: "\u5168\u90E8"
784
+ }
785
+ ),
786
+ allCategories.map((tab) => {
787
+ const isActive = sheetTabCode === tab.code;
788
+ return /* @__PURE__ */ jsx8(
789
+ "button",
790
+ {
791
+ type: "button",
792
+ className: isActive ? "is-active" : void 0,
793
+ "aria-pressed": isActive,
794
+ onClick: () => setSheetTabCode(tab.code),
795
+ children: tab.name
796
+ },
797
+ tab.code
798
+ );
799
+ })
800
+ ] }),
801
+ /* @__PURE__ */ jsxs6("div", { ref: bodyRef, className: "sg-store-list-sheet__body", children: [
802
+ /* @__PURE__ */ jsxs6("p", { className: "sg-store-list-sheet__count", "aria-live": "polite", children: [
803
+ "\u5F53\u524D\u663E\u793A ",
804
+ filteredItems.length,
805
+ " \u5BB6\u95E8\u5E97"
806
+ ] }),
807
+ filteredItems.length === 0 ? /* @__PURE__ */ jsx8("div", { className: "sg-store-list-sheet__empty", children: "\u6682\u65F6\u6CA1\u6709\u7B26\u5408\u6761\u4EF6\u7684\u95E8\u5E97" }) : /* @__PURE__ */ jsx8("ul", { className: "sg-store-list-sheet__list", children: filteredItems.map((item) => /* @__PURE__ */ jsx8("li", { children: /* @__PURE__ */ jsx8(
808
+ MerchantRow,
809
+ {
810
+ merchant: item,
811
+ className: "sg-store-list-sheet__item",
812
+ onSelect: () => onSelect(item)
813
+ }
814
+ ) }, item.merchantId)) })
815
+ ] }),
816
+ showFloorRail && /* @__PURE__ */ jsxs6("nav", { className: "sg-store-list-sheet__floors", "aria-label": "\u6309\u697C\u5C42\u7B5B\u9009", children: [
817
+ /* @__PURE__ */ jsx8(
818
+ "button",
819
+ {
820
+ type: "button",
821
+ className: !activeFloor ? "is-active" : void 0,
822
+ "aria-pressed": !activeFloor,
823
+ onClick: () => setActiveFloor(""),
824
+ children: "\u5168"
825
+ }
826
+ ),
827
+ floorNames.map((floor) => /* @__PURE__ */ jsx8(
828
+ "button",
829
+ {
830
+ type: "button",
831
+ className: activeFloor === floor ? "is-active" : void 0,
832
+ "aria-pressed": activeFloor === floor,
833
+ onClick: () => setActiveFloor(floor),
834
+ children: floor
835
+ },
836
+ floor
837
+ ))
838
+ ] })
839
+ ] })
840
+ ] })
841
+ ]
842
+ }
843
+ ),
844
+ document.body
845
+ );
846
+ }
847
+
848
+ // src/client/cards/shop-list/index.tsx
849
+ import { httpGet } from "@tbox.cn/app-sdk/client";
850
+ import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
851
+ var PREVIEW_ITEM_COUNT = 3;
852
+ function projectSheetDataFromItem(merchant) {
853
+ return {
854
+ name: merchant.name,
855
+ logoUrl: merchant.logoUrl,
856
+ coverUrl: merchant.coverUrl,
857
+ brand: merchant.brand,
858
+ businessCategories: merchant.businessCategories,
859
+ location: merchant.location,
860
+ status: merchant.status,
861
+ contactInfo: merchant.contactInfo,
862
+ services: merchant.services,
863
+ itemActions: merchant.itemActions,
864
+ coupons: merchant.coupons
865
+ };
866
+ }
867
+ function projectSheetDataFromDetail(detail) {
868
+ return {
869
+ name: detail.name,
870
+ logoUrl: detail.logoUrl,
871
+ coverUrl: detail.coverUrls[0],
872
+ brand: detail.brand,
873
+ businessCategories: detail.businessCategories,
874
+ location: detail.location,
875
+ status: detail.status,
876
+ description: detail.description,
877
+ contactInfo: detail.contactInfo,
878
+ services: detail.services,
879
+ itemActions: detail.itemActions,
880
+ coupons: detail.coupons
881
+ };
882
+ }
883
+ function ShopListCard(props) {
884
+ const { data, cardId, isHistory, actionTokens } = props;
885
+ const [activeTabCode, setActiveTabCode] = useState6("");
886
+ const [overlay, setOverlay] = useState6({ kind: "closed" });
887
+ const [sheetData, setSheetData] = useState6(null);
888
+ const [detailLoading, setDetailLoading] = useState6(false);
889
+ const openedMerchantIdRef = useRef3(null);
890
+ const fetchControllerRef = useRef3(null);
891
+ const allTabs = useMemo2(() => resolveCategoryTabs(data.categoryTabs, data.items), [data.categoryTabs, data.items]);
892
+ const activeTab = allTabs.find((tab) => tab.code === activeTabCode);
893
+ const filteredItems = activeTab ? data.items.filter((item) => item.businessCategories.includes(activeTab.name)) : data.items;
894
+ const previewItems = filteredItems.slice(0, PREVIEW_ITEM_COUNT);
895
+ const closeOverlay = useCallback3(() => {
896
+ fetchControllerRef.current?.abort();
897
+ fetchControllerRef.current = null;
898
+ openedMerchantIdRef.current = null;
899
+ setDetailLoading(false);
900
+ setOverlay({ kind: "closed" });
901
+ setSheetData(null);
902
+ }, []);
903
+ const openDetail = useCallback3((merchant) => {
904
+ fetchControllerRef.current?.abort();
905
+ const controller = new AbortController();
906
+ fetchControllerRef.current = controller;
907
+ openedMerchantIdRef.current = merchant.merchantId;
908
+ setSheetData(projectSheetDataFromItem(merchant));
909
+ setOverlay({ kind: "detail", merchant });
910
+ const { mallId, miniAppId } = data;
911
+ if (!mallId || !miniAppId) {
912
+ setDetailLoading(false);
913
+ return;
914
+ }
915
+ setDetailLoading(true);
916
+ const url = `/api/m/shopping-guide/shop-detail?shopId=${encodeURIComponent(merchant.merchantId)}&mallId=${encodeURIComponent(mallId)}&miniAppId=${encodeURIComponent(miniAppId)}`;
917
+ httpGet(url, { signal: controller.signal }).then(({ data: payload }) => {
918
+ if (openedMerchantIdRef.current === merchant.merchantId && fetchControllerRef.current === controller) {
919
+ if (payload) setSheetData(projectSheetDataFromDetail(payload.data));
920
+ setDetailLoading(false);
921
+ }
922
+ }).catch(() => {
923
+ if (openedMerchantIdRef.current === merchant.merchantId && fetchControllerRef.current === controller) {
924
+ setDetailLoading(false);
925
+ }
926
+ });
927
+ }, [data]);
928
+ return /* @__PURE__ */ jsxs7(Fragment2, { children: [
929
+ /* @__PURE__ */ jsxs7("section", { className: "sg-card sg-recommend-merchants sg-shop-list", children: [
930
+ /* @__PURE__ */ jsx9(ShopGuideHeader, { subtitle: data.summary ?? "\u6309\u54C1\u7C7B\u5FEB\u901F\u627E\u5230\u60F3\u901B\u7684\u95E8\u5E97" }),
931
+ allTabs.length > 0 && /* @__PURE__ */ jsxs7("div", { className: "sg-rm-tabs", "aria-label": "\u6309\u95E8\u5E97\u54C1\u7C7B\u7B5B\u9009", children: [
932
+ /* @__PURE__ */ jsx9(
933
+ "button",
934
+ {
935
+ type: "button",
936
+ "aria-pressed": !activeTabCode,
937
+ className: `sg-rm-tab${!activeTabCode ? " sg-rm-tab--active" : ""}`,
938
+ onClick: () => setActiveTabCode(""),
939
+ children: /* @__PURE__ */ jsx9("span", { children: "\u5168\u90E8" })
940
+ }
941
+ ),
942
+ allTabs.map((tab) => {
943
+ const isActive = tab.code === activeTabCode;
944
+ return /* @__PURE__ */ jsx9(
945
+ "button",
946
+ {
947
+ type: "button",
948
+ "aria-pressed": isActive,
949
+ className: `sg-rm-tab${isActive ? " sg-rm-tab--active" : ""}`,
950
+ onClick: () => setActiveTabCode(tab.code),
951
+ children: /* @__PURE__ */ jsx9("span", { children: tab.name })
952
+ },
953
+ tab.code
954
+ );
955
+ })
956
+ ] }),
957
+ filteredItems.length === 0 ? /* @__PURE__ */ jsx9("div", { className: "sg-empty", children: data.noResultsReason ?? "\u6682\u65F6\u6CA1\u6709\u7B26\u5408\u6761\u4EF6\u7684\u95E8\u5E97" }) : /* @__PURE__ */ jsxs7(Fragment2, { children: [
958
+ /* @__PURE__ */ jsx9(ShopGuideSectionLabel, {}),
959
+ /* @__PURE__ */ jsx9("ul", { className: "sg-rm-list", children: previewItems.map((item) => /* @__PURE__ */ jsx9("li", { className: "sg-rm-item", children: /* @__PURE__ */ jsx9(MerchantRow, { merchant: item, onSelect: () => openDetail(item) }) }, item.merchantId)) }),
960
+ filteredItems.length > PREVIEW_ITEM_COUNT && /* @__PURE__ */ jsxs7(
961
+ "button",
962
+ {
963
+ type: "button",
964
+ className: "sg-rm-view-all",
965
+ onClick: () => setOverlay({ kind: "list" }),
966
+ children: [
967
+ "\u67E5\u770B\u5168\u90E8\u95E8\u5E97",
968
+ /* @__PURE__ */ jsx9(CaretRight, { size: 17 })
969
+ ]
970
+ }
971
+ )
972
+ ] })
973
+ ] }),
974
+ /* @__PURE__ */ jsx9(
975
+ ShopListSheet,
976
+ {
977
+ open: overlay.kind === "list",
978
+ items: data.items,
979
+ categoryTabs: allTabs,
980
+ activeTabCode,
981
+ isHistory,
982
+ onSelect: openDetail,
983
+ onClose: closeOverlay
984
+ }
985
+ ),
986
+ /* @__PURE__ */ jsx9(
987
+ ShopDetailSheet,
988
+ {
989
+ open: overlay.kind === "detail",
990
+ data: sheetData,
991
+ loading: detailLoading,
992
+ cardId,
993
+ isHistory,
994
+ actionTokens,
995
+ claimActionId: "promotion.acquire-from-shop-list",
996
+ onClose: closeOverlay
997
+ }
998
+ )
999
+ ] });
1000
+ }
1001
+ markSelfRendering(ShopListCard);
1002
+ var shop_list_default = ShopListCard;
1003
+
1004
+ // src/client/cards/shop-detail/index.tsx
1005
+ import { useCallback as useCallback4, useRef as useRef4, useState as useState7 } from "react";
1006
+ import { Clock as Clock2, Phone as Phone2 } from "@phosphor-icons/react";
1007
+ import { httpGet as httpGet2, markSelfRendering as markSelfRendering2 } from "@tbox.cn/app-sdk/client";
1008
+ import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
1009
+ function projectSheetDataFromCardData(data) {
1010
+ return {
1011
+ name: data.name,
1012
+ logoUrl: data.logoUrl,
1013
+ coverUrl: data.coverUrls[0],
1014
+ brand: data.brand,
1015
+ businessCategories: data.businessCategories,
1016
+ location: data.location,
1017
+ status: data.status,
1018
+ description: data.description,
1019
+ contactInfo: data.contactInfo,
1020
+ services: data.services,
1021
+ itemActions: data.itemActions,
1022
+ coupons: data.coupons
1023
+ };
1024
+ }
1025
+ function ShopDetailCard(props) {
1026
+ const { data, cardId, isHistory, actionTokens } = props;
1027
+ const [sheetOpen, setSheetOpen] = useState7(false);
1028
+ const [sheetData, setSheetData] = useState7(null);
1029
+ const [detailLoading, setDetailLoading] = useState7(false);
1030
+ const fetchControllerRef = useRef4(null);
1031
+ const openDetail = useCallback4(() => {
1032
+ fetchControllerRef.current?.abort();
1033
+ const controller = new AbortController();
1034
+ fetchControllerRef.current = controller;
1035
+ setSheetData(projectSheetDataFromCardData(data));
1036
+ setSheetOpen(true);
1037
+ const { merchantId, mallId, miniAppId } = data;
1038
+ if (!mallId || !miniAppId) {
1039
+ setDetailLoading(false);
1040
+ return;
1041
+ }
1042
+ setDetailLoading(true);
1043
+ const url = `/api/m/shopping-guide/shop-detail?shopId=${encodeURIComponent(merchantId)}&mallId=${encodeURIComponent(mallId)}&miniAppId=${encodeURIComponent(miniAppId)}`;
1044
+ httpGet2(url, { signal: controller.signal }).then(({ data: payload }) => {
1045
+ if (fetchControllerRef.current === controller) {
1046
+ if (payload) setSheetData(projectSheetDataFromCardData(payload.data));
1047
+ setDetailLoading(false);
1048
+ }
1049
+ }).catch((err) => {
1050
+ if (fetchControllerRef.current !== controller) return;
1051
+ if (err instanceof Error && err.name === "AbortError") return;
1052
+ setDetailLoading(false);
1053
+ });
1054
+ }, [data]);
1055
+ const closeDetail = useCallback4(() => {
1056
+ fetchControllerRef.current?.abort();
1057
+ fetchControllerRef.current = null;
1058
+ setDetailLoading(false);
1059
+ setSheetOpen(false);
1060
+ setSheetData(null);
1061
+ }, []);
1062
+ const hoursText = data.contactInfo?.find((item) => /hours|营业时间/i.test(item.channel))?.value ?? "\u5468\u4E00-\u5468\u65E5 10:00-22:00";
1063
+ const phone = data.contactInfo?.find((item) => /phone|电话/i.test(item.channel));
1064
+ return /* @__PURE__ */ jsxs8(Fragment3, { children: [
1065
+ /* @__PURE__ */ jsxs8("section", { className: "sg-card sg-recommend-merchants sg-shop-detail", children: [
1066
+ /* @__PURE__ */ jsx10(ShopGuideHeader, { subtitle: data.brand ?? data.businessCategories.join(" \xB7 ") ?? "\u95E8\u5E97\u8BE6\u60C5" }),
1067
+ /* @__PURE__ */ jsx10("ul", { className: "sg-rm-list", children: /* @__PURE__ */ jsx10("li", { className: "sg-rm-item", children: /* @__PURE__ */ jsx10(MerchantRow, { merchant: data, onSelect: openDetail }) }) }),
1068
+ (hoursText || phone) && /* @__PURE__ */ jsxs8("div", { className: "sg-shop-detail__facts", children: [
1069
+ /* @__PURE__ */ jsxs8("span", { className: "sg-shop-detail__fact", children: [
1070
+ /* @__PURE__ */ jsx10(Clock2, { size: 15, weight: "duotone", "aria-hidden": "true" }),
1071
+ hoursText
1072
+ ] }),
1073
+ phone && /* @__PURE__ */ jsxs8("span", { className: "sg-shop-detail__fact", children: [
1074
+ /* @__PURE__ */ jsx10(Phone2, { size: 15, weight: "duotone", "aria-hidden": "true" }),
1075
+ phone.value
1076
+ ] })
1077
+ ] })
1078
+ ] }),
1079
+ /* @__PURE__ */ jsx10(
1080
+ ShopDetailSheet,
1081
+ {
1082
+ open: sheetOpen,
1083
+ data: sheetData,
1084
+ loading: detailLoading,
1085
+ cardId,
1086
+ isHistory,
1087
+ actionTokens,
1088
+ claimActionId: "promotion.acquire-from-shop-detail",
1089
+ onClose: closeDetail
1090
+ }
1091
+ )
1092
+ ] });
1093
+ }
1094
+ markSelfRendering2(ShopDetailCard);
1095
+ var shop_detail_default = ShopDetailCard;
1096
+
1097
+ // src/client/cards/category-list/index.tsx
1098
+ import { useState as useState8 } from "react";
1099
+ import { CaretDown } from "@phosphor-icons/react";
1100
+ import { sendCardAction as sendCardAction3 } from "@tbox.cn/app-sdk/client";
1101
+
1102
+ // src/client/cards/view.ts
1103
+ function formatDistance(distanceKm) {
1104
+ if (distanceKm === void 0 || distanceKm < 0) return "\u2014";
1105
+ if (distanceKm < 1) return `${Math.round(distanceKm * 1e3)}m`;
1106
+ return `${distanceKm.toFixed(1)} km`;
1107
+ }
1108
+ function deriveLocationLevel(data) {
1109
+ const { location, itemActions } = data;
1110
+ const hasRoute = itemActions.some((a) => a.kind === "link");
1111
+ if (hasRoute) return "route_available";
1112
+ const locationComplete = Boolean(location.displayText);
1113
+ return locationComplete ? "location_only" : "unavailable";
1114
+ }
1115
+ var CATEGORY_ICONS = {
1116
+ // 英文 key
1117
+ food: "\u{1F35C}",
1118
+ restaurant: "\u{1F35C}",
1119
+ dining: "\u{1F35C}",
1120
+ drinks: "\u{1F964}",
1121
+ beverage: "\u{1F964}",
1122
+ fashion: "\u{1F457}",
1123
+ clothing: "\u{1F457}",
1124
+ apparel: "\u{1F457}",
1125
+ beauty: "\u{1F484}",
1126
+ cosmetics: "\u{1F484}",
1127
+ supermarket: "\u{1F6D2}",
1128
+ groceries: "\u{1F6D2}",
1129
+ cinema: "\u{1F3AC}",
1130
+ entertainment: "\u{1F3AE}",
1131
+ kids: "\u{1F9F8}",
1132
+ children: "\u{1F9F8}",
1133
+ parent_child: "\u{1F9F8}",
1134
+ sports: "\u{1F3C3}",
1135
+ fitness: "\u{1F4AA}",
1136
+ electronics: "\u{1F4F1}",
1137
+ digital: "\u{1F4F1}",
1138
+ home: "\u{1F6CB}\uFE0F",
1139
+ furniture: "\u{1F6CB}\uFE0F",
1140
+ jewelry: "\u{1F48D}",
1141
+ gold: "\u{1F48D}",
1142
+ watch: "\u231A",
1143
+ eyewear: "\u{1F453}",
1144
+ books: "\u{1F4DA}",
1145
+ education: "\u{1F4D6}",
1146
+ hotel: "\u{1F3E8}",
1147
+ travel: "\u{1F9F3}",
1148
+ service: "\u{1F9FE}",
1149
+ lifestyle: "\u{1F9FE}",
1150
+ parking: "\u{1F17F}\uFE0F",
1151
+ car: "\u{1F697}",
1152
+ pharmacy: "\u{1F48A}",
1153
+ healthcare: "\u{1F48A}",
1154
+ flower: "\u{1F490}",
1155
+ pet: "\u{1F43E}",
1156
+ exhibition: "\u{1F5BC}\uFE0F",
1157
+ office: "\u{1F3E2}"
1158
+ };
1159
+ var CATEGORY_ICONS_ZH = [
1160
+ ["\u9910\u996E", "\u{1F35C}"],
1161
+ ["\u7F8E\u98DF", "\u{1F35C}"],
1162
+ ["\u5496\u5561", "\u2615"],
1163
+ ["\u8336\u996E", "\u{1F9CB}"],
1164
+ ["\u5976\u8336", "\u{1F9CB}"],
1165
+ ["\u996E\u54C1", "\u{1F964}"],
1166
+ ["\u96F6\u552E", "\u{1F6CD}\uFE0F"],
1167
+ ["\u65F6\u5C1A", "\u{1F457}"],
1168
+ ["\u670D\u88C5", "\u{1F457}"],
1169
+ ["\u5973\u88C5", "\u{1F457}"],
1170
+ ["\u7537\u88C5", "\u{1F9E5}"],
1171
+ ["\u8FD0\u52A8", "\u{1F3C3}"],
1172
+ ["\u5065\u8EAB", "\u{1F4AA}"],
1173
+ ["\u7F8E\u5986", "\u{1F484}"],
1174
+ ["\u62A4\u80A4", "\u{1F9F4}"],
1175
+ ["\u7F8E\u5BB9", "\u{1F486}"],
1176
+ ["\u6BCD\u5A74", "\u{1F9F8}"],
1177
+ ["\u513F\u7AE5", "\u{1F9F8}"],
1178
+ ["\u4EB2\u5B50", "\u{1F9F8}"],
1179
+ ["\u8D85\u5E02", "\u{1F6D2}"],
1180
+ ["\u4FBF\u5229", "\u{1F6D2}"],
1181
+ ["\u751F\u9C9C", "\u{1F966}"],
1182
+ ["\u6570\u7801", "\u{1F4F1}"],
1183
+ ["\u7535\u5B50", "\u{1F4F1}"],
1184
+ ["\u5BB6\u5C45", "\u{1F6CB}\uFE0F"],
1185
+ ["\u5BB6\u7535", "\u{1F50C}"],
1186
+ ["\u73E0\u5B9D", "\u{1F48D}"],
1187
+ ["\u9EC4\u91D1", "\u{1F3C5}"],
1188
+ ["\u624B\u8868", "\u231A"],
1189
+ ["\u773C\u955C", "\u{1F453}"],
1190
+ ["\u4E66\u5E97", "\u{1F4DA}"],
1191
+ ["\u6587\u5177", "\u270F\uFE0F"],
1192
+ ["\u6559\u80B2", "\u{1F4D6}"],
1193
+ ["\u57F9\u8BAD", "\u{1F4D6}"],
1194
+ ["\u5F71\u9662", "\u{1F3AC}"],
1195
+ ["\u7535\u5F71", "\u{1F3AC}"],
1196
+ ["\u5A31\u4E50", "\u{1F3AE}"],
1197
+ ["\u6E38\u620F", "\u{1F3AE}"],
1198
+ ["\u6587\u4F53", "\u{1F3AD}"],
1199
+ ["\u6587\u5316", "\u{1F3A8}"],
1200
+ ["\u827A\u672F", "\u{1F3A8}"],
1201
+ ["\u5BA0\u7269", "\u{1F43E}"],
1202
+ ["\u9C9C\u82B1", "\u{1F490}"],
1203
+ ["\u533B\u7597", "\u{1F48A}"],
1204
+ ["\u836F\u5E97", "\u{1F48A}"],
1205
+ ["\u5065\u5EB7", "\u{1F3E5}"],
1206
+ ["\u9152\u5E97", "\u{1F3E8}"],
1207
+ ["\u65C5\u884C", "\u{1F9F3}"],
1208
+ ["\u505C\u8F66", "\u{1F17F}\uFE0F"],
1209
+ ["\u6C7D\u8F66", "\u{1F697}"],
1210
+ ["\u670D\u52A1", "\u{1F9FE}"],
1211
+ ["\u751F\u6D3B", "\u{1F9FE}"],
1212
+ ["\u94F6\u884C", "\u{1F3E6}"],
1213
+ ["\u91D1\u878D", "\u{1F4B3}"],
1214
+ ["\u672A\u5F52\u7C7B", "\u{1F3EA}"]
1215
+ ];
1216
+ function categoryIcon(code) {
1217
+ const key = code.toLowerCase();
1218
+ if (CATEGORY_ICONS[key]) return CATEGORY_ICONS[key];
1219
+ for (const [k, icon] of Object.entries(CATEGORY_ICONS)) {
1220
+ if (key.startsWith(k)) return icon;
1221
+ }
1222
+ for (const [keyword, icon] of CATEGORY_ICONS_ZH) {
1223
+ if (code.includes(keyword)) return icon;
1224
+ }
1225
+ return "\u{1F3EA}";
1226
+ }
1227
+
1228
+ // src/client/cards/category-list/index.tsx
1229
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
1230
+ var PAGE = 9;
1231
+ function CategoryListCard(props) {
1232
+ const { data, cardId, isHistory } = props;
1233
+ const [expanded, setExpanded] = useState8(false);
1234
+ const collapsible = data.categories.length > PAGE;
1235
+ const visible = collapsible && !expanded ? data.categories.slice(0, PAGE) : data.categories;
1236
+ function handleCategoryClick(c) {
1237
+ if (isHistory) return;
1238
+ const sendAction = c.itemActions?.find((a) => a.kind === "send");
1239
+ sendCardAction3(cardId, {
1240
+ type: "sendMessage",
1241
+ value: sendAction?.value ?? sendAction?.label ?? `\u67E5\u770B${c.name}\u7684\u95E8\u5E97\u5217\u8868`,
1242
+ visible: true
1243
+ });
1244
+ }
1245
+ return /* @__PURE__ */ jsxs9("section", { className: "sg-card sg-category-list", children: [
1246
+ /* @__PURE__ */ jsx11("div", { className: "sg-card-title", children: "\u4E1A\u6001\u5206\u7C7B" }),
1247
+ /* @__PURE__ */ jsx11("ul", { className: "sg-category-grid", children: visible.map((c) => /* @__PURE__ */ jsx11("li", { children: /* @__PURE__ */ jsxs9(
1248
+ "button",
1249
+ {
1250
+ type: "button",
1251
+ className: "sg-category-cell",
1252
+ disabled: isHistory,
1253
+ onClick: () => handleCategoryClick(c),
1254
+ "aria-label": `\u67E5\u770B${c.name}\uFF08${c.merchantCount} \u5BB6\u95E8\u5E97\uFF09`,
1255
+ children: [
1256
+ /* @__PURE__ */ jsx11("span", { className: "sg-category-icon-wrap", "aria-hidden": "true", children: /* @__PURE__ */ jsx11("span", { className: "sg-category-icon", children: categoryIcon(c.code) }) }),
1257
+ /* @__PURE__ */ jsx11("span", { className: "sg-category-name", children: c.name }),
1258
+ c.merchantCount > 0 && /* @__PURE__ */ jsxs9("span", { className: "sg-category-count", children: [
1259
+ c.merchantCount,
1260
+ " \u5BB6"
1261
+ ] })
1262
+ ]
1263
+ }
1264
+ ) }, c.code)) }),
1265
+ collapsible && /* @__PURE__ */ jsxs9(
1266
+ "button",
1267
+ {
1268
+ type: "button",
1269
+ className: "sg-category-toggle",
1270
+ "aria-expanded": expanded,
1271
+ onClick: () => setExpanded((v) => !v),
1272
+ children: [
1273
+ /* @__PURE__ */ jsx11(
1274
+ CaretDown,
1275
+ {
1276
+ size: 14,
1277
+ className: "sg-category-toggle__icon",
1278
+ "data-rotated": expanded || void 0
1279
+ }
1280
+ ),
1281
+ expanded ? "\u6536\u8D77" : `\u5C55\u5F00\u5168\u90E8 ${data.categories.length} \u7C7B`
1282
+ ]
1283
+ }
1284
+ ),
1285
+ data.buildings && data.buildings.length > 0 && /* @__PURE__ */ jsxs9("div", { className: "sg-category-floors", children: [
1286
+ /* @__PURE__ */ jsx11("div", { className: "sg-category-floors__title", children: "\u697C\u5C42\u5BFC\u89C8" }),
1287
+ data.buildings.map((building) => /* @__PURE__ */ jsxs9("div", { className: "sg-category-floors__building", children: [
1288
+ data.buildings.length > 1 && /* @__PURE__ */ jsx11("div", { className: "sg-category-floors__building-name", children: building.buildingName }),
1289
+ /* @__PURE__ */ jsx11("div", { className: "sg-category-floors__floor-list", children: building.floors.map((floor) => /* @__PURE__ */ jsxs9(
1290
+ "button",
1291
+ {
1292
+ type: "button",
1293
+ className: "sg-category-floor-chip",
1294
+ disabled: isHistory,
1295
+ onClick: () => {
1296
+ if (isHistory) return;
1297
+ sendCardAction3(cardId, {
1298
+ type: "sendMessage",
1299
+ value: `\u5C55\u793A\u5546\u573A${building.buildingName}${floor.floorName}\u7684\u95E8\u5E97\u5217\u8868`,
1300
+ visible: true
1301
+ });
1302
+ },
1303
+ children: [
1304
+ /* @__PURE__ */ jsx11("span", { className: "sg-category-floor-chip__name", children: floor.floorName }),
1305
+ floor.merchantCount > 0 && /* @__PURE__ */ jsx11("span", { className: "sg-category-floor-chip__count", children: floor.merchantCount })
1306
+ ]
1307
+ },
1308
+ floor.floorCode
1309
+ )) })
1310
+ ] }, building.buildingCode))
1311
+ ] })
1312
+ ] });
1313
+ }
1314
+ var category_list_default = CategoryListCard;
1315
+
1316
+ // src/client/cards/product-comparison/index.tsx
1317
+ import { useEffect as useEffect3, useState as useState9 } from "react";
1318
+ import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
1319
+ function ProductComparisonCard(props) {
1320
+ const { data } = props;
1321
+ const [stale, setStale] = useState9(false);
1322
+ useEffect3(() => {
1323
+ if (!data.refreshRequiredAt) return;
1324
+ const deadline = new Date(data.refreshRequiredAt).getTime();
1325
+ const delay = Math.max(0, deadline - Date.now());
1326
+ const timer = window.setTimeout(() => setStale(true), delay);
1327
+ return () => window.clearTimeout(timer);
1328
+ }, [data.refreshRequiredAt]);
1329
+ const attrNames = Array.from(new Set(data.products.flatMap((p) => p.attributes.map((a) => a.name))));
1330
+ return /* @__PURE__ */ jsxs10("section", { className: `sg-card sg-product-comparison${stale ? " sg-product-comparison--stale" : ""}`, children: [
1331
+ /* @__PURE__ */ jsx12("div", { className: "sg-card-title", children: "\u5546\u54C1\u5BF9\u6BD4" }),
1332
+ stale && /* @__PURE__ */ jsx12("div", { className: "sg-stale-notice", children: /* @__PURE__ */ jsx12("span", { children: "\u5BF9\u6BD4\u6570\u636E\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u53D1\u8D77\u5BF9\u6BD4" }) }),
1333
+ /* @__PURE__ */ jsx12("div", { className: "sg-compare-wrap", children: /* @__PURE__ */ jsxs10("table", { className: "sg-compare", children: [
1334
+ /* @__PURE__ */ jsx12("thead", { children: /* @__PURE__ */ jsxs10("tr", { children: [
1335
+ /* @__PURE__ */ jsx12("th", { scope: "col", className: "sg-compare__label" }),
1336
+ data.products.map((p) => /* @__PURE__ */ jsxs10("th", { scope: "col", children: [
1337
+ /* @__PURE__ */ jsx12(ImageWithFallback, { src: p.imageUrl, alt: p.name, className: "sg-compare__img", size: 40 }),
1338
+ /* @__PURE__ */ jsx12("div", { className: "sg-compare__name", children: p.name }),
1339
+ /* @__PURE__ */ jsx12("div", { className: "sg-price-sale", children: p.price.sale?.display ?? "\u2014" })
1340
+ ] }, p.productId))
1341
+ ] }) }),
1342
+ /* @__PURE__ */ jsxs10("tbody", { children: [
1343
+ /* @__PURE__ */ jsxs10("tr", { children: [
1344
+ /* @__PURE__ */ jsx12("th", { scope: "row", className: "sg-compare__label", children: "\u5E93\u5B58" }),
1345
+ data.products.map((p) => /* @__PURE__ */ jsx12("td", { children: /* @__PURE__ */ jsx12("span", { className: `sg-availability sg-availability-${p.availability.status}`, children: p.availability.label }) }, p.productId))
1346
+ ] }),
1347
+ attrNames.map((name) => /* @__PURE__ */ jsxs10("tr", { children: [
1348
+ /* @__PURE__ */ jsx12("th", { scope: "row", className: "sg-compare__label", children: name }),
1349
+ data.products.map((p) => {
1350
+ const attr = p.attributes.find((a) => a.name === name);
1351
+ return /* @__PURE__ */ jsx12("td", { className: attr ? "" : "sg-compare__cell-empty", children: attr?.value ?? "\u2014" }, p.productId);
1352
+ })
1353
+ ] }, name))
1354
+ ] })
1355
+ ] }) }),
1356
+ data.products.some((p) => p.caveats.length > 0) && /* @__PURE__ */ jsx12("div", { className: "sg-item-caveats", children: data.products.flatMap((p) => p.caveats.map((c, i) => ({ key: `${p.productId}-${i}`, text: c }))).map(({ key, text }) => /* @__PURE__ */ jsxs10("div", { className: "sg-caveat-item", children: [
1357
+ "\u26A0\uFE0F ",
1358
+ text
1359
+ ] }, key)) }),
1360
+ /* @__PURE__ */ jsx12("span", { className: "sg-compare__stale-marker", hidden: !stale, children: "\u5BF9\u6BD4\u6570\u636E\u53EF\u80FD\u5DF2\u8FC7\u671F" })
1361
+ ] });
1362
+ }
1363
+ var product_comparison_default = ProductComparisonCard;
1364
+
1365
+ // src/client/cards/mall-directory/index.tsx
1366
+ import { useState as useState10 } from "react";
1367
+ import { CaretDown as CaretDown2, Storefront as Storefront2 } from "@phosphor-icons/react";
1368
+ import { sendCardAction as sendCardAction4 } from "@tbox.cn/app-sdk/client";
1369
+ import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
1370
+ function MallDirectoryCard(props) {
1371
+ const { data, cardId, isHistory } = props;
1372
+ const [openBuilding, setOpenBuilding] = useState10(
1373
+ data.buildings.length > 0 ? data.buildings[0].buildingCode : null
1374
+ );
1375
+ return /* @__PURE__ */ jsxs11("section", { className: "sg-card sg-mall-directory", children: [
1376
+ /* @__PURE__ */ jsxs11("div", { className: "sg-card-title", children: [
1377
+ data.mallName,
1378
+ " \xB7 \u697C\u5C42\u76EE\u5F55"
1379
+ ] }),
1380
+ data.buildings.map((b) => {
1381
+ const open = openBuilding === b.buildingCode;
1382
+ return /* @__PURE__ */ jsxs11("div", { className: "sg-dir-building", children: [
1383
+ /* @__PURE__ */ jsxs11(
1384
+ "button",
1385
+ {
1386
+ type: "button",
1387
+ className: "sg-dir-building__head",
1388
+ "aria-expanded": open,
1389
+ onClick: () => setOpenBuilding(open ? null : b.buildingCode),
1390
+ children: [
1391
+ /* @__PURE__ */ jsx13(Storefront2, { size: 18 }),
1392
+ /* @__PURE__ */ jsx13("span", { className: "sg-dir-building__name", children: b.buildingName }),
1393
+ /* @__PURE__ */ jsxs11("span", { className: "sg-dir-building__count", children: [
1394
+ b.floors.length,
1395
+ " \u5C42"
1396
+ ] }),
1397
+ /* @__PURE__ */ jsx13(CaretDown2, { size: 16, className: "sg-dir-building__chevron", "data-rotated": open || void 0 })
1398
+ ]
1399
+ }
1400
+ ),
1401
+ open && /* @__PURE__ */ jsx13("ul", { className: "sg-dir-floors", children: b.floors.map((f) => /* @__PURE__ */ jsxs11("li", { className: "sg-dir-floor", children: [
1402
+ /* @__PURE__ */ jsxs11("div", { className: "sg-dir-floor__info", children: [
1403
+ /* @__PURE__ */ jsx13("span", { className: "sg-dir-floor__name", children: f.floorName }),
1404
+ /* @__PURE__ */ jsx13("span", { className: "sg-dir-floor__cats", children: f.businessCategories.join(" / ") || `${f.merchantCount} \u5BB6\u5546\u6237` })
1405
+ ] }),
1406
+ f.itemActions && f.itemActions.length > 0 && /* @__PURE__ */ jsx13(
1407
+ "button",
1408
+ {
1409
+ type: "button",
1410
+ className: "sg-chip sg-dir-floor__action",
1411
+ disabled: isHistory,
1412
+ onClick: () => {
1413
+ if (isHistory) return;
1414
+ const a = f.itemActions[0];
1415
+ sendCardAction4(
1416
+ cardId,
1417
+ a.kind === "send" ? { type: "sendMessage", value: a.value ?? a.label, visible: true } : { type: "openLink", url: a.url }
1418
+ );
1419
+ },
1420
+ children: f.itemActions[0].label
1421
+ }
1422
+ )
1423
+ ] }, f.floorCode)) })
1424
+ ] }, b.buildingCode);
1425
+ })
1426
+ ] });
1427
+ }
1428
+ var mall_directory_default = MallDirectoryCard;
1429
+
1430
+ // src/client/cards/nearby-mall-list/index.tsx
1431
+ import { ItemActionsRow as ItemActionsRow4 } from "@tbox.cn/app-sdk/client";
1432
+ import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
1433
+ function NearbyMallListCard(props) {
1434
+ const { data, cardId, isHistory } = props;
1435
+ if (data.malls.length === 0) {
1436
+ return /* @__PURE__ */ jsx14("section", { className: "sg-card", children: /* @__PURE__ */ jsx14("div", { className: "sg-empty", children: "\u6682\u65E0\u9644\u8FD1\u5546\u573A" }) });
1437
+ }
1438
+ return /* @__PURE__ */ jsxs12("section", { className: "sg-card sg-nearby-malls", children: [
1439
+ /* @__PURE__ */ jsx14("div", { className: "sg-card-title", children: "\u9644\u8FD1\u5546\u573A" }),
1440
+ data.query && /* @__PURE__ */ jsxs12("div", { className: "sg-card-summary", children: [
1441
+ "\u67E5\u8BE2\u300C",
1442
+ data.query,
1443
+ "\u300D"
1444
+ ] }),
1445
+ /* @__PURE__ */ jsx14("ul", { className: "sg-nearby-list", children: data.malls.map((m) => /* @__PURE__ */ jsxs12("li", { className: "sg-nearby-item", children: [
1446
+ /* @__PURE__ */ jsxs12("div", { className: "sg-nearby-item__head", children: [
1447
+ /* @__PURE__ */ jsx14("span", { className: "sg-merchant-name", children: m.name }),
1448
+ /* @__PURE__ */ jsx14("span", { className: `sg-status sg-status-${m.status.code}`, children: m.status.label })
1449
+ ] }),
1450
+ /* @__PURE__ */ jsxs12("div", { className: "sg-nearby-item__meta", children: [
1451
+ /* @__PURE__ */ jsx14("span", { children: m.address }),
1452
+ /* @__PURE__ */ jsx14("span", { className: "sg-nearby-item__distance", children: formatDistance(m.distanceKm) })
1453
+ ] }),
1454
+ /* @__PURE__ */ jsx14(ItemActionsRow4, { actions: m.itemActions, cardId, isHistory, className: "sg-item-actions", chipClassName: "sg-chip" })
1455
+ ] }, m.mallId)) })
1456
+ ] });
1457
+ }
1458
+ var nearby_mall_list_default = NearbyMallListCard;
1459
+
1460
+ // src/client/cards/human-guide-list/index.tsx
1461
+ import { sendCardAction as sendCardAction5 } from "@tbox.cn/app-sdk/client";
1462
+ import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
1463
+ function HumanGuideListCard(props) {
1464
+ const { data, cardId, isHistory } = props;
1465
+ return /* @__PURE__ */ jsxs13("section", { className: "sg-card sg-human-guide", children: [
1466
+ /* @__PURE__ */ jsxs13("div", { className: "sg-card-title", children: [
1467
+ data.merchantName,
1468
+ " \xB7 \u4EBA\u5DE5\u5BFC\u8D2D"
1469
+ ] }),
1470
+ data.guides.length === 0 ? /* @__PURE__ */ jsx15("div", { className: "sg-empty", children: "\u6682\u65E0\u5BFC\u8D2D\u5458\u4FE1\u606F" }) : /* @__PURE__ */ jsx15("ul", { className: "sg-guide-list", children: data.guides.map((g) => {
1471
+ const contact = g.itemActions[0];
1472
+ const contactDisabled = isHistory || !contact;
1473
+ return /* @__PURE__ */ jsxs13("li", { className: "sg-guide-item", children: [
1474
+ /* @__PURE__ */ jsx15(ImageWithFallback, { src: g.avatarUrl, alt: g.name, className: "sg-guide-avatar", size: 48 }),
1475
+ /* @__PURE__ */ jsxs13("div", { className: "sg-guide-info", children: [
1476
+ /* @__PURE__ */ jsxs13("div", { className: "sg-guide-head", children: [
1477
+ /* @__PURE__ */ jsx15("span", { className: "sg-merchant-name", children: g.name }),
1478
+ /* @__PURE__ */ jsx15("span", { className: `sg-status sg-status-${g.available ? "available" : "offline"}`, children: g.available ? "\u5728\u7EBF" : "\u79BB\u7EBF" })
1479
+ ] }),
1480
+ g.title && /* @__PURE__ */ jsx15("div", { className: "sg-guide-title", children: g.title }),
1481
+ g.contactInfo && g.contactInfo.length > 0 && /* @__PURE__ */ jsx15("div", { className: "sg-guide-channels", children: g.contactInfo.map((c, i) => /* @__PURE__ */ jsx15("span", { className: "sg-guide-channel", children: c.channel }, i)) })
1482
+ ] }),
1483
+ /* @__PURE__ */ jsx15(
1484
+ "button",
1485
+ {
1486
+ type: "button",
1487
+ className: "sg-guide-contact",
1488
+ disabled: contactDisabled,
1489
+ title: contact ? contact.label : "\u6682\u65E0\u53EF\u7528\u7684\u8054\u7CFB\u65B9\u5F0F",
1490
+ onClick: () => {
1491
+ if (!contact || isHistory) return;
1492
+ sendCardAction5(
1493
+ cardId,
1494
+ contact.kind === "send" ? { type: "sendMessage", value: contact.value ?? contact.label, visible: true } : { type: "openLink", url: contact.url }
1495
+ );
1496
+ },
1497
+ children: contact?.label ?? "\u8054\u7CFB"
1498
+ }
1499
+ )
1500
+ ] }, g.guideId);
1501
+ }) }),
1502
+ /* @__PURE__ */ jsx15("p", { className: "sg-guide-privacy", children: "\u5BFC\u8D2D\u4FE1\u606F\u7531\u95E8\u5E97\u63D0\u4F9B\uFF0C\u8054\u7CFB\u65B9\u5F0F\u4EC5\u7528\u4E8E\u672C\u6B21\u54A8\u8BE2" })
1503
+ ] });
1504
+ }
1505
+ var human_guide_list_default = HumanGuideListCard;
1506
+
1507
+ // src/client/cards/location-handoff/index.tsx
1508
+ import { MapPin as MapPin3, NavigationArrow } from "@phosphor-icons/react";
1509
+ import { sendCardAction as sendCardAction6 } from "@tbox.cn/app-sdk/client";
1510
+ import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
1511
+ function LocationHandoffCard(props) {
1512
+ const { data, cardId } = props;
1513
+ const level = deriveLocationLevel({ location: data.location, itemActions: data.itemActions });
1514
+ const navAction = data.itemActions.find((a) => a.kind === "link");
1515
+ return /* @__PURE__ */ jsxs14("section", { className: "sg-card sg-location-handoff", children: [
1516
+ /* @__PURE__ */ jsxs14("div", { className: "sg-card-title", children: [
1517
+ data.merchantName,
1518
+ " \xB7 \u4F4D\u7F6E"
1519
+ ] }),
1520
+ data.mapUrl && /* @__PURE__ */ jsx16(ImageWithFallback, { src: data.mapUrl, alt: `${data.merchantName} \u4F4D\u7F6E\u793A\u610F`, className: "sg-lh-map", size: 88 }),
1521
+ /* @__PURE__ */ jsxs14("div", { className: "sg-lh-address", children: [
1522
+ /* @__PURE__ */ jsx16(MapPin3, { size: 16 }),
1523
+ /* @__PURE__ */ jsx16("span", { children: data.location.displayText })
1524
+ ] }),
1525
+ (data.location.buildingName || data.location.floorName || data.location.unitName) && /* @__PURE__ */ jsxs14("div", { className: "sg-lh-detail", children: [
1526
+ data.location.buildingName && /* @__PURE__ */ jsx16("span", { children: data.location.buildingName }),
1527
+ data.location.floorName && /* @__PURE__ */ jsx16("span", { children: data.location.floorName }),
1528
+ data.location.unitName && /* @__PURE__ */ jsx16("span", { children: data.location.unitName })
1529
+ ] }),
1530
+ level === "route_available" && navAction && /* @__PURE__ */ jsxs14(
1531
+ "button",
1532
+ {
1533
+ type: "button",
1534
+ className: "sg-lh-nav",
1535
+ onClick: () => {
1536
+ sendCardAction6(cardId, { type: "openLink", url: navAction.url });
1537
+ },
1538
+ children: [
1539
+ /* @__PURE__ */ jsx16(NavigationArrow, { size: 16 }),
1540
+ navAction.label
1541
+ ]
1542
+ }
1543
+ )
1544
+ ] });
1545
+ }
1546
+ var location_handoff_default = LocationHandoffCard;
1547
+
1548
+ // src/client/cards/recommend-merchants/index.tsx
1549
+ import { useCallback as useCallback5, useMemo as useMemo3, useState as useState11 } from "react";
1550
+ import { CaretRight as CaretRight2 } from "@phosphor-icons/react";
1551
+ import { Fragment as Fragment4, jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
1552
+ var PREVIEW_ITEM_COUNT2 = 3;
1553
+ function RecommendMerchantsCard(props) {
1554
+ const { data, cardId, isHistory } = props;
1555
+ const [activeTabCode, setActiveTabCode] = useState11("");
1556
+ const [overlay, setOverlay] = useState11({ kind: "closed" });
1557
+ const visibleTabs = useMemo3(() => resolveCategoryTabs(data.categoryTabs, data.items), [data.categoryTabs, data.items]);
1558
+ function getFilteredItems() {
1559
+ if (!activeTabCode) return data.items;
1560
+ const activeTab = visibleTabs.find((tab) => tab.code === activeTabCode);
1561
+ if (!activeTab) return data.items;
1562
+ return data.items.filter((item) => item.businessCategories.includes(activeTab.name));
1563
+ }
1564
+ const filteredItems = getFilteredItems();
1565
+ const previewItems = filteredItems.slice(0, PREVIEW_ITEM_COUNT2);
1566
+ const selectedMerchant = overlay.kind === "detail" ? overlay.merchant : null;
1567
+ const detailData = useMemo3(() => selectedMerchant ? {
1568
+ name: selectedMerchant.name,
1569
+ logoUrl: selectedMerchant.logoUrl,
1570
+ coverUrl: selectedMerchant.coverUrl,
1571
+ brand: selectedMerchant.brand,
1572
+ businessCategories: selectedMerchant.businessCategories,
1573
+ location: selectedMerchant.location,
1574
+ status: selectedMerchant.status,
1575
+ rating: selectedMerchant.rating,
1576
+ avgSpend: selectedMerchant.avgSpend,
1577
+ operatingStatus: selectedMerchant.operatingStatus,
1578
+ description: selectedMerchant.description,
1579
+ contactInfo: selectedMerchant.contactInfo,
1580
+ services: selectedMerchant.services,
1581
+ itemActions: selectedMerchant.itemActions
1582
+ } : null, [selectedMerchant]);
1583
+ const closeOverlay = useCallback5(() => setOverlay({ kind: "closed" }), []);
1584
+ const openDetail = useCallback5((merchant) => {
1585
+ setOverlay({ kind: "detail", merchant });
1586
+ }, []);
1587
+ return /* @__PURE__ */ jsxs15(Fragment4, { children: [
1588
+ /* @__PURE__ */ jsxs15("section", { className: "sg-card sg-recommend-merchants", children: [
1589
+ /* @__PURE__ */ jsx17(ShopGuideHeader, { subtitle: data.summary ?? "\u6309\u54C1\u7C7B\u53D1\u73B0\u503C\u5F97\u901B\u7684\u95E8\u5E97" }),
1590
+ visibleTabs.length > 0 && /* @__PURE__ */ jsxs15("div", { className: "sg-rm-tabs", "aria-label": "\u6309\u95E8\u5E97\u54C1\u7C7B\u7B5B\u9009", children: [
1591
+ /* @__PURE__ */ jsx17(
1592
+ "button",
1593
+ {
1594
+ type: "button",
1595
+ "aria-pressed": !activeTabCode,
1596
+ className: `sg-rm-tab${!activeTabCode ? " sg-rm-tab--active" : ""}`,
1597
+ onClick: () => setActiveTabCode(""),
1598
+ children: /* @__PURE__ */ jsx17("span", { children: "\u5168\u90E8" })
1599
+ }
1600
+ ),
1601
+ visibleTabs.map((tab) => {
1602
+ const isActive = tab.code === activeTabCode;
1603
+ return /* @__PURE__ */ jsx17(
1604
+ "button",
1605
+ {
1606
+ type: "button",
1607
+ "aria-pressed": isActive,
1608
+ className: `sg-rm-tab${isActive ? " sg-rm-tab--active" : ""}`,
1609
+ onClick: () => setActiveTabCode(tab.code),
1610
+ children: /* @__PURE__ */ jsx17("span", { children: tab.name })
1611
+ },
1612
+ tab.code
1613
+ );
1614
+ })
1615
+ ] }),
1616
+ filteredItems.length === 0 ? /* @__PURE__ */ jsx17("div", { className: "sg-empty", children: data.noResultsReason ?? "\u6682\u65F6\u6CA1\u6709\u7B26\u5408\u6761\u4EF6\u7684\u95E8\u5E97" }) : /* @__PURE__ */ jsxs15(Fragment4, { children: [
1617
+ /* @__PURE__ */ jsx17(ShopGuideSectionLabel, {}),
1618
+ /* @__PURE__ */ jsx17("ul", { className: "sg-rm-list", children: previewItems.map((item) => /* @__PURE__ */ jsx17("li", { className: "sg-rm-item", children: /* @__PURE__ */ jsx17(MerchantRow, { merchant: item, onSelect: () => openDetail(item) }) }, item.merchantId)) }),
1619
+ filteredItems.length > PREVIEW_ITEM_COUNT2 && /* @__PURE__ */ jsxs15(
1620
+ "button",
1621
+ {
1622
+ type: "button",
1623
+ className: "sg-rm-view-all",
1624
+ onClick: () => setOverlay({ kind: "list" }),
1625
+ children: [
1626
+ "\u67E5\u770B\u5168\u90E8\u95E8\u5E97",
1627
+ /* @__PURE__ */ jsx17(CaretRight2, { size: 17 })
1628
+ ]
1629
+ }
1630
+ )
1631
+ ] })
1632
+ ] }),
1633
+ /* @__PURE__ */ jsx17(
1634
+ ShopListSheet,
1635
+ {
1636
+ open: overlay.kind === "list",
1637
+ items: data.items,
1638
+ categoryTabs: data.categoryTabs ?? [],
1639
+ activeTabCode,
1640
+ isHistory,
1641
+ onSelect: openDetail,
1642
+ onClose: closeOverlay
1643
+ }
1644
+ ),
1645
+ /* @__PURE__ */ jsx17(
1646
+ ShopDetailSheet,
1647
+ {
1648
+ open: overlay.kind === "detail",
1649
+ data: detailData,
1650
+ cardId,
1651
+ isHistory,
1652
+ onClose: closeOverlay
1653
+ }
1654
+ )
1655
+ ] });
1656
+ }
1657
+ var recommend_merchants_default = RecommendMerchantsCard;
1658
+
1659
+ // src/client/index.ts
1660
+ var cards = {
1661
+ "product-list": product_list_default,
1662
+ "product-detail": product_detail_default,
1663
+ "shop-list": shop_list_default,
1664
+ "shop-detail": shop_detail_default,
1665
+ "category-list": category_list_default,
1666
+ "product-comparison": product_comparison_default,
1667
+ "mall-directory": mall_directory_default,
1668
+ "nearby-mall-list": nearby_mall_list_default,
1669
+ "human-guide-list": human_guide_list_default,
1670
+ "location-handoff": location_handoff_default,
1671
+ "recommend-merchants": recommend_merchants_default
1672
+ };
1673
+ var clientModule = {
1674
+ cards,
1675
+ register(ctx) {
1676
+ ctx.cards.registerMap(cards);
1677
+ }
1678
+ };
1679
+
1680
+ export {
1681
+ clientModule
1682
+ };