@agg-build/ui 4.2.0 → 4.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +25 -16
  2. package/dist/{chunk-DNPDXL2D.mjs → chunk-3RQCBGIK.mjs} +341 -105
  3. package/dist/{chunk-GNEFI4SO.mjs → chunk-C4GFVJ62.mjs} +725 -400
  4. package/dist/{chunk-UDBHAZJJ.mjs → chunk-EOLR7DHL.mjs} +568 -145
  5. package/dist/{chunk-6X6Y4INU.mjs → chunk-LXQ3U4X2.mjs} +2 -2
  6. package/dist/{chunk-QW7VFURU.mjs → chunk-RDBMHBR2.mjs} +67 -3
  7. package/dist/{chunk-WDCH4RRS.mjs → chunk-WYCSTAN7.mjs} +1 -1
  8. package/dist/{chunk-FTL25XKE.mjs → chunk-XN2NB2NP.mjs} +1 -1
  9. package/dist/events.js +1149 -661
  10. package/dist/events.mjs +6 -4
  11. package/dist/index.js +3320 -2291
  12. package/dist/index.mjs +12 -8
  13. package/dist/modals.js +9 -2
  14. package/dist/modals.mjs +3 -3
  15. package/dist/pages.js +2789 -1762
  16. package/dist/pages.mjs +8 -6
  17. package/dist/primitives.js +30 -3
  18. package/dist/primitives.mjs +1 -1
  19. package/dist/styles.css +1 -1
  20. package/dist/tailwind.css +1 -1
  21. package/dist/trading.js +338 -102
  22. package/dist/trading.mjs +4 -4
  23. package/dist/types/events/index.d.mts +1 -0
  24. package/dist/types/events/index.d.ts +1 -0
  25. package/dist/types/events/item-details/event-list-item-details-market-selector.d.mts +4 -1
  26. package/dist/types/events/item-details/event-list-item-details-market-selector.d.ts +4 -1
  27. package/dist/types/events/item-details/event-list-item-details.types.d.mts +25 -1
  28. package/dist/types/events/item-details/event-list-item-details.types.d.ts +25 -1
  29. package/dist/types/events/item-details/index.d.mts +1 -1
  30. package/dist/types/events/item-details/index.d.ts +1 -1
  31. package/dist/types/events/list/event-list.constants.d.mts +3 -1
  32. package/dist/types/events/list/event-list.constants.d.ts +3 -1
  33. package/dist/types/events/list/event-list.types.d.mts +17 -0
  34. package/dist/types/events/list/event-list.types.d.ts +17 -0
  35. package/dist/types/events/list/event-list.utils.d.mts +4 -0
  36. package/dist/types/events/list/event-list.utils.d.ts +4 -0
  37. package/dist/types/events/list/index.d.mts +2 -2
  38. package/dist/types/events/list/index.d.ts +2 -2
  39. package/dist/types/events/market-details/index.d.mts +1 -1
  40. package/dist/types/events/market-details/index.d.ts +1 -1
  41. package/dist/types/events/market-details/market-details.types.d.mts +4 -0
  42. package/dist/types/events/market-details/market-details.types.d.ts +4 -0
  43. package/dist/types/events/shared/format-event-title.d.mts +9 -1
  44. package/dist/types/events/shared/format-event-title.d.ts +9 -1
  45. package/dist/types/events/shared/format-sports-event-time.d.mts +2 -0
  46. package/dist/types/events/shared/format-sports-event-time.d.ts +2 -0
  47. package/dist/types/events/shared/sports-live-score.d.mts +10 -0
  48. package/dist/types/events/shared/sports-live-score.d.ts +10 -0
  49. package/dist/types/pages/event-market/event-market.types.d.mts +4 -0
  50. package/dist/types/pages/event-market/event-market.types.d.ts +4 -0
  51. package/dist/types/pages/event-market/index.d.mts +1 -0
  52. package/dist/types/pages/event-market/index.d.ts +1 -0
  53. package/dist/types/pages/home/event-discovery-url-state.d.mts +35 -0
  54. package/dist/types/pages/home/event-discovery-url-state.d.ts +35 -0
  55. package/dist/types/pages/user-profile/components/available-balance-card.d.mts +5 -0
  56. package/dist/types/pages/user-profile/components/available-balance-card.d.ts +5 -0
  57. package/dist/types/pages/user-profile/components/open-order-row.d.mts +1 -0
  58. package/dist/types/pages/user-profile/components/open-order-row.d.ts +1 -0
  59. package/dist/types/pages/user-profile/components/positions-activity.d.mts +1 -1
  60. package/dist/types/pages/user-profile/components/positions-activity.d.ts +1 -1
  61. package/dist/types/pages/user-profile/user-profile.types.d.mts +1 -1
  62. package/dist/types/pages/user-profile/user-profile.types.d.ts +1 -1
  63. package/dist/types/trading/place-order/index.d.mts +1 -1
  64. package/dist/types/trading/place-order/index.d.ts +1 -1
  65. package/dist/types/trading/place-order/index.place-order.execution-steps.d.mts +13 -1
  66. package/dist/types/trading/place-order/index.place-order.execution-steps.d.ts +13 -1
  67. package/dist/types/trading/place-order/index.place-order.execution-view.d.mts +2 -1
  68. package/dist/types/trading/place-order/index.place-order.execution-view.d.ts +2 -1
  69. package/dist/types/trading/place-order/index.place-order.types.d.mts +9 -0
  70. package/dist/types/trading/place-order/index.place-order.types.d.ts +9 -0
  71. package/dist/types/trading/place-order/index.place-order.utils.d.mts +6 -0
  72. package/dist/types/trading/place-order/index.place-order.utils.d.ts +6 -0
  73. package/package.json +3 -3
  74. /package/dist/{chunk-KHHFHXXD.mjs → chunk-JH4B3ZHQ.mjs} +0 -0
@@ -9,12 +9,12 @@ import {
9
9
  getTradingVenueLabel,
10
10
  prepareSettlementDifferences,
11
11
  resolveOrderEligibilityMessage
12
- } from "./chunk-WDCH4RRS.mjs";
12
+ } from "./chunk-WYCSTAN7.mjs";
13
13
  import {
14
14
  ConnectKalshiModal,
15
15
  GeoBlockBanner,
16
16
  subscribeAggDepositNotification
17
- } from "./chunk-FTL25XKE.mjs";
17
+ } from "./chunk-XN2NB2NP.mjs";
18
18
  import {
19
19
  AGG_TERMS_OF_SERVICE_URL,
20
20
  Button,
@@ -47,7 +47,7 @@ import {
47
47
  resolveResolvedOutcomeLabel,
48
48
  skeletonViews,
49
49
  useOptionalToast
50
- } from "./chunk-QW7VFURU.mjs";
50
+ } from "./chunk-RDBMHBR2.mjs";
51
51
 
52
52
  // src/trading/types.ts
53
53
  import { Venue, enumGuard, isFiniteNonNeg, safeParse } from "@agg-build/sdk";
@@ -1077,7 +1077,7 @@ var getSmartRouteTotalFees = (feeBreakdown) => {
1077
1077
  if (!feeBreakdown) return null;
1078
1078
  const feeParts = [feeBreakdown.venueFees, feeBreakdown.bridgeFees, feeBreakdown.executionGas];
1079
1079
  if (!feeParts.every(Number.isFinite)) return null;
1080
- return feeParts.reduce((total, fee) => total + fee, 0);
1080
+ return feeParts.reduce((total, fee) => total + Math.round(fee * 100) / 100, 0);
1081
1081
  };
1082
1082
  var getPlaceOrderContainerClassName = () => {
1083
1083
  return PLACE_ORDER_CONTAINER_CLASS_NAME;
@@ -1339,7 +1339,7 @@ var buildLiveRouteCards = ({
1339
1339
  // balance condition, and `handleExecuteQuote` rejects an empty quoteId.
1340
1340
  sq.venue !== primaryWinnerVenue
1341
1341
  ).map((sq) => {
1342
- var _a2;
1342
+ var _a2, _b2;
1343
1343
  const parsedVenue = parseVenue(sq.venue);
1344
1344
  const venue = parsedVenue.success ? parsedVenue.data : void 0;
1345
1345
  if (geoBlockedVenues.has(sq.venue)) {
@@ -1372,7 +1372,12 @@ var buildLiveRouteCards = ({
1372
1372
  estimatedProfit: sq.estimatedProfit,
1373
1373
  returnPct: sq.returnPct,
1374
1374
  // venueSoloQuotes stripped on solo card's quoteData (only the primary needs them)
1375
- venueSoloQuotes: void 0
1375
+ venueSoloQuotes: void 0,
1376
+ // This solo's OWN fee breakdown. Without it the spread above leaves the
1377
+ // primary route's breakdown in place, so selecting a bridge-free venue
1378
+ // still showed the primary's bridging charge. Falls back to the
1379
+ // primary only when the router omitted one (non-"ok" solos).
1380
+ feeBreakdown: (_b2 = sq.feeBreakdown) != null ? _b2 : quoteData.feeBreakdown
1376
1381
  }), sq.quoteId ? { status: "ok", error: void 0 } : null);
1377
1382
  return {
1378
1383
  id: `live-solo-${sq.venue}`,
@@ -1994,18 +1999,15 @@ var resolvePlaceOrderFailureActions = ({
1994
1999
  canRetryRemaining = true,
1995
2000
  kind,
1996
2001
  labels,
1997
- terminalEvent
2002
+ terminalEvent: _terminalEvent
1998
2003
  }) => {
1999
- const parsedVenue = parseVenue(terminalEvent == null ? void 0 : terminalEvent.venue);
2000
- const venue = parsedVenue.success ? parsedVenue.data : void 0;
2001
- const venueLabel = getTradingVenueLabel(venue);
2002
2004
  if (kind === "partial_fill") {
2003
2005
  if (!canRetryRemaining) {
2004
2006
  return [
2005
2007
  {
2006
- id: "skip",
2007
- label: labels.orderSkip,
2008
- variant: "skip"
2008
+ id: "new-trade",
2009
+ label: labels.orderNewTrade,
2010
+ variant: "dismiss"
2009
2011
  }
2010
2012
  ];
2011
2013
  }
@@ -2016,9 +2018,9 @@ var resolvePlaceOrderFailureActions = ({
2016
2018
  variant: "retry"
2017
2019
  },
2018
2020
  {
2019
- id: "skip",
2020
- label: labels.orderSkip,
2021
- variant: "skip"
2021
+ id: "new-trade",
2022
+ label: labels.orderNewTrade,
2023
+ variant: "dismiss"
2022
2024
  }
2023
2025
  ];
2024
2026
  }
@@ -2026,12 +2028,12 @@ var resolvePlaceOrderFailureActions = ({
2026
2028
  return [
2027
2029
  {
2028
2030
  id: "retry",
2029
- label: labels.orderRetryVenue(venueLabel),
2031
+ label: labels.orderRetry,
2030
2032
  variant: "retry"
2031
2033
  },
2032
2034
  {
2033
- id: "dismiss",
2034
- label: labels.orderDismiss,
2035
+ id: "close",
2036
+ label: labels.orderClose,
2035
2037
  variant: "dismiss"
2036
2038
  }
2037
2039
  ];
@@ -2052,8 +2054,8 @@ var resolvePlaceOrderFailureActions = ({
2052
2054
  variant: "retry"
2053
2055
  },
2054
2056
  {
2055
- id: "dismiss",
2056
- label: labels.orderDone,
2057
+ id: "close",
2058
+ label: labels.orderClose,
2057
2059
  variant: "dismiss"
2058
2060
  }
2059
2061
  ];
@@ -2139,6 +2141,21 @@ var getPlaceOrderUnfilledRemaining = ({
2139
2141
  }, 0);
2140
2142
  return Math.max(0, originalAmount - filled);
2141
2143
  };
2144
+ var getCanonicalPlaceOrderUnfilledRemaining = ({
2145
+ originalAmount,
2146
+ tradeSide,
2147
+ terminalOrderEvents
2148
+ }) => {
2149
+ const fillEvents = (terminalOrderEvents != null ? terminalOrderEvents : []).filter(
2150
+ (event) => event.event === "filled" || event.event === "partial_fill"
2151
+ );
2152
+ if (fillEvents.length === 0) return null;
2153
+ const hasCanonicalFillUnits = fillEvents.every(
2154
+ (event) => tradeSide === "buy" ? event.filledAmountRaw != null : event.actualSharesRaw != null
2155
+ );
2156
+ if (!hasCanonicalFillUnits) return null;
2157
+ return getPlaceOrderUnfilledRemaining({ originalAmount, tradeSide, terminalOrderEvents });
2158
+ };
2142
2159
  var buildPlaceOrderFailureSummary = ({
2143
2160
  actionLabel,
2144
2161
  canRetryRemaining,
@@ -2152,7 +2169,7 @@ var buildPlaceOrderFailureSummary = ({
2152
2169
  submittedOrders,
2153
2170
  terminalOrderEvents
2154
2171
  }) => {
2155
- var _a;
2172
+ var _a, _b;
2156
2173
  const normalizedErrorMessage = normalizePlaceOrderErrorMessage({
2157
2174
  errorMessage,
2158
2175
  fallbackMessage: labels.orderFailed,
@@ -2198,7 +2215,7 @@ var buildPlaceOrderFailureSummary = ({
2198
2215
  });
2199
2216
  }
2200
2217
  const venueSteps = sortedEvents.flatMap((terminalEvent, index) => {
2201
- var _a2, _b, _c, _d, _e;
2218
+ var _a2, _b2, _c, _d, _e;
2202
2219
  const parsedVenue = parseVenue(terminalEvent.venue);
2203
2220
  const venue = parsedVenue.success ? parsedVenue.data : void 0;
2204
2221
  const venueLabel = getTradingVenueLabel(venue);
@@ -2206,7 +2223,7 @@ var buildPlaceOrderFailureSummary = ({
2206
2223
  (candidate) => candidate.orderId === terminalEvent.orderId
2207
2224
  );
2208
2225
  const fallbackPrice = (_a2 = quoteData == null ? void 0 : quoteData.fills[index]) == null ? void 0 : _a2.avgPrice;
2209
- const priceLabel = getTradingRoutePriceLabel((_c = (_b = submittedOrder == null ? void 0 : submittedOrder.price) != null ? _b : fallbackPrice) != null ? _c : 0);
2226
+ const priceLabel = getTradingRoutePriceLabel((_c = (_b2 = submittedOrder == null ? void 0 : submittedOrder.price) != null ? _b2 : fallbackPrice) != null ? _c : 0);
2210
2227
  const filledDollars = parseFilledAmountRawDollars(terminalEvent.filledAmountRaw);
2211
2228
  const amountLabel = filledDollars != null ? formatUsd(filledDollars) : null;
2212
2229
  const executingStep = {
@@ -2255,6 +2272,17 @@ var buildPlaceOrderFailureSummary = ({
2255
2272
  } : null;
2256
2273
  const primaryNonFilledEvent = (_a = sortedEvents.find((e) => e.event !== "filled")) != null ? _a : sortedEvents[0];
2257
2274
  const parsedRetryVenue = primaryNonFilledEvent ? parseVenue(primaryNonFilledEvent.venue) : null;
2275
+ const failedEventMessage = (_b = sortedEvents.find(
2276
+ (event) => {
2277
+ var _a2;
2278
+ return event.event === "failed" && ((_a2 = event.errorReason) == null ? void 0 : _a2.trim());
2279
+ }
2280
+ )) == null ? void 0 : _b.errorReason;
2281
+ const resolvedErrorMessage = failedEventMessage ? normalizePlaceOrderErrorMessage({
2282
+ errorMessage: failedEventMessage,
2283
+ fallbackMessage: labels.orderFailed,
2284
+ labels
2285
+ }) : overallFailureKind === "partial_fill" ? void 0 : normalizedErrorMessage;
2258
2286
  return __spreadProps(__spreadValues({
2259
2287
  actionLabel,
2260
2288
  actions: resolvePlaceOrderFailureActions({
@@ -2263,7 +2291,7 @@ var buildPlaceOrderFailureSummary = ({
2263
2291
  labels,
2264
2292
  terminalEvent: primaryNonFilledEvent
2265
2293
  }),
2266
- errorMessage: normalizedErrorMessage,
2294
+ errorMessage: resolvedErrorMessage,
2267
2295
  eventImage,
2268
2296
  eventSubtitle,
2269
2297
  eventTitle,
@@ -2489,7 +2517,8 @@ var resolveActualFillPresentation = ({
2489
2517
  };
2490
2518
  var resolveBackendStepStatus = (status) => {
2491
2519
  if (status === "completed" || status === "skipped") return "done";
2492
- if (status === "in_progress" || status === "failed") return "loading";
2520
+ if (status === "failed") return "failed";
2521
+ if (status === "in_progress") return "loading";
2493
2522
  return "not-started";
2494
2523
  };
2495
2524
  var resolveOrderFallbackFill = (quoteData, order, orderIndex) => {
@@ -2600,20 +2629,35 @@ var deriveBackendExecutionOrderGroups = ({
2600
2629
  });
2601
2630
  const usesBackendPendingLabel = step.groupStatus === "pending" || step.groupStatus === "in_progress" || step.groupStatus === "failed";
2602
2631
  const usesBackendCompletedLabel = step.groupStatus === "completed" || step.groupStatus === "skipped";
2632
+ const isPartialFillStep = step.kind === "fill" && order.event === "partial_fill";
2633
+ const partialFillLabel = labels.orderPartiallyFilledAtPriceWithAmount(
2634
+ presentation.venueLabel,
2635
+ presentation.priceLabel,
2636
+ presentation.amountLabel
2637
+ );
2603
2638
  return {
2604
2639
  id: `${order.orderId}:${step.groupId}`,
2605
2640
  kind: step.kind,
2606
- pendingLabel: usesBackendPendingLabel ? step.label : fallbackLabels.pendingLabel,
2607
- completedLabel: usesBackendCompletedLabel ? step.label : fallbackLabels.completedLabel,
2608
- realStatus: forceCompleted ? "done" : resolveBackendStepStatus(step.groupStatus)
2641
+ pendingLabel: isPartialFillStep ? partialFillLabel : usesBackendPendingLabel ? step.label : fallbackLabels.pendingLabel,
2642
+ completedLabel: isPartialFillStep ? partialFillLabel : usesBackendCompletedLabel ? step.label : fallbackLabels.completedLabel,
2643
+ realStatus: isPartialFillStep ? "warning" : forceCompleted ? "done" : resolveBackendStepStatus(step.groupStatus)
2609
2644
  };
2610
2645
  });
2611
2646
  if (steps.length === 0) return [];
2612
2647
  return [__spreadProps(__spreadValues({ id: order.orderId }, presentation), { steps })];
2613
2648
  });
2614
- return deriveSequentialDisplayGroups(realGroups);
2615
- };
2616
- var deriveSequentialDisplayGroups = (groups) => {
2649
+ const allOrdersTerminal = executionOrders.every((order) => order.event !== null);
2650
+ return deriveSequentialDisplayGroups(realGroups, allOrdersTerminal);
2651
+ };
2652
+ var deriveSequentialDisplayGroups = (groups, revealTerminalOutcomes = false) => {
2653
+ if (revealTerminalOutcomes) {
2654
+ return groups.map((group) => __spreadProps(__spreadValues({}, group), {
2655
+ steps: group.steps.map((_a) => {
2656
+ var _b = _a, { realStatus } = _b, step = __objRest(_b, ["realStatus"]);
2657
+ return __spreadProps(__spreadValues({}, step), { status: realStatus });
2658
+ })
2659
+ }));
2660
+ }
2617
2661
  let hasUnresolvedPredecessor = false;
2618
2662
  return groups.map((group) => __spreadProps(__spreadValues({}, group), {
2619
2663
  steps: group.steps.map((_a) => {
@@ -2679,6 +2723,9 @@ var deriveExecutionOrderGroups = ({
2679
2723
  const hasSuccessfulTerminalEvent = venueTerminalEvents.some(
2680
2724
  (event) => event.event === "filled" || event.event === "partial_fill"
2681
2725
  );
2726
+ const hasPartialTerminalEvent = venueTerminalEvents.some(
2727
+ (event) => event.event === "partial_fill"
2728
+ );
2682
2729
  const hasVenueExecutionProgress = venueRawSteps.some(isRawStepStarted);
2683
2730
  const quotedAmount = fill.venueQty * fill.avgPrice;
2684
2731
  const actualFill = resolveActualFillPresentation({
@@ -2688,6 +2735,11 @@ var deriveExecutionOrderGroups = ({
2688
2735
  });
2689
2736
  const completedAmountLabel = tradeSide === "buy" ? formatUsd(actualFill.amount) : labels.executionShares(formatTokenAmount(fill.venueQty));
2690
2737
  const completedPriceLabel = getTradingRoutePriceLabel(actualFill.price);
2738
+ const partialFillLabel = labels.orderPartiallyFilledAtPriceWithAmount(
2739
+ venueLabel,
2740
+ completedPriceLabel,
2741
+ completedAmountLabel
2742
+ );
2691
2743
  const setupRawSteps = rawExecutionSteps.filter(
2692
2744
  (step) => setupCosts.some((setupCost) => isSetupRawStep(step, setupCost))
2693
2745
  );
@@ -2699,7 +2751,7 @@ var deriveExecutionOrderGroups = ({
2699
2751
  steps: bridgeRawSteps,
2700
2752
  nextPhaseStarted: hasVenueExecutionProgress || hasSuccessfulTerminalEvent
2701
2753
  });
2702
- const executionStatus = forceCompleted || hasSuccessfulTerminalEvent ? "done" : resolveRawPhaseStatus({ steps: venueRawSteps });
2754
+ const executionStatus = hasPartialTerminalEvent ? "warning" : forceCompleted || hasSuccessfulTerminalEvent ? "done" : resolveRawPhaseStatus({ steps: venueRawSteps });
2703
2755
  const groupId = `${normalizeIdentity(fill.venue) || "venue"}-${fillIndex}`;
2704
2756
  const steps = [
2705
2757
  {
@@ -2731,8 +2783,8 @@ var deriveExecutionOrderGroups = ({
2731
2783
  {
2732
2784
  id: `${groupId}-execute`,
2733
2785
  kind: "fill",
2734
- pendingLabel: labels.fillingOnVenue(venueLabel),
2735
- completedLabel: labels.venueFilledAtPriceWithAmount(
2786
+ pendingLabel: hasPartialTerminalEvent ? partialFillLabel : labels.fillingOnVenue(venueLabel),
2787
+ completedLabel: hasPartialTerminalEvent ? partialFillLabel : labels.venueFilledAtPriceWithAmount(
2736
2788
  venueLabel,
2737
2789
  completedAmountLabel,
2738
2790
  completedPriceLabel
@@ -2749,7 +2801,92 @@ var deriveExecutionOrderGroups = ({
2749
2801
  steps
2750
2802
  };
2751
2803
  });
2752
- return deriveSequentialDisplayGroups(realGroups);
2804
+ return deriveSequentialDisplayGroups(
2805
+ realGroups,
2806
+ terminalOrderEvents.length >= quoteData.fills.length && quoteData.fills.length > 0
2807
+ );
2808
+ };
2809
+ var EXECUTION_MILESTONE_WEIGHTS = {
2810
+ submit: 20,
2811
+ setup: 20,
2812
+ bridge: 20,
2813
+ fill: 40
2814
+ };
2815
+ var COMPLETED_MILESTONE_GROUP_STATUSES = /* @__PURE__ */ new Set([
2816
+ "completed",
2817
+ "skipped"
2818
+ ]);
2819
+ var TERMINAL_EXECUTION_GROUP_STATUSES = /* @__PURE__ */ new Set([
2820
+ "completed",
2821
+ "failed",
2822
+ "skipped"
2823
+ ]);
2824
+ var uniqueGroupsForOrderAndKind = ({
2825
+ kind,
2826
+ orderId,
2827
+ steps
2828
+ }) => {
2829
+ var _a;
2830
+ const groups = /* @__PURE__ */ new Map();
2831
+ for (const step of steps) {
2832
+ if (step.kind !== kind || !((_a = step.orderIds) == null ? void 0 : _a.includes(orderId)) || groups.has(step.groupId))
2833
+ continue;
2834
+ groups.set(step.groupId, step);
2835
+ }
2836
+ return Array.from(groups.values());
2837
+ };
2838
+ var calculateExecutionProgress = ({
2839
+ orderIds,
2840
+ submittedOrderIds = [],
2841
+ executionSteps = [],
2842
+ executionOrders = [],
2843
+ minimumProgress = 0
2844
+ }) => {
2845
+ const resolvedOrderIds = orderIds.length > 0 ? orderIds : executionOrders.map((order) => order.orderId);
2846
+ if (resolvedOrderIds.length === 0) return 0;
2847
+ const submittedIds = new Set(submittedOrderIds);
2848
+ const orderById = new Map(executionOrders.map((order) => [order.orderId, order]));
2849
+ const hasAuthoritativeTopology = executionSteps.some(
2850
+ (step) => {
2851
+ var _a, _b;
2852
+ return step.kind !== "internal" && step.kind !== "submit" && ((_b = (_a = step.orderIds) == null ? void 0 : _a.length) != null ? _b : 0) > 0;
2853
+ }
2854
+ );
2855
+ let progress = 0;
2856
+ for (const orderId of resolvedOrderIds) {
2857
+ const order = orderById.get(orderId);
2858
+ const isOrderTerminal = (order == null ? void 0 : order.event) !== null && (order == null ? void 0 : order.event) !== void 0;
2859
+ const contributionScale = 1 / resolvedOrderIds.length;
2860
+ const submitGroups = uniqueGroupsForOrderAndKind({
2861
+ kind: "submit",
2862
+ orderId,
2863
+ steps: executionSteps
2864
+ });
2865
+ const setupGroups = uniqueGroupsForOrderAndKind({
2866
+ kind: "setup",
2867
+ orderId,
2868
+ steps: executionSteps
2869
+ });
2870
+ const bridgeGroups = uniqueGroupsForOrderAndKind({
2871
+ kind: "bridge",
2872
+ orderId,
2873
+ steps: executionSteps
2874
+ });
2875
+ const fillGroups = uniqueGroupsForOrderAndKind({
2876
+ kind: "fill",
2877
+ orderId,
2878
+ steps: executionSteps
2879
+ });
2880
+ const submissionComplete = isOrderTerminal || submittedIds.has(orderId) || submitGroups.some((step) => COMPLETED_MILESTONE_GROUP_STATUSES.has(step.groupStatus));
2881
+ const fundingComplete = isOrderTerminal || hasAuthoritativeTopology && (setupGroups.length === 0 || setupGroups.every((step) => COMPLETED_MILESTONE_GROUP_STATUSES.has(step.groupStatus)));
2882
+ const bridgingComplete = isOrderTerminal || hasAuthoritativeTopology && (bridgeGroups.length === 0 || bridgeGroups.every((step) => COMPLETED_MILESTONE_GROUP_STATUSES.has(step.groupStatus)));
2883
+ const executionComplete = isOrderTerminal || fillGroups.length > 0 && fillGroups.every((step) => TERMINAL_EXECUTION_GROUP_STATUSES.has(step.groupStatus));
2884
+ if (submissionComplete) progress += EXECUTION_MILESTONE_WEIGHTS.submit * contributionScale;
2885
+ if (fundingComplete) progress += EXECUTION_MILESTONE_WEIGHTS.setup * contributionScale;
2886
+ if (bridgingComplete) progress += EXECUTION_MILESTONE_WEIGHTS.bridge * contributionScale;
2887
+ if (executionComplete) progress += EXECUTION_MILESTONE_WEIGHTS.fill * contributionScale;
2888
+ }
2889
+ return Math.min(100, Math.max(0, minimumProgress, Math.round(progress)));
2753
2890
  };
2754
2891
 
2755
2892
  // src/trading/place-order/index.place-order.execution-view.tsx
@@ -2801,6 +2938,28 @@ var ExecutionStepIndicator = ({
2801
2938
  }
2802
2939
  ) });
2803
2940
  }
2941
+ if (step.status === "failed") {
2942
+ return /* @__PURE__ */ jsx4(
2943
+ Icon,
2944
+ {
2945
+ name: "error-filled",
2946
+ size: "xs",
2947
+ className: "h-3 w-3 shrink-0 text-agg-error",
2948
+ "aria-hidden": "true"
2949
+ }
2950
+ );
2951
+ }
2952
+ if (step.status === "warning") {
2953
+ return /* @__PURE__ */ jsx4(
2954
+ Icon,
2955
+ {
2956
+ name: "warning-filled",
2957
+ size: "xs",
2958
+ className: "h-3 w-3 shrink-0 text-agg-warning",
2959
+ "aria-hidden": "true"
2960
+ }
2961
+ );
2962
+ }
2804
2963
  return /* @__PURE__ */ jsx4(
2805
2964
  "span",
2806
2965
  {
@@ -2864,10 +3023,9 @@ var PlaceOrderExecutionView = ({
2864
3023
  eventImage,
2865
3024
  eventTitle,
2866
3025
  groups,
2867
- labels
3026
+ labels,
3027
+ progress
2868
3028
  }) => {
2869
- const steps = groups.flatMap((group) => group.steps);
2870
- const completedStepCount = steps.filter((step) => step.status === "done").length;
2871
3029
  return /* @__PURE__ */ jsx4(
2872
3030
  Card,
2873
3031
  {
@@ -2888,30 +3046,18 @@ var PlaceOrderExecutionView = ({
2888
3046
  }
2889
3047
  ),
2890
3048
  /* @__PURE__ */ jsxs3("div", { className: cn("flex flex-col gap-5", classNames == null ? void 0 : classNames.content), children: [
2891
- /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-2", children: [
2892
- /* @__PURE__ */ jsx4("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: labels.executingOrder }),
3049
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3", children: [
3050
+ /* @__PURE__ */ jsxs3("p", { className: "shrink-0 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: [
3051
+ progress,
3052
+ "%"
3053
+ ] }),
2893
3054
  /* @__PURE__ */ jsx4(
2894
- "div",
3055
+ "progress",
2895
3056
  {
2896
- role: "progressbar",
2897
3057
  "aria-label": labels.executingOrder,
2898
- "aria-valuemin": 0,
2899
- "aria-valuemax": steps.length,
2900
- "aria-valuenow": completedStepCount,
2901
- className: "flex h-1 w-full gap-0.5",
2902
- children: steps.map((step) => /* @__PURE__ */ jsx4(
2903
- "span",
2904
- {
2905
- "data-testid": "execution-progress-segment",
2906
- className: cn(
2907
- "h-1 min-w-0 flex-1 rounded-agg-full",
2908
- step.status === "done" ? "bg-agg-primary" : "bg-agg-separator"
2909
- ),
2910
- "aria-hidden": "true",
2911
- "data-status": step.status
2912
- },
2913
- step.id
2914
- ))
3058
+ className: "h-1 min-w-0 flex-1 overflow-hidden rounded-agg-full bg-agg-separator text-agg-primary accent-agg-primary [&::-moz-progress-bar]:bg-agg-primary [&::-webkit-progress-bar]:bg-agg-separator [&::-webkit-progress-value]:bg-agg-primary",
3059
+ max: 100,
3060
+ value: progress
2915
3061
  }
2916
3062
  )
2917
3063
  ] }),
@@ -2974,7 +3120,7 @@ var PlaceOrderFailureView = ({
2974
3120
  onDone,
2975
3121
  onSkip
2976
3122
  }) => {
2977
- var _a, _b, _c;
3123
+ var _a, _b, _c, _d, _e;
2978
3124
  const shouldShowPartialFailureLayout = summary.kind === "partial_fill";
2979
3125
  const failureStepGroups = shouldShowPartialFailureLayout ? groupPlaceOrderFailureSteps(summary.steps) : [];
2980
3126
  if (shouldShowPartialFailureLayout) {
@@ -2993,14 +3139,42 @@ var PlaceOrderFailureView = ({
2993
3139
  ] }),
2994
3140
  summary.eventSubtitle ? /* @__PURE__ */ jsx5("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
2995
3141
  ] }),
2996
- /* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-4", children: failureStepGroups.map((group, groupIndex) => /* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-2", children: group.map((step) => renderPartialFailureStep(step)) }, `failure-group-${groupIndex}`)) }),
2997
- /* @__PURE__ */ jsx5("div", { className: "flex items-center gap-4", children: summary.actions.map((action) => /* @__PURE__ */ jsx5(
3142
+ /* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-4", children: ((_b = summary.executionGroups) == null ? void 0 : _b.length) ? /* @__PURE__ */ jsx5(
3143
+ PlaceOrderExecutionGroups,
3144
+ {
3145
+ enableAnimations: false,
3146
+ groups: summary.executionGroups,
3147
+ labels: tradingLabels
3148
+ }
3149
+ ) : failureStepGroups.map((group, groupIndex) => /* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-2", children: group.map((step) => renderPartialFailureStep(step)) }, `failure-group-${groupIndex}`)) }),
3150
+ summary.errorMessage ? /* @__PURE__ */ jsx5(
3151
+ InlineAlert,
3152
+ {
3153
+ tone: "error",
3154
+ variant: "surface",
3155
+ message: tradingLabels.orderFailureDescription(summary.errorMessage)
3156
+ }
3157
+ ) : null,
3158
+ summary.result ? /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-4", children: [
3159
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-4", children: [
3160
+ /* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 flex-col", children: [
3161
+ /* @__PURE__ */ jsx5("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.orderPartiallyFilled }),
3162
+ /* @__PURE__ */ jsx5("p", { className: "text-agg-sm leading-agg-5 text-agg-muted-foreground", children: tradingLabels.orderAveragePrice(summary.result.averagePriceLabel) })
3163
+ ] }),
3164
+ /* @__PURE__ */ jsx5("p", { className: "shrink-0 text-right text-[30px] font-agg-bold leading-[36px] text-agg-foreground", children: summary.result.filledAmountLabel })
3165
+ ] }),
3166
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-4", children: [
3167
+ /* @__PURE__ */ jsx5("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.orderPayout }),
3168
+ /* @__PURE__ */ jsx5("p", { className: "shrink-0 text-right text-[30px] font-agg-bold leading-[36px] text-agg-success", children: summary.result.payoutLabel })
3169
+ ] })
3170
+ ] }) : null,
3171
+ /* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-4", children: summary.actions.map((action) => /* @__PURE__ */ jsx5(
2998
3172
  Button,
2999
3173
  {
3000
- variant: "tertiary",
3174
+ variant: action.variant === "retry" ? "primary" : "secondary",
3001
3175
  size: "medium",
3002
3176
  "aria-label": action.label,
3003
- className: "text-agg-sm! leading-agg-5! text-agg-primary!",
3177
+ className: "w-full",
3004
3178
  onClick: resolveFailureActionHandler({ action, onDone, onRetry, onSkip }),
3005
3179
  children: action.label
3006
3180
  },
@@ -3014,7 +3188,7 @@ var PlaceOrderFailureView = ({
3014
3188
  /* @__PURE__ */ jsx5(
3015
3189
  RemoteImage,
3016
3190
  {
3017
- src: (_b = summary.eventImage) != null ? _b : null,
3191
+ src: (_c = summary.eventImage) != null ? _c : null,
3018
3192
  alt: "",
3019
3193
  className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
3020
3194
  }
@@ -3023,21 +3197,29 @@ var PlaceOrderFailureView = ({
3023
3197
  ] }),
3024
3198
  summary.eventSubtitle ? /* @__PURE__ */ jsx5("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
3025
3199
  ] }),
3200
+ ((_d = summary.executionGroups) == null ? void 0 : _d.length) ? /* @__PURE__ */ jsx5(
3201
+ PlaceOrderExecutionGroups,
3202
+ {
3203
+ enableAnimations: false,
3204
+ groups: summary.executionGroups,
3205
+ labels: tradingLabels
3206
+ }
3207
+ ) : null,
3026
3208
  /* @__PURE__ */ jsx5(
3027
3209
  InlineAlert,
3028
3210
  {
3029
3211
  tone: "error",
3030
3212
  variant: "surface",
3031
3213
  title: tradingLabels.orderFailureTitle,
3032
- message: tradingLabels.orderFailureDescription((_c = summary.errorMessage) != null ? _c : "")
3214
+ message: tradingLabels.orderFailureDescription((_e = summary.errorMessage) != null ? _e : "")
3033
3215
  }
3034
3216
  ),
3035
- /* @__PURE__ */ jsx5("div", { className: "agg-order-failure-actions flex items-center gap-3", children: summary.actions.map((action) => /* @__PURE__ */ jsx5(
3217
+ /* @__PURE__ */ jsx5("div", { className: "agg-order-failure-actions flex flex-col gap-4", children: summary.actions.map((action) => /* @__PURE__ */ jsx5(
3036
3218
  Button,
3037
3219
  {
3038
3220
  variant: action.variant === "retry" ? "primary" : "secondary",
3039
3221
  size: "medium",
3040
- className: "flex-1",
3222
+ className: "w-full",
3041
3223
  "aria-label": action.label,
3042
3224
  onClick: resolveFailureActionHandler({ action, onDone, onRetry, onSkip }),
3043
3225
  children: action.label
@@ -3061,7 +3243,7 @@ var PlaceOrderSuccessView = ({
3061
3243
  onDone,
3062
3244
  onShare: _onShare
3063
3245
  }) => {
3064
- var _a, _b, _c, _d, _e, _f;
3246
+ var _a, _b, _c, _d, _e;
3065
3247
  const resolvedTradeSide = (_a = summary.tradeSide) != null ? _a : "buy";
3066
3248
  const resolvedAmountLabel = (_b = summary.amountLabel) != null ? _b : resolvedTradeSide === "sell" ? summary.shares : summary.estimatedCost;
3067
3249
  const resolvedPayoutLabel = (_c = summary.toWinLabel) != null ? _c : resolvedTradeSide === "sell" ? summary.estimatedCost : resolveBuyPayoutLabel(summary.shares);
@@ -3114,15 +3296,11 @@ var PlaceOrderSuccessView = ({
3114
3296
  },
3115
3297
  step.id
3116
3298
  )) }) : null,
3117
- /* @__PURE__ */ jsxs5("div", { className: "agg-order-success-pill flex h-11 w-full items-center justify-center gap-2 rounded-agg-full bg-agg-success px-6 py-2.5 text-center text-agg-base font-agg-bold leading-agg-6 text-agg-on-primary", children: [
3118
- /* @__PURE__ */ jsx6(Icon, { name: "success-check", size: "xs", className: "h-3 w-3 shrink-0 text-current" }),
3119
- /* @__PURE__ */ jsx6("span", { children: (_f = summary.actionLabel) != null ? _f : tradingLabels.orderSuccessTitle })
3120
- ] }),
3121
3299
  /* @__PURE__ */ jsxs5("div", { className: "agg-order-success-summary flex flex-col gap-4", children: [
3122
3300
  /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between gap-4", children: [
3123
3301
  /* @__PURE__ */ jsxs5("div", { className: "flex min-w-0 flex-col", children: [
3124
- /* @__PURE__ */ jsx6("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: summary.requestedAmountLabel ? resolvedTradeSide === "buy" ? tradingLabels.orderAmountFilled : tradingLabels.amount(resolvedTradeSide) : tradingLabels.amount(resolvedTradeSide) }),
3125
- summary.requestedAmountLabel ? /* @__PURE__ */ jsx6("p", { className: "text-agg-sm leading-agg-5 text-agg-muted-foreground", children: tradingLabels.orderAmountFilledOf(summary.requestedAmountLabel) }) : null
3302
+ /* @__PURE__ */ jsx6("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: summary.resultState === "partial" ? tradingLabels.orderPartiallyFilled : tradingLabels.orderFullyFilled }),
3303
+ /* @__PURE__ */ jsx6("p", { className: "text-agg-sm leading-agg-5 text-agg-muted-foreground", children: tradingLabels.orderAveragePrice(summary.avgPrice) })
3126
3304
  ] }),
3127
3305
  /* @__PURE__ */ jsx6("p", { className: "shrink-0 text-right text-[30px] font-agg-bold leading-[36px] text-agg-foreground", children: resolvedAmountLabel })
3128
3306
  ] }),
@@ -3540,13 +3718,14 @@ var PlaceOrderResolvedView = ({
3540
3718
  resolutionTimestamp,
3541
3719
  resolvedClaim,
3542
3720
  className,
3543
- isSportsEvent = false
3721
+ isSportsEvent = false,
3722
+ showResolvingState = false
3544
3723
  }) => {
3545
3724
  var _a, _b;
3546
3725
  const labels = useLabels2();
3547
3726
  const tradingLabels = labels.trading;
3548
3727
  const resolvingTimestamp = (_a = resolutionTimestamp != null ? resolutionTimestamp : tradingState.resolvesAt) != null ? _a : tradingState.endsAt;
3549
- const isResolvingMarket = false;
3728
+ const isResolvingMarket = showResolvingState && !tradingState.winningOutcome;
3550
3729
  const resolvingSubtitle = tradingState.market ? (() => {
3551
3730
  const endDateLabel = isSportsEvent ? formatSportsEventTimeEt(resolvingTimestamp != null ? resolvingTimestamp : "") : getTradingDateLabel(resolvingTimestamp != null ? resolvingTimestamp : "");
3552
3731
  return endDateLabel ? `${tradingState.market.question} \xB7 ${endDateLabel}` : tradingState.market.question;
@@ -3826,6 +4005,7 @@ var PlaceOrder = ({
3826
4005
  onError,
3827
4006
  onExecutionStateChange,
3828
4007
  resolvedClaim,
4008
+ showResolvingState = false,
3829
4009
  midpointsResult
3830
4010
  }) => {
3831
4011
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha;
@@ -3889,7 +4069,7 @@ var PlaceOrder = ({
3889
4069
  const resolvedReadOnlyTradingState = useMemo(() => {
3890
4070
  return resolveMarketTradingState(resolvedReadOnlyMarket);
3891
4071
  }, [resolvedReadOnlyMarket]);
3892
- const isEndedWithoutKnownWinner = false;
4072
+ const isEndedWithoutKnownWinner = showResolvingState && !resolvedEventTradingState.winningOutcome && !resolvedReadOnlyTradingState.winningOutcome;
3893
4073
  const orderEligibility = useMemo(
3894
4074
  () => resolveOrderEligibility({
3895
4075
  event: scopedSelectedEvent,
@@ -4525,6 +4705,10 @@ var PlaceOrder = ({
4525
4705
  mode: isPaperMode ? "paper" : void 0,
4526
4706
  enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((_N = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _N.length)
4527
4707
  });
4708
+ const executionProgressFloorRef = useRef2({
4709
+ quoteId: null,
4710
+ value: 0
4711
+ });
4528
4712
  const selectedOutcomeLabel = (_Q = (_P = (_O = outcomes.find((outcome) => outcome.id === scopedSelectedOutcomeId)) == null ? void 0 : _O.label) != null ? _P : scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.label) != null ? _Q : "";
4529
4713
  const headerImage = (_S = (_R = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.image) != null ? _R : scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.image) != null ? _S : null;
4530
4714
  const headerTitle = (_U = (_T = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _T : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _U : "";
@@ -4555,6 +4739,26 @@ var PlaceOrder = ({
4555
4739
  (_Z = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _Z.length,
4556
4740
  tradingLabels
4557
4741
  ]);
4742
+ const executionProgressPercent = useMemo(() => {
4743
+ var _a2, _b2, _c2;
4744
+ const quoteId = (_a2 = submissionProgressState == null ? void 0 : submissionProgressState.quoteId) != null ? _a2 : null;
4745
+ const previousProgress = executionProgressFloorRef.current.quoteId === quoteId ? executionProgressFloorRef.current.value : 0;
4746
+ const nextProgress = calculateExecutionProgress({
4747
+ orderIds: (_b2 = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) != null ? _b2 : [],
4748
+ submittedOrderIds: executionProgress.submittedOrders.map((order) => order.orderId),
4749
+ executionSteps: executionProgress.executionSteps,
4750
+ executionOrders: (_c2 = executionProgress.executionOrders) != null ? _c2 : [],
4751
+ minimumProgress: previousProgress
4752
+ });
4753
+ executionProgressFloorRef.current = { quoteId, value: nextProgress };
4754
+ return nextProgress;
4755
+ }, [
4756
+ executionProgress.executionOrders,
4757
+ executionProgress.executionSteps,
4758
+ executionProgress.submittedOrders,
4759
+ submissionProgressState == null ? void 0 : submissionProgressState.orderIds,
4760
+ submissionProgressState == null ? void 0 : submissionProgressState.quoteId
4761
+ ]);
4558
4762
  const buildExecutionSummary = useCallback2(
4559
4763
  (quoteData, executionVenue, orderId, partialFillSummary) => {
4560
4764
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2;
@@ -4583,6 +4787,7 @@ var PlaceOrder = ({
4583
4787
  const eventTitle = (_f2 = (_e2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _e2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _f2 : "";
4584
4788
  const eventDateSource = (_g2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.endDate) != null ? _g2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.endDate;
4585
4789
  return {
4790
+ resultState: partialFillSummary ? "partial" : "success",
4586
4791
  tradeSide: internalTab,
4587
4792
  shares: sharesLabel,
4588
4793
  avgPrice: avgPriceLabel,
@@ -4923,31 +5128,30 @@ var PlaceOrder = ({
4923
5128
  });
4924
5129
  }, [isSell, orderedRouteCards.length, smartRoute.error, tradingLabels, venueSellQuotes.error]);
4925
5130
  const progressActionLabel = (internalTab === "buy" ? tradingLabels.buyingOutcome(selectedOutcomeLabel) : tradingLabels.sellingOutcome(selectedOutcomeLabel)).trim();
4926
- const canRetryRemaining = useMemo(() => {
4927
- const remaining = getPlaceOrderUnfilledRemaining({
5131
+ const retryRemainingAmount = useMemo(() => {
5132
+ return getCanonicalPlaceOrderUnfilledRemaining({
4928
5133
  originalAmount: internalAmount,
4929
5134
  tradeSide: internalTab,
4930
5135
  terminalOrderEvents: executionProgress.terminalOrderEvents
4931
5136
  });
5137
+ }, [executionProgress.terminalOrderEvents, internalAmount, internalTab]);
5138
+ const canRetryRemaining = useMemo(() => {
5139
+ if (retryRemainingAmount == null) return false;
4932
5140
  const minRemainder = isSell ? MIN_SELL_ORDER_SHARES : MIN_BUY_ORDER_AMOUNT;
4933
- return remaining >= minRemainder;
4934
- }, [executionProgress.terminalOrderEvents, internalAmount, internalTab, isSell]);
5141
+ return retryRemainingAmount >= minRemainder;
5142
+ }, [isSell, retryRemainingAmount]);
4935
5143
  const PARTIAL_FILL_AUTO_SUCCESS_THRESHOLD = 0.95;
4936
5144
  const shouldAutoSkipPartialFill = useMemo(() => {
4937
- if (internalAmount <= 0) return false;
4938
- const remaining = getPlaceOrderUnfilledRemaining({
4939
- originalAmount: internalAmount,
4940
- tradeSide: internalTab,
4941
- terminalOrderEvents: executionProgress.terminalOrderEvents
4942
- });
4943
- const filled = Math.max(0, internalAmount - remaining);
5145
+ if (internalAmount <= 0 || retryRemainingAmount == null) return false;
5146
+ const filled = Math.max(0, internalAmount - retryRemainingAmount);
4944
5147
  const fillRatio = filled / internalAmount;
4945
5148
  return fillRatio >= PARTIAL_FILL_AUTO_SUCCESS_THRESHOLD || !canRetryRemaining;
4946
- }, [canRetryRemaining, executionProgress.terminalOrderEvents, internalAmount, internalTab]);
5149
+ }, [canRetryRemaining, internalAmount, retryRemainingAmount]);
4947
5150
  const failureSummary = useMemo(() => {
4948
5151
  var _a2;
4949
5152
  if ((submissionProgressState == null ? void 0 : submissionProgressState.phase) !== "failed") return void 0;
4950
- return buildPlaceOrderFailureSummary({
5153
+ const quoteData = (_a2 = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _a2 : activeQuoteData;
5154
+ const baseSummary = buildPlaceOrderFailureSummary({
4951
5155
  actionLabel: progressActionLabel,
4952
5156
  canRetryRemaining,
4953
5157
  errorMessage: submissionProgressState.errorMessage,
@@ -4956,19 +5160,53 @@ var PlaceOrder = ({
4956
5160
  eventTitle: headerTitle || tradingLabels.orderFailureTitle,
4957
5161
  labels: tradingLabels,
4958
5162
  orderId: submissionProgressState.orderId,
4959
- quoteData: (_a2 = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _a2 : activeQuoteData,
5163
+ quoteData,
4960
5164
  submittedOrders: executionProgress.submittedOrders,
4961
5165
  terminalOrderEvents: executionProgress.terminalOrderEvents
4962
5166
  });
5167
+ const summaryWithGroups = __spreadValues(__spreadValues({}, baseSummary), executionOrderGroups.length > 0 ? { executionGroups: executionOrderGroups } : {});
5168
+ if (baseSummary.kind !== "partial_fill") return summaryWithGroups;
5169
+ const actualEconomics = resolveActualExecutionEconomics({
5170
+ quoteData,
5171
+ tradeSide: internalTab,
5172
+ terminalOrderEvents: executionProgress.terminalOrderEvents,
5173
+ submittedOrders: executionProgress.submittedOrders
5174
+ });
5175
+ if (!actualEconomics.hasActualFillData) return summaryWithGroups;
5176
+ if (retryRemainingAmount == null) return summaryWithGroups;
5177
+ const remaining = retryRemainingAmount;
5178
+ const remainingLabel = isSell ? tradingLabels.executionShares(
5179
+ remaining.toLocaleString("en-US", { maximumFractionDigits: 2 })
5180
+ ) : formatUsd(remaining);
5181
+ const filledAmountLabel = isSell ? tradingLabels.executionShares(
5182
+ actualEconomics.actualTotalFilled.toLocaleString("en-US", {
5183
+ maximumFractionDigits: 2
5184
+ })
5185
+ ) : formatUsd(actualEconomics.actualRawExecCost);
5186
+ const payoutLabel = isSell ? formatUsd(actualEconomics.actualRawExecCost) : formatUsd(actualEconomics.actualTotalFilled);
5187
+ return __spreadProps(__spreadValues({}, summaryWithGroups), {
5188
+ actions: summaryWithGroups.actions.map(
5189
+ (action) => action.variant === "retry" ? __spreadProps(__spreadValues({}, action), { label: tradingLabels.orderTryRemaining(remainingLabel) }) : action
5190
+ ),
5191
+ result: {
5192
+ averagePriceLabel: getTradingRoutePriceLabel(actualEconomics.avgExecutionPrice),
5193
+ filledAmountLabel,
5194
+ payoutLabel
5195
+ }
5196
+ });
4963
5197
  }, [
4964
5198
  activeQuoteData,
4965
5199
  canRetryRemaining,
5200
+ executionOrderGroups,
4966
5201
  executionProgress.submittedOrders,
4967
5202
  executionProgress.terminalOrderEvents,
4968
5203
  headerImage,
4969
5204
  headerSubtitle,
4970
5205
  headerTitle,
5206
+ internalTab,
5207
+ isSell,
4971
5208
  progressActionLabel,
5209
+ retryRemainingAmount,
4972
5210
  selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData,
4973
5211
  submissionProgressState,
4974
5212
  tradingLabels
@@ -5492,7 +5730,7 @@ var PlaceOrder = ({
5492
5730
  if (!shouldAutoSkipPartialFill) return;
5493
5731
  handleSkipToSuccess();
5494
5732
  }, [
5495
- failureSummary == null ? void 0 : failureSummary.kind,
5733
+ failureSummary,
5496
5734
  handleSkipToSuccess,
5497
5735
  shouldAutoSkipPartialFill,
5498
5736
  submissionProgressState == null ? void 0 : submissionProgressState.phase
@@ -5506,12 +5744,8 @@ var PlaceOrder = ({
5506
5744
  setSubmissionFeedback(null);
5507
5745
  let retryAmount = internalAmount;
5508
5746
  let useRemainderRoute = false;
5509
- if ((failureSummary == null ? void 0 : failureSummary.kind) === "partial_fill" && internalAmount > 0) {
5510
- const remaining = getPlaceOrderUnfilledRemaining({
5511
- originalAmount: internalAmount,
5512
- tradeSide: internalTab,
5513
- terminalOrderEvents: executionProgress.terminalOrderEvents
5514
- });
5747
+ if ((failureSummary == null ? void 0 : failureSummary.kind) === "partial_fill" && internalAmount > 0 && retryRemainingAmount != null) {
5748
+ const remaining = retryRemainingAmount;
5515
5749
  if (remaining > 0) {
5516
5750
  retryAmount = remaining;
5517
5751
  useRemainderRoute = true;
@@ -5631,8 +5865,7 @@ var PlaceOrder = ({
5631
5865
  }), [
5632
5866
  aggClient,
5633
5867
  chainBalancesOverride,
5634
- executionProgress.terminalOrderEvents,
5635
- failureSummary == null ? void 0 : failureSummary.kind,
5868
+ failureSummary,
5636
5869
  handleExecuteQuote,
5637
5870
  handleReturnToOrderForm,
5638
5871
  internalAmount,
@@ -5642,6 +5875,7 @@ var PlaceOrder = ({
5642
5875
  onAmountChange,
5643
5876
  orderEligibility.canPlaceOrder,
5644
5877
  orderedRouteCards,
5878
+ retryRemainingAmount,
5645
5879
  scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.venueMarkets,
5646
5880
  scopedSelectedOutcomeId,
5647
5881
  selectedRouteCardId,
@@ -5697,7 +5931,8 @@ var PlaceOrder = ({
5697
5931
  eventImage: headerImage,
5698
5932
  eventTitle: headerTitle,
5699
5933
  groups: executionOrderGroups,
5700
- labels: tradingLabels
5934
+ labels: tradingLabels,
5935
+ progress: executionProgressPercent
5701
5936
  }
5702
5937
  );
5703
5938
  }
@@ -5912,7 +6147,8 @@ var PlaceOrder = ({
5912
6147
  resolvedClaim,
5913
6148
  classNames,
5914
6149
  className,
5915
- isSportsEvent: (scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.structureType) === "sport" && !!(scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.sport) && scopedSelectedEvent.sport !== "other_sport"
6150
+ isSportsEvent: (scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.structureType) === "sport" && !!(scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.sport) && scopedSelectedEvent.sport !== "other_sport",
6151
+ showResolvingState
5916
6152
  }
5917
6153
  );
5918
6154
  }
@@ -6992,7 +7228,7 @@ function useResolvedMarketClaim(options = {}) {
6992
7228
  });
6993
7229
  } : void 0
6994
7230
  };
6995
- }, [claimWinnings, marketId, positions, shouldFetch]);
7231
+ }, [claimWinnings, market, marketId, positions, shouldFetch]);
6996
7232
  }
6997
7233
 
6998
7234
  export {