@nukleus-sports/ui-patterns 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/team.cjs ADDED
@@ -0,0 +1,1641 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/team/index.ts
21
+ var team_exports = {};
22
+ __export(team_exports, {
23
+ EmptyValue: () => EmptyValue,
24
+ FactField: () => FactField,
25
+ FactPills: () => FactPills,
26
+ FieldLabel: () => FieldLabel,
27
+ RecentGamesWidget: () => RecentGamesWidget,
28
+ SeasonSelector: () => SeasonSelector,
29
+ StatColumn: () => StatColumn,
30
+ StatRankingLeaderboardDialog: () => StatRankingLeaderboardDialog,
31
+ TeamFactsContent: () => TeamFactsContent,
32
+ TeamFactsWidget: () => TeamFactsWidget,
33
+ TeamInfoCard: () => TeamInfoCard,
34
+ TeamSeasonScheduleSummaryPanel: () => TeamSeasonScheduleSummaryPanel,
35
+ TeamSeasonStatsSummaryPanel: () => TeamSeasonStatsSummaryPanel,
36
+ TeamSeasonStatsWidget: () => TeamSeasonStatsWidget,
37
+ TeamStaffTable: () => TeamStaffTable,
38
+ VenuePhoto: () => VenuePhoto
39
+ });
40
+ module.exports = __toCommonJS(team_exports);
41
+
42
+ // src/team/team-info-card.tsx
43
+ var import_ui_web2 = require("@nukleus-sports/ui-web");
44
+ var import_core = require("@nukleus-sports/core");
45
+
46
+ // src/entity-avatar.tsx
47
+ var import_ui_web = require("@nukleus-sports/ui-web");
48
+ var import_jsx_runtime = require("react/jsx-runtime");
49
+ var sizeClasses = {
50
+ xs: "h-4 w-4",
51
+ sm: "h-6 w-6",
52
+ md: "h-8 w-8",
53
+ lg: "h-12 w-12",
54
+ xl: "h-16 w-16",
55
+ "2xl": "h-[120px] w-[120px]",
56
+ "3xl": "h-40 w-40"
57
+ };
58
+ var initialSizeClasses = {
59
+ xs: "text-[8px]",
60
+ sm: "text-xs",
61
+ md: "text-sm",
62
+ lg: "text-base",
63
+ xl: "text-lg",
64
+ "2xl": "text-2xl",
65
+ "3xl": "text-2xl"
66
+ };
67
+ var contactSizeClasses = {
68
+ xs: "h-4 w-4",
69
+ sm: "h-6 w-6",
70
+ md: "h-8 w-8",
71
+ lg: "h-12 w-12",
72
+ xl: "h-16 w-16",
73
+ "2xl": "h-[120px] w-[120px]",
74
+ "3xl": "h-40 w-40"
75
+ };
76
+ var contactInitialSizeClasses = {
77
+ xs: "text-[8px]",
78
+ sm: "text-[10px]",
79
+ md: "text-sm",
80
+ lg: "text-base",
81
+ xl: "text-lg",
82
+ "2xl": "text-2xl",
83
+ "3xl": "text-2xl"
84
+ };
85
+ function EntityAvatar({
86
+ entityType = "initials",
87
+ entityData,
88
+ firstName,
89
+ lastName,
90
+ name,
91
+ imageUrl,
92
+ resolveImageUrl,
93
+ size = "md",
94
+ className,
95
+ fallbackClassName,
96
+ showInitials = true,
97
+ cacheBreaker
98
+ }) {
99
+ const extractedFirstName = firstName || entityData?.first_name || "";
100
+ const extractedLastName = lastName || entityData?.last_name || "";
101
+ const extractedName = name || entityData?.name || "";
102
+ const isSquared = entityType === "team" || entityType === "company";
103
+ const usesContactSizes = entityType === "contact" || entityType === "company" || entityType === "initials";
104
+ const avatarSizeClasses = usesContactSizes ? contactSizeClasses : sizeClasses;
105
+ const initialsSizeClasses = usesContactSizes ? contactInitialSizeClasses : initialSizeClasses;
106
+ const defaultSize = usesContactSizes ? "sm" : "md";
107
+ const effectiveSize = size || defaultSize;
108
+ const getRawImageUrl = () => {
109
+ if (imageUrl) return imageUrl;
110
+ switch (entityType) {
111
+ case "player":
112
+ return entityData?.player_image_url ?? null;
113
+ case "coach":
114
+ return entityData?.coach_image_url ?? null;
115
+ case "team":
116
+ return entityData?.team_logo_url ?? null;
117
+ case "initials":
118
+ case "contact":
119
+ case "company":
120
+ return entityData?.avatar_url ?? null;
121
+ case "agency":
122
+ return entityData?.profile_image_url ?? null;
123
+ default:
124
+ return null;
125
+ }
126
+ };
127
+ const getImageUrl = () => {
128
+ const rawUrl = getRawImageUrl();
129
+ if (!rawUrl) return null;
130
+ if (resolveImageUrl) {
131
+ return resolveImageUrl(rawUrl, { entityType, size: effectiveSize, cacheBreaker });
132
+ }
133
+ if (rawUrl.startsWith("http") || rawUrl.startsWith("data:")) {
134
+ return rawUrl;
135
+ }
136
+ return null;
137
+ };
138
+ const getInitials = () => {
139
+ if (!showInitials) {
140
+ const defaults = {
141
+ player: "P",
142
+ coach: "C",
143
+ team: "T",
144
+ contact: "C",
145
+ company: "C",
146
+ agency: "",
147
+ initials: ""
148
+ };
149
+ return defaults[entityType];
150
+ }
151
+ switch (entityType) {
152
+ case "player":
153
+ case "coach":
154
+ case "agency": {
155
+ const first = extractedFirstName?.[0] || "";
156
+ const last = extractedLastName?.[0] || "";
157
+ const initials2 = (first + last).toUpperCase();
158
+ if (initials2) return initials2;
159
+ if (entityType === "player") return "P";
160
+ if (entityType === "coach") return "C";
161
+ return "?";
162
+ }
163
+ case "team": {
164
+ const teamName = entityData?.team || "";
165
+ const nickname = entityData?.nickname || "";
166
+ const displayName = nickname || teamName || "";
167
+ const words = displayName.trim().split(/\s+/);
168
+ if (words.length >= 2) {
169
+ return (words[0][0] + words[1][0]).toUpperCase();
170
+ } else if (words.length === 1 && words[0].length >= 2) {
171
+ return words[0].substring(0, 2).toUpperCase();
172
+ }
173
+ return "T";
174
+ }
175
+ case "initials": {
176
+ const displayName = extractedName.trim();
177
+ if (!displayName) return "?";
178
+ const nameParts = displayName.trim().split(/\s+/);
179
+ if (nameParts.length >= 2) {
180
+ return (nameParts[0][0] + nameParts[nameParts.length - 1][0]).toUpperCase();
181
+ }
182
+ return displayName.substring(0, 2).toUpperCase();
183
+ }
184
+ case "contact":
185
+ case "company": {
186
+ const displayName = extractedName;
187
+ if (!displayName) return "C";
188
+ const nameParts = displayName.trim().split(/\s+/);
189
+ if (nameParts.length >= 2) {
190
+ if (entityType === "company") {
191
+ return (nameParts[0][0] + nameParts[1][0]).toUpperCase();
192
+ } else {
193
+ return (nameParts[0][0] + nameParts[nameParts.length - 1][0]).toUpperCase();
194
+ }
195
+ }
196
+ return displayName.substring(0, 2).toUpperCase();
197
+ }
198
+ default:
199
+ return "?";
200
+ }
201
+ };
202
+ const getDefaultImageUrl = () => {
203
+ switch (entityType) {
204
+ case "player":
205
+ case "coach":
206
+ return "/images/headshot_default.png";
207
+ case "team":
208
+ return "/images/team_default.png";
209
+ case "contact":
210
+ return "/images/contact_default.png";
211
+ case "company":
212
+ return "/images/company_default.png";
213
+ case "agency":
214
+ return "/images/agency_default.png";
215
+ case "initials":
216
+ return "/images/headshot_default.png";
217
+ default:
218
+ return "/images/headshot_default.png";
219
+ }
220
+ };
221
+ const getAltText = () => {
222
+ switch (entityType) {
223
+ case "player":
224
+ return `${extractedFirstName} ${extractedLastName}`.trim() || "Player avatar";
225
+ case "coach":
226
+ return `${extractedFirstName} ${extractedLastName}`.trim() || "Coach avatar";
227
+ case "team":
228
+ return `${entityData?.team || entityData?.nickname || "Team"} logo`;
229
+ case "initials":
230
+ return `${extractedName}`.trim() || "User avatar";
231
+ case "contact":
232
+ return extractedName || "Profile Picture";
233
+ case "company":
234
+ return extractedName || "Company avatar";
235
+ case "agency":
236
+ return `${extractedFirstName} ${extractedLastName}`.trim() || "User avatar";
237
+ default:
238
+ return "Avatar";
239
+ }
240
+ };
241
+ const processedImageUrl = getImageUrl();
242
+ const defaultImageUrl = getDefaultImageUrl();
243
+ const initials = getInitials();
244
+ const altText = getAltText();
245
+ const hasValidImage = Boolean(
246
+ processedImageUrl && processedImageUrl !== "null" && processedImageUrl !== null && processedImageUrl.trim() !== ""
247
+ );
248
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui_web.Avatar, { className: (0, import_ui_web.cn)(avatarSizeClasses[effectiveSize], isSquared && "rounded-lg", className), children: [
249
+ hasValidImage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui_web.AvatarImage, { src: processedImageUrl, alt: altText }),
250
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
251
+ import_ui_web.AvatarFallback,
252
+ {
253
+ className: (0, import_ui_web.cn)(
254
+ initialsSizeClasses[effectiveSize],
255
+ isSquared && "rounded-lg bg-greys-grey-table-h",
256
+ fallbackClassName
257
+ ),
258
+ children: entityType === "contact" || entityType === "initials" ? initials : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
259
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
260
+ "img",
261
+ {
262
+ src: defaultImageUrl,
263
+ alt: altText,
264
+ className: "aspect-square h-full w-full object-cover"
265
+ }
266
+ ),
267
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: initials })
268
+ ] })
269
+ }
270
+ )
271
+ ] });
272
+ }
273
+
274
+ // src/team/team-info-card.tsx
275
+ var import_jsx_runtime2 = require("react/jsx-runtime");
276
+ var TAB_TRIGGER_CLASS = "flex-1 bg-card text-[13px] text-text-primary data-[state=active]:bg-card data-[state=active]:text-primary-color-nuk-text data-[state=active]:shadow-none border-b border-greys-grey-strokes-tables data-[state=active]:border-primary-color-nuk-ui-elem rounded-none px-0 pb-2 mb-[-1px] relative after:absolute after:left-0 after:-bottom-[1px] after:w-full after:h-[2px] after:content-[''] after:bg-transparent data-[state=active]:after:bg-primary-color-nuk-ui-elem";
277
+ function TeamInfoCard({ team, resolveImageUrl, className }) {
278
+ const teamDisplayName = (0, import_core.formatTeamName)(team.team, team.nickname) || "Team not found";
279
+ const conferenceInfo = team.specificData?.conference || team.specificData?.division ? `${team.specificData.conference || ""} ${team.specificData.division || ""}`.trim() : "";
280
+ const { venue: venueInfo, facility: facilityInfo } = (0, import_core.getTeamPlaceSummaries)(
281
+ team.specificData,
282
+ team.leagueAbbreviation
283
+ );
284
+ const socials = team.specificData?.socials ?? [];
285
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
286
+ import_ui_web2.Card,
287
+ {
288
+ className: (0, import_ui_web2.cn)(
289
+ "p-4 sm:py-4 sm:px-9 w-full xl:w-[420px] flex flex-col overflow-hidden border-none h-full md:min-h-[612px]",
290
+ className
291
+ ),
292
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui_web2.CardContent, { className: "flex flex-col gap-4 items-center p-0", children: [
293
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex sm:flex-col sm:items-center sm:gap-4", children: [
294
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
295
+ EntityAvatar,
296
+ {
297
+ entityType: "team",
298
+ entityData: {
299
+ team: team.team,
300
+ nickname: team.nickname,
301
+ team_logo_url: team.teamLogoUrl
302
+ },
303
+ resolveImageUrl,
304
+ size: "3xl",
305
+ className: "rounded-none",
306
+ fallbackClassName: "text-2xl font-bold"
307
+ }
308
+ ),
309
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex flex-col gap-2 justify-center px-4 sm:items-center", children: [
310
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "text-text-primary text-[24px] font-black sm:player-card-name", children: teamDisplayName }),
311
+ conferenceInfo && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-sm text-text-primary", children: conferenceInfo })
312
+ ] })
313
+ ] }),
314
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui_web2.Tabs, { defaultValue: "info", className: "w-full", children: [
315
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui_web2.TabsList, { className: "grid w-full grid-cols-2 bg-transparent border-b rounded-none h-auto p-0 text-text-primary", children: [
316
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui_web2.TabsTrigger, { value: "info", className: TAB_TRIGGER_CLASS, children: "Info" }),
317
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui_web2.TabsTrigger, { value: "social", className: TAB_TRIGGER_CLASS, children: "Social" })
318
+ ] }),
319
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui_web2.TabsContent, { value: "info", className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "grid grid-cols-[auto_1fr] gap-4", children: [
320
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "text-text-primary body-text", children: [
321
+ venueInfo.label,
322
+ ":"
323
+ ] }) }),
324
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col text-right", children: venueInfo.name ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "text-text-primary body-text", children: [
325
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: venueInfo.name }),
326
+ venueInfo.address && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: venueInfo.address })
327
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-text-primary body-text", children: "No address available" }) }),
328
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "text-text-primary body-text", children: [
329
+ facilityInfo.label,
330
+ ":"
331
+ ] }) }),
332
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col text-right", children: facilityInfo.name ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "text-text-primary body-text", children: [
333
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: facilityInfo.name }),
334
+ facilityInfo.address && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: facilityInfo.address })
335
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-text-primary body-text", children: "No address available" }) }),
336
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-text-primary body-text", children: "Website:" }) }),
337
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col text-right", children: team.officialWebsite ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
338
+ "a",
339
+ {
340
+ href: /^https?:\/\//.test(team.officialWebsite) ? team.officialWebsite : `http://${team.officialWebsite}`,
341
+ target: "_blank",
342
+ rel: "noopener noreferrer",
343
+ className: "text-primary-color-nuk-text body-text inline-flex items-center justify-end gap-1",
344
+ children: [
345
+ team.officialWebsite.replace(/^https?:\/\//, ""),
346
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { className: "w-3 h-3", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
347
+ "path",
348
+ {
349
+ strokeLinecap: "round",
350
+ strokeLinejoin: "round",
351
+ strokeWidth: 2,
352
+ d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
353
+ }
354
+ ) })
355
+ ]
356
+ }
357
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-text-primary body-text", children: "No website available" }) })
358
+ ] }) }),
359
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui_web2.TabsContent, { value: "social", className: "mt-3", children: socials.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-text-primary body-text", children: "No social networks yet." }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col gap-3", children: socials.map((social) => {
360
+ const handle = social.handle || social.url?.split("/").pop() || "";
361
+ const url = social.url || `https://${social.platform.toLowerCase()}.com/${handle}`;
362
+ const displayHandle = handle.startsWith("@") ? handle : `@${handle}`;
363
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
364
+ "div",
365
+ {
366
+ className: "flex items-center justify-between gap-2",
367
+ children: [
368
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-text-primary body-text", children: social.platform }),
369
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
370
+ "a",
371
+ {
372
+ href: url,
373
+ target: "_blank",
374
+ rel: "noopener noreferrer",
375
+ className: "text-primary-color-nuk-text body-text hover:underline line-clamp-2 break-words",
376
+ children: displayHandle
377
+ }
378
+ )
379
+ ]
380
+ },
381
+ `${social.platform}:${social.handle ?? ""}:${social.url ?? ""}`
382
+ );
383
+ }) }) })
384
+ ] })
385
+ ] })
386
+ }
387
+ );
388
+ }
389
+
390
+ // src/team/team-staff-table.tsx
391
+ var import_react = require("react");
392
+ var import_ui_web3 = require("@nukleus-sports/ui-web");
393
+ var import_core2 = require("@nukleus-sports/core");
394
+ var import_jsx_runtime3 = require("react/jsx-runtime");
395
+ var CATEGORY_ORDER = [
396
+ "Head Coaches",
397
+ "Assistant Coaches",
398
+ "Offensive Coaches",
399
+ "Defensive Coaches",
400
+ "Special Teams Coaches"
401
+ ];
402
+ var UNCATEGORIZED_LABEL = "Other Coaches";
403
+ var DEFAULT_SORT = [{ id: "display_order", desc: false }];
404
+ function TeamStaffTable({
405
+ staff,
406
+ loading,
407
+ isError,
408
+ interactive = false,
409
+ onStaffClick,
410
+ sortable = false,
411
+ sorting,
412
+ onSortingChange,
413
+ virtualized = false,
414
+ isSplitLayout = false,
415
+ isCompact = false,
416
+ resolveImageUrl,
417
+ className
418
+ }) {
419
+ const [internalSorting, setInternalSorting] = (0, import_react.useState)(DEFAULT_SORT);
420
+ const activeSorting = sorting ?? internalSorting;
421
+ const handleSortingChange = onSortingChange ?? setInternalSorting;
422
+ const effectiveVirtualized = virtualized && !isSplitLayout;
423
+ const rows = (0, import_react.useMemo)(() => {
424
+ if (staff.length === 0) return [];
425
+ const grouped = /* @__PURE__ */ new Map();
426
+ for (const member of staff) {
427
+ const key = member.position_group || UNCATEGORIZED_LABEL;
428
+ if (!grouped.has(key)) grouped.set(key, []);
429
+ grouped.get(key).push(member);
430
+ }
431
+ grouped.forEach((list, key) => {
432
+ grouped.set(key, (0, import_core2.sortTeamStaff)(list, activeSorting));
433
+ });
434
+ const orderedKeys = [
435
+ ...CATEGORY_ORDER.filter((k) => grouped.has(k)),
436
+ ...Array.from(grouped.keys()).filter((k) => !CATEGORY_ORDER.includes(k))
437
+ ];
438
+ const result = [];
439
+ for (const key of orderedKeys) {
440
+ result.push({
441
+ id: -1 * (result.length + 1),
442
+ first_name: "",
443
+ last_name: "",
444
+ position: null,
445
+ position_group: key,
446
+ coach_image_url: null,
447
+ display_order: 0,
448
+ __isCategoryRow: true,
449
+ __categoryLabel: key
450
+ });
451
+ result.push(...grouped.get(key));
452
+ }
453
+ return result;
454
+ }, [staff, activeSorting]);
455
+ const { visibleItems, sentinelRef, hasMore } = (0, import_ui_web3.useInfiniteList)(rows, {
456
+ resetKey: `${staff.length}|${JSON.stringify(activeSorting)}`
457
+ });
458
+ const displayedRows = effectiveVirtualized ? visibleItems : rows;
459
+ const columns = (0, import_react.useMemo)(() => {
460
+ const activate = (id) => onStaffClick?.(id);
461
+ const interactionProps = (id, ariaLabel) => interactive ? {
462
+ onClick: () => activate(id),
463
+ onKeyDown: (e) => {
464
+ if (e.key === "Enter" || e.key === " ") {
465
+ e.preventDefault();
466
+ activate(id);
467
+ }
468
+ },
469
+ tabIndex: 0,
470
+ role: "button",
471
+ "aria-label": ariaLabel
472
+ } : {};
473
+ const nameHeader = sortable ? (0, import_ui_web3.createClickableSortableHeader)("Name") : "Name";
474
+ const positionHeader = sortable ? (0, import_ui_web3.createClickableSortableHeader)("Position") : "Position";
475
+ return [
476
+ {
477
+ id: "name",
478
+ header: nameHeader,
479
+ accessorFn: (row) => `${row.first_name} ${row.last_name}`,
480
+ cell: ({ row }) => {
481
+ const member = row.original;
482
+ const fullName = `${member.first_name} ${member.last_name}`.trim();
483
+ const labelText = `View ${fullName}'s profile`;
484
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex gap-2 items-center w-full line-clamp-2", children: [
485
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
486
+ "div",
487
+ {
488
+ className: (0, import_ui_web3.cn)("flex items-center justify-center", interactive && "cursor-pointer"),
489
+ ...interactionProps(member.id, labelText),
490
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
491
+ EntityAvatar,
492
+ {
493
+ entityType: "coach",
494
+ entityData: {
495
+ first_name: member.first_name,
496
+ last_name: member.last_name,
497
+ coach_image_url: member.coach_image_url
498
+ },
499
+ resolveImageUrl,
500
+ size: isCompact ? "xs" : "lg"
501
+ }
502
+ )
503
+ }
504
+ ),
505
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
506
+ "div",
507
+ {
508
+ className: (0, import_ui_web3.cn)("line-clamp-2", interactive && "cursor-pointer"),
509
+ ...interactionProps(member.id, labelText),
510
+ children: fullName
511
+ }
512
+ )
513
+ ] });
514
+ },
515
+ meta: { cellSize: isCompact ? "teamMobile" : "xl" }
516
+ },
517
+ {
518
+ id: "position",
519
+ header: positionHeader,
520
+ accessorFn: (row) => row.position || "-",
521
+ cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "flex items-center h-full min-h-[46px]", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
522
+ "span",
523
+ {
524
+ className: (0, import_ui_web3.cn)("line-clamp-2 break-words", interactive && "cursor-pointer"),
525
+ ...interactionProps(
526
+ row.original.id,
527
+ `View ${row.original.first_name} ${row.original.last_name}'s position`
528
+ ),
529
+ children: row.original.position || "-"
530
+ }
531
+ ) }),
532
+ meta: { cellSize: "l" }
533
+ }
534
+ ];
535
+ }, [interactive, onStaffClick, sortable, isCompact, resolveImageUrl]);
536
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "w-full xl:flex xl:h-full xl:flex-1 xl:min-h-0 xl:flex-col xl:overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
537
+ import_ui_web3.BaseTable,
538
+ {
539
+ columns,
540
+ data: displayedRows,
541
+ sorting: sortable ? activeSorting : void 0,
542
+ onSortingChange: sortable ? ((updater) => {
543
+ const next = typeof updater === "function" ? updater(activeSorting) : updater;
544
+ handleSortingChange(next);
545
+ }) : void 0,
546
+ manualSorting: sortable,
547
+ loading,
548
+ emptyMessage: isError ? "Failed to load coaching staff. Please try again." : "No coaches found.",
549
+ pageSize: Math.max(displayedRows.length, 25),
550
+ hidePagination: effectiveVirtualized,
551
+ stickyHeader: true,
552
+ splitLayout: isSplitLayout,
553
+ numberOfColumns: 1,
554
+ splitLayoutGridCols: isCompact ? "!grid-cols-[minmax(120px,120px)_1fr]" : isSplitLayout ? "sm:!grid-cols-[minmax(220px,220px)_1fr]" : "",
555
+ containerClassName: (0, import_ui_web3.cn)("border-0 rounded-none", effectiveVirtualized && "h-full"),
556
+ className: (0, import_ui_web3.cn)(
557
+ "border-none",
558
+ effectiveVirtualized && "h-full min-h-0 w-full xl:flex-1 xl:overflow-hidden",
559
+ className
560
+ ),
561
+ bottomContent: effectiveVirtualized && hasMore ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: sentinelRef, className: "h-px w-full" }) : null,
562
+ getRowBanner: (row) => row.__isCategoryRow ? row.__categoryLabel : null,
563
+ bannerRowClassName: "bg-greys-background-hover hover:bg-greys-background-hover",
564
+ getRowClassName: (row) => row.__isCategoryRow ? "hidden" : ""
565
+ }
566
+ ) });
567
+ }
568
+
569
+ // src/team/stat-column.tsx
570
+ var import_jsx_runtime4 = require("react/jsx-runtime");
571
+ function StatColumn({ label, value, suffix, rankBadge }) {
572
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-col items-center h-full justify-center flex-1 gap-1 sm:gap-3 w-full", children: [
573
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "label-xs-medium text-text-secondary leading-normal opacity-[0.8] ss05", children: label }),
574
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "text-[19px] font-semibold sm:text-[32px] sm:font-bold text-text-primary leading-normal title-text opacity-[0.8]", children: [
575
+ value,
576
+ suffix || ""
577
+ ] }),
578
+ rankBadge
579
+ ] });
580
+ }
581
+
582
+ // src/team/team-season-stats-summary-panel.tsx
583
+ var import_ui_web4 = require("@nukleus-sports/ui-web");
584
+ var import_core3 = require("@nukleus-sports/core");
585
+ var import_jsx_runtime5 = require("react/jsx-runtime");
586
+ function getStatusMessage({
587
+ isSupportedSport,
588
+ selectedYear,
589
+ selectedType,
590
+ isError,
591
+ stats
592
+ }) {
593
+ if (!isSupportedSport) return "Team season stats coming soon.";
594
+ if (!selectedYear || selectedType === null) return "Select a season to view stats.";
595
+ if (isError && !stats) return "Couldn't load season stats. Please try again.";
596
+ if (!stats) return "No season stats for the current season.";
597
+ return null;
598
+ }
599
+ function TeamSeasonStatsSummaryPanel({
600
+ sportId,
601
+ selectedYear,
602
+ selectedType,
603
+ stats,
604
+ loading,
605
+ isError,
606
+ className
607
+ }) {
608
+ const columns = (0, import_core3.getTeamStatColumns)(sportId);
609
+ const statusMessage = loading ? null : getStatusMessage({
610
+ isSupportedSport: (0, import_core3.isSupportedTeamStatsSport)(sportId),
611
+ selectedYear,
612
+ selectedType,
613
+ isError,
614
+ stats
615
+ });
616
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_ui_web4.Card, { className: (0, import_ui_web4.cn)("border-0 p-4 flex flex-col gap-4", className), children: [
617
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui_web4.CardHeader, { className: "p-0", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui_web4.CardTitle, { className: "text-base text-text-primary font-medium leading-normal", children: "Season Stats" }) }),
618
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui_web4.CardContent, { className: "p-0 flex-1 flex justify-center items-center", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex items-center justify-center w-full", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui_web4.Skeleton, { className: "h-4 w-3/4" }) }) : statusMessage ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex items-center justify-center w-full text-14.5 text-text-secondary", children: statusMessage }) : stats && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-full flex flex-col sm:flex-row gap-6 sm:gap-3 justify-between items-center", children: columns.map((col, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
619
+ StatColumn,
620
+ {
621
+ label: col.label,
622
+ value: stats.values[i],
623
+ suffix: col.suffix
624
+ },
625
+ col.label
626
+ )) }) })
627
+ ] });
628
+ }
629
+
630
+ // src/team/team-season-schedule-summary-panel.tsx
631
+ var import_ui_web5 = require("@nukleus-sports/ui-web");
632
+ var import_jsx_runtime6 = require("react/jsx-runtime");
633
+ function TeamSeasonScheduleSummaryPanel({
634
+ selectedYear,
635
+ selectedType,
636
+ summary,
637
+ loading,
638
+ isError,
639
+ className
640
+ }) {
641
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui_web5.Card, { className: (0, import_ui_web5.cn)("border-0 p-4 flex flex-col gap-4", className), children: [
642
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui_web5.CardHeader, { className: "p-0", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui_web5.CardTitle, { className: "text-base text-text-primary font-medium leading-normal", children: "Season Summary" }) }),
643
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui_web5.CardContent, { className: "p-0 flex-1 flex justify-center items-center", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex items-center justify-center w-full", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui_web5.Skeleton, { className: "h-4 w-3/4" }) }) : !selectedYear || selectedType === null ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex items-center justify-center w-full text-14.5 text-text-secondary", children: "Select a season to view summary." }) : isError && !summary ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex items-center justify-center w-full text-14.5 text-text-secondary", children: "Couldn't load the schedule summary. Please try again." }) : !summary ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex items-center justify-center w-full text-14.5 text-text-secondary", children: "No schedule data for the current season." }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w-full flex flex-col sm:flex-row gap-6 sm:gap-3 justify-between items-center", children: [
644
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StatColumn, { label: "Record", value: summary.record }),
645
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
646
+ StatColumn,
647
+ {
648
+ label: "Games Played",
649
+ value: `${summary.gamesPlayed} of ${summary.totalGames}`
650
+ }
651
+ )
652
+ ] }) })
653
+ ] });
654
+ }
655
+
656
+ // src/team/season-selector.tsx
657
+ var import_ui_web6 = require("@nukleus-sports/ui-web");
658
+ var import_jsx_runtime7 = require("react/jsx-runtime");
659
+ function SeasonSelector({
660
+ years,
661
+ types,
662
+ selectedYear,
663
+ selectedType,
664
+ onYearChange,
665
+ onTypeChange,
666
+ hideTypeOnMobile = false,
667
+ className
668
+ }) {
669
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: (0, import_ui_web6.cn)("flex gap-3", className), children: [
670
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
671
+ import_ui_web6.Select,
672
+ {
673
+ value: selectedYear?.toString() ?? "",
674
+ onValueChange: (value) => onYearChange(Number(value)),
675
+ children: [
676
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui_web6.SelectTrigger, { variant: "widget", size: "widget", "aria-label": "Season year", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui_web6.SelectValue, { placeholder: "Select year" }) }),
677
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
678
+ import_ui_web6.SelectContent,
679
+ {
680
+ className: "bg-card border-border z-50 [&_.checkbox]:!flex",
681
+ classNameViewPort: "gap-2",
682
+ children: years.map((year) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui_web6.SelectItem, { value: year.value.toString(), className: "min-h-8", children: year.label }, year.value))
683
+ }
684
+ )
685
+ ]
686
+ }
687
+ ),
688
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: (0, import_ui_web6.cn)(hideTypeOnMobile && "hidden sm:block"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
689
+ import_ui_web6.Select,
690
+ {
691
+ value: selectedType?.toString() ?? "",
692
+ onValueChange: (value) => onTypeChange(Number(value)),
693
+ disabled: selectedYear === null,
694
+ children: [
695
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui_web6.SelectTrigger, { variant: "widget", size: "widget", "aria-label": "Season type", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui_web6.SelectValue, { placeholder: "Select type" }) }),
696
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
697
+ import_ui_web6.SelectContent,
698
+ {
699
+ className: "bg-card border-border z-50 [&_.checkbox]:!flex",
700
+ classNameViewPort: "gap-2",
701
+ children: types.map((type) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui_web6.SelectItem, { value: type.value.toString(), className: "min-h-8", children: type.label }, type.value))
702
+ }
703
+ )
704
+ ]
705
+ }
706
+ ) })
707
+ ] });
708
+ }
709
+
710
+ // src/team/fact-pills.tsx
711
+ var import_react2 = require("react");
712
+ var import_ui_web7 = require("@nukleus-sports/ui-web");
713
+ var import_jsx_runtime8 = require("react/jsx-runtime");
714
+ var MAX_ROWS = 2;
715
+ var KEY_SEPARATOR = "";
716
+ var PILL_CLASS = "flex min-w-0 max-w-full shrink-0 items-center justify-center rounded-[6px] bg-greys-background-hover px-2 py-0.5 label-xs-table font-ss02-ss05 text-text-primary";
717
+ var TOGGLE_CLASS = "flex shrink-0 items-center py-0.5 label-xs-table font-ss02-ss05 text-primary-color-nuk-text hover:underline focus-visible:underline focus-visible:outline-none";
718
+ function pillKeys(items) {
719
+ const seen = /* @__PURE__ */ new Map();
720
+ return items.map((item) => {
721
+ const text = String(item);
722
+ const count = seen.get(text) ?? 0;
723
+ seen.set(text, count + 1);
724
+ return `${text}${KEY_SEPARATOR}${count}`;
725
+ });
726
+ }
727
+ function FactPills({ items, capped = false }) {
728
+ const listId = (0, import_react2.useId)();
729
+ const listRef = (0, import_react2.useRef)(null);
730
+ const [expanded, setExpanded] = (0, import_react2.useState)(false);
731
+ const [visibleCount, setVisibleCount] = (0, import_react2.useState)(null);
732
+ const [clipHeight, setClipHeight] = (0, import_react2.useState)(null);
733
+ const [width, setWidth] = (0, import_react2.useState)(0);
734
+ const contentKey = items.join(KEY_SEPARATOR);
735
+ const keys = pillKeys(items);
736
+ const collapsible = capped && !expanded;
737
+ (0, import_react2.useLayoutEffect)(() => {
738
+ const list = listRef.current;
739
+ if (!capped || !list || typeof ResizeObserver === "undefined") return;
740
+ const observer = new ResizeObserver((entries) => {
741
+ const next = Math.round(entries[0]?.contentRect.width ?? 0);
742
+ setWidth((prev) => prev === next ? prev : next);
743
+ });
744
+ observer.observe(list);
745
+ return () => observer.disconnect();
746
+ }, [capped]);
747
+ const measurementKey = `${width}:${contentKey}`;
748
+ const [measuredFor, setMeasuredFor] = (0, import_react2.useState)(measurementKey);
749
+ if (measuredFor !== measurementKey) {
750
+ setMeasuredFor(measurementKey);
751
+ if (visibleCount !== null) setVisibleCount(null);
752
+ }
753
+ (0, import_react2.useLayoutEffect)(() => {
754
+ const list = listRef.current;
755
+ if (!collapsible || !list) return;
756
+ const children = Array.from(list.children).filter(
757
+ (el) => el instanceof HTMLElement
758
+ );
759
+ const first = children[0];
760
+ if (!first || first.offsetHeight === 0) return;
761
+ const rowGap = Number.parseFloat(getComputedStyle(list).rowGap) || 0;
762
+ const rowStep = first.offsetHeight + rowGap;
763
+ const lastRowTop = first.offsetTop + rowStep * (MAX_ROWS - 1);
764
+ const fits = (el) => el.offsetTop <= lastRowTop + 1;
765
+ if (visibleCount === null) {
766
+ const nextClip = Math.ceil(rowStep * MAX_ROWS - rowGap);
767
+ setClipHeight((prev) => prev === nextClip ? prev : nextClip);
768
+ const fitting = children.filter(fits).length;
769
+ if (fitting < items.length) setVisibleCount(fitting);
770
+ return;
771
+ }
772
+ const toggle = children[children.length - 1];
773
+ if (toggle && !fits(toggle)) {
774
+ setVisibleCount((prev) => prev !== null && prev > 0 ? prev - 1 : prev);
775
+ }
776
+ }, [collapsible, visibleCount, contentKey, items.length, width]);
777
+ const truncated = collapsible && visibleCount !== null && visibleCount < items.length;
778
+ const shownCount = truncated ? visibleCount : items.length;
779
+ const handleShowMore = () => setExpanded(true);
780
+ const handleShowLess = () => {
781
+ setExpanded(false);
782
+ setVisibleCount(null);
783
+ };
784
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
785
+ "ul",
786
+ {
787
+ id: listId,
788
+ ref: listRef,
789
+ className: (0, import_ui_web7.cn)(
790
+ "flex w-full flex-wrap content-start items-start gap-1",
791
+ collapsible && "overflow-hidden"
792
+ ),
793
+ style: collapsible && clipHeight !== null ? { maxHeight: clipHeight } : void 0,
794
+ children: [
795
+ items.slice(0, shownCount).map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { className: PILL_CLASS, title: String(item), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "truncate", children: item }) }, keys[index])),
796
+ truncated && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { className: "flex shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
797
+ "button",
798
+ {
799
+ type: "button",
800
+ className: TOGGLE_CLASS,
801
+ "aria-expanded": false,
802
+ "aria-controls": listId,
803
+ onClick: handleShowMore,
804
+ children: "Show More"
805
+ }
806
+ ) }),
807
+ capped && expanded && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { className: "flex shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
808
+ "button",
809
+ {
810
+ type: "button",
811
+ className: TOGGLE_CLASS,
812
+ "aria-expanded": true,
813
+ "aria-controls": listId,
814
+ onClick: handleShowLess,
815
+ children: "Show Less"
816
+ }
817
+ ) })
818
+ ]
819
+ }
820
+ );
821
+ }
822
+
823
+ // src/team/fact-field.tsx
824
+ var import_ui_web8 = require("@nukleus-sports/ui-web");
825
+ var import_core4 = require("@nukleus-sports/core");
826
+ var import_jsx_runtime9 = require("react/jsx-runtime");
827
+ function numberFact(facts, key) {
828
+ const value = facts[key];
829
+ return typeof value === "number" ? value : null;
830
+ }
831
+ function listFact(facts, key) {
832
+ const value = facts[key];
833
+ return Array.isArray(value) ? value : [];
834
+ }
835
+ function textFact(facts, key) {
836
+ const value = facts[key];
837
+ return typeof value === "string" ? value : null;
838
+ }
839
+ function EmptyValue({ children = import_core4.EMPTY_FACT_VALUE }) {
840
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "body-text font-ss02-ss05 text-text-secondary", children });
841
+ }
842
+ function FieldLabel({ children }) {
843
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "w-full label-xs-text font-ss02-ss05 text-text-secondary", children });
844
+ }
845
+ function CountFact({
846
+ factKey,
847
+ data
848
+ }) {
849
+ const { facts, config } = data;
850
+ const pairedYears = import_core4.TEAM_FACT_YEAR_PAIRS[factKey];
851
+ const years = pairedYears ? (0, import_core4.formatYearPills)(listFact(facts, pairedYears), config.formatChampionshipYear) : [];
852
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex min-w-0 flex-col items-start gap-1", children: [
853
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FieldLabel, { children: config.labels[factKey] }),
854
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "stat-count-number title-text text-text-primary", children: (0, import_core4.formatTeamFactNumber)("count", numberFact(facts, factKey)) }),
855
+ years.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FactPills, { items: years, capped: true })
856
+ ] });
857
+ }
858
+ function RivalValue({
859
+ rival,
860
+ resolveImageUrl,
861
+ getRivalHref
862
+ }) {
863
+ switch (rival.status) {
864
+ case "none":
865
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EmptyValue, {});
866
+ case "loading":
867
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui_web8.Skeleton, { className: "h-8 w-40", "aria-label": "Loading rival" });
868
+ case "error":
869
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EmptyValue, { children: "Couldn't load the rival team" });
870
+ case "ready": {
871
+ const content = /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
872
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
873
+ EntityAvatar,
874
+ {
875
+ entityType: "initials",
876
+ name: rival.rival.name,
877
+ imageUrl: rival.rival.teamLogoUrl,
878
+ resolveImageUrl,
879
+ size: "md",
880
+ className: "shrink-0"
881
+ }
882
+ ),
883
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "min-w-0", children: rival.rival.name })
884
+ ] });
885
+ const className = "inline-flex max-w-full items-center gap-1.5 body-text-semibold font-ss02-ss05 text-primary-color-nuk-text";
886
+ return getRivalHref ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("a", { href: getRivalHref(rival.rival.id), className: (0, import_ui_web8.cn)(className, "hover:underline"), children: content }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className, children: content });
887
+ }
888
+ }
889
+ }
890
+ function factValue(factKey, layout, data, resolveImageUrl, getRivalHref) {
891
+ const { facts, config } = data;
892
+ const kind = import_core4.TEAM_FACT_KINDS[factKey];
893
+ if (kind === "number" || kind === "year" || kind === "text") {
894
+ const display = kind === "text" ? textFact(facts, factKey) : (0, import_core4.formatTeamFactNumber)(kind, numberFact(facts, factKey));
895
+ const isEmpty = !display || display === import_core4.EMPTY_FACT_VALUE;
896
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
897
+ "span",
898
+ {
899
+ className: (0, import_ui_web8.cn)(
900
+ "w-full header-xl-medium-card font-ss02-ss05 [overflow-wrap:anywhere]",
901
+ isEmpty ? "text-text-secondary" : "text-text-primary"
902
+ ),
903
+ children: display ?? import_core4.EMPTY_FACT_VALUE
904
+ }
905
+ );
906
+ }
907
+ if (kind === "years" || kind === "labeled_years" || kind === "list") {
908
+ const raw = listFact(facts, factKey);
909
+ const items = kind === "years" ? (0, import_core4.formatYearPills)(raw, config.formatChampionshipYear) : raw;
910
+ return items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FactPills, { items, capped: layout === "grid" }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EmptyValue, {});
911
+ }
912
+ if (kind === "rival") {
913
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
914
+ RivalValue,
915
+ {
916
+ rival: data.rival,
917
+ resolveImageUrl,
918
+ getRivalHref
919
+ }
920
+ );
921
+ }
922
+ const text = textFact(facts, factKey);
923
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
924
+ "p",
925
+ {
926
+ className: (0, import_ui_web8.cn)(
927
+ "w-full body-text font-ss02-ss05 whitespace-pre-line",
928
+ text ? "text-text-primary" : "text-text-secondary"
929
+ ),
930
+ children: text ?? import_core4.EMPTY_FACT_VALUE
931
+ }
932
+ );
933
+ }
934
+ function FactField({
935
+ factKey,
936
+ layout,
937
+ data,
938
+ resolveImageUrl,
939
+ getRivalHref
940
+ }) {
941
+ const kind = import_core4.TEAM_FACT_KINDS[factKey];
942
+ if (kind === "count") return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CountFact, { factKey, data });
943
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
944
+ "div",
945
+ {
946
+ className: (0, import_ui_web8.cn)(
947
+ "flex min-w-0 flex-col items-start gap-1.5",
948
+ layout === "row" && "flex-1",
949
+ layout === "grid" && kind !== "list" && "gap-1"
950
+ ),
951
+ children: [
952
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FieldLabel, { children: data.config.labels[factKey] }),
953
+ factValue(factKey, layout, data, resolveImageUrl, getRivalHref)
954
+ ]
955
+ }
956
+ );
957
+ }
958
+
959
+ // src/team/venue-photo.tsx
960
+ var import_react3 = require("react");
961
+ var import_ui_web9 = require("@nukleus-sports/ui-web");
962
+ var import_icons = require("@nukleus-sports/icons");
963
+ var import_core5 = require("@nukleus-sports/core");
964
+ var import_jsx_runtime10 = require("react/jsx-runtime");
965
+ var PHOTO_WIDTHS = [640, 960, 1280];
966
+ var PHOTO_SIZES = "(min-width: 1280px) 420px, 100vw";
967
+ var LINK_CLASS = "inline-flex shrink-0 items-center gap-1 hover:text-text-primary";
968
+ function NewTabNote() {
969
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "sr-only", children: " (opens in a new tab)" });
970
+ }
971
+ function resolvePhotoSources(path, resolveImageUrl) {
972
+ const candidates = PHOTO_WIDTHS.flatMap((width) => {
973
+ const url = resolveImageUrl(path, width);
974
+ return url ? [{ url, width }] : [];
975
+ });
976
+ return {
977
+ original: resolveImageUrl(path) ?? void 0,
978
+ srcSet: candidates.length ? candidates.map(({ url, width }) => `${url} ${width}w`).join(", ") : void 0,
979
+ resized: resolveImageUrl(path, 960) ?? candidates[0]?.url
980
+ };
981
+ }
982
+ function VenueNameOnly({ name, label }) {
983
+ if (!name) return null;
984
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex min-w-0 flex-col items-start gap-1.5", children: [
985
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FieldLabel, { children: label }),
986
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "w-full header-xl-medium-card font-ss02-ss05 text-text-primary", children: name })
987
+ ] });
988
+ }
989
+ function PhotoCaption({ name, image }) {
990
+ const credit = (0, import_core5.facilityImageCredit)(image);
991
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("figcaption", { className: "flex w-full flex-col gap-1 xxs-body-text font-ss02-ss05", children: [
992
+ name && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "w-full text-text-primary", children: name }),
993
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex w-full items-start gap-2 text-greys-text-secondary", children: [
994
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "min-w-0 flex-1", children: credit ? `Photo: ${credit}` : "Photo from Wikimedia Commons" }),
995
+ image.sourceUrl && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
996
+ "a",
997
+ {
998
+ href: image.sourceUrl,
999
+ target: "_blank",
1000
+ rel: "noopener noreferrer",
1001
+ className: LINK_CLASS,
1002
+ children: [
1003
+ "Source",
1004
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(NewTabNote, {}),
1005
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { "aria-hidden": "true", className: "flex shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1006
+ import_icons.XsViewInvoiceIcon,
1007
+ {
1008
+ width: 16,
1009
+ height: 16,
1010
+ className: "shrink-0 text-greys-ui-elem-strokes"
1011
+ }
1012
+ ) })
1013
+ ]
1014
+ }
1015
+ ),
1016
+ image.licenseUrl && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1017
+ "a",
1018
+ {
1019
+ href: image.licenseUrl,
1020
+ target: "_blank",
1021
+ rel: "noopener noreferrer",
1022
+ className: LINK_CLASS,
1023
+ children: [
1024
+ "License",
1025
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(NewTabNote, {})
1026
+ ]
1027
+ }
1028
+ )
1029
+ ] })
1030
+ ] });
1031
+ }
1032
+ function VenuePhoto({ venue, label, resolveImageUrl }) {
1033
+ const { name, image } = venue;
1034
+ const [failed, setFailed] = (0, import_react3.useState)("none");
1035
+ const [isLoaded, setIsLoaded] = (0, import_react3.useState)(false);
1036
+ const sources = image && resolveImageUrl ? resolvePhotoSources(image.path, resolveImageUrl) : null;
1037
+ const useResized = failed === "none" && Boolean(sources?.srcSet);
1038
+ const src = failed === "all" ? void 0 : useResized ? sources?.resized : sources?.original;
1039
+ if (!image || !src) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(VenueNameOnly, { name, label });
1040
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("figure", { className: "flex w-full flex-col gap-3", children: [
1041
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1042
+ "img",
1043
+ {
1044
+ src,
1045
+ srcSet: useResized ? sources?.srcSet : void 0,
1046
+ sizes: useResized ? PHOTO_SIZES : void 0,
1047
+ onLoad: () => setIsLoaded(true),
1048
+ onError: () => setFailed(useResized ? "resized" : "all"),
1049
+ alt: name ?? label,
1050
+ className: (0, import_ui_web9.cn)(
1051
+ "h-[150px] w-full rounded-[8px] bg-greys-background-hover object-cover",
1052
+ !isLoaded && "animate-pulse"
1053
+ ),
1054
+ loading: "lazy"
1055
+ }
1056
+ ),
1057
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PhotoCaption, { name, image })
1058
+ ] });
1059
+ }
1060
+
1061
+ // src/team/team-facts-content.tsx
1062
+ var import_core6 = require("@nukleus-sports/core");
1063
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1064
+ var SECTION_FIELDS_CLASS = {
1065
+ grid: "grid grid-cols-2 items-start gap-3",
1066
+ row: "flex items-start gap-3",
1067
+ column: "flex flex-col gap-3"
1068
+ };
1069
+ var SECTION_CLASS = (
1070
+ // 11px + the 1px border = a 12px inset.
1071
+ "flex w-full min-w-0 flex-col gap-3 overflow-hidden rounded-[10px] border border-greys-grey-strokes-tables bg-greys-light-grey p-3"
1072
+ );
1073
+ function TeamFactsContent({
1074
+ data,
1075
+ resolveImageUrl,
1076
+ resolveVenuePhotoUrl,
1077
+ getRivalHref
1078
+ }) {
1079
+ const { config, venue, hasFacts } = data;
1080
+ const photo = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1081
+ VenuePhoto,
1082
+ {
1083
+ venue,
1084
+ label: config.venue.label,
1085
+ resolveImageUrl: resolveVenuePhotoUrl
1086
+ },
1087
+ venue.image?.path ?? "none"
1088
+ );
1089
+ if (!hasFacts) {
1090
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-col gap-3", children: [
1091
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex h-[120px] items-center justify-center rounded-[10px] border border-dashed border-greys-grey-strokes-tables text-14.5 text-text-secondary", children: "No team facts yet." }),
1092
+ (venue.image || venue.name) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("section", { className: SECTION_CLASS, children: photo })
1093
+ ] });
1094
+ }
1095
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex flex-col gap-3", children: config.sections.map((section) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("section", { "aria-label": section.title, className: SECTION_CLASS, children: [
1096
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { className: "label-xs-semibold-text font-ss02-ss05 uppercase text-greys-text-secondary", children: section.title }),
1097
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: SECTION_FIELDS_CLASS[section.layout], children: (0, import_core6.teamFactsDisplayFields)(section).map((key) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1098
+ FactField,
1099
+ {
1100
+ factKey: key,
1101
+ layout: section.layout,
1102
+ data,
1103
+ resolveImageUrl,
1104
+ getRivalHref
1105
+ },
1106
+ key
1107
+ )) }),
1108
+ section.showsVenuePhoto && photo
1109
+ ] }, section.title)) });
1110
+ }
1111
+
1112
+ // src/team/team-facts-widget.tsx
1113
+ var import_ui_web10 = require("@nukleus-sports/ui-web");
1114
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1115
+ var SKELETON_KEYS = ["trophy-case", "tradition", "profile"];
1116
+ function TeamFactsWidget({
1117
+ state,
1118
+ resolveImageUrl,
1119
+ resolveVenuePhotoUrl,
1120
+ getRivalHref,
1121
+ className
1122
+ }) {
1123
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1124
+ import_ui_web10.Card,
1125
+ {
1126
+ className: (0, import_ui_web10.cn)(
1127
+ "flex w-full min-w-0 flex-col gap-3 rounded-[10px] border-0 px-4 pb-[22px] pt-4",
1128
+ // Matches the Team Info card's desktop height (TeamInfoCard `md:min-h-[612px]`).
1129
+ "xl:min-h-[612px] xl:self-stretch xl:[contain:size]",
1130
+ className
1131
+ ),
1132
+ children: [
1133
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui_web10.CardHeader, { className: "flex h-8 shrink-0 flex-row items-center p-0", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui_web10.CardTitle, { className: "header-xl-medium-card font-ss02-ss05 text-text-primary", children: "Team Facts" }) }),
1134
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui_web10.CardContent, { className: "p-0 xl:min-h-0 xl:flex-1 xl:overflow-y-auto xl:[scrollbar-width:none] xl:[&::-webkit-scrollbar]:hidden", children: [
1135
+ state.status === "loading" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex flex-col gap-3", role: "status", "aria-label": "Loading team facts", children: SKELETON_KEYS.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui_web10.Skeleton, { className: "h-[200px] w-full rounded-[10px]" }, key)) }),
1136
+ state.status === "error" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1137
+ "div",
1138
+ {
1139
+ role: "alert",
1140
+ className: "flex h-[120px] flex-col items-center justify-center gap-2 text-14.5 text-text-secondary",
1141
+ children: [
1142
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "Couldn't load team facts." }),
1143
+ state.devMessage && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "xxs-body-text", children: state.devMessage }),
1144
+ state.retry && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui_web10.Button, { type: "button", variant: "outline", size: "sm", onClick: state.retry, children: "Try again" })
1145
+ ]
1146
+ }
1147
+ ),
1148
+ state.status === "ready" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1149
+ TeamFactsContent,
1150
+ {
1151
+ data: state.data,
1152
+ resolveImageUrl,
1153
+ resolveVenuePhotoUrl,
1154
+ getRivalHref
1155
+ },
1156
+ state.data.teamId
1157
+ )
1158
+ ] })
1159
+ ]
1160
+ }
1161
+ );
1162
+ }
1163
+
1164
+ // src/team/stat-ranking-leaderboard-dialog.tsx
1165
+ var import_react4 = require("react");
1166
+ var import_ui_web11 = require("@nukleus-sports/ui-web");
1167
+ var import_icons2 = require("@nukleus-sports/icons");
1168
+ var import_core7 = require("@nukleus-sports/core");
1169
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1170
+ var PAGE_BUTTON_BASE = "background";
1171
+ var PAGE_BUTTON_DESKTOP = "!h-[32px] !w-[32px] p-[6px]";
1172
+ var PAGE_BUTTON_MOBILE = "!h-11 !w-11 p-3 !outline-0 !border-0 !bg-inherit";
1173
+ var HIGHLIGHT_CLASS = "text-semantic-color-status-priority-completed-copy bg-primary-color-total-row-table-2";
1174
+ function formatRank(rank, tied) {
1175
+ return tied ? `T-${(0, import_core7.toOrdinal)(rank)}` : (0, import_core7.toOrdinal)(rank);
1176
+ }
1177
+ function Footnotes({ notes }) {
1178
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { children: notes.map((note) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: "alert-text-italic text-text-secondary", children: [
1179
+ "* ",
1180
+ note
1181
+ ] }, note)) });
1182
+ }
1183
+ function Pagination({ page, totalPages, isCountKnown, isSm, onPageChange }) {
1184
+ const buttonClass = (0, import_ui_web11.cn)(PAGE_BUTTON_BASE, isSm ? PAGE_BUTTON_DESKTOP : PAGE_BUTTON_MOBILE);
1185
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center justify-between", children: [
1186
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "label-xs-text text-text-secondary", children: isCountKnown ? `Page ${page} of ${totalPages}` : `Page ${page}` }),
1187
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-3", children: [
1188
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1189
+ import_ui_web11.Button,
1190
+ {
1191
+ variant: "secondary-greys",
1192
+ size: "sm",
1193
+ className: buttonClass,
1194
+ onClick: () => onPageChange(Math.max(1, page - 1)),
1195
+ disabled: page === 1,
1196
+ "aria-label": "Go to previous page",
1197
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons2.ChevronLeftIcon, { className: "h-4 w-4" })
1198
+ }
1199
+ ),
1200
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1201
+ import_ui_web11.Button,
1202
+ {
1203
+ variant: "secondary-greys",
1204
+ size: "sm",
1205
+ className: buttonClass,
1206
+ onClick: () => onPageChange(Math.min(totalPages, page + 1)),
1207
+ disabled: !isCountKnown || page >= totalPages,
1208
+ "aria-label": "Go to next page",
1209
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons2.ChevronRightIcon, { className: "h-4 w-4" })
1210
+ }
1211
+ )
1212
+ ] })
1213
+ ] });
1214
+ }
1215
+ function useLeaderboardColumns(entityLabel, statLabel, formatValue, isSm) {
1216
+ return (0, import_react4.useMemo)(
1217
+ () => [
1218
+ {
1219
+ accessorKey: "rank",
1220
+ header: "Rank",
1221
+ // BaseTable already wraps every cell in its own <TableCell>; returning another here would
1222
+ // nest <td>s. Column styling goes through rowCellClassName (the row highlight is the
1223
+ // table's getRowClassName).
1224
+ meta: { cellSize: "xs", rowCellClassName: "tabular-nums" },
1225
+ cell: ({ row }) => formatRank(row.original.rank, row.original.tied)
1226
+ },
1227
+ {
1228
+ accessorKey: "entityName",
1229
+ header: entityLabel,
1230
+ meta: { cellSize: isSm ? "xxl" : "m" },
1231
+ cell: ({ row }) => row.original.entityName
1232
+ },
1233
+ {
1234
+ accessorKey: "value",
1235
+ header: () => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-right text-wrap line-clamp-2", title: statLabel, children: statLabel }),
1236
+ meta: {
1237
+ cellSize: isSm ? "m" : "xs",
1238
+ rowCellClassName: "text-right tabular-nums break-all"
1239
+ },
1240
+ cell: ({ row }) => formatValue(row.original.value)
1241
+ }
1242
+ ],
1243
+ [entityLabel, statLabel, formatValue, isSm]
1244
+ );
1245
+ }
1246
+ function LeaderboardTable(props) {
1247
+ const { rows, highlightEntityId, pageSize, loading, isError, isConfigError } = props;
1248
+ const columns = useLeaderboardColumns(
1249
+ props.entityLabel,
1250
+ props.statLabel,
1251
+ props.formatValue,
1252
+ props.isSm
1253
+ );
1254
+ if (isConfigError) {
1255
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex items-center justify-center h-full text-14.5 text-text-secondary", children: "Couldn't load ranking details. Please try again." });
1256
+ }
1257
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
1258
+ isError && rows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-12 text-destructive px-1 pb-2", children: "Couldn't refresh rankings. Showing the last loaded data." }),
1259
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1260
+ import_ui_web11.BaseTable,
1261
+ {
1262
+ columns,
1263
+ data: rows,
1264
+ loading,
1265
+ pageSize,
1266
+ stickyHeader: true,
1267
+ numberOfColumns: 2,
1268
+ tableClassName: "!border-separate border-spacing-0 !overflow-visible",
1269
+ containerClassName: "border-0 rounded-none w-full !overflow-visible [&_div.overflow-auto]:!overflow-visible [&_div.overflow-auto]:!h-auto",
1270
+ className: "w-full",
1271
+ emptyMessage: isError ? "Couldn't load ranking data. Please try again." : "No ranking data available.",
1272
+ getRowId: (row) => `${row.entityId}-${row.rank}`,
1273
+ getRowClassName: (row) => highlightEntityId != null && row.entityId === highlightEntityId ? HIGHLIGHT_CLASS : ""
1274
+ }
1275
+ )
1276
+ ] });
1277
+ }
1278
+ function LeaderboardContent(props) {
1279
+ const { subtitle, footnotes = [], isSm, page, totalCount, pageSize, onPageChange } = props;
1280
+ const isCountKnown = totalCount !== void 0;
1281
+ const totalPages = Math.max(1, Math.ceil((totalCount ?? 0) / pageSize));
1282
+ const showPagination = page > 1 || isCountKnown && totalPages > 1;
1283
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col h-full overflow-hidden", children: [
1284
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col gap-6 sm:gap-4 overflow-hidden px-5", children: [
1285
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui_web11.DialogDescription, { className: "flex flex-col gap-1 header-xl-medium-card text-text-secondary sm:px-4 font-ss02 ss05 leading-normal", children: [
1286
+ subtitle,
1287
+ !isSm && footnotes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Footnotes, { notes: footnotes })
1288
+ ] }),
1289
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LeaderboardTable, { ...props }) })
1290
+ ] }),
1291
+ (footnotes.length > 0 || showPagination) && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col pt-3 pb-6 px-9 border-t border-border gap-3 relative z-10 shadow-[0_0_4px_0_rgba(0,0,0,0.25)]", children: [
1292
+ footnotes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Footnotes, { notes: footnotes }),
1293
+ showPagination && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1294
+ Pagination,
1295
+ {
1296
+ page,
1297
+ totalPages,
1298
+ isCountKnown,
1299
+ isSm,
1300
+ onPageChange
1301
+ }
1302
+ )
1303
+ ] })
1304
+ ] });
1305
+ }
1306
+ function StatRankingLeaderboardDialog(props) {
1307
+ const { open, onOpenChange, title, isSm } = props;
1308
+ if (isSm) {
1309
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui_web11.Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui_web11.DialogContent, { className: "p-0 min-w-[536px] sm:max-w-[500px] pt-4 gap-6 bg-card border-0 flex flex-col max-h-[85vh]", children: [
1310
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui_web11.DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui_web11.DialogTitle, { className: "header-xl-medium-card", children: title }) }),
1311
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LeaderboardContent, { ...props })
1312
+ ] }) });
1313
+ }
1314
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1315
+ import_ui_web11.MobileModalLayout,
1316
+ {
1317
+ onCancel: () => onOpenChange(false),
1318
+ isOpen: open,
1319
+ isSm,
1320
+ title,
1321
+ cancelButtonName: "Close",
1322
+ childClassName: "h-auto min-h-full h-[calc(100vh-100px)]",
1323
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex flex-col h-full pt-6", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LeaderboardContent, { ...props }) })
1324
+ }
1325
+ );
1326
+ }
1327
+
1328
+ // src/team/team-season-stats-widget.tsx
1329
+ var import_ui_web12 = require("@nukleus-sports/ui-web");
1330
+ var import_core8 = require("@nukleus-sports/core");
1331
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1332
+ var PRESEASON_TYPE = 1;
1333
+ var RANK_TEXT_CLASS = "label-xs-medium text-text-secondary";
1334
+ var RANK_LINK_CLASS = `${RANK_TEXT_CLASS} hover:text-text-primary hover:underline cursor-pointer transition-colors`;
1335
+ function RankBadge({
1336
+ rankText,
1337
+ statLabel,
1338
+ configId,
1339
+ isRankingsError,
1340
+ onRankClick
1341
+ }) {
1342
+ if (isRankingsError) {
1343
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "label-xs-medium text-destructive", title: "Couldn't load ranking", children: [
1344
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { "aria-hidden": "true", children: "--" }),
1345
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "sr-only", children: "Couldn't load ranking" })
1346
+ ] });
1347
+ }
1348
+ if (!rankText) return null;
1349
+ if (!onRankClick) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: RANK_TEXT_CLASS, children: rankText });
1350
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1351
+ import_ui_web12.Button,
1352
+ {
1353
+ type: "button",
1354
+ variant: "unstyled",
1355
+ size: "none",
1356
+ "aria-label": `${rankText} in ${statLabel}: view leaderboard`,
1357
+ onClick: (event) => {
1358
+ event.stopPropagation();
1359
+ onRankClick(configId);
1360
+ },
1361
+ className: RANK_LINK_CLASS,
1362
+ children: rankText
1363
+ }
1364
+ );
1365
+ }
1366
+ function CenteredMessage({ children }) {
1367
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex items-center justify-center h-full text-14.5 text-text-secondary", children });
1368
+ }
1369
+ function StatsBody({
1370
+ stats,
1371
+ sportId,
1372
+ rankings,
1373
+ configIds,
1374
+ showRanks,
1375
+ isSummaryError,
1376
+ isRankingsError,
1377
+ onRankClick
1378
+ }) {
1379
+ const columns = (0, import_core8.getTeamStatColumns)(sportId);
1380
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-col gap-1.5 h-full w-full justify-center", children: [
1381
+ isSummaryError && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-12 text-destructive", children: "Couldn't refresh stats. Showing the last loaded data." }),
1382
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "grid grid-cols-2 gap-x-1.5 gap-y-1.5 sm:flex sm:flex-row sm:gap-3 sm:justify-between items-center w-full", children: columns.map((column, index) => {
1383
+ const configId = configIds?.[index];
1384
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1385
+ StatColumn,
1386
+ {
1387
+ label: column.label,
1388
+ value: stats.values[index],
1389
+ suffix: column.suffix,
1390
+ rankBadge: showRanks && configId !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1391
+ RankBadge,
1392
+ {
1393
+ rankText: (0, import_core8.formatStatRankByConfig)(rankings, configId),
1394
+ statLabel: column.label,
1395
+ configId,
1396
+ isRankingsError,
1397
+ onRankClick
1398
+ }
1399
+ ) : void 0
1400
+ },
1401
+ column.label
1402
+ );
1403
+ }) })
1404
+ ] });
1405
+ }
1406
+ function getEmptyMessage(isSupportedSport, hasSeason, isSummaryError) {
1407
+ if (!isSupportedSport) return "Team season stats coming soon.";
1408
+ if (!hasSeason) return "Select a season to view stats.";
1409
+ return isSummaryError ? "Couldn't load season stats. Please try again." : "No season stats for the current season.";
1410
+ }
1411
+ function TeamSeasonStatsWidget({
1412
+ sportId,
1413
+ leagueId,
1414
+ seasons,
1415
+ seasonsLoading = false,
1416
+ summary,
1417
+ rankings,
1418
+ statsLoading = false,
1419
+ isSummaryError = false,
1420
+ isRankingsError = false,
1421
+ onRankClick,
1422
+ className
1423
+ }) {
1424
+ const isSupportedSport = sportId != null && (0, import_core8.isSupportedTeamStatsSport)(sportId);
1425
+ const hasSeason = Boolean(seasons?.selectedYear) && seasons?.selectedType != null;
1426
+ const stats = isSupportedSport && hasSeason ? (0, import_core8.computeTeamSeasonStatsFromSummary)(summary, sportId) : null;
1427
+ const configIds = (0, import_core8.getTeamRankingConfigIds)(sportId, leagueId);
1428
+ const showRanks = seasons?.selectedType !== PRESEASON_TYPE;
1429
+ if (seasonsLoading) {
1430
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_ui_web12.Card, { className: (0, import_ui_web12.cn)("border-0 p-4 h-[300px]", className), children: [
1431
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.CardHeader, { className: "p-0 pb-4", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.CardTitle, { className: "text-base font-medium", children: "Season Stats" }) }),
1432
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.CardContent, { className: "p-0", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "space-y-3 flex justify-center items-center w-full h-full", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.IconLoader, {}) }) })
1433
+ ] });
1434
+ }
1435
+ let body;
1436
+ if (statsLoading) {
1437
+ body = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.Skeleton, { className: "h-4 w-3/4" }) });
1438
+ } else if (isSupportedSport && stats) {
1439
+ body = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1440
+ StatsBody,
1441
+ {
1442
+ stats,
1443
+ sportId,
1444
+ rankings: rankings ?? [],
1445
+ configIds,
1446
+ showRanks,
1447
+ isSummaryError,
1448
+ isRankingsError,
1449
+ onRankClick
1450
+ }
1451
+ );
1452
+ } else {
1453
+ body = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CenteredMessage, { children: getEmptyMessage(isSupportedSport, hasSeason, isSummaryError) });
1454
+ }
1455
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1456
+ import_ui_web12.Card,
1457
+ {
1458
+ className: (0, import_ui_web12.cn)(
1459
+ "border-0 px-4 py-3 sm:p-4 flex flex-col gap-[25px] sm:gap-4 sm:h-[300px]",
1460
+ className
1461
+ ),
1462
+ children: [
1463
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.CardHeader, { className: "p-0", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-row items-center justify-between w-full h-8", children: [
1464
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.CardTitle, { className: "header-xl-medium-card text-base text-text-primary", children: "Team Stats" }),
1465
+ isSupportedSport && seasons && seasons.years.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SeasonSelector, { ...seasons, hideTypeOnMobile: true })
1466
+ ] }) }),
1467
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.CardContent, { className: "p-0 h-auto sm:h-[220px] flex justify-center", children: body })
1468
+ ]
1469
+ }
1470
+ );
1471
+ }
1472
+
1473
+ // src/team/recent-games-widget.tsx
1474
+ var import_react5 = require("react");
1475
+ var import_ui_web13 = require("@nukleus-sports/ui-web");
1476
+ var import_icons3 = require("@nukleus-sports/icons");
1477
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1478
+ var DATE_FORMAT = new Intl.DateTimeFormat("en-US", {
1479
+ weekday: "long",
1480
+ month: "long",
1481
+ day: "numeric",
1482
+ year: "numeric"
1483
+ });
1484
+ var MESSAGES = {
1485
+ "no-team": "No games available.",
1486
+ "team-error": "Couldn't load team info. Please try again.",
1487
+ "games-error": "Couldn't load games. Please try again."
1488
+ };
1489
+ function ResultText({ result }) {
1490
+ if (result.outcome === "none") return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-text-secondary text-14", children: "--" });
1491
+ if (result.outcome === "tie") {
1492
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "text-14 font-medium text-text-primary", children: [
1493
+ "T ",
1494
+ result.detail
1495
+ ] });
1496
+ }
1497
+ const isWin = result.outcome === "win";
1498
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "text-14 font-medium", children: [
1499
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1500
+ "span",
1501
+ {
1502
+ className: isWin ? "text-primary-color-nuk-text" : "text-semantic-color-status-priority-blocked-hot-copy",
1503
+ children: isWin ? "W" : "L"
1504
+ }
1505
+ ),
1506
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "text-text-primary", children: [
1507
+ " ",
1508
+ result.detail
1509
+ ] })
1510
+ ] });
1511
+ }
1512
+ function OpponentLogo({ opponent, resolveImageUrl, defaultLogoUrl }) {
1513
+ const [failedUrl, setFailedUrl] = (0, import_react5.useState)(null);
1514
+ const { logo } = opponent;
1515
+ const resolved = logo ? logo.stored ? resolveImageUrl?.(logo.url) : logo.url : void 0;
1516
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1517
+ "img",
1518
+ {
1519
+ src: resolved && resolved !== failedUrl ? resolved : defaultLogoUrl,
1520
+ alt: `${opponent.name} logo`,
1521
+ className: "h-8 w-8 rounded-full",
1522
+ loading: "lazy",
1523
+ onError: () => {
1524
+ if (resolved) setFailedUrl(resolved);
1525
+ }
1526
+ }
1527
+ );
1528
+ }
1529
+ function GameItem({ row, resolveImageUrl, defaultLogoUrl }) {
1530
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "border-b border-border last:border-0", children: [
1531
+ row.isFirstUpcoming && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "px-2 pt-2 text-12 font-medium uppercase tracking-wide text-text-secondary", children: "Upcoming" }),
1532
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col p-2 gap-[5px]", children: [
1533
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-14 font-normal text-text-secondary", children: DATE_FORMAT.format(new Date(row.gameDate)) }),
1534
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-3", children: [
1535
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-14 font-normal text-text-secondary shrink-0", children: row.isHome ? "vs " : "@ " }),
1536
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1537
+ OpponentLogo,
1538
+ {
1539
+ opponent: row.opponent,
1540
+ resolveImageUrl,
1541
+ defaultLogoUrl
1542
+ }
1543
+ ),
1544
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-14.5 font-normal text-text-primary truncate", children: row.opponent.name }),
1545
+ row.result && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
1546
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-14 text-text-secondary", children: "-" }),
1547
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ResultText, { result: row.result })
1548
+ ] })
1549
+ ] }),
1550
+ row.time && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-14 font-normal text-text-secondary", children: row.time })
1551
+ ] })
1552
+ ] });
1553
+ }
1554
+ function Message({ children }) {
1555
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "text-text-primary text-14.5 px-1", children });
1556
+ }
1557
+ function Body({
1558
+ status,
1559
+ rows,
1560
+ resolveImageUrl,
1561
+ defaultLogoUrl
1562
+ }) {
1563
+ if (status === "loading") {
1564
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "space-y-4 flex justify-center items-center w-full h-full", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_ui_web13.IconLoader, {}) });
1565
+ }
1566
+ if (status !== "ready") return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Message, { children: MESSAGES[status] });
1567
+ if (rows.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Message, { children: "There are no games scheduled at this time." });
1568
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "flex flex-col overflow-y-auto overflow-x-hidden gap-1", children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1569
+ GameItem,
1570
+ {
1571
+ row,
1572
+ resolveImageUrl,
1573
+ defaultLogoUrl
1574
+ },
1575
+ row.id
1576
+ )) });
1577
+ }
1578
+ function RecentGamesWidget({
1579
+ status,
1580
+ rows,
1581
+ resolveImageUrl,
1582
+ defaultLogoUrl,
1583
+ onExpand,
1584
+ className
1585
+ }) {
1586
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1587
+ import_ui_web13.Card,
1588
+ {
1589
+ className: (0, import_ui_web13.cn)(
1590
+ "p-4 w-full xl:w-[420px] flex flex-col overflow-hidden border-none gap-3 h-full md:min-h-[612px]",
1591
+ className
1592
+ ),
1593
+ children: [
1594
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_ui_web13.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 p-0", children: [
1595
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_ui_web13.CardTitle, { children: "Recent Games" }),
1596
+ onExpand && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1597
+ import_ui_web13.Button,
1598
+ {
1599
+ type: "button",
1600
+ variant: "ghost",
1601
+ size: "sm",
1602
+ "aria-label": "View full schedule",
1603
+ onClick: onExpand,
1604
+ className: "outline-1 background outline-offset-[-1px] outline-[hsl(var(--color-ui-elem-strokes))] outline h-[32px] w-[32px]",
1605
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons3.ArrowUpRightIcon, { className: "text-greys-icons h-5 w-5" })
1606
+ }
1607
+ )
1608
+ ] }),
1609
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_ui_web13.CardContent, { className: "flex-1 flex flex-col overflow-hidden p-0", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1610
+ Body,
1611
+ {
1612
+ status,
1613
+ rows,
1614
+ resolveImageUrl,
1615
+ defaultLogoUrl
1616
+ }
1617
+ ) })
1618
+ ]
1619
+ }
1620
+ );
1621
+ }
1622
+ // Annotate the CommonJS export names for ESM import in node:
1623
+ 0 && (module.exports = {
1624
+ EmptyValue,
1625
+ FactField,
1626
+ FactPills,
1627
+ FieldLabel,
1628
+ RecentGamesWidget,
1629
+ SeasonSelector,
1630
+ StatColumn,
1631
+ StatRankingLeaderboardDialog,
1632
+ TeamFactsContent,
1633
+ TeamFactsWidget,
1634
+ TeamInfoCard,
1635
+ TeamSeasonScheduleSummaryPanel,
1636
+ TeamSeasonStatsSummaryPanel,
1637
+ TeamSeasonStatsWidget,
1638
+ TeamStaffTable,
1639
+ VenuePhoto
1640
+ });
1641
+ //# sourceMappingURL=team.cjs.map