@sensiblestats/widget-react 0.147.0 → 0.149.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/index.js CHANGED
@@ -1347,7 +1347,7 @@ function parseCustomTotal(text2, format2) {
1347
1347
  }
1348
1348
 
1349
1349
  // src/version.generated.ts
1350
- var WIDGET_REACT_VERSION = "0.147.0";
1350
+ var WIDGET_REACT_VERSION = "0.149.0";
1351
1351
 
1352
1352
  // src/config.ts
1353
1353
  function hostTag(cfg) {
@@ -2645,10 +2645,13 @@ function slipPickFields(selection, label, line) {
2645
2645
  if (Number.isFinite(odds) && odds > 1 && odds <= MAX_ODDS) fields.odds = odds;
2646
2646
  return fields;
2647
2647
  }
2648
- function chipSelection(market, match, conversationId) {
2648
+ function chipSelection(market, match, conversationId, scope) {
2649
2649
  if (!market || !market.addToSlipEnabled || typeof market.matchOddsId !== "number" || typeof market.price !== "number" || !market.priceFormats) return null;
2650
2650
  const selection = { matchOddsId: market.matchOddsId, matchId: match.matchId, oddsDecimal: market.price, forms: market.priceFormats };
2651
2651
  if (conversationId !== void 0) selection.conversationId = conversationId;
2652
+ const slipSport = slipSportOf2(scope?.sport);
2653
+ if (slipSport !== void 0) selection.sport = slipSport;
2654
+ if (scope?.tour) selection.tour = scope.tour;
2652
2655
  return withMatch(selection, { home: match.homeTeamName, away: match.awayTeamName, kickoffUtc: match.kickoffUtc, marketLabel: market.marketLabel });
2653
2656
  }
2654
2657
  function chipPriceText(market, format2) {
@@ -6899,6 +6902,7 @@ function PriceHistoryButton({ selection, monitor, ui, displayLabel }) {
6899
6902
 
6900
6903
  // src/components/LiveFactBlock.tsx
6901
6904
  import { useRef as useRef22, useState as useState26 } from "react";
6905
+ import { localIdOf as localIdOf4, qualifiedId as qualifiedId2, toWireSport as toWireSport5 } from "@sensiblestats/widget-sdk";
6902
6906
 
6903
6907
  // src/useFactView.ts
6904
6908
  import { useEffect as useEffect22, useRef as useRef21 } from "react";
@@ -6957,7 +6961,7 @@ function evidenceText(f, ui) {
6957
6961
  if (e.since) parts2.push(ui.liveFactSince(e.since));
6958
6962
  return parts2.length > 0 ? parts2.join(" \xB7 ") : void 0;
6959
6963
  }
6960
- function LiveFactBlock({ facts, match, ui, slip, onAsk }) {
6964
+ function LiveFactBlock({ facts, match, ui, slip, onAsk, scope }) {
6961
6965
  const [expanded, setExpanded] = useState26(false);
6962
6966
  const { oddsFormat } = useOddsSettings();
6963
6967
  const log = useEventLog();
@@ -6966,7 +6970,10 @@ function LiveFactBlock({ facts, match, ui, slip, onAsk }) {
6966
6970
  const earlier = facts.filter((f) => f.marketState && f !== current);
6967
6971
  const background = facts.filter((f) => !f.marketState).slice(0, BACKGROUND_MAX);
6968
6972
  const m = current?.market;
6969
- const entity2 = current?.marketState && m ? { entityType: "market", entityId: m.marketDeveloperName } : { entityType: "match", entityId: String(match.matchId) };
6973
+ const sport = scope?.sport;
6974
+ const wire = toWireSport5(sport);
6975
+ const sportFields = wire ? { sport: wire, ...scope?.tour ? { tour: scope.tour } : {} } : {};
6976
+ const entity2 = current?.marketState && m ? { entityType: "market", entityId: qualifiedId2(sport, "market", m.marketDeveloperName), ...sportFields } : { entityType: "match", entityId: qualifiedId2(sport, "game", localIdOf4(sport, match.matchId, scope?.tour)), ...sportFields };
6970
6977
  useFactView(sectionRef, current, entity2);
6971
6978
  if (facts.length === 0) return null;
6972
6979
  const open = current?.marketState === "open" && !!m && !m.isSuspended;
@@ -6994,7 +7001,7 @@ function LiveFactBlock({ facts, match, ui, slip, onAsk }) {
6994
7001
  open ? /* @__PURE__ */ jsx17(
6995
7002
  SlipButton,
6996
7003
  {
6997
- selection: chipSelection(m, match, slip.conversationId),
7004
+ selection: slipOpenFor(slip, sport) ? chipSelection(m, match, slip.conversationId, scope) : null,
6998
7005
  marketDeveloperName: m.marketDeveloperName,
6999
7006
  selectionLabel: m.selectionLabel,
7000
7007
  slip,
@@ -7026,7 +7033,7 @@ function LiveFactBlock({ facts, match, ui, slip, onAsk }) {
7026
7033
  className: "ss-w-fact-link",
7027
7034
  onClick: () => {
7028
7035
  log?.log({ name: "fact_ask", ...entity2, factId: String(current.id), factKey: current.factKey });
7029
- onAsk(current.text, { kind: "liveFact", matchId: match.matchId, subject: current.text.slice(0, 400) });
7036
+ onAsk(current.text, scope ? { kind: "match", subject: scope.subject, ...sportFields, ...scope.tour ? {} : { matchId: match.matchId } } : { kind: "liveFact", matchId: match.matchId, subject: current.text.slice(0, 400) });
7030
7037
  },
7031
7038
  children: ui.liveFactAsk
7032
7039
  }
@@ -12283,7 +12290,7 @@ function UnavailableCard({ match, monitor, ui, sport }) {
12283
12290
  /* @__PURE__ */ jsx86("div", { className: "ss-w-mon-grace", children: ui.graceNote })
12284
12291
  ] }) });
12285
12292
  }
12286
- function NbaMonitorCard({ match, monitor, ui, slip }) {
12293
+ function NbaMonitorCard({ match, monitor, ui, slip, onAsk }) {
12287
12294
  const b = match.basketball;
12288
12295
  if (!b) return /* @__PURE__ */ jsx86(UnavailableCard, { match, monitor, ui, sport: "basketball" });
12289
12296
  const live = match.phase === "live";
@@ -12352,7 +12359,18 @@ function NbaMonitorCard({ match, monitor, ui, slip }) {
12352
12359
  ": ",
12353
12360
  t.value
12354
12361
  ] }, t.key) : /* @__PURE__ */ jsx86("span", {}, t.key)) })
12355
- ] })
12362
+ ] }),
12363
+ live && match.facts && match.facts.length > 0 && /* @__PURE__ */ jsx86(
12364
+ LiveFactBlock,
12365
+ {
12366
+ facts: match.facts,
12367
+ match,
12368
+ ui,
12369
+ slip,
12370
+ onAsk,
12371
+ scope: { sport: "basketball", subject: `${match.awayTeamName ?? ""} ${ui.venue.away} ${match.homeTeamName ?? ""}`.trim() }
12372
+ }
12373
+ )
12356
12374
  ] }),
12357
12375
  /* @__PURE__ */ jsx86(NbaFormSection, { match, monitor, ui }, `form-${match.matchId}`),
12358
12376
  /* @__PURE__ */ jsx86(MarketAccordion, { match, monitor, ui, slip }),
@@ -12692,7 +12710,7 @@ function playedThrough(f) {
12692
12710
  };
12693
12711
  return Math.max(nonZero(f.homePeriods), nonZero(f.awayPeriods));
12694
12712
  }
12695
- function NflMonitorCard({ match, monitor, ui, slip }) {
12713
+ function NflMonitorCard({ match, monitor, ui, slip, onAsk }) {
12696
12714
  const f = match.americanFootball;
12697
12715
  if (!f) return /* @__PURE__ */ jsx91(UnavailableCard, { match, monitor, ui, sport: "americanfootball" });
12698
12716
  const live = match.phase === "live";
@@ -12765,6 +12783,17 @@ function NflMonitorCard({ match, monitor, ui, slip }) {
12765
12783
  ] })
12766
12784
  ] })
12767
12785
  ] }),
12786
+ live && match.facts && match.facts.length > 0 && /* @__PURE__ */ jsx91(
12787
+ LiveFactBlock,
12788
+ {
12789
+ facts: match.facts,
12790
+ match,
12791
+ ui,
12792
+ slip,
12793
+ onAsk,
12794
+ scope: { sport: "americanfootball", subject: `${match.awayTeamName ?? f.awayAbbreviation} ${ui.venue.away} ${match.homeTeamName ?? f.homeAbbreviation}` }
12795
+ }
12796
+ ),
12768
12797
  /* @__PURE__ */ jsx91(MarketAccordion, { match, monitor, ui, slip }),
12769
12798
  /* @__PURE__ */ jsx91(NflPropsSection, { match, monitor, ui, slip }, `props-${match.matchId}`),
12770
12799
  /* @__PURE__ */ jsx91(NflFormSection, { match, monitor, ui }, `form-${match.matchId}`)
@@ -12773,7 +12802,7 @@ function NflMonitorCard({ match, monitor, ui, slip }) {
12773
12802
 
12774
12803
  // src/components/TennisMonitorCard.tsx
12775
12804
  import { useRef as useRef34 } from "react";
12776
- import { toWireSport as toWireSport5 } from "@sensiblestats/widget-sdk";
12805
+ import { toWireSport as toWireSport6 } from "@sensiblestats/widget-sdk";
12777
12806
 
12778
12807
  // src/components/TennisFixtureRow.tsx
12779
12808
  import { matchKey as matchKey4 } from "@sensiblestats/widget-sdk";
@@ -13262,7 +13291,7 @@ function TennisMonitorCard({ match, monitor, ui, slip, onAsk }) {
13262
13291
  const surface = t.header.surface ? surfaceLabel(ui, t.header.surface) : null;
13263
13292
  const ask = () => {
13264
13293
  if (!onAsk) return;
13265
- const wire = toWireSport5("tennis");
13294
+ const wire = toWireSport6("tennis");
13266
13295
  const grounding = {
13267
13296
  kind: "match",
13268
13297
  subject: `${t.p1.name} ${ui.tennis.vs} ${t.p2.name}`,
@@ -13603,7 +13632,7 @@ function MatchesPanel({ monitor, ui, slip, onAsk, discovery }) {
13603
13632
  tiles.filter((t) => t.match).length >= 2 && /* @__PURE__ */ jsx99(ScoreboardStrip, { tiles, selectedKey: selected.pin.key, onSelect: monitor.selectMatch, ui }),
13604
13633
  /* @__PURE__ */ jsxs92("div", { className: "ss-w-mon-list", children: [
13605
13634
  !m && /* @__PURE__ */ jsx99(MonitorSkeleton, { pin: selected.pin, monitor, ui }),
13606
- m && (isTennis(m) ? /* @__PURE__ */ jsx99(TennisMonitorCard, { match: m, monitor, ui, slip, onAsk }) : sportKeyOf(m.sport) === "americanfootball" ? /* @__PURE__ */ jsx99(NflMonitorCard, { match: m, monitor, ui, slip }) : isBasketball(m) ? /* @__PURE__ */ jsx99(NbaMonitorCard, { match: m, monitor, ui, slip }) : /* @__PURE__ */ jsxs92("div", { className: "ss-w-mon-item", children: [
13635
+ m && (isTennis(m) ? /* @__PURE__ */ jsx99(TennisMonitorCard, { match: m, monitor, ui, slip, onAsk }) : sportKeyOf(m.sport) === "americanfootball" ? /* @__PURE__ */ jsx99(NflMonitorCard, { match: m, monitor, ui, slip, onAsk }) : isBasketball(m) ? /* @__PURE__ */ jsx99(NbaMonitorCard, { match: m, monitor, ui, slip, onAsk }) : /* @__PURE__ */ jsxs92("div", { className: "ss-w-mon-item", children: [
13607
13636
  /* @__PURE__ */ jsx99(
13608
13637
  MonitorMatchCard,
13609
13638
  {
@@ -13838,7 +13867,7 @@ function LeagueGroup({ view, open, onToggle, disambiguate, rowCap, onShowAll, on
13838
13867
 
13839
13868
  // src/components/MatchSheet.tsx
13840
13869
  import { useId as useId3, useState as useState61 } from "react";
13841
- import { localIdOf as localIdOf4, qualifiedId as qualifiedId2, slipSportOf as slipSportOf9, toWireSport as toWireSport6 } from "@sensiblestats/widget-sdk";
13870
+ import { localIdOf as localIdOf5, qualifiedId as qualifiedId3, slipSportOf as slipSportOf9, toWireSport as toWireSport7 } from "@sensiblestats/widget-sdk";
13842
13871
 
13843
13872
  // src/useModalDialog.ts
13844
13873
  import { useEffect as useEffect44, useRef as useRef36 } from "react";
@@ -13925,11 +13954,11 @@ function MatchSheet({ match, league, state, stale, ui, monitor, onAsk, onClose,
13925
13954
  return;
13926
13955
  }
13927
13956
  if (result === "added") {
13928
- const wireSport = toWireSport6(pinSport);
13957
+ const wireSport = toWireSport7(pinSport);
13929
13958
  log?.log({
13930
13959
  name: "pin_add",
13931
13960
  entityType: "match",
13932
- entityId: qualifiedId2(pinSport, "game", localIdOf4(pinSport, match.matchId, tour)),
13961
+ entityId: qualifiedId3(pinSport, "game", localIdOf5(pinSport, match.matchId, tour)),
13933
13962
  ...wireSport ? { sport: wireSport } : {}
13934
13963
  });
13935
13964
  }
@@ -13937,7 +13966,7 @@ function MatchSheet({ match, league, state, stale, ui, monitor, onAsk, onClose,
13937
13966
  };
13938
13967
  const ask = () => {
13939
13968
  if (!onAsk) return;
13940
- const wire = toWireSport6(match.sport);
13969
+ const wire = toWireSport7(match.sport);
13941
13970
  const grounding = {
13942
13971
  kind: treatedLive ? "liveFact" : "match",
13943
13972
  ...pinSport === "tennis" ? {} : { matchId: match.matchId },