@sensiblestats/widget-react 0.144.0 → 0.145.1

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/index.js CHANGED
@@ -221,6 +221,10 @@ var BUNDLED_EN_GB = {
221
221
  "widget.v8BuilderCustomRange": "Enter a total above 1.01 and up to 1000.",
222
222
  "widget.v8BuilderCustomUnreadable": "Type the total like {example}.",
223
223
  "widget.v8BuilderCustomEdit": "Your total {total}, edit",
224
+ "widget.v8BuilderAnother": "Another combo",
225
+ "widget.v8BuilderSwap": "Swap {leg}",
226
+ "widget.v8BuilderSwapLeg": "{pair}, {market}",
227
+ "widget.v8BuilderSwapNone": "No other game fits here.",
224
228
  "widget.v8BuilderLoading": "Loading\u2026",
225
229
  "widget.v8BuilderError": "Couldn't load this right now.",
226
230
  "widget.v8BuilderRetry": "Try again",
@@ -1117,6 +1121,9 @@ var ROW_LEAVES = {
1117
1121
  v8BuilderCustomPlaceholder: (c) => (example) => c.t("widget.v8BuilderCustomPlaceholder", { example }),
1118
1122
  v8BuilderCustomUnreadable: (c) => (example) => c.t("widget.v8BuilderCustomUnreadable", { example }),
1119
1123
  v8BuilderCustomEdit: (c) => (total) => c.t("widget.v8BuilderCustomEdit", { total }),
1124
+ v8Pair: (c) => (home, away) => c.t("widget.addAllPartial.pair", { home, away }),
1125
+ v8BuilderSwapLeg: (c) => (pair, market) => c.t("widget.v8BuilderSwapLeg", { pair, market }),
1126
+ v8BuilderSwap: (c) => (leg) => c.t("widget.v8BuilderSwap", { leg }),
1120
1127
  v8Follow: (c) => (name) => c.t("widget.v8Follow", { name }),
1121
1128
  v8PricesAsOf: (c) => (time) => c.t("widget.v8PricesAsOf", { time }),
1122
1129
  v8InjuryAsOf: (c) => (time) => c.t("widget.v8InjuryAsOf", { time }),
@@ -1332,7 +1339,7 @@ function parseCustomTotal(text2, format2) {
1332
1339
  }
1333
1340
 
1334
1341
  // src/version.generated.ts
1335
- var WIDGET_REACT_VERSION = "0.144.0";
1342
+ var WIDGET_REACT_VERSION = "0.145.1";
1336
1343
 
1337
1344
  // src/config.ts
1338
1345
  function hostTag(cfg) {
@@ -1648,6 +1655,11 @@ function normalizeUi(cfg, loaded) {
1648
1655
  v8BuilderCustomRange: strings.v8BuilderCustomRange,
1649
1656
  v8BuilderCustomUnreadable: strings.v8BuilderCustomUnreadable,
1650
1657
  v8BuilderCustomEdit: strings.v8BuilderCustomEdit,
1658
+ v8BuilderAnother: strings.v8BuilderAnother,
1659
+ v8Pair: strings.v8Pair,
1660
+ v8BuilderSwapLeg: strings.v8BuilderSwapLeg,
1661
+ v8BuilderSwap: strings.v8BuilderSwap,
1662
+ v8BuilderSwapNone: strings.v8BuilderSwapNone,
1651
1663
  v8BuilderLoading: strings.v8BuilderLoading,
1652
1664
  v8BuilderError: strings.v8BuilderError,
1653
1665
  v8BuilderRetry: strings.v8BuilderRetry,
@@ -5908,7 +5920,13 @@ import { useCallback as useCallback13, useEffect as useEffect17, useRef as useRe
5908
5920
  // src/builderMemory.ts
5909
5921
  var GRID_TTL_MS = 5 * 6e4;
5910
5922
  var hasReadableQuote = (grid) => grid.legs.some((leg) => !Number.isNaN(Date.parse(leg.quotedAtUtc)));
5911
- var gridKey = (locale, req) => `${locale ?? ""}|${JSON.stringify(req)}`;
5923
+ var sortedIds = (ids) => ids && ids.length > 0 ? [...ids].sort((a, b) => a - b) : void 0;
5924
+ var gridKey = (locale, req) => {
5925
+ const { variant, keep, swapped, ...rest } = req;
5926
+ const keepIds = sortedIds(keep);
5927
+ const swappedIds = sortedIds(swapped);
5928
+ return `${locale ?? ""}|${JSON.stringify({ ...rest, ...variant ? { variant } : {}, ...keepIds ? { keep: keepIds } : {}, ...swappedIds ? { swapped: swappedIds } : {} })}`;
5929
+ };
5912
5930
  function createBuilderMemory(now = Date.now) {
5913
5931
  const views = /* @__PURE__ */ new Map();
5914
5932
  const grids = /* @__PURE__ */ new Map();
@@ -8296,6 +8314,9 @@ function BettingInsightList({ insights, ui, slip, monitor }) {
8296
8314
  return /* @__PURE__ */ jsx35("div", { className: "ss-w-binsights", children: insights.map((it) => /* @__PURE__ */ jsx35(InsightCard, { it, ui, slip, monitor }, it.id)) });
8297
8315
  }
8298
8316
 
8317
+ // src/components/ComboCardList.tsx
8318
+ import { useId } from "react";
8319
+
8299
8320
  // src/components/AddAllToSlipButton.tsx
8300
8321
  import { useCallback as useCallback24, useState as useState37 } from "react";
8301
8322
  import { jsx as jsx36, jsxs as jsxs31 } from "react/jsx-runtime";
@@ -8388,7 +8409,7 @@ function usePresetTools() {
8388
8409
 
8389
8410
  // src/components/ComboCardList.tsx
8390
8411
  import { jsx as jsx37, jsxs as jsxs32 } from "react/jsx-runtime";
8391
- function ComboLegRow({ leg, addToSlipEnabled, ui, slip, monitor, hold, closed }) {
8412
+ function ComboLegRow({ leg, addToSlipEnabled, ui, slip, monitor, hold, closed, swap }) {
8392
8413
  const { oddsFormat } = useOddsSettings();
8393
8414
  const odds = formatOdds(leg.priceForms, oddsFormat);
8394
8415
  const kickoffFallback = !leg.kickoffLabel && leg.kickoffUtc ? ui.bettingKickoff(leg.kickoffUtc) : void 0;
@@ -8397,6 +8418,7 @@ function ComboLegRow({ leg, addToSlipEnabled, ui, slip, monitor, hold, closed })
8397
8418
  const showPin = !!monitor && leg.pinEnabled;
8398
8419
  const factText = leg.fact ? (leg.fact.direction === "over" ? ui.presets.legFactOver : ui.presets.legFactUnder)(leg.fact.hits, leg.fact.games) : void 0;
8399
8420
  const line = leg.statText ?? factText;
8421
+ const noteId = useId();
8400
8422
  return /* @__PURE__ */ jsxs32("li", { className: "ss-w-combo-leg", children: [
8401
8423
  leg.competition || kickoff || showPin ? /* @__PURE__ */ jsxs32("div", { className: "ss-w-combo-leg-meta", children: [
8402
8424
  /* @__PURE__ */ jsx37("span", { className: "ss-w-bi-comp", children: leg.competition ?? "" }),
@@ -8430,8 +8452,15 @@ function ComboLegRow({ leg, addToSlipEnabled, ui, slip, monitor, hold, closed })
8430
8452
  ariaLabel: `${leg.homeTeamName} ${leg.awayTeamName}, ${leg.selection} ${odds}`,
8431
8453
  hold
8432
8454
  }
8433
- )
8455
+ ),
8456
+ swap ? /* @__PURE__ */ jsx37("button", { type: "button", className: "ss-w-combo-leg-swap", "aria-label": swap.label, "aria-describedby": noteId, "data-focus": swap.focusKey, disabled: swap.disabled, onClick: swap.onSwap, children: /* @__PURE__ */ jsxs32("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children: [
8457
+ /* @__PURE__ */ jsx37("path", { d: "M17 3l4 4-4 4" }),
8458
+ /* @__PURE__ */ jsx37("path", { d: "M3 7h18" }),
8459
+ /* @__PURE__ */ jsx37("path", { d: "M7 21l-4-4 4-4" }),
8460
+ /* @__PURE__ */ jsx37("path", { d: "M21 17H3" })
8461
+ ] }) }) : null
8434
8462
  ] }),
8463
+ swap ? /* @__PURE__ */ jsx37("p", { id: noteId, className: "ss-w-combo-leg-swapnone", "data-kind": "swap-none", role: "status", children: swap.note ?? "" }) : null,
8435
8464
  line ? /* @__PURE__ */ jsx37("p", { className: "ss-w-combo-leg-stat", children: line }) : null
8436
8465
  ] });
8437
8466
  }
@@ -10525,9 +10554,9 @@ function LiveTimelineCard({ card, ui }) {
10525
10554
  const [expanded, setExpanded] = useState45(false);
10526
10555
  const events = card.data.events;
10527
10556
  if (!events || events.length === 0) return null;
10528
- const sorted = [...events].sort((a, b) => b.minute - a.minute);
10529
- const rest = sorted.length - SHOWN2;
10530
- const shown2 = expanded ? sorted : sorted.slice(0, SHOWN2);
10557
+ const sorted2 = [...events].sort((a, b) => b.minute - a.minute);
10558
+ const rest = sorted2.length - SHOWN2;
10559
+ const shown2 = expanded ? sorted2 : sorted2.slice(0, SHOWN2);
10531
10560
  const { showMore, showLess } = ui;
10532
10561
  return /* @__PURE__ */ jsxs57("div", { className: "ss-w-fandash-card ss-w-fandash-live-timeline", children: [
10533
10562
  card.title ? /* @__PURE__ */ jsx62("span", { className: "ss-w-fandash-eyebrow", children: card.title }) : null,
@@ -10546,7 +10575,7 @@ function LiveTimelineCard({ card, ui }) {
10546
10575
  }
10547
10576
 
10548
10577
  // src/components/dashboard/MomentumWave.tsx
10549
- import { useId } from "react";
10578
+ import { useId as useId2 } from "react";
10550
10579
  import { jsx as jsx63, jsxs as jsxs58 } from "react/jsx-runtime";
10551
10580
  var WIDTH = 270;
10552
10581
  var HEIGHT = 56;
@@ -10571,7 +10600,7 @@ function MomentumWave({
10571
10600
  }) {
10572
10601
  if (points.length === 0) return null;
10573
10602
  const { area, line, lastLeftPct, lastTopPx } = buildPaths(points);
10574
- const clipId = useId();
10603
+ const clipId = useId2();
10575
10604
  const topClipId = `${clipId}-top`;
10576
10605
  const bottomClipId = `${clipId}-bottom`;
10577
10606
  const topClass = clubIsHome ? "ss-w-fandash-live-mom-home" : "ss-w-fandash-live-mom-away";
@@ -13419,7 +13448,7 @@ function LeagueGroup({ view, open, onToggle, disambiguate, rowCap, onShowAll, on
13419
13448
  }
13420
13449
 
13421
13450
  // src/components/MatchSheet.tsx
13422
- import { useId as useId2, useState as useState58 } from "react";
13451
+ import { useId as useId3, useState as useState58 } from "react";
13423
13452
  import { localIdOf as localIdOf4, qualifiedId as qualifiedId2, slipSportOf as slipSportOf9, toWireSport as toWireSport6 } from "@sensiblestats/widget-sdk";
13424
13453
 
13425
13454
  // src/useModalDialog.ts
@@ -13484,7 +13513,7 @@ function kickoffDate(kickoffUnix, lang, timeZone) {
13484
13513
  function MatchSheet({ match, league, state, stale, ui, monitor, onAsk, onClose, opener }) {
13485
13514
  const { dialogRef, onKeyDown } = useModalDialog(onClose, { opener });
13486
13515
  const log = useEventLog();
13487
- const titleId = useId2();
13516
+ const titleId = useId3();
13488
13517
  const [limitHit, setLimitHit] = useState58(false);
13489
13518
  const pinSport = slipSportOf9(match.sport);
13490
13519
  const tour = pinSport === "tennis" && isKnownTour(match.tour) ? match.tour : void 0;
@@ -13695,7 +13724,7 @@ function LivePanel({ discovery, ui, monitor, sport, offered, onSport, league, on
13695
13724
  }
13696
13725
 
13697
13726
  // src/components/ScheduleMatchesPanel.tsx
13698
- import { useEffect as useEffect45, useId as useId3, useMemo as useMemo12, useRef as useRef37, useState as useState61 } from "react";
13727
+ import { useEffect as useEffect45, useId as useId4, useMemo as useMemo12, useRef as useRef37, useState as useState61 } from "react";
13699
13728
  import { matchKey as matchKey10 } from "@sensiblestats/widget-sdk";
13700
13729
 
13701
13730
  // src/useTennisRowPrices.ts
@@ -13865,7 +13894,7 @@ var TOP_ROW_CAP = 3;
13865
13894
  var SKELETON_ROWS = 3;
13866
13895
  function ScheduleMatchesPanel({ discovery, ui, monitor, sport, offered, onSport, day, onDay, loaded, onOpenLive, onAsk, locale, getTennisPrices, slip }) {
13867
13896
  const { localDate: today, states, stale } = discovery;
13868
- const searchId = useId3();
13897
+ const searchId = useId4();
13869
13898
  const [query, setQuery] = useState61("");
13870
13899
  const [toggled, setToggled] = useState61(/* @__PURE__ */ new Map());
13871
13900
  const [expanded, setExpanded] = useState61(/* @__PURE__ */ new Set());
@@ -14310,7 +14339,7 @@ function useGamePlay(conversation, { gameId, gameDay, fixtureId, locale, refresh
14310
14339
  }
14311
14340
 
14312
14341
  // src/components/games/MysteryTigerGame.tsx
14313
- import { useState as useState65, useId as useId4 } from "react";
14342
+ import { useState as useState65, useId as useId5 } from "react";
14314
14343
 
14315
14344
  // src/components/games/nationFlags.ts
14316
14345
  var FLAGS = {
@@ -14784,7 +14813,7 @@ function MysteryTigerGame({
14784
14813
  }) {
14785
14814
  const t = ui.games.mysteryTiger;
14786
14815
  const [query, setQuery] = useState65("");
14787
- const inputId = useId4();
14816
+ const inputId = useId5();
14788
14817
  const clientState = parseClientState(result?.clientStateJson);
14789
14818
  const guessResults = clientState?.guessResults ?? [];
14790
14819
  const alreadyGuessedIds = new Set(guessResults.map((g) => g.playerId));
@@ -15045,7 +15074,7 @@ function HigherOrLowerGame({
15045
15074
  }
15046
15075
 
15047
15076
  // src/components/games/CareerPathGame.tsx
15048
- import { useState as useState67, useId as useId5 } from "react";
15077
+ import { useState as useState67, useId as useId6 } from "react";
15049
15078
 
15050
15079
  // src/components/games/ui/CrestShield.tsx
15051
15080
  import { useState as useState66 } from "react";
@@ -15084,7 +15113,7 @@ function CareerPathGame({
15084
15113
  const s = ui.games.careerPath;
15085
15114
  const title = gameTitle({ gameId: "career-path" }, ui.games.titles);
15086
15115
  const [query, setQuery] = useState67("");
15087
- const inputId = useId5();
15116
+ const inputId = useId6();
15088
15117
  const clientState = parseClientState3(result?.clientStateJson);
15089
15118
  const alreadyGuessedIds = new Set(clientState?.guessResults.map((g) => g.playerId) ?? []);
15090
15119
  const isOver = result?.alreadyPlayed === true || clientState?.solved === true || clientState?.failed === true;
@@ -15190,7 +15219,7 @@ function CareerPathGame({
15190
15219
  }
15191
15220
 
15192
15221
  // src/components/games/BeatTheGridGame.tsx
15193
- import React, { useEffect as useEffect47, useId as useId6, useRef as useRef39, useState as useState68 } from "react";
15222
+ import React, { useEffect as useEffect47, useId as useId7, useRef as useRef39, useState as useState68 } from "react";
15194
15223
 
15195
15224
  // src/components/games/ui/OptionList.tsx
15196
15225
  import { jsx as jsx122 } from "react/jsx-runtime";
@@ -15280,7 +15309,7 @@ function SearchSheet({
15280
15309
  }) {
15281
15310
  const s = ui.games.beatTheGrid;
15282
15311
  const [query, setQuery] = useState68("");
15283
- const inputId = useId6();
15312
+ const inputId = useId7();
15284
15313
  const inputRef = useRef39(null);
15285
15314
  useEffect47(() => {
15286
15315
  inputRef.current?.focus();
@@ -15502,7 +15531,7 @@ function BeatTheGridGame({
15502
15531
  }
15503
15532
 
15504
15533
  // src/components/games/GuessTheXiGame.tsx
15505
- import { useState as useState69, useId as useId7 } from "react";
15534
+ import { useState as useState69, useId as useId8 } from "react";
15506
15535
 
15507
15536
  // src/components/games/ui/PitchSvg.tsx
15508
15537
  import { Fragment as Fragment36, jsx as jsx124, jsxs as jsxs109 } from "react/jsx-runtime";
@@ -15592,7 +15621,7 @@ function GuessTheXiGame({
15592
15621
  }) {
15593
15622
  const t = ui.games.guessTheXi;
15594
15623
  const [query, setQuery] = useState69("");
15595
- const inputId = useId7();
15624
+ const inputId = useId8();
15596
15625
  const clientState = parseClientState5(result?.clientStateJson);
15597
15626
  const isOver = result?.alreadyPlayed === true || clientState?.status === "solved" || clientState?.status === "failed";
15598
15627
  const solved = clientState?.status === "solved";
@@ -15886,7 +15915,7 @@ function DailyQuizGame({
15886
15915
  }
15887
15916
 
15888
15917
  // src/components/games/MatchdayPredictorGame.tsx
15889
- import { useId as useId8, useState as useState71 } from "react";
15918
+ import { useId as useId9, useState as useState71 } from "react";
15890
15919
  import { jsx as jsx127, jsxs as jsxs112 } from "react/jsx-runtime";
15891
15920
  var SCORER_SEARCH_THRESHOLD = 9;
15892
15921
  function parseClientState7(json) {
@@ -15987,7 +16016,7 @@ function MatchdayPredictorGame({
15987
16016
  const [firstScorerPlayerId, setFirstScorerPlayerId] = useState71(null);
15988
16017
  const [lastEdited, setLastEdited] = useState71("home");
15989
16018
  const [query, setQuery] = useState71("");
15990
- const searchId = useId8();
16019
+ const searchId = useId9();
15991
16020
  const clientState = parseClientState7(result?.clientStateJson);
15992
16021
  const alreadyPlayed = result?.alreadyPlayed === true;
15993
16022
  const header = /* @__PURE__ */ jsx127(
@@ -16154,7 +16183,7 @@ function MatchdayPredictorGame({
16154
16183
  }
16155
16184
 
16156
16185
  // src/components/games/StartingXiGame.tsx
16157
- import { useId as useId9, useState as useState72 } from "react";
16186
+ import { useId as useId10, useState as useState72 } from "react";
16158
16187
  import { Fragment as Fragment39, jsx as jsx128, jsxs as jsxs113 } from "react/jsx-runtime";
16159
16188
  var POINTS_PER_STARTER = 8;
16160
16189
  var XI_SIZE = 11;
@@ -16201,7 +16230,7 @@ function StartingXiGame({
16201
16230
  const [slotPlayers, setSlotPlayers] = useState72(() => Array(XI_SIZE).fill(null));
16202
16231
  const [active, setActive] = useState72(0);
16203
16232
  const [query, setQuery] = useState72("");
16204
- const searchId = useId9();
16233
+ const searchId = useId10();
16205
16234
  const clientState = parseClientState8(result?.clientStateJson);
16206
16235
  const alreadyPlayed = result?.alreadyPlayed === true;
16207
16236
  const header = /* @__PURE__ */ jsx128(
@@ -16340,7 +16369,7 @@ function StartingXiGame({
16340
16369
  }
16341
16370
 
16342
16371
  // src/components/games/StatLadderGame.tsx
16343
- import { useId as useId10, useState as useState73 } from "react";
16372
+ import { useId as useId11, useState as useState73 } from "react";
16344
16373
  import { jsx as jsx129, jsxs as jsxs114 } from "react/jsx-runtime";
16345
16374
  function ladderClue(ladder) {
16346
16375
  const mystery = ladder.find((r) => r.rank === 2);
@@ -16379,7 +16408,7 @@ function StatLadderGame({
16379
16408
  const t = ui.games.statLadder;
16380
16409
  const [query, setQuery] = useState73("");
16381
16410
  const [selectedId, setSelectedId] = useState73(null);
16382
- const searchId = useId10();
16411
+ const searchId = useId11();
16383
16412
  const clientState = parseClientState9(result?.clientStateJson);
16384
16413
  const revealed = clientState != null;
16385
16414
  const header = /* @__PURE__ */ jsx129(GameHeader, { title: gameTitle({ gameId: "stat-ladder" }, ui.games.titles), eyebrow: t.eyebrow, onBack, backLabel: ui.back });
@@ -17202,11 +17231,11 @@ function FavouritesPanel({ controller, ui, sport, sports, onSportChange }) {
17202
17231
  }
17203
17232
 
17204
17233
  // src/components/PresetTools.tsx
17205
- import { useId as useId11, useState as useState80 } from "react";
17234
+ import { useId as useId12, useState as useState80 } from "react";
17206
17235
  import { Fragment as Fragment42, jsx as jsx140, jsxs as jsxs123 } from "react/jsx-runtime";
17207
17236
  function PresetToolModal({ title, closeLabel, onClose, children, footer, className }) {
17208
17237
  const { dialogRef, onKeyDown } = useModalDialog(onClose, { restoreFocus: false });
17209
- const titleId = useId11();
17238
+ const titleId = useId12();
17210
17239
  return /* @__PURE__ */ jsx140("div", { className: className ? `ss-w-tool-backdrop ${className}` : "ss-w-tool-backdrop", children: /* @__PURE__ */ jsxs123("div", { ref: dialogRef, className: "ss-w-tool", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, tabIndex: -1, onKeyDown, children: [
17211
17240
  /* @__PURE__ */ jsxs123("div", { className: "ss-w-tool-head", children: [
17212
17241
  /* @__PURE__ */ jsx140("h2", { id: titleId, className: "ss-w-tool-title", children: title }),
@@ -17297,7 +17326,8 @@ function FavouritesSheet({ ui, controller, sport, sports, onSportChange, onClose
17297
17326
  }
17298
17327
 
17299
17328
  // src/components/dashboard/v8/SentenceBuilder.tsx
17300
- import { useEffect as useEffect54, useId as useId12, useRef as useRef44, useState as useState81 } from "react";
17329
+ import { useEffect as useEffect54, useId as useId13, useRef as useRef44, useState as useState81 } from "react";
17330
+ import { MAX_SWAPPED_IDS } from "@sensiblestats/widget-sdk";
17301
17331
  import { Fragment as Fragment43, jsx as jsx142, jsxs as jsxs124 } from "react/jsx-runtime";
17302
17332
  var TOTALS = ["any", "3", "5", "10", "20", "50"];
17303
17333
  var BASE_LEGS = [1, 2, 3, 4];
@@ -17308,6 +17338,20 @@ var totalLabel = (t, options, format2, ui) => {
17308
17338
  const option = options.find((o) => o.key === t);
17309
17339
  return t === "any" || !option ? ui.v8BuilderAny : formatOdds(option.formats, format2);
17310
17340
  };
17341
+ var NO_BASE = { variant: 0, variants: 1, requested: 0, supported: false };
17342
+ function shownAfter(prev, grid, req) {
17343
+ if (grid.status === "noSwap" && prev) {
17344
+ const failed = prev.grid.legs.map((l) => l.matchOddsId).find((id) => !req.keep?.includes(id));
17345
+ const noSwap = failed === void 0 || prev.noSwap.includes(failed) ? prev.noSwap : [...prev.noSwap, failed];
17346
+ return { ...prev, seen: grid, seenReq: req, noSwap };
17347
+ }
17348
+ const swap = (req.keep?.length ?? 0) > 0;
17349
+ const ids = grid.legs.map((l) => l.matchOddsId);
17350
+ const trusted = !swap || (req.keep ?? []).every((id) => ids.includes(id));
17351
+ const base = swap && trusted ? prev?.base ?? NO_BASE : grid.status === "ok" ? { variant: grid.variant ?? 0, variants: grid.variants ?? 1, requested: swap ? grid.variant ?? 0 : req.variant ?? 0, supported: typeof grid.variants === "number" } : NO_BASE;
17352
+ return { seen: grid, seenReq: req, grid, req, trusted, noSwap: [], base };
17353
+ }
17354
+ var sorted = (ids) => [...new Set(ids)].sort((a, b) => a - b);
17311
17355
  var sameIds = (a, b) => a.length === b.length && a.every((id) => b.includes(id));
17312
17356
  function openingGames(preset) {
17313
17357
  const options = preset.gamesOptions && preset.gamesOptions.length > 0 ? preset.gamesOptions : null;
@@ -17342,7 +17386,8 @@ function SentenceBuilder({ preset, ui, conversation, memory: memory3, slip, spor
17342
17386
  const [view, setView] = useState81(() => saved?.view ?? openingView);
17343
17387
  const autoWidened = useRef44(false);
17344
17388
  const [widenedNote, setWidenedNote] = useState81(saved?.widenedNote ?? false);
17345
- const requestFor = (v) => ({
17389
+ const track = useTrack();
17390
+ const requestFor = (v, extra) => ({
17346
17391
  sport,
17347
17392
  ...v.marketKey !== null ? { marketKey: v.marketKey } : {},
17348
17393
  matchIds: v.widen ? [] : v.matchIds,
@@ -17350,6 +17395,9 @@ function SentenceBuilder({ preset, ui, conversation, memory: memory3, slip, spor
17350
17395
  // The total row is hidden for Singles, so a total picked earlier must not narrow them; the pick stays in state for the way back.
17351
17396
  total: v.legs === 1 ? "any" : v.custom?.decimal ?? v.total,
17352
17397
  widen: v.widen,
17398
+ ...extra?.variant ? { variant: extra.variant } : {},
17399
+ ...extra?.keep?.length ? { keep: sorted(extra.keep) } : {},
17400
+ ...extra?.swapped?.length ? { swapped: [...new Set(extra.swapped)].slice(-MAX_SWAPPED_IDS) } : {},
17353
17401
  ...operatorUserId ? { operatorUserId } : {},
17354
17402
  ...anonymousUserId ? { anonymousUserId } : {}
17355
17403
  });
@@ -17358,8 +17406,8 @@ function SentenceBuilder({ preset, ui, conversation, memory: memory3, slip, spor
17358
17406
  const [invalid, setInvalid] = useState81(null);
17359
17407
  const inputRef = useRef44(null);
17360
17408
  const pencilRef = useRef44(null);
17361
- const noteId = useId12();
17362
- const customId = useId12();
17409
+ const noteId = useId13();
17410
+ const customId = useId13();
17363
17411
  useEffect54(() => {
17364
17412
  if (editing) inputRef.current?.focus();
17365
17413
  }, [editing]);
@@ -17381,7 +17429,13 @@ function SentenceBuilder({ preset, ui, conversation, memory: memory3, slip, spor
17381
17429
  pencilRef.current?.focus();
17382
17430
  };
17383
17431
  const [first] = useState81(() => requestFor(view));
17384
- const { grid, status: status2, confirmed, request } = useBuilderGrid({ conversation, locale: ui.hostTag, memory: memory3, initial: first });
17432
+ const { grid, answeredFor, status: status2, confirmed, request } = useBuilderGrid({ conversation, locale: ui.hostTag, memory: memory3, initial: first });
17433
+ const [shown2, setShown] = useState81(null);
17434
+ if (grid === null) {
17435
+ if (shown2 !== null && status2 === "ready") setShown(null);
17436
+ } else if (answeredFor && (shown2?.seen !== grid || shown2.seenReq !== answeredFor)) {
17437
+ setShown(shownAfter(shown2, grid, answeredFor));
17438
+ }
17385
17439
  const lastRequest = useRef44(first);
17386
17440
  useEffect54(() => {
17387
17441
  void request(lastRequest.current);
@@ -17398,6 +17452,7 @@ function SentenceBuilder({ preset, ui, conversation, memory: memory3, slip, spor
17398
17452
  const ask = (next) => {
17399
17453
  setStartedNote(false);
17400
17454
  autoWidened.current = false;
17455
+ setTapped(null);
17401
17456
  commit(next, false);
17402
17457
  send(requestFor(next));
17403
17458
  };
@@ -17419,13 +17474,32 @@ function SentenceBuilder({ preset, ui, conversation, memory: memory3, slip, spor
17419
17474
  ask(next);
17420
17475
  };
17421
17476
  const canNarrow = preset.matchIds.length > 0;
17422
- const suggested = grid?.status === "miss" || grid?.nearest === true ? grid.legCountThatLands : null;
17477
+ const ready = status2 === "ready" && grid !== null;
17478
+ const [tapped, setTapped] = useState81(null);
17479
+ const busy = tapped !== null && status2 === "loading" && shown2 !== null;
17480
+ const g = ready ? shown2?.grid ?? grid : busy ? shown2.grid : null;
17481
+ const suggested = g?.status === "miss" || g?.nearest === true ? g.legCountThatLands : null;
17423
17482
  const legButtons = Array.from(/* @__PURE__ */ new Set([
17424
17483
  ...BASE_LEGS,
17425
17484
  ...[preset.legs, suggested].filter((n) => n !== null && n > 4)
17426
17485
  ])).sort((a, b) => a - b);
17427
- const ready = status2 === "ready" && grid !== null;
17428
- const rows = ready && grid.status === "ok" ? legsOf(grid, sport) : null;
17486
+ const rows = g && g.status === "ok" ? legsOf(g, sport) : null;
17487
+ const sectionRef = useRef44(null);
17488
+ useEffect54(() => {
17489
+ if (tapped === null || status2 !== "ready") return;
17490
+ setTapped(null);
17491
+ const root = sectionRef.current;
17492
+ if (!root) return;
17493
+ const at2 = document.activeElement;
17494
+ const mine = Array.from(root.querySelectorAll(".ss-w-combo-legs, .ss-w-v8-builder-actions"));
17495
+ if (at2 && at2 !== document.body && !mine.some((n) => n.contains(at2))) return;
17496
+ const pick = (key) => {
17497
+ const b = root.querySelector(`[data-focus="${key}"]`);
17498
+ return b && !b.disabled ? b : null;
17499
+ };
17500
+ const list = root.querySelector(".ss-w-combo-legs");
17501
+ (pick(tapped) ?? pick("another") ?? list ?? root)?.focus();
17502
+ }, [tapped, status2]);
17429
17503
  const rowSlip = rows ? guardLegsPreMatch(slip, rows, ui) : slip;
17430
17504
  useNextKickoffRender(rows ? rows.map((l) => l.kickoffUtc) : []);
17431
17505
  const [startedNote, setStartedNote] = useState81(false);
@@ -17439,14 +17513,45 @@ function SentenceBuilder({ preset, ui, conversation, memory: memory3, slip, spor
17439
17513
  if (market) setSeen(market);
17440
17514
  }, [market]);
17441
17515
  const marketName = view.marketKey === null ? null : marketOptions?.find((m) => m.key === view.marketKey)?.label ?? market ?? seen2;
17442
- const paused = ready && grid.status === "paused";
17516
+ const paused = g?.status === "paused";
17443
17517
  const coolOff = status2 === "ready" && grid === null;
17444
- const empty2 = ready && (grid.status === "miss" || grid.status === "ok" && (rows === null || rows.length === 0));
17445
- const widened = view.widen || ready && grid.widened;
17518
+ const empty2 = g !== null && (g.status === "miss" || g.status === "ok" && (rows === null || rows.length === 0));
17519
+ const widened = view.widen || g?.widened === true;
17446
17520
  const singles = view.legs === 1;
17447
17521
  const onOpeningChoice = view.marketKey === openingView.marketKey && view.widen === openingView.widen && view.gamesId === openingView.gamesId && sameIds(view.matchIds, openingView.matchIds);
17448
17522
  const quotedAt = rows ? oldestQuote(rows) : null;
17449
- const combo = ready && grid.total !== null ? { sport, totalChosen: view.custom ? "custom" : view.total, totalActual: grid.total } : void 0;
17523
+ const totalChosen = view.custom ? "custom" : view.total;
17524
+ const combo = g && g.total !== null ? { sport, totalChosen, totalActual: g.total } : void 0;
17525
+ const comboOn = rows !== null && rows.length > 1 && g !== null && g.requestedLegs > 1 && view.legs > 1;
17526
+ const base = shown2?.base ?? NO_BASE;
17527
+ const anotherOn = comboOn && base.variants > 1 && base.variant === base.requested % base.variants;
17528
+ const committedSwapped = shown2 && shown2.trusted && (shown2.req.keep?.length ?? 0) > 0 ? shown2.req.swapped ?? [] : [];
17529
+ const swapOn = comboOn && base.supported && g.nearest !== true && shown2?.trusted === true;
17530
+ const noSwapIds = shown2?.noSwap ?? [];
17531
+ const another = () => {
17532
+ const variant = (base.variant + 1) % base.variants;
17533
+ track({ name: "combo_variant_click", surface: "builder", sport, legs: view.legs, total: totalChosen, variant });
17534
+ setTapped("another");
17535
+ send(requestFor(view, { variant }));
17536
+ };
17537
+ const swapOf = (leg, all) => {
17538
+ if (!swapOn) return void 0;
17539
+ const stuck = noSwapIds.includes(leg.matchOddsId);
17540
+ const pair = ui.v8Pair(leg.homeTeamName, leg.awayTeamName);
17541
+ const sharesGame = all.some((l) => l !== leg && l.matchId === leg.matchId);
17542
+ const focusKey = `swap-${all.indexOf(leg)}`;
17543
+ return {
17544
+ focusKey,
17545
+ label: ui.v8BuilderSwap(sharesGame ? ui.v8BuilderSwapLeg(pair, leg.market) : pair),
17546
+ disabled: stuck || busy || !confirmed,
17547
+ note: stuck ? ui.v8BuilderSwapNone : void 0,
17548
+ onSwap: () => {
17549
+ track({ name: "combo_swap_click", surface: "builder", sport, legs: view.legs, total: totalChosen });
17550
+ setTapped(focusKey);
17551
+ send(requestFor(view, { keep: all.filter((l) => l !== leg).map((l) => l.matchOddsId), swapped: [...committedSwapped, leg.matchOddsId] }));
17552
+ }
17553
+ };
17554
+ };
17450
17555
  const canWiden = gamesOptions === null || allGames !== null;
17451
17556
  useEffect54(() => {
17452
17557
  if (!empty2 || !singles || widened || !canWiden || autoWidened.current) return;
@@ -17464,7 +17569,7 @@ function SentenceBuilder({ preset, ui, conversation, memory: memory3, slip, spor
17464
17569
  const nextWhen = nextAtMs !== null && nextAtMs > Date.now() ? kickoffText(ui, preset.nextGamesAtUtc) : null;
17465
17570
  const phrase = preset.nextGamesAtUtc == null ? nextGames : null;
17466
17571
  const mineGames = gamesOptions?.find((o) => o.id === view.gamesId)?.mine === true;
17467
- return /* @__PURE__ */ jsx142("section", { className: "ss-w-v8-sec ss-w-v8-builder", "data-testid": "v8-builder", "aria-busy": status2 === "loading" || void 0, children: conversation && paused ? /* @__PURE__ */ jsx142("p", { className: "ss-w-v8-builder-note", "data-kind": "paused", children: nextWhen ? ui.v8PausedNext(nextWhen) : /* @__PURE__ */ jsxs124(Fragment43, { children: [
17572
+ return /* @__PURE__ */ jsx142("section", { ref: sectionRef, tabIndex: -1, className: "ss-w-v8-sec ss-w-v8-builder", "data-testid": "v8-builder", "aria-busy": status2 === "loading" || void 0, children: conversation && paused ? /* @__PURE__ */ jsx142("p", { className: "ss-w-v8-builder-note", "data-kind": "paused", children: nextWhen ? ui.v8PausedNext(nextWhen) : /* @__PURE__ */ jsxs124(Fragment43, { children: [
17468
17573
  ui.v8Paused,
17469
17574
  phrase ? /* @__PURE__ */ jsx142("span", { className: "ss-w-v8-builder-next", "data-testid": "v8-next-games", children: phrase }) : null
17470
17575
  ] }) }) : conversation ? /* @__PURE__ */ jsxs124(Fragment43, { children: [
@@ -17613,13 +17718,16 @@ function SentenceBuilder({ preset, ui, conversation, memory: memory3, slip, spor
17613
17718
  ] }) : null,
17614
17719
  rows && rows.length > 0 ? /* @__PURE__ */ jsxs124(Fragment43, { children: [
17615
17720
  /* @__PURE__ */ jsxs124("div", { className: "ss-w-v8-builder-rows", children: [
17616
- grid?.nearest === true ? /* @__PURE__ */ jsx142("p", { className: "ss-w-v8-builder-note", "data-kind": "nearest", children: ui.v8Nearest }) : null,
17617
- /* @__PURE__ */ jsx142("ol", { className: "ss-w-combo-legs", role: "list", children: rows.map((leg) => /* @__PURE__ */ jsx142(ComboLegRow, { leg, addToSlipEnabled: !!slip.onAddToSlip, ui, slip: rowSlip, hold: !confirmed, closed: !preMatchOpen(leg.kickoffUtc, Date.now()) }, leg.key)) }),
17618
- grid && grid.requestedLegs > 1 && grid.total !== null && grid.totalFormats !== null && grid.multiplication !== null ? /* @__PURE__ */ jsx142("div", { className: "ss-w-combo-math", children: oddsFormat === "decimal" ? grid.multiplication : formatOdds(grid.totalFormats, oddsFormat) }) : null,
17619
- grid && grid.requestedLegs > 1 ? /* @__PURE__ */ jsx142(AddAllToSlipButton, { legs: rows, slip: rowSlip, ui, labels: { add: ui.v8AddAll, done: ui.allInSlip }, combo, sizeless: true, hold: !confirmed, onStartedGame: () => {
17620
- setStartedNote(true);
17621
- void request(lastRequest.current);
17622
- } }) : null
17721
+ g?.nearest === true ? /* @__PURE__ */ jsx142("p", { className: "ss-w-v8-builder-note", "data-kind": "nearest", children: ui.v8Nearest }) : null,
17722
+ /* @__PURE__ */ jsx142("ol", { className: "ss-w-combo-legs", role: "list", tabIndex: -1, "aria-busy": busy || void 0, children: rows.map((leg) => /* @__PURE__ */ jsx142(ComboLegRow, { leg, addToSlipEnabled: !!slip.onAddToSlip, ui, slip: rowSlip, hold: !confirmed, closed: !preMatchOpen(leg.kickoffUtc, Date.now()), swap: swapOf(leg, rows) }, leg.key)) }),
17723
+ g && g.requestedLegs > 1 && g.total !== null && g.totalFormats !== null && g.multiplication !== null ? /* @__PURE__ */ jsx142("div", { className: "ss-w-combo-math", children: oddsFormat === "decimal" ? g.multiplication : formatOdds(g.totalFormats, oddsFormat) }) : null,
17724
+ g && g.requestedLegs > 1 ? /* @__PURE__ */ jsxs124("div", { className: "ss-w-v8-builder-actions", children: [
17725
+ anotherOn ? /* @__PURE__ */ jsx142("button", { type: "button", className: "ss-w-v8-builder-another", "data-focus": "another", disabled: busy, onClick: another, children: ui.v8BuilderAnother }) : null,
17726
+ /* @__PURE__ */ jsx142(AddAllToSlipButton, { legs: rows, slip: rowSlip, ui, labels: { add: ui.v8AddAll, done: ui.allInSlip }, combo, sizeless: true, hold: !confirmed, onStartedGame: () => {
17727
+ setStartedNote(true);
17728
+ void request(lastRequest.current);
17729
+ } })
17730
+ ] }) : null
17623
17731
  ] }),
17624
17732
  quotedAt ? /* @__PURE__ */ jsx142("p", { className: "ss-w-v8-builder-note", "data-testid": "v8-asof", children: ui.v8PricesAsOf(fmtHhMm(quotedAt, ui.locale, clockOf(ui), ui.timeZone)) }) : null
17625
17733
  ] }) : null
@@ -19192,6 +19300,11 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
19192
19300
  .ss-w-combo-leg-pick .ss-w-slip-btn { flex: none; }
19193
19301
  .ss-w-combo-leg .ss-w-bi-team { white-space: normal; text-overflow: clip; overflow-wrap: break-word; line-height: 1.25; }
19194
19302
  .ss-w-combo-leg-pick .ss-w-toast { position: static; flex-basis: 100%; width: auto; max-width: none; box-shadow: none; }
19303
+ .ss-w-combo-leg-swap { flex: none; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; width: 32px; height: 32px; margin-left: auto; padding: 0; border: 1px solid var(--ss-w-line); border-radius: 50%; background: transparent; color: var(--ss-w-ink); cursor: pointer; }
19304
+ .ss-w-combo-leg-swap:hover:not(:disabled) { border-color: var(--ss-w-accent); }
19305
+ .ss-w-combo-leg-swap:disabled { cursor: default; opacity: .4; }
19306
+ .ss-w-combo-leg-swapnone { margin: 0; font-size: 12px; line-height: 1.4; color: var(--ss-w-faint); }
19307
+ .ss-w-combo-leg-swapnone:empty { margin-top: -5px; }
19195
19308
  .ss-w-combo-leg-stat { font-size: 12px; line-height: 1.45; color: var(--ss-w-ink); background: var(--ss-w-bubble); border-radius: 8px; padding: 6px 9px; }
19196
19309
  .ss-w-combo-math { font-family: ui-monospace, monospace; font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 700; line-height: 1.4; color: var(--ss-w-ink); text-align: right; background: color-mix(in srgb, var(--ss-w-accent) 9%, var(--ss-w-panel)); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; }
19197
19310
  .ss-w-combo-note { font-size: 11px; line-height: 1.4; color: var(--ss-w-faint); }
@@ -20283,6 +20396,10 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
20283
20396
  .ss-w-v8-builder > .ss-w-v8-builder-btn { align-self: flex-start; min-height: 40px; padding: 6px 14px; }
20284
20397
  .ss-w-v8-builder .ss-w-slip-btn { min-height: 36px; }
20285
20398
  .ss-w-v8-builder .ss-w-combo-addall .ss-w-slip-btn { min-height: 44px; }
20399
+ .ss-w-v8-builder-actions { display: flex; align-items: stretch; gap: 8px; }
20400
+ .ss-w-v8-builder-actions > .ss-w-combo-addall { flex: 1 1 0; min-width: 0; }
20401
+ .ss-w-v8-builder-another { flex: 0 1 auto; align-self: flex-start; max-width: 50%; min-height: 44px; padding: 8px 14px; border: 1px solid var(--ss-w-line); border-radius: 22px; background: transparent; color: var(--ss-w-ink); font: inherit; font-size: 14px; font-weight: 650; line-height: 1.15; overflow-wrap: normal; word-break: normal; cursor: pointer; }
20402
+ .ss-w-v8-builder-another:hover { border-color: var(--ss-w-accent); }
20286
20403
  .ss-w-fav .ss-w-dash-sport { min-height: 36px; }
20287
20404
  .ss-w-v8-builder-note { margin: 0; font-size: 12.5px; line-height: 1.35; color: color-mix(in srgb, #fff 78%, var(--ss-w-nav)); }
20288
20405
  .ss-w-v8-builder-note[data-kind] { padding: 10px 12px; border-radius: 10px; background: var(--ss-v8-chip); color: #dce8e1; font-size: 13.5px; }