@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
package/dist/trading.js CHANGED
@@ -8528,7 +8528,7 @@ var getSmartRouteTotalFees = (feeBreakdown) => {
8528
8528
  if (!feeBreakdown) return null;
8529
8529
  const feeParts = [feeBreakdown.venueFees, feeBreakdown.bridgeFees, feeBreakdown.executionGas];
8530
8530
  if (!feeParts.every(Number.isFinite)) return null;
8531
- return feeParts.reduce((total, fee) => total + fee, 0);
8531
+ return feeParts.reduce((total, fee) => total + Math.round(fee * 100) / 100, 0);
8532
8532
  };
8533
8533
  var getPlaceOrderContainerClassName = () => {
8534
8534
  return PLACE_ORDER_CONTAINER_CLASS_NAME;
@@ -8790,7 +8790,7 @@ var buildLiveRouteCards = ({
8790
8790
  // balance condition, and `handleExecuteQuote` rejects an empty quoteId.
8791
8791
  sq.venue !== primaryWinnerVenue
8792
8792
  ).map((sq) => {
8793
- var _a2;
8793
+ var _a2, _b2;
8794
8794
  const parsedVenue = parseVenue(sq.venue);
8795
8795
  const venue = parsedVenue.success ? parsedVenue.data : void 0;
8796
8796
  if (geoBlockedVenues.has(sq.venue)) {
@@ -8823,7 +8823,12 @@ var buildLiveRouteCards = ({
8823
8823
  estimatedProfit: sq.estimatedProfit,
8824
8824
  returnPct: sq.returnPct,
8825
8825
  // venueSoloQuotes stripped on solo card's quoteData (only the primary needs them)
8826
- venueSoloQuotes: void 0
8826
+ venueSoloQuotes: void 0,
8827
+ // This solo's OWN fee breakdown. Without it the spread above leaves the
8828
+ // primary route's breakdown in place, so selecting a bridge-free venue
8829
+ // still showed the primary's bridging charge. Falls back to the
8830
+ // primary only when the router omitted one (non-"ok" solos).
8831
+ feeBreakdown: (_b2 = sq.feeBreakdown) != null ? _b2 : quoteData.feeBreakdown
8827
8832
  }), sq.quoteId ? { status: "ok", error: void 0 } : null);
8828
8833
  return {
8829
8834
  id: `live-solo-${sq.venue}`,
@@ -9445,18 +9450,15 @@ var resolvePlaceOrderFailureActions = ({
9445
9450
  canRetryRemaining = true,
9446
9451
  kind,
9447
9452
  labels,
9448
- terminalEvent
9453
+ terminalEvent: _terminalEvent
9449
9454
  }) => {
9450
- const parsedVenue = parseVenue(terminalEvent == null ? void 0 : terminalEvent.venue);
9451
- const venue = parsedVenue.success ? parsedVenue.data : void 0;
9452
- const venueLabel = getTradingVenueLabel(venue);
9453
9455
  if (kind === "partial_fill") {
9454
9456
  if (!canRetryRemaining) {
9455
9457
  return [
9456
9458
  {
9457
- id: "skip",
9458
- label: labels.orderSkip,
9459
- variant: "skip"
9459
+ id: "new-trade",
9460
+ label: labels.orderNewTrade,
9461
+ variant: "dismiss"
9460
9462
  }
9461
9463
  ];
9462
9464
  }
@@ -9467,9 +9469,9 @@ var resolvePlaceOrderFailureActions = ({
9467
9469
  variant: "retry"
9468
9470
  },
9469
9471
  {
9470
- id: "skip",
9471
- label: labels.orderSkip,
9472
- variant: "skip"
9472
+ id: "new-trade",
9473
+ label: labels.orderNewTrade,
9474
+ variant: "dismiss"
9473
9475
  }
9474
9476
  ];
9475
9477
  }
@@ -9477,12 +9479,12 @@ var resolvePlaceOrderFailureActions = ({
9477
9479
  return [
9478
9480
  {
9479
9481
  id: "retry",
9480
- label: labels.orderRetryVenue(venueLabel),
9482
+ label: labels.orderRetry,
9481
9483
  variant: "retry"
9482
9484
  },
9483
9485
  {
9484
- id: "dismiss",
9485
- label: labels.orderDismiss,
9486
+ id: "close",
9487
+ label: labels.orderClose,
9486
9488
  variant: "dismiss"
9487
9489
  }
9488
9490
  ];
@@ -9503,8 +9505,8 @@ var resolvePlaceOrderFailureActions = ({
9503
9505
  variant: "retry"
9504
9506
  },
9505
9507
  {
9506
- id: "dismiss",
9507
- label: labels.orderDone,
9508
+ id: "close",
9509
+ label: labels.orderClose,
9508
9510
  variant: "dismiss"
9509
9511
  }
9510
9512
  ];
@@ -9590,6 +9592,21 @@ var getPlaceOrderUnfilledRemaining = ({
9590
9592
  }, 0);
9591
9593
  return Math.max(0, originalAmount - filled);
9592
9594
  };
9595
+ var getCanonicalPlaceOrderUnfilledRemaining = ({
9596
+ originalAmount,
9597
+ tradeSide,
9598
+ terminalOrderEvents
9599
+ }) => {
9600
+ const fillEvents = (terminalOrderEvents != null ? terminalOrderEvents : []).filter(
9601
+ (event) => event.event === "filled" || event.event === "partial_fill"
9602
+ );
9603
+ if (fillEvents.length === 0) return null;
9604
+ const hasCanonicalFillUnits = fillEvents.every(
9605
+ (event) => tradeSide === "buy" ? event.filledAmountRaw != null : event.actualSharesRaw != null
9606
+ );
9607
+ if (!hasCanonicalFillUnits) return null;
9608
+ return getPlaceOrderUnfilledRemaining({ originalAmount, tradeSide, terminalOrderEvents });
9609
+ };
9593
9610
  var buildPlaceOrderFailureSummary = ({
9594
9611
  actionLabel,
9595
9612
  canRetryRemaining,
@@ -9603,7 +9620,7 @@ var buildPlaceOrderFailureSummary = ({
9603
9620
  submittedOrders,
9604
9621
  terminalOrderEvents
9605
9622
  }) => {
9606
- var _a;
9623
+ var _a, _b;
9607
9624
  const normalizedErrorMessage = normalizePlaceOrderErrorMessage({
9608
9625
  errorMessage,
9609
9626
  fallbackMessage: labels.orderFailed,
@@ -9649,7 +9666,7 @@ var buildPlaceOrderFailureSummary = ({
9649
9666
  });
9650
9667
  }
9651
9668
  const venueSteps = sortedEvents.flatMap((terminalEvent, index) => {
9652
- var _a2, _b, _c, _d, _e;
9669
+ var _a2, _b2, _c, _d, _e;
9653
9670
  const parsedVenue = parseVenue(terminalEvent.venue);
9654
9671
  const venue = parsedVenue.success ? parsedVenue.data : void 0;
9655
9672
  const venueLabel = getTradingVenueLabel(venue);
@@ -9657,7 +9674,7 @@ var buildPlaceOrderFailureSummary = ({
9657
9674
  (candidate) => candidate.orderId === terminalEvent.orderId
9658
9675
  );
9659
9676
  const fallbackPrice = (_a2 = quoteData == null ? void 0 : quoteData.fills[index]) == null ? void 0 : _a2.avgPrice;
9660
- const priceLabel = getTradingRoutePriceLabel((_c = (_b = submittedOrder == null ? void 0 : submittedOrder.price) != null ? _b : fallbackPrice) != null ? _c : 0);
9677
+ const priceLabel = getTradingRoutePriceLabel((_c = (_b2 = submittedOrder == null ? void 0 : submittedOrder.price) != null ? _b2 : fallbackPrice) != null ? _c : 0);
9661
9678
  const filledDollars = parseFilledAmountRawDollars(terminalEvent.filledAmountRaw);
9662
9679
  const amountLabel = filledDollars != null ? formatUsd(filledDollars) : null;
9663
9680
  const executingStep = {
@@ -9706,6 +9723,17 @@ var buildPlaceOrderFailureSummary = ({
9706
9723
  } : null;
9707
9724
  const primaryNonFilledEvent = (_a = sortedEvents.find((e) => e.event !== "filled")) != null ? _a : sortedEvents[0];
9708
9725
  const parsedRetryVenue = primaryNonFilledEvent ? parseVenue(primaryNonFilledEvent.venue) : null;
9726
+ const failedEventMessage = (_b = sortedEvents.find(
9727
+ (event) => {
9728
+ var _a2;
9729
+ return event.event === "failed" && ((_a2 = event.errorReason) == null ? void 0 : _a2.trim());
9730
+ }
9731
+ )) == null ? void 0 : _b.errorReason;
9732
+ const resolvedErrorMessage = failedEventMessage ? normalizePlaceOrderErrorMessage({
9733
+ errorMessage: failedEventMessage,
9734
+ fallbackMessage: labels.orderFailed,
9735
+ labels
9736
+ }) : overallFailureKind === "partial_fill" ? void 0 : normalizedErrorMessage;
9709
9737
  return __spreadProps(__spreadValues({
9710
9738
  actionLabel,
9711
9739
  actions: resolvePlaceOrderFailureActions({
@@ -9714,7 +9742,7 @@ var buildPlaceOrderFailureSummary = ({
9714
9742
  labels,
9715
9743
  terminalEvent: primaryNonFilledEvent
9716
9744
  }),
9717
- errorMessage: normalizedErrorMessage,
9745
+ errorMessage: resolvedErrorMessage,
9718
9746
  eventImage,
9719
9747
  eventSubtitle,
9720
9748
  eventTitle,
@@ -9940,7 +9968,8 @@ var resolveActualFillPresentation = ({
9940
9968
  };
9941
9969
  var resolveBackendStepStatus = (status) => {
9942
9970
  if (status === "completed" || status === "skipped") return "done";
9943
- if (status === "in_progress" || status === "failed") return "loading";
9971
+ if (status === "failed") return "failed";
9972
+ if (status === "in_progress") return "loading";
9944
9973
  return "not-started";
9945
9974
  };
9946
9975
  var resolveOrderFallbackFill = (quoteData, order, orderIndex) => {
@@ -10051,20 +10080,35 @@ var deriveBackendExecutionOrderGroups = ({
10051
10080
  });
10052
10081
  const usesBackendPendingLabel = step.groupStatus === "pending" || step.groupStatus === "in_progress" || step.groupStatus === "failed";
10053
10082
  const usesBackendCompletedLabel = step.groupStatus === "completed" || step.groupStatus === "skipped";
10083
+ const isPartialFillStep = step.kind === "fill" && order.event === "partial_fill";
10084
+ const partialFillLabel = labels.orderPartiallyFilledAtPriceWithAmount(
10085
+ presentation.venueLabel,
10086
+ presentation.priceLabel,
10087
+ presentation.amountLabel
10088
+ );
10054
10089
  return {
10055
10090
  id: `${order.orderId}:${step.groupId}`,
10056
10091
  kind: step.kind,
10057
- pendingLabel: usesBackendPendingLabel ? step.label : fallbackLabels.pendingLabel,
10058
- completedLabel: usesBackendCompletedLabel ? step.label : fallbackLabels.completedLabel,
10059
- realStatus: forceCompleted ? "done" : resolveBackendStepStatus(step.groupStatus)
10092
+ pendingLabel: isPartialFillStep ? partialFillLabel : usesBackendPendingLabel ? step.label : fallbackLabels.pendingLabel,
10093
+ completedLabel: isPartialFillStep ? partialFillLabel : usesBackendCompletedLabel ? step.label : fallbackLabels.completedLabel,
10094
+ realStatus: isPartialFillStep ? "warning" : forceCompleted ? "done" : resolveBackendStepStatus(step.groupStatus)
10060
10095
  };
10061
10096
  });
10062
10097
  if (steps.length === 0) return [];
10063
10098
  return [__spreadProps(__spreadValues({ id: order.orderId }, presentation), { steps })];
10064
10099
  });
10065
- return deriveSequentialDisplayGroups(realGroups);
10066
- };
10067
- var deriveSequentialDisplayGroups = (groups) => {
10100
+ const allOrdersTerminal = executionOrders.every((order) => order.event !== null);
10101
+ return deriveSequentialDisplayGroups(realGroups, allOrdersTerminal);
10102
+ };
10103
+ var deriveSequentialDisplayGroups = (groups, revealTerminalOutcomes = false) => {
10104
+ if (revealTerminalOutcomes) {
10105
+ return groups.map((group) => __spreadProps(__spreadValues({}, group), {
10106
+ steps: group.steps.map((_a) => {
10107
+ var _b = _a, { realStatus } = _b, step = __objRest(_b, ["realStatus"]);
10108
+ return __spreadProps(__spreadValues({}, step), { status: realStatus });
10109
+ })
10110
+ }));
10111
+ }
10068
10112
  let hasUnresolvedPredecessor = false;
10069
10113
  return groups.map((group) => __spreadProps(__spreadValues({}, group), {
10070
10114
  steps: group.steps.map((_a) => {
@@ -10130,6 +10174,9 @@ var deriveExecutionOrderGroups = ({
10130
10174
  const hasSuccessfulTerminalEvent = venueTerminalEvents.some(
10131
10175
  (event) => event.event === "filled" || event.event === "partial_fill"
10132
10176
  );
10177
+ const hasPartialTerminalEvent = venueTerminalEvents.some(
10178
+ (event) => event.event === "partial_fill"
10179
+ );
10133
10180
  const hasVenueExecutionProgress = venueRawSteps.some(isRawStepStarted);
10134
10181
  const quotedAmount = fill.venueQty * fill.avgPrice;
10135
10182
  const actualFill = resolveActualFillPresentation({
@@ -10139,6 +10186,11 @@ var deriveExecutionOrderGroups = ({
10139
10186
  });
10140
10187
  const completedAmountLabel = tradeSide === "buy" ? formatUsd(actualFill.amount) : labels.executionShares(formatTokenAmount(fill.venueQty));
10141
10188
  const completedPriceLabel = getTradingRoutePriceLabel(actualFill.price);
10189
+ const partialFillLabel = labels.orderPartiallyFilledAtPriceWithAmount(
10190
+ venueLabel,
10191
+ completedPriceLabel,
10192
+ completedAmountLabel
10193
+ );
10142
10194
  const setupRawSteps = rawExecutionSteps.filter(
10143
10195
  (step) => setupCosts.some((setupCost) => isSetupRawStep(step, setupCost))
10144
10196
  );
@@ -10150,7 +10202,7 @@ var deriveExecutionOrderGroups = ({
10150
10202
  steps: bridgeRawSteps,
10151
10203
  nextPhaseStarted: hasVenueExecutionProgress || hasSuccessfulTerminalEvent
10152
10204
  });
10153
- const executionStatus = forceCompleted || hasSuccessfulTerminalEvent ? "done" : resolveRawPhaseStatus({ steps: venueRawSteps });
10205
+ const executionStatus = hasPartialTerminalEvent ? "warning" : forceCompleted || hasSuccessfulTerminalEvent ? "done" : resolveRawPhaseStatus({ steps: venueRawSteps });
10154
10206
  const groupId = `${normalizeIdentity(fill.venue) || "venue"}-${fillIndex}`;
10155
10207
  const steps = [
10156
10208
  {
@@ -10182,8 +10234,8 @@ var deriveExecutionOrderGroups = ({
10182
10234
  {
10183
10235
  id: `${groupId}-execute`,
10184
10236
  kind: "fill",
10185
- pendingLabel: labels.fillingOnVenue(venueLabel),
10186
- completedLabel: labels.venueFilledAtPriceWithAmount(
10237
+ pendingLabel: hasPartialTerminalEvent ? partialFillLabel : labels.fillingOnVenue(venueLabel),
10238
+ completedLabel: hasPartialTerminalEvent ? partialFillLabel : labels.venueFilledAtPriceWithAmount(
10187
10239
  venueLabel,
10188
10240
  completedAmountLabel,
10189
10241
  completedPriceLabel
@@ -10200,7 +10252,92 @@ var deriveExecutionOrderGroups = ({
10200
10252
  steps
10201
10253
  };
10202
10254
  });
10203
- return deriveSequentialDisplayGroups(realGroups);
10255
+ return deriveSequentialDisplayGroups(
10256
+ realGroups,
10257
+ terminalOrderEvents.length >= quoteData.fills.length && quoteData.fills.length > 0
10258
+ );
10259
+ };
10260
+ var EXECUTION_MILESTONE_WEIGHTS = {
10261
+ submit: 20,
10262
+ setup: 20,
10263
+ bridge: 20,
10264
+ fill: 40
10265
+ };
10266
+ var COMPLETED_MILESTONE_GROUP_STATUSES = /* @__PURE__ */ new Set([
10267
+ "completed",
10268
+ "skipped"
10269
+ ]);
10270
+ var TERMINAL_EXECUTION_GROUP_STATUSES = /* @__PURE__ */ new Set([
10271
+ "completed",
10272
+ "failed",
10273
+ "skipped"
10274
+ ]);
10275
+ var uniqueGroupsForOrderAndKind = ({
10276
+ kind,
10277
+ orderId,
10278
+ steps
10279
+ }) => {
10280
+ var _a;
10281
+ const groups = /* @__PURE__ */ new Map();
10282
+ for (const step of steps) {
10283
+ if (step.kind !== kind || !((_a = step.orderIds) == null ? void 0 : _a.includes(orderId)) || groups.has(step.groupId))
10284
+ continue;
10285
+ groups.set(step.groupId, step);
10286
+ }
10287
+ return Array.from(groups.values());
10288
+ };
10289
+ var calculateExecutionProgress = ({
10290
+ orderIds,
10291
+ submittedOrderIds = [],
10292
+ executionSteps = [],
10293
+ executionOrders = [],
10294
+ minimumProgress = 0
10295
+ }) => {
10296
+ const resolvedOrderIds = orderIds.length > 0 ? orderIds : executionOrders.map((order) => order.orderId);
10297
+ if (resolvedOrderIds.length === 0) return 0;
10298
+ const submittedIds = new Set(submittedOrderIds);
10299
+ const orderById = new Map(executionOrders.map((order) => [order.orderId, order]));
10300
+ const hasAuthoritativeTopology = executionSteps.some(
10301
+ (step) => {
10302
+ var _a, _b;
10303
+ return step.kind !== "internal" && step.kind !== "submit" && ((_b = (_a = step.orderIds) == null ? void 0 : _a.length) != null ? _b : 0) > 0;
10304
+ }
10305
+ );
10306
+ let progress = 0;
10307
+ for (const orderId of resolvedOrderIds) {
10308
+ const order = orderById.get(orderId);
10309
+ const isOrderTerminal = (order == null ? void 0 : order.event) !== null && (order == null ? void 0 : order.event) !== void 0;
10310
+ const contributionScale = 1 / resolvedOrderIds.length;
10311
+ const submitGroups = uniqueGroupsForOrderAndKind({
10312
+ kind: "submit",
10313
+ orderId,
10314
+ steps: executionSteps
10315
+ });
10316
+ const setupGroups = uniqueGroupsForOrderAndKind({
10317
+ kind: "setup",
10318
+ orderId,
10319
+ steps: executionSteps
10320
+ });
10321
+ const bridgeGroups = uniqueGroupsForOrderAndKind({
10322
+ kind: "bridge",
10323
+ orderId,
10324
+ steps: executionSteps
10325
+ });
10326
+ const fillGroups = uniqueGroupsForOrderAndKind({
10327
+ kind: "fill",
10328
+ orderId,
10329
+ steps: executionSteps
10330
+ });
10331
+ const submissionComplete = isOrderTerminal || submittedIds.has(orderId) || submitGroups.some((step) => COMPLETED_MILESTONE_GROUP_STATUSES.has(step.groupStatus));
10332
+ const fundingComplete = isOrderTerminal || hasAuthoritativeTopology && (setupGroups.length === 0 || setupGroups.every((step) => COMPLETED_MILESTONE_GROUP_STATUSES.has(step.groupStatus)));
10333
+ const bridgingComplete = isOrderTerminal || hasAuthoritativeTopology && (bridgeGroups.length === 0 || bridgeGroups.every((step) => COMPLETED_MILESTONE_GROUP_STATUSES.has(step.groupStatus)));
10334
+ const executionComplete = isOrderTerminal || fillGroups.length > 0 && fillGroups.every((step) => TERMINAL_EXECUTION_GROUP_STATUSES.has(step.groupStatus));
10335
+ if (submissionComplete) progress += EXECUTION_MILESTONE_WEIGHTS.submit * contributionScale;
10336
+ if (fundingComplete) progress += EXECUTION_MILESTONE_WEIGHTS.setup * contributionScale;
10337
+ if (bridgingComplete) progress += EXECUTION_MILESTONE_WEIGHTS.bridge * contributionScale;
10338
+ if (executionComplete) progress += EXECUTION_MILESTONE_WEIGHTS.fill * contributionScale;
10339
+ }
10340
+ return Math.min(100, Math.max(0, minimumProgress, Math.round(progress)));
10204
10341
  };
10205
10342
 
10206
10343
  // src/trading/place-order/index.place-order.execution-view.tsx
@@ -10252,6 +10389,28 @@ var ExecutionStepIndicator = ({
10252
10389
  }
10253
10390
  ) });
10254
10391
  }
10392
+ if (step.status === "failed") {
10393
+ return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
10394
+ Icon,
10395
+ {
10396
+ name: "error-filled",
10397
+ size: "xs",
10398
+ className: "h-3 w-3 shrink-0 text-agg-error",
10399
+ "aria-hidden": "true"
10400
+ }
10401
+ );
10402
+ }
10403
+ if (step.status === "warning") {
10404
+ return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
10405
+ Icon,
10406
+ {
10407
+ name: "warning-filled",
10408
+ size: "xs",
10409
+ className: "h-3 w-3 shrink-0 text-agg-warning",
10410
+ "aria-hidden": "true"
10411
+ }
10412
+ );
10413
+ }
10255
10414
  return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
10256
10415
  "span",
10257
10416
  {
@@ -10315,10 +10474,9 @@ var PlaceOrderExecutionView = ({
10315
10474
  eventImage,
10316
10475
  eventTitle,
10317
10476
  groups,
10318
- labels
10477
+ labels,
10478
+ progress
10319
10479
  }) => {
10320
- const steps = groups.flatMap((group) => group.steps);
10321
- const completedStepCount = steps.filter((step) => step.status === "done").length;
10322
10480
  return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
10323
10481
  Card,
10324
10482
  {
@@ -10339,30 +10497,18 @@ var PlaceOrderExecutionView = ({
10339
10497
  }
10340
10498
  ),
10341
10499
  /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("div", { className: cn("flex flex-col gap-5", classNames == null ? void 0 : classNames.content), children: [
10342
- /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("div", { className: "flex flex-col gap-2", children: [
10343
- /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: labels.executingOrder }),
10500
+ /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("div", { className: "flex items-center gap-3", children: [
10501
+ /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("p", { className: "shrink-0 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: [
10502
+ progress,
10503
+ "%"
10504
+ ] }),
10344
10505
  /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
10345
- "div",
10506
+ "progress",
10346
10507
  {
10347
- role: "progressbar",
10348
10508
  "aria-label": labels.executingOrder,
10349
- "aria-valuemin": 0,
10350
- "aria-valuemax": steps.length,
10351
- "aria-valuenow": completedStepCount,
10352
- className: "flex h-1 w-full gap-0.5",
10353
- children: steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
10354
- "span",
10355
- {
10356
- "data-testid": "execution-progress-segment",
10357
- className: cn(
10358
- "h-1 min-w-0 flex-1 rounded-agg-full",
10359
- step.status === "done" ? "bg-agg-primary" : "bg-agg-separator"
10360
- ),
10361
- "aria-hidden": "true",
10362
- "data-status": step.status
10363
- },
10364
- step.id
10365
- ))
10509
+ 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",
10510
+ max: 100,
10511
+ value: progress
10366
10512
  }
10367
10513
  )
10368
10514
  ] }),
@@ -10425,7 +10571,7 @@ var PlaceOrderFailureView = ({
10425
10571
  onDone,
10426
10572
  onSkip
10427
10573
  }) => {
10428
- var _a, _b, _c;
10574
+ var _a, _b, _c, _d, _e;
10429
10575
  const shouldShowPartialFailureLayout = summary.kind === "partial_fill";
10430
10576
  const failureStepGroups = shouldShowPartialFailureLayout ? groupPlaceOrderFailureSteps(summary.steps) : [];
10431
10577
  if (shouldShowPartialFailureLayout) {
@@ -10444,14 +10590,42 @@ var PlaceOrderFailureView = ({
10444
10590
  ] }),
10445
10591
  summary.eventSubtitle ? /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
10446
10592
  ] }),
10447
- /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("div", { className: "flex flex-col gap-4", children: failureStepGroups.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("div", { className: "flex flex-col gap-2", children: group.map((step) => renderPartialFailureStep(step)) }, `failure-group-${groupIndex}`)) }),
10448
- /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("div", { className: "flex items-center gap-4", children: summary.actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
10593
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("div", { className: "flex flex-col gap-4", children: ((_b = summary.executionGroups) == null ? void 0 : _b.length) ? /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
10594
+ PlaceOrderExecutionGroups,
10595
+ {
10596
+ enableAnimations: false,
10597
+ groups: summary.executionGroups,
10598
+ labels: tradingLabels
10599
+ }
10600
+ ) : failureStepGroups.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("div", { className: "flex flex-col gap-2", children: group.map((step) => renderPartialFailureStep(step)) }, `failure-group-${groupIndex}`)) }),
10601
+ summary.errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
10602
+ InlineAlert,
10603
+ {
10604
+ tone: "error",
10605
+ variant: "surface",
10606
+ message: tradingLabels.orderFailureDescription(summary.errorMessage)
10607
+ }
10608
+ ) : null,
10609
+ summary.result ? /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)("div", { className: "flex flex-col gap-4", children: [
10610
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
10611
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)("div", { className: "flex min-w-0 flex-col", children: [
10612
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.orderPartiallyFilled }),
10613
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("p", { className: "text-agg-sm leading-agg-5 text-agg-muted-foreground", children: tradingLabels.orderAveragePrice(summary.result.averagePriceLabel) })
10614
+ ] }),
10615
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("p", { className: "shrink-0 text-right text-[30px] font-agg-bold leading-[36px] text-agg-foreground", children: summary.result.filledAmountLabel })
10616
+ ] }),
10617
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
10618
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.orderPayout }),
10619
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("p", { className: "shrink-0 text-right text-[30px] font-agg-bold leading-[36px] text-agg-success", children: summary.result.payoutLabel })
10620
+ ] })
10621
+ ] }) : null,
10622
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("div", { className: "flex flex-col gap-4", children: summary.actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
10449
10623
  Button,
10450
10624
  {
10451
- variant: "tertiary",
10625
+ variant: action.variant === "retry" ? "primary" : "secondary",
10452
10626
  size: "medium",
10453
10627
  "aria-label": action.label,
10454
- className: "text-agg-sm! leading-agg-5! text-agg-primary!",
10628
+ className: "w-full",
10455
10629
  onClick: resolveFailureActionHandler({ action, onDone, onRetry, onSkip }),
10456
10630
  children: action.label
10457
10631
  },
@@ -10465,7 +10639,7 @@ var PlaceOrderFailureView = ({
10465
10639
  /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
10466
10640
  RemoteImage,
10467
10641
  {
10468
- src: (_b = summary.eventImage) != null ? _b : null,
10642
+ src: (_c = summary.eventImage) != null ? _c : null,
10469
10643
  alt: "",
10470
10644
  className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
10471
10645
  }
@@ -10474,21 +10648,29 @@ var PlaceOrderFailureView = ({
10474
10648
  ] }),
10475
10649
  summary.eventSubtitle ? /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
10476
10650
  ] }),
10651
+ ((_d = summary.executionGroups) == null ? void 0 : _d.length) ? /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
10652
+ PlaceOrderExecutionGroups,
10653
+ {
10654
+ enableAnimations: false,
10655
+ groups: summary.executionGroups,
10656
+ labels: tradingLabels
10657
+ }
10658
+ ) : null,
10477
10659
  /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
10478
10660
  InlineAlert,
10479
10661
  {
10480
10662
  tone: "error",
10481
10663
  variant: "surface",
10482
10664
  title: tradingLabels.orderFailureTitle,
10483
- message: tradingLabels.orderFailureDescription((_c = summary.errorMessage) != null ? _c : "")
10665
+ message: tradingLabels.orderFailureDescription((_e = summary.errorMessage) != null ? _e : "")
10484
10666
  }
10485
10667
  ),
10486
- /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("div", { className: "agg-order-failure-actions flex items-center gap-3", children: summary.actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
10668
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("div", { className: "agg-order-failure-actions flex flex-col gap-4", children: summary.actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
10487
10669
  Button,
10488
10670
  {
10489
10671
  variant: action.variant === "retry" ? "primary" : "secondary",
10490
10672
  size: "medium",
10491
- className: "flex-1",
10673
+ className: "w-full",
10492
10674
  "aria-label": action.label,
10493
10675
  onClick: resolveFailureActionHandler({ action, onDone, onRetry, onSkip }),
10494
10676
  children: action.label
@@ -10512,7 +10694,7 @@ var PlaceOrderSuccessView = ({
10512
10694
  onDone,
10513
10695
  onShare: _onShare
10514
10696
  }) => {
10515
- var _a, _b, _c, _d, _e, _f;
10697
+ var _a, _b, _c, _d, _e;
10516
10698
  const resolvedTradeSide = (_a = summary.tradeSide) != null ? _a : "buy";
10517
10699
  const resolvedAmountLabel = (_b = summary.amountLabel) != null ? _b : resolvedTradeSide === "sell" ? summary.shares : summary.estimatedCost;
10518
10700
  const resolvedPayoutLabel = (_c = summary.toWinLabel) != null ? _c : resolvedTradeSide === "sell" ? summary.estimatedCost : resolveBuyPayoutLabel(summary.shares);
@@ -10565,15 +10747,11 @@ var PlaceOrderSuccessView = ({
10565
10747
  },
10566
10748
  step.id
10567
10749
  )) }) : null,
10568
- /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("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: [
10569
- /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(Icon, { name: "success-check", size: "xs", className: "h-3 w-3 shrink-0 text-current" }),
10570
- /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("span", { children: (_f = summary.actionLabel) != null ? _f : tradingLabels.orderSuccessTitle })
10571
- ] }),
10572
10750
  /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("div", { className: "agg-order-success-summary flex flex-col gap-4", children: [
10573
10751
  /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
10574
10752
  /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("div", { className: "flex min-w-0 flex-col", children: [
10575
- /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("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) }),
10576
- summary.requestedAmountLabel ? /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("p", { className: "text-agg-sm leading-agg-5 text-agg-muted-foreground", children: tradingLabels.orderAmountFilledOf(summary.requestedAmountLabel) }) : null
10753
+ /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: summary.resultState === "partial" ? tradingLabels.orderPartiallyFilled : tradingLabels.orderFullyFilled }),
10754
+ /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("p", { className: "text-agg-sm leading-agg-5 text-agg-muted-foreground", children: tradingLabels.orderAveragePrice(summary.avgPrice) })
10577
10755
  ] }),
10578
10756
  /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("p", { className: "shrink-0 text-right text-[30px] font-agg-bold leading-[36px] text-agg-foreground", children: resolvedAmountLabel })
10579
10757
  ] }),
@@ -10991,13 +11169,14 @@ var PlaceOrderResolvedView = ({
10991
11169
  resolutionTimestamp,
10992
11170
  resolvedClaim,
10993
11171
  className,
10994
- isSportsEvent = false
11172
+ isSportsEvent = false,
11173
+ showResolvingState = false
10995
11174
  }) => {
10996
11175
  var _a, _b;
10997
11176
  const labels = (0, import_hooks38.useLabels)();
10998
11177
  const tradingLabels = labels.trading;
10999
11178
  const resolvingTimestamp = (_a = resolutionTimestamp != null ? resolutionTimestamp : tradingState.resolvesAt) != null ? _a : tradingState.endsAt;
11000
- const isResolvingMarket = false;
11179
+ const isResolvingMarket = showResolvingState && !tradingState.winningOutcome;
11001
11180
  const resolvingSubtitle = tradingState.market ? (() => {
11002
11181
  const endDateLabel = isSportsEvent ? formatSportsEventTimeEt(resolvingTimestamp != null ? resolvingTimestamp : "") : getTradingDateLabel(resolvingTimestamp != null ? resolvingTimestamp : "");
11003
11182
  return endDateLabel ? `${tradingState.market.question} \xB7 ${endDateLabel}` : tradingState.market.question;
@@ -11277,6 +11456,7 @@ var PlaceOrder = ({
11277
11456
  onError,
11278
11457
  onExecutionStateChange,
11279
11458
  resolvedClaim,
11459
+ showResolvingState = false,
11280
11460
  midpointsResult
11281
11461
  }) => {
11282
11462
  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;
@@ -11340,7 +11520,7 @@ var PlaceOrder = ({
11340
11520
  const resolvedReadOnlyTradingState = (0, import_react15.useMemo)(() => {
11341
11521
  return (0, import_hooks38.resolveMarketTradingState)(resolvedReadOnlyMarket);
11342
11522
  }, [resolvedReadOnlyMarket]);
11343
- const isEndedWithoutKnownWinner = false;
11523
+ const isEndedWithoutKnownWinner = showResolvingState && !resolvedEventTradingState.winningOutcome && !resolvedReadOnlyTradingState.winningOutcome;
11344
11524
  const orderEligibility = (0, import_react15.useMemo)(
11345
11525
  () => (0, import_hooks38.resolveOrderEligibility)({
11346
11526
  event: scopedSelectedEvent,
@@ -11976,6 +12156,10 @@ var PlaceOrder = ({
11976
12156
  mode: isPaperMode ? "paper" : void 0,
11977
12157
  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)
11978
12158
  });
12159
+ const executionProgressFloorRef = (0, import_react15.useRef)({
12160
+ quoteId: null,
12161
+ value: 0
12162
+ });
11979
12163
  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 : "";
11980
12164
  const headerImage = (_S = (_R = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.image) != null ? _R : scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.image) != null ? _S : null;
11981
12165
  const headerTitle = (_U = (_T = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _T : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _U : "";
@@ -12006,6 +12190,26 @@ var PlaceOrder = ({
12006
12190
  (_Z = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _Z.length,
12007
12191
  tradingLabels
12008
12192
  ]);
12193
+ const executionProgressPercent = (0, import_react15.useMemo)(() => {
12194
+ var _a2, _b2, _c2;
12195
+ const quoteId = (_a2 = submissionProgressState == null ? void 0 : submissionProgressState.quoteId) != null ? _a2 : null;
12196
+ const previousProgress = executionProgressFloorRef.current.quoteId === quoteId ? executionProgressFloorRef.current.value : 0;
12197
+ const nextProgress = calculateExecutionProgress({
12198
+ orderIds: (_b2 = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) != null ? _b2 : [],
12199
+ submittedOrderIds: executionProgress.submittedOrders.map((order) => order.orderId),
12200
+ executionSteps: executionProgress.executionSteps,
12201
+ executionOrders: (_c2 = executionProgress.executionOrders) != null ? _c2 : [],
12202
+ minimumProgress: previousProgress
12203
+ });
12204
+ executionProgressFloorRef.current = { quoteId, value: nextProgress };
12205
+ return nextProgress;
12206
+ }, [
12207
+ executionProgress.executionOrders,
12208
+ executionProgress.executionSteps,
12209
+ executionProgress.submittedOrders,
12210
+ submissionProgressState == null ? void 0 : submissionProgressState.orderIds,
12211
+ submissionProgressState == null ? void 0 : submissionProgressState.quoteId
12212
+ ]);
12009
12213
  const buildExecutionSummary = (0, import_react15.useCallback)(
12010
12214
  (quoteData, executionVenue, orderId, partialFillSummary) => {
12011
12215
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2;
@@ -12034,6 +12238,7 @@ var PlaceOrder = ({
12034
12238
  const eventTitle = (_f2 = (_e2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _e2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _f2 : "";
12035
12239
  const eventDateSource = (_g2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.endDate) != null ? _g2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.endDate;
12036
12240
  return {
12241
+ resultState: partialFillSummary ? "partial" : "success",
12037
12242
  tradeSide: internalTab,
12038
12243
  shares: sharesLabel,
12039
12244
  avgPrice: avgPriceLabel,
@@ -12374,31 +12579,30 @@ var PlaceOrder = ({
12374
12579
  });
12375
12580
  }, [isSell, orderedRouteCards.length, smartRoute.error, tradingLabels, venueSellQuotes.error]);
12376
12581
  const progressActionLabel = (internalTab === "buy" ? tradingLabels.buyingOutcome(selectedOutcomeLabel) : tradingLabels.sellingOutcome(selectedOutcomeLabel)).trim();
12377
- const canRetryRemaining = (0, import_react15.useMemo)(() => {
12378
- const remaining = getPlaceOrderUnfilledRemaining({
12582
+ const retryRemainingAmount = (0, import_react15.useMemo)(() => {
12583
+ return getCanonicalPlaceOrderUnfilledRemaining({
12379
12584
  originalAmount: internalAmount,
12380
12585
  tradeSide: internalTab,
12381
12586
  terminalOrderEvents: executionProgress.terminalOrderEvents
12382
12587
  });
12588
+ }, [executionProgress.terminalOrderEvents, internalAmount, internalTab]);
12589
+ const canRetryRemaining = (0, import_react15.useMemo)(() => {
12590
+ if (retryRemainingAmount == null) return false;
12383
12591
  const minRemainder = isSell ? MIN_SELL_ORDER_SHARES : MIN_BUY_ORDER_AMOUNT;
12384
- return remaining >= minRemainder;
12385
- }, [executionProgress.terminalOrderEvents, internalAmount, internalTab, isSell]);
12592
+ return retryRemainingAmount >= minRemainder;
12593
+ }, [isSell, retryRemainingAmount]);
12386
12594
  const PARTIAL_FILL_AUTO_SUCCESS_THRESHOLD = 0.95;
12387
12595
  const shouldAutoSkipPartialFill = (0, import_react15.useMemo)(() => {
12388
- if (internalAmount <= 0) return false;
12389
- const remaining = getPlaceOrderUnfilledRemaining({
12390
- originalAmount: internalAmount,
12391
- tradeSide: internalTab,
12392
- terminalOrderEvents: executionProgress.terminalOrderEvents
12393
- });
12394
- const filled = Math.max(0, internalAmount - remaining);
12596
+ if (internalAmount <= 0 || retryRemainingAmount == null) return false;
12597
+ const filled = Math.max(0, internalAmount - retryRemainingAmount);
12395
12598
  const fillRatio = filled / internalAmount;
12396
12599
  return fillRatio >= PARTIAL_FILL_AUTO_SUCCESS_THRESHOLD || !canRetryRemaining;
12397
- }, [canRetryRemaining, executionProgress.terminalOrderEvents, internalAmount, internalTab]);
12600
+ }, [canRetryRemaining, internalAmount, retryRemainingAmount]);
12398
12601
  const failureSummary = (0, import_react15.useMemo)(() => {
12399
12602
  var _a2;
12400
12603
  if ((submissionProgressState == null ? void 0 : submissionProgressState.phase) !== "failed") return void 0;
12401
- return buildPlaceOrderFailureSummary({
12604
+ const quoteData = (_a2 = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _a2 : activeQuoteData;
12605
+ const baseSummary = buildPlaceOrderFailureSummary({
12402
12606
  actionLabel: progressActionLabel,
12403
12607
  canRetryRemaining,
12404
12608
  errorMessage: submissionProgressState.errorMessage,
@@ -12407,19 +12611,53 @@ var PlaceOrder = ({
12407
12611
  eventTitle: headerTitle || tradingLabels.orderFailureTitle,
12408
12612
  labels: tradingLabels,
12409
12613
  orderId: submissionProgressState.orderId,
12410
- quoteData: (_a2 = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _a2 : activeQuoteData,
12614
+ quoteData,
12411
12615
  submittedOrders: executionProgress.submittedOrders,
12412
12616
  terminalOrderEvents: executionProgress.terminalOrderEvents
12413
12617
  });
12618
+ const summaryWithGroups = __spreadValues(__spreadValues({}, baseSummary), executionOrderGroups.length > 0 ? { executionGroups: executionOrderGroups } : {});
12619
+ if (baseSummary.kind !== "partial_fill") return summaryWithGroups;
12620
+ const actualEconomics = resolveActualExecutionEconomics({
12621
+ quoteData,
12622
+ tradeSide: internalTab,
12623
+ terminalOrderEvents: executionProgress.terminalOrderEvents,
12624
+ submittedOrders: executionProgress.submittedOrders
12625
+ });
12626
+ if (!actualEconomics.hasActualFillData) return summaryWithGroups;
12627
+ if (retryRemainingAmount == null) return summaryWithGroups;
12628
+ const remaining = retryRemainingAmount;
12629
+ const remainingLabel = isSell ? tradingLabels.executionShares(
12630
+ remaining.toLocaleString("en-US", { maximumFractionDigits: 2 })
12631
+ ) : formatUsd(remaining);
12632
+ const filledAmountLabel = isSell ? tradingLabels.executionShares(
12633
+ actualEconomics.actualTotalFilled.toLocaleString("en-US", {
12634
+ maximumFractionDigits: 2
12635
+ })
12636
+ ) : formatUsd(actualEconomics.actualRawExecCost);
12637
+ const payoutLabel = isSell ? formatUsd(actualEconomics.actualRawExecCost) : formatUsd(actualEconomics.actualTotalFilled);
12638
+ return __spreadProps(__spreadValues({}, summaryWithGroups), {
12639
+ actions: summaryWithGroups.actions.map(
12640
+ (action) => action.variant === "retry" ? __spreadProps(__spreadValues({}, action), { label: tradingLabels.orderTryRemaining(remainingLabel) }) : action
12641
+ ),
12642
+ result: {
12643
+ averagePriceLabel: getTradingRoutePriceLabel(actualEconomics.avgExecutionPrice),
12644
+ filledAmountLabel,
12645
+ payoutLabel
12646
+ }
12647
+ });
12414
12648
  }, [
12415
12649
  activeQuoteData,
12416
12650
  canRetryRemaining,
12651
+ executionOrderGroups,
12417
12652
  executionProgress.submittedOrders,
12418
12653
  executionProgress.terminalOrderEvents,
12419
12654
  headerImage,
12420
12655
  headerSubtitle,
12421
12656
  headerTitle,
12657
+ internalTab,
12658
+ isSell,
12422
12659
  progressActionLabel,
12660
+ retryRemainingAmount,
12423
12661
  selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData,
12424
12662
  submissionProgressState,
12425
12663
  tradingLabels
@@ -12943,7 +13181,7 @@ var PlaceOrder = ({
12943
13181
  if (!shouldAutoSkipPartialFill) return;
12944
13182
  handleSkipToSuccess();
12945
13183
  }, [
12946
- failureSummary == null ? void 0 : failureSummary.kind,
13184
+ failureSummary,
12947
13185
  handleSkipToSuccess,
12948
13186
  shouldAutoSkipPartialFill,
12949
13187
  submissionProgressState == null ? void 0 : submissionProgressState.phase
@@ -12957,12 +13195,8 @@ var PlaceOrder = ({
12957
13195
  setSubmissionFeedback(null);
12958
13196
  let retryAmount = internalAmount;
12959
13197
  let useRemainderRoute = false;
12960
- if ((failureSummary == null ? void 0 : failureSummary.kind) === "partial_fill" && internalAmount > 0) {
12961
- const remaining = getPlaceOrderUnfilledRemaining({
12962
- originalAmount: internalAmount,
12963
- tradeSide: internalTab,
12964
- terminalOrderEvents: executionProgress.terminalOrderEvents
12965
- });
13198
+ if ((failureSummary == null ? void 0 : failureSummary.kind) === "partial_fill" && internalAmount > 0 && retryRemainingAmount != null) {
13199
+ const remaining = retryRemainingAmount;
12966
13200
  if (remaining > 0) {
12967
13201
  retryAmount = remaining;
12968
13202
  useRemainderRoute = true;
@@ -13082,8 +13316,7 @@ var PlaceOrder = ({
13082
13316
  }), [
13083
13317
  aggClient,
13084
13318
  chainBalancesOverride,
13085
- executionProgress.terminalOrderEvents,
13086
- failureSummary == null ? void 0 : failureSummary.kind,
13319
+ failureSummary,
13087
13320
  handleExecuteQuote,
13088
13321
  handleReturnToOrderForm,
13089
13322
  internalAmount,
@@ -13093,6 +13326,7 @@ var PlaceOrder = ({
13093
13326
  onAmountChange,
13094
13327
  orderEligibility.canPlaceOrder,
13095
13328
  orderedRouteCards,
13329
+ retryRemainingAmount,
13096
13330
  scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.venueMarkets,
13097
13331
  scopedSelectedOutcomeId,
13098
13332
  selectedRouteCardId,
@@ -13148,7 +13382,8 @@ var PlaceOrder = ({
13148
13382
  eventImage: headerImage,
13149
13383
  eventTitle: headerTitle,
13150
13384
  groups: executionOrderGroups,
13151
- labels: tradingLabels
13385
+ labels: tradingLabels,
13386
+ progress: executionProgressPercent
13152
13387
  }
13153
13388
  );
13154
13389
  }
@@ -13363,7 +13598,8 @@ var PlaceOrder = ({
13363
13598
  resolvedClaim,
13364
13599
  classNames,
13365
13600
  className,
13366
- isSportsEvent: (scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.structureType) === "sport" && !!(scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.sport) && scopedSelectedEvent.sport !== "other_sport"
13601
+ isSportsEvent: (scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.structureType) === "sport" && !!(scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.sport) && scopedSelectedEvent.sport !== "other_sport",
13602
+ showResolvingState
13367
13603
  }
13368
13604
  );
13369
13605
  }
@@ -14432,7 +14668,7 @@ function useResolvedMarketClaim(options = {}) {
14432
14668
  });
14433
14669
  } : void 0
14434
14670
  };
14435
- }, [claimWinnings, marketId, positions, shouldFetch]);
14671
+ }, [claimWinnings, market, marketId, positions, shouldFetch]);
14436
14672
  }
14437
14673
  // Annotate the CommonJS export names for ESM import in node:
14438
14674
  0 && (module.exports = {