@agg-build/ui 2.1.5 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/{chunk-T4YZGAYS.mjs → chunk-4QGZ3FWI.mjs} +1 -1
  2. package/dist/{chunk-XUBIJI4R.mjs → chunk-JGBEQ4IV.mjs} +1079 -872
  3. package/dist/{chunk-BW7S2YR3.mjs → chunk-JOZPXDNZ.mjs} +48 -21
  4. package/dist/{chunk-R2YNZJZ3.mjs → chunk-LPIAEKSZ.mjs} +82 -2
  5. package/dist/{chunk-TBZWRUFB.mjs → chunk-QM3WWPCV.mjs} +201 -87
  6. package/dist/{chunk-VP76G6PN.mjs → chunk-UTXQUOU3.mjs} +177 -27
  7. package/dist/{chunk-XHE2VO3S.mjs → chunk-ZRYHWHTD.mjs} +2 -2
  8. package/dist/events.js +369 -82
  9. package/dist/events.mjs +3 -3
  10. package/dist/index.js +2180 -1621
  11. package/dist/index.mjs +9 -7
  12. package/dist/modals.js +2 -2
  13. package/dist/modals.mjs +3 -3
  14. package/dist/pages.js +1552 -995
  15. package/dist/pages.mjs +6 -6
  16. package/dist/primitives.js +74 -26
  17. package/dist/primitives.mjs +1 -1
  18. package/dist/styles.css +1 -1
  19. package/dist/tailwind.css +1 -1
  20. package/dist/trading.js +131 -20
  21. package/dist/trading.mjs +4 -4
  22. package/dist/types/events/item/event-list-item.types.d.mts +6 -2
  23. package/dist/types/events/item/event-list-item.types.d.ts +6 -2
  24. package/dist/types/events/item/event-list-item.utils.d.mts +3 -2
  25. package/dist/types/events/item/event-list-item.utils.d.ts +3 -2
  26. package/dist/types/events/item-details/event-list-item-details.types.d.mts +0 -6
  27. package/dist/types/events/item-details/event-list-item-details.types.d.ts +0 -6
  28. package/dist/types/events/item-details/event-list-item-details.utils.d.mts +9 -0
  29. package/dist/types/events/item-details/event-list-item-details.utils.d.ts +9 -0
  30. package/dist/types/events/market-details/market-details.types.d.mts +1 -0
  31. package/dist/types/events/market-details/market-details.types.d.ts +1 -0
  32. package/dist/types/events/shared/chart-venue-selection.d.mts +2 -1
  33. package/dist/types/events/shared/chart-venue-selection.d.ts +2 -1
  34. package/dist/types/events/shared/event-trading-state.utils.d.mts +4 -2
  35. package/dist/types/events/shared/event-trading-state.utils.d.ts +4 -2
  36. package/dist/types/pages/event-market/sports-event-market.utils.d.mts +1 -1
  37. package/dist/types/pages/event-market/sports-event-market.utils.d.ts +1 -1
  38. package/dist/types/pages/user-profile/components/claim-activity-breakdown-modal.d.mts +8 -0
  39. package/dist/types/pages/user-profile/components/claim-activity-breakdown-modal.d.ts +8 -0
  40. package/dist/types/pages/user-profile/index.d.mts +1 -1
  41. package/dist/types/pages/user-profile/index.d.ts +1 -1
  42. package/dist/types/pages/user-profile/user-profile.types.d.mts +14 -0
  43. package/dist/types/pages/user-profile/user-profile.types.d.ts +14 -0
  44. package/dist/types/primitives/search/search.types.d.mts +1 -0
  45. package/dist/types/primitives/search/search.types.d.ts +1 -0
  46. package/dist/types/primitives/search/search.utils.d.mts +4 -1
  47. package/dist/types/primitives/search/search.utils.d.ts +4 -1
  48. package/dist/types/shared/utils.d.mts +16 -0
  49. package/dist/types/shared/utils.d.ts +16 -0
  50. package/dist/types/trading/types.d.mts +2 -1
  51. package/dist/types/trading/types.d.ts +2 -1
  52. package/package.json +3 -3
package/dist/events.js CHANGED
@@ -104,6 +104,92 @@ var toDate = (value) => {
104
104
  if (Number.isNaN(parsed.getTime())) return null;
105
105
  return parsed;
106
106
  };
107
+ var GENERIC_BINARY_OUTCOME_LABELS = /* @__PURE__ */ new Set(["yes", "no"]);
108
+ var TOTAL_OUTCOME_LABELS = /* @__PURE__ */ new Set(["over", "under"]);
109
+ var DIRECTIONAL_OUTCOME_LABELS = /* @__PURE__ */ new Set(["up", "down"]);
110
+ var NUMERIC_TOKEN_RE = /[-+]?\d+(?:\.\d+)?/;
111
+ var UP_OR_DOWN_QUESTION_RE = /\bup or down\b/i;
112
+ var normalizeResolvedOutcomeLabel = (value) => {
113
+ const trimmedValue = value == null ? void 0 : value.trim();
114
+ return trimmedValue ? trimmedValue : null;
115
+ };
116
+ var readOutcomeMetadataLabel = (outcome) => {
117
+ const outcomeRecord = outcome;
118
+ for (const key of ["displayName", "name", "title"]) {
119
+ const value = outcomeRecord[key];
120
+ if (typeof value !== "string") continue;
121
+ const normalizedValue = normalizeResolvedOutcomeLabel(value);
122
+ if (normalizedValue) return normalizedValue;
123
+ }
124
+ return null;
125
+ };
126
+ var formatLineValue = (value) => {
127
+ return Number.isInteger(value) ? String(value) : String(value);
128
+ };
129
+ var readMarketLabel = (market) => {
130
+ var _a;
131
+ const rawLabel = (_a = normalizeResolvedOutcomeLabel(market == null ? void 0 : market.shortTitle)) != null ? _a : normalizeResolvedOutcomeLabel(market == null ? void 0 : market.question);
132
+ if (!rawLabel) return null;
133
+ if (/^draw\s*\(/i.test(rawLabel)) return "Draw";
134
+ return rawLabel;
135
+ };
136
+ var deriveTotalOutcomeLabel = (outcome, metadataLabel) => {
137
+ const normalizedMetadataLabel = metadataLabel == null ? void 0 : metadataLabel.trim().toLowerCase();
138
+ if (normalizedMetadataLabel && TOTAL_OUTCOME_LABELS.has(normalizedMetadataLabel)) {
139
+ return metadataLabel;
140
+ }
141
+ const normalizedRawLabel = outcome.label.trim().toLowerCase();
142
+ if (normalizedRawLabel === "yes") return "Over";
143
+ if (normalizedRawLabel === "no") return "Under";
144
+ return metadataLabel;
145
+ };
146
+ var resolveResolvedOutcomeLabel = ({
147
+ market,
148
+ outcome,
149
+ allowSportsMoneylineMarketFallback = true
150
+ }) => {
151
+ var _a;
152
+ if (!outcome) return null;
153
+ const rawLabel = normalizeResolvedOutcomeLabel(outcome.label);
154
+ const metadataLabel = readOutcomeMetadataLabel(outcome);
155
+ const normalizedRawLabel = (_a = rawLabel == null ? void 0 : rawLabel.toLowerCase()) != null ? _a : "";
156
+ const isGenericBinary = GENERIC_BINARY_OUTCOME_LABELS.has(normalizedRawLabel);
157
+ const isSportsMarket = Boolean(
158
+ (market == null ? void 0 : market.sportsMarketType) || (market == null ? void 0 : market.marketGroup) || (market == null ? void 0 : market.lineValue) != null
159
+ );
160
+ if (!isSportsMarket) {
161
+ const isDirectionalBinaryMarket = Boolean((market == null ? void 0 : market.question) && UP_OR_DOWN_QUESTION_RE.test(market.question)) && Boolean(metadataLabel && DIRECTIONAL_OUTCOME_LABELS.has(metadataLabel.trim().toLowerCase()));
162
+ if (isDirectionalBinaryMarket) return metadataLabel;
163
+ if (isGenericBinary) return rawLabel;
164
+ return metadataLabel != null ? metadataLabel : rawLabel;
165
+ }
166
+ const lineValue = typeof (market == null ? void 0 : market.lineValue) === "number" ? market.lineValue : null;
167
+ const isMoneylineMarket = (market == null ? void 0 : market.sportsMarketType) === "moneyline" || (market == null ? void 0 : market.marketGroup) === "game_lines";
168
+ const isTotalMarket = (market == null ? void 0 : market.sportsMarketType) === "total" || (market == null ? void 0 : market.marketGroup) === "totals";
169
+ if (isMoneylineMarket && metadataLabel) return metadataLabel;
170
+ if (allowSportsMoneylineMarketFallback && isMoneylineMarket && isGenericBinary) {
171
+ const marketLabel = readMarketLabel(market);
172
+ if (marketLabel) return marketLabel;
173
+ }
174
+ if (isTotalMarket) {
175
+ const totalLabel = deriveTotalOutcomeLabel(outcome, metadataLabel);
176
+ if (totalLabel && lineValue != null && !NUMERIC_TOKEN_RE.test(totalLabel)) {
177
+ return `${totalLabel} ${formatLineValue(Math.abs(lineValue))}`;
178
+ }
179
+ if (totalLabel) return totalLabel;
180
+ }
181
+ const isSpreadMarket = (market == null ? void 0 : market.sportsMarketType) === "spread" || (market == null ? void 0 : market.marketGroup) === "spreads";
182
+ if (isSpreadMarket && metadataLabel) {
183
+ if (lineValue != null && !NUMERIC_TOKEN_RE.test(metadataLabel)) {
184
+ const resolvedLineValue = normalizedRawLabel === "no" ? Math.abs(lineValue) : lineValue;
185
+ const formattedLineValue = resolvedLineValue > 0 ? `+${formatLineValue(resolvedLineValue)}` : formatLineValue(resolvedLineValue);
186
+ return `${metadataLabel} ${formattedLineValue}`;
187
+ }
188
+ return metadataLabel;
189
+ }
190
+ if (metadataLabel) return metadataLabel;
191
+ return rawLabel;
192
+ };
107
193
 
108
194
  // src/primitives/icon/types.ts
109
195
  var getIconA11yProps = (title2) => ({
@@ -3688,7 +3774,8 @@ var normalizeSeries = (series) => {
3688
3774
  }).filter((seriesItem) => seriesItem.points.length > 0);
3689
3775
  };
3690
3776
  var formatDefaultChartValue = (value) => {
3691
- return `${Number(value).toFixed(2)}%`;
3777
+ const roundedValue = Number(value.toFixed(1));
3778
+ return `${Number.isInteger(roundedValue) ? String(roundedValue) : roundedValue.toFixed(1)}%`;
3692
3779
  };
3693
3780
  var resolveChartTimeFormatter = (windowSeconds) => {
3694
3781
  return (timestamp) => {
@@ -5383,7 +5470,7 @@ var sizeClasses2 = {
5383
5470
  var lineColorByVenue = {
5384
5471
  light: {
5385
5472
  [import_sdk10.Venue.kalshi]: "#00D295",
5386
- [import_sdk10.Venue.limitless]: "#000000",
5473
+ [import_sdk10.Venue.limitless]: "#C4FF00",
5387
5474
  [import_sdk10.Venue.opinion]: "#000000",
5388
5475
  [import_sdk10.Venue.polymarket]: "#2E5CFF",
5389
5476
  [import_sdk10.Venue.predict]: "#6D57F8",
@@ -5393,7 +5480,7 @@ var lineColorByVenue = {
5393
5480
  },
5394
5481
  dark: {
5395
5482
  [import_sdk10.Venue.kalshi]: "#00D295",
5396
- [import_sdk10.Venue.limitless]: "#FFFFFF",
5483
+ [import_sdk10.Venue.limitless]: "#C4FF00",
5397
5484
  [import_sdk10.Venue.opinion]: "#FFFFFF",
5398
5485
  [import_sdk10.Venue.polymarket]: "#2E5CFF",
5399
5486
  [import_sdk10.Venue.predict]: "#6D57F8",
@@ -5712,13 +5799,26 @@ var formatMarketProbabilityPercent = (value, formatPercent = formatWholePercent)
5712
5799
  }
5713
5800
  return formattedValue;
5714
5801
  };
5715
- var formatPriceGapPercent = (value) => {
5802
+ var formatPriceGapPercent = (value, mode = "percent") => {
5716
5803
  if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
5804
+ if (value <= 0) return void 0;
5805
+ if (mode === "fraction") {
5806
+ const percentageValue = value * 100;
5807
+ if (percentageValue < import_hooks25.MIN_PRICE_GAP_PCT) return void 0;
5808
+ return `${Math.round(percentageValue)}%`;
5809
+ }
5717
5810
  if (value < import_hooks25.MIN_PRICE_GAP_PCT) return void 0;
5718
5811
  if (value > import_hooks25.MAX_PRICE_GAP_PCT) return void 0;
5719
5812
  return `${Math.round(value)}%`;
5720
5813
  };
5721
5814
  var sortOutcomes = (outcomes) => {
5815
+ return sortOutcomesWithPrices(outcomes);
5816
+ };
5817
+ var resolveOutcomeProbability = (outcome, priceByOutcomeId) => {
5818
+ const resolvedPrice = priceByOutcomeId === void 0 ? outcome.price : priceByOutcomeId.has(outcome.id) ? priceByOutcomeId.get(outcome.id) : void 0;
5819
+ return normalizeProbability(resolvedPrice);
5820
+ };
5821
+ var sortOutcomesWithPrices = (outcomes, priceByOutcomeId) => {
5722
5822
  if (outcomes.length <= 1) return outcomes;
5723
5823
  if (hasBinaryOutcomes(outcomes)) {
5724
5824
  return sortYesFirst(outcomes);
@@ -5734,8 +5834,8 @@ var sortOutcomes = (outcomes) => {
5734
5834
  }
5735
5835
  return [...outcomes].sort((a, b) => {
5736
5836
  var _a, _b;
5737
- const aPrice = (_a = normalizeProbability(a.price)) != null ? _a : 0;
5738
- const bPrice = (_b = normalizeProbability(b.price)) != null ? _b : 0;
5837
+ const aPrice = (_a = resolveOutcomeProbability(a, priceByOutcomeId)) != null ? _a : 0;
5838
+ const bPrice = (_b = resolveOutcomeProbability(b, priceByOutcomeId)) != null ? _b : 0;
5739
5839
  return bPrice - aPrice;
5740
5840
  });
5741
5841
  };
@@ -7215,9 +7315,8 @@ var collectOutcomePrices = (market, outcome, priceByOutcomeId) => {
7215
7315
  const prices = [];
7216
7316
  const seenOutcomeKeys = /* @__PURE__ */ new Set();
7217
7317
  const addPrice = (priceMarket, priceOutcome) => {
7218
- var _a2;
7219
7318
  if (!priceMarket || !priceOutcome) return;
7220
- const resolvedPrice = (_a2 = priceByOutcomeId == null ? void 0 : priceByOutcomeId.get(priceOutcome.id)) != null ? _a2 : priceOutcome.price;
7319
+ const resolvedPrice = priceByOutcomeId === void 0 ? priceOutcome.price : priceByOutcomeId.has(priceOutcome.id) ? priceByOutcomeId.get(priceOutcome.id) : void 0;
7221
7320
  const normalizedPrice = normalizeProbability(resolvedPrice);
7222
7321
  if (normalizedPrice == null) return;
7223
7322
  const key = `${priceMarket.id}:${priceOutcome.id}`;
@@ -7399,6 +7498,24 @@ var buildOutcomeMidpointsByOutcomeId = (midpointRows) => {
7399
7498
  }
7400
7499
  return outcomeMidpointsByOutcomeId;
7401
7500
  };
7501
+ var buildArbReturnByVenueMarketId = (midpointRows) => {
7502
+ const arbReturnByVenueMarketId = /* @__PURE__ */ new Map();
7503
+ const addArbReturn = (value) => {
7504
+ var _a, _b;
7505
+ if (!value || typeof value !== "object") return;
7506
+ const row = value;
7507
+ if (row.venueMarketId && !arbReturnByVenueMarketId.has(row.venueMarketId)) {
7508
+ arbReturnByVenueMarketId.set(row.venueMarketId, (_a = row.arbReturn) != null ? _a : null);
7509
+ }
7510
+ for (const matchedRow of (_b = row.matched) != null ? _b : []) {
7511
+ addArbReturn(matchedRow);
7512
+ }
7513
+ };
7514
+ for (const row of midpointRows) {
7515
+ addArbReturn(row);
7516
+ }
7517
+ return arbReturnByVenueMarketId;
7518
+ };
7402
7519
  var resolveMarketHrefFromEventHref = (eventHref, marketId, outcomeId) => {
7403
7520
  if (!eventHref) return void 0;
7404
7521
  if (typeof window === "undefined") return void 0;
@@ -7415,6 +7532,9 @@ var EventListItemContent = ({
7415
7532
  event,
7416
7533
  classNames,
7417
7534
  arbitrageByOutcomeId,
7535
+ midpointPrices,
7536
+ midpointRows: sharedMidpointRows,
7537
+ midpointsLoading,
7418
7538
  onEventClick,
7419
7539
  onMarketClick,
7420
7540
  getMarketHref,
@@ -7468,6 +7588,8 @@ var EventListItemContent = ({
7468
7588
  if (!isLazyMarketsQueryEnabled || lazyLoadedMarkets.length === 0) return allVenueMarkets;
7469
7589
  return dedupeVenueMarketsById([...allVenueMarkets, ...lazyLoadedMarkets]);
7470
7590
  }, [allVenueMarkets, isLazyMarketsQueryEnabled, lazyLoadedMarkets]);
7591
+ const hasExpandedMarkets = isLazyMarketsQueryEnabled && lazyLoadedMarkets.length > 0;
7592
+ const shouldUseSharedMidpoints = !hasExpandedMarkets && (midpointPrices !== void 0 || sharedMidpointRows !== void 0 || midpointsLoading !== void 0);
7471
7593
  const midpointVenueMarketIds = (0, import_react10.useMemo)(() => {
7472
7594
  var _a2;
7473
7595
  const ids = [];
@@ -7479,19 +7601,21 @@ var EventListItemContent = ({
7479
7601
  }
7480
7602
  return [...new Set(ids)];
7481
7603
  }, [resolvedOutcomeMarkets]);
7482
- const { midpointRows, isLoading: isVenueMarketMidpointsLoading } = (0, import_hooks31.useVenueMarketMidpoints)({
7483
- venueMarketIds: midpointVenueMarketIds,
7484
- enabled: midpointVenueMarketIds.length > 0
7604
+ const { midpointRows: fetchedMidpointRows, isLoading: isVenueMarketMidpointsLoading } = (0, import_hooks31.useVenueMarketMidpoints)({
7605
+ venueMarketIds: shouldUseSharedMidpoints ? [] : midpointVenueMarketIds,
7606
+ enabled: !shouldUseSharedMidpoints && midpointVenueMarketIds.length > 0
7485
7607
  });
7486
- const { prices: displayMidpointsByOutcomeId, isLoading: isOutcomeMidpointsLoading } = (0, import_hooks31.useMidpoints)(resolvedOutcomeMarkets);
7487
- const isAwaitingMidpoints = isOutcomeMidpointsLoading || midpointVenueMarketIds.length > 0 && isVenueMarketMidpointsLoading;
7608
+ const { prices: displayMidpointsByOutcomeId, isLoading: isOutcomeMidpointsLoading } = (0, import_hooks31.useMidpoints)(shouldUseSharedMidpoints ? [] : resolvedOutcomeMarkets);
7609
+ const resolvedMidpointRows = shouldUseSharedMidpoints ? sharedMidpointRows != null ? sharedMidpointRows : [] : fetchedMidpointRows;
7610
+ const resolvedDisplayMidpointsByOutcomeId = shouldUseSharedMidpoints ? midpointPrices != null ? midpointPrices : /* @__PURE__ */ new Map() : displayMidpointsByOutcomeId;
7611
+ const isAwaitingMidpoints = midpointsLoading != null ? midpointsLoading : isOutcomeMidpointsLoading || midpointVenueMarketIds.length > 0 && isVenueMarketMidpointsLoading;
7488
7612
  const displayPriceByOutcomeId = (0, import_react10.useMemo)(() => {
7489
- const priceByOutcomeId = new Map(displayMidpointsByOutcomeId);
7490
- for (const [outcomeId, price] of buildOutcomeMidpointsByOutcomeId(midpointRows)) {
7613
+ const priceByOutcomeId = new Map(resolvedDisplayMidpointsByOutcomeId);
7614
+ for (const [outcomeId, price] of buildOutcomeMidpointsByOutcomeId(resolvedMidpointRows)) {
7491
7615
  priceByOutcomeId.set(outcomeId, price);
7492
7616
  }
7493
7617
  return priceByOutcomeId;
7494
- }, [displayMidpointsByOutcomeId, midpointRows]);
7618
+ }, [resolvedDisplayMidpointsByOutcomeId, resolvedMidpointRows]);
7495
7619
  const comparison = (0, import_react10.useMemo)(() => {
7496
7620
  return normalizeEventListItemV2Comparison({
7497
7621
  venueMarkets: resolvedOutcomeMarkets,
@@ -7502,6 +7626,9 @@ var EventListItemContent = ({
7502
7626
  const gapsByVenueMarketId = (0, import_react10.useMemo)(() => {
7503
7627
  return computePriceGapsFromComparisonRows(comparison.rows);
7504
7628
  }, [comparison.rows]);
7629
+ const arbReturnByVenueMarketId = (0, import_react10.useMemo)(() => {
7630
+ return buildArbReturnByVenueMarketId(resolvedMidpointRows);
7631
+ }, [resolvedMidpointRows]);
7505
7632
  const shouldRenderLoadingOutcomeRow = shouldEnableLazyMarketLoading && (!isLazyMarketsQueryEnabled || isLoadingLazyMarkets || isFetchingNextLazyMarketsPage || hasNextLazyMarketsPage);
7506
7633
  const resolvedVolume = (_a = resolveDisplayVolume(event.volume, allVenueMarkets)) != null ? _a : 0;
7507
7634
  const volumeLabel = `${config.formatting.formatCompactCurrency(resolvedVolume)} ${labels.eventItem.volumeSuffix}`;
@@ -7633,10 +7760,10 @@ var EventListItemContent = ({
7633
7760
  )
7634
7761
  ] });
7635
7762
  };
7636
- const renderPriceGapPill = (value) => {
7763
+ const renderPriceGapPill = (value, source = "percent") => {
7637
7764
  if (!config.features.enablePriceGap) return null;
7638
7765
  if (isAwaitingMidpoints) return null;
7639
- const formattedPriceGap = formatPriceGapPercent(value);
7766
+ const formattedPriceGap = formatPriceGapPercent(value, source);
7640
7767
  if (!formattedPriceGap) return null;
7641
7768
  return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(
7642
7769
  "span",
@@ -7772,7 +7899,9 @@ var EventListItemContent = ({
7772
7899
  comparison.rows.map((row) => {
7773
7900
  var _a2;
7774
7901
  const arbitragePercent = (_a2 = arbitrageByOutcomeId == null ? void 0 : arbitrageByOutcomeId[row.outcome.id]) != null ? _a2 : arbitrageByOutcomeId == null ? void 0 : arbitrageByOutcomeId[row.market.id];
7775
- const priceGapPercent = gapsByVenueMarketId.get(row.market.id);
7902
+ const arbReturn = arbReturnByVenueMarketId.get(row.market.id);
7903
+ const priceGapPercent = arbReturn == null ? gapsByVenueMarketId.get(row.market.id) : arbReturn;
7904
+ const priceGapSource = arbReturn == null ? "percent" : "fraction";
7776
7905
  return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(
7777
7906
  "div",
7778
7907
  {
@@ -7792,7 +7921,7 @@ var EventListItemContent = ({
7792
7921
  ) }),
7793
7922
  /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)("div", { className: "agg-outcome-meta flex shrink-0 flex-row items-center justify-end gap-2", children: [
7794
7923
  renderArbitrage(arbitragePercent),
7795
- renderPriceGapPill(priceGapPercent),
7924
+ renderPriceGapPill(priceGapPercent, priceGapSource),
7796
7925
  /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("div", { className: "agg-outcome-price-strip relative flex shrink-0 items-center justify-end", children: isAwaitingMidpoints ? renderPriceStripSkeleton(row.prices.length) : row.prices.map(
7797
7926
  (price, priceIndex) => renderComparisonPriceBadge(row, price, priceIndex)
7798
7927
  ) })
@@ -8107,6 +8236,79 @@ var isDateLikeLabel = (value) => {
8107
8236
  if (!value.trim()) return false;
8108
8237
  return (0, import_dayjs3.default)(value).isValid();
8109
8238
  };
8239
+ var CHART_RANGE_PRIORITY = ["1H", "6H", "1D", "1W", "1M", "ALL"];
8240
+ var RANGE_SECONDS_BY_TIME_RANGE = {
8241
+ "1H": 60 * 60,
8242
+ "6H": 6 * 60 * 60,
8243
+ "1D": 24 * 60 * 60,
8244
+ "1W": 7 * 24 * 60 * 60,
8245
+ "1M": 30 * 24 * 60 * 60,
8246
+ ALL: 6 * 30 * 24 * 60 * 60
8247
+ };
8248
+ var toUnixTimestamp = (value) => {
8249
+ if (!value) return null;
8250
+ const parsedValue = (0, import_dayjs3.default)(value);
8251
+ if (!parsedValue.isValid()) return null;
8252
+ return parsedValue.unix();
8253
+ };
8254
+ var isResolvedMarketStatus = (status) => {
8255
+ if (!status) return false;
8256
+ const normalizedStatus = status.trim().toLowerCase();
8257
+ return normalizedStatus.includes("resolved") || normalizedStatus.includes("closed") || normalizedStatus.includes("settled") || normalizedStatus.includes("final");
8258
+ };
8259
+ var resolveInitialEventDetailsChartRange = ({
8260
+ chartData,
8261
+ event,
8262
+ fallbackRange,
8263
+ nowSec = (0, import_dayjs3.default)().unix(),
8264
+ selectedMarket
8265
+ }) => {
8266
+ var _a, _b;
8267
+ const scopedMarkets = selectedMarket ? [selectedMarket] : event.venueMarkets;
8268
+ const preferredEventStart = (_a = toUnixTimestamp(event.startDate)) != null ? _a : toUnixTimestamp(event.creationDate);
8269
+ const marketStartCandidates = scopedMarkets.map((market) => {
8270
+ var _a2;
8271
+ return (_a2 = toUnixTimestamp(market.startDate)) != null ? _a2 : toUnixTimestamp(market.creationDate);
8272
+ }).filter((value) => value != null);
8273
+ const metadataStarts = [preferredEventStart, ...marketStartCandidates].filter(
8274
+ (value) => value != null
8275
+ );
8276
+ const metadataEnds = [
8277
+ toUnixTimestamp(event.endDate),
8278
+ ...scopedMarkets.flatMap((market) => [
8279
+ toUnixTimestamp(market.endDate),
8280
+ toUnixTimestamp(market.resolutionDate)
8281
+ ])
8282
+ ].filter((value) => value != null);
8283
+ const historyTimestamps = chartData == null ? [] : Object.values(chartData.venues).flatMap((venueData) => [
8284
+ ...venueData.candles.map((candle) => candle.time),
8285
+ ...venueData.liveCandle ? [venueData.liveCandle.time] : []
8286
+ ]);
8287
+ const startCandidates = [...metadataStarts, ...historyTimestamps];
8288
+ if (startCandidates.length === 0) {
8289
+ return fallbackRange != null ? fallbackRange : null;
8290
+ }
8291
+ const marketResolved = [event.status, ...scopedMarkets.map((market) => market.status)].some(
8292
+ isResolvedMarketStatus
8293
+ );
8294
+ const isUsingSharedOverlapStart = scopedMarkets.length > 1 && marketStartCandidates.length === scopedMarkets.length;
8295
+ const startTs = isUsingSharedOverlapStart ? Math.max(...marketStartCandidates) : Math.min(...startCandidates);
8296
+ const endTs = Math.max(
8297
+ ...marketResolved && metadataEnds.length > 0 ? [nowSec, ...metadataEnds, ...historyTimestamps] : [nowSec, ...historyTimestamps]
8298
+ );
8299
+ const spanSeconds = Math.max(0, endTs - startTs);
8300
+ if (spanSeconds <= 0) {
8301
+ return fallbackRange != null ? fallbackRange : null;
8302
+ }
8303
+ if (!marketResolved && spanSeconds > RANGE_SECONDS_BY_TIME_RANGE["1M"]) {
8304
+ return "1M";
8305
+ }
8306
+ const requiredSeconds = spanSeconds * (isUsingSharedOverlapStart ? 1 : marketResolved ? 1.05 : 1.2);
8307
+ const matchingRange = CHART_RANGE_PRIORITY.find((range) => {
8308
+ return RANGE_SECONDS_BY_TIME_RANGE[range] >= requiredSeconds;
8309
+ });
8310
+ return (_b = matchingRange != null ? matchingRange : fallbackRange) != null ? _b : "ALL";
8311
+ };
8110
8312
  var matchOutcomeByLabel = (outcome, selectedOutcomeLabel) => {
8111
8313
  const normalizedSelectedLabel = normalizeLabel(selectedOutcomeLabel);
8112
8314
  const semanticSelectedLabel = toSemanticLabel(selectedOutcomeLabel);
@@ -9120,13 +9322,8 @@ var resolveChartVenueOutcomes = ({
9120
9322
  }) => {
9121
9323
  if (eligibleVenueOutcomes.length <= 1) return eligibleVenueOutcomes;
9122
9324
  const sortedEligibleVenueOutcomes = [...eligibleVenueOutcomes].sort((left, right) => {
9123
- var _a, _b;
9124
- const leftProbability = normalizeProbability(
9125
- (_a = livePrices.get(left.outcome.id)) != null ? _a : left.outcome.price
9126
- );
9127
- const rightProbability = normalizeProbability(
9128
- (_b = livePrices.get(right.outcome.id)) != null ? _b : right.outcome.price
9129
- );
9325
+ const leftProbability = normalizeProbability(livePrices.get(left.outcome.id));
9326
+ const rightProbability = normalizeProbability(livePrices.get(right.outcome.id));
9130
9327
  const probabilityDifference = (leftProbability != null ? leftProbability : 2) - (rightProbability != null ? rightProbability : 2);
9131
9328
  if (probabilityDifference !== 0) return probabilityDifference;
9132
9329
  if (left.venue === right.venue) return 0;
@@ -10191,13 +10388,18 @@ var EventListItemDetailsNotFoundState = ({
10191
10388
  }
10192
10389
  );
10193
10390
  };
10391
+ var resolveResolvedOutcomePriceMap = (outcomes) => {
10392
+ if (!(outcomes == null ? void 0 : outcomes.length)) return null;
10393
+ if (!outcomes.some((outcome) => outcome.winner === true)) return null;
10394
+ if (outcomes.some((outcome) => outcome.winner == null)) return null;
10395
+ return new Map(outcomes.map((outcome) => [outcome.id, outcome.winner === true ? 1 : 0]));
10396
+ };
10194
10397
  var EventListItemDetailsGraphSection = ({
10195
10398
  classNames,
10196
10399
  selectedChartType,
10197
10400
  venueMarkets,
10198
10401
  selectedMarketId,
10199
10402
  livePrices,
10200
- wsLivePrices,
10201
10403
  restMidpoints,
10202
10404
  bestMidpoint,
10203
10405
  bestPrices,
@@ -10312,6 +10514,18 @@ var EventListItemDetailsGraphSection = ({
10312
10514
  });
10313
10515
  });
10314
10516
  }, [availableMarkets, tradingContext == null ? void 0 : tradingContext.selectedMarket]);
10517
+ const resolvedOutcomePriceByMarketId = (0, import_react16.useMemo)(() => {
10518
+ const map = /* @__PURE__ */ new Map();
10519
+ for (const market of availableMarkets) {
10520
+ const marketTradingState = (0, import_hooks40.resolveMarketTradingState)(market);
10521
+ if (marketTradingState.kind !== "resolved") continue;
10522
+ const outcomePriceMap = resolveResolvedOutcomePriceMap(market.venueMarketOutcomes);
10523
+ if (outcomePriceMap) {
10524
+ map.set(market.id, outcomePriceMap);
10525
+ }
10526
+ }
10527
+ return map;
10528
+ }, [availableMarkets]);
10315
10529
  const resolvedVenueChartSeries = (0, import_react16.useMemo)(() => {
10316
10530
  return resolveMarketChartVenueSeries({
10317
10531
  chartData: scopedMarketChartData,
@@ -10379,7 +10593,7 @@ var EventListItemDetailsGraphSection = ({
10379
10593
  {
10380
10594
  classNames: { root: cn("agg-chart-region", classNames == null ? void 0 : classNames.chart) },
10381
10595
  series: visibleChartSeries,
10382
- height: 300,
10596
+ height: 200,
10383
10597
  isLoading: isScopedMarketChartLoading,
10384
10598
  chartType: selectedChartType,
10385
10599
  liveCandle: selectedChartType === "candlestick" ? (_m = chartLiveState.liveCandle) != null ? _m : void 0 : void 0,
@@ -10407,8 +10621,8 @@ var EventListItemDetailsGraphSection = ({
10407
10621
  classNames == null ? void 0 : classNames.outcomeBadges
10408
10622
  ),
10409
10623
  children: chartAvailableVenueOutcomes.map((item) => {
10410
- var _a3;
10411
- const percentage = (_a3 = wsLivePrices.get(item.outcome.id)) != null ? _a3 : item.outcome.price;
10624
+ var _a3, _b3;
10625
+ const percentage = (_b3 = (_a3 = resolvedOutcomePriceByMarketId.get(item.market.id)) == null ? void 0 : _a3.get(item.outcome.id)) != null ? _b3 : livePrices.get(item.outcome.id);
10412
10626
  const text = formatMarketProbabilityPercent(percentage, formatPercent);
10413
10627
  const seriesId = `${item.venue}-chart`;
10414
10628
  const isActiveVenue = activeGraphVenue === item.venue;
@@ -10416,6 +10630,7 @@ var EventListItemDetailsGraphSection = ({
10416
10630
  "button",
10417
10631
  {
10418
10632
  type: "button",
10633
+ "data-id": item.outcome.id,
10419
10634
  "aria-label": `${item.venue} ${text}`,
10420
10635
  "aria-pressed": isActiveVenue,
10421
10636
  className: cn(
@@ -10471,21 +10686,21 @@ var EventListItemDetailsGraphSection = ({
10471
10686
  tradingContext == null ? void 0 : tradingContext.selectOutcome(outcomeId);
10472
10687
  },
10473
10688
  options: selectedMarketOutcomes.map((outcome) => {
10474
- var _a3, _b3, _c3;
10475
- const price = getDisplayOutcomePrice({
10689
+ var _a3, _b3, _c3, _d3, _e2;
10690
+ 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);
10691
+ const price = resolvedPrice != null ? resolvedPrice : getDisplayOutcomePrice({
10476
10692
  outcomeId: outcome.id,
10477
10693
  outcomeLabel: outcome.label,
10478
- selection: (_a3 = tradingContext == null ? void 0 : tradingContext.tradeSide) != null ? _a3 : "buy",
10694
+ selection: (_c3 = tradingContext == null ? void 0 : tradingContext.tradeSide) != null ? _c3 : "buy",
10479
10695
  bestPrices,
10480
10696
  bestMidpoint,
10481
10697
  bestMidpointsByOutcomeId: restMidpoints,
10482
- livePrices,
10483
- fallbackPrice: outcome.price
10698
+ livePrices
10484
10699
  });
10485
10700
  return {
10486
10701
  value: outcome.id,
10487
- label: `${(_b3 = outcome.title) != null ? _b3 : outcome.label} ${formatProbabilityCents(price)}`,
10488
- ariaLabel: `${(_c3 = outcome.title) != null ? _c3 : outcome.label} ${formatProbabilityCents(price)}`
10702
+ label: `${(_d3 = outcome.title) != null ? _d3 : outcome.label} ${formatProbabilityCents(price)}`,
10703
+ ariaLabel: `${(_e2 = outcome.title) != null ? _e2 : outcome.label} ${formatProbabilityCents(price)}`
10489
10704
  };
10490
10705
  })
10491
10706
  }
@@ -10506,6 +10721,7 @@ var EventListItemDetailsContent = ({
10506
10721
  detailsStats,
10507
10722
  eventTradingState,
10508
10723
  ariaLabel,
10724
+ defaultTimeRange,
10509
10725
  onClick,
10510
10726
  midpointsResult
10511
10727
  }) => {
@@ -10514,9 +10730,6 @@ var EventListItemDetailsContent = ({
10514
10730
  const lastAppliedEventSyncKeyRef = (0, import_react16.useRef)(null);
10515
10731
  const lastAppliedDefaultRef = (0, import_react16.useRef)(null);
10516
10732
  const [chartRangeOverride, setChartRangeOverride] = (0, import_react16.useState)(null);
10517
- (0, import_react16.useEffect)(() => {
10518
- setChartRangeOverride(null);
10519
- }, [event.id]);
10520
10733
  const config = (0, import_hooks40.useSdkUiConfig)();
10521
10734
  const labels = (0, import_hooks40.useLabels)();
10522
10735
  const tradingContext = (0, import_hooks33.useEventTradingContext)();
@@ -10525,13 +10738,20 @@ var EventListItemDetailsContent = ({
10525
10738
  return eventTradingState != null ? eventTradingState : (0, import_hooks40.resolveEventTradingState)(event);
10526
10739
  }, [event, eventTradingState]);
10527
10740
  const scopedSelectedMarket = (tradingContext == null ? void 0 : tradingContext.selectedEventId) === event.id ? (_a = tradingContext.selectedMarket) != null ? _a : resolvedEventTradingState.primaryMarket : resolvedEventTradingState.primaryMarket;
10741
+ const venueMarkets = (0, import_react16.useMemo)(
10742
+ () => resolvedEventTradingState.displayMarkets,
10743
+ [resolvedEventTradingState.displayMarkets]
10744
+ );
10745
+ const eventDetailVenueMarkets = (0, import_react16.useMemo)(() => {
10746
+ return normalizeVenueMarketCluster(venueMarkets);
10747
+ }, [venueMarkets]);
10528
10748
  const scopedSelectedMarketId = (tradingContext == null ? void 0 : tradingContext.selectedEventId) === event.id ? tradingContext.selectedMarketId : null;
10529
10749
  (0, import_hooks40.useEventOrderbookData)(
10530
10750
  resolvedEventTradingState.isTradingDisabled ? [] : resolvedEventTradingState.displayMarkets,
10531
10751
  scopedSelectedMarketId
10532
10752
  );
10533
- const wsLivePrices = (0, import_hooks40.useLiveOutcomePrices)(resolvedEventTradingState.displayMarkets);
10534
- const wsBestPrices = (0, import_hooks40.useLiveBestPrices)(resolvedEventTradingState.displayMarkets);
10753
+ const wsLivePrices = (0, import_hooks40.useLiveOutcomePrices)(eventDetailVenueMarkets);
10754
+ const wsBestPrices = (0, import_hooks40.useLiveBestPrices)(eventDetailVenueMarkets);
10535
10755
  const resolvedMidpointsResult = midpointsResult != null ? midpointsResult : {
10536
10756
  prices: /* @__PURE__ */ new Map(),
10537
10757
  bestMidpointsByOutcomeId: /* @__PURE__ */ new Map(),
@@ -10556,6 +10776,16 @@ var EventListItemDetailsContent = ({
10556
10776
  for (const [k, v] of wsLivePrices) merged.set(k, v);
10557
10777
  return merged;
10558
10778
  }, [restMidpoints, wsLivePrices]);
10779
+ const initialChartTimeRange = (0, import_react16.useMemo)(() => {
10780
+ return resolveInitialEventDetailsChartRange({
10781
+ event,
10782
+ selectedMarket: scopedSelectedMarket,
10783
+ fallbackRange: defaultTimeRange != null ? defaultTimeRange : config.chart.selectedChartTimeRange
10784
+ });
10785
+ }, [config.chart.selectedChartTimeRange, defaultTimeRange, event, scopedSelectedMarket]);
10786
+ (0, import_react16.useEffect)(() => {
10787
+ setChartRangeOverride(initialChartTimeRange);
10788
+ }, [event.id, initialChartTimeRange, scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id]);
10559
10789
  (0, import_react16.useEffect)(() => {
10560
10790
  if (!tradingContext) return;
10561
10791
  if (lastAppliedEventSyncKeyRef.current === eventSyncKey) return;
@@ -10593,10 +10823,6 @@ var EventListItemDetailsContent = ({
10593
10823
  tradingContext,
10594
10824
  tradingContext == null ? void 0 : tradingContext.selectedEventId
10595
10825
  ]);
10596
- const venueMarkets = (0, import_react16.useMemo)(
10597
- () => resolvedEventTradingState.displayMarkets,
10598
- [resolvedEventTradingState.displayMarkets]
10599
- );
10600
10826
  const marketOptions = (0, import_react16.useMemo)(
10601
10827
  () => venueMarkets.map((vm) => ({
10602
10828
  value: vm.id,
@@ -10718,7 +10944,6 @@ var EventListItemDetailsContent = ({
10718
10944
  venueMarkets,
10719
10945
  selectedMarketId: (_d = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id) != null ? _d : null,
10720
10946
  livePrices,
10721
- wsLivePrices,
10722
10947
  restMidpoints,
10723
10948
  bestMidpoint,
10724
10949
  bestPrices,
@@ -11434,8 +11659,13 @@ var resolveTradingStateTimestampLabel = (labels, state) => {
11434
11659
  return null;
11435
11660
  };
11436
11661
  var resolveTradingStatePresentation = (labels, state) => {
11662
+ var _a;
11437
11663
  const timestampLabel = resolveTradingStateTimestampLabel(labels, state);
11438
- const winningOutcomeLabel = state.winningOutcome ? labels.eventMarketPage.winningOutcome(state.winningOutcome.label) : null;
11664
+ const resolvedOutcomeLabel = resolveResolvedOutcomeLabel({
11665
+ market: (_a = state.market) != null ? _a : null,
11666
+ outcome: state.winningOutcome
11667
+ });
11668
+ const winningOutcomeLabel = resolvedOutcomeLabel ? labels.eventMarketPage.winningOutcome(resolvedOutcomeLabel) : null;
11439
11669
  if (state.kind === "resolved") {
11440
11670
  return {
11441
11671
  badgeLabel: labels.eventMarketPage.tradingResolvedBadge,
@@ -11546,6 +11776,34 @@ var getMarketDetailsOutcomeButtonClassNames = ({
11546
11776
  text: cn(isSelected ? toneClasses.text : "text-agg-foreground")
11547
11777
  };
11548
11778
  };
11779
+ var OutcomePriceContent = ({
11780
+ isLoading,
11781
+ isSelected,
11782
+ value,
11783
+ textClassName
11784
+ }) => {
11785
+ if (isLoading) {
11786
+ return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
11787
+ "span",
11788
+ {
11789
+ "aria-hidden": "true",
11790
+ className: cn(
11791
+ "agg-market-details-outcome-price-loading",
11792
+ "h-4 w-10 shrink-0 rounded-agg-sm bg-agg-separator animate-pulse"
11793
+ )
11794
+ }
11795
+ );
11796
+ }
11797
+ return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
11798
+ Typography,
11799
+ {
11800
+ as: "span",
11801
+ variant: isSelected ? "body-strong" : "body",
11802
+ className: cn("shrink-0 whitespace-nowrap", textClassName),
11803
+ children: formatProbabilityCents(value)
11804
+ }
11805
+ );
11806
+ };
11549
11807
  var MarketDetailsOutcomeButton = ({
11550
11808
  ariaControls,
11551
11809
  enableAnimations,
@@ -11601,12 +11859,12 @@ var MarketDetailsOutcomeButton = ({
11601
11859
  }
11602
11860
  ) : null,
11603
11861
  /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
11604
- Typography,
11862
+ OutcomePriceContent,
11605
11863
  {
11606
- as: "span",
11607
- variant: isSelected ? "body-strong" : "body",
11608
- className: cn("shrink-0 whitespace-nowrap", classNames.text),
11609
- children: formatProbabilityCents(item.probability)
11864
+ isLoading: item.isPriceLoading,
11865
+ isSelected,
11866
+ value: item.probability,
11867
+ textClassName: classNames.text
11610
11868
  }
11611
11869
  )
11612
11870
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)("div", { className: "inline-flex max-w-full items-center justify-center gap-1.5", children: [
@@ -11621,12 +11879,12 @@ var MarketDetailsOutcomeButton = ({
11621
11879
  }
11622
11880
  ),
11623
11881
  /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
11624
- Typography,
11882
+ OutcomePriceContent,
11625
11883
  {
11626
- as: "span",
11627
- variant: isSelected ? "body-strong" : "body",
11628
- className: cn("shrink-0 whitespace-nowrap", classNames.text),
11629
- children: formatProbabilityCents(item.probability)
11884
+ isLoading: item.isPriceLoading,
11885
+ isSelected,
11886
+ value: item.probability,
11887
+ textClassName: classNames.text
11630
11888
  }
11631
11889
  )
11632
11890
  ] })
@@ -11818,9 +12076,8 @@ var MarketDetailsGraphPanel = ({
11818
12076
  var _a2, _b2, _c2, _d;
11819
12077
  return /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("div", { className: "agg-chart-toolbar w-full flex flex-col gap-4 md:flex-row md:items-center md:justify-between", children: [
11820
12078
  /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("div", { className: "agg-market-venues flex flex-wrap gap-2", children: chartAvailableOutcomesByVenue.map((item) => {
11821
- var _a3;
11822
12079
  const probability = formatProbabilityPercent(
11823
- (_a3 = wsLivePrices.get(item.outcome.id)) != null ? _a3 : item.outcome.price,
12080
+ wsLivePrices.get(item.outcome.id),
11824
12081
  formatPercent
11825
12082
  );
11826
12083
  const isActiveVenue = selectedGraphVenue === item.venue;
@@ -12031,16 +12288,8 @@ var MarketDetailsContent = ({
12031
12288
  isResolvedMarket ? [] : resolvedMarket == null ? void 0 : resolvedMarket.venueMarkets,
12032
12289
  (_b = scopedResolvedMarket == null ? void 0 : scopedResolvedMarket.id) != null ? _b : null
12033
12290
  );
12034
- const clusterMidpointResult = midpointsResult != null ? midpointsResult : {
12035
- prices: /* @__PURE__ */ new Map(),
12036
- bestMidpointsByOutcomeId: /* @__PURE__ */ new Map(),
12037
- venueByOutcomeId: /* @__PURE__ */ new Map(),
12038
- bestPrices: /* @__PURE__ */ new Map(),
12039
- bestPriceVenuesByOutcomeId: /* @__PURE__ */ new Map(),
12040
- isLoading: false,
12041
- bestMidpoint: void 0,
12042
- bestMidpointVenue: void 0
12043
- };
12291
+ const fetchedClusterMidpointResult = (0, import_hooks43.useMidpoints)(midpointsResult ? [] : clusterVenueMarkets);
12292
+ const clusterMidpointResult = midpointsResult != null ? midpointsResult : fetchedClusterMidpointResult;
12044
12293
  const clusterMidpoints = (_c = clusterMidpointResult.bestMidpointsByOutcomeId) != null ? _c : clusterMidpointResult.prices;
12045
12294
  const clusterBestMidpointsByOutcomeId = clusterMidpoints;
12046
12295
  const clusterVenueByOutcomeId = clusterMidpointResult.venueByOutcomeId;
@@ -12108,6 +12357,10 @@ var MarketDetailsContent = ({
12108
12357
  const isOutcomeSelectionLocked = marketTradingState.isTradingDisabled;
12109
12358
  const isUpcomingMarket = marketTradingState.kind === "unopened";
12110
12359
  const marketStatePresentation = resolveTradingStatePresentation(labels, marketTradingState);
12360
+ const resolvedWinningOutcomeLabel = resolveResolvedOutcomeLabel({
12361
+ market: scopedMarketForCard,
12362
+ outcome: marketTradingState.winningOutcome
12363
+ });
12111
12364
  const marketDetailsTabs = (0, import_react20.useMemo)(() => {
12112
12365
  return getMarketDetailsTabs(labels);
12113
12366
  }, [labels]);
@@ -12200,18 +12453,24 @@ var MarketDetailsContent = ({
12200
12453
  });
12201
12454
  const bestVenue = candidate == null ? void 0 : candidate.venue;
12202
12455
  const outcomeBestPrice = candidate == null ? void 0 : candidate.price;
12456
+ const isPriceLoading = !isResolvedMarket && outcomeBestPrice == null && clusterMidpointResult.isLoading;
12203
12457
  if (isResolvedMarket) {
12204
12458
  const isWinningOutcome = item.id === ((_a2 = marketTradingState.winningOutcome) == null ? void 0 : _a2.id);
12205
12459
  return __spreadValues(__spreadProps(__spreadValues({}, item), {
12206
- probability: isWinningOutcome ? 1 : 0
12460
+ probability: isWinningOutcome ? 1 : 0,
12461
+ isPriceLoading: false
12207
12462
  }), bestVenue ? { venue: bestVenue } : {});
12208
12463
  }
12209
12464
  if (outcomeBestPrice != null) {
12210
12465
  return __spreadValues(__spreadProps(__spreadValues({}, item), {
12211
- probability: outcomeBestPrice
12466
+ probability: outcomeBestPrice,
12467
+ isPriceLoading: false
12212
12468
  }), bestVenue ? { venue: bestVenue } : {});
12213
12469
  }
12214
- return item;
12470
+ return __spreadProps(__spreadValues({}, item), {
12471
+ probability: void 0,
12472
+ isPriceLoading
12473
+ });
12215
12474
  });
12216
12475
  }, [
12217
12476
  clusterBestMidpoint,
@@ -12233,7 +12492,7 @@ var MarketDetailsContent = ({
12233
12492
  wsBestCandidates
12234
12493
  ]);
12235
12494
  const headlineProbability = (0, import_react20.useMemo)(() => {
12236
- var _a2, _b2, _c2, _d2;
12495
+ var _a2;
12237
12496
  if (!model || !scopedMarketForCard) return void 0;
12238
12497
  if (isResolvedMarket) {
12239
12498
  const yesOutcome2 = resolveYesOutcome(scopedMarketForCard);
@@ -12241,10 +12500,7 @@ var MarketDetailsContent = ({
12241
12500
  return yesOutcome2.winner === true ? 1 : 0;
12242
12501
  }
12243
12502
  const yesOutcome = resolveYesOutcome(scopedMarketForCard);
12244
- const displayOutcome = yesOutcome != null ? yesOutcome : (_b2 = scopedMarketForCard.venueMarketOutcomes) == null ? void 0 : _b2.reduce(
12245
- (acc, outcome) => outcome.price > acc.price ? outcome : acc,
12246
- (_a2 = scopedMarketForCard.venueMarketOutcomes) == null ? void 0 : _a2[0]
12247
- );
12503
+ const displayOutcome = yesOutcome != null ? yesOutcome : (_a2 = scopedMarketForCard.venueMarketOutcomes) == null ? void 0 : _a2[0];
12248
12504
  if (displayOutcome == null) return void 0;
12249
12505
  const referencePrice = getDisplayOutcomePrice({
12250
12506
  outcomeId: displayOutcome.id,
@@ -12254,10 +12510,10 @@ var MarketDetailsContent = ({
12254
12510
  bestMidpoint: clusterBestMidpoint,
12255
12511
  bestMidpointsByOutcomeId: clusterBestMidpointsByOutcomeId,
12256
12512
  livePrices: wsLivePrices,
12257
- fallbackPrice: (_c2 = midpointsFallback == null ? void 0 : midpointsFallback.get(displayOutcome.id)) != null ? _c2 : displayOutcome.price
12513
+ fallbackPrice: midpointsFallback == null ? void 0 : midpointsFallback.get(displayOutcome.id)
12258
12514
  });
12259
12515
  if (referencePrice != null) return referencePrice;
12260
- return (_d2 = (0, import_hooks43.findLivePriceById)(wsLivePrices, displayOutcome.id)) != null ? _d2 : displayOutcome.price;
12516
+ return (0, import_hooks43.findLivePriceById)(wsLivePrices, displayOutcome.id);
12261
12517
  }, [
12262
12518
  clusterBestMidpoint,
12263
12519
  clusterBestMidpointsByOutcomeId,
@@ -12541,7 +12797,9 @@ var MarketDetailsContent = ({
12541
12797
  )
12542
12798
  }
12543
12799
  ),
12544
- /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Typography, { variant: "body", children: labels.eventMarketPage.resolvedOutcome(marketTradingState.winningOutcome.label) })
12800
+ /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Typography, { variant: "body", children: labels.eventMarketPage.resolvedOutcome(
12801
+ resolvedWinningOutcomeLabel != null ? resolvedWinningOutcomeLabel : marketTradingState.winningOutcome.label
12802
+ ) })
12545
12803
  ]
12546
12804
  }
12547
12805
  ) }) : isUpcomingMarket ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("div", { className: "agg-outcomes flex w-full items-center justify-end md:w-auto md:shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
@@ -13307,6 +13565,23 @@ var resolveSortQueryParams = (value) => {
13307
13565
  }
13308
13566
  return { sortBy: "volume24hr", sortDir: "desc" };
13309
13567
  };
13568
+ var collectEventListVenueMarkets = (events) => {
13569
+ return events.flatMap((event) => {
13570
+ var _a;
13571
+ return (_a = event.venueMarkets) != null ? _a : [];
13572
+ });
13573
+ };
13574
+ var collectMidpointVenueMarketIds = (venueMarkets) => {
13575
+ var _a;
13576
+ const ids = [];
13577
+ for (const market of venueMarkets) {
13578
+ ids.push(market.id);
13579
+ for (const sibling of (_a = market.matchedVenueMarkets) != null ? _a : []) {
13580
+ ids.push(sibling.id);
13581
+ }
13582
+ }
13583
+ return [...new Set(ids)];
13584
+ };
13310
13585
  var EventList = ({
13311
13586
  title: title2,
13312
13587
  limit = DEFAULT_EVENTS_LIMIT,
@@ -13521,6 +13796,16 @@ var EventList = ({
13521
13796
  if (resolvedMaxVisibleItems == null) return normalizedEvents;
13522
13797
  return normalizedEvents.slice(0, resolvedMaxVisibleItems);
13523
13798
  }, [orderedEvents, resolvedMaxVisibleItems]);
13799
+ const visibleVenueMarkets = (0, import_react23.useMemo)(() => {
13800
+ return collectEventListVenueMarkets(tileEvents);
13801
+ }, [tileEvents]);
13802
+ const visibleMidpointVenueMarketIds = (0, import_react23.useMemo)(() => {
13803
+ return collectMidpointVenueMarketIds(visibleVenueMarkets);
13804
+ }, [visibleVenueMarkets]);
13805
+ const { midpointRows: sharedMidpointRows, isLoading: isSharedMidpointsLoading } = (0, import_hooks45.useVenueMarketMidpoints)({
13806
+ venueMarketIds: visibleMidpointVenueMarketIds,
13807
+ enabled: visibleMidpointVenueMarketIds.length > 0
13808
+ });
13524
13809
  const shouldRenderLoadingState = isLoading && !isPlaceholderData && tileEvents.length === 0;
13525
13810
  const shouldRenderEmptyState = !isLoading && !isError && tileEvents.length === 0;
13526
13811
  const shouldRenderPaginationLoadingItems = shouldPaginate && hasNextPage;
@@ -13689,6 +13974,8 @@ var EventList = ({
13689
13974
  EventListItem,
13690
13975
  {
13691
13976
  event,
13977
+ midpointRows: sharedMidpointRows,
13978
+ midpointsLoading: isSharedMidpointsLoading,
13692
13979
  classNames: {
13693
13980
  root: "agg-event-list-item w-full min-w-0! max-w-none justify-between!"
13694
13981
  },