@agg-build/ui 2.1.4 → 2.2.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.
Files changed (37) hide show
  1. package/dist/{chunk-T4YZGAYS.mjs → chunk-5MRFY5ZQ.mjs} +1 -1
  2. package/dist/{chunk-BW7S2YR3.mjs → chunk-73MO7MYG.mjs} +21 -17
  3. package/dist/{chunk-TBZWRUFB.mjs → chunk-BTRFSEPC.mjs} +97 -61
  4. package/dist/{chunk-FLESSOSU.mjs → chunk-DTOI4V6P.mjs} +47 -10
  5. package/dist/{chunk-XHE2VO3S.mjs → chunk-HNLA44SY.mjs} +2 -2
  6. package/dist/{chunk-VP76G6PN.mjs → chunk-MIAAL7BL.mjs} +79 -23
  7. package/dist/{chunk-R2YNZJZ3.mjs → chunk-TR7HUVY7.mjs} +1 -1
  8. package/dist/events.js +93 -52
  9. package/dist/events.mjs +3 -3
  10. package/dist/index.js +214 -93
  11. package/dist/index.mjs +7 -7
  12. package/dist/modals.mjs +3 -3
  13. package/dist/pages.js +214 -93
  14. package/dist/pages.mjs +6 -6
  15. package/dist/primitives.js +70 -23
  16. package/dist/primitives.mjs +1 -1
  17. package/dist/trading.js +17 -14
  18. package/dist/trading.mjs +4 -4
  19. package/dist/types/events/item/event-list-item.types.d.mts +2 -2
  20. package/dist/types/events/item/event-list-item.types.d.ts +2 -2
  21. package/dist/types/events/item/event-list-item.utils.d.mts +2 -1
  22. package/dist/types/events/item/event-list-item.utils.d.ts +2 -1
  23. package/dist/types/events/item-details/event-list-item-details.types.d.mts +0 -1
  24. package/dist/types/events/item-details/event-list-item-details.types.d.ts +0 -1
  25. package/dist/types/events/market-details/market-details.types.d.mts +1 -0
  26. package/dist/types/events/market-details/market-details.types.d.ts +1 -0
  27. package/dist/types/events/shared/chart-venue-selection.d.mts +2 -1
  28. package/dist/types/events/shared/chart-venue-selection.d.ts +2 -1
  29. package/dist/types/pages/event-market/sports-event-market.utils.d.mts +15 -1
  30. package/dist/types/pages/event-market/sports-event-market.utils.d.ts +15 -1
  31. package/dist/types/primitives/search/search.types.d.mts +1 -0
  32. package/dist/types/primitives/search/search.types.d.ts +1 -0
  33. package/dist/types/primitives/search/search.utils.d.mts +4 -1
  34. package/dist/types/primitives/search/search.utils.d.ts +4 -1
  35. package/dist/types/trading/types.d.mts +2 -1
  36. package/dist/types/trading/types.d.ts +2 -1
  37. package/package.json +3 -3
package/dist/pages.js CHANGED
@@ -6268,6 +6268,13 @@ var formatPriceGapPercent = (value) => {
6268
6268
  return `${Math.round(value)}%`;
6269
6269
  };
6270
6270
  var sortOutcomes = (outcomes) => {
6271
+ return sortOutcomesWithPrices(outcomes);
6272
+ };
6273
+ var resolveOutcomeProbability = (outcome, priceByOutcomeId) => {
6274
+ const resolvedPrice = priceByOutcomeId === void 0 ? outcome.price : priceByOutcomeId.has(outcome.id) ? priceByOutcomeId.get(outcome.id) : void 0;
6275
+ return normalizeProbability(resolvedPrice);
6276
+ };
6277
+ var sortOutcomesWithPrices = (outcomes, priceByOutcomeId) => {
6271
6278
  if (outcomes.length <= 1) return outcomes;
6272
6279
  if (hasBinaryOutcomes(outcomes)) {
6273
6280
  return sortYesFirst(outcomes);
@@ -6283,38 +6290,41 @@ var sortOutcomes = (outcomes) => {
6283
6290
  }
6284
6291
  return [...outcomes].sort((a, b) => {
6285
6292
  var _a, _b;
6286
- const aPrice = (_a = normalizeProbability(a.price)) != null ? _a : 0;
6287
- const bPrice = (_b = normalizeProbability(b.price)) != null ? _b : 0;
6293
+ const aPrice = (_a = resolveOutcomeProbability(a, priceByOutcomeId)) != null ? _a : 0;
6294
+ const bPrice = (_b = resolveOutcomeProbability(b, priceByOutcomeId)) != null ? _b : 0;
6288
6295
  return bPrice - aPrice;
6289
6296
  });
6290
6297
  };
6291
- var compareVisibleOutcomeRows = (left, right) => {
6298
+ var compareVisibleOutcomeRows = (left, right, priceByOutcomeId) => {
6292
6299
  var _a, _b;
6293
6300
  const leftDate = toDate(resolveOutcomeTitle(left.outcome));
6294
6301
  const rightDate = toDate(resolveOutcomeTitle(right.outcome));
6295
6302
  if (leftDate && rightDate) {
6296
6303
  return leftDate.getTime() - rightDate.getTime();
6297
6304
  }
6298
- const leftProbability = (_a = normalizeProbability(left.outcome.price)) != null ? _a : -1;
6299
- const rightProbability = (_b = normalizeProbability(right.outcome.price)) != null ? _b : -1;
6305
+ const leftProbability = (_a = resolveOutcomeProbability(left.outcome, priceByOutcomeId)) != null ? _a : -1;
6306
+ const rightProbability = (_b = resolveOutcomeProbability(right.outcome, priceByOutcomeId)) != null ? _b : -1;
6300
6307
  return rightProbability - leftProbability;
6301
6308
  };
6302
- var shouldReplaceVisibleOutcome = (current, next) => {
6309
+ var shouldReplaceVisibleOutcome = (current, next, priceByOutcomeId) => {
6303
6310
  var _a, _b;
6304
6311
  const currentVolume = typeof current.market.volume === "number" ? current.market.volume : -1;
6305
6312
  const nextVolume = typeof next.market.volume === "number" ? next.market.volume : -1;
6306
6313
  if (currentVolume !== nextVolume) {
6307
6314
  return nextVolume > currentVolume;
6308
6315
  }
6309
- const currentProbability = (_a = normalizeProbability(current.outcome.price)) != null ? _a : -1;
6310
- const nextProbability = (_b = normalizeProbability(next.outcome.price)) != null ? _b : -1;
6316
+ const currentProbability = (_a = resolveOutcomeProbability(current.outcome, priceByOutcomeId)) != null ? _a : -1;
6317
+ const nextProbability = (_b = resolveOutcomeProbability(next.outcome, priceByOutcomeId)) != null ? _b : -1;
6311
6318
  return nextProbability > currentProbability;
6312
6319
  };
6313
- var resolveVisibleOutcomes = (venueMarkets) => {
6320
+ var resolveVisibleOutcomes = (venueMarkets, priceByOutcomeId) => {
6314
6321
  const visibleOutcomesByLabel = /* @__PURE__ */ new Map();
6315
6322
  venueMarkets.forEach((market) => {
6316
6323
  const title2 = market.question;
6317
- const canonicalOutcome = sortOutcomes(market.venueMarketOutcomes)[0];
6324
+ const canonicalOutcome = sortOutcomesWithPrices(
6325
+ market.venueMarketOutcomes,
6326
+ priceByOutcomeId
6327
+ )[0];
6318
6328
  if (!canonicalOutcome) return;
6319
6329
  const normalizedTitle = title2.trim().toLowerCase();
6320
6330
  const nextVisibleOutcome = {
@@ -6324,11 +6334,11 @@ var resolveVisibleOutcomes = (venueMarkets) => {
6324
6334
  title: title2
6325
6335
  };
6326
6336
  const currentVisibleOutcome = visibleOutcomesByLabel.get(normalizedTitle);
6327
- if (!currentVisibleOutcome || shouldReplaceVisibleOutcome(currentVisibleOutcome, nextVisibleOutcome)) {
6337
+ if (!currentVisibleOutcome || shouldReplaceVisibleOutcome(currentVisibleOutcome, nextVisibleOutcome, priceByOutcomeId)) {
6328
6338
  visibleOutcomesByLabel.set(normalizedTitle, nextVisibleOutcome);
6329
6339
  }
6330
6340
  });
6331
- return [...visibleOutcomesByLabel.values()].sort(compareVisibleOutcomeRows).slice(0, Math.max(1, 2));
6341
+ return [...visibleOutcomesByLabel.values()].sort((left, right) => compareVisibleOutcomeRows(left, right, priceByOutcomeId)).slice(0, Math.max(1, 2));
6332
6342
  };
6333
6343
  var dedupeVenueMarketsById = (venueMarkets) => {
6334
6344
  const seenClusterIds = /* @__PURE__ */ new Set();
@@ -6408,18 +6418,19 @@ var toVenueLogoName = (value) => {
6408
6418
  if (!venueLogoNameSet.has(value)) return null;
6409
6419
  return value;
6410
6420
  };
6411
- var mapVenueEventToSearchResult = (event, labels, formatPercent, formatCompactCurrency) => {
6412
- var _a, _b;
6421
+ var mapVenueEventToSearchResult = (event, labels, formatPercent, formatCompactCurrency, options) => {
6422
+ var _a, _b, _c;
6413
6423
  const primaryVenueMarket = selectPrimaryVenueMarket(event.venueMarkets);
6414
6424
  if (!primaryVenueMarket) return null;
6415
6425
  const primaryVenue = toVenueLogoName(primaryVenueMarket.venue);
6416
6426
  if (!primaryVenue) return null;
6417
- const visibleOutcome = resolveVisibleOutcomes(event.venueMarkets)[0];
6427
+ const visibleOutcome = resolveVisibleOutcomes(event.venueMarkets, options == null ? void 0 : options.priceByOutcomeId)[0];
6418
6428
  if (!visibleOutcome) return null;
6419
- const probability = normalizeProbability(visibleOutcome.outcome.price);
6420
- if (probability == null) return null;
6429
+ const probability = normalizeProbability(
6430
+ (_a = options == null ? void 0 : options.priceByOutcomeId) == null ? void 0 : _a.get(visibleOutcome.outcome.id)
6431
+ );
6421
6432
  const resolvedTitle = formatEventTitleWithDateSuffix({
6422
- title: (_a = event == null ? void 0 : event.title) != null ? _a : "",
6433
+ title: (_b = event == null ? void 0 : event.title) != null ? _b : "",
6423
6434
  categories: event.categories,
6424
6435
  structureType: event.structureType,
6425
6436
  gameStartTime: event.gameStartTime,
@@ -6441,13 +6452,14 @@ var mapVenueEventToSearchResult = (event, labels, formatPercent, formatCompactCu
6441
6452
  return {
6442
6453
  id: event.id,
6443
6454
  title: resolvedTitle,
6444
- thumbnailSrc: (_b = resolveTileImage(event, primaryVenueMarket, void 0)) != null ? _b : "",
6455
+ thumbnailSrc: (_c = resolveTileImage(event, primaryVenueMarket, void 0)) != null ? _c : "",
6445
6456
  thumbnailAlt: resolvedTitle,
6446
6457
  venue: primaryVenue,
6447
6458
  visibleVenues,
6448
6459
  marketSummaryLabel,
6449
6460
  volumeLabel,
6450
6461
  valueLabel: formatMarketProbabilityPercent(probability, formatPercent),
6462
+ isValueLoading: probability == null && (options == null ? void 0 : options.isPriceLoading) === true,
6451
6463
  contextLabel: formatSearchContextLabel(visibleOutcome.title)
6452
6464
  };
6453
6465
  };
@@ -6557,7 +6569,16 @@ var SearchResultRow = ({
6557
6569
  children: [
6558
6570
  /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(VenueLogo, { venue: item.venue, size: "small" }),
6559
6571
  /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)("div", { className: "flex min-w-0 flex-1 items-baseline gap-2", children: [
6560
- /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
6572
+ item.isValueLoading ? /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
6573
+ "span",
6574
+ {
6575
+ "aria-hidden": "true",
6576
+ className: cn(
6577
+ "agg-search-result-value-loading",
6578
+ "h-5 w-12 shrink-0 rounded-agg-sm bg-agg-separator animate-pulse"
6579
+ )
6580
+ }
6581
+ ) : /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
6561
6582
  "p",
6562
6583
  {
6563
6584
  className: cn(
@@ -6670,6 +6691,24 @@ var Search = ({
6670
6691
  () => filterOpenEvents(searchResults),
6671
6692
  [searchResults]
6672
6693
  );
6694
+ const visibleVenueMarkets = (0, import_react7.useMemo)(
6695
+ () => openEvents.flatMap((event) => {
6696
+ var _a;
6697
+ return (_a = event.venueMarkets) != null ? _a : [];
6698
+ }),
6699
+ [openEvents]
6700
+ );
6701
+ const livePrices = (0, import_hooks27.useLiveOutcomePrices)(visibleVenueMarkets);
6702
+ const midpointResult = (0, import_hooks27.useMidpoints)(visibleVenueMarkets);
6703
+ const searchDisplayPrices = (0, import_react7.useMemo)(() => {
6704
+ if (!midpointResult.bestMidpointsByOutcomeId.size) return livePrices;
6705
+ if (!livePrices.size) return midpointResult.bestMidpointsByOutcomeId;
6706
+ const merged = new Map(midpointResult.bestMidpointsByOutcomeId);
6707
+ for (const [outcomeId, price] of livePrices) {
6708
+ merged.set(outcomeId, price);
6709
+ }
6710
+ return merged;
6711
+ }, [livePrices, midpointResult.bestMidpointsByOutcomeId]);
6673
6712
  const { validatedResults, eventsByResultId } = (0, import_react7.useMemo)(() => {
6674
6713
  const nextEventsByResultId = /* @__PURE__ */ new Map();
6675
6714
  const nextResults = openEvents.map((event) => {
@@ -6677,7 +6716,11 @@ var Search = ({
6677
6716
  event,
6678
6717
  labels,
6679
6718
  formatPercent,
6680
- formatCompactCurrency
6719
+ formatCompactCurrency,
6720
+ {
6721
+ priceByOutcomeId: searchDisplayPrices,
6722
+ isPriceLoading: midpointResult.isLoading
6723
+ }
6681
6724
  );
6682
6725
  if (!item) return null;
6683
6726
  nextEventsByResultId.set(item.id, event);
@@ -6687,7 +6730,14 @@ var Search = ({
6687
6730
  validatedResults: nextResults,
6688
6731
  eventsByResultId: nextEventsByResultId
6689
6732
  };
6690
- }, [formatCompactCurrency, formatPercent, labels, openEvents]);
6733
+ }, [
6734
+ formatCompactCurrency,
6735
+ formatPercent,
6736
+ labels,
6737
+ midpointResult.isLoading,
6738
+ openEvents,
6739
+ searchDisplayPrices
6740
+ ]);
6691
6741
  const hasSearchValue = trimmedValue.length > 0;
6692
6742
  const shouldRenderDropdown = isFocused && shouldSearchValue && !searchConfig.result && !searchConfig.isShowingAllResults;
6693
6743
  const resolvedIsActive = isFocused;
@@ -8771,9 +8821,8 @@ var collectOutcomePrices = (market, outcome, priceByOutcomeId) => {
8771
8821
  const prices = [];
8772
8822
  const seenOutcomeKeys = /* @__PURE__ */ new Set();
8773
8823
  const addPrice = (priceMarket, priceOutcome) => {
8774
- var _a2;
8775
8824
  if (!priceMarket || !priceOutcome) return;
8776
- const resolvedPrice = (_a2 = priceByOutcomeId == null ? void 0 : priceByOutcomeId.get(priceOutcome.id)) != null ? _a2 : priceOutcome.price;
8825
+ const resolvedPrice = priceByOutcomeId === void 0 ? priceOutcome.price : priceByOutcomeId.has(priceOutcome.id) ? priceByOutcomeId.get(priceOutcome.id) : void 0;
8777
8826
  const normalizedPrice = normalizeProbability(resolvedPrice);
8778
8827
  if (normalizedPrice == null) return;
8779
8828
  const key = `${priceMarket.id}:${priceOutcome.id}`;
@@ -11457,13 +11506,8 @@ var resolveChartVenueOutcomes = ({
11457
11506
  }) => {
11458
11507
  if (eligibleVenueOutcomes.length <= 1) return eligibleVenueOutcomes;
11459
11508
  const sortedEligibleVenueOutcomes = [...eligibleVenueOutcomes].sort((left, right) => {
11460
- var _a, _b;
11461
- const leftProbability = normalizeProbability(
11462
- (_a = livePrices.get(left.outcome.id)) != null ? _a : left.outcome.price
11463
- );
11464
- const rightProbability = normalizeProbability(
11465
- (_b = livePrices.get(right.outcome.id)) != null ? _b : right.outcome.price
11466
- );
11509
+ const leftProbability = normalizeProbability(livePrices.get(left.outcome.id));
11510
+ const rightProbability = normalizeProbability(livePrices.get(right.outcome.id));
11467
11511
  const probabilityDifference = (leftProbability != null ? leftProbability : 2) - (rightProbability != null ? rightProbability : 2);
11468
11512
  if (probabilityDifference !== 0) return probabilityDifference;
11469
11513
  if (left.venue === right.venue) return 0;
@@ -12556,6 +12600,12 @@ var EventListItemDetailsNotFoundState = ({
12556
12600
  }
12557
12601
  );
12558
12602
  };
12603
+ var resolveResolvedOutcomePriceMap = (outcomes) => {
12604
+ if (!(outcomes == null ? void 0 : outcomes.length)) return null;
12605
+ if (!outcomes.some((outcome) => outcome.winner === true)) return null;
12606
+ if (outcomes.some((outcome) => outcome.winner == null)) return null;
12607
+ return new Map(outcomes.map((outcome) => [outcome.id, outcome.winner === true ? 1 : 0]));
12608
+ };
12559
12609
  var EventListItemDetailsGraphSection = ({
12560
12610
  classNames,
12561
12611
  selectedChartType,
@@ -12677,6 +12727,18 @@ var EventListItemDetailsGraphSection = ({
12677
12727
  });
12678
12728
  });
12679
12729
  }, [availableMarkets, tradingContext == null ? void 0 : tradingContext.selectedMarket]);
12730
+ const resolvedOutcomePriceByMarketId = (0, import_react23.useMemo)(() => {
12731
+ const map = /* @__PURE__ */ new Map();
12732
+ for (const market of availableMarkets) {
12733
+ const marketTradingState = (0, import_hooks46.resolveMarketTradingState)(market);
12734
+ if (marketTradingState.kind !== "resolved") continue;
12735
+ const outcomePriceMap = resolveResolvedOutcomePriceMap(market.venueMarketOutcomes);
12736
+ if (outcomePriceMap) {
12737
+ map.set(market.id, outcomePriceMap);
12738
+ }
12739
+ }
12740
+ return map;
12741
+ }, [availableMarkets]);
12680
12742
  const resolvedVenueChartSeries = (0, import_react23.useMemo)(() => {
12681
12743
  return resolveMarketChartVenueSeries({
12682
12744
  chartData: scopedMarketChartData,
@@ -12772,8 +12834,8 @@ var EventListItemDetailsGraphSection = ({
12772
12834
  classNames == null ? void 0 : classNames.outcomeBadges
12773
12835
  ),
12774
12836
  children: chartAvailableVenueOutcomes.map((item) => {
12775
- var _a3;
12776
- const percentage = (_a3 = wsLivePrices.get(item.outcome.id)) != null ? _a3 : item.outcome.price;
12837
+ var _a3, _b3;
12838
+ const percentage = (_b3 = (_a3 = resolvedOutcomePriceByMarketId.get(item.market.id)) == null ? void 0 : _a3.get(item.outcome.id)) != null ? _b3 : wsLivePrices.get(item.outcome.id);
12777
12839
  const text = formatMarketProbabilityPercent(percentage, formatPercent);
12778
12840
  const seriesId = `${item.venue}-chart`;
12779
12841
  const isActiveVenue = activeGraphVenue === item.venue;
@@ -12836,21 +12898,21 @@ var EventListItemDetailsGraphSection = ({
12836
12898
  tradingContext == null ? void 0 : tradingContext.selectOutcome(outcomeId);
12837
12899
  },
12838
12900
  options: selectedMarketOutcomes.map((outcome) => {
12839
- var _a3, _b3, _c3;
12840
- const price = getDisplayOutcomePrice({
12901
+ var _a3, _b3, _c3, _d3, _e2;
12902
+ const resolvedPrice = availableMarkets[0] == null ? void 0 : (_b3 = resolvedOutcomePriceByMarketId.get(((_a3 = tradingContext == null ? void 0 : tradingContext.selectedMarket) != null ? _a3 : availableMarkets[0]).id)) == null ? void 0 : _b3.get(outcome.id);
12903
+ const price = resolvedPrice != null ? resolvedPrice : getDisplayOutcomePrice({
12841
12904
  outcomeId: outcome.id,
12842
12905
  outcomeLabel: outcome.label,
12843
- selection: (_a3 = tradingContext == null ? void 0 : tradingContext.tradeSide) != null ? _a3 : "buy",
12906
+ selection: (_c3 = tradingContext == null ? void 0 : tradingContext.tradeSide) != null ? _c3 : "buy",
12844
12907
  bestPrices,
12845
12908
  bestMidpoint,
12846
12909
  bestMidpointsByOutcomeId: restMidpoints,
12847
- livePrices,
12848
- fallbackPrice: outcome.price
12910
+ livePrices
12849
12911
  });
12850
12912
  return {
12851
12913
  value: outcome.id,
12852
- label: `${(_b3 = outcome.title) != null ? _b3 : outcome.label} ${formatProbabilityCents(price)}`,
12853
- ariaLabel: `${(_c3 = outcome.title) != null ? _c3 : outcome.label} ${formatProbabilityCents(price)}`
12914
+ label: `${(_d3 = outcome.title) != null ? _d3 : outcome.label} ${formatProbabilityCents(price)}`,
12915
+ ariaLabel: `${(_e2 = outcome.title) != null ? _e2 : outcome.label} ${formatProbabilityCents(price)}`
12854
12916
  };
12855
12917
  })
12856
12918
  }
@@ -13930,6 +13992,34 @@ var getMarketDetailsOutcomeButtonClassNames = ({
13930
13992
  text: cn(isSelected ? toneClasses.text : "text-agg-foreground")
13931
13993
  };
13932
13994
  };
13995
+ var OutcomePriceContent = ({
13996
+ isLoading,
13997
+ isSelected,
13998
+ value,
13999
+ textClassName
14000
+ }) => {
14001
+ if (isLoading) {
14002
+ return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
14003
+ "span",
14004
+ {
14005
+ "aria-hidden": "true",
14006
+ className: cn(
14007
+ "agg-market-details-outcome-price-loading",
14008
+ "h-4 w-10 shrink-0 rounded-agg-sm bg-agg-separator animate-pulse"
14009
+ )
14010
+ }
14011
+ );
14012
+ }
14013
+ return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
14014
+ Typography,
14015
+ {
14016
+ as: "span",
14017
+ variant: isSelected ? "body-strong" : "body",
14018
+ className: cn("shrink-0 whitespace-nowrap", textClassName),
14019
+ children: formatProbabilityCents(value)
14020
+ }
14021
+ );
14022
+ };
13933
14023
  var MarketDetailsOutcomeButton = ({
13934
14024
  ariaControls,
13935
14025
  enableAnimations,
@@ -13985,12 +14075,12 @@ var MarketDetailsOutcomeButton = ({
13985
14075
  }
13986
14076
  ) : null,
13987
14077
  /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
13988
- Typography,
14078
+ OutcomePriceContent,
13989
14079
  {
13990
- as: "span",
13991
- variant: isSelected ? "body-strong" : "body",
13992
- className: cn("shrink-0 whitespace-nowrap", classNames.text),
13993
- children: formatProbabilityCents(item.probability)
14080
+ isLoading: item.isPriceLoading,
14081
+ isSelected,
14082
+ value: item.probability,
14083
+ textClassName: classNames.text
13994
14084
  }
13995
14085
  )
13996
14086
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)("div", { className: "inline-flex max-w-full items-center justify-center gap-1.5", children: [
@@ -14005,12 +14095,12 @@ var MarketDetailsOutcomeButton = ({
14005
14095
  }
14006
14096
  ),
14007
14097
  /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
14008
- Typography,
14098
+ OutcomePriceContent,
14009
14099
  {
14010
- as: "span",
14011
- variant: isSelected ? "body-strong" : "body",
14012
- className: cn("shrink-0 whitespace-nowrap", classNames.text),
14013
- children: formatProbabilityCents(item.probability)
14100
+ isLoading: item.isPriceLoading,
14101
+ isSelected,
14102
+ value: item.probability,
14103
+ textClassName: classNames.text
14014
14104
  }
14015
14105
  )
14016
14106
  ] })
@@ -14202,9 +14292,8 @@ var MarketDetailsGraphPanel = ({
14202
14292
  var _a2, _b2, _c2, _d;
14203
14293
  return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("div", { className: "agg-chart-toolbar w-full flex flex-col gap-4 md:flex-row md:items-center md:justify-between", children: [
14204
14294
  /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { className: "agg-market-venues flex flex-wrap gap-2", children: chartAvailableOutcomesByVenue.map((item) => {
14205
- var _a3;
14206
14295
  const probability = formatProbabilityPercent(
14207
- (_a3 = wsLivePrices.get(item.outcome.id)) != null ? _a3 : item.outcome.price,
14296
+ wsLivePrices.get(item.outcome.id),
14208
14297
  formatPercent
14209
14298
  );
14210
14299
  const isActiveVenue = selectedGraphVenue === item.venue;
@@ -14415,16 +14504,8 @@ var MarketDetailsContent = ({
14415
14504
  isResolvedMarket ? [] : resolvedMarket == null ? void 0 : resolvedMarket.venueMarkets,
14416
14505
  (_b = scopedResolvedMarket == null ? void 0 : scopedResolvedMarket.id) != null ? _b : null
14417
14506
  );
14418
- const clusterMidpointResult = midpointsResult != null ? midpointsResult : {
14419
- prices: /* @__PURE__ */ new Map(),
14420
- bestMidpointsByOutcomeId: /* @__PURE__ */ new Map(),
14421
- venueByOutcomeId: /* @__PURE__ */ new Map(),
14422
- bestPrices: /* @__PURE__ */ new Map(),
14423
- bestPriceVenuesByOutcomeId: /* @__PURE__ */ new Map(),
14424
- isLoading: false,
14425
- bestMidpoint: void 0,
14426
- bestMidpointVenue: void 0
14427
- };
14507
+ const fetchedClusterMidpointResult = (0, import_hooks49.useMidpoints)(midpointsResult ? [] : clusterVenueMarkets);
14508
+ const clusterMidpointResult = midpointsResult != null ? midpointsResult : fetchedClusterMidpointResult;
14428
14509
  const clusterMidpoints = (_c = clusterMidpointResult.bestMidpointsByOutcomeId) != null ? _c : clusterMidpointResult.prices;
14429
14510
  const clusterBestMidpointsByOutcomeId = clusterMidpoints;
14430
14511
  const clusterVenueByOutcomeId = clusterMidpointResult.venueByOutcomeId;
@@ -14584,18 +14665,24 @@ var MarketDetailsContent = ({
14584
14665
  });
14585
14666
  const bestVenue = candidate == null ? void 0 : candidate.venue;
14586
14667
  const outcomeBestPrice = candidate == null ? void 0 : candidate.price;
14668
+ const isPriceLoading = !isResolvedMarket && outcomeBestPrice == null && clusterMidpointResult.isLoading;
14587
14669
  if (isResolvedMarket) {
14588
14670
  const isWinningOutcome = item.id === ((_a2 = marketTradingState.winningOutcome) == null ? void 0 : _a2.id);
14589
14671
  return __spreadValues(__spreadProps(__spreadValues({}, item), {
14590
- probability: isWinningOutcome ? 1 : 0
14672
+ probability: isWinningOutcome ? 1 : 0,
14673
+ isPriceLoading: false
14591
14674
  }), bestVenue ? { venue: bestVenue } : {});
14592
14675
  }
14593
14676
  if (outcomeBestPrice != null) {
14594
14677
  return __spreadValues(__spreadProps(__spreadValues({}, item), {
14595
- probability: outcomeBestPrice
14678
+ probability: outcomeBestPrice,
14679
+ isPriceLoading: false
14596
14680
  }), bestVenue ? { venue: bestVenue } : {});
14597
14681
  }
14598
- return item;
14682
+ return __spreadProps(__spreadValues({}, item), {
14683
+ probability: void 0,
14684
+ isPriceLoading
14685
+ });
14599
14686
  });
14600
14687
  }, [
14601
14688
  clusterBestMidpoint,
@@ -14617,7 +14704,7 @@ var MarketDetailsContent = ({
14617
14704
  wsBestCandidates
14618
14705
  ]);
14619
14706
  const headlineProbability = (0, import_react27.useMemo)(() => {
14620
- var _a2, _b2, _c2, _d2;
14707
+ var _a2;
14621
14708
  if (!model || !scopedMarketForCard) return void 0;
14622
14709
  if (isResolvedMarket) {
14623
14710
  const yesOutcome2 = resolveYesOutcome(scopedMarketForCard);
@@ -14625,10 +14712,7 @@ var MarketDetailsContent = ({
14625
14712
  return yesOutcome2.winner === true ? 1 : 0;
14626
14713
  }
14627
14714
  const yesOutcome = resolveYesOutcome(scopedMarketForCard);
14628
- const displayOutcome = yesOutcome != null ? yesOutcome : (_b2 = scopedMarketForCard.venueMarketOutcomes) == null ? void 0 : _b2.reduce(
14629
- (acc, outcome) => outcome.price > acc.price ? outcome : acc,
14630
- (_a2 = scopedMarketForCard.venueMarketOutcomes) == null ? void 0 : _a2[0]
14631
- );
14715
+ const displayOutcome = yesOutcome != null ? yesOutcome : (_a2 = scopedMarketForCard.venueMarketOutcomes) == null ? void 0 : _a2[0];
14632
14716
  if (displayOutcome == null) return void 0;
14633
14717
  const referencePrice = getDisplayOutcomePrice({
14634
14718
  outcomeId: displayOutcome.id,
@@ -14638,10 +14722,10 @@ var MarketDetailsContent = ({
14638
14722
  bestMidpoint: clusterBestMidpoint,
14639
14723
  bestMidpointsByOutcomeId: clusterBestMidpointsByOutcomeId,
14640
14724
  livePrices: wsLivePrices,
14641
- fallbackPrice: (_c2 = midpointsFallback == null ? void 0 : midpointsFallback.get(displayOutcome.id)) != null ? _c2 : displayOutcome.price
14725
+ fallbackPrice: midpointsFallback == null ? void 0 : midpointsFallback.get(displayOutcome.id)
14642
14726
  });
14643
14727
  if (referencePrice != null) return referencePrice;
14644
- return (_d2 = (0, import_hooks49.findLivePriceById)(wsLivePrices, displayOutcome.id)) != null ? _d2 : displayOutcome.price;
14728
+ return (0, import_hooks49.findLivePriceById)(wsLivePrices, displayOutcome.id);
14645
14729
  }, [
14646
14730
  clusterBestMidpoint,
14647
14731
  clusterBestMidpointsByOutcomeId,
@@ -16206,7 +16290,7 @@ var mapVenueMarketOutcomesToPlaceOrderOutcomes = (venueMarketOutcomes) => {
16206
16290
  label: outcome.label,
16207
16291
  title: (_a = outcome.title) != null ? _a : null,
16208
16292
  price: outcome.price,
16209
- priceLabel: getTradingPriceLabel(outcome.price)
16293
+ priceLabel: outcome.price != null ? getTradingPriceLabel(outcome.price) : ""
16210
16294
  };
16211
16295
  });
16212
16296
  };
@@ -18426,16 +18510,10 @@ var PlaceOrder = ({
18426
18510
  scopedSelectedMarket ? [scopedSelectedMarket] : void 0
18427
18511
  );
18428
18512
  const wsBestPrices = (0, import_hooks54.useLiveBestPrices)(scopedSelectedMarket ? [scopedSelectedMarket] : void 0);
18429
- const clusterMidpointResult = midpointsResult != null ? midpointsResult : {
18430
- prices: /* @__PURE__ */ new Map(),
18431
- bestMidpointsByOutcomeId: /* @__PURE__ */ new Map(),
18432
- venueByOutcomeId: /* @__PURE__ */ new Map(),
18433
- bestPrices: /* @__PURE__ */ new Map(),
18434
- bestPriceVenuesByOutcomeId: /* @__PURE__ */ new Map(),
18435
- isLoading: false,
18436
- bestMidpoint: void 0,
18437
- bestMidpointVenue: void 0
18438
- };
18513
+ const fetchedClusterMidpointResult = (0, import_hooks54.useMidpoints)(
18514
+ midpointsResult ? [] : scopedSelectedMarket ? [scopedSelectedMarket] : []
18515
+ );
18516
+ const clusterMidpointResult = midpointsResult != null ? midpointsResult : fetchedClusterMidpointResult;
18439
18517
  const clusterBestMidpointsByOutcomeId = (_i = clusterMidpointResult.bestMidpointsByOutcomeId) != null ? _i : clusterMidpointResult.prices;
18440
18518
  const clusterBestMidpoint = clusterMidpointResult.bestMidpoint;
18441
18519
  const clusterBestPricesRest = clusterMidpointResult.bestPrices;
@@ -19618,11 +19696,11 @@ var PlaceOrder = ({
19618
19696
  bestPrices: clusterBestPrices,
19619
19697
  bestMidpoint: clusterBestMidpoint,
19620
19698
  bestMidpointsByOutcomeId: clusterBestMidpointsByOutcomeId,
19621
- livePrices,
19622
- fallbackPrice: outcome.price
19699
+ livePrices
19623
19700
  });
19624
19701
  const isActive = outcome.id === scopedSelectedOutcomeId;
19625
19702
  const isPositive = resolveIsPositiveOutcome(outcome, index);
19703
+ const isPriceLoading = clusterMidpointResult.isLoading && price == null;
19626
19704
  return /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(
19627
19705
  "button",
19628
19706
  {
@@ -19652,7 +19730,16 @@ var PlaceOrder = ({
19652
19730
  children: (_c2 = outcome.title) != null ? _c2 : outcome.label
19653
19731
  }
19654
19732
  ),
19655
- /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(Typography, { as: "span", variant: isActive ? "body-strong" : "body", children: formatProbabilityCents(price) })
19733
+ isPriceLoading ? /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
19734
+ "span",
19735
+ {
19736
+ "aria-hidden": "true",
19737
+ className: cn(
19738
+ "agg-place-order-outcome-price-loading",
19739
+ "h-4 w-10 shrink-0 rounded-agg-sm bg-agg-separator animate-pulse"
19740
+ )
19741
+ }
19742
+ ) : /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(Typography, { as: "span", variant: isActive ? "body-strong" : "body", children: formatProbabilityCents(price) })
19656
19743
  ]
19657
19744
  },
19658
19745
  outcome.id
@@ -20839,6 +20926,7 @@ var SPORTS_PERIOD_KEYS = [
20839
20926
  "first_5_innings",
20840
20927
  "other"
20841
20928
  ];
20929
+ var SPORTS_PERIOD_GRAMMAR_PATTERN = /^(?:(set|map|game|period|inning)_(\d{1,2})|first_(\d{1,2})_innings)$/;
20842
20930
  var SPORTS_MARKET_CATEGORY_KEYS = [
20843
20931
  "game_lines",
20844
20932
  "exact_score",
@@ -20967,9 +21055,22 @@ var stripLineValueFromQuestion = (question) => {
20967
21055
  const strippedQuestion = sanitizeFamilyValue(question);
20968
21056
  return strippedQuestion ? question.replace(/\(\s*[+-]?\d+(?:\.\d+)?\s*\)\s*$/g, "").replace(/\s+[+-]?\d+(?:\.\d+)?\s*$/g, "").replace(/\s+/g, " ").trim() : question.trim();
20969
21057
  };
21058
+ var SPORTS_PERIOD_FAMILY_ORDER = ["period", "inning", "set", "map", "game"];
20970
21059
  var getSportsPeriodOrderIndex = (period) => {
21060
+ var _a, _b;
20971
21061
  const periodIndex = SPORTS_PERIOD_ORDER.indexOf(period);
20972
- return periodIndex >= 0 ? periodIndex : SPORTS_PERIOD_ORDER.length;
21062
+ if (periodIndex >= 0) {
21063
+ return period === "other" ? Number.MAX_SAFE_INTEGER : periodIndex;
21064
+ }
21065
+ const grammarMatch = SPORTS_PERIOD_GRAMMAR_PATTERN.exec(period);
21066
+ if (grammarMatch) {
21067
+ const familyIndex = grammarMatch[1] ? SPORTS_PERIOD_FAMILY_ORDER.indexOf(
21068
+ grammarMatch[1]
21069
+ ) : SPORTS_PERIOD_FAMILY_ORDER.length;
21070
+ const scopeNumber = Number((_b = (_a = grammarMatch[2]) != null ? _a : grammarMatch[3]) != null ? _b : 0);
21071
+ return SPORTS_PERIOD_ORDER.length + familyIndex * 100 + scopeNumber;
21072
+ }
21073
+ return Number.MAX_SAFE_INTEGER - 1;
20973
21074
  };
20974
21075
  var getSportsMarketTypeOrderIndex = (sportsMarketType) => {
20975
21076
  if (!sportsMarketType) return SPORTS_MARKET_TYPE_ORDER.length;
@@ -20986,7 +21087,10 @@ var resolveSportsSectionDefinition = (key) => {
20986
21087
  var normalizeSportsPeriod = (value) => {
20987
21088
  const resolvedValue = toTrimmedString(value).toLowerCase();
20988
21089
  if (!resolvedValue) return "full";
20989
- return SPORTS_PERIOD_KEY_SET.has(resolvedValue) ? resolvedValue : "other";
21090
+ if (resolvedValue === "match") return "full";
21091
+ if (SPORTS_PERIOD_KEY_SET.has(resolvedValue)) return resolvedValue;
21092
+ if (SPORTS_PERIOD_GRAMMAR_PATTERN.test(resolvedValue)) return resolvedValue;
21093
+ return "other";
20990
21094
  };
20991
21095
  var normalizeSportsMarketType = (value) => {
20992
21096
  const resolvedValue = toTrimmedString(value).toLowerCase();
@@ -21069,8 +21173,7 @@ var isBinarySportsMoneylineMarket = (market) => {
21069
21173
  );
21070
21174
  const marketSubtype = toTrimmedString(market.marketSubtype).toLowerCase();
21071
21175
  const marketGroup = normalizeSportsMarketGroup(market.marketGroup);
21072
- const hasMoneylineAggKey = toTrimmedString(market.aggKey).includes("_ml_");
21073
- return (marketSubtype === "moneyline" || hasMoneylineAggKey) && marketGroup === "game_lines" && normalizeSportsPeriod(market.period) === "full" && normalizedOutcomeLabels.length === 2 && normalizedOutcomeLabels.every((label2) => YES_NO_LABELS.has(label2));
21176
+ return marketSubtype === "moneyline" && marketGroup === "game_lines" && normalizeSportsPeriod(market.period) === "full" && normalizedOutcomeLabels.length === 2 && normalizedOutcomeLabels.every((label2) => YES_NO_LABELS.has(label2));
21074
21177
  };
21075
21178
  var resolveDisplayGroupFamilyKey = (market) => {
21076
21179
  var _a, _b, _c;
@@ -21295,6 +21398,15 @@ var buildSportsSlideFromGroup = (group) => {
21295
21398
  defaultStopIndex
21296
21399
  };
21297
21400
  };
21401
+ var formatSportsPeriodGrammarLabel = (period) => {
21402
+ const grammarMatch = SPORTS_PERIOD_GRAMMAR_PATTERN.exec(period);
21403
+ if (!grammarMatch) return null;
21404
+ if (grammarMatch[1]) {
21405
+ const family = grammarMatch[1].charAt(0).toUpperCase() + grammarMatch[1].slice(1);
21406
+ return `${family} ${Number(grammarMatch[2])}`;
21407
+ }
21408
+ return `First ${Number(grammarMatch[3])} Innings`;
21409
+ };
21298
21410
  var resolveSportsCategoryTokens = (event) => {
21299
21411
  return new Set(
21300
21412
  event.categories.flatMap((entry) => {
@@ -21428,7 +21540,7 @@ var SportsMarketCard = ({
21428
21540
  const combinedMoneylineHeaderOutcomeItems = (0, import_react36.useMemo)(() => {
21429
21541
  if (!isCombinedMoneylineGroup) return void 0;
21430
21542
  return combinedMoneylineMarkets.flatMap((market, index) => {
21431
- var _a2;
21543
+ var _a2, _b2;
21432
21544
  const typedMarket = market;
21433
21545
  const yesOutcome = market.venueMarketOutcomes.find(
21434
21546
  (outcome) => outcome.label.trim().toLowerCase() === "yes"
@@ -21436,19 +21548,25 @@ var SportsMarketCard = ({
21436
21548
  if (!yesOutcome) return [];
21437
21549
  const label2 = ((_a2 = typedMarket.shortTitle) == null ? void 0 : _a2.trim()) || market.question.trim();
21438
21550
  if (!label2) return [];
21551
+ const probability = midpointsResult == null ? void 0 : getDisplayOutcomePrice({
21552
+ outcomeId: yesOutcome.id,
21553
+ outcomeLabel: yesOutcome.label,
21554
+ bestMidpointsByOutcomeId: (_b2 = midpointsResult.bestMidpointsByOutcomeId) != null ? _b2 : midpointsResult.prices
21555
+ });
21439
21556
  return [
21440
21557
  {
21441
21558
  id: yesOutcome.id,
21442
21559
  label: label2,
21443
21560
  title: label2,
21444
- probability: yesOutcome.price,
21561
+ probability,
21562
+ isPriceLoading: (midpointsResult == null ? void 0 : midpointsResult.isLoading) === true && probability == null,
21445
21563
  tone: index === 0 ? "positive" : "negative",
21446
21564
  variant: "outcome",
21447
21565
  venue: market.venue
21448
21566
  }
21449
21567
  ];
21450
21568
  });
21451
- }, [combinedMoneylineMarkets, isCombinedMoneylineGroup]);
21569
+ }, [combinedMoneylineMarkets, isCombinedMoneylineGroup, midpointsResult]);
21452
21570
  const headerOutcomeVariant = isCombinedMoneylineGroup ? "outcome" : resolveSportsMarketCardVariant(activeMarket);
21453
21571
  const handleLineSelect = (index) => {
21454
21572
  var _a2, _b2;
@@ -21532,6 +21650,7 @@ var resolveSportsSectionLabel = (labels, key) => {
21532
21650
  }
21533
21651
  };
21534
21652
  var resolveSportsPeriodLabel = (labels, period) => {
21653
+ var _a;
21535
21654
  switch (period) {
21536
21655
  case "full":
21537
21656
  return labels.eventMarketPage.sports.fullPeriod;
@@ -21559,6 +21678,8 @@ var resolveSportsPeriodLabel = (labels, period) => {
21559
21678
  return "1st 5 Innings";
21560
21679
  case "other":
21561
21680
  return labels.eventMarketPage.sports.otherPeriod;
21681
+ default:
21682
+ return (_a = formatSportsPeriodGrammarLabel(period)) != null ? _a : labels.eventMarketPage.sports.otherPeriod;
21562
21683
  }
21563
21684
  };
21564
21685
  var SportsTabButton = ({
package/dist/pages.mjs CHANGED
@@ -8,17 +8,17 @@ import {
8
8
  UserProfilePage,
9
9
  buildAggTxExplorerHref,
10
10
  useHomePageModals
11
- } from "./chunk-FLESSOSU.mjs";
12
- import "./chunk-TBZWRUFB.mjs";
11
+ } from "./chunk-DTOI4V6P.mjs";
12
+ import "./chunk-BTRFSEPC.mjs";
13
13
  import {
14
14
  DEPOSIT_MODAL_OPEN_EVENT,
15
15
  WITHDRAW_MODAL_OPEN_EVENT,
16
16
  requestAggDepositModalOpen,
17
17
  requestAggWithdrawModalOpen
18
- } from "./chunk-BW7S2YR3.mjs";
19
- import "./chunk-R2YNZJZ3.mjs";
20
- import "./chunk-T4YZGAYS.mjs";
21
- import "./chunk-VP76G6PN.mjs";
18
+ } from "./chunk-73MO7MYG.mjs";
19
+ import "./chunk-TR7HUVY7.mjs";
20
+ import "./chunk-5MRFY5ZQ.mjs";
21
+ import "./chunk-MIAAL7BL.mjs";
22
22
  export {
23
23
  DEPOSIT_MODAL_OPEN_EVENT,
24
24
  EventMarketPage,