@agg-build/ui 1.2.6 → 1.2.8

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 (32) hide show
  1. package/dist/{chunk-2HI6K7JF.mjs → chunk-2YVW6J5N.mjs} +12 -6
  2. package/dist/{chunk-5FXMHTVR.mjs → chunk-BW4DQYWM.mjs} +1 -1
  3. package/dist/{chunk-34L7ZKJW.mjs → chunk-HQRT3B3L.mjs} +3 -2
  4. package/dist/{chunk-WPF47BQQ.mjs → chunk-IIEE4FVO.mjs} +9 -2
  5. package/dist/{chunk-TBKDLNOE.mjs → chunk-RPIYL7EA.mjs} +29 -8
  6. package/dist/{chunk-E45WOOMN.mjs → chunk-SMGKYWEP.mjs} +22 -8
  7. package/dist/{chunk-FS3FGVAG.mjs → chunk-U6YU5OE7.mjs} +671 -152
  8. package/dist/events.js +51 -15
  9. package/dist/events.mjs +3 -3
  10. package/dist/index.js +771 -196
  11. package/dist/index.mjs +27 -20
  12. package/dist/modals.js +8 -1
  13. package/dist/modals.mjs +3 -3
  14. package/dist/pages.js +735 -174
  15. package/dist/pages.mjs +6 -6
  16. package/dist/primitives.js +3 -2
  17. package/dist/primitives.mjs +1 -1
  18. package/dist/styles.css +1 -1
  19. package/dist/tailwind.css +1 -1
  20. package/dist/trading.js +670 -150
  21. package/dist/trading.mjs +4 -4
  22. package/dist/types/primitives/switch-button/switch-button.constants.d.mts +1 -1
  23. package/dist/types/primitives/switch-button/switch-button.constants.d.ts +1 -1
  24. package/dist/types/primitives/tooltip/index.d.mts +1 -1
  25. package/dist/types/primitives/tooltip/index.d.ts +1 -1
  26. package/dist/types/primitives/tooltip/tooltip.types.d.mts +2 -0
  27. package/dist/types/primitives/tooltip/tooltip.types.d.ts +2 -0
  28. package/dist/types/trading/place-order/index.place-order.execution-debug.d.mts +183 -0
  29. package/dist/types/trading/place-order/index.place-order.execution-debug.d.ts +183 -0
  30. package/dist/types/trading/place-order/index.place-order.execution-steps.d.mts +72 -0
  31. package/dist/types/trading/place-order/index.place-order.execution-steps.d.ts +72 -0
  32. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3688,7 +3688,7 @@ var SWITCH_BUTTON_ANIMATION_DURATION_MS = 350;
3688
3688
  var SWITCH_BUTTON_CONTAINER_CLASS_NAME = "group/agg-switch-button min-w-fit inline-flex min-w-0 rounded-agg-full bg-agg-secondary-hover font-agg-sans cursor-pointer hover:bg-agg-tertiary";
3689
3689
  var SWITCH_BUTTON_TRACK_CLASS_NAME = "agg-switch-button-track relative grid min-w-0 flex-1 items-center";
3690
3690
  var SWITCH_BUTTON_TRACK_HIGHLIGHT_CLASS_NAME = "pointer-events-none absolute inset-y-0 left-0 rounded-agg-full border border-agg-primary bg-agg-secondary";
3691
- var SWITCH_BUTTON_OPTION_BASE_CLASS_NAME = "agg-switch-button-option whitespace-nowrap relative z-10 min-w-0 rounded-agg-full px-5 py-1.5 font-agg-sans text-agg-base leading-agg-6 text-agg-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary-hover cursor-pointer disabled:cursor-not-allowed disabled:text-agg-muted-foreground";
3691
+ var SWITCH_BUTTON_OPTION_BASE_CLASS_NAME = "agg-switch-button-option whitespace-nowrap relative z-10 min-w-0 rounded-agg-full px-5 py-1.5 font-agg-sans text-agg-sm leading-agg-5 md:text-agg-base md:leading-agg-6 text-agg-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary-hover cursor-pointer disabled:cursor-not-allowed disabled:text-agg-muted-foreground";
3692
3692
 
3693
3693
  // src/primitives/switch-button/switch-button.utils.ts
3694
3694
  var resolveActiveIndex = (options, value) => {
@@ -9193,6 +9193,7 @@ var Tooltip = ({
9193
9193
  side = "top",
9194
9194
  delayDuration = 150,
9195
9195
  collisionPadding = 12,
9196
+ sideOffset = 0,
9196
9197
  classNames,
9197
9198
  "aria-label": ariaLabel
9198
9199
  }) => {
@@ -9220,7 +9221,7 @@ var Tooltip = ({
9220
9221
  TooltipPrimitive.Content,
9221
9222
  {
9222
9223
  side,
9223
- sideOffset: 0,
9224
+ sideOffset,
9224
9225
  collisionPadding,
9225
9226
  className: cn(
9226
9227
  "group/agg-tooltip",
@@ -9737,7 +9738,14 @@ var AuthConnectButtonView = ({
9737
9738
  ConditionalWrapper,
9738
9739
  {
9739
9740
  condition: isDepositBlocked,
9740
- wrapper: (children) => /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(Tooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("p", { className: "text-center", children: labels.auth.depositGeoBlocked }), children }),
9741
+ wrapper: (children) => /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
9742
+ Tooltip,
9743
+ {
9744
+ content: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("p", { className: "text-center", children: labels.auth.depositGeoBlocked }),
9745
+ sideOffset: 4,
9746
+ children
9747
+ }
9748
+ ),
9741
9749
  children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
9742
9750
  Button,
9743
9751
  __spreadProps(__spreadValues({
@@ -9953,23 +9961,23 @@ var AuthConnectButtonView = ({
9953
9961
  }
9954
9962
  ),
9955
9963
  isDepositBlocked ? /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
9956
- Tooltip,
9964
+ DropdownMenu.Item,
9957
9965
  {
9958
- content: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("p", { className: "text-center", children: labels.auth.depositGeoBlocked }),
9959
- children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("span", { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)(
9960
- DropdownMenu.Item,
9966
+ className: cn(dropdownMenuItemClassName, "opacity-50 cursor-not-allowed!"),
9967
+ onSelect: (e) => e.preventDefault(),
9968
+ "aria-disabled": "true",
9969
+ children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
9970
+ Tooltip,
9961
9971
  {
9962
- className: cn(
9963
- dropdownMenuItemClassName,
9964
- "opacity-50 pointer-events-none"
9965
- ),
9966
- disabled: true,
9967
- children: [
9972
+ content: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("p", { className: "text-center", children: labels.auth.depositGeoBlocked }),
9973
+ side: "bottom",
9974
+ sideOffset: 4,
9975
+ children: /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)("span", { className: "inline-flex items-center gap-3", children: [
9968
9976
  /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(Icon, { name: "download", size: "small", className: "text-agg-foreground" }),
9969
9977
  /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("span", { children: labels.auth.deposit })
9970
- ]
9978
+ ] })
9971
9979
  }
9972
- ) })
9980
+ )
9973
9981
  }
9974
9982
  ) : /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)(
9975
9983
  DropdownMenu.Item,
@@ -10914,6 +10922,18 @@ var marketChartCandleToScaledCandlePoint = (candle, transformProbability) => {
10914
10922
  v: candle.volume
10915
10923
  };
10916
10924
  };
10925
+ var venueCandlesToLinePoints = (venueData, transformProbability) => {
10926
+ const candles = venueData.liveCandle && !venueData.candles.some((candle) => {
10927
+ var _a;
10928
+ return candle.time === ((_a = venueData.liveCandle) == null ? void 0 : _a.time);
10929
+ }) ? [...venueData.candles, venueData.liveCandle] : venueData.liveCandle ? venueData.candles.map(
10930
+ (candle) => {
10931
+ var _a;
10932
+ return candle.time === ((_a = venueData.liveCandle) == null ? void 0 : _a.time) ? venueData.liveCandle : candle;
10933
+ }
10934
+ ) : venueData.candles;
10935
+ return candles.map((candle) => marketChartCandleToLineChartPoint(candle, transformProbability));
10936
+ };
10917
10937
  var resolveMarketChartVenueSeries = ({
10918
10938
  chartData,
10919
10939
  transformProbability
@@ -10921,9 +10941,7 @@ var resolveMarketChartVenueSeries = ({
10921
10941
  if (!chartData) return [];
10922
10942
  return Object.entries(chartData.venues).map(([venue, venueData]) => ({
10923
10943
  venue,
10924
- points: venueData.candles.map(
10925
- (candle) => marketChartCandleToLineChartPoint(candle, transformProbability)
10926
- )
10944
+ points: venueCandlesToLinePoints(venueData, transformProbability)
10927
10945
  })).filter((item) => item.points.length > 0);
10928
10946
  };
10929
10947
  var resolveAggregatedCandleSource = (candles) => {
@@ -10976,13 +10994,24 @@ var resolveMarketChartDisplaySeries = ({
10976
10994
  if (selectedVenue) {
10977
10995
  return venueEntries.map(([venue, venueData]) => ({
10978
10996
  venue,
10979
- points: venueData.candles.map(
10980
- (candle) => marketChartCandleToLineChartPoint(candle, transformProbability)
10981
- )
10997
+ points: venueCandlesToLinePoints(venueData, transformProbability)
10982
10998
  })).filter((item) => item.points.length > 0);
10983
10999
  }
10984
11000
  const aggregatedCandles = aggregateMarketChartCandles(
10985
- venueEntries.flatMap(([, venueData]) => venueData.candles)
11001
+ venueEntries.flatMap(([, venueData]) => {
11002
+ const closed = venueData.candles;
11003
+ if (!venueData.liveCandle) return closed;
11004
+ const hasOverlap = closed.some((candle) => {
11005
+ var _a;
11006
+ return candle.time === ((_a = venueData.liveCandle) == null ? void 0 : _a.time);
11007
+ });
11008
+ return hasOverlap ? closed.map(
11009
+ (candle) => {
11010
+ var _a;
11011
+ return candle.time === ((_a = venueData.liveCandle) == null ? void 0 : _a.time) ? venueData.liveCandle : candle;
11012
+ }
11013
+ ) : [...closed, venueData.liveCandle];
11014
+ })
10986
11015
  );
10987
11016
  if (aggregatedCandles.length === 0) return [];
10988
11017
  return [
@@ -12861,7 +12890,9 @@ var EventListItemDetailsGraphSection = ({
12861
12890
  }
12862
12891
  ),
12863
12892
  classNames: {
12864
- root: cn("h-9 shrink-0 border px-4 text-agg-base leading-agg-6")
12893
+ root: cn(
12894
+ "shrink-0 border px-4 h-8 text-agg-sm leading-agg-5 md:h-9 md:text-agg-base md:leading-agg-6"
12895
+ )
12865
12896
  },
12866
12897
  isActive: isActiveVenue
12867
12898
  }
@@ -13542,8 +13573,20 @@ var OrderbookRow = ({
13542
13573
  }).map(([venue]) => venue);
13543
13574
  const venues = entry.row.venues && entry.row.venues.length > 0 ? entry.row.venues : venuesFromBreakdown.length > 0 ? venuesFromBreakdown : [entry.row.venue];
13544
13575
  const barPercent = Math.max(2, Number((entry.unifiedBarScale * 100).toFixed(2)));
13545
- return /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("div", { className: "agg-orderbook-row relative flex h-9 items-center gap-2.5 overflow-clip md:gap-10 pr-2.5 md:pr-5", children: [
13546
- /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("div", { className: "md:relative min-w-0 flex-1 self-stretch", children: [
13576
+ return /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("div", { className: "agg-orderbook-row relative flex h-9 items-center gap-2.5 overflow-clip pl-5 pr-2.5 md:gap-10 md:pl-0 md:pr-5", children: [
13577
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
13578
+ "div",
13579
+ {
13580
+ "aria-hidden": "true",
13581
+ className: cn(
13582
+ "agg-orderbook-bar md:hidden absolute inset-y-0 left-0",
13583
+ barClassName,
13584
+ getMotionClassName(enableAnimations, "transition-[width] duration-200 ease-in-out")
13585
+ ),
13586
+ style: { width: `${barPercent}%` }
13587
+ }
13588
+ ),
13589
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("div", { className: "hidden md:block md:relative min-w-0 flex-1 self-stretch", children: [
13547
13590
  /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
13548
13591
  "div",
13549
13592
  {
@@ -13646,8 +13689,8 @@ var Orderbook = ({
13646
13689
  spreadEntry
13647
13690
  ]);
13648
13691
  return /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("div", { className: cn("agg-orderbook-unified flex flex-col", className), children: [
13649
- /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("div", { className: "flex h-9 items-center gap-2.5 overflow-clip border-b border-agg-separator pr-5 md:gap-10", children: [
13650
- /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("span", { className: "flex min-w-0 flex-1 items-center gap-2 pl-5", children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("span", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground", children: labels.tradeOutcome }) }),
13692
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("div", { className: "flex h-9 items-center gap-2.5 overflow-clip border-b border-agg-separator pl-5 pr-5 md:pl-0 md:gap-10", children: [
13693
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("span", { className: "hidden md:flex min-w-0 flex-1 items-center gap-2 pl-5", children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("span", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground", children: labels.tradeOutcome }) }),
13651
13694
  /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("span", { className: "w-20 shrink-0 text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground md:w-[120px]", children: labels.price }),
13652
13695
  /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("span", { className: "w-20 shrink-0 text-center text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground md:w-[120px]", children: labels.shares }),
13653
13696
  /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("span", { className: "w-20 shrink-0 text-center text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground md:w-[120px]", children: labels.total })
@@ -14482,7 +14525,7 @@ var MarketDetailsContent = ({
14482
14525
  "span",
14483
14526
  {
14484
14527
  className: cn(
14485
- "min-w-35 inline-flex h-9 items-center justify-center gap-2 rounded-agg-full",
14528
+ "w-full md:w-auto md:min-w-35 inline-flex h-9 items-center justify-center gap-2 rounded-agg-full",
14486
14529
  "border px-5 py-1.5 text-agg-sm font-agg-bold",
14487
14530
  getMotionClassName(
14488
14531
  enableAnimations,
@@ -15446,7 +15489,7 @@ EventList.displayName = "EventList";
15446
15489
 
15447
15490
  // src/pages/home/index.tsx
15448
15491
  var import_hooks55 = require("@agg-build/hooks");
15449
- var import_sdk17 = require("@agg-build/sdk");
15492
+ var import_sdk18 = require("@agg-build/sdk");
15450
15493
  var import_react35 = require("react");
15451
15494
 
15452
15495
  // src/pages/event-market/index.tsx
@@ -15664,6 +15707,447 @@ var PLACE_ORDER_OUTCOME_BUTTON_CLASS_NAMES = {
15664
15707
  inactive: "border-transparent bg-agg-secondary-hover font-agg-normal text-agg-foreground hover:bg-agg-tertiary"
15665
15708
  };
15666
15709
 
15710
+ // src/trading/place-order/index.place-order.execution-steps.ts
15711
+ var import_sdk17 = require("@agg-build/sdk");
15712
+ var WAIT_STEP_TYPES = /* @__PURE__ */ new Set(["_wait", "wait"]);
15713
+ var CHECKING_BALANCE_STEP_TYPES = /* @__PURE__ */ new Set([
15714
+ "check-balance",
15715
+ "check-position",
15716
+ "position-reserve",
15717
+ "position-release"
15718
+ ]);
15719
+ var VENUE_BUY_SELL_REGEX = /^(?:buy|sell)-([a-z]+)$/;
15720
+ var VENUE_FINALIZE_REGEX = /^([a-z]+)-finalize$/;
15721
+ var VENUE_NAME_MAP = {
15722
+ kalshi: import_sdk17.Venue.kalshi,
15723
+ polymarket: import_sdk17.Venue.polymarket,
15724
+ limitless: import_sdk17.Venue.limitless,
15725
+ opinion: import_sdk17.Venue.opinion,
15726
+ predict: import_sdk17.Venue.predict,
15727
+ probable: import_sdk17.Venue.probable,
15728
+ myriad: import_sdk17.Venue.myriad,
15729
+ hyperliquid: import_sdk17.Venue.hyperliquid
15730
+ };
15731
+ var parseVenueName = (raw) => VENUE_NAME_MAP[raw];
15732
+ var NON_VENUE_FINALIZE_PREFIXES = /* @__PURE__ */ new Set(["bridge"]);
15733
+ var classifyExecutionStepType = (stepType) => {
15734
+ if (!stepType) return null;
15735
+ if (WAIT_STEP_TYPES.has(stepType)) return null;
15736
+ if (CHECKING_BALANCE_STEP_TYPES.has(stepType)) {
15737
+ return { kind: "checking-balance" };
15738
+ }
15739
+ const buySellMatch = stepType.match(VENUE_BUY_SELL_REGEX);
15740
+ if (buySellMatch) {
15741
+ const venue = parseVenueName(buySellMatch[1]);
15742
+ if (venue) return { kind: "executing-venue", venue };
15743
+ }
15744
+ const finalizeMatch = stepType.match(VENUE_FINALIZE_REGEX);
15745
+ if (finalizeMatch && !NON_VENUE_FINALIZE_PREFIXES.has(finalizeMatch[1])) {
15746
+ const venue = parseVenueName(finalizeMatch[1]);
15747
+ if (venue) return { kind: "executing-venue", venue };
15748
+ }
15749
+ if (stepType === "submit-verify-order-status") {
15750
+ return null;
15751
+ }
15752
+ return { kind: "submitting" };
15753
+ };
15754
+ var buildPhaseTimeline = (dag) => {
15755
+ const timeline = [];
15756
+ const completed = new Set(dag.completedSequences);
15757
+ for (let seq = 1; seq <= dag.totalSteps; seq++) {
15758
+ const stepType = dag.stepTypes[seq];
15759
+ if (!stepType) continue;
15760
+ const classified = classifyExecutionStepType(stepType);
15761
+ if (!classified) continue;
15762
+ const isCompleted = completed.has(seq);
15763
+ const last = timeline[timeline.length - 1];
15764
+ if (last && last.kind === classified.kind && last.venue === classified.venue) {
15765
+ last.lastSeq = seq;
15766
+ last.allCompleted = last.allCompleted && isCompleted;
15767
+ continue;
15768
+ }
15769
+ timeline.push({
15770
+ kind: classified.kind,
15771
+ venue: classified.venue,
15772
+ firstSeq: seq,
15773
+ lastSeq: seq,
15774
+ allCompleted: isCompleted
15775
+ });
15776
+ }
15777
+ return timeline;
15778
+ };
15779
+ var phaseRowId = (phase) => phase.venue ? `${phase.kind}:${phase.venue}` : phase.kind;
15780
+ var phaseRowLabel = (phase, labels) => {
15781
+ switch (phase.kind) {
15782
+ case "finding-route":
15783
+ return labels.findingBestRoute;
15784
+ case "checking-balance":
15785
+ return labels.checkingBalance;
15786
+ case "submitting":
15787
+ return labels.submittingOrderProgress;
15788
+ case "wallet-confirm":
15789
+ return labels.confirmTransactionInWallet;
15790
+ case "executing-venue":
15791
+ return labels.executingOnVenue(getTradingVenueLabel(phase.venue));
15792
+ case "filled":
15793
+ return labels.executionConfirmed;
15794
+ case "failed":
15795
+ return labels.orderFailureTitle;
15796
+ }
15797
+ };
15798
+ var buildSubmissionDisplayRows = ({
15799
+ phase,
15800
+ dagProgress,
15801
+ executionVenue,
15802
+ isAwaitingWalletConfirmation,
15803
+ labels
15804
+ }) => {
15805
+ if (phase === "finding-route") {
15806
+ return [
15807
+ {
15808
+ id: "finding-route",
15809
+ label: labels.findingBestRoute,
15810
+ status: "pending"
15811
+ }
15812
+ ];
15813
+ }
15814
+ const rows = [
15815
+ {
15816
+ id: "finding-route",
15817
+ label: labels.findingBestRoute,
15818
+ status: "complete"
15819
+ }
15820
+ ];
15821
+ const pushPhase = (phaseEntry, status) => {
15822
+ const id = phaseRowId(phaseEntry);
15823
+ if (rows.some((row) => row.id === id)) return;
15824
+ rows.push({
15825
+ id,
15826
+ label: phaseRowLabel(phaseEntry, labels),
15827
+ status,
15828
+ venue: phaseEntry.venue
15829
+ });
15830
+ };
15831
+ if (dagProgress && dagProgress.totalSteps > 0) {
15832
+ const timeline = buildPhaseTimeline(dagProgress);
15833
+ let activeEmitted = false;
15834
+ for (const entry of timeline) {
15835
+ const id = phaseRowId(entry);
15836
+ const alreadyShown = rows.some((row) => row.id === id);
15837
+ if (entry.allCompleted) {
15838
+ if (alreadyShown) continue;
15839
+ pushPhase(entry, "complete");
15840
+ continue;
15841
+ }
15842
+ if (activeEmitted) break;
15843
+ if (alreadyShown) continue;
15844
+ if (isAwaitingWalletConfirmation && entry.kind === "submitting") {
15845
+ pushPhase({ kind: "wallet-confirm" }, "pending");
15846
+ } else {
15847
+ pushPhase(entry, "pending");
15848
+ }
15849
+ activeEmitted = true;
15850
+ }
15851
+ if (!activeEmitted) {
15852
+ const last = rows[rows.length - 1];
15853
+ if (last && last.id.startsWith("executing-venue")) {
15854
+ last.status = "pending";
15855
+ } else {
15856
+ const fallbackVenue = executionVenue;
15857
+ rows.push({
15858
+ id: fallbackVenue ? `executing-venue:${fallbackVenue}` : "executing-venue",
15859
+ label: phaseRowLabel({ kind: "executing-venue", venue: fallbackVenue }, labels),
15860
+ status: "pending",
15861
+ venue: fallbackVenue
15862
+ });
15863
+ }
15864
+ }
15865
+ return rows;
15866
+ }
15867
+ if (isAwaitingWalletConfirmation) {
15868
+ pushPhase({ kind: "wallet-confirm" }, "pending");
15869
+ return rows;
15870
+ }
15871
+ if (phase === "submitting") {
15872
+ pushPhase({ kind: "submitting" }, "pending");
15873
+ return rows;
15874
+ }
15875
+ pushPhase({ kind: "submitting" }, "complete");
15876
+ pushPhase({ kind: "executing-venue", venue: executionVenue }, "pending");
15877
+ return rows;
15878
+ };
15879
+
15880
+ // src/trading/place-order/index.place-order.execution-debug.ts
15881
+ var REDACTED = "[redacted]";
15882
+ var SENSITIVE_FIELD_PATTERNS = [
15883
+ "token",
15884
+ "authorization",
15885
+ "cookie",
15886
+ "secret",
15887
+ "signature",
15888
+ "privatekey",
15889
+ "private_key",
15890
+ "accesstoken",
15891
+ "access_token",
15892
+ "refreshtoken",
15893
+ "refresh_token",
15894
+ "jwt",
15895
+ "password",
15896
+ "apikey",
15897
+ "api_key",
15898
+ "email",
15899
+ "headers"
15900
+ ];
15901
+ var isSensitiveFieldName = (name) => {
15902
+ const normalized = name.toLowerCase();
15903
+ return SENSITIVE_FIELD_PATTERNS.some((pattern) => normalized.includes(pattern));
15904
+ };
15905
+ var sanitizeExecutionDebugValue = (input) => {
15906
+ const ancestors = /* @__PURE__ */ new Set();
15907
+ const walk = (value) => {
15908
+ if (value === null || value === void 0) return value;
15909
+ if (typeof value !== "object") return value;
15910
+ if (ancestors.has(value)) return "[circular]";
15911
+ ancestors.add(value);
15912
+ try {
15913
+ if (Array.isArray(value)) {
15914
+ return value.map((entry) => walk(entry));
15915
+ }
15916
+ if (value instanceof Error) {
15917
+ return {
15918
+ name: value.name,
15919
+ message: value.message,
15920
+ stack: value.stack
15921
+ };
15922
+ }
15923
+ const out = {};
15924
+ for (const [key, raw] of Object.entries(value)) {
15925
+ if (isSensitiveFieldName(key)) {
15926
+ out[key] = REDACTED;
15927
+ continue;
15928
+ }
15929
+ out[key] = walk(raw);
15930
+ }
15931
+ return out;
15932
+ } finally {
15933
+ ancestors.delete(value);
15934
+ }
15935
+ };
15936
+ return walk(input);
15937
+ };
15938
+ var cloneEnvironment = (env) => __spreadProps(__spreadValues({}, env), {
15939
+ packageVersions: env.packageVersions ? __spreadValues({}, env.packageVersions) : void 0
15940
+ });
15941
+ var buildEnvironment = (overrides) => {
15942
+ var _a;
15943
+ const url = typeof window !== "undefined" ? (_a = window.location) == null ? void 0 : _a.href : void 0;
15944
+ const userAgent = typeof navigator !== "undefined" && typeof navigator.userAgent === "string" ? navigator.userAgent : void 0;
15945
+ return __spreadValues({
15946
+ url,
15947
+ userAgent,
15948
+ capturedAt: Date.now()
15949
+ }, overrides);
15950
+ };
15951
+ var generateAttemptId = () => {
15952
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
15953
+ return crypto.randomUUID();
15954
+ }
15955
+ return `attempt-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
15956
+ };
15957
+ var createExecutionDebugStore = (initial) => {
15958
+ let attempts = [];
15959
+ let environment = buildEnvironment(initial);
15960
+ const findAttempt = (attemptId) => attempts.find((attempt) => attempt.attemptId === attemptId);
15961
+ const touch = (attempt) => {
15962
+ attempt.updatedAt = Date.now();
15963
+ };
15964
+ return {
15965
+ appendAttempt(input = {}) {
15966
+ var _a, _b;
15967
+ const now = Date.now();
15968
+ const attempt = {
15969
+ attemptId: (_a = input.attemptId) != null ? _a : generateAttemptId(),
15970
+ startedAt: now,
15971
+ updatedAt: now,
15972
+ status: (_b = input.status) != null ? _b : "quoting",
15973
+ quoteId: input.quoteId,
15974
+ orderId: input.orderId,
15975
+ orderIds: input.orderIds,
15976
+ quote: input.quote,
15977
+ selectedRoute: input.selectedRoute,
15978
+ bridge: input.bridge,
15979
+ venueExecution: input.venueExecution,
15980
+ rawEvents: [],
15981
+ normalizedSteps: [],
15982
+ errors: []
15983
+ };
15984
+ attempts = [...attempts, attempt];
15985
+ return attempt;
15986
+ },
15987
+ updateAttempt(attemptId, patch) {
15988
+ const attempt = findAttempt(attemptId);
15989
+ if (!attempt) return;
15990
+ if (patch.status !== void 0) attempt.status = patch.status;
15991
+ if (patch.quoteId !== void 0) attempt.quoteId = patch.quoteId;
15992
+ if (patch.orderId !== void 0) attempt.orderId = patch.orderId;
15993
+ if (patch.orderIds !== void 0) attempt.orderIds = patch.orderIds;
15994
+ if (patch.quote !== void 0) attempt.quote = patch.quote;
15995
+ if (patch.selectedRoute !== void 0) attempt.selectedRoute = patch.selectedRoute;
15996
+ if (patch.bridge !== void 0) attempt.bridge = patch.bridge;
15997
+ if (patch.venueExecution !== void 0) attempt.venueExecution = patch.venueExecution;
15998
+ if (patch.finalStatus !== void 0) attempt.finalStatus = patch.finalStatus;
15999
+ touch(attempt);
16000
+ },
16001
+ appendEvent(attemptId, event) {
16002
+ var _a;
16003
+ const attempt = findAttempt(attemptId);
16004
+ if (!attempt) return;
16005
+ attempt.rawEvents.push({
16006
+ kind: event.kind,
16007
+ label: event.label,
16008
+ data: event.data,
16009
+ timestamp: (_a = event.timestamp) != null ? _a : Date.now()
16010
+ });
16011
+ touch(attempt);
16012
+ },
16013
+ appendError(attemptId, error) {
16014
+ var _a;
16015
+ const attempt = findAttempt(attemptId);
16016
+ if (!attempt) return;
16017
+ attempt.errors.push({
16018
+ message: error.message,
16019
+ name: error.name,
16020
+ code: error.code,
16021
+ stack: error.stack,
16022
+ failedStep: error.failedStep,
16023
+ data: error.data,
16024
+ timestamp: (_a = error.timestamp) != null ? _a : Date.now()
16025
+ });
16026
+ touch(attempt);
16027
+ },
16028
+ setNormalizedSteps(attemptId, steps) {
16029
+ const attempt = findAttempt(attemptId);
16030
+ if (!attempt) return;
16031
+ attempt.normalizedSteps = steps;
16032
+ touch(attempt);
16033
+ },
16034
+ getSnapshot() {
16035
+ return {
16036
+ attempts: attempts.map((attempt) => __spreadProps(__spreadValues({}, attempt), {
16037
+ rawEvents: [...attempt.rawEvents],
16038
+ normalizedSteps: [...attempt.normalizedSteps],
16039
+ errors: [...attempt.errors]
16040
+ })),
16041
+ environment: cloneEnvironment(environment)
16042
+ };
16043
+ },
16044
+ getFailedAttempts() {
16045
+ return attempts.filter(
16046
+ (attempt) => attempt.status === "failed" || attempt.finalStatus === "failed" || attempt.errors.length > 0
16047
+ ).map((attempt) => __spreadProps(__spreadValues({}, attempt), {
16048
+ rawEvents: [...attempt.rawEvents],
16049
+ normalizedSteps: [...attempt.normalizedSteps],
16050
+ errors: [...attempt.errors]
16051
+ }));
16052
+ },
16053
+ clear() {
16054
+ attempts = [];
16055
+ environment = buildEnvironment(initial);
16056
+ }
16057
+ };
16058
+ };
16059
+ var writeClipboardLegacy = (text) => {
16060
+ if (typeof document === "undefined") return false;
16061
+ const textarea = document.createElement("textarea");
16062
+ textarea.value = text;
16063
+ textarea.setAttribute("readonly", "");
16064
+ textarea.style.position = "fixed";
16065
+ textarea.style.top = "-1000px";
16066
+ textarea.style.opacity = "0";
16067
+ document.body.appendChild(textarea);
16068
+ try {
16069
+ textarea.select();
16070
+ return document.execCommand("copy");
16071
+ } catch (e) {
16072
+ return false;
16073
+ } finally {
16074
+ document.body.removeChild(textarea);
16075
+ }
16076
+ };
16077
+ var tryWriteClipboard = (text, consoleImpl) => __async(null, null, function* () {
16078
+ var _a;
16079
+ if (typeof navigator !== "undefined" && ((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
16080
+ try {
16081
+ yield navigator.clipboard.writeText(text);
16082
+ consoleImpl.info("[agg-execution-debug] Copied execution data to clipboard.");
16083
+ return;
16084
+ } catch (e) {
16085
+ }
16086
+ }
16087
+ if (writeClipboardLegacy(text)) {
16088
+ consoleImpl.info("[agg-execution-debug] Copied execution data to clipboard.");
16089
+ return;
16090
+ }
16091
+ consoleImpl.warn(
16092
+ "[agg-execution-debug] Clipboard copy was blocked by the browser. The JSON is logged below \u2014 right-click the entry and copy."
16093
+ );
16094
+ consoleImpl.log(text);
16095
+ });
16096
+ var installExecutionDebugWindow = ({
16097
+ store,
16098
+ consoleImpl
16099
+ }) => {
16100
+ if (typeof window === "undefined") return () => {
16101
+ };
16102
+ const targetConsole = consoleImpl != null ? consoleImpl : console;
16103
+ const previous = {
16104
+ executionData: window.executionData,
16105
+ getExecutionData: window.getExecutionData,
16106
+ getFailedExecutionData: window.getFailedExecutionData,
16107
+ clearExecutionData: window.clearExecutionData,
16108
+ storeRef: window.__aggExecutionDebugStore
16109
+ };
16110
+ const refresh = () => {
16111
+ window.executionData = sanitizeExecutionDebugValue(store.getSnapshot());
16112
+ };
16113
+ refresh();
16114
+ window.__aggExecutionDebugStore = store;
16115
+ window.getExecutionData = () => {
16116
+ const data = sanitizeExecutionDebugValue(store.getSnapshot());
16117
+ window.executionData = data;
16118
+ void tryWriteClipboard(JSON.stringify(data, null, 2), targetConsole);
16119
+ return data;
16120
+ };
16121
+ window.getFailedExecutionData = () => {
16122
+ const failed = sanitizeExecutionDebugValue({ attempts: store.getFailedAttempts() });
16123
+ void tryWriteClipboard(JSON.stringify(failed, null, 2), targetConsole);
16124
+ return failed;
16125
+ };
16126
+ window.clearExecutionData = () => {
16127
+ store.clear();
16128
+ refresh();
16129
+ };
16130
+ targetConsole.info(
16131
+ "AGG execution debug enabled. Run window.getFailedExecutionData() after a failed order to copy logs."
16132
+ );
16133
+ return () => {
16134
+ if (typeof window === "undefined") return;
16135
+ window.executionData = previous.executionData;
16136
+ window.getExecutionData = previous.getExecutionData;
16137
+ window.getFailedExecutionData = previous.getFailedExecutionData;
16138
+ window.clearExecutionData = previous.clearExecutionData;
16139
+ window.__aggExecutionDebugStore = previous.storeRef;
16140
+ };
16141
+ };
16142
+ var enableExecutionDebugInBrowser = (initial) => {
16143
+ if (typeof window === "undefined") return null;
16144
+ const existing = window.__aggExecutionDebugStore;
16145
+ if (existing) return existing;
16146
+ const store = createExecutionDebugStore(initial);
16147
+ installExecutionDebugWindow({ store });
16148
+ return store;
16149
+ };
16150
+
15667
16151
  // src/trading/place-order/index.place-order.utils.ts
15668
16152
  var routePriceLabelFormatter = new Intl.NumberFormat("en-US", {
15669
16153
  minimumFractionDigits: 0,
@@ -15874,18 +16358,19 @@ var buildLiveRouteCards = ({
15874
16358
  const parsedPrimaryVenue = parseVenue(primaryVenue);
15875
16359
  const isSplit = quoteData.fills.length > 1;
15876
16360
  const primaryWinnerVenue = quoteData.fills.length === 1 ? primaryVenue : void 0;
15877
- const isPrimaryRouteGeoBlocked = quoteData.fills.length > 0 && quoteData.fills.every((f) => geoBlockedVenues.has(f.venue));
16361
+ const isPrimaryRouteGeoBlocked = quoteData.fills.length > 0 && quoteData.fills.some((f) => geoBlockedVenues.has(f.venue));
15878
16362
  const primaryCard = primaryResult ? isPrimaryRouteGeoBlocked ? {
15879
16363
  id: "live-route",
15880
16364
  hint: labels.venueUnavailableInRegion,
15881
- kind: "venue",
15882
- label: getTradingVenueLabel(
16365
+ kind: isSplit ? "split" : "venue",
16366
+ label: isSplit ? labels.orderSplitting : getTradingVenueLabel(
15883
16367
  parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
15884
16368
  ),
15885
16369
  numericValue: tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled,
15886
16370
  quoteData,
16371
+ rows: isSplit ? mapQuoteDataToRoutingRows(quoteData) : void 0,
15887
16372
  value: primaryResult.value,
15888
- venue: parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0,
16373
+ venue: isSplit ? void 0 : parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0,
15889
16374
  isUnavailable: true
15890
16375
  } : {
15891
16376
  id: "live-route",
@@ -16850,21 +17335,6 @@ PlaceOrderSuccessView.displayName = "PlaceOrderSuccessView";
16850
17335
 
16851
17336
  // src/trading/place-order/index.tsx
16852
17337
  var import_jsx_runtime142 = require("react/jsx-runtime");
16853
- var DEFAULT_STEP_LABELS = {
16854
- "check-balance": "Checking balance",
16855
- "check-position": "Checking position",
16856
- "lane-bridge": "Bridging funds",
16857
- bridge: "Bridging funds",
16858
- "bridge-to-user": "Transferring to wallet",
16859
- "sweep-bridge": "Completing bridge",
16860
- "submit-order": "Submitting order",
16861
- "order-bridge-execute": "Executing order",
16862
- "transfer-to-user": "Transferring to wallet"
16863
- };
16864
- var getDefaultStepLabel = (stepType) => {
16865
- var _a;
16866
- return (_a = DEFAULT_STEP_LABELS[stepType]) != null ? _a : stepType.replace(/-/g, " ").replace(/^\w/, (c) => c.toUpperCase());
16867
- };
16868
17338
  var resolveRefetchedQuoteData = (result) => {
16869
17339
  if (!result || typeof result !== "object" || !("data" in result)) return null;
16870
17340
  const data = result.data;
@@ -17364,7 +17834,6 @@ var renderRouteCard = ({
17364
17834
  }
17365
17835
  );
17366
17836
  };
17367
- var normalizeOrderIdLabelInput2 = (orderId) => orderId.replace(/^#+/, "");
17368
17837
  var renderSubmissionSurface = ({
17369
17838
  actionLabel,
17370
17839
  className,
@@ -17376,81 +17845,12 @@ var renderSubmissionSurface = ({
17376
17845
  progressState,
17377
17846
  tradingLabels
17378
17847
  }) => {
17379
- const resolveStepGroups = () => {
17380
- var _a, _b, _c;
17381
- if (progressState.phase === "finding-route") {
17382
- return [
17383
- [
17384
- {
17385
- id: "finding-route",
17386
- label: tradingLabels.findingBestRoute,
17387
- status: "pending"
17388
- }
17389
- ]
17390
- ];
17391
- }
17392
- const dag = progressState.dagProgress;
17393
- if (dag && dag.totalSteps > 0) {
17394
- const steps = [
17395
- {
17396
- id: "finding-route",
17397
- label: tradingLabels.findingBestRoute,
17398
- status: "complete"
17399
- }
17400
- ];
17401
- for (let i = 1; i <= dag.totalSteps; i++) {
17402
- const isCompleted = dag.completedSequences.includes(i);
17403
- const isCurrent = i === dag.currentSequence && !isCompleted;
17404
- const stepType = (_a = dag.stepTypes[i]) != null ? _a : null;
17405
- const stepLabel = stepType ? getDefaultStepLabel(stepType) : `Step ${i} of ${dag.totalSteps}`;
17406
- const prev = steps[steps.length - 1];
17407
- if (prev && prev.label === stepLabel) {
17408
- if (prev.status === "complete" && !isCompleted) {
17409
- prev.status = "pending";
17410
- }
17411
- continue;
17412
- }
17413
- steps.push({
17414
- id: `dag-step-${i}`,
17415
- label: stepLabel,
17416
- status: isCompleted ? "complete" : isCurrent ? "pending" : "pending"
17417
- });
17418
- }
17419
- return [steps];
17420
- }
17421
- const baseSteps = [
17422
- {
17423
- id: "finding-route",
17424
- label: tradingLabels.findingBestRoute,
17425
- status: "complete"
17426
- },
17427
- {
17428
- id: "submitting-order",
17429
- label: tradingLabels.submittingOrderProgress,
17430
- status: "complete"
17431
- }
17432
- ];
17433
- const submittedOrderId = (_c = progressState.orderId) != null ? _c : (_b = progressState.orderIds) == null ? void 0 : _b[0];
17434
- if (submittedOrderId) {
17435
- baseSteps.push({
17436
- id: "order-submitted",
17437
- label: tradingLabels.orderSubmittedProgress(normalizeOrderIdLabelInput2(submittedOrderId)),
17438
- status: "complete"
17439
- });
17440
- }
17441
- return [
17442
- baseSteps,
17443
- [
17444
- {
17445
- id: "executing-order",
17446
- label: tradingLabels.executingOnVenue(getTradingVenueLabel(progressState.executionVenue)),
17447
- status: "pending",
17448
- venue: progressState.executionVenue
17449
- }
17450
- ]
17451
- ];
17452
- };
17453
- const stepGroups = resolveStepGroups();
17848
+ const displayRows = buildSubmissionDisplayRows({
17849
+ phase: progressState.phase,
17850
+ dagProgress: progressState.dagProgress,
17851
+ executionVenue: progressState.executionVenue,
17852
+ labels: tradingLabels
17853
+ });
17454
17854
  return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
17455
17855
  Card,
17456
17856
  {
@@ -17472,51 +17872,50 @@ var renderSubmissionSurface = ({
17472
17872
  /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(LoadingGlyph, { enableAnimations, className: "h-4 w-4 text-current" }),
17473
17873
  /* @__PURE__ */ (0, import_jsx_runtime142.jsx)("span", { children: actionLabel })
17474
17874
  ] }),
17475
- /* @__PURE__ */ (0, import_jsx_runtime142.jsx)("div", { className: "agg-order-submission-steps flex flex-col gap-4", children: stepGroups.map((steps, groupIndex) => {
17476
- return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
17477
- "div",
17478
- {
17479
- className: "agg-order-submission-group flex flex-col gap-2",
17480
- children: steps.map((step) => {
17481
- return /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(
17482
- "div",
17483
- {
17484
- className: "agg-order-submission-step flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
17485
- children: [
17486
- step.status === "complete" ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
17487
- Icon,
17488
- {
17489
- name: "check-circle",
17490
- size: "small",
17491
- className: "h-3 w-3 shrink-0 text-agg-primary",
17492
- "aria-hidden": "true"
17493
- }
17494
- ) : /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
17495
- LoadingGlyph,
17496
- {
17497
- enableAnimations,
17498
- className: "h-3 w-3 shrink-0 text-agg-primary"
17499
- }
17500
- ),
17501
- /* @__PURE__ */ (0, import_jsx_runtime142.jsx)("p", { className: "min-w-0 flex-1", children: step.label }),
17502
- step.venue ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
17503
- VenueLogo,
17504
- {
17505
- venue: step.venue,
17506
- size: "small",
17507
- ariaLabel: getTradingVenueLabel(step.venue),
17508
- className: "h-4 w-4"
17509
- }
17510
- ) : null
17511
- ]
17512
- },
17513
- step.id
17514
- );
17515
- })
17516
- },
17517
- `step-group-${groupIndex}`
17518
- );
17519
- }) })
17875
+ /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
17876
+ "div",
17877
+ {
17878
+ className: "agg-order-submission-steps agg-order-submission-group flex flex-col gap-2",
17879
+ "data-testid": "agg-order-submission-steps",
17880
+ children: displayRows.map((step) => {
17881
+ return /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(
17882
+ "div",
17883
+ {
17884
+ className: "agg-order-submission-step flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
17885
+ "data-status": step.status,
17886
+ children: [
17887
+ step.status === "complete" ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
17888
+ Icon,
17889
+ {
17890
+ name: "check-circle",
17891
+ size: "small",
17892
+ className: "h-3 w-3 shrink-0 text-agg-primary",
17893
+ "aria-hidden": "true"
17894
+ }
17895
+ ) : /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
17896
+ LoadingGlyph,
17897
+ {
17898
+ enableAnimations,
17899
+ className: "h-3 w-3 shrink-0 text-agg-primary"
17900
+ }
17901
+ ),
17902
+ /* @__PURE__ */ (0, import_jsx_runtime142.jsx)("p", { className: "min-w-0 flex-1", children: step.label }),
17903
+ step.venue ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
17904
+ VenueLogo,
17905
+ {
17906
+ venue: step.venue,
17907
+ size: "small",
17908
+ ariaLabel: getTradingVenueLabel(step.venue),
17909
+ className: "h-4 w-4"
17910
+ }
17911
+ ) : null
17912
+ ]
17913
+ },
17914
+ step.id
17915
+ );
17916
+ })
17917
+ }
17918
+ )
17520
17919
  ] })
17521
17920
  ] })
17522
17921
  }
@@ -17652,6 +18051,7 @@ var PlaceOrder = ({
17652
18051
  }) => {
17653
18052
  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;
17654
18053
  const {
18054
+ enableDebug: isExecutionDebugEnabled,
17655
18055
  features: { enableAnimations, showFeesBreakdown },
17656
18056
  general: { locale }
17657
18057
  } = (0, import_hooks53.useSdkUiConfig)();
@@ -17748,6 +18148,27 @@ var PlaceOrder = ({
17748
18148
  const [isSplitDetailOpen, setIsSplitDetailOpen] = (0, import_react31.useState)(false);
17749
18149
  const [submissionFeedback, setSubmissionFeedback] = (0, import_react31.useState)(null);
17750
18150
  const [submissionProgressState, setSubmissionProgressState] = (0, import_react31.useState)(null);
18151
+ const executionDebugStoreRef = (0, import_react31.useRef)(null);
18152
+ const executionDebugAttemptIdRef = (0, import_react31.useRef)(null);
18153
+ (0, import_react31.useEffect)(() => {
18154
+ if (!isExecutionDebugEnabled) {
18155
+ executionDebugStoreRef.current = null;
18156
+ return;
18157
+ }
18158
+ executionDebugStoreRef.current = enableExecutionDebugInBrowser();
18159
+ }, [isExecutionDebugEnabled]);
18160
+ (0, import_react31.useEffect)(() => {
18161
+ if (!isExecutionDebugEnabled) return;
18162
+ const store = executionDebugStoreRef.current;
18163
+ if (!store) return;
18164
+ store.clear();
18165
+ executionDebugAttemptIdRef.current = null;
18166
+ }, [
18167
+ isExecutionDebugEnabled,
18168
+ scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.id,
18169
+ scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id,
18170
+ scopedSelectedOutcomeId
18171
+ ]);
17751
18172
  const debouncedAmount = (0, import_hooks53.useDebouncedValue)(internalAmount, 300);
17752
18173
  const isSell = (0, import_react31.useMemo)(() => internalTab === "sell", [internalTab]);
17753
18174
  const {
@@ -18007,8 +18428,39 @@ var PlaceOrder = ({
18007
18428
  selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData
18008
18429
  ]);
18009
18430
  (0, import_react31.useEffect)(() => {
18431
+ var _a2, _b2;
18010
18432
  const dp = executionProgress.dagProgress;
18011
18433
  if (!dp) return;
18434
+ const debugStore = executionDebugStoreRef.current;
18435
+ const debugAttemptId = executionDebugAttemptIdRef.current;
18436
+ if (debugStore && debugAttemptId) {
18437
+ debugStore.appendEvent(debugAttemptId, {
18438
+ kind: "ws_update",
18439
+ label: "dag_progress",
18440
+ data: dp
18441
+ });
18442
+ const normalizedRows = buildSubmissionDisplayRows({
18443
+ phase: "executing",
18444
+ dagProgress: dp,
18445
+ labels: tradingLabels
18446
+ });
18447
+ debugStore.setNormalizedSteps(debugAttemptId, normalizedRows);
18448
+ debugStore.appendEvent(debugAttemptId, {
18449
+ kind: "normalized_steps",
18450
+ data: normalizedRows
18451
+ });
18452
+ if (dp.status === "failed") {
18453
+ debugStore.appendError(debugAttemptId, {
18454
+ message: (_a2 = dp.errorReason) != null ? _a2 : "DAG execution failed",
18455
+ failedStep: (_b2 = dp.currentStepType) != null ? _b2 : void 0,
18456
+ data: { currentSequence: dp.currentSequence, totalSteps: dp.totalSteps }
18457
+ });
18458
+ debugStore.updateAttempt(debugAttemptId, {
18459
+ status: "failed",
18460
+ finalStatus: "failed"
18461
+ });
18462
+ }
18463
+ }
18012
18464
  setSubmissionProgressState((prev) => {
18013
18465
  if (!prev) return prev;
18014
18466
  if (dp.status === "failed") {
@@ -18024,7 +18476,7 @@ var PlaceOrder = ({
18024
18476
  }
18025
18477
  return __spreadProps(__spreadValues({}, prev), { dagProgress: dp });
18026
18478
  });
18027
- }, [executionProgress.dagProgress, tradingLabels.orderFailed]);
18479
+ }, [executionProgress.dagProgress, tradingLabels]);
18028
18480
  (0, import_react31.useEffect)(() => {
18029
18481
  const orderIds = submissionProgressState == null ? void 0 : submissionProgressState.orderIds;
18030
18482
  if (!(orderIds == null ? void 0 : orderIds.length)) return;
@@ -18032,6 +18484,17 @@ var PlaceOrder = ({
18032
18484
  orderIds,
18033
18485
  executionProgress.terminalOrderEvents
18034
18486
  );
18487
+ const debugStore = executionDebugStoreRef.current;
18488
+ const debugAttemptId = executionDebugAttemptIdRef.current;
18489
+ if (debugStore && debugAttemptId && executionProgress.terminalOrderEvents.length > 0) {
18490
+ debugStore.appendEvent(debugAttemptId, {
18491
+ kind: "terminal_event",
18492
+ data: {
18493
+ aggregateStatus,
18494
+ events: executionProgress.terminalOrderEvents
18495
+ }
18496
+ });
18497
+ }
18035
18498
  if (aggregateStatus === "pending") return;
18036
18499
  setSubmissionProgressState((prev) => {
18037
18500
  var _a2, _b2, _c2;
@@ -18074,14 +18537,45 @@ var PlaceOrder = ({
18074
18537
  tradingLabels.orderFailed
18075
18538
  ]);
18076
18539
  (0, import_react31.useEffect)(() => {
18540
+ var _a2, _b2;
18077
18541
  if (!submissionProgressState) return;
18078
18542
  onExecutionStateChange == null ? void 0 : onExecutionStateChange(submissionProgressState);
18543
+ const debugStore = executionDebugStoreRef.current;
18544
+ const debugAttemptId = executionDebugAttemptIdRef.current;
18545
+ if (debugStore && debugAttemptId) {
18546
+ debugStore.appendEvent(debugAttemptId, {
18547
+ kind: "state_change",
18548
+ label: submissionProgressState.phase,
18549
+ data: {
18550
+ phase: submissionProgressState.phase,
18551
+ executionVenue: submissionProgressState.executionVenue,
18552
+ orderIds: submissionProgressState.orderIds,
18553
+ errorMessage: submissionProgressState.errorMessage
18554
+ }
18555
+ });
18556
+ }
18079
18557
  if (submissionProgressState.phase === "success" && submissionProgressState.summary) {
18080
18558
  (0, import_hooks53.invalidateBalanceQueries)(queryClient);
18081
18559
  (0, import_hooks53.invalidatePositionQueries)(queryClient);
18560
+ if (debugStore && debugAttemptId) {
18561
+ debugStore.updateAttempt(debugAttemptId, {
18562
+ status: "succeeded",
18563
+ finalStatus: "succeeded"
18564
+ });
18565
+ }
18082
18566
  onSuccess == null ? void 0 : onSuccess(submissionProgressState.summary);
18083
18567
  }
18084
18568
  if (submissionProgressState.phase === "failed" && submissionProgressState.errorMessage) {
18569
+ if (debugStore && debugAttemptId) {
18570
+ debugStore.appendError(debugAttemptId, {
18571
+ message: submissionProgressState.errorMessage,
18572
+ failedStep: (_b2 = (_a2 = submissionProgressState.dagProgress) == null ? void 0 : _a2.currentStepType) != null ? _b2 : void 0
18573
+ });
18574
+ debugStore.updateAttempt(debugAttemptId, {
18575
+ status: "failed",
18576
+ finalStatus: "failed"
18577
+ });
18578
+ }
18085
18579
  onError == null ? void 0 : onError(new Error(submissionProgressState.errorMessage));
18086
18580
  }
18087
18581
  }, [submissionProgressState, onExecutionStateChange, onSuccess, onError, queryClient]);
@@ -18255,23 +18749,91 @@ var PlaceOrder = ({
18255
18749
  };
18256
18750
  const handleExecuteQuote = (0, import_react31.useCallback)(
18257
18751
  (quoteData) => __async(null, null, function* () {
18752
+ var _a2, _b2, _c2;
18258
18753
  const quoteId = quoteData == null ? void 0 : quoteData.quoteId;
18259
18754
  if (!quoteId) {
18260
18755
  throw new Error(tradingLabels.quoteUnavailable);
18261
18756
  }
18757
+ const debugStore = executionDebugStoreRef.current;
18758
+ const venues = (_b2 = (_a2 = quoteData == null ? void 0 : quoteData.fills) == null ? void 0 : _a2.map((fill) => fill.venue).filter(Boolean)) != null ? _b2 : [];
18759
+ const debugAttempt = debugStore == null ? void 0 : debugStore.appendAttempt({
18760
+ status: "executing",
18761
+ quoteId,
18762
+ quote: {
18763
+ request: {
18764
+ venueMarketOutcomeId: scopedSelectedOutcomeId,
18765
+ amount: internalAmount,
18766
+ slippage: internalSlippage,
18767
+ tradeSide: isSell ? "sell" : "buy"
18768
+ },
18769
+ response: smartRoute.data,
18770
+ selectedRoute: quoteData,
18771
+ side: isSell ? "sell" : "buy",
18772
+ marketId: scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id,
18773
+ eventId: scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.id,
18774
+ outcomeId: scopedSelectedOutcomeId != null ? scopedSelectedOutcomeId : void 0,
18775
+ venues,
18776
+ capturedAt: Date.now()
18777
+ },
18778
+ selectedRoute: quoteData
18779
+ });
18780
+ executionDebugAttemptIdRef.current = (_c2 = debugAttempt == null ? void 0 : debugAttempt.attemptId) != null ? _c2 : null;
18262
18781
  if (onPrimaryAction) {
18782
+ debugStore == null ? void 0 : debugStore.appendEvent(debugAttempt.attemptId, {
18783
+ kind: "execute_request",
18784
+ label: "delegated_to_partner",
18785
+ data: { quoteId }
18786
+ });
18263
18787
  onPrimaryAction({ quoteId });
18264
18788
  return;
18265
18789
  }
18266
- const response = yield executeManaged.mutateAsync({ quoteId });
18267
- setSubmissionProgressState({
18268
- executionVenue: resolveExecutionVenueFromQuote(quoteData),
18269
- orderId: response.orderIds[0],
18270
- orderIds: response.orderIds,
18271
- phase: "submitting"
18272
- });
18790
+ try {
18791
+ const response = yield executeManaged.mutateAsync({ quoteId });
18792
+ if (debugAttempt) {
18793
+ debugStore == null ? void 0 : debugStore.appendEvent(debugAttempt.attemptId, {
18794
+ kind: "execute_response",
18795
+ data: { orderIds: response.orderIds }
18796
+ });
18797
+ debugStore == null ? void 0 : debugStore.updateAttempt(debugAttempt.attemptId, {
18798
+ orderId: response.orderIds[0],
18799
+ orderIds: response.orderIds
18800
+ });
18801
+ }
18802
+ setSubmissionProgressState({
18803
+ executionVenue: resolveExecutionVenueFromQuote(quoteData),
18804
+ orderId: response.orderIds[0],
18805
+ orderIds: response.orderIds,
18806
+ phase: "submitting"
18807
+ });
18808
+ } catch (error) {
18809
+ if (debugAttempt) {
18810
+ const err = error instanceof Error ? error : new Error(String(error));
18811
+ debugStore == null ? void 0 : debugStore.appendError(debugAttempt.attemptId, {
18812
+ message: err.message,
18813
+ name: err.name,
18814
+ stack: err.stack,
18815
+ failedStep: "execute_request"
18816
+ });
18817
+ debugStore == null ? void 0 : debugStore.updateAttempt(debugAttempt.attemptId, {
18818
+ status: "failed",
18819
+ finalStatus: "failed"
18820
+ });
18821
+ }
18822
+ throw error;
18823
+ }
18273
18824
  }),
18274
- [executeManaged, onPrimaryAction, tradingLabels.quoteUnavailable]
18825
+ [
18826
+ executeManaged,
18827
+ internalAmount,
18828
+ internalSlippage,
18829
+ isSell,
18830
+ onPrimaryAction,
18831
+ scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.id,
18832
+ scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id,
18833
+ scopedSelectedOutcomeId,
18834
+ smartRoute.data,
18835
+ tradingLabels.quoteUnavailable
18836
+ ]
18275
18837
  );
18276
18838
  const handleSkipToSuccess = (0, import_react31.useCallback)(() => {
18277
18839
  const primaryFilledEvent = executionProgress.terminalOrderEvents.find(
@@ -19486,7 +20048,7 @@ var HomeSearchResults = ({
19486
20048
  const eventListTabs = useEventListTabs();
19487
20049
  const { headerRef, titleRef, shouldUseSelectOverflow } = useEventListTabsHeaderOverflow(eventListTabs);
19488
20050
  const visibleVenues = (0, import_react35.useMemo)(
19489
- () => disabledVenues.length === 0 ? void 0 : import_sdk17.VENUES.filter(
20051
+ () => disabledVenues.length === 0 ? void 0 : import_sdk18.VENUES.filter(
19490
20052
  (v) => !disabledVenues.includes(v)
19491
20053
  ),
19492
20054
  [disabledVenues]
@@ -19920,7 +20482,7 @@ HomePage.displayName = "HomePage";
19920
20482
 
19921
20483
  // src/pages/user-profile/index.tsx
19922
20484
  var import_hooks59 = require("@agg-build/hooks");
19923
- var import_sdk18 = require("@agg-build/sdk");
20485
+ var import_sdk19 = require("@agg-build/sdk");
19924
20486
  var import_react37 = require("react");
19925
20487
 
19926
20488
  // src/pages/user-profile/chain-display.ts
@@ -20660,7 +21222,7 @@ var toneTextClassName = (tone) => {
20660
21222
  if (tone === "negative") return "text-agg-error";
20661
21223
  return "text-agg-muted-foreground";
20662
21224
  };
20663
- var OutcomePill = ({ label: label2 }) => /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("span", { className: "agg-position-outcome inline-flex items-center justify-center rounded-full bg-agg-secondary-hover px-4 py-[6px]", children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("span", { className: "whitespace-nowrap font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground", children: label2 }) });
21225
+ var OutcomePill = ({ label: label2 }) => /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("span", { className: "agg-position-outcome max-w-[120px] inline-flex items-center justify-center rounded-full bg-agg-secondary-hover px-4 py-[6px]", children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("span", { className: "whitespace-nowrap font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground truncate", children: label2 }) });
20664
21226
  var VenueShares = ({
20665
21227
  model,
20666
21228
  className,
@@ -20843,7 +21405,7 @@ var PositionRow = ({
20843
21405
  {
20844
21406
  model,
20845
21407
  keyPrefix: "desktop",
20846
- className: "agg-position-venues flex min-w-0 flex-1 flex-wrap content-center items-center gap-x-3 gap-y-2"
21408
+ className: "agg-position-venues flex flex-1 flex-wrap content-center items-center gap-x-3 gap-y-2"
20847
21409
  }
20848
21410
  )
20849
21411
  ] })
@@ -21540,6 +22102,7 @@ var UserInfoCard = ({
21540
22102
  content: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("p", { className: "text-center", children: labels.auth.depositGeoBlocked }),
21541
22103
  size: "small",
21542
22104
  side: "bottom",
22105
+ sideOffset: 4,
21543
22106
  children
21544
22107
  }
21545
22108
  ),
@@ -21861,10 +22424,10 @@ var toTokenAmountLabel = ({
21861
22424
  return `${prefix}${formatTokenAmountTwoDecimals(amountRaw, tokenSymbol, chainId)} ${tokenSymbol}`;
21862
22425
  };
21863
22426
  var POSITION_ROW_VENUE_ORDER = [
21864
- import_sdk18.Venue.polymarket,
21865
- import_sdk18.Venue.kalshi,
21866
- import_sdk18.Venue.opinion,
21867
- import_sdk18.Venue.limitless
22427
+ import_sdk19.Venue.polymarket,
22428
+ import_sdk19.Venue.kalshi,
22429
+ import_sdk19.Venue.opinion,
22430
+ import_sdk19.Venue.limitless
21868
22431
  ];
21869
22432
  function venueBreakdownSortKey(venue) {
21870
22433
  const idx = POSITION_ROW_VENUE_ORDER.indexOf(venue);
@@ -22020,6 +22583,8 @@ var UserProfilePage = ({
22020
22583
  try {
22021
22584
  yield redeemMutation.mutateAsync({ venueMarketOutcomeIds });
22022
22585
  yield queryClient.invalidateQueries({ queryKey: ["current-user"] });
22586
+ } catch (err) {
22587
+ console.error("[UserProfilePage] redeem failed", err);
22023
22588
  } finally {
22024
22589
  setInternalClaimingIds((prev) => {
22025
22590
  const _a2 = prev, { [claimKey]: _removed } = _a2, rest = __objRest(_a2, [__restKey(claimKey)]);
@@ -22402,7 +22967,10 @@ var UserProfilePage = ({
22402
22967
  /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(
22403
22968
  "div",
22404
22969
  {
22405
- className: cn("agg-profile-side-panels flex flex-col gap-4", classNames == null ? void 0 : classNames.rightColumn),
22970
+ className: cn(
22971
+ "agg-profile-side-panels flex flex-col-reverse md:flex-col gap-4",
22972
+ classNames == null ? void 0 : classNames.rightColumn
22973
+ ),
22406
22974
  children: [
22407
22975
  /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(PositionsValueCard, { valueLabel: positionsValueLabel }),
22408
22976
  /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
@@ -24693,7 +25261,7 @@ var import_hooks78 = require("@agg-build/hooks");
24693
25261
  var Dialog6 = __toESM(require("@radix-ui/react-dialog"));
24694
25262
 
24695
25263
  // src/onboarding/onboarding-modal.constants.ts
24696
- var import_sdk19 = require("@agg-build/sdk");
25264
+ var import_sdk20 = require("@agg-build/sdk");
24697
25265
  var HOW_IT_WORKS_FEATURE_KEYS = [
24698
25266
  "createAccount",
24699
25267
  "linkAccounts",
@@ -24705,7 +25273,7 @@ var ONBOARDING_STEPS = {
24705
25273
  PROFILE_SETUP: 1,
24706
25274
  CONNECT_ACCOUNTS: 2
24707
25275
  };
24708
- var ONCHAIN_VENUES = [import_sdk19.Venue.polymarket, import_sdk19.Venue.opinion, import_sdk19.Venue.predict];
25276
+ var ONCHAIN_VENUES = [import_sdk20.Venue.polymarket, import_sdk20.Venue.opinion, import_sdk20.Venue.predict];
24709
25277
 
24710
25278
  // src/onboarding/steps/how-it-works.tsx
24711
25279
  var import_react43 = require("react");
@@ -24925,7 +25493,7 @@ var ProfileSetupStep = ({ onContinue }) => {
24925
25493
  ProfileSetupStep.displayName = "ProfileSetupStep";
24926
25494
 
24927
25495
  // src/onboarding/steps/connect-accounts.tsx
24928
- var import_sdk20 = require("@agg-build/sdk");
25496
+ var import_sdk21 = require("@agg-build/sdk");
24929
25497
  var import_hooks75 = require("@agg-build/hooks");
24930
25498
  var import_jsx_runtime170 = require("react/jsx-runtime");
24931
25499
  var OnchainVenueLogos = () => {
@@ -25026,7 +25594,7 @@ var ConnectAccountsStep = ({
25026
25594
  logos: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("div", { className: "sm:flex sm:w-14 sm:items-center sm:justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
25027
25595
  VenueLogo,
25028
25596
  {
25029
- venue: import_sdk20.Venue.kalshi,
25597
+ venue: import_sdk21.Venue.kalshi,
25030
25598
  variant: "logo",
25031
25599
  size: "large",
25032
25600
  className: "h-6 w-6 sm:h-9 sm:w-9"
@@ -25057,7 +25625,7 @@ var ConnectAccountsStep = ({
25057
25625
  ConnectAccountsStep.displayName = "ConnectAccountsStep";
25058
25626
 
25059
25627
  // src/onboarding/steps/connect-kalshi-modal.tsx
25060
- var import_sdk21 = require("@agg-build/sdk");
25628
+ var import_sdk22 = require("@agg-build/sdk");
25061
25629
  var import_react45 = require("react");
25062
25630
  var import_hooks76 = require("@agg-build/hooks");
25063
25631
  var Dialog4 = __toESM(require("@radix-ui/react-dialog"));
@@ -25140,7 +25708,7 @@ var ConnectKalshiModal = ({
25140
25708
  /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
25141
25709
  VenueLogo,
25142
25710
  {
25143
- venue: import_sdk21.Venue.kalshi,
25711
+ venue: import_sdk22.Venue.kalshi,
25144
25712
  variant: "logo",
25145
25713
  size: "large",
25146
25714
  className: "h-[60px] w-[60px]"
@@ -25525,7 +26093,7 @@ var OnboardingModal = ({
25525
26093
  OnboardingModal.displayName = "OnboardingModal";
25526
26094
 
25527
26095
  // src/profile/index.tsx
25528
- var import_sdk22 = require("@agg-build/sdk");
26096
+ var import_sdk23 = require("@agg-build/sdk");
25529
26097
  var import_react50 = require("react");
25530
26098
  var import_hooks81 = require("@agg-build/hooks");
25531
26099
 
@@ -25875,7 +26443,7 @@ AccountsWalletsTab.displayName = "AccountsWalletsTab";
25875
26443
 
25876
26444
  // src/profile/index.tsx
25877
26445
  var import_jsx_runtime176 = require("react/jsx-runtime");
25878
- var EVM_WALLET_VENUES = [import_sdk22.Venue.polymarket, import_sdk22.Venue.predict, import_sdk22.Venue.opinion];
26446
+ var EVM_WALLET_VENUES = [import_sdk23.Venue.polymarket, import_sdk23.Venue.predict, import_sdk23.Venue.opinion];
25879
26447
  var ProfileModal = ({
25880
26448
  open,
25881
26449
  onOpenChange,
@@ -26357,7 +26925,14 @@ var GeoBlockModal = ({
26357
26925
  maxWidth: "480px",
26358
26926
  classNames: { container: cn("!rounded-agg-2xl", classNames == null ? void 0 : classNames.container) },
26359
26927
  children: [
26360
- /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Modal.Header, { title: "", hideBorder: true, classNames: { container: "px-8 pt-8 pb-0" } }),
26928
+ /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
26929
+ Modal.Header,
26930
+ {
26931
+ title: "",
26932
+ hideBorder: true,
26933
+ classNames: { root: "min-h-0", container: "px-8 pt-6! pb-0!" }
26934
+ }
26935
+ ),
26361
26936
  /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Modal.Body, { classNames: { root: cn("!px-10 !pb-12 !pt-0", classNames == null ? void 0 : classNames.body) }, children: /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)("div", { className: "flex flex-col items-center gap-8", children: [
26362
26937
  /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
26363
26938
  Icon,