@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/pages.js CHANGED
@@ -98,7 +98,7 @@ module.exports = __toCommonJS(pages_exports);
98
98
 
99
99
  // src/pages/home/index.tsx
100
100
  var import_hooks53 = require("@agg-build/hooks");
101
- var import_sdk17 = require("@agg-build/sdk");
101
+ var import_sdk18 = require("@agg-build/sdk");
102
102
  var import_react31 = require("react");
103
103
 
104
104
  // src/events/item/index.tsx
@@ -3509,7 +3509,7 @@ var SWITCH_BUTTON_ANIMATION_DURATION_MS = 350;
3509
3509
  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";
3510
3510
  var SWITCH_BUTTON_TRACK_CLASS_NAME = "agg-switch-button-track relative grid min-w-0 flex-1 items-center";
3511
3511
  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";
3512
- 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";
3512
+ 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";
3513
3513
 
3514
3514
  // src/primitives/switch-button/switch-button.utils.ts
3515
3515
  var resolveActiveIndex = (options, value) => {
@@ -8254,6 +8254,7 @@ var Tooltip = ({
8254
8254
  side = "top",
8255
8255
  delayDuration = 150,
8256
8256
  collisionPadding = 12,
8257
+ sideOffset = 0,
8257
8258
  classNames,
8258
8259
  "aria-label": ariaLabel
8259
8260
  }) => {
@@ -8281,7 +8282,7 @@ var Tooltip = ({
8281
8282
  TooltipPrimitive.Content,
8282
8283
  {
8283
8284
  side,
8284
- sideOffset: 0,
8285
+ sideOffset,
8285
8286
  collisionPadding,
8286
8287
  className: cn(
8287
8288
  "group/agg-tooltip",
@@ -9564,6 +9565,18 @@ var marketChartCandleToScaledCandlePoint = (candle, transformProbability) => {
9564
9565
  v: candle.volume
9565
9566
  };
9566
9567
  };
9568
+ var venueCandlesToLinePoints = (venueData, transformProbability) => {
9569
+ const candles = venueData.liveCandle && !venueData.candles.some((candle) => {
9570
+ var _a;
9571
+ return candle.time === ((_a = venueData.liveCandle) == null ? void 0 : _a.time);
9572
+ }) ? [...venueData.candles, venueData.liveCandle] : venueData.liveCandle ? venueData.candles.map(
9573
+ (candle) => {
9574
+ var _a;
9575
+ return candle.time === ((_a = venueData.liveCandle) == null ? void 0 : _a.time) ? venueData.liveCandle : candle;
9576
+ }
9577
+ ) : venueData.candles;
9578
+ return candles.map((candle) => marketChartCandleToLineChartPoint(candle, transformProbability));
9579
+ };
9567
9580
  var resolveMarketChartVenueSeries = ({
9568
9581
  chartData,
9569
9582
  transformProbability
@@ -9571,9 +9584,7 @@ var resolveMarketChartVenueSeries = ({
9571
9584
  if (!chartData) return [];
9572
9585
  return Object.entries(chartData.venues).map(([venue, venueData]) => ({
9573
9586
  venue,
9574
- points: venueData.candles.map(
9575
- (candle) => marketChartCandleToLineChartPoint(candle, transformProbability)
9576
- )
9587
+ points: venueCandlesToLinePoints(venueData, transformProbability)
9577
9588
  })).filter((item) => item.points.length > 0);
9578
9589
  };
9579
9590
  var resolveAggregatedCandleSource = (candles) => {
@@ -9626,13 +9637,24 @@ var resolveMarketChartDisplaySeries = ({
9626
9637
  if (selectedVenue) {
9627
9638
  return venueEntries.map(([venue, venueData]) => ({
9628
9639
  venue,
9629
- points: venueData.candles.map(
9630
- (candle) => marketChartCandleToLineChartPoint(candle, transformProbability)
9631
- )
9640
+ points: venueCandlesToLinePoints(venueData, transformProbability)
9632
9641
  })).filter((item) => item.points.length > 0);
9633
9642
  }
9634
9643
  const aggregatedCandles = aggregateMarketChartCandles(
9635
- venueEntries.flatMap(([, venueData]) => venueData.candles)
9644
+ venueEntries.flatMap(([, venueData]) => {
9645
+ const closed = venueData.candles;
9646
+ if (!venueData.liveCandle) return closed;
9647
+ const hasOverlap = closed.some((candle) => {
9648
+ var _a;
9649
+ return candle.time === ((_a = venueData.liveCandle) == null ? void 0 : _a.time);
9650
+ });
9651
+ return hasOverlap ? closed.map(
9652
+ (candle) => {
9653
+ var _a;
9654
+ return candle.time === ((_a = venueData.liveCandle) == null ? void 0 : _a.time) ? venueData.liveCandle : candle;
9655
+ }
9656
+ ) : [...closed, venueData.liveCandle];
9657
+ })
9636
9658
  );
9637
9659
  if (aggregatedCandles.length === 0) return [];
9638
9660
  return [
@@ -11442,7 +11464,9 @@ var EventListItemDetailsGraphSection = ({
11442
11464
  }
11443
11465
  ),
11444
11466
  classNames: {
11445
- root: cn("h-9 shrink-0 border px-4 text-agg-base leading-agg-6")
11467
+ root: cn(
11468
+ "shrink-0 border px-4 h-8 text-agg-sm leading-agg-5 md:h-9 md:text-agg-base md:leading-agg-6"
11469
+ )
11446
11470
  },
11447
11471
  isActive: isActiveVenue
11448
11472
  }
@@ -12123,8 +12147,20 @@ var OrderbookRow = ({
12123
12147
  }).map(([venue]) => venue);
12124
12148
  const venues = entry.row.venues && entry.row.venues.length > 0 ? entry.row.venues : venuesFromBreakdown.length > 0 ? venuesFromBreakdown : [entry.row.venue];
12125
12149
  const barPercent = Math.max(2, Number((entry.unifiedBarScale * 100).toFixed(2)));
12126
- return /* @__PURE__ */ (0, import_jsx_runtime128.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: [
12127
- /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)("div", { className: "md:relative min-w-0 flex-1 self-stretch", children: [
12150
+ return /* @__PURE__ */ (0, import_jsx_runtime128.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: [
12151
+ /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
12152
+ "div",
12153
+ {
12154
+ "aria-hidden": "true",
12155
+ className: cn(
12156
+ "agg-orderbook-bar md:hidden absolute inset-y-0 left-0",
12157
+ barClassName,
12158
+ getMotionClassName(enableAnimations, "transition-[width] duration-200 ease-in-out")
12159
+ ),
12160
+ style: { width: `${barPercent}%` }
12161
+ }
12162
+ ),
12163
+ /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)("div", { className: "hidden md:block md:relative min-w-0 flex-1 self-stretch", children: [
12128
12164
  /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
12129
12165
  "div",
12130
12166
  {
@@ -12227,8 +12263,8 @@ var Orderbook = ({
12227
12263
  spreadEntry
12228
12264
  ]);
12229
12265
  return /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)("div", { className: cn("agg-orderbook-unified flex flex-col", className), children: [
12230
- /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)("div", { className: "flex h-9 items-center gap-2.5 overflow-clip border-b border-agg-separator pr-5 md:gap-10", children: [
12231
- /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("span", { className: "flex min-w-0 flex-1 items-center gap-2 pl-5", children: /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("span", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground", children: labels.tradeOutcome }) }),
12266
+ /* @__PURE__ */ (0, import_jsx_runtime128.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: [
12267
+ /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("span", { className: "hidden md:flex min-w-0 flex-1 items-center gap-2 pl-5", children: /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("span", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground", children: labels.tradeOutcome }) }),
12232
12268
  /* @__PURE__ */ (0, import_jsx_runtime128.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 }),
12233
12269
  /* @__PURE__ */ (0, import_jsx_runtime128.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 }),
12234
12270
  /* @__PURE__ */ (0, import_jsx_runtime128.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 })
@@ -13063,7 +13099,7 @@ var MarketDetailsContent = ({
13063
13099
  "span",
13064
13100
  {
13065
13101
  className: cn(
13066
- "min-w-35 inline-flex h-9 items-center justify-center gap-2 rounded-agg-full",
13102
+ "w-full md:w-auto md:min-w-35 inline-flex h-9 items-center justify-center gap-2 rounded-agg-full",
13067
13103
  "border px-5 py-1.5 text-agg-sm font-agg-bold",
13068
13104
  getMotionClassName(
13069
13105
  enableAnimations,
@@ -13897,6 +13933,447 @@ var PLACE_ORDER_OUTCOME_BUTTON_CLASS_NAMES = {
13897
13933
  inactive: "border-transparent bg-agg-secondary-hover font-agg-normal text-agg-foreground hover:bg-agg-tertiary"
13898
13934
  };
13899
13935
 
13936
+ // src/trading/place-order/index.place-order.execution-steps.ts
13937
+ var import_sdk17 = require("@agg-build/sdk");
13938
+ var WAIT_STEP_TYPES = /* @__PURE__ */ new Set(["_wait", "wait"]);
13939
+ var CHECKING_BALANCE_STEP_TYPES = /* @__PURE__ */ new Set([
13940
+ "check-balance",
13941
+ "check-position",
13942
+ "position-reserve",
13943
+ "position-release"
13944
+ ]);
13945
+ var VENUE_BUY_SELL_REGEX = /^(?:buy|sell)-([a-z]+)$/;
13946
+ var VENUE_FINALIZE_REGEX = /^([a-z]+)-finalize$/;
13947
+ var VENUE_NAME_MAP = {
13948
+ kalshi: import_sdk17.Venue.kalshi,
13949
+ polymarket: import_sdk17.Venue.polymarket,
13950
+ limitless: import_sdk17.Venue.limitless,
13951
+ opinion: import_sdk17.Venue.opinion,
13952
+ predict: import_sdk17.Venue.predict,
13953
+ probable: import_sdk17.Venue.probable,
13954
+ myriad: import_sdk17.Venue.myriad,
13955
+ hyperliquid: import_sdk17.Venue.hyperliquid
13956
+ };
13957
+ var parseVenueName = (raw) => VENUE_NAME_MAP[raw];
13958
+ var NON_VENUE_FINALIZE_PREFIXES = /* @__PURE__ */ new Set(["bridge"]);
13959
+ var classifyExecutionStepType = (stepType) => {
13960
+ if (!stepType) return null;
13961
+ if (WAIT_STEP_TYPES.has(stepType)) return null;
13962
+ if (CHECKING_BALANCE_STEP_TYPES.has(stepType)) {
13963
+ return { kind: "checking-balance" };
13964
+ }
13965
+ const buySellMatch = stepType.match(VENUE_BUY_SELL_REGEX);
13966
+ if (buySellMatch) {
13967
+ const venue = parseVenueName(buySellMatch[1]);
13968
+ if (venue) return { kind: "executing-venue", venue };
13969
+ }
13970
+ const finalizeMatch = stepType.match(VENUE_FINALIZE_REGEX);
13971
+ if (finalizeMatch && !NON_VENUE_FINALIZE_PREFIXES.has(finalizeMatch[1])) {
13972
+ const venue = parseVenueName(finalizeMatch[1]);
13973
+ if (venue) return { kind: "executing-venue", venue };
13974
+ }
13975
+ if (stepType === "submit-verify-order-status") {
13976
+ return null;
13977
+ }
13978
+ return { kind: "submitting" };
13979
+ };
13980
+ var buildPhaseTimeline = (dag) => {
13981
+ const timeline = [];
13982
+ const completed = new Set(dag.completedSequences);
13983
+ for (let seq = 1; seq <= dag.totalSteps; seq++) {
13984
+ const stepType = dag.stepTypes[seq];
13985
+ if (!stepType) continue;
13986
+ const classified = classifyExecutionStepType(stepType);
13987
+ if (!classified) continue;
13988
+ const isCompleted = completed.has(seq);
13989
+ const last = timeline[timeline.length - 1];
13990
+ if (last && last.kind === classified.kind && last.venue === classified.venue) {
13991
+ last.lastSeq = seq;
13992
+ last.allCompleted = last.allCompleted && isCompleted;
13993
+ continue;
13994
+ }
13995
+ timeline.push({
13996
+ kind: classified.kind,
13997
+ venue: classified.venue,
13998
+ firstSeq: seq,
13999
+ lastSeq: seq,
14000
+ allCompleted: isCompleted
14001
+ });
14002
+ }
14003
+ return timeline;
14004
+ };
14005
+ var phaseRowId = (phase) => phase.venue ? `${phase.kind}:${phase.venue}` : phase.kind;
14006
+ var phaseRowLabel = (phase, labels) => {
14007
+ switch (phase.kind) {
14008
+ case "finding-route":
14009
+ return labels.findingBestRoute;
14010
+ case "checking-balance":
14011
+ return labels.checkingBalance;
14012
+ case "submitting":
14013
+ return labels.submittingOrderProgress;
14014
+ case "wallet-confirm":
14015
+ return labels.confirmTransactionInWallet;
14016
+ case "executing-venue":
14017
+ return labels.executingOnVenue(getTradingVenueLabel(phase.venue));
14018
+ case "filled":
14019
+ return labels.executionConfirmed;
14020
+ case "failed":
14021
+ return labels.orderFailureTitle;
14022
+ }
14023
+ };
14024
+ var buildSubmissionDisplayRows = ({
14025
+ phase,
14026
+ dagProgress,
14027
+ executionVenue,
14028
+ isAwaitingWalletConfirmation,
14029
+ labels
14030
+ }) => {
14031
+ if (phase === "finding-route") {
14032
+ return [
14033
+ {
14034
+ id: "finding-route",
14035
+ label: labels.findingBestRoute,
14036
+ status: "pending"
14037
+ }
14038
+ ];
14039
+ }
14040
+ const rows = [
14041
+ {
14042
+ id: "finding-route",
14043
+ label: labels.findingBestRoute,
14044
+ status: "complete"
14045
+ }
14046
+ ];
14047
+ const pushPhase = (phaseEntry, status) => {
14048
+ const id = phaseRowId(phaseEntry);
14049
+ if (rows.some((row) => row.id === id)) return;
14050
+ rows.push({
14051
+ id,
14052
+ label: phaseRowLabel(phaseEntry, labels),
14053
+ status,
14054
+ venue: phaseEntry.venue
14055
+ });
14056
+ };
14057
+ if (dagProgress && dagProgress.totalSteps > 0) {
14058
+ const timeline = buildPhaseTimeline(dagProgress);
14059
+ let activeEmitted = false;
14060
+ for (const entry of timeline) {
14061
+ const id = phaseRowId(entry);
14062
+ const alreadyShown = rows.some((row) => row.id === id);
14063
+ if (entry.allCompleted) {
14064
+ if (alreadyShown) continue;
14065
+ pushPhase(entry, "complete");
14066
+ continue;
14067
+ }
14068
+ if (activeEmitted) break;
14069
+ if (alreadyShown) continue;
14070
+ if (isAwaitingWalletConfirmation && entry.kind === "submitting") {
14071
+ pushPhase({ kind: "wallet-confirm" }, "pending");
14072
+ } else {
14073
+ pushPhase(entry, "pending");
14074
+ }
14075
+ activeEmitted = true;
14076
+ }
14077
+ if (!activeEmitted) {
14078
+ const last = rows[rows.length - 1];
14079
+ if (last && last.id.startsWith("executing-venue")) {
14080
+ last.status = "pending";
14081
+ } else {
14082
+ const fallbackVenue = executionVenue;
14083
+ rows.push({
14084
+ id: fallbackVenue ? `executing-venue:${fallbackVenue}` : "executing-venue",
14085
+ label: phaseRowLabel({ kind: "executing-venue", venue: fallbackVenue }, labels),
14086
+ status: "pending",
14087
+ venue: fallbackVenue
14088
+ });
14089
+ }
14090
+ }
14091
+ return rows;
14092
+ }
14093
+ if (isAwaitingWalletConfirmation) {
14094
+ pushPhase({ kind: "wallet-confirm" }, "pending");
14095
+ return rows;
14096
+ }
14097
+ if (phase === "submitting") {
14098
+ pushPhase({ kind: "submitting" }, "pending");
14099
+ return rows;
14100
+ }
14101
+ pushPhase({ kind: "submitting" }, "complete");
14102
+ pushPhase({ kind: "executing-venue", venue: executionVenue }, "pending");
14103
+ return rows;
14104
+ };
14105
+
14106
+ // src/trading/place-order/index.place-order.execution-debug.ts
14107
+ var REDACTED = "[redacted]";
14108
+ var SENSITIVE_FIELD_PATTERNS = [
14109
+ "token",
14110
+ "authorization",
14111
+ "cookie",
14112
+ "secret",
14113
+ "signature",
14114
+ "privatekey",
14115
+ "private_key",
14116
+ "accesstoken",
14117
+ "access_token",
14118
+ "refreshtoken",
14119
+ "refresh_token",
14120
+ "jwt",
14121
+ "password",
14122
+ "apikey",
14123
+ "api_key",
14124
+ "email",
14125
+ "headers"
14126
+ ];
14127
+ var isSensitiveFieldName = (name) => {
14128
+ const normalized = name.toLowerCase();
14129
+ return SENSITIVE_FIELD_PATTERNS.some((pattern) => normalized.includes(pattern));
14130
+ };
14131
+ var sanitizeExecutionDebugValue = (input) => {
14132
+ const ancestors = /* @__PURE__ */ new Set();
14133
+ const walk = (value) => {
14134
+ if (value === null || value === void 0) return value;
14135
+ if (typeof value !== "object") return value;
14136
+ if (ancestors.has(value)) return "[circular]";
14137
+ ancestors.add(value);
14138
+ try {
14139
+ if (Array.isArray(value)) {
14140
+ return value.map((entry) => walk(entry));
14141
+ }
14142
+ if (value instanceof Error) {
14143
+ return {
14144
+ name: value.name,
14145
+ message: value.message,
14146
+ stack: value.stack
14147
+ };
14148
+ }
14149
+ const out = {};
14150
+ for (const [key, raw] of Object.entries(value)) {
14151
+ if (isSensitiveFieldName(key)) {
14152
+ out[key] = REDACTED;
14153
+ continue;
14154
+ }
14155
+ out[key] = walk(raw);
14156
+ }
14157
+ return out;
14158
+ } finally {
14159
+ ancestors.delete(value);
14160
+ }
14161
+ };
14162
+ return walk(input);
14163
+ };
14164
+ var cloneEnvironment = (env) => __spreadProps(__spreadValues({}, env), {
14165
+ packageVersions: env.packageVersions ? __spreadValues({}, env.packageVersions) : void 0
14166
+ });
14167
+ var buildEnvironment = (overrides) => {
14168
+ var _a;
14169
+ const url = typeof window !== "undefined" ? (_a = window.location) == null ? void 0 : _a.href : void 0;
14170
+ const userAgent = typeof navigator !== "undefined" && typeof navigator.userAgent === "string" ? navigator.userAgent : void 0;
14171
+ return __spreadValues({
14172
+ url,
14173
+ userAgent,
14174
+ capturedAt: Date.now()
14175
+ }, overrides);
14176
+ };
14177
+ var generateAttemptId = () => {
14178
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
14179
+ return crypto.randomUUID();
14180
+ }
14181
+ return `attempt-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
14182
+ };
14183
+ var createExecutionDebugStore = (initial) => {
14184
+ let attempts = [];
14185
+ let environment = buildEnvironment(initial);
14186
+ const findAttempt = (attemptId) => attempts.find((attempt) => attempt.attemptId === attemptId);
14187
+ const touch = (attempt) => {
14188
+ attempt.updatedAt = Date.now();
14189
+ };
14190
+ return {
14191
+ appendAttempt(input = {}) {
14192
+ var _a, _b;
14193
+ const now = Date.now();
14194
+ const attempt = {
14195
+ attemptId: (_a = input.attemptId) != null ? _a : generateAttemptId(),
14196
+ startedAt: now,
14197
+ updatedAt: now,
14198
+ status: (_b = input.status) != null ? _b : "quoting",
14199
+ quoteId: input.quoteId,
14200
+ orderId: input.orderId,
14201
+ orderIds: input.orderIds,
14202
+ quote: input.quote,
14203
+ selectedRoute: input.selectedRoute,
14204
+ bridge: input.bridge,
14205
+ venueExecution: input.venueExecution,
14206
+ rawEvents: [],
14207
+ normalizedSteps: [],
14208
+ errors: []
14209
+ };
14210
+ attempts = [...attempts, attempt];
14211
+ return attempt;
14212
+ },
14213
+ updateAttempt(attemptId, patch) {
14214
+ const attempt = findAttempt(attemptId);
14215
+ if (!attempt) return;
14216
+ if (patch.status !== void 0) attempt.status = patch.status;
14217
+ if (patch.quoteId !== void 0) attempt.quoteId = patch.quoteId;
14218
+ if (patch.orderId !== void 0) attempt.orderId = patch.orderId;
14219
+ if (patch.orderIds !== void 0) attempt.orderIds = patch.orderIds;
14220
+ if (patch.quote !== void 0) attempt.quote = patch.quote;
14221
+ if (patch.selectedRoute !== void 0) attempt.selectedRoute = patch.selectedRoute;
14222
+ if (patch.bridge !== void 0) attempt.bridge = patch.bridge;
14223
+ if (patch.venueExecution !== void 0) attempt.venueExecution = patch.venueExecution;
14224
+ if (patch.finalStatus !== void 0) attempt.finalStatus = patch.finalStatus;
14225
+ touch(attempt);
14226
+ },
14227
+ appendEvent(attemptId, event) {
14228
+ var _a;
14229
+ const attempt = findAttempt(attemptId);
14230
+ if (!attempt) return;
14231
+ attempt.rawEvents.push({
14232
+ kind: event.kind,
14233
+ label: event.label,
14234
+ data: event.data,
14235
+ timestamp: (_a = event.timestamp) != null ? _a : Date.now()
14236
+ });
14237
+ touch(attempt);
14238
+ },
14239
+ appendError(attemptId, error) {
14240
+ var _a;
14241
+ const attempt = findAttempt(attemptId);
14242
+ if (!attempt) return;
14243
+ attempt.errors.push({
14244
+ message: error.message,
14245
+ name: error.name,
14246
+ code: error.code,
14247
+ stack: error.stack,
14248
+ failedStep: error.failedStep,
14249
+ data: error.data,
14250
+ timestamp: (_a = error.timestamp) != null ? _a : Date.now()
14251
+ });
14252
+ touch(attempt);
14253
+ },
14254
+ setNormalizedSteps(attemptId, steps) {
14255
+ const attempt = findAttempt(attemptId);
14256
+ if (!attempt) return;
14257
+ attempt.normalizedSteps = steps;
14258
+ touch(attempt);
14259
+ },
14260
+ getSnapshot() {
14261
+ return {
14262
+ attempts: attempts.map((attempt) => __spreadProps(__spreadValues({}, attempt), {
14263
+ rawEvents: [...attempt.rawEvents],
14264
+ normalizedSteps: [...attempt.normalizedSteps],
14265
+ errors: [...attempt.errors]
14266
+ })),
14267
+ environment: cloneEnvironment(environment)
14268
+ };
14269
+ },
14270
+ getFailedAttempts() {
14271
+ return attempts.filter(
14272
+ (attempt) => attempt.status === "failed" || attempt.finalStatus === "failed" || attempt.errors.length > 0
14273
+ ).map((attempt) => __spreadProps(__spreadValues({}, attempt), {
14274
+ rawEvents: [...attempt.rawEvents],
14275
+ normalizedSteps: [...attempt.normalizedSteps],
14276
+ errors: [...attempt.errors]
14277
+ }));
14278
+ },
14279
+ clear() {
14280
+ attempts = [];
14281
+ environment = buildEnvironment(initial);
14282
+ }
14283
+ };
14284
+ };
14285
+ var writeClipboardLegacy = (text) => {
14286
+ if (typeof document === "undefined") return false;
14287
+ const textarea = document.createElement("textarea");
14288
+ textarea.value = text;
14289
+ textarea.setAttribute("readonly", "");
14290
+ textarea.style.position = "fixed";
14291
+ textarea.style.top = "-1000px";
14292
+ textarea.style.opacity = "0";
14293
+ document.body.appendChild(textarea);
14294
+ try {
14295
+ textarea.select();
14296
+ return document.execCommand("copy");
14297
+ } catch (e) {
14298
+ return false;
14299
+ } finally {
14300
+ document.body.removeChild(textarea);
14301
+ }
14302
+ };
14303
+ var tryWriteClipboard = (text, consoleImpl) => __async(null, null, function* () {
14304
+ var _a;
14305
+ if (typeof navigator !== "undefined" && ((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
14306
+ try {
14307
+ yield navigator.clipboard.writeText(text);
14308
+ consoleImpl.info("[agg-execution-debug] Copied execution data to clipboard.");
14309
+ return;
14310
+ } catch (e) {
14311
+ }
14312
+ }
14313
+ if (writeClipboardLegacy(text)) {
14314
+ consoleImpl.info("[agg-execution-debug] Copied execution data to clipboard.");
14315
+ return;
14316
+ }
14317
+ consoleImpl.warn(
14318
+ "[agg-execution-debug] Clipboard copy was blocked by the browser. The JSON is logged below \u2014 right-click the entry and copy."
14319
+ );
14320
+ consoleImpl.log(text);
14321
+ });
14322
+ var installExecutionDebugWindow = ({
14323
+ store,
14324
+ consoleImpl
14325
+ }) => {
14326
+ if (typeof window === "undefined") return () => {
14327
+ };
14328
+ const targetConsole = consoleImpl != null ? consoleImpl : console;
14329
+ const previous = {
14330
+ executionData: window.executionData,
14331
+ getExecutionData: window.getExecutionData,
14332
+ getFailedExecutionData: window.getFailedExecutionData,
14333
+ clearExecutionData: window.clearExecutionData,
14334
+ storeRef: window.__aggExecutionDebugStore
14335
+ };
14336
+ const refresh = () => {
14337
+ window.executionData = sanitizeExecutionDebugValue(store.getSnapshot());
14338
+ };
14339
+ refresh();
14340
+ window.__aggExecutionDebugStore = store;
14341
+ window.getExecutionData = () => {
14342
+ const data = sanitizeExecutionDebugValue(store.getSnapshot());
14343
+ window.executionData = data;
14344
+ void tryWriteClipboard(JSON.stringify(data, null, 2), targetConsole);
14345
+ return data;
14346
+ };
14347
+ window.getFailedExecutionData = () => {
14348
+ const failed = sanitizeExecutionDebugValue({ attempts: store.getFailedAttempts() });
14349
+ void tryWriteClipboard(JSON.stringify(failed, null, 2), targetConsole);
14350
+ return failed;
14351
+ };
14352
+ window.clearExecutionData = () => {
14353
+ store.clear();
14354
+ refresh();
14355
+ };
14356
+ targetConsole.info(
14357
+ "AGG execution debug enabled. Run window.getFailedExecutionData() after a failed order to copy logs."
14358
+ );
14359
+ return () => {
14360
+ if (typeof window === "undefined") return;
14361
+ window.executionData = previous.executionData;
14362
+ window.getExecutionData = previous.getExecutionData;
14363
+ window.getFailedExecutionData = previous.getFailedExecutionData;
14364
+ window.clearExecutionData = previous.clearExecutionData;
14365
+ window.__aggExecutionDebugStore = previous.storeRef;
14366
+ };
14367
+ };
14368
+ var enableExecutionDebugInBrowser = (initial) => {
14369
+ if (typeof window === "undefined") return null;
14370
+ const existing = window.__aggExecutionDebugStore;
14371
+ if (existing) return existing;
14372
+ const store = createExecutionDebugStore(initial);
14373
+ installExecutionDebugWindow({ store });
14374
+ return store;
14375
+ };
14376
+
13900
14377
  // src/trading/place-order/index.place-order.utils.ts
13901
14378
  var routePriceLabelFormatter = new Intl.NumberFormat("en-US", {
13902
14379
  minimumFractionDigits: 0,
@@ -14107,18 +14584,19 @@ var buildLiveRouteCards = ({
14107
14584
  const parsedPrimaryVenue = parseVenue(primaryVenue);
14108
14585
  const isSplit = quoteData.fills.length > 1;
14109
14586
  const primaryWinnerVenue = quoteData.fills.length === 1 ? primaryVenue : void 0;
14110
- const isPrimaryRouteGeoBlocked = quoteData.fills.length > 0 && quoteData.fills.every((f) => geoBlockedVenues.has(f.venue));
14587
+ const isPrimaryRouteGeoBlocked = quoteData.fills.length > 0 && quoteData.fills.some((f) => geoBlockedVenues.has(f.venue));
14111
14588
  const primaryCard = primaryResult ? isPrimaryRouteGeoBlocked ? {
14112
14589
  id: "live-route",
14113
14590
  hint: labels.venueUnavailableInRegion,
14114
- kind: "venue",
14115
- label: getTradingVenueLabel(
14591
+ kind: isSplit ? "split" : "venue",
14592
+ label: isSplit ? labels.orderSplitting : getTradingVenueLabel(
14116
14593
  parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
14117
14594
  ),
14118
14595
  numericValue: tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled,
14119
14596
  quoteData,
14597
+ rows: isSplit ? mapQuoteDataToRoutingRows(quoteData) : void 0,
14120
14598
  value: primaryResult.value,
14121
- venue: parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0,
14599
+ venue: isSplit ? void 0 : parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0,
14122
14600
  isUnavailable: true
14123
14601
  } : {
14124
14602
  id: "live-route",
@@ -15083,21 +15561,6 @@ PlaceOrderSuccessView.displayName = "PlaceOrderSuccessView";
15083
15561
 
15084
15562
  // src/trading/place-order/index.tsx
15085
15563
  var import_jsx_runtime135 = require("react/jsx-runtime");
15086
- var DEFAULT_STEP_LABELS = {
15087
- "check-balance": "Checking balance",
15088
- "check-position": "Checking position",
15089
- "lane-bridge": "Bridging funds",
15090
- bridge: "Bridging funds",
15091
- "bridge-to-user": "Transferring to wallet",
15092
- "sweep-bridge": "Completing bridge",
15093
- "submit-order": "Submitting order",
15094
- "order-bridge-execute": "Executing order",
15095
- "transfer-to-user": "Transferring to wallet"
15096
- };
15097
- var getDefaultStepLabel = (stepType) => {
15098
- var _a;
15099
- return (_a = DEFAULT_STEP_LABELS[stepType]) != null ? _a : stepType.replace(/-/g, " ").replace(/^\w/, (c) => c.toUpperCase());
15100
- };
15101
15564
  var resolveRefetchedQuoteData = (result) => {
15102
15565
  if (!result || typeof result !== "object" || !("data" in result)) return null;
15103
15566
  const data = result.data;
@@ -15597,7 +16060,6 @@ var renderRouteCard = ({
15597
16060
  }
15598
16061
  );
15599
16062
  };
15600
- var normalizeOrderIdLabelInput2 = (orderId) => orderId.replace(/^#+/, "");
15601
16063
  var renderSubmissionSurface = ({
15602
16064
  actionLabel,
15603
16065
  className,
@@ -15609,81 +16071,12 @@ var renderSubmissionSurface = ({
15609
16071
  progressState,
15610
16072
  tradingLabels
15611
16073
  }) => {
15612
- const resolveStepGroups = () => {
15613
- var _a, _b, _c;
15614
- if (progressState.phase === "finding-route") {
15615
- return [
15616
- [
15617
- {
15618
- id: "finding-route",
15619
- label: tradingLabels.findingBestRoute,
15620
- status: "pending"
15621
- }
15622
- ]
15623
- ];
15624
- }
15625
- const dag = progressState.dagProgress;
15626
- if (dag && dag.totalSteps > 0) {
15627
- const steps = [
15628
- {
15629
- id: "finding-route",
15630
- label: tradingLabels.findingBestRoute,
15631
- status: "complete"
15632
- }
15633
- ];
15634
- for (let i = 1; i <= dag.totalSteps; i++) {
15635
- const isCompleted = dag.completedSequences.includes(i);
15636
- const isCurrent = i === dag.currentSequence && !isCompleted;
15637
- const stepType = (_a = dag.stepTypes[i]) != null ? _a : null;
15638
- const stepLabel = stepType ? getDefaultStepLabel(stepType) : `Step ${i} of ${dag.totalSteps}`;
15639
- const prev = steps[steps.length - 1];
15640
- if (prev && prev.label === stepLabel) {
15641
- if (prev.status === "complete" && !isCompleted) {
15642
- prev.status = "pending";
15643
- }
15644
- continue;
15645
- }
15646
- steps.push({
15647
- id: `dag-step-${i}`,
15648
- label: stepLabel,
15649
- status: isCompleted ? "complete" : isCurrent ? "pending" : "pending"
15650
- });
15651
- }
15652
- return [steps];
15653
- }
15654
- const baseSteps = [
15655
- {
15656
- id: "finding-route",
15657
- label: tradingLabels.findingBestRoute,
15658
- status: "complete"
15659
- },
15660
- {
15661
- id: "submitting-order",
15662
- label: tradingLabels.submittingOrderProgress,
15663
- status: "complete"
15664
- }
15665
- ];
15666
- const submittedOrderId = (_c = progressState.orderId) != null ? _c : (_b = progressState.orderIds) == null ? void 0 : _b[0];
15667
- if (submittedOrderId) {
15668
- baseSteps.push({
15669
- id: "order-submitted",
15670
- label: tradingLabels.orderSubmittedProgress(normalizeOrderIdLabelInput2(submittedOrderId)),
15671
- status: "complete"
15672
- });
15673
- }
15674
- return [
15675
- baseSteps,
15676
- [
15677
- {
15678
- id: "executing-order",
15679
- label: tradingLabels.executingOnVenue(getTradingVenueLabel(progressState.executionVenue)),
15680
- status: "pending",
15681
- venue: progressState.executionVenue
15682
- }
15683
- ]
15684
- ];
15685
- };
15686
- const stepGroups = resolveStepGroups();
16074
+ const displayRows = buildSubmissionDisplayRows({
16075
+ phase: progressState.phase,
16076
+ dagProgress: progressState.dagProgress,
16077
+ executionVenue: progressState.executionVenue,
16078
+ labels: tradingLabels
16079
+ });
15687
16080
  return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
15688
16081
  Card,
15689
16082
  {
@@ -15705,51 +16098,50 @@ var renderSubmissionSurface = ({
15705
16098
  /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(LoadingGlyph, { enableAnimations, className: "h-4 w-4 text-current" }),
15706
16099
  /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("span", { children: actionLabel })
15707
16100
  ] }),
15708
- /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("div", { className: "agg-order-submission-steps flex flex-col gap-4", children: stepGroups.map((steps, groupIndex) => {
15709
- return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
15710
- "div",
15711
- {
15712
- className: "agg-order-submission-group flex flex-col gap-2",
15713
- children: steps.map((step) => {
15714
- return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
15715
- "div",
15716
- {
15717
- className: "agg-order-submission-step flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
15718
- children: [
15719
- step.status === "complete" ? /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
15720
- Icon,
15721
- {
15722
- name: "check-circle",
15723
- size: "small",
15724
- className: "h-3 w-3 shrink-0 text-agg-primary",
15725
- "aria-hidden": "true"
15726
- }
15727
- ) : /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
15728
- LoadingGlyph,
15729
- {
15730
- enableAnimations,
15731
- className: "h-3 w-3 shrink-0 text-agg-primary"
15732
- }
15733
- ),
15734
- /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("p", { className: "min-w-0 flex-1", children: step.label }),
15735
- step.venue ? /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
15736
- VenueLogo,
15737
- {
15738
- venue: step.venue,
15739
- size: "small",
15740
- ariaLabel: getTradingVenueLabel(step.venue),
15741
- className: "h-4 w-4"
15742
- }
15743
- ) : null
15744
- ]
15745
- },
15746
- step.id
15747
- );
15748
- })
15749
- },
15750
- `step-group-${groupIndex}`
15751
- );
15752
- }) })
16101
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
16102
+ "div",
16103
+ {
16104
+ className: "agg-order-submission-steps agg-order-submission-group flex flex-col gap-2",
16105
+ "data-testid": "agg-order-submission-steps",
16106
+ children: displayRows.map((step) => {
16107
+ return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
16108
+ "div",
16109
+ {
16110
+ className: "agg-order-submission-step flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
16111
+ "data-status": step.status,
16112
+ children: [
16113
+ step.status === "complete" ? /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
16114
+ Icon,
16115
+ {
16116
+ name: "check-circle",
16117
+ size: "small",
16118
+ className: "h-3 w-3 shrink-0 text-agg-primary",
16119
+ "aria-hidden": "true"
16120
+ }
16121
+ ) : /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
16122
+ LoadingGlyph,
16123
+ {
16124
+ enableAnimations,
16125
+ className: "h-3 w-3 shrink-0 text-agg-primary"
16126
+ }
16127
+ ),
16128
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("p", { className: "min-w-0 flex-1", children: step.label }),
16129
+ step.venue ? /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
16130
+ VenueLogo,
16131
+ {
16132
+ venue: step.venue,
16133
+ size: "small",
16134
+ ariaLabel: getTradingVenueLabel(step.venue),
16135
+ className: "h-4 w-4"
16136
+ }
16137
+ ) : null
16138
+ ]
16139
+ },
16140
+ step.id
16141
+ );
16142
+ })
16143
+ }
16144
+ )
15753
16145
  ] })
15754
16146
  ] })
15755
16147
  }
@@ -15885,6 +16277,7 @@ var PlaceOrder = ({
15885
16277
  }) => {
15886
16278
  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;
15887
16279
  const {
16280
+ enableDebug: isExecutionDebugEnabled,
15888
16281
  features: { enableAnimations, showFeesBreakdown },
15889
16282
  general: { locale }
15890
16283
  } = (0, import_hooks51.useSdkUiConfig)();
@@ -15981,6 +16374,27 @@ var PlaceOrder = ({
15981
16374
  const [isSplitDetailOpen, setIsSplitDetailOpen] = (0, import_react27.useState)(false);
15982
16375
  const [submissionFeedback, setSubmissionFeedback] = (0, import_react27.useState)(null);
15983
16376
  const [submissionProgressState, setSubmissionProgressState] = (0, import_react27.useState)(null);
16377
+ const executionDebugStoreRef = (0, import_react27.useRef)(null);
16378
+ const executionDebugAttemptIdRef = (0, import_react27.useRef)(null);
16379
+ (0, import_react27.useEffect)(() => {
16380
+ if (!isExecutionDebugEnabled) {
16381
+ executionDebugStoreRef.current = null;
16382
+ return;
16383
+ }
16384
+ executionDebugStoreRef.current = enableExecutionDebugInBrowser();
16385
+ }, [isExecutionDebugEnabled]);
16386
+ (0, import_react27.useEffect)(() => {
16387
+ if (!isExecutionDebugEnabled) return;
16388
+ const store = executionDebugStoreRef.current;
16389
+ if (!store) return;
16390
+ store.clear();
16391
+ executionDebugAttemptIdRef.current = null;
16392
+ }, [
16393
+ isExecutionDebugEnabled,
16394
+ scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.id,
16395
+ scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id,
16396
+ scopedSelectedOutcomeId
16397
+ ]);
15984
16398
  const debouncedAmount = (0, import_hooks51.useDebouncedValue)(internalAmount, 300);
15985
16399
  const isSell = (0, import_react27.useMemo)(() => internalTab === "sell", [internalTab]);
15986
16400
  const {
@@ -16240,8 +16654,39 @@ var PlaceOrder = ({
16240
16654
  selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData
16241
16655
  ]);
16242
16656
  (0, import_react27.useEffect)(() => {
16657
+ var _a2, _b2;
16243
16658
  const dp = executionProgress.dagProgress;
16244
16659
  if (!dp) return;
16660
+ const debugStore = executionDebugStoreRef.current;
16661
+ const debugAttemptId = executionDebugAttemptIdRef.current;
16662
+ if (debugStore && debugAttemptId) {
16663
+ debugStore.appendEvent(debugAttemptId, {
16664
+ kind: "ws_update",
16665
+ label: "dag_progress",
16666
+ data: dp
16667
+ });
16668
+ const normalizedRows = buildSubmissionDisplayRows({
16669
+ phase: "executing",
16670
+ dagProgress: dp,
16671
+ labels: tradingLabels
16672
+ });
16673
+ debugStore.setNormalizedSteps(debugAttemptId, normalizedRows);
16674
+ debugStore.appendEvent(debugAttemptId, {
16675
+ kind: "normalized_steps",
16676
+ data: normalizedRows
16677
+ });
16678
+ if (dp.status === "failed") {
16679
+ debugStore.appendError(debugAttemptId, {
16680
+ message: (_a2 = dp.errorReason) != null ? _a2 : "DAG execution failed",
16681
+ failedStep: (_b2 = dp.currentStepType) != null ? _b2 : void 0,
16682
+ data: { currentSequence: dp.currentSequence, totalSteps: dp.totalSteps }
16683
+ });
16684
+ debugStore.updateAttempt(debugAttemptId, {
16685
+ status: "failed",
16686
+ finalStatus: "failed"
16687
+ });
16688
+ }
16689
+ }
16245
16690
  setSubmissionProgressState((prev) => {
16246
16691
  if (!prev) return prev;
16247
16692
  if (dp.status === "failed") {
@@ -16257,7 +16702,7 @@ var PlaceOrder = ({
16257
16702
  }
16258
16703
  return __spreadProps(__spreadValues({}, prev), { dagProgress: dp });
16259
16704
  });
16260
- }, [executionProgress.dagProgress, tradingLabels.orderFailed]);
16705
+ }, [executionProgress.dagProgress, tradingLabels]);
16261
16706
  (0, import_react27.useEffect)(() => {
16262
16707
  const orderIds = submissionProgressState == null ? void 0 : submissionProgressState.orderIds;
16263
16708
  if (!(orderIds == null ? void 0 : orderIds.length)) return;
@@ -16265,6 +16710,17 @@ var PlaceOrder = ({
16265
16710
  orderIds,
16266
16711
  executionProgress.terminalOrderEvents
16267
16712
  );
16713
+ const debugStore = executionDebugStoreRef.current;
16714
+ const debugAttemptId = executionDebugAttemptIdRef.current;
16715
+ if (debugStore && debugAttemptId && executionProgress.terminalOrderEvents.length > 0) {
16716
+ debugStore.appendEvent(debugAttemptId, {
16717
+ kind: "terminal_event",
16718
+ data: {
16719
+ aggregateStatus,
16720
+ events: executionProgress.terminalOrderEvents
16721
+ }
16722
+ });
16723
+ }
16268
16724
  if (aggregateStatus === "pending") return;
16269
16725
  setSubmissionProgressState((prev) => {
16270
16726
  var _a2, _b2, _c2;
@@ -16307,14 +16763,45 @@ var PlaceOrder = ({
16307
16763
  tradingLabels.orderFailed
16308
16764
  ]);
16309
16765
  (0, import_react27.useEffect)(() => {
16766
+ var _a2, _b2;
16310
16767
  if (!submissionProgressState) return;
16311
16768
  onExecutionStateChange == null ? void 0 : onExecutionStateChange(submissionProgressState);
16769
+ const debugStore = executionDebugStoreRef.current;
16770
+ const debugAttemptId = executionDebugAttemptIdRef.current;
16771
+ if (debugStore && debugAttemptId) {
16772
+ debugStore.appendEvent(debugAttemptId, {
16773
+ kind: "state_change",
16774
+ label: submissionProgressState.phase,
16775
+ data: {
16776
+ phase: submissionProgressState.phase,
16777
+ executionVenue: submissionProgressState.executionVenue,
16778
+ orderIds: submissionProgressState.orderIds,
16779
+ errorMessage: submissionProgressState.errorMessage
16780
+ }
16781
+ });
16782
+ }
16312
16783
  if (submissionProgressState.phase === "success" && submissionProgressState.summary) {
16313
16784
  (0, import_hooks51.invalidateBalanceQueries)(queryClient);
16314
16785
  (0, import_hooks51.invalidatePositionQueries)(queryClient);
16786
+ if (debugStore && debugAttemptId) {
16787
+ debugStore.updateAttempt(debugAttemptId, {
16788
+ status: "succeeded",
16789
+ finalStatus: "succeeded"
16790
+ });
16791
+ }
16315
16792
  onSuccess == null ? void 0 : onSuccess(submissionProgressState.summary);
16316
16793
  }
16317
16794
  if (submissionProgressState.phase === "failed" && submissionProgressState.errorMessage) {
16795
+ if (debugStore && debugAttemptId) {
16796
+ debugStore.appendError(debugAttemptId, {
16797
+ message: submissionProgressState.errorMessage,
16798
+ failedStep: (_b2 = (_a2 = submissionProgressState.dagProgress) == null ? void 0 : _a2.currentStepType) != null ? _b2 : void 0
16799
+ });
16800
+ debugStore.updateAttempt(debugAttemptId, {
16801
+ status: "failed",
16802
+ finalStatus: "failed"
16803
+ });
16804
+ }
16318
16805
  onError == null ? void 0 : onError(new Error(submissionProgressState.errorMessage));
16319
16806
  }
16320
16807
  }, [submissionProgressState, onExecutionStateChange, onSuccess, onError, queryClient]);
@@ -16488,23 +16975,91 @@ var PlaceOrder = ({
16488
16975
  };
16489
16976
  const handleExecuteQuote = (0, import_react27.useCallback)(
16490
16977
  (quoteData) => __async(null, null, function* () {
16978
+ var _a2, _b2, _c2;
16491
16979
  const quoteId = quoteData == null ? void 0 : quoteData.quoteId;
16492
16980
  if (!quoteId) {
16493
16981
  throw new Error(tradingLabels.quoteUnavailable);
16494
16982
  }
16983
+ const debugStore = executionDebugStoreRef.current;
16984
+ const venues = (_b2 = (_a2 = quoteData == null ? void 0 : quoteData.fills) == null ? void 0 : _a2.map((fill) => fill.venue).filter(Boolean)) != null ? _b2 : [];
16985
+ const debugAttempt = debugStore == null ? void 0 : debugStore.appendAttempt({
16986
+ status: "executing",
16987
+ quoteId,
16988
+ quote: {
16989
+ request: {
16990
+ venueMarketOutcomeId: scopedSelectedOutcomeId,
16991
+ amount: internalAmount,
16992
+ slippage: internalSlippage,
16993
+ tradeSide: isSell ? "sell" : "buy"
16994
+ },
16995
+ response: smartRoute.data,
16996
+ selectedRoute: quoteData,
16997
+ side: isSell ? "sell" : "buy",
16998
+ marketId: scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id,
16999
+ eventId: scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.id,
17000
+ outcomeId: scopedSelectedOutcomeId != null ? scopedSelectedOutcomeId : void 0,
17001
+ venues,
17002
+ capturedAt: Date.now()
17003
+ },
17004
+ selectedRoute: quoteData
17005
+ });
17006
+ executionDebugAttemptIdRef.current = (_c2 = debugAttempt == null ? void 0 : debugAttempt.attemptId) != null ? _c2 : null;
16495
17007
  if (onPrimaryAction) {
17008
+ debugStore == null ? void 0 : debugStore.appendEvent(debugAttempt.attemptId, {
17009
+ kind: "execute_request",
17010
+ label: "delegated_to_partner",
17011
+ data: { quoteId }
17012
+ });
16496
17013
  onPrimaryAction({ quoteId });
16497
17014
  return;
16498
17015
  }
16499
- const response = yield executeManaged.mutateAsync({ quoteId });
16500
- setSubmissionProgressState({
16501
- executionVenue: resolveExecutionVenueFromQuote(quoteData),
16502
- orderId: response.orderIds[0],
16503
- orderIds: response.orderIds,
16504
- phase: "submitting"
16505
- });
17016
+ try {
17017
+ const response = yield executeManaged.mutateAsync({ quoteId });
17018
+ if (debugAttempt) {
17019
+ debugStore == null ? void 0 : debugStore.appendEvent(debugAttempt.attemptId, {
17020
+ kind: "execute_response",
17021
+ data: { orderIds: response.orderIds }
17022
+ });
17023
+ debugStore == null ? void 0 : debugStore.updateAttempt(debugAttempt.attemptId, {
17024
+ orderId: response.orderIds[0],
17025
+ orderIds: response.orderIds
17026
+ });
17027
+ }
17028
+ setSubmissionProgressState({
17029
+ executionVenue: resolveExecutionVenueFromQuote(quoteData),
17030
+ orderId: response.orderIds[0],
17031
+ orderIds: response.orderIds,
17032
+ phase: "submitting"
17033
+ });
17034
+ } catch (error) {
17035
+ if (debugAttempt) {
17036
+ const err = error instanceof Error ? error : new Error(String(error));
17037
+ debugStore == null ? void 0 : debugStore.appendError(debugAttempt.attemptId, {
17038
+ message: err.message,
17039
+ name: err.name,
17040
+ stack: err.stack,
17041
+ failedStep: "execute_request"
17042
+ });
17043
+ debugStore == null ? void 0 : debugStore.updateAttempt(debugAttempt.attemptId, {
17044
+ status: "failed",
17045
+ finalStatus: "failed"
17046
+ });
17047
+ }
17048
+ throw error;
17049
+ }
16506
17050
  }),
16507
- [executeManaged, onPrimaryAction, tradingLabels.quoteUnavailable]
17051
+ [
17052
+ executeManaged,
17053
+ internalAmount,
17054
+ internalSlippage,
17055
+ isSell,
17056
+ onPrimaryAction,
17057
+ scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.id,
17058
+ scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id,
17059
+ scopedSelectedOutcomeId,
17060
+ smartRoute.data,
17061
+ tradingLabels.quoteUnavailable
17062
+ ]
16508
17063
  );
16509
17064
  const handleSkipToSuccess = (0, import_react27.useCallback)(() => {
16510
17065
  const primaryFilledEvent = executionProgress.terminalOrderEvents.find(
@@ -17719,7 +18274,7 @@ var HomeSearchResults = ({
17719
18274
  const eventListTabs = useEventListTabs();
17720
18275
  const { headerRef, titleRef, shouldUseSelectOverflow } = useEventListTabsHeaderOverflow(eventListTabs);
17721
18276
  const visibleVenues = (0, import_react31.useMemo)(
17722
- () => disabledVenues.length === 0 ? void 0 : import_sdk17.VENUES.filter(
18277
+ () => disabledVenues.length === 0 ? void 0 : import_sdk18.VENUES.filter(
17723
18278
  (v) => !disabledVenues.includes(v)
17724
18279
  ),
17725
18280
  [disabledVenues]
@@ -18153,7 +18708,7 @@ HomePage.displayName = "HomePage";
18153
18708
 
18154
18709
  // src/pages/user-profile/index.tsx
18155
18710
  var import_hooks57 = require("@agg-build/hooks");
18156
- var import_sdk18 = require("@agg-build/sdk");
18711
+ var import_sdk19 = require("@agg-build/sdk");
18157
18712
  var import_react33 = require("react");
18158
18713
 
18159
18714
  // src/pages/user-profile/chain-display.ts
@@ -18893,7 +19448,7 @@ var toneTextClassName = (tone) => {
18893
19448
  if (tone === "negative") return "text-agg-error";
18894
19449
  return "text-agg-muted-foreground";
18895
19450
  };
18896
- var OutcomePill = ({ label: label2 }) => /* @__PURE__ */ (0, import_jsx_runtime141.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_runtime141.jsx)("span", { className: "whitespace-nowrap font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground", children: label2 }) });
19451
+ var OutcomePill = ({ label: label2 }) => /* @__PURE__ */ (0, import_jsx_runtime141.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_runtime141.jsx)("span", { className: "whitespace-nowrap font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground truncate", children: label2 }) });
18897
19452
  var VenueShares = ({
18898
19453
  model,
18899
19454
  className,
@@ -19076,7 +19631,7 @@ var PositionRow = ({
19076
19631
  {
19077
19632
  model,
19078
19633
  keyPrefix: "desktop",
19079
- className: "agg-position-venues flex min-w-0 flex-1 flex-wrap content-center items-center gap-x-3 gap-y-2"
19634
+ className: "agg-position-venues flex flex-1 flex-wrap content-center items-center gap-x-3 gap-y-2"
19080
19635
  }
19081
19636
  )
19082
19637
  ] })
@@ -19829,6 +20384,7 @@ var UserInfoCard = ({
19829
20384
  content: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)("p", { className: "text-center", children: labels.auth.depositGeoBlocked }),
19830
20385
  size: "small",
19831
20386
  side: "bottom",
20387
+ sideOffset: 4,
19832
20388
  children
19833
20389
  }
19834
20390
  ),
@@ -20150,10 +20706,10 @@ var toTokenAmountLabel = ({
20150
20706
  return `${prefix}${formatTokenAmountTwoDecimals(amountRaw, tokenSymbol, chainId)} ${tokenSymbol}`;
20151
20707
  };
20152
20708
  var POSITION_ROW_VENUE_ORDER = [
20153
- import_sdk18.Venue.polymarket,
20154
- import_sdk18.Venue.kalshi,
20155
- import_sdk18.Venue.opinion,
20156
- import_sdk18.Venue.limitless
20709
+ import_sdk19.Venue.polymarket,
20710
+ import_sdk19.Venue.kalshi,
20711
+ import_sdk19.Venue.opinion,
20712
+ import_sdk19.Venue.limitless
20157
20713
  ];
20158
20714
  function venueBreakdownSortKey(venue) {
20159
20715
  const idx = POSITION_ROW_VENUE_ORDER.indexOf(venue);
@@ -20309,6 +20865,8 @@ var UserProfilePage = ({
20309
20865
  try {
20310
20866
  yield redeemMutation.mutateAsync({ venueMarketOutcomeIds });
20311
20867
  yield queryClient.invalidateQueries({ queryKey: ["current-user"] });
20868
+ } catch (err) {
20869
+ console.error("[UserProfilePage] redeem failed", err);
20312
20870
  } finally {
20313
20871
  setInternalClaimingIds((prev) => {
20314
20872
  const _a2 = prev, { [claimKey]: _removed } = _a2, rest = __objRest(_a2, [__restKey(claimKey)]);
@@ -20691,7 +21249,10 @@ var UserProfilePage = ({
20691
21249
  /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)(
20692
21250
  "div",
20693
21251
  {
20694
- className: cn("agg-profile-side-panels flex flex-col gap-4", classNames == null ? void 0 : classNames.rightColumn),
21252
+ className: cn(
21253
+ "agg-profile-side-panels flex flex-col-reverse md:flex-col gap-4",
21254
+ classNames == null ? void 0 : classNames.rightColumn
21255
+ ),
20695
21256
  children: [
20696
21257
  /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(PositionsValueCard, { valueLabel: positionsValueLabel }),
20697
21258
  /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(