@agg-build/ui 2.1.1 → 2.1.3
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.
- package/dist/{chunk-XHDGSRG7.mjs → chunk-BW7S2YR3.mjs} +1139 -308
- package/dist/{chunk-TERG43WW.mjs → chunk-R2YNZJZ3.mjs} +69 -27
- package/dist/{chunk-RPXRTXCY.mjs → chunk-T4YZGAYS.mjs} +22 -1
- package/dist/{chunk-IQT4I5B4.mjs → chunk-TAGPAADA.mjs} +2108 -767
- package/dist/{chunk-NK57KMYN.mjs → chunk-TBZWRUFB.mjs} +752 -589
- package/dist/{chunk-YJO6LMRT.mjs → chunk-VP76G6PN.mjs} +87 -25
- package/dist/{chunk-WU2C3C6K.mjs → chunk-XHE2VO3S.mjs} +4 -21
- package/dist/events.js +1014 -760
- package/dist/events.mjs +5 -3
- package/dist/index.js +9937 -7880
- package/dist/index.mjs +117 -456
- package/dist/modals.js +1 -1
- package/dist/modals.mjs +3 -3
- package/dist/pages.js +8513 -6380
- package/dist/pages.mjs +6 -6
- package/dist/primitives.js +85 -25
- package/dist/primitives.mjs +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/trading.js +979 -402
- package/dist/trading.mjs +10 -6
- package/dist/types/events/item/event-list-item.utils.d.mts +1 -25
- package/dist/types/events/item/event-list-item.utils.d.ts +1 -25
- package/dist/types/events/item-details/index.d.mts +2 -1
- package/dist/types/events/item-details/index.d.ts +2 -1
- package/dist/types/events/market-details/market-details-graph-panel.d.mts +39 -0
- package/dist/types/events/market-details/market-details-graph-panel.d.ts +39 -0
- package/dist/types/events/market-details/market-details-outcome-button.d.mts +2 -1
- package/dist/types/events/market-details/market-details-outcome-button.d.ts +2 -1
- package/dist/types/events/market-details/market-details.types.d.mts +31 -0
- package/dist/types/events/market-details/market-details.types.d.ts +31 -0
- package/dist/types/events/market-details/market-details.utils.d.mts +3 -16
- package/dist/types/events/market-details/market-details.utils.d.ts +3 -16
- package/dist/types/events/shared/format-event-title.d.mts +24 -0
- package/dist/types/events/shared/format-event-title.d.ts +24 -0
- package/dist/types/events/shared/format-sports-event-time.d.mts +2 -0
- package/dist/types/events/shared/format-sports-event-time.d.ts +2 -0
- package/dist/types/events/shared/select-best-outcome.d.mts +88 -0
- package/dist/types/events/shared/select-best-outcome.d.ts +88 -0
- package/dist/types/notifications/agg-notification-events-provider.d.mts +10 -1
- package/dist/types/notifications/agg-notification-events-provider.d.ts +10 -1
- package/dist/types/pages/event-market/event-market.shared.d.mts +30 -0
- package/dist/types/pages/event-market/event-market.shared.d.ts +30 -0
- package/dist/types/pages/event-market/event-market.types.d.mts +7 -0
- package/dist/types/pages/event-market/event-market.types.d.ts +7 -0
- package/dist/types/pages/event-market/sports-event-market-page.d.mts +8 -0
- package/dist/types/pages/event-market/sports-event-market-page.d.ts +8 -0
- package/dist/types/pages/event-market/sports-event-market.fixtures.d.mts +13 -0
- package/dist/types/pages/event-market/sports-event-market.fixtures.d.ts +13 -0
- package/dist/types/pages/event-market/sports-event-market.utils.d.mts +156 -0
- package/dist/types/pages/event-market/sports-event-market.utils.d.ts +156 -0
- package/dist/types/pages/event-market/sports-line-rail.d.mts +17 -0
- package/dist/types/pages/event-market/sports-line-rail.d.ts +17 -0
- package/dist/types/pages/event-market/sports-market-card.d.mts +22 -0
- package/dist/types/pages/event-market/sports-market-card.d.ts +22 -0
- package/dist/types/pages/event-market/sports-markets.d.mts +13 -0
- package/dist/types/pages/event-market/sports-markets.d.ts +13 -0
- package/dist/types/primitives/state-message/index.d.mts +1 -1
- package/dist/types/primitives/state-message/index.d.ts +1 -1
- package/dist/types/primitives/state-message/state-message.types.d.mts +1 -1
- package/dist/types/primitives/state-message/state-message.types.d.ts +1 -1
- package/dist/types/trading/index.d.mts +2 -0
- package/dist/types/trading/index.d.ts +2 -0
- package/dist/types/trading/place-order/index.d.mts +1 -1
- package/dist/types/trading/place-order/index.d.ts +1 -1
- package/dist/types/trading/place-order/index.place-order.types.d.mts +30 -1
- package/dist/types/trading/place-order/index.place-order.types.d.ts +30 -1
- package/dist/types/trading/settlement/settlement-text.utils.d.mts +5 -2
- package/dist/types/trading/settlement/settlement-text.utils.d.ts +5 -2
- package/dist/types/trading/use-claim-winnings.d.mts +84 -0
- package/dist/types/trading/use-claim-winnings.d.ts +84 -0
- package/dist/types/trading/use-resolved-market-claim.d.mts +26 -0
- package/dist/types/trading/use-resolved-market-claim.d.ts +26 -0
- package/package.json +3 -3
package/dist/trading.js
CHANGED
|
@@ -24,6 +24,7 @@ var __spreadValues = (a, b) => {
|
|
|
24
24
|
return a;
|
|
25
25
|
};
|
|
26
26
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
27
|
+
var __restKey = (key) => typeof key === "symbol" ? key : key + "";
|
|
27
28
|
var __objRest = (source, exclude) => {
|
|
28
29
|
var target = {};
|
|
29
30
|
for (var prop in source)
|
|
@@ -99,7 +100,9 @@ __export(trading_exports, {
|
|
|
99
100
|
getTradingVenueLabel: () => getTradingVenueLabel,
|
|
100
101
|
parseAmount: () => parseAmount,
|
|
101
102
|
parseVenue: () => parseVenue,
|
|
102
|
-
|
|
103
|
+
useClaimWinnings: () => useClaimWinnings,
|
|
104
|
+
useEventTradingContext: () => import_hooks31.useEventTradingContext,
|
|
105
|
+
useResolvedMarketClaim: () => useResolvedMarketClaim
|
|
103
106
|
});
|
|
104
107
|
module.exports = __toCommonJS(trading_exports);
|
|
105
108
|
|
|
@@ -927,7 +930,6 @@ var normalizeSettlementForCompare = (input) => {
|
|
|
927
930
|
};
|
|
928
931
|
var dedupeSettlementSources = (sources) => {
|
|
929
932
|
const order = ["eventDescription", "marketDescription", "primaryRules"];
|
|
930
|
-
const seen = /* @__PURE__ */ new Set();
|
|
931
933
|
const result = [];
|
|
932
934
|
for (const key of order) {
|
|
933
935
|
const value = sources[key];
|
|
@@ -936,11 +938,13 @@ var dedupeSettlementSources = (sources) => {
|
|
|
936
938
|
if (!trimmed) continue;
|
|
937
939
|
const fingerprint = normalizeSettlementForCompare(trimmed);
|
|
938
940
|
if (!fingerprint) continue;
|
|
939
|
-
if (
|
|
940
|
-
|
|
941
|
-
|
|
941
|
+
if (result.some((block) => block.fingerprint.includes(fingerprint))) continue;
|
|
942
|
+
for (let i = result.length - 1; i >= 0; i -= 1) {
|
|
943
|
+
if (fingerprint.includes(result[i].fingerprint)) result.splice(i, 1);
|
|
944
|
+
}
|
|
945
|
+
result.push({ key, content: trimmed, fingerprint });
|
|
942
946
|
}
|
|
943
|
-
return result;
|
|
947
|
+
return result.map(({ key, content }) => ({ key, content }));
|
|
944
948
|
};
|
|
945
949
|
|
|
946
950
|
// src/trading/settlement/settlement-text-renderer.tsx
|
|
@@ -1204,10 +1208,10 @@ var SettlementDetails = ({ className }) => {
|
|
|
1204
1208
|
SettlementDetails.displayName = "SettlementDetails";
|
|
1205
1209
|
|
|
1206
1210
|
// src/trading/place-order/index.tsx
|
|
1207
|
-
var
|
|
1208
|
-
var
|
|
1211
|
+
var import_hooks30 = require("@agg-build/hooks");
|
|
1212
|
+
var import_react10 = __toESM(require("@number-flow/react"));
|
|
1209
1213
|
var Dialog2 = __toESM(require("@radix-ui/react-dialog"));
|
|
1210
|
-
var
|
|
1214
|
+
var import_react11 = require("react");
|
|
1211
1215
|
|
|
1212
1216
|
// src/events/market-details/market-details.utils.ts
|
|
1213
1217
|
var import_sdk12 = require("@agg-build/sdk");
|
|
@@ -5234,6 +5238,22 @@ var VenueLogo = ({
|
|
|
5234
5238
|
};
|
|
5235
5239
|
VenueLogo.displayName = "VenueLogo";
|
|
5236
5240
|
|
|
5241
|
+
// src/events/shared/format-sports-event-time.ts
|
|
5242
|
+
var import_dayjs4 = __toESM(require("dayjs"));
|
|
5243
|
+
var import_timezone = __toESM(require("dayjs/plugin/timezone"));
|
|
5244
|
+
var import_utc = __toESM(require("dayjs/plugin/utc"));
|
|
5245
|
+
import_dayjs4.default.extend(import_utc.default);
|
|
5246
|
+
import_dayjs4.default.extend(import_timezone.default);
|
|
5247
|
+
var SPORTS_EVENT_TIMEZONE = "America/New_York";
|
|
5248
|
+
var SPORTS_EVENT_TIME_FORMAT = "MMM D, h:mm A";
|
|
5249
|
+
var formatSportsEventTimeEt = (value) => {
|
|
5250
|
+
const resolvedValue = value.trim();
|
|
5251
|
+
if (!resolvedValue) return null;
|
|
5252
|
+
const parsedValue = import_dayjs4.default.utc(resolvedValue);
|
|
5253
|
+
if (!parsedValue.isValid()) return null;
|
|
5254
|
+
return `${parsedValue.tz(SPORTS_EVENT_TIMEZONE).format(SPORTS_EVENT_TIME_FORMAT)} ET`;
|
|
5255
|
+
};
|
|
5256
|
+
|
|
5237
5257
|
// src/primitives/inline-alert/inline-alert.constants.ts
|
|
5238
5258
|
var INLINE_ALERT_DEFAULT_TONE = "error";
|
|
5239
5259
|
var INLINE_ALERT_TONE_ICON_NAME = {
|
|
@@ -5835,10 +5855,19 @@ var Typography = ({
|
|
|
5835
5855
|
};
|
|
5836
5856
|
Typography.displayName = "Typography";
|
|
5837
5857
|
|
|
5858
|
+
// src/primitives/toast/index.tsx
|
|
5859
|
+
var RadixToast = __toESM(require("@radix-ui/react-toast"));
|
|
5860
|
+
var import_react5 = require("react");
|
|
5861
|
+
var import_jsx_runtime118 = require("react/jsx-runtime");
|
|
5862
|
+
var ToastContext = (0, import_react5.createContext)(null);
|
|
5863
|
+
function useOptionalToast() {
|
|
5864
|
+
return (0, import_react5.useContext)(ToastContext);
|
|
5865
|
+
}
|
|
5866
|
+
|
|
5838
5867
|
// src/primitives/tooltip/index.tsx
|
|
5839
5868
|
var import_hooks27 = require("@agg-build/hooks");
|
|
5840
5869
|
var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"));
|
|
5841
|
-
var
|
|
5870
|
+
var import_react6 = require("react");
|
|
5842
5871
|
|
|
5843
5872
|
// src/primitives/tooltip/tooltip.constants.ts
|
|
5844
5873
|
var tooltipSizeClasses = {
|
|
@@ -5870,7 +5899,7 @@ var resolveTooltipArrowDimensions = (size) => {
|
|
|
5870
5899
|
};
|
|
5871
5900
|
|
|
5872
5901
|
// src/primitives/tooltip/index.tsx
|
|
5873
|
-
var
|
|
5902
|
+
var import_jsx_runtime119 = require("react/jsx-runtime");
|
|
5874
5903
|
var Tooltip = ({
|
|
5875
5904
|
content,
|
|
5876
5905
|
children,
|
|
@@ -5886,24 +5915,24 @@ var Tooltip = ({
|
|
|
5886
5915
|
general: { rootClassName },
|
|
5887
5916
|
features: { enableAnimations }
|
|
5888
5917
|
} = (0, import_hooks27.useSdkUiConfig)();
|
|
5889
|
-
const trigger = (0,
|
|
5918
|
+
const trigger = (0, import_react6.useMemo)(() => {
|
|
5890
5919
|
if (children) return children;
|
|
5891
|
-
return /* @__PURE__ */ (0,
|
|
5920
|
+
return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
|
|
5892
5921
|
"button",
|
|
5893
5922
|
{
|
|
5894
5923
|
type: "button",
|
|
5895
5924
|
className: resolveTooltipTriggerClassName(classNames == null ? void 0 : classNames.trigger),
|
|
5896
5925
|
"aria-label": ariaLabel != null ? ariaLabel : defaultTooltipTriggerAriaLabel,
|
|
5897
|
-
children: /* @__PURE__ */ (0,
|
|
5926
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(Icon, { name: "info", size: "small", className: cn(classNames == null ? void 0 : classNames.icon), "aria-hidden": true })
|
|
5898
5927
|
}
|
|
5899
5928
|
);
|
|
5900
5929
|
}, [children, classNames == null ? void 0 : classNames.trigger, classNames == null ? void 0 : classNames.icon, ariaLabel]);
|
|
5901
5930
|
const { width: arrowWidth, height: arrowHeight } = resolveTooltipArrowDimensions(size);
|
|
5902
5931
|
const arrowPoints = `0,0 ${arrowWidth},0 ${arrowWidth / 2},${arrowHeight}`;
|
|
5903
5932
|
const arrowBorderPath = `M0 0 L${arrowWidth / 2} ${arrowHeight} L${arrowWidth} 0`;
|
|
5904
|
-
return /* @__PURE__ */ (0,
|
|
5905
|
-
/* @__PURE__ */ (0,
|
|
5906
|
-
/* @__PURE__ */ (0,
|
|
5933
|
+
return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(TooltipPrimitive.Provider, { delayDuration, children: /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(TooltipPrimitive.Root, { children: [
|
|
5934
|
+
/* @__PURE__ */ (0, import_jsx_runtime119.jsx)(TooltipPrimitive.Trigger, { asChild: true, children: trigger }),
|
|
5935
|
+
/* @__PURE__ */ (0, import_jsx_runtime119.jsx)(TooltipPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(
|
|
5907
5936
|
TooltipPrimitive.Content,
|
|
5908
5937
|
{
|
|
5909
5938
|
side,
|
|
@@ -5927,7 +5956,7 @@ var Tooltip = ({
|
|
|
5927
5956
|
classNames == null ? void 0 : classNames.content
|
|
5928
5957
|
),
|
|
5929
5958
|
children: [
|
|
5930
|
-
/* @__PURE__ */ (0,
|
|
5959
|
+
/* @__PURE__ */ (0, import_jsx_runtime119.jsx)(TooltipPrimitive.Arrow, { asChild: true, width: arrowWidth, height: arrowHeight, children: /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(
|
|
5931
5960
|
"svg",
|
|
5932
5961
|
{
|
|
5933
5962
|
width: arrowWidth,
|
|
@@ -5936,8 +5965,8 @@ var Tooltip = ({
|
|
|
5936
5965
|
"aria-hidden": "true",
|
|
5937
5966
|
className: cn("overflow-visible", classNames == null ? void 0 : classNames.arrow),
|
|
5938
5967
|
children: [
|
|
5939
|
-
/* @__PURE__ */ (0,
|
|
5940
|
-
/* @__PURE__ */ (0,
|
|
5968
|
+
/* @__PURE__ */ (0, import_jsx_runtime119.jsx)("polygon", { points: arrowPoints, className: "fill-agg-secondary" }),
|
|
5969
|
+
/* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
|
|
5941
5970
|
"path",
|
|
5942
5971
|
{
|
|
5943
5972
|
d: arrowBorderPath,
|
|
@@ -5958,6 +5987,98 @@ var Tooltip = ({
|
|
|
5958
5987
|
};
|
|
5959
5988
|
Tooltip.displayName = "Tooltip";
|
|
5960
5989
|
|
|
5990
|
+
// src/notifications/agg-notification-events-provider.tsx
|
|
5991
|
+
var import_hooks28 = require("@agg-build/hooks");
|
|
5992
|
+
var import_react7 = require("react");
|
|
5993
|
+
var import_jsx_runtime120 = require("react/jsx-runtime");
|
|
5994
|
+
var firedOrderNotificationKeys = /* @__PURE__ */ new Set();
|
|
5995
|
+
var MICRO_UNITS_SCALE = 1e6;
|
|
5996
|
+
var formatScaledMicroAmount = (value) => {
|
|
5997
|
+
if (!value) return void 0;
|
|
5998
|
+
if (value.includes(".")) {
|
|
5999
|
+
const parsed = Number(value);
|
|
6000
|
+
if (!Number.isFinite(parsed)) return void 0;
|
|
6001
|
+
return parsed.toLocaleString("en-US", { maximumFractionDigits: 2 });
|
|
6002
|
+
}
|
|
6003
|
+
try {
|
|
6004
|
+
const raw = BigInt(value);
|
|
6005
|
+
const whole = raw / BigInt(MICRO_UNITS_SCALE);
|
|
6006
|
+
const remainder = raw % BigInt(MICRO_UNITS_SCALE);
|
|
6007
|
+
const parsed = Number(whole) + Number(remainder) / MICRO_UNITS_SCALE;
|
|
6008
|
+
return parsed.toLocaleString("en-US", { maximumFractionDigits: 2 });
|
|
6009
|
+
} catch (e) {
|
|
6010
|
+
const parsed = Number(value);
|
|
6011
|
+
if (!Number.isFinite(parsed)) return void 0;
|
|
6012
|
+
return (parsed / MICRO_UNITS_SCALE).toLocaleString("en-US", { maximumFractionDigits: 2 });
|
|
6013
|
+
}
|
|
6014
|
+
};
|
|
6015
|
+
var formatPriceCents = (value) => {
|
|
6016
|
+
if (!value) return void 0;
|
|
6017
|
+
const parsed = Number(value);
|
|
6018
|
+
if (!Number.isFinite(parsed)) return void 0;
|
|
6019
|
+
const cents = parsed * 100;
|
|
6020
|
+
const display2 = cents.toLocaleString("en-US", {
|
|
6021
|
+
minimumFractionDigits: 0,
|
|
6022
|
+
maximumFractionDigits: 1
|
|
6023
|
+
});
|
|
6024
|
+
return `${display2}\xA2`;
|
|
6025
|
+
};
|
|
6026
|
+
var formatSharesLabel = (raw) => {
|
|
6027
|
+
const formatted = formatScaledMicroAmount(raw);
|
|
6028
|
+
if (!formatted) return void 0;
|
|
6029
|
+
return `${formatted} shares`;
|
|
6030
|
+
};
|
|
6031
|
+
var capitalize = (value) => {
|
|
6032
|
+
if (!value) return void 0;
|
|
6033
|
+
return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase();
|
|
6034
|
+
};
|
|
6035
|
+
var venueLabelFor = (venueKey, labels) => {
|
|
6036
|
+
var _a;
|
|
6037
|
+
if (!venueKey) return void 0;
|
|
6038
|
+
const normalized = venueKey.toLowerCase();
|
|
6039
|
+
const lookup = labels.venues;
|
|
6040
|
+
return (_a = lookup[normalized]) != null ? _a : capitalize(venueKey);
|
|
6041
|
+
};
|
|
6042
|
+
function handleOrderEvent({ event, labels, fireOnce }) {
|
|
6043
|
+
var _a, _b;
|
|
6044
|
+
const venueLabel = venueLabelFor(event.venue, labels);
|
|
6045
|
+
const amountLabel = formatSharesLabel((_a = event.actualSharesRaw) != null ? _a : event.filledAmountRaw);
|
|
6046
|
+
const priceLabel = formatPriceCents((_b = event.executionPriceRaw) != null ? _b : event.quotedPriceRaw);
|
|
6047
|
+
const fireOrderOnce = (key, tone, title2, message, detail) => {
|
|
6048
|
+
if (firedOrderNotificationKeys.has(key)) return;
|
|
6049
|
+
firedOrderNotificationKeys.add(key);
|
|
6050
|
+
fireOnce(key, tone, title2, message, detail);
|
|
6051
|
+
};
|
|
6052
|
+
if (event.event === "filled") {
|
|
6053
|
+
fireOrderOnce(
|
|
6054
|
+
`order:${event.orderId}:filled`,
|
|
6055
|
+
"success",
|
|
6056
|
+
labels.notifications.order.filledTitle,
|
|
6057
|
+
labels.notifications.order.filledMessage({ venueLabel, amountLabel, priceLabel })
|
|
6058
|
+
);
|
|
6059
|
+
return;
|
|
6060
|
+
}
|
|
6061
|
+
if (event.event === "partial_fill") {
|
|
6062
|
+
fireOrderOnce(
|
|
6063
|
+
`order:${event.orderId}:partial_fill`,
|
|
6064
|
+
"warning",
|
|
6065
|
+
labels.notifications.order.partialFilledTitle,
|
|
6066
|
+
labels.notifications.order.partialFilledMessage({ venueLabel, amountLabel, priceLabel })
|
|
6067
|
+
);
|
|
6068
|
+
return;
|
|
6069
|
+
}
|
|
6070
|
+
if (event.event === "failed") {
|
|
6071
|
+
fireOrderOnce(
|
|
6072
|
+
`order:${event.orderId}:failed`,
|
|
6073
|
+
"error",
|
|
6074
|
+
labels.notifications.order.failedTitle,
|
|
6075
|
+
labels.notifications.order.failedMessage(event.errorReason),
|
|
6076
|
+
venueLabel
|
|
6077
|
+
);
|
|
6078
|
+
}
|
|
6079
|
+
}
|
|
6080
|
+
var CLIENT_DEPOSIT_ACTIVITY_SUPPRESSION_MS = 2 * 60 * 1e3;
|
|
6081
|
+
|
|
5961
6082
|
// src/shared/deposit-modal-events.ts
|
|
5962
6083
|
var DEPOSIT_MODAL_OPEN_EVENT = "agg-deposit:open-modal";
|
|
5963
6084
|
var requestAggDepositModalOpen = () => {
|
|
@@ -5966,8 +6087,8 @@ var requestAggDepositModalOpen = () => {
|
|
|
5966
6087
|
};
|
|
5967
6088
|
|
|
5968
6089
|
// src/trading/use-kalshi-kyc-flow.ts
|
|
5969
|
-
var
|
|
5970
|
-
var
|
|
6090
|
+
var import_hooks29 = require("@agg-build/hooks");
|
|
6091
|
+
var import_react8 = require("react");
|
|
5971
6092
|
var KYC_PENDING_STORAGE_KEY = "agg_kyc_pending";
|
|
5972
6093
|
var getKycPendingState = () => {
|
|
5973
6094
|
var _a, _b;
|
|
@@ -5997,14 +6118,14 @@ var useKalshiKycFlow = ({
|
|
|
5997
6118
|
walletAddress,
|
|
5998
6119
|
onError
|
|
5999
6120
|
}) => {
|
|
6000
|
-
const client = (0,
|
|
6001
|
-
const [isVerifyModalOpen, setIsVerifyModalOpen] = (0,
|
|
6002
|
-
const [showSuccessModal, setShowSuccessModal] = (0,
|
|
6003
|
-
const [isInitiating, setIsInitiating] = (0,
|
|
6004
|
-
const [needsDepositAddress, setNeedsDepositAddress] = (0,
|
|
6005
|
-
const initiationAttemptRef = (0,
|
|
6006
|
-
const { isReady, isTimedOut } = (0,
|
|
6007
|
-
const pendingState = (0,
|
|
6121
|
+
const client = (0, import_hooks29.useAggClient)();
|
|
6122
|
+
const [isVerifyModalOpen, setIsVerifyModalOpen] = (0, import_react8.useState)(false);
|
|
6123
|
+
const [showSuccessModal, setShowSuccessModal] = (0, import_react8.useState)(false);
|
|
6124
|
+
const [isInitiating, setIsInitiating] = (0, import_react8.useState)(false);
|
|
6125
|
+
const [needsDepositAddress, setNeedsDepositAddress] = (0, import_react8.useState)(false);
|
|
6126
|
+
const initiationAttemptRef = (0, import_react8.useRef)(0);
|
|
6127
|
+
const { isReady, isTimedOut } = (0, import_hooks29.useDepositAddresses)({ enabled: needsDepositAddress, poll: true });
|
|
6128
|
+
const pendingState = (0, import_react8.useMemo)(
|
|
6008
6129
|
() => ({
|
|
6009
6130
|
venue: "kalshi",
|
|
6010
6131
|
userId: userId != null ? userId : null,
|
|
@@ -6012,28 +6133,28 @@ var useKalshiKycFlow = ({
|
|
|
6012
6133
|
}),
|
|
6013
6134
|
[userId, walletAddress]
|
|
6014
6135
|
);
|
|
6015
|
-
const resetInitiation = (0,
|
|
6136
|
+
const resetInitiation = (0, import_react8.useCallback)(() => {
|
|
6016
6137
|
setIsInitiating(false);
|
|
6017
6138
|
setNeedsDepositAddress(false);
|
|
6018
6139
|
}, []);
|
|
6019
|
-
const closeVerifyModal = (0,
|
|
6140
|
+
const closeVerifyModal = (0, import_react8.useCallback)(() => {
|
|
6020
6141
|
initiationAttemptRef.current += 1;
|
|
6021
6142
|
clearKycPendingState();
|
|
6022
6143
|
resetInitiation();
|
|
6023
6144
|
setIsVerifyModalOpen(false);
|
|
6024
6145
|
}, [resetInitiation]);
|
|
6025
|
-
const closeSuccessModal = (0,
|
|
6146
|
+
const closeSuccessModal = (0, import_react8.useCallback)(() => {
|
|
6026
6147
|
setShowSuccessModal(false);
|
|
6027
6148
|
}, []);
|
|
6028
|
-
const openVerifyModal = (0,
|
|
6149
|
+
const openVerifyModal = (0, import_react8.useCallback)(() => {
|
|
6029
6150
|
setIsVerifyModalOpen(true);
|
|
6030
6151
|
}, []);
|
|
6031
|
-
const startVerification = (0,
|
|
6152
|
+
const startVerification = (0, import_react8.useCallback)(() => {
|
|
6032
6153
|
initiationAttemptRef.current += 1;
|
|
6033
6154
|
setIsInitiating(true);
|
|
6034
6155
|
setNeedsDepositAddress(true);
|
|
6035
6156
|
}, []);
|
|
6036
|
-
(0,
|
|
6157
|
+
(0, import_react8.useEffect)(() => {
|
|
6037
6158
|
if (!isInitiating || !isReady) return;
|
|
6038
6159
|
const attemptId = initiationAttemptRef.current;
|
|
6039
6160
|
const redirectUri = window.location.href;
|
|
@@ -6050,14 +6171,14 @@ var useKalshiKycFlow = ({
|
|
|
6050
6171
|
resetInitiation();
|
|
6051
6172
|
});
|
|
6052
6173
|
}, [client, isInitiating, isReady, onError, pendingState, resetInitiation]);
|
|
6053
|
-
(0,
|
|
6174
|
+
(0, import_react8.useEffect)(() => {
|
|
6054
6175
|
if (isTimedOut && isInitiating) {
|
|
6055
6176
|
clearKycPendingState();
|
|
6056
6177
|
resetInitiation();
|
|
6057
6178
|
onError == null ? void 0 : onError(new Error("Deposit address provisioning timed out"));
|
|
6058
6179
|
}
|
|
6059
6180
|
}, [isInitiating, isTimedOut, onError, resetInitiation]);
|
|
6060
|
-
(0,
|
|
6181
|
+
(0, import_react8.useEffect)(() => {
|
|
6061
6182
|
const storedPendingState = getKycPendingState();
|
|
6062
6183
|
const isMatchingSession = (storedPendingState == null ? void 0 : storedPendingState.venue) === "kalshi" && storedPendingState.userId === pendingState.userId && storedPendingState.walletAddress === pendingState.walletAddress;
|
|
6063
6184
|
if (isKalshiVerified && isMatchingSession) {
|
|
@@ -7647,7 +7768,7 @@ var isPercentageBelowMinimum = (value, minimumValue) => {
|
|
|
7647
7768
|
};
|
|
7648
7769
|
|
|
7649
7770
|
// src/trading/place-order/index.place-order.failure.tsx
|
|
7650
|
-
var
|
|
7771
|
+
var import_jsx_runtime121 = require("react/jsx-runtime");
|
|
7651
7772
|
var resolveFailureActionHandler = ({
|
|
7652
7773
|
action,
|
|
7653
7774
|
onDone,
|
|
@@ -7660,12 +7781,12 @@ var resolveFailureActionHandler = ({
|
|
|
7660
7781
|
};
|
|
7661
7782
|
var renderPartialFailureStep = (step) => {
|
|
7662
7783
|
const isWarningStep = step.tone === "warning" || step.tone === "error";
|
|
7663
|
-
return /* @__PURE__ */ (0,
|
|
7784
|
+
return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(
|
|
7664
7785
|
"div",
|
|
7665
7786
|
{
|
|
7666
7787
|
className: "flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
|
|
7667
7788
|
children: [
|
|
7668
|
-
/* @__PURE__ */ (0,
|
|
7789
|
+
/* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
|
|
7669
7790
|
Icon,
|
|
7670
7791
|
{
|
|
7671
7792
|
name: isWarningStep ? "warning-filled" : "check-circle",
|
|
@@ -7674,8 +7795,8 @@ var renderPartialFailureStep = (step) => {
|
|
|
7674
7795
|
"aria-hidden": "true"
|
|
7675
7796
|
}
|
|
7676
7797
|
),
|
|
7677
|
-
/* @__PURE__ */ (0,
|
|
7678
|
-
step.venue ? /* @__PURE__ */ (0,
|
|
7798
|
+
/* @__PURE__ */ (0, import_jsx_runtime121.jsx)("p", { className: "min-w-0 flex-1", children: step.label }),
|
|
7799
|
+
step.venue ? /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(VenueLogo, { venue: step.venue, size: "small", className: "h-4 w-4 shrink-0" }) : null
|
|
7679
7800
|
]
|
|
7680
7801
|
},
|
|
7681
7802
|
step.id
|
|
@@ -7694,10 +7815,10 @@ var PlaceOrderFailureView = ({
|
|
|
7694
7815
|
const shouldShowPartialFailureLayout = summary.kind === "partial_fill";
|
|
7695
7816
|
const failureStepGroups = shouldShowPartialFailureLayout ? groupPlaceOrderFailureSteps(summary.steps) : [];
|
|
7696
7817
|
if (shouldShowPartialFailureLayout) {
|
|
7697
|
-
return /* @__PURE__ */ (0,
|
|
7698
|
-
/* @__PURE__ */ (0,
|
|
7699
|
-
/* @__PURE__ */ (0,
|
|
7700
|
-
/* @__PURE__ */ (0,
|
|
7818
|
+
return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(Card, { className: cn("group/agg-order-panel", getPlaceOrderContainerClassName(), className), children: /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)("div", { className: "agg-order-failure-body flex flex-col gap-6 p-5", children: [
|
|
7819
|
+
/* @__PURE__ */ (0, import_jsx_runtime121.jsxs)("div", { className: "agg-order-failure-header flex flex-col gap-2", children: [
|
|
7820
|
+
/* @__PURE__ */ (0, import_jsx_runtime121.jsxs)("div", { className: "agg-order-failure-market flex items-center gap-3", children: [
|
|
7821
|
+
/* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
|
|
7701
7822
|
RemoteImage,
|
|
7702
7823
|
{
|
|
7703
7824
|
src: (_a = summary.eventImage) != null ? _a : null,
|
|
@@ -7705,12 +7826,12 @@ var PlaceOrderFailureView = ({
|
|
|
7705
7826
|
className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
|
|
7706
7827
|
}
|
|
7707
7828
|
),
|
|
7708
|
-
/* @__PURE__ */ (0,
|
|
7829
|
+
/* @__PURE__ */ (0, import_jsx_runtime121.jsx)("p", { className: "min-w-0 flex-1 text-agg-base font-agg-bold leading-agg-6 text-agg-foreground line-clamp-2", children: summary.eventTitle })
|
|
7709
7830
|
] }),
|
|
7710
|
-
summary.eventSubtitle ? /* @__PURE__ */ (0,
|
|
7831
|
+
summary.eventSubtitle ? /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
|
|
7711
7832
|
] }),
|
|
7712
|
-
/* @__PURE__ */ (0,
|
|
7713
|
-
/* @__PURE__ */ (0,
|
|
7833
|
+
/* @__PURE__ */ (0, import_jsx_runtime121.jsx)("div", { className: "flex flex-col gap-4", children: failureStepGroups.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("div", { className: "flex flex-col gap-2", children: group.map((step) => renderPartialFailureStep(step)) }, `failure-group-${groupIndex}`)) }),
|
|
7834
|
+
/* @__PURE__ */ (0, import_jsx_runtime121.jsx)("div", { className: "flex items-center gap-4", children: summary.actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
|
|
7714
7835
|
Button,
|
|
7715
7836
|
{
|
|
7716
7837
|
variant: "tertiary",
|
|
@@ -7724,10 +7845,10 @@ var PlaceOrderFailureView = ({
|
|
|
7724
7845
|
)) })
|
|
7725
7846
|
] }) });
|
|
7726
7847
|
}
|
|
7727
|
-
return /* @__PURE__ */ (0,
|
|
7728
|
-
/* @__PURE__ */ (0,
|
|
7729
|
-
/* @__PURE__ */ (0,
|
|
7730
|
-
/* @__PURE__ */ (0,
|
|
7848
|
+
return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(Card, { className: cn("group/agg-order-panel", getPlaceOrderContainerClassName(), className), children: /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)("div", { className: "agg-order-failure-body flex flex-col gap-6 p-5", children: [
|
|
7849
|
+
/* @__PURE__ */ (0, import_jsx_runtime121.jsxs)("div", { className: "agg-order-failure-header flex flex-col gap-2", children: [
|
|
7850
|
+
/* @__PURE__ */ (0, import_jsx_runtime121.jsxs)("div", { className: "agg-order-failure-market flex items-center gap-3", children: [
|
|
7851
|
+
/* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
|
|
7731
7852
|
RemoteImage,
|
|
7732
7853
|
{
|
|
7733
7854
|
src: (_b = summary.eventImage) != null ? _b : null,
|
|
@@ -7735,11 +7856,11 @@ var PlaceOrderFailureView = ({
|
|
|
7735
7856
|
className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
|
|
7736
7857
|
}
|
|
7737
7858
|
),
|
|
7738
|
-
/* @__PURE__ */ (0,
|
|
7859
|
+
/* @__PURE__ */ (0, import_jsx_runtime121.jsx)("p", { className: "min-w-0 flex-1 text-agg-base font-agg-bold leading-agg-6 text-agg-foreground line-clamp-2", children: summary.eventTitle })
|
|
7739
7860
|
] }),
|
|
7740
|
-
summary.eventSubtitle ? /* @__PURE__ */ (0,
|
|
7861
|
+
summary.eventSubtitle ? /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
|
|
7741
7862
|
] }),
|
|
7742
|
-
/* @__PURE__ */ (0,
|
|
7863
|
+
/* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
|
|
7743
7864
|
InlineAlert,
|
|
7744
7865
|
{
|
|
7745
7866
|
tone: "error",
|
|
@@ -7748,7 +7869,7 @@ var PlaceOrderFailureView = ({
|
|
|
7748
7869
|
message: tradingLabels.orderFailureDescription((_c = summary.errorMessage) != null ? _c : "")
|
|
7749
7870
|
}
|
|
7750
7871
|
),
|
|
7751
|
-
/* @__PURE__ */ (0,
|
|
7872
|
+
/* @__PURE__ */ (0, import_jsx_runtime121.jsx)("div", { className: "agg-order-failure-actions flex items-center gap-3", children: summary.actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
|
|
7752
7873
|
Button,
|
|
7753
7874
|
{
|
|
7754
7875
|
variant: action.variant === "retry" ? "primary" : "secondary",
|
|
@@ -7765,8 +7886,8 @@ var PlaceOrderFailureView = ({
|
|
|
7765
7886
|
PlaceOrderFailureView.displayName = "PlaceOrderFailureView";
|
|
7766
7887
|
|
|
7767
7888
|
// src/trading/place-order/index.place-order.success.tsx
|
|
7768
|
-
var
|
|
7769
|
-
var
|
|
7889
|
+
var import_react9 = require("react");
|
|
7890
|
+
var import_jsx_runtime122 = require("react/jsx-runtime");
|
|
7770
7891
|
var resolveBuyToWinLabel = (shares) => {
|
|
7771
7892
|
if (!shares) return "$0";
|
|
7772
7893
|
return shares.startsWith("$") ? shares : `$${shares}`;
|
|
@@ -7779,7 +7900,7 @@ var PlaceOrderSuccessView = ({
|
|
|
7779
7900
|
onShare: _onShare
|
|
7780
7901
|
}) => {
|
|
7781
7902
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
7782
|
-
const [isExecutionDetailsExpanded, setIsExecutionDetailsExpanded] = (0,
|
|
7903
|
+
const [isExecutionDetailsExpanded, setIsExecutionDetailsExpanded] = (0, import_react9.useState)(true);
|
|
7783
7904
|
const doneLabel = tradingLabels.orderDone;
|
|
7784
7905
|
const _shareLabel = (_a = tradingLabels.orderShare) != null ? _a : "Share";
|
|
7785
7906
|
const potentialReturnLabel = summary.potentialReturnLabel && tradingLabels.potentialReturnBonus ? tradingLabels.potentialReturnBonus(summary.potentialReturnLabel) : summary.potentialReturnLabel ? `+${summary.potentialReturnLabel} Better Payout` : null;
|
|
@@ -7797,10 +7918,10 @@ var PlaceOrderSuccessView = ({
|
|
|
7797
7918
|
const resolveStepIconClassName = (tone) => {
|
|
7798
7919
|
return tone === "warning" || tone === "error" ? "text-agg-warning" : "text-agg-primary";
|
|
7799
7920
|
};
|
|
7800
|
-
return /* @__PURE__ */ (0,
|
|
7801
|
-
summary.eventTitle ? /* @__PURE__ */ (0,
|
|
7802
|
-
/* @__PURE__ */ (0,
|
|
7803
|
-
/* @__PURE__ */ (0,
|
|
7921
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Card, { className: cn("group/agg-order-panel", getPlaceOrderContainerClassName(), className), children: /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { className: "agg-order-success-body flex flex-col gap-6 p-5", children: [
|
|
7922
|
+
summary.eventTitle ? /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { className: "agg-order-success-header flex flex-col gap-2", children: [
|
|
7923
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { className: "agg-order-success-market flex items-center gap-3", children: [
|
|
7924
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
7804
7925
|
RemoteImage,
|
|
7805
7926
|
{
|
|
7806
7927
|
src: (_h = summary.eventImage) != null ? _h : null,
|
|
@@ -7808,12 +7929,12 @@ var PlaceOrderSuccessView = ({
|
|
|
7808
7929
|
className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
|
|
7809
7930
|
}
|
|
7810
7931
|
),
|
|
7811
|
-
/* @__PURE__ */ (0,
|
|
7932
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)("p", { className: "min-w-0 flex-1 text-agg-base font-agg-bold leading-agg-6 text-agg-foreground line-clamp-2", children: summary.eventTitle })
|
|
7812
7933
|
] }),
|
|
7813
|
-
summary.eventDateLabel ? /* @__PURE__ */ (0,
|
|
7934
|
+
summary.eventDateLabel ? /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventDateLabel }) : null
|
|
7814
7935
|
] }) : null,
|
|
7815
|
-
executionStepGroups.length > 0 ? /* @__PURE__ */ (0,
|
|
7816
|
-
/* @__PURE__ */ (0,
|
|
7936
|
+
executionStepGroups.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { className: "agg-order-success-timeline flex flex-col gap-2", children: [
|
|
7937
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
7817
7938
|
"div",
|
|
7818
7939
|
{
|
|
7819
7940
|
"aria-hidden": !isExecutionDetailsExpanded,
|
|
@@ -7826,12 +7947,12 @@ var PlaceOrderSuccessView = ({
|
|
|
7826
7947
|
"transition-[grid-template-rows,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
|
|
7827
7948
|
)
|
|
7828
7949
|
),
|
|
7829
|
-
children: /* @__PURE__ */ (0,
|
|
7950
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { className: "min-h-0", children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { className: "flex flex-col gap-4 pb-2", children: detailedStepGroups.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { className: "flex flex-col gap-2", children: group.map((step) => /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(
|
|
7830
7951
|
"div",
|
|
7831
7952
|
{
|
|
7832
7953
|
className: "flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
|
|
7833
7954
|
children: [
|
|
7834
|
-
/* @__PURE__ */ (0,
|
|
7955
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
7835
7956
|
Icon,
|
|
7836
7957
|
{
|
|
7837
7958
|
name: resolveStepIconName(step.tone),
|
|
@@ -7840,8 +7961,8 @@ var PlaceOrderSuccessView = ({
|
|
|
7840
7961
|
"aria-hidden": "true"
|
|
7841
7962
|
}
|
|
7842
7963
|
),
|
|
7843
|
-
/* @__PURE__ */ (0,
|
|
7844
|
-
step.venue ? /* @__PURE__ */ (0,
|
|
7964
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)("p", { className: "min-w-0 flex-1", children: step.label }),
|
|
7965
|
+
step.venue ? /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
7845
7966
|
VenueLogo,
|
|
7846
7967
|
{
|
|
7847
7968
|
venue: step.venue,
|
|
@@ -7855,7 +7976,7 @@ var PlaceOrderSuccessView = ({
|
|
|
7855
7976
|
)) }, `execution-group-${groupIndex}`)) }) })
|
|
7856
7977
|
}
|
|
7857
7978
|
),
|
|
7858
|
-
finalStep ? hasExecutionDetails ? /* @__PURE__ */ (0,
|
|
7979
|
+
finalStep ? hasExecutionDetails ? /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(
|
|
7859
7980
|
"button",
|
|
7860
7981
|
{
|
|
7861
7982
|
type: "button",
|
|
@@ -7867,7 +7988,7 @@ var PlaceOrderSuccessView = ({
|
|
|
7867
7988
|
),
|
|
7868
7989
|
onClick: () => setIsExecutionDetailsExpanded((currentValue) => !currentValue),
|
|
7869
7990
|
children: [
|
|
7870
|
-
/* @__PURE__ */ (0,
|
|
7991
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
7871
7992
|
Icon,
|
|
7872
7993
|
{
|
|
7873
7994
|
name: resolveStepIconName(finalStep.tone),
|
|
@@ -7876,8 +7997,8 @@ var PlaceOrderSuccessView = ({
|
|
|
7876
7997
|
"aria-hidden": "true"
|
|
7877
7998
|
}
|
|
7878
7999
|
),
|
|
7879
|
-
/* @__PURE__ */ (0,
|
|
7880
|
-
/* @__PURE__ */ (0,
|
|
8000
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)("p", { className: "min-w-0 flex-1", children: finalStep.label }),
|
|
8001
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
7881
8002
|
Icon,
|
|
7882
8003
|
{
|
|
7883
8004
|
name: isExecutionDetailsExpanded ? "chevron-up" : "chevron-down",
|
|
@@ -7888,8 +8009,8 @@ var PlaceOrderSuccessView = ({
|
|
|
7888
8009
|
)
|
|
7889
8010
|
]
|
|
7890
8011
|
}
|
|
7891
|
-
) : /* @__PURE__ */ (0,
|
|
7892
|
-
/* @__PURE__ */ (0,
|
|
8012
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { className: "flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground", children: [
|
|
8013
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
7893
8014
|
Icon,
|
|
7894
8015
|
{
|
|
7895
8016
|
name: resolveStepIconName(finalStep.tone),
|
|
@@ -7898,34 +8019,34 @@ var PlaceOrderSuccessView = ({
|
|
|
7898
8019
|
"aria-hidden": "true"
|
|
7899
8020
|
}
|
|
7900
8021
|
),
|
|
7901
|
-
/* @__PURE__ */ (0,
|
|
8022
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)("p", { className: "min-w-0 flex-1", children: finalStep.label })
|
|
7902
8023
|
] }) : null
|
|
7903
8024
|
] }) : null,
|
|
7904
|
-
/* @__PURE__ */ (0,
|
|
8025
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(
|
|
7905
8026
|
"div",
|
|
7906
8027
|
{
|
|
7907
8028
|
className: cn(
|
|
7908
8029
|
"agg-order-success-pill flex min-h-12 w-full items-center justify-center gap-2 rounded-agg-full px-6 py-2.5 text-center text-agg-base font-agg-bold leading-agg-6 text-agg-on-primary bg-agg-success"
|
|
7909
8030
|
),
|
|
7910
8031
|
children: [
|
|
7911
|
-
/* @__PURE__ */ (0,
|
|
7912
|
-
/* @__PURE__ */ (0,
|
|
8032
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Icon, { name: "success-check", size: "small", className: "h-4 w-4 shrink-0 text-current" }),
|
|
8033
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)("span", { children: resolvedActionLabel })
|
|
7913
8034
|
]
|
|
7914
8035
|
}
|
|
7915
8036
|
),
|
|
7916
|
-
/* @__PURE__ */ (0,
|
|
7917
|
-
/* @__PURE__ */ (0,
|
|
7918
|
-
/* @__PURE__ */ (0,
|
|
8037
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { className: "agg-order-success-summary flex items-center justify-between gap-4", children: [
|
|
8038
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.amount(resolvedTradeSide) }),
|
|
8039
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)("p", { className: "text-right text-[30px] font-agg-bold leading-[36px] text-agg-foreground", children: resolvedAmountLabel })
|
|
7919
8040
|
] }),
|
|
7920
|
-
/* @__PURE__ */ (0,
|
|
7921
|
-
/* @__PURE__ */ (0,
|
|
7922
|
-
/* @__PURE__ */ (0,
|
|
8041
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { className: "agg-order-success-summary flex items-center justify-between gap-4", children: [
|
|
8042
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.toWin(resolvedTradeSide) }),
|
|
8043
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)("p", { className: "text-right text-[30px] font-agg-bold leading-[36px] text-agg-success", children: resolvedToWinLabel })
|
|
7923
8044
|
] }),
|
|
7924
|
-
summary.potentialReturnLabel ? /* @__PURE__ */ (0,
|
|
7925
|
-
/* @__PURE__ */ (0,
|
|
7926
|
-
/* @__PURE__ */ (0,
|
|
8045
|
+
summary.potentialReturnLabel ? /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { className: "flex w-full flex-col items-center justify-center gap-1 overflow-hidden rounded-agg-lg border border-agg-primary/50 bg-gradient-to-b from-agg-primary/8 to-agg-primary/15 p-3 text-center", children: [
|
|
8046
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)("p", { className: "bg-gradient-to-r from-agg-primary to-agg-primary-hover bg-clip-text text-agg-lg font-agg-bold leading-[28px] text-transparent", children: potentialReturnLabel }),
|
|
8047
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)("p", { className: "text-agg-xs leading-agg-4 text-agg-foreground", children: (_i = tradingLabels.withSmartRouting) != null ? _i : "with Smart Routing" })
|
|
7927
8048
|
] }) : null,
|
|
7928
|
-
/* @__PURE__ */ (0,
|
|
8049
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { className: "agg-order-success-actions flex gap-3", children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
7929
8050
|
Button,
|
|
7930
8051
|
{
|
|
7931
8052
|
variant: "secondary",
|
|
@@ -7941,7 +8062,23 @@ var PlaceOrderSuccessView = ({
|
|
|
7941
8062
|
PlaceOrderSuccessView.displayName = "PlaceOrderSuccessView";
|
|
7942
8063
|
|
|
7943
8064
|
// src/trading/place-order/index.tsx
|
|
7944
|
-
var
|
|
8065
|
+
var import_jsx_runtime123 = require("react/jsx-runtime");
|
|
8066
|
+
var SELL_SHARE_INPUT_DECIMALS = 6;
|
|
8067
|
+
var SELL_SHARE_DISPLAY_DECIMALS = 2;
|
|
8068
|
+
var floorToDecimals = (value, decimals) => {
|
|
8069
|
+
if (!Number.isFinite(value) || value <= 0) return 0;
|
|
8070
|
+
const scale = __pow(10, decimals);
|
|
8071
|
+
return Math.trunc(value * scale) / scale;
|
|
8072
|
+
};
|
|
8073
|
+
var formatFlooredShareAmount = (value, decimals) => {
|
|
8074
|
+
const flooredValue = floorToDecimals(value, decimals);
|
|
8075
|
+
if (flooredValue <= 0) return "0";
|
|
8076
|
+
const formattedValue = flooredValue.toLocaleString("en-US", {
|
|
8077
|
+
minimumFractionDigits: 0,
|
|
8078
|
+
maximumFractionDigits: decimals
|
|
8079
|
+
});
|
|
8080
|
+
return formattedValue.replace(/(\.\d*?[1-9])0+$/u, "$1").replace(/\.0+$/u, "");
|
|
8081
|
+
};
|
|
7945
8082
|
var resolveRefetchedQuoteData = (result) => {
|
|
7946
8083
|
if (!result || typeof result !== "object" || !("data" in result)) return null;
|
|
7947
8084
|
const data = result.data;
|
|
@@ -7960,7 +8097,7 @@ var LoadingGlyph = ({
|
|
|
7960
8097
|
className,
|
|
7961
8098
|
enableAnimations
|
|
7962
8099
|
}) => {
|
|
7963
|
-
return /* @__PURE__ */ (0,
|
|
8100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
7964
8101
|
"span",
|
|
7965
8102
|
{
|
|
7966
8103
|
"aria-hidden": "true",
|
|
@@ -7980,25 +8117,25 @@ var PlaceOrderSlippageControl = ({
|
|
|
7980
8117
|
minimumValue: slippageMinimumValue
|
|
7981
8118
|
}) => {
|
|
7982
8119
|
var _a, _b;
|
|
7983
|
-
const labels = (0,
|
|
7984
|
-
const containerRef = (0,
|
|
7985
|
-
const triggerRef = (0,
|
|
7986
|
-
const inputRef = (0,
|
|
7987
|
-
const warningId = (0,
|
|
8120
|
+
const labels = (0, import_hooks30.useLabels)();
|
|
8121
|
+
const containerRef = (0, import_react11.useRef)(null);
|
|
8122
|
+
const triggerRef = (0, import_react11.useRef)(null);
|
|
8123
|
+
const inputRef = (0, import_react11.useRef)(null);
|
|
8124
|
+
const warningId = (0, import_react11.useId)();
|
|
7988
8125
|
const defaultValue = finalizePercentageValue(slippageDefaultValue);
|
|
7989
8126
|
const committedValue = finalizePercentageValue(slippageValue) || defaultValue;
|
|
7990
|
-
const [draftValue, setDraftValue] = (0,
|
|
7991
|
-
const [isEditing, setIsEditing] = (0,
|
|
8127
|
+
const [draftValue, setDraftValue] = (0, import_react11.useState)(committedValue);
|
|
8128
|
+
const [isEditing, setIsEditing] = (0, import_react11.useState)(
|
|
7992
8129
|
() => isPercentageBelowMinimum(committedValue, slippageMinimumValue)
|
|
7993
8130
|
);
|
|
7994
|
-
const [shouldFocusInput, setShouldFocusInput] = (0,
|
|
7995
|
-
(0,
|
|
8131
|
+
const [shouldFocusInput, setShouldFocusInput] = (0, import_react11.useState)(false);
|
|
8132
|
+
(0, import_react11.useEffect)(() => {
|
|
7996
8133
|
setDraftValue(committedValue);
|
|
7997
8134
|
if (isPercentageBelowMinimum(committedValue, slippageMinimumValue)) {
|
|
7998
8135
|
setIsEditing(true);
|
|
7999
8136
|
}
|
|
8000
8137
|
}, [committedValue, slippageMinimumValue]);
|
|
8001
|
-
(0,
|
|
8138
|
+
(0, import_react11.useEffect)(() => {
|
|
8002
8139
|
if (!shouldFocusInput) return;
|
|
8003
8140
|
requestAnimationFrame(() => {
|
|
8004
8141
|
var _a2, _b2;
|
|
@@ -8015,7 +8152,7 @@ var PlaceOrderSlippageControl = ({
|
|
|
8015
8152
|
Number(committedValue || slippageDefaultValue || DEFAULT_SLIPPAGE_VALUE)
|
|
8016
8153
|
);
|
|
8017
8154
|
const resolvedAutoLabel = labels.trading.resetSlippage;
|
|
8018
|
-
const resolvedWarningMessage = (0,
|
|
8155
|
+
const resolvedWarningMessage = (0, import_react11.useMemo)(() => {
|
|
8019
8156
|
if (isLowSlippage) {
|
|
8020
8157
|
return labels.trading.slippageLow(slippageMinimumValue);
|
|
8021
8158
|
}
|
|
@@ -8078,8 +8215,8 @@ var PlaceOrderSlippageControl = ({
|
|
|
8078
8215
|
if (!isEditing) return;
|
|
8079
8216
|
handleCommitDraft(false);
|
|
8080
8217
|
};
|
|
8081
|
-
return /* @__PURE__ */ (0,
|
|
8082
|
-
/* @__PURE__ */ (0,
|
|
8218
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { ref: containerRef, className: "agg-slippage-control w-full", onBlur: handleContainerBlur, children: [
|
|
8219
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
|
|
8083
8220
|
"button",
|
|
8084
8221
|
{
|
|
8085
8222
|
ref: triggerRef,
|
|
@@ -8097,8 +8234,8 @@ var PlaceOrderSlippageControl = ({
|
|
|
8097
8234
|
),
|
|
8098
8235
|
onClick: handleToggleEditing,
|
|
8099
8236
|
children: [
|
|
8100
|
-
/* @__PURE__ */ (0,
|
|
8101
|
-
/* @__PURE__ */ (0,
|
|
8237
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { className: "agg-slippage-label", children: collapsedLabel }),
|
|
8238
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8102
8239
|
Icon,
|
|
8103
8240
|
{
|
|
8104
8241
|
name: isEditing ? "chevron-up" : "pencil",
|
|
@@ -8110,7 +8247,7 @@ var PlaceOrderSlippageControl = ({
|
|
|
8110
8247
|
]
|
|
8111
8248
|
}
|
|
8112
8249
|
),
|
|
8113
|
-
/* @__PURE__ */ (0,
|
|
8250
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8114
8251
|
"div",
|
|
8115
8252
|
{
|
|
8116
8253
|
"aria-hidden": !isEditing,
|
|
@@ -8124,10 +8261,10 @@ var PlaceOrderSlippageControl = ({
|
|
|
8124
8261
|
"transition-[grid-template-rows,opacity,margin-top] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)]"
|
|
8125
8262
|
)
|
|
8126
8263
|
),
|
|
8127
|
-
children: /* @__PURE__ */ (0,
|
|
8128
|
-
/* @__PURE__ */ (0,
|
|
8129
|
-
/* @__PURE__ */ (0,
|
|
8130
|
-
/* @__PURE__ */ (0,
|
|
8264
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "min-h-0", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-slippage-editor-body flex flex-col gap-2", children: [
|
|
8265
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-slippage-input-row flex h-9 overflow-hidden rounded-agg-sm border border-agg-separator", children: [
|
|
8266
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-slippage-input-group flex min-w-0 flex-1 items-center gap-2 bg-agg-secondary px-3", children: [
|
|
8267
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8131
8268
|
"input",
|
|
8132
8269
|
{
|
|
8133
8270
|
ref: inputRef,
|
|
@@ -8142,7 +8279,7 @@ var PlaceOrderSlippageControl = ({
|
|
|
8142
8279
|
onKeyDown: handleInputKeyDown
|
|
8143
8280
|
}
|
|
8144
8281
|
),
|
|
8145
|
-
/* @__PURE__ */ (0,
|
|
8282
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8146
8283
|
"button",
|
|
8147
8284
|
{
|
|
8148
8285
|
type: "button",
|
|
@@ -8160,8 +8297,8 @@ var PlaceOrderSlippageControl = ({
|
|
|
8160
8297
|
}
|
|
8161
8298
|
)
|
|
8162
8299
|
] }),
|
|
8163
|
-
/* @__PURE__ */ (0,
|
|
8164
|
-
/* @__PURE__ */ (0,
|
|
8300
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "h-full w-px bg-agg-separator", "aria-hidden": "true" }),
|
|
8301
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8165
8302
|
"div",
|
|
8166
8303
|
{
|
|
8167
8304
|
className: "agg-slippage-suffix flex w-9 items-center justify-center bg-agg-secondary-hover text-agg-sm leading-agg-5 text-agg-muted-foreground",
|
|
@@ -8170,7 +8307,7 @@ var PlaceOrderSlippageControl = ({
|
|
|
8170
8307
|
}
|
|
8171
8308
|
)
|
|
8172
8309
|
] }),
|
|
8173
|
-
/* @__PURE__ */ (0,
|
|
8310
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8174
8311
|
"div",
|
|
8175
8312
|
{
|
|
8176
8313
|
"aria-hidden": !resolvedWarningMessage,
|
|
@@ -8184,13 +8321,13 @@ var PlaceOrderSlippageControl = ({
|
|
|
8184
8321
|
"transition-[grid-template-rows,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
|
|
8185
8322
|
)
|
|
8186
8323
|
),
|
|
8187
|
-
children: /* @__PURE__ */ (0,
|
|
8324
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "min-h-0", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
|
|
8188
8325
|
"div",
|
|
8189
8326
|
{
|
|
8190
8327
|
id: warningId,
|
|
8191
8328
|
className: "agg-slippage-warning-message flex items-start gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
|
|
8192
8329
|
children: [
|
|
8193
|
-
/* @__PURE__ */ (0,
|
|
8330
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8194
8331
|
Icon,
|
|
8195
8332
|
{
|
|
8196
8333
|
name: "warning-filled",
|
|
@@ -8199,7 +8336,7 @@ var PlaceOrderSlippageControl = ({
|
|
|
8199
8336
|
color: "currentColor"
|
|
8200
8337
|
}
|
|
8201
8338
|
),
|
|
8202
|
-
/* @__PURE__ */ (0,
|
|
8339
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { children: resolvedWarningMessage != null ? resolvedWarningMessage : "" })
|
|
8203
8340
|
]
|
|
8204
8341
|
}
|
|
8205
8342
|
) })
|
|
@@ -8219,9 +8356,9 @@ var renderCardHeader = ({
|
|
|
8219
8356
|
onClose
|
|
8220
8357
|
}) => {
|
|
8221
8358
|
if (!headerTitle) return null;
|
|
8222
|
-
return /* @__PURE__ */ (0,
|
|
8223
|
-
/* @__PURE__ */ (0,
|
|
8224
|
-
/* @__PURE__ */ (0,
|
|
8359
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: cn("agg-order-panel-header flex flex-col gap-2", className), children: [
|
|
8360
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-order-market-summary flex items-center gap-3", children: [
|
|
8361
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8225
8362
|
RemoteImage,
|
|
8226
8363
|
{
|
|
8227
8364
|
src: headerImage,
|
|
@@ -8229,32 +8366,78 @@ var renderCardHeader = ({
|
|
|
8229
8366
|
className: "agg-order-market-image h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
|
|
8230
8367
|
}
|
|
8231
8368
|
),
|
|
8232
|
-
/* @__PURE__ */ (0,
|
|
8233
|
-
onClose ? /* @__PURE__ */ (0,
|
|
8369
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "agg-order-market-title min-w-0 flex-1 text-agg-base font-agg-bold leading-agg-6 text-agg-foreground line-clamp-2", children: headerTitle }),
|
|
8370
|
+
onClose ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8234
8371
|
"button",
|
|
8235
8372
|
{
|
|
8236
8373
|
type: "button",
|
|
8237
8374
|
className: "agg-order-close -mr-1 -mt-1 hidden shrink-0 cursor-pointer items-center justify-center p-1 text-agg-muted-foreground hover:text-agg-foreground sm:flex",
|
|
8238
8375
|
"aria-label": "Close",
|
|
8239
8376
|
onClick: onClose,
|
|
8240
|
-
children: /* @__PURE__ */ (0,
|
|
8377
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(CloseIcon, { className: "h-5 w-5" })
|
|
8241
8378
|
}
|
|
8242
8379
|
) : null
|
|
8243
8380
|
] }),
|
|
8244
|
-
headerSubtitle ? /* @__PURE__ */ (0,
|
|
8381
|
+
headerSubtitle ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "agg-order-market-subtitle text-agg-base leading-agg-6 text-agg-foreground", children: headerSubtitle }) : null
|
|
8245
8382
|
] });
|
|
8246
8383
|
};
|
|
8247
8384
|
var PlaceOrderResolvedView = ({
|
|
8248
8385
|
classNames,
|
|
8249
8386
|
tradingState,
|
|
8387
|
+
resolutionTimestamp,
|
|
8250
8388
|
resolvedClaim,
|
|
8251
|
-
className
|
|
8389
|
+
className,
|
|
8390
|
+
isSportsEvent = false
|
|
8252
8391
|
}) => {
|
|
8253
|
-
var _a
|
|
8254
|
-
const labels = (0,
|
|
8392
|
+
var _a;
|
|
8393
|
+
const labels = (0, import_hooks30.useLabels)();
|
|
8255
8394
|
const tradingLabels = labels.trading;
|
|
8256
|
-
const
|
|
8257
|
-
|
|
8395
|
+
const resolvingTimestamp = (_a = resolutionTimestamp != null ? resolutionTimestamp : tradingState.resolvesAt) != null ? _a : tradingState.endsAt;
|
|
8396
|
+
const isResolvingMarket = false;
|
|
8397
|
+
const resolvingSubtitle = tradingState.market ? (() => {
|
|
8398
|
+
const endDateLabel = isSportsEvent ? formatSportsEventTimeEt(resolvingTimestamp != null ? resolvingTimestamp : "") : getTradingDateLabel(resolvingTimestamp != null ? resolvingTimestamp : "");
|
|
8399
|
+
return endDateLabel ? `${tradingState.market.question} \xB7 ${endDateLabel}` : tradingState.market.question;
|
|
8400
|
+
})() : "";
|
|
8401
|
+
if (isResolvingMarket) {
|
|
8402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8403
|
+
Card,
|
|
8404
|
+
{
|
|
8405
|
+
className: cn(
|
|
8406
|
+
"group/agg-order-panel",
|
|
8407
|
+
getPlaceOrderContainerClassName(),
|
|
8408
|
+
classNames == null ? void 0 : classNames.root,
|
|
8409
|
+
className
|
|
8410
|
+
),
|
|
8411
|
+
role: "status",
|
|
8412
|
+
"aria-label": labels.marketDetails.resolvingTitle,
|
|
8413
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
|
|
8414
|
+
"div",
|
|
8415
|
+
{
|
|
8416
|
+
className: cn(
|
|
8417
|
+
"agg-order-panel-body flex flex-col items-center justify-center gap-6 px-5 py-10 text-center",
|
|
8418
|
+
classNames == null ? void 0 : classNames.body
|
|
8419
|
+
),
|
|
8420
|
+
children: [
|
|
8421
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "flex h-[60px] w-[60px] items-center justify-center rounded-full bg-agg-primary/10", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(LoadingIcon, { variant: "prominent" }) }),
|
|
8422
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: cn("flex w-full flex-col items-center gap-1", classNames == null ? void 0 : classNames.content), children: [
|
|
8423
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Typography, { variant: "body-large-strong", children: labels.marketDetails.resolvingTitle }),
|
|
8424
|
+
resolvingSubtitle ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Typography, { variant: "body", className: "text-center", children: resolvingSubtitle }) : null
|
|
8425
|
+
] }),
|
|
8426
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8427
|
+
Typography,
|
|
8428
|
+
{
|
|
8429
|
+
variant: "label",
|
|
8430
|
+
className: "max-w-[300px] text-center text-agg-muted-foreground",
|
|
8431
|
+
children: labels.marketDetails.resolvingDescription
|
|
8432
|
+
}
|
|
8433
|
+
)
|
|
8434
|
+
]
|
|
8435
|
+
}
|
|
8436
|
+
)
|
|
8437
|
+
}
|
|
8438
|
+
);
|
|
8439
|
+
}
|
|
8440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8258
8441
|
Card,
|
|
8259
8442
|
{
|
|
8260
8443
|
className: cn(
|
|
@@ -8263,19 +8446,19 @@ var PlaceOrderResolvedView = ({
|
|
|
8263
8446
|
classNames == null ? void 0 : classNames.root,
|
|
8264
8447
|
className
|
|
8265
8448
|
),
|
|
8266
|
-
children: /* @__PURE__ */ (0,
|
|
8267
|
-
/* @__PURE__ */ (0,
|
|
8268
|
-
/* @__PURE__ */ (0,
|
|
8449
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: cn("agg-order-panel-body flex flex-col", classNames == null ? void 0 : classNames.body), children: [
|
|
8450
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "flex flex-col items-center gap-6 p-8", children: [
|
|
8451
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8269
8452
|
"div",
|
|
8270
8453
|
{
|
|
8271
8454
|
className: cn(
|
|
8272
8455
|
"flex h-15 w-15 items-center justify-center rounded-full",
|
|
8273
8456
|
"bg-agg-primary/15"
|
|
8274
8457
|
),
|
|
8275
|
-
children: /* @__PURE__ */ (0,
|
|
8458
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Icon, { name: "success-check", className: cn("h-6 w-6", "text-agg-primary") })
|
|
8276
8459
|
}
|
|
8277
8460
|
),
|
|
8278
|
-
/* @__PURE__ */ (0,
|
|
8461
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
|
|
8279
8462
|
"div",
|
|
8280
8463
|
{
|
|
8281
8464
|
className: cn(
|
|
@@ -8283,31 +8466,31 @@ var PlaceOrderResolvedView = ({
|
|
|
8283
8466
|
classNames == null ? void 0 : classNames.content
|
|
8284
8467
|
),
|
|
8285
8468
|
children: [
|
|
8286
|
-
tradingState.market ? /* @__PURE__ */ (0,
|
|
8287
|
-
tradingState.winningOutcome ? /* @__PURE__ */ (0,
|
|
8469
|
+
tradingState.market ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Typography, { variant: "body", className: "text-center", children: tradingState.market.question }) : null,
|
|
8470
|
+
tradingState.winningOutcome ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Typography, { variant: "body-large-strong", children: tradingLabels.outcome(tradingState.winningOutcome.label) }) : null
|
|
8288
8471
|
]
|
|
8289
8472
|
}
|
|
8290
8473
|
)
|
|
8291
8474
|
] }),
|
|
8292
|
-
resolvedClaim ? /* @__PURE__ */ (0,
|
|
8293
|
-
/* @__PURE__ */ (0,
|
|
8294
|
-
/* @__PURE__ */ (0,
|
|
8295
|
-
/* @__PURE__ */ (0,
|
|
8296
|
-
/* @__PURE__ */ (0,
|
|
8297
|
-
resolvedClaim.resolutionDateLabel ? /* @__PURE__ */ (0,
|
|
8298
|
-
/* @__PURE__ */ (0,
|
|
8299
|
-
/* @__PURE__ */ (0,
|
|
8475
|
+
resolvedClaim ? /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(import_jsx_runtime123.Fragment, { children: [
|
|
8476
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "h-px w-full bg-agg-separator" }),
|
|
8477
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "flex w-full flex-col gap-5 p-6", children: [
|
|
8478
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Typography, { variant: "body-strong", className: "text-center", children: tradingLabels.resolvedEarningsTitle }),
|
|
8479
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "flex flex-col gap-3 text-agg-sm leading-agg-5 text-agg-foreground", children: [
|
|
8480
|
+
resolvedClaim.resolutionDateLabel ? /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
|
|
8481
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { children: tradingLabels.resolvedResolutionDateLabel }),
|
|
8482
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { className: "font-agg-bold", children: resolvedClaim.resolutionDateLabel })
|
|
8300
8483
|
] }) : null,
|
|
8301
|
-
/* @__PURE__ */ (0,
|
|
8302
|
-
/* @__PURE__ */ (0,
|
|
8303
|
-
/* @__PURE__ */ (0,
|
|
8484
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
|
|
8485
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { children: tradingLabels.resolvedSharesLabel }),
|
|
8486
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { className: "font-agg-bold", children: resolvedClaim.sharesLabel })
|
|
8304
8487
|
] }),
|
|
8305
|
-
/* @__PURE__ */ (0,
|
|
8306
|
-
/* @__PURE__ */ (0,
|
|
8307
|
-
/* @__PURE__ */ (0,
|
|
8488
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
|
|
8489
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { children: tradingLabels.resolvedTotalPayoutLabel }),
|
|
8490
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { className: "font-agg-bold", children: resolvedClaim.totalPayoutLabel })
|
|
8308
8491
|
] })
|
|
8309
8492
|
] }),
|
|
8310
|
-
resolvedClaim.onClaim ? /* @__PURE__ */ (0,
|
|
8493
|
+
resolvedClaim.onClaim ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8311
8494
|
Button,
|
|
8312
8495
|
{
|
|
8313
8496
|
size: "large",
|
|
@@ -8315,7 +8498,7 @@ var PlaceOrderResolvedView = ({
|
|
|
8315
8498
|
onClick: resolvedClaim.onClaim,
|
|
8316
8499
|
isLoading: resolvedClaim.isClaiming,
|
|
8317
8500
|
disabled: resolvedClaim.isClaiming,
|
|
8318
|
-
children:
|
|
8501
|
+
children: tradingLabels.claimWinnings
|
|
8319
8502
|
}
|
|
8320
8503
|
) : null
|
|
8321
8504
|
] })
|
|
@@ -8328,18 +8511,18 @@ var renderRouteBreakdownRow = (row) => {
|
|
|
8328
8511
|
var _a, _b;
|
|
8329
8512
|
const venueLabel = getTradingVenueLabel(row.venue);
|
|
8330
8513
|
const rowKey = `${row.venue}-${row.label}-${row.priceLabel}-${(_a = row.resultLabel) != null ? _a : ""}`;
|
|
8331
|
-
return /* @__PURE__ */ (0,
|
|
8514
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
|
|
8332
8515
|
"div",
|
|
8333
8516
|
{
|
|
8334
8517
|
className: "agg-route-breakdown-row flex items-center justify-between gap-4 text-left",
|
|
8335
8518
|
children: [
|
|
8336
|
-
/* @__PURE__ */ (0,
|
|
8337
|
-
/* @__PURE__ */ (0,
|
|
8338
|
-
/* @__PURE__ */ (0,
|
|
8519
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-route-breakdown-market flex min-w-0 items-center gap-2", children: [
|
|
8520
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(VenueLogo, { venue: row.venue, className: "size-3!", ariaLabel: venueLabel }),
|
|
8521
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "agg-route-breakdown-label truncate text-agg-sm leading-agg-5 text-agg-foreground", children: row.label })
|
|
8339
8522
|
] }),
|
|
8340
|
-
/* @__PURE__ */ (0,
|
|
8341
|
-
/* @__PURE__ */ (0,
|
|
8342
|
-
/* @__PURE__ */ (0,
|
|
8523
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-route-breakdown-value flex shrink-0 items-center gap-2 text-agg-sm leading-agg-5", children: [
|
|
8524
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "text-agg-muted-foreground", children: row.priceLabel }),
|
|
8525
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "text-agg-foreground", children: (_b = row.resultLabel) != null ? _b : "" })
|
|
8343
8526
|
] })
|
|
8344
8527
|
]
|
|
8345
8528
|
},
|
|
@@ -8357,7 +8540,7 @@ var renderRouteCard = ({
|
|
|
8357
8540
|
var _a, _b;
|
|
8358
8541
|
const showSplitDetails = isSelected && isExpanded && card.kind === "split" && !!((_a = card.rows) == null ? void 0 : _a.length);
|
|
8359
8542
|
const ariaLabel = [card.label, card.hint, card.value].filter(Boolean).join(" ");
|
|
8360
|
-
return /* @__PURE__ */ (0,
|
|
8543
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8361
8544
|
"button",
|
|
8362
8545
|
{
|
|
8363
8546
|
type: "button",
|
|
@@ -8376,10 +8559,10 @@ var renderRouteCard = ({
|
|
|
8376
8559
|
isSelected && !card.isUnavailable ? "border border-agg-trade-highlight-border bg-linear-to-b from-agg-trade-highlight-surface-from to-agg-trade-highlight-surface-to" : "border-transparent bg-agg-secondary-hover"
|
|
8377
8560
|
),
|
|
8378
8561
|
onClick: () => onSelect(card.id),
|
|
8379
|
-
children: /* @__PURE__ */ (0,
|
|
8380
|
-
/* @__PURE__ */ (0,
|
|
8381
|
-
/* @__PURE__ */ (0,
|
|
8382
|
-
card.kind === "split" ? /* @__PURE__ */ (0,
|
|
8562
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-route-card-content relative z-10 flex flex-col gap-3", children: [
|
|
8563
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-route-card-header flex items-center justify-between gap-4", children: [
|
|
8564
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-route-card-meta flex min-w-0 gap-3 items-center", children: [
|
|
8565
|
+
card.kind === "split" ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8383
8566
|
Icon,
|
|
8384
8567
|
{
|
|
8385
8568
|
name: "sparkles-filled",
|
|
@@ -8390,7 +8573,7 @@ var renderRouteCard = ({
|
|
|
8390
8573
|
),
|
|
8391
8574
|
"aria-hidden": "true"
|
|
8392
8575
|
}
|
|
8393
|
-
) : card.venue ? /* @__PURE__ */ (0,
|
|
8576
|
+
) : card.venue ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8394
8577
|
VenueLogo,
|
|
8395
8578
|
{
|
|
8396
8579
|
venue: card.venue,
|
|
@@ -8398,10 +8581,10 @@ var renderRouteCard = ({
|
|
|
8398
8581
|
ariaLabel: getTradingVenueLabel(card.venue)
|
|
8399
8582
|
}
|
|
8400
8583
|
) : null,
|
|
8401
|
-
/* @__PURE__ */ (0,
|
|
8402
|
-
/* @__PURE__ */ (0,
|
|
8403
|
-
/* @__PURE__ */ (0,
|
|
8404
|
-
card.isUnavailable ? /* @__PURE__ */ (0,
|
|
8584
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "flex flex-col gap-1 min-w-0", children: [
|
|
8585
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
8586
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "agg-route-card-title truncate text-agg-sm leading-agg-5 text-agg-foreground", children: card.label }),
|
|
8587
|
+
card.isUnavailable ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8405
8588
|
Icon,
|
|
8406
8589
|
{
|
|
8407
8590
|
name: "lock",
|
|
@@ -8409,7 +8592,7 @@ var renderRouteCard = ({
|
|
|
8409
8592
|
className: "shrink-0 text-agg-muted-foreground",
|
|
8410
8593
|
"aria-hidden": "true"
|
|
8411
8594
|
}
|
|
8412
|
-
) : card.kind === "split" && isSelected ? /* @__PURE__ */ (0,
|
|
8595
|
+
) : card.kind === "split" && isSelected ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8413
8596
|
Icon,
|
|
8414
8597
|
{
|
|
8415
8598
|
name: showSplitDetails ? "chevron-up" : "chevron-down",
|
|
@@ -8419,10 +8602,10 @@ var renderRouteCard = ({
|
|
|
8419
8602
|
}
|
|
8420
8603
|
) : null
|
|
8421
8604
|
] }),
|
|
8422
|
-
card.hint ? /* @__PURE__ */ (0,
|
|
8605
|
+
card.hint ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "agg-route-card-hint text-agg-xs leading-agg-4 text-agg-muted-foreground", children: card.hint }) : null
|
|
8423
8606
|
] })
|
|
8424
8607
|
] }),
|
|
8425
|
-
/* @__PURE__ */ (0,
|
|
8608
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8426
8609
|
"p",
|
|
8427
8610
|
{
|
|
8428
8611
|
className: cn(
|
|
@@ -8434,9 +8617,9 @@ var renderRouteCard = ({
|
|
|
8434
8617
|
}
|
|
8435
8618
|
)
|
|
8436
8619
|
] }),
|
|
8437
|
-
showSplitDetails ? /* @__PURE__ */ (0,
|
|
8438
|
-
/* @__PURE__ */ (0,
|
|
8439
|
-
/* @__PURE__ */ (0,
|
|
8620
|
+
showSplitDetails ? /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(import_jsx_runtime123.Fragment, { children: [
|
|
8621
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "agg-route-card-description text-agg-xs leading-agg-4 text-agg-foreground", children: tradingLabels.splitOrderDescription }),
|
|
8622
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "agg-route-breakdown flex flex-col gap-3", children: (_b = card.rows) == null ? void 0 : _b.map((row) => renderRouteBreakdownRow(row)) })
|
|
8440
8623
|
] }) : null
|
|
8441
8624
|
] })
|
|
8442
8625
|
}
|
|
@@ -8459,7 +8642,7 @@ var renderSubmissionSurface = ({
|
|
|
8459
8642
|
executionVenue: progressState.executionVenue,
|
|
8460
8643
|
labels: tradingLabels
|
|
8461
8644
|
});
|
|
8462
|
-
return /* @__PURE__ */ (0,
|
|
8645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8463
8646
|
Card,
|
|
8464
8647
|
{
|
|
8465
8648
|
className: cn(
|
|
@@ -8468,31 +8651,31 @@ var renderSubmissionSurface = ({
|
|
|
8468
8651
|
classNames == null ? void 0 : classNames.root,
|
|
8469
8652
|
className
|
|
8470
8653
|
),
|
|
8471
|
-
children: /* @__PURE__ */ (0,
|
|
8654
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: cn("agg-order-submission-body flex flex-col gap-6 p-5", classNames == null ? void 0 : classNames.body), children: [
|
|
8472
8655
|
renderCardHeader({
|
|
8473
8656
|
className: classNames == null ? void 0 : classNames.header,
|
|
8474
8657
|
headerSubtitle,
|
|
8475
8658
|
headerImage,
|
|
8476
8659
|
headerTitle
|
|
8477
8660
|
}),
|
|
8478
|
-
/* @__PURE__ */ (0,
|
|
8479
|
-
/* @__PURE__ */ (0,
|
|
8480
|
-
/* @__PURE__ */ (0,
|
|
8481
|
-
/* @__PURE__ */ (0,
|
|
8661
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: cn("agg-order-panel-content flex flex-col gap-6", classNames == null ? void 0 : classNames.content), children: [
|
|
8662
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-order-submission-status flex h-12 w-full items-center justify-center gap-3 rounded-agg-full bg-agg-primary-hover px-8 text-agg-base font-agg-bold leading-agg-6 text-agg-on-primary", children: [
|
|
8663
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(LoadingGlyph, { enableAnimations, className: "h-4 w-4 text-current" }),
|
|
8664
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { children: actionLabel })
|
|
8482
8665
|
] }),
|
|
8483
|
-
/* @__PURE__ */ (0,
|
|
8666
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8484
8667
|
"div",
|
|
8485
8668
|
{
|
|
8486
8669
|
className: "agg-order-submission-steps agg-order-submission-group flex flex-col gap-2",
|
|
8487
8670
|
"data-testid": "agg-order-submission-steps",
|
|
8488
8671
|
children: displayRows.map((step) => {
|
|
8489
|
-
return /* @__PURE__ */ (0,
|
|
8672
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
|
|
8490
8673
|
"div",
|
|
8491
8674
|
{
|
|
8492
8675
|
className: "agg-order-submission-step flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
|
|
8493
8676
|
"data-status": step.status,
|
|
8494
8677
|
children: [
|
|
8495
|
-
step.status === "complete" ? /* @__PURE__ */ (0,
|
|
8678
|
+
step.status === "complete" ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8496
8679
|
Icon,
|
|
8497
8680
|
{
|
|
8498
8681
|
name: "check-circle",
|
|
@@ -8500,15 +8683,15 @@ var renderSubmissionSurface = ({
|
|
|
8500
8683
|
className: "h-3 w-3 shrink-0 text-agg-primary",
|
|
8501
8684
|
"aria-hidden": "true"
|
|
8502
8685
|
}
|
|
8503
|
-
) : /* @__PURE__ */ (0,
|
|
8686
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8504
8687
|
LoadingGlyph,
|
|
8505
8688
|
{
|
|
8506
8689
|
enableAnimations,
|
|
8507
8690
|
className: "h-3 w-3 shrink-0 text-agg-primary"
|
|
8508
8691
|
}
|
|
8509
8692
|
),
|
|
8510
|
-
/* @__PURE__ */ (0,
|
|
8511
|
-
step.venue ? /* @__PURE__ */ (0,
|
|
8693
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "min-w-0 flex-1", children: step.label }),
|
|
8694
|
+
step.venue ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8512
8695
|
VenueLogo,
|
|
8513
8696
|
{
|
|
8514
8697
|
venue: step.venue,
|
|
@@ -8529,7 +8712,7 @@ var renderSubmissionSurface = ({
|
|
|
8529
8712
|
}
|
|
8530
8713
|
);
|
|
8531
8714
|
};
|
|
8532
|
-
var InitiateKycButton = ({ label: label2, onOpen }) => /* @__PURE__ */ (0,
|
|
8715
|
+
var InitiateKycButton = ({ label: label2, onOpen }) => /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8533
8716
|
Button,
|
|
8534
8717
|
{
|
|
8535
8718
|
size: "large",
|
|
@@ -8546,35 +8729,35 @@ var KycVerifyModal = ({
|
|
|
8546
8729
|
isInitiating,
|
|
8547
8730
|
labels
|
|
8548
8731
|
}) => {
|
|
8549
|
-
return /* @__PURE__ */ (0,
|
|
8732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8550
8733
|
Modal,
|
|
8551
8734
|
{
|
|
8552
8735
|
open,
|
|
8553
8736
|
onOpenChange: (next) => {
|
|
8554
8737
|
onOpenChange(next);
|
|
8555
8738
|
},
|
|
8556
|
-
children: /* @__PURE__ */ (0,
|
|
8557
|
-
/* @__PURE__ */ (0,
|
|
8558
|
-
/* @__PURE__ */ (0,
|
|
8559
|
-
/* @__PURE__ */ (0,
|
|
8560
|
-
/* @__PURE__ */ (0,
|
|
8739
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(Modal.Container, { maxWidth: "480px", "aria-label": labels.title, children: [
|
|
8740
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Dialog2.Title, { className: "sr-only", children: labels.title }),
|
|
8741
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Dialog2.Description, { className: "sr-only", children: labels.description }),
|
|
8742
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(Modal.Body, { classNames: { root: "sm:px-10 sm:py-12" }, children: [
|
|
8743
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8561
8744
|
"button",
|
|
8562
8745
|
{
|
|
8563
8746
|
type: "button",
|
|
8564
8747
|
className: "absolute right-8 top-7 flex items-center justify-center text-agg-foreground transition-colors hover:text-agg-foreground/80",
|
|
8565
8748
|
onClick: () => onOpenChange(false),
|
|
8566
8749
|
"aria-label": "Close",
|
|
8567
|
-
children: /* @__PURE__ */ (0,
|
|
8750
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(CloseIcon, { className: "h-6 w-6" })
|
|
8568
8751
|
}
|
|
8569
8752
|
),
|
|
8570
|
-
/* @__PURE__ */ (0,
|
|
8571
|
-
/* @__PURE__ */ (0,
|
|
8572
|
-
/* @__PURE__ */ (0,
|
|
8573
|
-
/* @__PURE__ */ (0,
|
|
8574
|
-
/* @__PURE__ */ (0,
|
|
8753
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "flex flex-col items-center gap-8 text-center", children: [
|
|
8754
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "flex h-[60px] w-[60px] items-center justify-center text-agg-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(UserTrustIcon, { className: "h-[60px] w-[60px]" }) }),
|
|
8755
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "flex flex-col items-center gap-3", children: [
|
|
8756
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("h3", { className: "text-agg-2xl leading-agg-8 font-agg-bold text-agg-foreground", children: labels.title }),
|
|
8757
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "agg-type-body text-agg-foreground", children: labels.description })
|
|
8575
8758
|
] }),
|
|
8576
|
-
/* @__PURE__ */ (0,
|
|
8577
|
-
/* @__PURE__ */ (0,
|
|
8759
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "flex w-full flex-col items-center gap-5", children: [
|
|
8760
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8578
8761
|
Button,
|
|
8579
8762
|
{
|
|
8580
8763
|
size: "large",
|
|
@@ -8585,7 +8768,7 @@ var KycVerifyModal = ({
|
|
|
8585
8768
|
children: labels.startVerification
|
|
8586
8769
|
}
|
|
8587
8770
|
),
|
|
8588
|
-
/* @__PURE__ */ (0,
|
|
8771
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8589
8772
|
"button",
|
|
8590
8773
|
{
|
|
8591
8774
|
type: "button",
|
|
@@ -8605,27 +8788,27 @@ var KycSuccessModal = ({
|
|
|
8605
8788
|
open,
|
|
8606
8789
|
onOpenChange,
|
|
8607
8790
|
labels
|
|
8608
|
-
}) => /* @__PURE__ */ (0,
|
|
8609
|
-
/* @__PURE__ */ (0,
|
|
8610
|
-
/* @__PURE__ */ (0,
|
|
8611
|
-
/* @__PURE__ */ (0,
|
|
8612
|
-
/* @__PURE__ */ (0,
|
|
8791
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Modal, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(Modal.Container, { maxWidth: "480px", "aria-label": labels.title, children: [
|
|
8792
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Dialog2.Title, { className: "sr-only", children: labels.title }),
|
|
8793
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Dialog2.Description, { className: "sr-only", children: labels.description }),
|
|
8794
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(Modal.Body, { classNames: { root: "px-10 py-12" }, children: [
|
|
8795
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8613
8796
|
"button",
|
|
8614
8797
|
{
|
|
8615
8798
|
type: "button",
|
|
8616
8799
|
className: "absolute right-8 top-7 flex items-center justify-center text-agg-foreground transition-colors hover:text-agg-foreground/80",
|
|
8617
8800
|
onClick: () => onOpenChange(false),
|
|
8618
8801
|
"aria-label": "Close",
|
|
8619
|
-
children: /* @__PURE__ */ (0,
|
|
8802
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(CloseIcon, { className: "h-6 w-6" })
|
|
8620
8803
|
}
|
|
8621
8804
|
),
|
|
8622
|
-
/* @__PURE__ */ (0,
|
|
8623
|
-
/* @__PURE__ */ (0,
|
|
8624
|
-
/* @__PURE__ */ (0,
|
|
8625
|
-
/* @__PURE__ */ (0,
|
|
8626
|
-
/* @__PURE__ */ (0,
|
|
8805
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "flex flex-col items-center gap-8 text-center", children: [
|
|
8806
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "flex h-[60px] w-[60px] items-center justify-center rounded-full bg-agg-success/15", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(SuccessCheckIcon, { className: "h-6 w-6 text-agg-success" }) }),
|
|
8807
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "flex flex-col items-center gap-3", children: [
|
|
8808
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("h3", { className: "text-agg-2xl leading-agg-8 font-agg-bold text-agg-foreground", children: labels.title }),
|
|
8809
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "agg-type-body text-agg-foreground", children: labels.description })
|
|
8627
8810
|
] }),
|
|
8628
|
-
/* @__PURE__ */ (0,
|
|
8811
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
8629
8812
|
Button,
|
|
8630
8813
|
{
|
|
8631
8814
|
variant: "secondary",
|
|
@@ -8646,11 +8829,13 @@ var PlaceOrder = ({
|
|
|
8646
8829
|
isLoading = false,
|
|
8647
8830
|
isPrimaryActionDisabled = false,
|
|
8648
8831
|
isPrimaryActionLoading = false,
|
|
8832
|
+
isQuotePanelActive = true,
|
|
8649
8833
|
chainBalancesOverride,
|
|
8650
8834
|
onAmountChange,
|
|
8651
8835
|
onClose,
|
|
8652
8836
|
onOutcomeChange,
|
|
8653
8837
|
onPrimaryAction,
|
|
8838
|
+
onBeforePrimaryAction,
|
|
8654
8839
|
onTabChange,
|
|
8655
8840
|
onSuccess,
|
|
8656
8841
|
onError,
|
|
@@ -8658,24 +8843,25 @@ var PlaceOrder = ({
|
|
|
8658
8843
|
resolvedClaim,
|
|
8659
8844
|
midpointsResult
|
|
8660
8845
|
}) => {
|
|
8661
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E;
|
|
8846
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G;
|
|
8662
8847
|
const {
|
|
8663
8848
|
enableDebug: isExecutionDebugEnabled,
|
|
8664
8849
|
features: { enableAnimations, showFeesBreakdown },
|
|
8665
8850
|
general: { locale },
|
|
8666
8851
|
trading: { executionMode: configuredExecutionMode = "live" } = { executionMode: "live" }
|
|
8667
|
-
} = (0,
|
|
8668
|
-
const labels = (0,
|
|
8852
|
+
} = (0, import_hooks30.useSdkUiConfig)();
|
|
8853
|
+
const labels = (0, import_hooks30.useLabels)();
|
|
8669
8854
|
const tradingLabels = labels.trading;
|
|
8670
|
-
const
|
|
8671
|
-
const
|
|
8855
|
+
const toastCtx = useOptionalToast();
|
|
8856
|
+
const { isTradingBlocked } = (0, import_hooks30.useGeoBlock)();
|
|
8857
|
+
const tradingContext = (0, import_hooks30.useEventTradingContext)();
|
|
8672
8858
|
const selectedEvent = (_a = tradingContext == null ? void 0 : tradingContext.selectedEvent) != null ? _a : null;
|
|
8673
8859
|
const selectedMarket = (_b = tradingContext == null ? void 0 : tradingContext.selectedMarket) != null ? _b : null;
|
|
8674
8860
|
const selectedOutcomeId = (_c = tradingContext == null ? void 0 : tradingContext.selectedOutcomeId) != null ? _c : null;
|
|
8675
|
-
const resolvedEventTradingState = (0,
|
|
8676
|
-
return eventTradingState != null ? eventTradingState : (0,
|
|
8861
|
+
const resolvedEventTradingState = (0, import_react11.useMemo)(() => {
|
|
8862
|
+
return eventTradingState != null ? eventTradingState : (0, import_hooks30.resolveEventTradingState)(selectedEvent);
|
|
8677
8863
|
}, [eventTradingState, selectedEvent]);
|
|
8678
|
-
const scopedSelectedEvent = (0,
|
|
8864
|
+
const scopedSelectedEvent = (0, import_react11.useMemo)(() => {
|
|
8679
8865
|
var _a2;
|
|
8680
8866
|
if (!selectedEvent) return null;
|
|
8681
8867
|
const primaryMarketId = (_a2 = resolvedEventTradingState.primaryMarket) == null ? void 0 : _a2.id;
|
|
@@ -8685,7 +8871,7 @@ var PlaceOrder = ({
|
|
|
8685
8871
|
);
|
|
8686
8872
|
return isSelectedEventInScope ? selectedEvent : null;
|
|
8687
8873
|
}, [(_d = resolvedEventTradingState.primaryMarket) == null ? void 0 : _d.id, selectedEvent]);
|
|
8688
|
-
const scopedSelectedMarket = (0,
|
|
8874
|
+
const scopedSelectedMarket = (0, import_react11.useMemo)(() => {
|
|
8689
8875
|
if (!selectedMarket) return resolvedEventTradingState.primaryMarket;
|
|
8690
8876
|
const isSelectedMarketInScope = resolvedEventTradingState.marketStates.some(
|
|
8691
8877
|
(item) => item.market.id === selectedMarket.id
|
|
@@ -8700,10 +8886,10 @@ var PlaceOrder = ({
|
|
|
8700
8886
|
(outcome) => outcome.label.trim().toLowerCase() === "yes"
|
|
8701
8887
|
)) != null ? _f : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes[0]) != null ? _g : null;
|
|
8702
8888
|
const scopedSelectedOutcomeId = (_h = scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.id) != null ? _h : null;
|
|
8703
|
-
const resolvedTradingState = (0,
|
|
8704
|
-
return (0,
|
|
8889
|
+
const resolvedTradingState = (0, import_react11.useMemo)(() => {
|
|
8890
|
+
return (0, import_hooks30.resolveMarketTradingState)(scopedSelectedMarket);
|
|
8705
8891
|
}, [scopedSelectedMarket]);
|
|
8706
|
-
const resolvedReadOnlyMarket = (0,
|
|
8892
|
+
const resolvedReadOnlyMarket = (0, import_react11.useMemo)(() => {
|
|
8707
8893
|
var _a2;
|
|
8708
8894
|
if (resolvedEventTradingState.kind !== "resolved") {
|
|
8709
8895
|
return scopedSelectedMarket;
|
|
@@ -8714,11 +8900,12 @@ var PlaceOrder = ({
|
|
|
8714
8900
|
resolvedEventTradingState.primaryMarket,
|
|
8715
8901
|
scopedSelectedMarket
|
|
8716
8902
|
]);
|
|
8717
|
-
const resolvedReadOnlyTradingState = (0,
|
|
8718
|
-
return (0,
|
|
8903
|
+
const resolvedReadOnlyTradingState = (0, import_react11.useMemo)(() => {
|
|
8904
|
+
return (0, import_hooks30.resolveMarketTradingState)(resolvedReadOnlyMarket);
|
|
8719
8905
|
}, [resolvedReadOnlyMarket]);
|
|
8720
|
-
const
|
|
8721
|
-
|
|
8906
|
+
const isEndedWithoutKnownWinner = false;
|
|
8907
|
+
const orderEligibility = (0, import_react11.useMemo)(
|
|
8908
|
+
() => (0, import_hooks30.resolveOrderEligibility)({
|
|
8722
8909
|
event: scopedSelectedEvent,
|
|
8723
8910
|
market: scopedSelectedMarket,
|
|
8724
8911
|
outcome: scopedSelectedOutcome,
|
|
@@ -8727,15 +8914,15 @@ var PlaceOrder = ({
|
|
|
8727
8914
|
[scopedSelectedEvent, scopedSelectedMarket, scopedSelectedOutcome, resolvedEventTradingState]
|
|
8728
8915
|
);
|
|
8729
8916
|
const isResolvedOutcomeCtaLocked = resolvedEventTradingState.kind === "resolved" || resolvedTradingState.kind === "resolved";
|
|
8730
|
-
const { isAuthenticated, user } = (0,
|
|
8917
|
+
const { isAuthenticated, user } = (0, import_hooks30.useAggAuthContext)();
|
|
8731
8918
|
const resolvedExecutionMode = executionMode != null ? executionMode : configuredExecutionMode;
|
|
8732
8919
|
const isPaperMode = resolvedExecutionMode === "paper";
|
|
8733
|
-
const liveBalanceState = (0,
|
|
8734
|
-
const paperBalancesQuery = (0,
|
|
8920
|
+
const liveBalanceState = (0, import_hooks30.useAggBalanceState)();
|
|
8921
|
+
const paperBalancesQuery = (0, import_hooks30.useManagedBalances)({
|
|
8735
8922
|
enabled: Boolean(isAuthenticated && isPaperMode),
|
|
8736
8923
|
mode: "paper"
|
|
8737
8924
|
});
|
|
8738
|
-
const paperTotalBalance = (0,
|
|
8925
|
+
const paperTotalBalance = (0, import_react11.useMemo)(() => {
|
|
8739
8926
|
var _a2, _b2;
|
|
8740
8927
|
const cash = (_b2 = (_a2 = paperBalancesQuery.balances) == null ? void 0 : _a2.cash) != null ? _b2 : [];
|
|
8741
8928
|
return cash.reduce((sum, token) => {
|
|
@@ -8750,13 +8937,13 @@ var PlaceOrder = ({
|
|
|
8750
8937
|
}, [paperBalancesQuery.balances]);
|
|
8751
8938
|
const totalBalance = isPaperMode ? paperTotalBalance : liveBalanceState.totalBalance;
|
|
8752
8939
|
const isBalanceLoading = isPaperMode ? paperBalancesQuery.isLoading : liveBalanceState.isLoading;
|
|
8753
|
-
const executeManaged = (0,
|
|
8754
|
-
const aggClient = (0,
|
|
8755
|
-
const queryClient = (0,
|
|
8756
|
-
const livePrices = (0,
|
|
8940
|
+
const executeManaged = (0, import_hooks30.useExecuteManaged)();
|
|
8941
|
+
const aggClient = (0, import_hooks30.useAggClient)();
|
|
8942
|
+
const queryClient = (0, import_hooks30.useQueryClient)();
|
|
8943
|
+
const livePrices = (0, import_hooks30.useLiveOutcomePrices)(
|
|
8757
8944
|
scopedSelectedMarket ? [scopedSelectedMarket] : void 0
|
|
8758
8945
|
);
|
|
8759
|
-
const wsBestPrices = (0,
|
|
8946
|
+
const wsBestPrices = (0, import_hooks30.useLiveBestPrices)(scopedSelectedMarket ? [scopedSelectedMarket] : void 0);
|
|
8760
8947
|
const clusterMidpointResult = midpointsResult != null ? midpointsResult : {
|
|
8761
8948
|
prices: /* @__PURE__ */ new Map(),
|
|
8762
8949
|
bestMidpointsByOutcomeId: /* @__PURE__ */ new Map(),
|
|
@@ -8770,36 +8957,37 @@ var PlaceOrder = ({
|
|
|
8770
8957
|
const clusterBestMidpointsByOutcomeId = (_i = clusterMidpointResult.bestMidpointsByOutcomeId) != null ? _i : clusterMidpointResult.prices;
|
|
8771
8958
|
const clusterBestMidpoint = clusterMidpointResult.bestMidpoint;
|
|
8772
8959
|
const clusterBestPricesRest = clusterMidpointResult.bestPrices;
|
|
8773
|
-
const clusterBestPrices = (0,
|
|
8774
|
-
() => (0,
|
|
8960
|
+
const clusterBestPrices = (0, import_react11.useMemo)(
|
|
8961
|
+
() => (0, import_hooks30.mergeBestPricesPreferringLive)(clusterBestPricesRest, wsBestPrices),
|
|
8775
8962
|
[clusterBestPricesRest, wsBestPrices]
|
|
8776
8963
|
);
|
|
8777
|
-
const outcomes = (0,
|
|
8964
|
+
const outcomes = (0, import_react11.useMemo)(
|
|
8778
8965
|
() => mapVenueMarketOutcomesToPlaceOrderOutcomes(scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes),
|
|
8779
8966
|
[scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes]
|
|
8780
8967
|
);
|
|
8781
|
-
const buyTabRef = (0,
|
|
8782
|
-
const sellTabRef = (0,
|
|
8783
|
-
const [internalTab, setInternalTab] = (0,
|
|
8784
|
-
const [internalAmount, setInternalAmount] = (0,
|
|
8785
|
-
const [sellFilledForOutcomeId, setSellFilledForOutcomeId] = (0,
|
|
8786
|
-
const [internalSlippage] = (0,
|
|
8787
|
-
const [isRoutesExpanded, setIsRoutesExpanded] = (0,
|
|
8788
|
-
const [selectedRouteCardId, setSelectedRouteCardId] = (0,
|
|
8789
|
-
const [isSplitDetailOpen, setIsSplitDetailOpen] = (0,
|
|
8790
|
-
const [submissionFeedback, setSubmissionFeedback] = (0,
|
|
8791
|
-
const [submissionProgressState, setSubmissionProgressState] = (0,
|
|
8792
|
-
const
|
|
8793
|
-
const
|
|
8794
|
-
const
|
|
8795
|
-
(0,
|
|
8968
|
+
const buyTabRef = (0, import_react11.useRef)(null);
|
|
8969
|
+
const sellTabRef = (0, import_react11.useRef)(null);
|
|
8970
|
+
const [internalTab, setInternalTab] = (0, import_react11.useState)("buy");
|
|
8971
|
+
const [internalAmount, setInternalAmount] = (0, import_react11.useState)(PLACE_ORDER_DEFAULT_AMOUNT);
|
|
8972
|
+
const [sellFilledForOutcomeId, setSellFilledForOutcomeId] = (0, import_react11.useState)(null);
|
|
8973
|
+
const [internalSlippage] = (0, import_react11.useState)(DEFAULT_SLIPPAGE_VALUE);
|
|
8974
|
+
const [isRoutesExpanded, setIsRoutesExpanded] = (0, import_react11.useState)(false);
|
|
8975
|
+
const [selectedRouteCardId, setSelectedRouteCardId] = (0, import_react11.useState)(null);
|
|
8976
|
+
const [isSplitDetailOpen, setIsSplitDetailOpen] = (0, import_react11.useState)(false);
|
|
8977
|
+
const [submissionFeedback, setSubmissionFeedback] = (0, import_react11.useState)(null);
|
|
8978
|
+
const [submissionProgressState, setSubmissionProgressState] = (0, import_react11.useState)(null);
|
|
8979
|
+
const [isBeforeActionPending, setIsBeforeActionPending] = (0, import_react11.useState)(false);
|
|
8980
|
+
const executionDebugStoreRef = (0, import_react11.useRef)(null);
|
|
8981
|
+
const executionDebugAttemptIdRef = (0, import_react11.useRef)(null);
|
|
8982
|
+
const submittedSelectionRef = (0, import_react11.useRef)(null);
|
|
8983
|
+
(0, import_react11.useEffect)(() => {
|
|
8796
8984
|
if (!isExecutionDebugEnabled) {
|
|
8797
8985
|
executionDebugStoreRef.current = null;
|
|
8798
8986
|
return;
|
|
8799
8987
|
}
|
|
8800
8988
|
executionDebugStoreRef.current = enableExecutionDebugInBrowser();
|
|
8801
8989
|
}, [isExecutionDebugEnabled]);
|
|
8802
|
-
(0,
|
|
8990
|
+
(0, import_react11.useEffect)(() => {
|
|
8803
8991
|
if (!isExecutionDebugEnabled) return;
|
|
8804
8992
|
const store = executionDebugStoreRef.current;
|
|
8805
8993
|
if (!store) return;
|
|
@@ -8811,17 +8999,18 @@ var PlaceOrder = ({
|
|
|
8811
8999
|
scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id,
|
|
8812
9000
|
scopedSelectedOutcomeId
|
|
8813
9001
|
]);
|
|
8814
|
-
const debouncedAmount = (0,
|
|
8815
|
-
const
|
|
9002
|
+
const debouncedAmount = (0, import_hooks30.useDebouncedValue)(internalAmount, 300);
|
|
9003
|
+
const isQuoteInputEditing = internalAmount !== debouncedAmount;
|
|
9004
|
+
const isSell = (0, import_react11.useMemo)(() => internalTab === "sell", [internalTab]);
|
|
8816
9005
|
const {
|
|
8817
9006
|
positions: executionPositions,
|
|
8818
9007
|
isLoading: isExecutionPositionsLoading,
|
|
8819
9008
|
isFetching: isExecutionPositionsFetching
|
|
8820
|
-
} = (0,
|
|
9009
|
+
} = (0, import_hooks30.useExecutionPositions)({
|
|
8821
9010
|
enabled: Boolean(isAuthenticated && isSell),
|
|
8822
9011
|
mode: isPaperMode ? "paper" : void 0
|
|
8823
9012
|
});
|
|
8824
|
-
const smartRoute = (0,
|
|
9013
|
+
const smartRoute = (0, import_hooks30.useSmartRoute)({
|
|
8825
9014
|
venueMarketOutcomeId: scopedSelectedOutcomeId,
|
|
8826
9015
|
maxSpend: isSell ? void 0 : debouncedAmount,
|
|
8827
9016
|
sellShares: isSell ? debouncedAmount : void 0,
|
|
@@ -8833,9 +9022,21 @@ var PlaceOrder = ({
|
|
|
8833
9022
|
compareVenues: true,
|
|
8834
9023
|
tradeSide: isSell ? "sell" : "buy",
|
|
8835
9024
|
mode: isPaperMode ? "paper" : void 0,
|
|
8836
|
-
enabled: debouncedAmount > 0 && orderEligibility.canPlaceOrder
|
|
9025
|
+
enabled: isQuotePanelActive && !isEndedWithoutKnownWinner && !submissionProgressState && !isBeforeActionPending && !executeManaged.isPending && debouncedAmount > 0 && orderEligibility.canPlaceOrder && // On the sell tab, hold the quote until the amount has been initialized
|
|
9026
|
+
// from the user's position for THIS outcome AND the debounced value has
|
|
9027
|
+
// caught up to it. The amount input is shared with the buy tab, so right
|
|
9028
|
+
// after switching to sell the debounced value still holds the buy default
|
|
9029
|
+
// (PLACE_ORDER_DEFAULT_AMOUNT) for ~300ms — without this gate it leaks into
|
|
9030
|
+
// the first sell quote as `sellShares` (e.g. sellShares=20).
|
|
9031
|
+
(!isSell || sellFilledForOutcomeId === scopedSelectedOutcomeId && !isQuoteInputEditing),
|
|
9032
|
+
refreshContext: {
|
|
9033
|
+
isEditing: isQuoteInputEditing,
|
|
9034
|
+
isMarketOpen: resolvedTradingState.kind === "open" && !isEndedWithoutKnownWinner,
|
|
9035
|
+
isPanelActive: isQuotePanelActive,
|
|
9036
|
+
isSubmitting: submissionProgressState != null || isBeforeActionPending || executeManaged.isPending
|
|
9037
|
+
}
|
|
8837
9038
|
});
|
|
8838
|
-
const currentSellableShares = (0,
|
|
9039
|
+
const currentSellableShares = (0, import_react11.useMemo)(() => {
|
|
8839
9040
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
|
|
8840
9041
|
const sharesFromQuote = (_b2 = (_a2 = smartRoute.data) == null ? void 0 : _a2.positionAvailability) == null ? void 0 : _b2.totalSellableShares;
|
|
8841
9042
|
if (typeof sharesFromQuote === "number" && Number.isFinite(sharesFromQuote)) {
|
|
@@ -8849,15 +9050,13 @@ var PlaceOrder = ({
|
|
|
8849
9050
|
(_d2 = scopedSelectedMarket.externalIdentifier) != null ? _d2 : void 0
|
|
8850
9051
|
].filter((value) => Boolean(value));
|
|
8851
9052
|
const selectedMarketIdSet = new Set(selectedMarketIds);
|
|
8852
|
-
const selectedVenue = scopedSelectedMarket.venue;
|
|
8853
9053
|
let resolvedShares = 0;
|
|
8854
9054
|
for (const group of executionPositions) {
|
|
8855
9055
|
const groupOutcomes = (_f2 = (_e2 = group.venueMarket) == null ? void 0 : _e2.venueMarketOutcomes) != null ? _f2 : [];
|
|
8856
9056
|
for (const outcome of groupOutcomes) {
|
|
8857
9057
|
if (outcome.label.trim().toLowerCase() !== normalizedSelectedOutcomeLabel) continue;
|
|
8858
9058
|
for (const breakdown of (_g2 = outcome.venueBreakdown) != null ? _g2 : []) {
|
|
8859
|
-
|
|
8860
|
-
const matchesMarketId = selectedMarketIdSet.size === 0 || selectedMarketIdSet.has(breakdown.venueMarketId) || selectedMarketIdSet.has(group.targetMarketId);
|
|
9059
|
+
const matchesMarketId = selectedMarketIdSet.size === 0 || selectedMarketIdSet.has(group.targetMarketId) || selectedMarketIdSet.has(breakdown.venueMarketId);
|
|
8861
9060
|
if (!matchesMarketId) continue;
|
|
8862
9061
|
resolvedShares += Number.isFinite(breakdown.size) ? breakdown.size : 0;
|
|
8863
9062
|
}
|
|
@@ -8871,29 +9070,37 @@ var PlaceOrder = ({
|
|
|
8871
9070
|
scopedSelectedOutcome,
|
|
8872
9071
|
(_k = (_j = smartRoute.data) == null ? void 0 : _j.positionAvailability) == null ? void 0 : _k.totalSellableShares
|
|
8873
9072
|
]);
|
|
9073
|
+
const maxSellableShares = (0, import_react11.useMemo)(
|
|
9074
|
+
() => floorToDecimals(currentSellableShares, SELL_SHARE_INPUT_DECIMALS),
|
|
9075
|
+
[currentSellableShares]
|
|
9076
|
+
);
|
|
8874
9077
|
const isCurrentSellableSharesLoading = isSell && isAuthenticated && !(typeof ((_m = (_l = smartRoute.data) == null ? void 0 : _l.positionAvailability) == null ? void 0 : _m.totalSellableShares) === "number") && (isExecutionPositionsLoading || isExecutionPositionsFetching);
|
|
8875
|
-
const displayedCurrentSellableShares = (0,
|
|
9078
|
+
const displayedCurrentSellableShares = (0, import_react11.useMemo)(() => {
|
|
8876
9079
|
if (!Number.isFinite(currentSellableShares) || currentSellableShares <= 0) return 0;
|
|
8877
|
-
return
|
|
9080
|
+
return floorToDecimals(currentSellableShares, SELL_SHARE_DISPLAY_DECIMALS);
|
|
8878
9081
|
}, [currentSellableShares]);
|
|
8879
|
-
const
|
|
8880
|
-
|
|
9082
|
+
const displayedCurrentSellableSharesLabel = (0, import_react11.useMemo)(
|
|
9083
|
+
() => `${formatFlooredShareAmount(maxSellableShares, SELL_SHARE_DISPLAY_DECIMALS)} shares`,
|
|
9084
|
+
[maxSellableShares]
|
|
9085
|
+
);
|
|
9086
|
+
const isAtMaxSellableShares = isSell && maxSellableShares > 0 && Math.abs(internalAmount - maxSellableShares) < 1e-9;
|
|
9087
|
+
(0, import_react11.useEffect)(() => {
|
|
8881
9088
|
if (submissionProgressState != null) return;
|
|
8882
9089
|
if (!isSell || isCurrentSellableSharesLoading) return;
|
|
8883
9090
|
if (scopedSelectedOutcomeId === sellFilledForOutcomeId) return;
|
|
8884
|
-
setInternalAmount(
|
|
9091
|
+
setInternalAmount(maxSellableShares);
|
|
8885
9092
|
setSellFilledForOutcomeId(scopedSelectedOutcomeId != null ? scopedSelectedOutcomeId : null);
|
|
8886
|
-
onAmountChange == null ? void 0 : onAmountChange(
|
|
9093
|
+
onAmountChange == null ? void 0 : onAmountChange(maxSellableShares);
|
|
8887
9094
|
}, [
|
|
8888
9095
|
isSell,
|
|
8889
9096
|
isCurrentSellableSharesLoading,
|
|
8890
9097
|
scopedSelectedOutcomeId,
|
|
8891
9098
|
sellFilledForOutcomeId,
|
|
8892
|
-
|
|
9099
|
+
maxSellableShares,
|
|
8893
9100
|
onAmountChange,
|
|
8894
9101
|
submissionProgressState
|
|
8895
9102
|
]);
|
|
8896
|
-
const routeCards = (0,
|
|
9103
|
+
const routeCards = (0, import_react11.useMemo)(
|
|
8897
9104
|
() => smartRoute.data ? buildLiveRouteCards({
|
|
8898
9105
|
eventVenues: scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.venueMarkets.map((market) => market.venue),
|
|
8899
9106
|
labels: tradingLabels,
|
|
@@ -8902,7 +9109,7 @@ var PlaceOrder = ({
|
|
|
8902
9109
|
}) : [],
|
|
8903
9110
|
[smartRoute.data, tradingLabels, isSell, scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.venueMarkets]
|
|
8904
9111
|
);
|
|
8905
|
-
const resolvedSelectedRouteCardId = (0,
|
|
9112
|
+
const resolvedSelectedRouteCardId = (0, import_react11.useMemo)(() => {
|
|
8906
9113
|
var _a2, _b2, _c2, _d2;
|
|
8907
9114
|
if (routeCards.length === 0) return null;
|
|
8908
9115
|
if (selectedRouteCardId && routeCards.some((card) => card.id === selectedRouteCardId && !card.isUnavailable)) {
|
|
@@ -8910,7 +9117,7 @@ var PlaceOrder = ({
|
|
|
8910
9117
|
}
|
|
8911
9118
|
return (_d2 = (_c2 = (_a2 = routeCards.find((card) => !card.isUnavailable)) == null ? void 0 : _a2.id) != null ? _c2 : (_b2 = routeCards[0]) == null ? void 0 : _b2.id) != null ? _d2 : null;
|
|
8912
9119
|
}, [routeCards, selectedRouteCardId]);
|
|
8913
|
-
(0,
|
|
9120
|
+
(0, import_react11.useEffect)(() => {
|
|
8914
9121
|
if (routeCards.length === 0) {
|
|
8915
9122
|
setSelectedRouteCardId(null);
|
|
8916
9123
|
setIsRoutesExpanded(false);
|
|
@@ -8922,22 +9129,22 @@ var PlaceOrder = ({
|
|
|
8922
9129
|
}
|
|
8923
9130
|
}, [resolvedSelectedRouteCardId, routeCards.length, selectedRouteCardId]);
|
|
8924
9131
|
const isSubmissionLocked = submissionProgressState != null;
|
|
8925
|
-
const isSubmissionLockedRef = (0,
|
|
9132
|
+
const isSubmissionLockedRef = (0, import_react11.useRef)(isSubmissionLocked);
|
|
8926
9133
|
isSubmissionLockedRef.current = isSubmissionLocked;
|
|
8927
|
-
(0,
|
|
9134
|
+
(0, import_react11.useEffect)(() => {
|
|
8928
9135
|
if (isSubmissionLockedRef.current) return;
|
|
8929
9136
|
setSubmissionFeedback(null);
|
|
8930
9137
|
setSubmissionProgressState(null);
|
|
8931
9138
|
}, [internalAmount, internalSlippage, internalTab, scopedSelectedOutcomeId]);
|
|
8932
9139
|
const orderedRouteCards = routeCards;
|
|
8933
9140
|
const selectedRouteCard = (_o = (_n = orderedRouteCards.find((card) => card.id === resolvedSelectedRouteCardId)) != null ? _n : orderedRouteCards[0]) != null ? _o : null;
|
|
8934
|
-
const isKalshiRoute = (0,
|
|
9141
|
+
const isKalshiRoute = (0, import_react11.useMemo)(() => {
|
|
8935
9142
|
if (selectedRouteCard) {
|
|
8936
9143
|
return selectedRouteCard.venue === "kalshi" || selectedRouteCard.quoteData.fills.some((f) => f.venue === "kalshi");
|
|
8937
9144
|
}
|
|
8938
9145
|
return (scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venue) === "kalshi";
|
|
8939
9146
|
}, [selectedRouteCard, scopedSelectedMarket]);
|
|
8940
|
-
const isKalshiVerified = (0,
|
|
9147
|
+
const isKalshiVerified = (0, import_react11.useMemo)(() => {
|
|
8941
9148
|
var _a2;
|
|
8942
9149
|
const kalshiAccount = (_a2 = user == null ? void 0 : user.venueAccounts) == null ? void 0 : _a2.find((va) => va.venue === "kalshi");
|
|
8943
9150
|
return (kalshiAccount == null ? void 0 : kalshiAccount.kycStatus) === "verified";
|
|
@@ -8954,10 +9161,10 @@ var PlaceOrder = ({
|
|
|
8954
9161
|
} = useKalshiKycFlow({
|
|
8955
9162
|
isKalshiVerified,
|
|
8956
9163
|
userId: user == null ? void 0 : user.id,
|
|
8957
|
-
walletAddress: (_p = (0,
|
|
9164
|
+
walletAddress: (_p = (0, import_hooks30.getWalletAddressFromUserProfile)(user)) != null ? _p : null,
|
|
8958
9165
|
onError
|
|
8959
9166
|
});
|
|
8960
|
-
const handleRouteCardSelect = (0,
|
|
9167
|
+
const handleRouteCardSelect = (0, import_react11.useCallback)(
|
|
8961
9168
|
(cardId) => {
|
|
8962
9169
|
if (cardId === resolvedSelectedRouteCardId) {
|
|
8963
9170
|
const card = routeCards.find((c) => c.id === cardId);
|
|
@@ -8970,16 +9177,17 @@ var PlaceOrder = ({
|
|
|
8970
9177
|
},
|
|
8971
9178
|
[resolvedSelectedRouteCardId, routeCards]
|
|
8972
9179
|
);
|
|
8973
|
-
const executionProgress = (0,
|
|
9180
|
+
const executionProgress = (0, import_hooks30.useExecutionProgress)({
|
|
8974
9181
|
orderIds: (_q = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) != null ? _q : null,
|
|
9182
|
+
quoteId: (_r = submissionProgressState == null ? void 0 : submissionProgressState.quoteId) != null ? _r : null,
|
|
8975
9183
|
mode: isPaperMode ? "paper" : void 0,
|
|
8976
|
-
enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((
|
|
9184
|
+
enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((_s = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _s.length)
|
|
8977
9185
|
});
|
|
8978
|
-
const selectedOutcomeLabel = (
|
|
8979
|
-
const headerImage = (
|
|
8980
|
-
const headerTitle = (
|
|
8981
|
-
const headerSubtitle = (
|
|
8982
|
-
const buildExecutionSummary = (0,
|
|
9186
|
+
const selectedOutcomeLabel = (_v = (_u = (_t = outcomes.find((outcome) => outcome.id === scopedSelectedOutcomeId)) == null ? void 0 : _t.label) != null ? _u : scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.label) != null ? _v : "";
|
|
9187
|
+
const headerImage = (_x = (_w = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.image) != null ? _w : scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.image) != null ? _x : null;
|
|
9188
|
+
const headerTitle = (_z = (_y = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _y : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _z : "";
|
|
9189
|
+
const headerSubtitle = (_A = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _A : "";
|
|
9190
|
+
const buildExecutionSummary = (0, import_react11.useCallback)(
|
|
8983
9191
|
(quoteData, executionVenue, orderId, partialFillSummary) => {
|
|
8984
9192
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
|
|
8985
9193
|
if (!quoteData) return void 0;
|
|
@@ -9055,7 +9263,7 @@ var PlaceOrder = ({
|
|
|
9055
9263
|
tradingLabels
|
|
9056
9264
|
]
|
|
9057
9265
|
);
|
|
9058
|
-
(0,
|
|
9266
|
+
(0, import_react11.useEffect)(() => {
|
|
9059
9267
|
if (executionProgress.phase === "order_submitted") {
|
|
9060
9268
|
const submittedOrder = executionProgress.submittedOrders[0];
|
|
9061
9269
|
setSubmissionProgressState((prev) => {
|
|
@@ -9068,7 +9276,7 @@ var PlaceOrder = ({
|
|
|
9068
9276
|
});
|
|
9069
9277
|
}
|
|
9070
9278
|
}, [executionProgress.phase, executionProgress.submittedOrders]);
|
|
9071
|
-
(0,
|
|
9279
|
+
(0, import_react11.useEffect)(() => {
|
|
9072
9280
|
var _a2, _b2;
|
|
9073
9281
|
const dp = executionProgress.dagProgress;
|
|
9074
9282
|
if (!dp) return;
|
|
@@ -9119,7 +9327,7 @@ var PlaceOrder = ({
|
|
|
9119
9327
|
return __spreadProps(__spreadValues({}, prev), { dagProgress: dp });
|
|
9120
9328
|
});
|
|
9121
9329
|
}, [executionProgress.dagProgress, tradingLabels]);
|
|
9122
|
-
(0,
|
|
9330
|
+
(0, import_react11.useEffect)(() => {
|
|
9123
9331
|
const orderIds = submissionProgressState == null ? void 0 : submissionProgressState.orderIds;
|
|
9124
9332
|
if (!(orderIds == null ? void 0 : orderIds.length)) return;
|
|
9125
9333
|
const aggregateStatus = deriveAggregateOrderStatus(
|
|
@@ -9180,7 +9388,7 @@ var PlaceOrder = ({
|
|
|
9180
9388
|
tradingLabels
|
|
9181
9389
|
]);
|
|
9182
9390
|
const estDurationMs = (selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) && typeof selectedRouteCard.quoteData.estDurationMs === "number" ? selectedRouteCard.quoteData.estDurationMs : 6e4;
|
|
9183
|
-
(0,
|
|
9391
|
+
(0, import_react11.useEffect)(() => {
|
|
9184
9392
|
const phase = submissionProgressState == null ? void 0 : submissionProgressState.phase;
|
|
9185
9393
|
if (phase !== "submitting" && phase !== "executing") return;
|
|
9186
9394
|
const timeoutMs = Math.max(6e4, 2 * estDurationMs);
|
|
@@ -9195,7 +9403,36 @@ var PlaceOrder = ({
|
|
|
9195
9403
|
}, timeoutMs);
|
|
9196
9404
|
return () => clearTimeout(id);
|
|
9197
9405
|
}, [submissionProgressState == null ? void 0 : submissionProgressState.phase, estDurationMs]);
|
|
9198
|
-
(0,
|
|
9406
|
+
const emitTerminalOrderNotifications = (0, import_react11.useCallback)(() => {
|
|
9407
|
+
const toast = toastCtx == null ? void 0 : toastCtx.toast;
|
|
9408
|
+
if (!toast) return;
|
|
9409
|
+
for (const event of executionProgress.terminalOrderEvents) {
|
|
9410
|
+
handleOrderEvent({
|
|
9411
|
+
event: {
|
|
9412
|
+
type: "order_event",
|
|
9413
|
+
userId: "",
|
|
9414
|
+
orderId: event.orderId,
|
|
9415
|
+
venue: event.venue,
|
|
9416
|
+
event: event.event,
|
|
9417
|
+
filledAmountRaw: event.filledAmountRaw,
|
|
9418
|
+
remainingAmountRaw: event.remainingAmountRaw,
|
|
9419
|
+
actualSharesRaw: event.actualSharesRaw,
|
|
9420
|
+
actualToWinRaw: event.actualToWinRaw,
|
|
9421
|
+
quotedSharesRaw: event.quotedSharesRaw,
|
|
9422
|
+
quotedToWinRaw: event.quotedToWinRaw,
|
|
9423
|
+
executionPriceRaw: event.executionPriceRaw,
|
|
9424
|
+
quotedPriceRaw: event.quotedPriceRaw,
|
|
9425
|
+
errorReason: event.errorReason,
|
|
9426
|
+
timestamp: event.timestamp
|
|
9427
|
+
},
|
|
9428
|
+
labels,
|
|
9429
|
+
fireOnce: (key, tone, title2, message, detail) => {
|
|
9430
|
+
toast(message, { tone, title: title2, detail });
|
|
9431
|
+
}
|
|
9432
|
+
});
|
|
9433
|
+
}
|
|
9434
|
+
}, [executionProgress.terminalOrderEvents, labels, toastCtx]);
|
|
9435
|
+
(0, import_react11.useEffect)(() => {
|
|
9199
9436
|
var _a2, _b2;
|
|
9200
9437
|
if (!submissionProgressState) return;
|
|
9201
9438
|
onExecutionStateChange == null ? void 0 : onExecutionStateChange(submissionProgressState);
|
|
@@ -9214,8 +9451,9 @@ var PlaceOrder = ({
|
|
|
9214
9451
|
});
|
|
9215
9452
|
}
|
|
9216
9453
|
if (submissionProgressState.phase === "success" && submissionProgressState.summary) {
|
|
9217
|
-
(
|
|
9218
|
-
(0,
|
|
9454
|
+
emitTerminalOrderNotifications();
|
|
9455
|
+
(0, import_hooks30.invalidateBalanceQueries)(queryClient);
|
|
9456
|
+
(0, import_hooks30.invalidatePositionQueries)(queryClient);
|
|
9219
9457
|
if (debugStore && debugAttemptId) {
|
|
9220
9458
|
debugStore.updateAttempt(debugAttemptId, {
|
|
9221
9459
|
status: "succeeded",
|
|
@@ -9225,6 +9463,7 @@ var PlaceOrder = ({
|
|
|
9225
9463
|
onSuccess == null ? void 0 : onSuccess(submissionProgressState.summary);
|
|
9226
9464
|
}
|
|
9227
9465
|
if (submissionProgressState.phase === "failed" && submissionProgressState.errorMessage) {
|
|
9466
|
+
emitTerminalOrderNotifications();
|
|
9228
9467
|
if (debugStore && debugAttemptId) {
|
|
9229
9468
|
debugStore.appendError(debugAttemptId, {
|
|
9230
9469
|
message: submissionProgressState.errorMessage,
|
|
@@ -9237,8 +9476,15 @@ var PlaceOrder = ({
|
|
|
9237
9476
|
}
|
|
9238
9477
|
onError == null ? void 0 : onError(new Error(submissionProgressState.errorMessage));
|
|
9239
9478
|
}
|
|
9240
|
-
}, [
|
|
9241
|
-
|
|
9479
|
+
}, [
|
|
9480
|
+
emitTerminalOrderNotifications,
|
|
9481
|
+
onError,
|
|
9482
|
+
onExecutionStateChange,
|
|
9483
|
+
onSuccess,
|
|
9484
|
+
queryClient,
|
|
9485
|
+
submissionProgressState
|
|
9486
|
+
]);
|
|
9487
|
+
const activeQuoteData = (_C = (_B = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _B : smartRoute.data) != null ? _C : null;
|
|
9242
9488
|
const visibleRouteCards = orderedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT && !isRoutesExpanded ? orderedRouteCards.slice(0, PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT) : orderedRouteCards;
|
|
9243
9489
|
const hasEnteredAmount = internalAmount > 0;
|
|
9244
9490
|
const isQuoteLoading = hasEnteredAmount && (smartRoute.isFetching || smartRoute.isLoading);
|
|
@@ -9250,7 +9496,7 @@ var PlaceOrder = ({
|
|
|
9250
9496
|
const isBelowVenueMinimumFromQuote = isQuoteBelowVenueMinimum(activeQuoteData);
|
|
9251
9497
|
const isBelowMinimum = isBelowClientMinimum || isBelowVenueMinimumFromQuote;
|
|
9252
9498
|
const belowMinimumMessage = isBelowClientMinimum ? tradingLabels.minimumOrderAmount(MIN_BUY_ORDER_AMOUNT) : tradingLabels.minOrderSizeViolated;
|
|
9253
|
-
const quoteStatus = (0,
|
|
9499
|
+
const quoteStatus = (0, import_react11.useMemo)(() => {
|
|
9254
9500
|
if (!orderEligibility.canPlaceOrder) return void 0;
|
|
9255
9501
|
return resolvePlaceOrderQuoteStatus({
|
|
9256
9502
|
amount: internalAmount,
|
|
@@ -9265,7 +9511,7 @@ var PlaceOrder = ({
|
|
|
9265
9511
|
scopedSelectedMarket,
|
|
9266
9512
|
tradingLabels
|
|
9267
9513
|
]);
|
|
9268
|
-
const smartRouteErrorMessage = (0,
|
|
9514
|
+
const smartRouteErrorMessage = (0, import_react11.useMemo)(() => {
|
|
9269
9515
|
if (!smartRoute.error) return null;
|
|
9270
9516
|
return normalizePlaceOrderErrorMessage({
|
|
9271
9517
|
errorMessage: smartRoute.error.message,
|
|
@@ -9274,7 +9520,7 @@ var PlaceOrder = ({
|
|
|
9274
9520
|
});
|
|
9275
9521
|
}, [smartRoute.error, tradingLabels]);
|
|
9276
9522
|
const progressActionLabel = (internalTab === "buy" ? tradingLabels.buyingOutcome(selectedOutcomeLabel) : tradingLabels.sellingOutcome(selectedOutcomeLabel)).trim();
|
|
9277
|
-
const canRetryRemaining = (0,
|
|
9523
|
+
const canRetryRemaining = (0, import_react11.useMemo)(() => {
|
|
9278
9524
|
const remaining = getPlaceOrderUnfilledRemaining({
|
|
9279
9525
|
originalAmount: internalAmount,
|
|
9280
9526
|
tradeSide: internalTab,
|
|
@@ -9284,7 +9530,7 @@ var PlaceOrder = ({
|
|
|
9284
9530
|
return remaining >= minRemainder;
|
|
9285
9531
|
}, [executionProgress.terminalOrderEvents, internalAmount, internalTab, isSell]);
|
|
9286
9532
|
const PARTIAL_FILL_AUTO_SUCCESS_THRESHOLD = 0.95;
|
|
9287
|
-
const shouldAutoSkipPartialFill = (0,
|
|
9533
|
+
const shouldAutoSkipPartialFill = (0, import_react11.useMemo)(() => {
|
|
9288
9534
|
if (internalAmount <= 0) return false;
|
|
9289
9535
|
const remaining = getPlaceOrderUnfilledRemaining({
|
|
9290
9536
|
originalAmount: internalAmount,
|
|
@@ -9295,7 +9541,7 @@ var PlaceOrder = ({
|
|
|
9295
9541
|
const fillRatio = filled / internalAmount;
|
|
9296
9542
|
return fillRatio >= PARTIAL_FILL_AUTO_SUCCESS_THRESHOLD || !canRetryRemaining;
|
|
9297
9543
|
}, [canRetryRemaining, executionProgress.terminalOrderEvents, internalAmount, internalTab]);
|
|
9298
|
-
const failureSummary = (0,
|
|
9544
|
+
const failureSummary = (0, import_react11.useMemo)(() => {
|
|
9299
9545
|
var _a2;
|
|
9300
9546
|
if ((submissionProgressState == null ? void 0 : submissionProgressState.phase) !== "failed") return void 0;
|
|
9301
9547
|
return buildPlaceOrderFailureSummary({
|
|
@@ -9324,7 +9570,7 @@ var PlaceOrder = ({
|
|
|
9324
9570
|
submissionProgressState,
|
|
9325
9571
|
tradingLabels
|
|
9326
9572
|
]);
|
|
9327
|
-
const displayedToWinHint = (0,
|
|
9573
|
+
const displayedToWinHint = (0, import_react11.useMemo)(() => {
|
|
9328
9574
|
var _a2, _b2, _c2, _d2;
|
|
9329
9575
|
if (!selectedRouteCard) return "";
|
|
9330
9576
|
if (selectedRouteCard.isUnavailable) {
|
|
@@ -9333,14 +9579,14 @@ var PlaceOrder = ({
|
|
|
9333
9579
|
}
|
|
9334
9580
|
return (_d2 = selectedRouteCard.hint) != null ? _d2 : "";
|
|
9335
9581
|
}, [selectedRouteCard, tradingLabels]);
|
|
9336
|
-
const displayedToWinValue = (
|
|
9582
|
+
const displayedToWinValue = (_D = selectedRouteCard == null ? void 0 : selectedRouteCard.numericValue) != null ? _D : 0;
|
|
9337
9583
|
const activeFeeBreakdown = activeQuoteData == null ? void 0 : activeQuoteData.feeBreakdown;
|
|
9338
|
-
const estimatedFeesValue = (0,
|
|
9584
|
+
const estimatedFeesValue = (0, import_react11.useMemo)(() => {
|
|
9339
9585
|
if (!activeFeeBreakdown) return null;
|
|
9340
9586
|
const totalFees = activeFeeBreakdown.venueFees + activeFeeBreakdown.bridgeFees + activeFeeBreakdown.executionGas;
|
|
9341
9587
|
return formatUsd(totalFees, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
9342
9588
|
}, [activeFeeBreakdown]);
|
|
9343
|
-
const feeBreakdownRows = (0,
|
|
9589
|
+
const feeBreakdownRows = (0, import_react11.useMemo)(() => {
|
|
9344
9590
|
if (!activeFeeBreakdown) return [];
|
|
9345
9591
|
return [
|
|
9346
9592
|
{
|
|
@@ -9374,16 +9620,16 @@ var PlaceOrder = ({
|
|
|
9374
9620
|
}
|
|
9375
9621
|
];
|
|
9376
9622
|
}, [activeFeeBreakdown, tradingLabels]);
|
|
9377
|
-
const isActionLoading = isPrimaryActionLoading || executeManaged.isPending;
|
|
9378
|
-
const selectedRouteGeoBlocked = (
|
|
9379
|
-
const geoBlockedVenuesFromWarnings = (0,
|
|
9623
|
+
const isActionLoading = isPrimaryActionLoading || executeManaged.isPending || isBeforeActionPending;
|
|
9624
|
+
const selectedRouteGeoBlocked = (_E = selectedRouteCard == null ? void 0 : selectedRouteCard.isUnavailable) != null ? _E : false;
|
|
9625
|
+
const geoBlockedVenuesFromWarnings = (0, import_react11.useMemo)(
|
|
9380
9626
|
() => {
|
|
9381
9627
|
var _a2;
|
|
9382
9628
|
return extractGeoBlockedVenues((_a2 = smartRoute.data) == null ? void 0 : _a2.warnings);
|
|
9383
9629
|
},
|
|
9384
|
-
[(
|
|
9630
|
+
[(_F = smartRoute.data) == null ? void 0 : _F.warnings]
|
|
9385
9631
|
);
|
|
9386
|
-
const isPrimaryVenueGeoBlocked = (0,
|
|
9632
|
+
const isPrimaryVenueGeoBlocked = (0, import_react11.useMemo)(() => {
|
|
9387
9633
|
var _a2, _b2;
|
|
9388
9634
|
if (!selectedRouteCard || selectedRouteCard.isUnavailable) return false;
|
|
9389
9635
|
const fills = (_b2 = (_a2 = selectedRouteCard.quoteData) == null ? void 0 : _a2.fills) != null ? _b2 : [];
|
|
@@ -9394,7 +9640,7 @@ var PlaceOrder = ({
|
|
|
9394
9640
|
const isActionDisabled = isPrimaryActionDisabled || !orderEligibility.canPlaceOrder || isActionLoading || !hasEnteredAmount || !scopedSelectedMarket || isInsufficientBalance || isQuoteInsufficientBalance || isBelowMinimum || isQuoteLoading || !selectedRouteCard || !selectedRouteCard.quoteData.quoteId || selectedRouteGeoBlocked || !isAuthenticated || quoteStatus !== void 0;
|
|
9395
9641
|
const shouldShowSmartRouting = orderEligibility.canPlaceOrder && hasEnteredAmount && !isBelowMinimum && (orderedRouteCards.length > 0 || smartRoute.isFetching || smartRoute.isLoading);
|
|
9396
9642
|
const shouldShowRouteToggle = !isQuoteLoading && orderedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT;
|
|
9397
|
-
const handleReturnToOrderForm = (0,
|
|
9643
|
+
const handleReturnToOrderForm = (0, import_react11.useCallback)(() => {
|
|
9398
9644
|
const submittedSelection = submittedSelectionRef.current;
|
|
9399
9645
|
submittedSelectionRef.current = null;
|
|
9400
9646
|
setSubmissionProgressState(null);
|
|
@@ -9415,7 +9661,7 @@ var PlaceOrder = ({
|
|
|
9415
9661
|
const shareUrl = `https://twitter.com/intent/tweet?text=${encodeURIComponent(shareText)}`;
|
|
9416
9662
|
window.open(shareUrl, "_blank", "noopener,noreferrer");
|
|
9417
9663
|
};
|
|
9418
|
-
const handleExecuteQuote = (0,
|
|
9664
|
+
const handleExecuteQuote = (0, import_react11.useCallback)(
|
|
9419
9665
|
(quoteData) => __async(null, null, function* () {
|
|
9420
9666
|
var _a2, _b2, _c2;
|
|
9421
9667
|
const quoteId = quoteData == null ? void 0 : quoteData.quoteId;
|
|
@@ -9474,6 +9720,7 @@ var PlaceOrder = ({
|
|
|
9474
9720
|
executionVenue: resolveExecutionVenueFromQuote(quoteData),
|
|
9475
9721
|
orderId: response.orderIds[0],
|
|
9476
9722
|
orderIds: response.orderIds,
|
|
9723
|
+
quoteId: response.quoteId,
|
|
9477
9724
|
phase: "submitting"
|
|
9478
9725
|
});
|
|
9479
9726
|
} catch (error) {
|
|
@@ -9513,7 +9760,7 @@ var PlaceOrder = ({
|
|
|
9513
9760
|
tradingLabels.quoteUnavailable
|
|
9514
9761
|
]
|
|
9515
9762
|
);
|
|
9516
|
-
const handleSkipToSuccess = (0,
|
|
9763
|
+
const handleSkipToSuccess = (0, import_react11.useCallback)(() => {
|
|
9517
9764
|
const primaryFilledEvent = executionProgress.terminalOrderEvents.find(
|
|
9518
9765
|
(e) => e.event === "filled" || e.event === "partial_fill"
|
|
9519
9766
|
);
|
|
@@ -9538,7 +9785,7 @@ var PlaceOrder = ({
|
|
|
9538
9785
|
failureSummary,
|
|
9539
9786
|
selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData
|
|
9540
9787
|
]);
|
|
9541
|
-
(0,
|
|
9788
|
+
(0, import_react11.useEffect)(() => {
|
|
9542
9789
|
if ((submissionProgressState == null ? void 0 : submissionProgressState.phase) !== "failed") return;
|
|
9543
9790
|
if ((failureSummary == null ? void 0 : failureSummary.kind) !== "partial_fill") return;
|
|
9544
9791
|
if (!shouldAutoSkipPartialFill) return;
|
|
@@ -9549,7 +9796,7 @@ var PlaceOrder = ({
|
|
|
9549
9796
|
shouldAutoSkipPartialFill,
|
|
9550
9797
|
submissionProgressState == null ? void 0 : submissionProgressState.phase
|
|
9551
9798
|
]);
|
|
9552
|
-
const handleRetrySubmission = (0,
|
|
9799
|
+
const handleRetrySubmission = (0, import_react11.useCallback)(() => __async(null, null, function* () {
|
|
9553
9800
|
var _a2, _b2, _c2;
|
|
9554
9801
|
if (!orderEligibility.canPlaceOrder || (failureSummary == null ? void 0 : failureSummary.kind) === "generic") {
|
|
9555
9802
|
handleReturnToOrderForm();
|
|
@@ -9643,7 +9890,7 @@ var PlaceOrder = ({
|
|
|
9643
9890
|
]);
|
|
9644
9891
|
const resolvedStatusClassName = cn(classNames == null ? void 0 : classNames.root, className);
|
|
9645
9892
|
if (isLoading) {
|
|
9646
|
-
return /* @__PURE__ */ (0,
|
|
9893
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9647
9894
|
Skeleton,
|
|
9648
9895
|
{
|
|
9649
9896
|
ariaLabel: labels.common.loading,
|
|
@@ -9654,7 +9901,7 @@ var PlaceOrder = ({
|
|
|
9654
9901
|
}
|
|
9655
9902
|
if (submissionProgressState) {
|
|
9656
9903
|
if (submissionProgressState.phase === "success" && submissionProgressState.summary) {
|
|
9657
|
-
return /* @__PURE__ */ (0,
|
|
9904
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9658
9905
|
PlaceOrderSuccessView,
|
|
9659
9906
|
{
|
|
9660
9907
|
className: resolvedStatusClassName,
|
|
@@ -9666,7 +9913,7 @@ var PlaceOrder = ({
|
|
|
9666
9913
|
);
|
|
9667
9914
|
}
|
|
9668
9915
|
if (submissionProgressState.phase === "failed") {
|
|
9669
|
-
return /* @__PURE__ */ (0,
|
|
9916
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9670
9917
|
PlaceOrderFailureView,
|
|
9671
9918
|
{
|
|
9672
9919
|
className: resolvedStatusClassName,
|
|
@@ -9721,8 +9968,8 @@ var PlaceOrder = ({
|
|
|
9721
9968
|
};
|
|
9722
9969
|
const handleFillSellableShares = () => {
|
|
9723
9970
|
if (!isSell) return;
|
|
9724
|
-
if (
|
|
9725
|
-
handleAmountChange(
|
|
9971
|
+
if (maxSellableShares <= 0) return;
|
|
9972
|
+
handleAmountChange(maxSellableShares);
|
|
9726
9973
|
};
|
|
9727
9974
|
const handleDepositRequiredClick = () => {
|
|
9728
9975
|
if (!isInsufficientBalance) return;
|
|
@@ -9740,7 +9987,7 @@ var PlaceOrder = ({
|
|
|
9740
9987
|
});
|
|
9741
9988
|
};
|
|
9742
9989
|
const handlePrimaryAction = () => __async(null, null, function* () {
|
|
9743
|
-
var _a2;
|
|
9990
|
+
var _a2, _b2, _c2;
|
|
9744
9991
|
if (!orderEligibility.canPlaceOrder) {
|
|
9745
9992
|
setSubmissionFeedback({
|
|
9746
9993
|
message: (_a2 = resolveOrderEligibilityMessage(labels, orderEligibility.reason)) != null ? _a2 : tradingLabels.orderFailed,
|
|
@@ -9750,6 +9997,26 @@ var PlaceOrder = ({
|
|
|
9750
9997
|
}
|
|
9751
9998
|
if (!selectedRouteCard) return;
|
|
9752
9999
|
setSubmissionFeedback(null);
|
|
10000
|
+
if (onBeforePrimaryAction) {
|
|
10001
|
+
const beforeContext = isPaperMode ? { quoteId: (_b2 = selectedRouteCard.quoteData) == null ? void 0 : _b2.quoteId, mode: "paper" } : { quoteId: (_c2 = selectedRouteCard.quoteData) == null ? void 0 : _c2.quoteId };
|
|
10002
|
+
setIsBeforeActionPending(true);
|
|
10003
|
+
try {
|
|
10004
|
+
const proceed = yield onBeforePrimaryAction(beforeContext);
|
|
10005
|
+
if (proceed === false) return;
|
|
10006
|
+
} catch (error) {
|
|
10007
|
+
setSubmissionFeedback({
|
|
10008
|
+
message: normalizePlaceOrderErrorMessage({
|
|
10009
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
10010
|
+
fallbackMessage: tradingLabels.orderFailed,
|
|
10011
|
+
labels: tradingLabels
|
|
10012
|
+
}),
|
|
10013
|
+
tone: "error"
|
|
10014
|
+
});
|
|
10015
|
+
return;
|
|
10016
|
+
} finally {
|
|
10017
|
+
setIsBeforeActionPending(false);
|
|
10018
|
+
}
|
|
10019
|
+
}
|
|
9753
10020
|
if (scopedSelectedMarket && scopedSelectedOutcomeId) {
|
|
9754
10021
|
submittedSelectionRef.current = {
|
|
9755
10022
|
marketId: scopedSelectedMarket.id,
|
|
@@ -9771,19 +10038,21 @@ var PlaceOrder = ({
|
|
|
9771
10038
|
});
|
|
9772
10039
|
}
|
|
9773
10040
|
});
|
|
9774
|
-
if (!orderEligibility.canPlaceOrder && resolvedReadOnlyTradingState.kind !== "open") {
|
|
9775
|
-
return /* @__PURE__ */ (0,
|
|
10041
|
+
if (isEndedWithoutKnownWinner || !orderEligibility.canPlaceOrder && resolvedReadOnlyTradingState.kind !== "open") {
|
|
10042
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9776
10043
|
PlaceOrderResolvedView,
|
|
9777
10044
|
{
|
|
9778
10045
|
tradingState: resolvedReadOnlyTradingState,
|
|
10046
|
+
resolutionTimestamp: (_G = resolvedEventTradingState.resolvesAt) != null ? _G : resolvedReadOnlyTradingState.resolvesAt,
|
|
9779
10047
|
resolvedClaim,
|
|
9780
10048
|
classNames,
|
|
9781
|
-
className
|
|
10049
|
+
className,
|
|
10050
|
+
isSportsEvent: (scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.structureType) === "sport" && !!(scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.sport) && scopedSelectedEvent.sport !== "other_sport"
|
|
9782
10051
|
}
|
|
9783
10052
|
);
|
|
9784
10053
|
}
|
|
9785
|
-
return /* @__PURE__ */ (0,
|
|
9786
|
-
/* @__PURE__ */ (0,
|
|
10054
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(import_react11.Fragment, { children: [
|
|
10055
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
|
|
9787
10056
|
Card,
|
|
9788
10057
|
{
|
|
9789
10058
|
className: cn(
|
|
@@ -9800,8 +10069,8 @@ var PlaceOrder = ({
|
|
|
9800
10069
|
headerTitle,
|
|
9801
10070
|
onClose
|
|
9802
10071
|
}),
|
|
9803
|
-
/* @__PURE__ */ (0,
|
|
9804
|
-
/* @__PURE__ */ (0,
|
|
10072
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: cn("agg-order-panel-content flex flex-col gap-6", classNames == null ? void 0 : classNames.content), children: [
|
|
10073
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9805
10074
|
"div",
|
|
9806
10075
|
{
|
|
9807
10076
|
className: "agg-order-tabs flex items-end border-b border-agg-separator",
|
|
@@ -9812,7 +10081,7 @@ var PlaceOrder = ({
|
|
|
9812
10081
|
{ value: "sell", label: tradingLabels.sell, ref: sellTabRef }
|
|
9813
10082
|
].map((tabItem) => {
|
|
9814
10083
|
const isActive = internalTab === tabItem.value;
|
|
9815
|
-
return /* @__PURE__ */ (0,
|
|
10084
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
|
|
9816
10085
|
"button",
|
|
9817
10086
|
{
|
|
9818
10087
|
ref: tabItem.ref,
|
|
@@ -9836,7 +10105,7 @@ var PlaceOrder = ({
|
|
|
9836
10105
|
onKeyDown: (event) => handleTabKeyDown(event, tabItem.value),
|
|
9837
10106
|
children: [
|
|
9838
10107
|
tabItem.label,
|
|
9839
|
-
/* @__PURE__ */ (0,
|
|
10108
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9840
10109
|
"span",
|
|
9841
10110
|
{
|
|
9842
10111
|
"aria-hidden": "true",
|
|
@@ -9858,7 +10127,7 @@ var PlaceOrder = ({
|
|
|
9858
10127
|
})
|
|
9859
10128
|
}
|
|
9860
10129
|
),
|
|
9861
|
-
outcomes.length >= 2 ? /* @__PURE__ */ (0,
|
|
10130
|
+
outcomes.length >= 2 ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "agg-outcomes flex w-full max-w-full gap-2", children: outcomes.map((outcome, index) => {
|
|
9862
10131
|
var _a2, _b2, _c2;
|
|
9863
10132
|
const price = getDisplayOutcomePrice({
|
|
9864
10133
|
outcomeId: outcome.id,
|
|
@@ -9872,7 +10141,7 @@ var PlaceOrder = ({
|
|
|
9872
10141
|
});
|
|
9873
10142
|
const isActive = outcome.id === scopedSelectedOutcomeId;
|
|
9874
10143
|
const isPositive = resolveIsPositiveOutcome(outcome, index);
|
|
9875
|
-
return /* @__PURE__ */ (0,
|
|
10144
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
|
|
9876
10145
|
"button",
|
|
9877
10146
|
{
|
|
9878
10147
|
"data-id": outcome.id,
|
|
@@ -9892,7 +10161,7 @@ var PlaceOrder = ({
|
|
|
9892
10161
|
disabled: !orderEligibility.canPlaceOrder || isResolvedOutcomeCtaLocked,
|
|
9893
10162
|
onClick: () => handleOutcomeChange(outcome.id),
|
|
9894
10163
|
children: [
|
|
9895
|
-
/* @__PURE__ */ (0,
|
|
10164
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9896
10165
|
Typography,
|
|
9897
10166
|
{
|
|
9898
10167
|
as: "span",
|
|
@@ -9901,18 +10170,18 @@ var PlaceOrder = ({
|
|
|
9901
10170
|
children: (_c2 = outcome.title) != null ? _c2 : outcome.label
|
|
9902
10171
|
}
|
|
9903
10172
|
),
|
|
9904
|
-
/* @__PURE__ */ (0,
|
|
10173
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Typography, { as: "span", variant: isActive ? "body-strong" : "body", children: formatProbabilityCents(price) })
|
|
9905
10174
|
]
|
|
9906
10175
|
},
|
|
9907
10176
|
outcome.id
|
|
9908
10177
|
);
|
|
9909
10178
|
}) }) : null,
|
|
9910
|
-
/* @__PURE__ */ (0,
|
|
9911
|
-
/* @__PURE__ */ (0,
|
|
9912
|
-
/* @__PURE__ */ (0,
|
|
9913
|
-
isAuthenticated ? isSell ? /* @__PURE__ */ (0,
|
|
9914
|
-
/* @__PURE__ */ (0,
|
|
9915
|
-
displayedCurrentSellableShares > 0 ? /* @__PURE__ */ (0,
|
|
10179
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-order-amount-section flex items-start justify-between gap-4", children: [
|
|
10180
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-order-amount-meta flex flex-col", children: [
|
|
10181
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "agg-order-amount-label text-agg-base font-agg-bold leading-agg-6 text-agg-foreground whitespace-nowrap", children: tradingLabels.amount(internalTab) }),
|
|
10182
|
+
isAuthenticated ? isSell ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "agg-balance-value flex items-baseline gap-1.5 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: isCurrentSellableSharesLoading ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(LoadingIcon, { size: "small" }) : /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(import_jsx_runtime123.Fragment, { children: [
|
|
10183
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { className: "whitespace-pre", children: displayedCurrentSellableSharesLabel }),
|
|
10184
|
+
displayedCurrentSellableShares > 0 ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9916
10185
|
"button",
|
|
9917
10186
|
{
|
|
9918
10187
|
type: "button",
|
|
@@ -9928,9 +10197,9 @@ var PlaceOrder = ({
|
|
|
9928
10197
|
children: tradingLabels.maxShares
|
|
9929
10198
|
}
|
|
9930
10199
|
) : null
|
|
9931
|
-
] }) }) : /* @__PURE__ */ (0,
|
|
10200
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "agg-balance-value flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: isBalanceLoading ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(LoadingIcon, { size: "small" }) : tradingLabels.balance(formatUsd(totalBalance)) }) : null
|
|
9932
10201
|
] }),
|
|
9933
|
-
/* @__PURE__ */ (0,
|
|
10202
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9934
10203
|
CurrencyInput,
|
|
9935
10204
|
{
|
|
9936
10205
|
value: internalAmount,
|
|
@@ -9939,7 +10208,7 @@ var PlaceOrder = ({
|
|
|
9939
10208
|
isInvalid: isInsufficientBalance || isBelowMinimum,
|
|
9940
10209
|
disabled: !orderEligibility.canPlaceOrder,
|
|
9941
10210
|
prefix: internalTab === "buy" ? "$" : "",
|
|
9942
|
-
decimalPlaces: isSell ?
|
|
10211
|
+
decimalPlaces: isSell ? SELL_SHARE_INPUT_DECIMALS : 2,
|
|
9943
10212
|
classNames: {
|
|
9944
10213
|
input: cn(
|
|
9945
10214
|
"agg-order-amount-input",
|
|
@@ -9950,9 +10219,9 @@ var PlaceOrder = ({
|
|
|
9950
10219
|
}
|
|
9951
10220
|
)
|
|
9952
10221
|
] }),
|
|
9953
|
-
showFeesBreakdown && hasEnteredAmount && !isBelowMinimum && estimatedFeesValue ? /* @__PURE__ */ (0,
|
|
9954
|
-
/* @__PURE__ */ (0,
|
|
9955
|
-
/* @__PURE__ */ (0,
|
|
10222
|
+
showFeesBreakdown && hasEnteredAmount && !isBelowMinimum && estimatedFeesValue ? /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-order-fees-section flex items-center justify-between gap-4", children: [
|
|
10223
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
10224
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9956
10225
|
Typography,
|
|
9957
10226
|
{
|
|
9958
10227
|
variant: "text-sm",
|
|
@@ -9960,7 +10229,7 @@ var PlaceOrder = ({
|
|
|
9960
10229
|
children: tradingLabels.estimatedFees
|
|
9961
10230
|
}
|
|
9962
10231
|
),
|
|
9963
|
-
feeBreakdownRows.length > 0 ? /* @__PURE__ */ (0,
|
|
10232
|
+
feeBreakdownRows.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9964
10233
|
Tooltip,
|
|
9965
10234
|
{
|
|
9966
10235
|
"aria-label": tradingLabels.estimatedFeesTooltipAria,
|
|
@@ -9972,13 +10241,13 @@ var PlaceOrder = ({
|
|
|
9972
10241
|
icon: "h-3 w-3 text-agg-muted-foreground",
|
|
9973
10242
|
trigger: "h-3 w-3 text-agg-muted-foreground"
|
|
9974
10243
|
},
|
|
9975
|
-
content: /* @__PURE__ */ (0,
|
|
10244
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "flex w-full flex-col gap-2", children: feeBreakdownRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
|
|
9976
10245
|
"div",
|
|
9977
10246
|
{
|
|
9978
10247
|
className: "flex items-center justify-between gap-3 text-agg-sm font-agg-normal leading-agg-5 text-agg-foreground",
|
|
9979
10248
|
children: [
|
|
9980
|
-
/* @__PURE__ */ (0,
|
|
9981
|
-
row.kind === "badge" ? /* @__PURE__ */ (0,
|
|
10249
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { children: row.label }),
|
|
10250
|
+
row.kind === "badge" ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9982
10251
|
"span",
|
|
9983
10252
|
{
|
|
9984
10253
|
className: cn(
|
|
@@ -9988,7 +10257,7 @@ var PlaceOrder = ({
|
|
|
9988
10257
|
),
|
|
9989
10258
|
children: row.badgeLabel
|
|
9990
10259
|
}
|
|
9991
|
-
) : /* @__PURE__ */ (0,
|
|
10260
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { className: "text-right", children: row.value })
|
|
9992
10261
|
]
|
|
9993
10262
|
},
|
|
9994
10263
|
row.label
|
|
@@ -9996,12 +10265,12 @@ var PlaceOrder = ({
|
|
|
9996
10265
|
}
|
|
9997
10266
|
) : null
|
|
9998
10267
|
] }),
|
|
9999
|
-
/* @__PURE__ */ (0,
|
|
10268
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: estimatedFeesValue })
|
|
10000
10269
|
] }) : null,
|
|
10001
|
-
shouldShowSmartRouting ? /* @__PURE__ */ (0,
|
|
10002
|
-
/* @__PURE__ */ (0,
|
|
10003
|
-
/* @__PURE__ */ (0,
|
|
10004
|
-
shouldShowRouteToggle && !isRoutesExpanded ? /* @__PURE__ */ (0,
|
|
10270
|
+
shouldShowSmartRouting ? /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-route-panel flex flex-col gap-3", children: [
|
|
10271
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-route-panel-header flex items-center justify-between gap-4", children: [
|
|
10272
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "agg-route-panel-title text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.smartRouting }),
|
|
10273
|
+
shouldShowRouteToggle && !isRoutesExpanded ? /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
|
|
10005
10274
|
"button",
|
|
10006
10275
|
{
|
|
10007
10276
|
type: "button",
|
|
@@ -10009,8 +10278,8 @@ var PlaceOrder = ({
|
|
|
10009
10278
|
"aria-label": tradingLabels.viewAllRoutes(orderedRouteCards.length),
|
|
10010
10279
|
onClick: () => setIsRoutesExpanded((currentValue) => !currentValue),
|
|
10011
10280
|
children: [
|
|
10012
|
-
/* @__PURE__ */ (0,
|
|
10013
|
-
/* @__PURE__ */ (0,
|
|
10281
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { children: tradingLabels.viewAllRoutes(orderedRouteCards.length) }),
|
|
10282
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
10014
10283
|
Icon,
|
|
10015
10284
|
{
|
|
10016
10285
|
name: "chevron-down",
|
|
@@ -10023,11 +10292,11 @@ var PlaceOrder = ({
|
|
|
10023
10292
|
}
|
|
10024
10293
|
) : null
|
|
10025
10294
|
] }),
|
|
10026
|
-
/* @__PURE__ */ (0,
|
|
10027
|
-
/* @__PURE__ */ (0,
|
|
10028
|
-
/* @__PURE__ */ (0,
|
|
10295
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "agg-route-list flex flex-col gap-2", children: isQuoteLoading ? /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-route-loading flex flex-col gap-2", "aria-hidden": "true", children: [
|
|
10296
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(PlaceOrderRouteCardSkeleton, {}),
|
|
10297
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(PlaceOrderRouteCardSkeleton, {})
|
|
10029
10298
|
] }) : visibleRouteCards.length > 0 ? visibleRouteCards.map((card) => {
|
|
10030
|
-
return /* @__PURE__ */ (0,
|
|
10299
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_react11.Fragment, { children: renderRouteCard({
|
|
10031
10300
|
card,
|
|
10032
10301
|
enableAnimations,
|
|
10033
10302
|
isExpanded: card.kind === "split" ? isSplitDetailOpen : isRoutesExpanded,
|
|
@@ -10037,13 +10306,13 @@ var PlaceOrder = ({
|
|
|
10037
10306
|
}) }, card.id);
|
|
10038
10307
|
}) : null })
|
|
10039
10308
|
] }) : null,
|
|
10040
|
-
hasEnteredAmount && selectedRouteCard && !isQuoteLoading && !isBelowMinimum && orderEligibility.canPlaceOrder ? /* @__PURE__ */ (0,
|
|
10041
|
-
/* @__PURE__ */ (0,
|
|
10042
|
-
/* @__PURE__ */ (0,
|
|
10043
|
-
/* @__PURE__ */ (0,
|
|
10309
|
+
hasEnteredAmount && selectedRouteCard && !isQuoteLoading && !isBelowMinimum && orderEligibility.canPlaceOrder ? /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-order-summary flex items-start justify-between gap-4", children: [
|
|
10310
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-order-summary-meta flex flex-col", children: [
|
|
10311
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "agg-order-summary-label text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.toWin(internalTab) }),
|
|
10312
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "agg-order-summary-hint text-agg-sm leading-agg-5 text-agg-muted-foreground", children: displayedToWinHint })
|
|
10044
10313
|
] }),
|
|
10045
|
-
/* @__PURE__ */ (0,
|
|
10046
|
-
|
|
10314
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
10315
|
+
import_react10.default,
|
|
10047
10316
|
{
|
|
10048
10317
|
value: displayedToWinValue,
|
|
10049
10318
|
locales: locale,
|
|
@@ -10057,7 +10326,7 @@ var PlaceOrder = ({
|
|
|
10057
10326
|
}
|
|
10058
10327
|
)
|
|
10059
10328
|
] }) : null,
|
|
10060
|
-
/* @__PURE__ */ (0,
|
|
10329
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
|
|
10061
10330
|
"div",
|
|
10062
10331
|
{
|
|
10063
10332
|
className: cn(
|
|
@@ -10065,17 +10334,17 @@ var PlaceOrder = ({
|
|
|
10065
10334
|
classNames == null ? void 0 : classNames.footer
|
|
10066
10335
|
),
|
|
10067
10336
|
children: [
|
|
10068
|
-
!shouldShowGeoBlockBanner ? /* @__PURE__ */ (0,
|
|
10069
|
-
submissionFeedback ? /* @__PURE__ */ (0,
|
|
10337
|
+
!shouldShowGeoBlockBanner ? /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-order-alerts flex flex-col gap-3 empty:hidden mb-3", children: [
|
|
10338
|
+
submissionFeedback ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
10070
10339
|
InlineAlert,
|
|
10071
10340
|
{
|
|
10072
10341
|
tone: submissionFeedback.tone,
|
|
10073
10342
|
message: submissionFeedback.message
|
|
10074
10343
|
}
|
|
10075
10344
|
) : null,
|
|
10076
|
-
!submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && isBelowMinimum ? /* @__PURE__ */ (0,
|
|
10077
|
-
!submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && !isBelowMinimum && quoteStatus ? /* @__PURE__ */ (0,
|
|
10078
|
-
!submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && !isBelowMinimum && !quoteStatus && isAuthenticated && hasEnteredAmount && smartRouteErrorMessage ? /* @__PURE__ */ (0,
|
|
10345
|
+
!submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && isBelowMinimum ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(InlineAlert, { tone: "error", message: belowMinimumMessage }) : null,
|
|
10346
|
+
!submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && !isBelowMinimum && quoteStatus ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(InlineAlert, { tone: quoteStatus.tone, message: quoteStatus.message }) : null,
|
|
10347
|
+
!submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && !isBelowMinimum && !quoteStatus && isAuthenticated && hasEnteredAmount && smartRouteErrorMessage ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
10079
10348
|
InlineAlert,
|
|
10080
10349
|
{
|
|
10081
10350
|
tone: "error",
|
|
@@ -10087,14 +10356,14 @@ var PlaceOrder = ({
|
|
|
10087
10356
|
}
|
|
10088
10357
|
) : null
|
|
10089
10358
|
] }) : null,
|
|
10090
|
-
!submissionFeedback && !shouldShowGeoBlockBanner && orderEligibility.canPlaceOrder && shouldShowInsufficientBalanceAlert ? /* @__PURE__ */ (0,
|
|
10359
|
+
!submissionFeedback && !shouldShowGeoBlockBanner && orderEligibility.canPlaceOrder && shouldShowInsufficientBalanceAlert ? /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
|
|
10091
10360
|
"div",
|
|
10092
10361
|
{
|
|
10093
10362
|
className: "agg-order-insufficient-balance-alert flex items-center justify-center gap-2",
|
|
10094
10363
|
role: "status",
|
|
10095
10364
|
"aria-live": "polite",
|
|
10096
10365
|
children: [
|
|
10097
|
-
/* @__PURE__ */ (0,
|
|
10366
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
10098
10367
|
Icon,
|
|
10099
10368
|
{
|
|
10100
10369
|
name: "warning-filled",
|
|
@@ -10103,11 +10372,11 @@ var PlaceOrder = ({
|
|
|
10103
10372
|
"aria-hidden": "true"
|
|
10104
10373
|
}
|
|
10105
10374
|
),
|
|
10106
|
-
/* @__PURE__ */ (0,
|
|
10375
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)("span", { className: "text-agg-sm text-agg-foreground", children: tradingLabels.insufficientBalance })
|
|
10107
10376
|
]
|
|
10108
10377
|
}
|
|
10109
10378
|
) : null,
|
|
10110
|
-
!submissionFeedback && !shouldShowGeoBlockBanner && isInsufficientBalance ? /* @__PURE__ */ (0,
|
|
10379
|
+
!submissionFeedback && !shouldShowGeoBlockBanner && isInsufficientBalance ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
10111
10380
|
Button,
|
|
10112
10381
|
{
|
|
10113
10382
|
size: "large",
|
|
@@ -10117,7 +10386,7 @@ var PlaceOrder = ({
|
|
|
10117
10386
|
onClick: handleDepositRequiredClick,
|
|
10118
10387
|
children: tradingLabels.deposit
|
|
10119
10388
|
}
|
|
10120
|
-
) : needsKycVerification && !submissionFeedback && !shouldShowGeoBlockBanner ? /* @__PURE__ */ (0,
|
|
10389
|
+
) : needsKycVerification && !submissionFeedback && !shouldShowGeoBlockBanner ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(InitiateKycButton, { label: tradingLabels.kycRequired, onOpen: openVerifyModal }) : isQuoteLoading && !isActionLoading ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
10121
10390
|
Button,
|
|
10122
10391
|
{
|
|
10123
10392
|
size: "large",
|
|
@@ -10126,7 +10395,7 @@ var PlaceOrder = ({
|
|
|
10126
10395
|
disabled: true,
|
|
10127
10396
|
"aria-live": "polite",
|
|
10128
10397
|
"aria-label": routeLoadingMessage != null ? routeLoadingMessage : labels.common.loading,
|
|
10129
|
-
prefix: /* @__PURE__ */ (0,
|
|
10398
|
+
prefix: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
10130
10399
|
"span",
|
|
10131
10400
|
{
|
|
10132
10401
|
className: cn(
|
|
@@ -10138,7 +10407,7 @@ var PlaceOrder = ({
|
|
|
10138
10407
|
),
|
|
10139
10408
|
children: routeLoadingMessage
|
|
10140
10409
|
}
|
|
10141
|
-
) : !isAuthenticated ? /* @__PURE__ */ (0,
|
|
10410
|
+
) : !isAuthenticated ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
10142
10411
|
Button,
|
|
10143
10412
|
{
|
|
10144
10413
|
size: "large",
|
|
@@ -10146,10 +10415,10 @@ var PlaceOrder = ({
|
|
|
10146
10415
|
className: "agg-order-submit h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none",
|
|
10147
10416
|
disabled: !orderEligibility.canPlaceOrder || shouldShowGeoBlockBanner,
|
|
10148
10417
|
"aria-label": tradingLabels.signInToTrade,
|
|
10149
|
-
onClick:
|
|
10418
|
+
onClick: import_hooks30.requestAggAuthChooserOpen,
|
|
10150
10419
|
children: tradingLabels.signInToTrade
|
|
10151
10420
|
}
|
|
10152
|
-
) : /* @__PURE__ */ (0,
|
|
10421
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
10153
10422
|
Button,
|
|
10154
10423
|
{
|
|
10155
10424
|
size: "large",
|
|
@@ -10164,8 +10433,8 @@ var PlaceOrder = ({
|
|
|
10164
10433
|
children: actionLabel
|
|
10165
10434
|
}
|
|
10166
10435
|
),
|
|
10167
|
-
!shouldShowGeoBlockBanner && internalTab === "buy" && showFeesBreakdown ? /* @__PURE__ */ (0,
|
|
10168
|
-
/* @__PURE__ */ (0,
|
|
10436
|
+
!shouldShowGeoBlockBanner && internalTab === "buy" && showFeesBreakdown ? /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "agg-order-platform-fee mt-1 flex items-center justify-center gap-1.5 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: [
|
|
10437
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
10169
10438
|
Icon,
|
|
10170
10439
|
{
|
|
10171
10440
|
name: "shield-trust",
|
|
@@ -10174,10 +10443,10 @@ var PlaceOrder = ({
|
|
|
10174
10443
|
"aria-hidden": "true"
|
|
10175
10444
|
}
|
|
10176
10445
|
),
|
|
10177
|
-
/* @__PURE__ */ (0,
|
|
10446
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Typography, { variant: "text-xs-caps", className: "text-agg-primary", children: tradingLabels.platformFee })
|
|
10178
10447
|
] }) : null,
|
|
10179
|
-
shouldShowGeoBlockBanner ? /* @__PURE__ */ (0,
|
|
10180
|
-
!shouldShowGeoBlockBanner ? /* @__PURE__ */ (0,
|
|
10448
|
+
shouldShowGeoBlockBanner ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(GeoBlockBanner, { termsUrl: AGG_TERMS_OF_SERVICE_URL }) : null,
|
|
10449
|
+
!shouldShowGeoBlockBanner ? /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("p", { className: "agg-order-disclaimer text-center text-agg-xs leading-agg-4 text-agg-muted-foreground", children: tradingLabels.disclaimer }) : null
|
|
10181
10450
|
]
|
|
10182
10451
|
}
|
|
10183
10452
|
)
|
|
@@ -10185,7 +10454,7 @@ var PlaceOrder = ({
|
|
|
10185
10454
|
]
|
|
10186
10455
|
}
|
|
10187
10456
|
),
|
|
10188
|
-
/* @__PURE__ */ (0,
|
|
10457
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
10189
10458
|
KycVerifyModal,
|
|
10190
10459
|
{
|
|
10191
10460
|
open: isKycVerifyModalOpen,
|
|
@@ -10202,7 +10471,7 @@ var PlaceOrder = ({
|
|
|
10202
10471
|
}
|
|
10203
10472
|
}
|
|
10204
10473
|
),
|
|
10205
|
-
/* @__PURE__ */ (0,
|
|
10474
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
10206
10475
|
KycSuccessModal,
|
|
10207
10476
|
{
|
|
10208
10477
|
open: showKycSuccessModal,
|
|
@@ -10221,7 +10490,313 @@ var PlaceOrder = ({
|
|
|
10221
10490
|
PlaceOrder.displayName = "PlaceOrder";
|
|
10222
10491
|
|
|
10223
10492
|
// src/trading/trading-context/index.tsx
|
|
10224
|
-
var
|
|
10493
|
+
var import_hooks31 = require("@agg-build/hooks");
|
|
10494
|
+
|
|
10495
|
+
// src/trading/use-claim-winnings.ts
|
|
10496
|
+
var import_hooks32 = require("@agg-build/hooks");
|
|
10497
|
+
var import_react12 = require("react");
|
|
10498
|
+
var toClaimError = (err) => {
|
|
10499
|
+
if (err instanceof Error) return err;
|
|
10500
|
+
return new Error(String(err));
|
|
10501
|
+
};
|
|
10502
|
+
function useClaimWinnings(options = {}) {
|
|
10503
|
+
const { onClaim, onClaimResult, onClaimSubmitError, externalClaimingKeys } = options;
|
|
10504
|
+
const labels = (0, import_hooks32.useLabels)();
|
|
10505
|
+
const claimNotificationLabels = labels.notifications.claim;
|
|
10506
|
+
const toastCtx = useOptionalToast();
|
|
10507
|
+
const queryClient = (0, import_hooks32.useQueryClient)();
|
|
10508
|
+
const redeemMutation = (0, import_hooks32.useRedeem)();
|
|
10509
|
+
const [activeRedeems, setActiveRedeems] = (0, import_react12.useState)({});
|
|
10510
|
+
const activeClaimKeysRef = (0, import_react12.useRef)(/* @__PURE__ */ new Set());
|
|
10511
|
+
const pendingClaimToastIdsRef = (0, import_react12.useRef)({});
|
|
10512
|
+
const submittedClaimToastKeysRef = (0, import_react12.useRef)(/* @__PURE__ */ new Set());
|
|
10513
|
+
const [submittingClaimKeys, setSubmittingClaimKeys] = (0, import_react12.useState)({});
|
|
10514
|
+
const lifecycleInputs = (0, import_react12.useMemo)(
|
|
10515
|
+
() => Object.values(activeRedeems),
|
|
10516
|
+
[activeRedeems]
|
|
10517
|
+
);
|
|
10518
|
+
const lifecycleStates = (0, import_hooks32.useRedeemLifecycles)(lifecycleInputs);
|
|
10519
|
+
const internalClaimingIds = (0, import_react12.useMemo)(() => {
|
|
10520
|
+
const out = __spreadValues({}, submittingClaimKeys);
|
|
10521
|
+
for (const [claimKey, active] of Object.entries(activeRedeems)) {
|
|
10522
|
+
const state = lifecycleStates[active.redeemId];
|
|
10523
|
+
if (!state || !state.terminal) out[claimKey] = true;
|
|
10524
|
+
}
|
|
10525
|
+
return out;
|
|
10526
|
+
}, [activeRedeems, lifecycleStates, submittingClaimKeys]);
|
|
10527
|
+
const claimingKeys = externalClaimingKeys != null ? externalClaimingKeys : internalClaimingIds;
|
|
10528
|
+
const isClaiming = (0, import_react12.useCallback)(
|
|
10529
|
+
(claimKey) => Boolean(externalClaimingKeys == null ? void 0 : externalClaimingKeys[claimKey]) || Boolean(internalClaimingIds[claimKey]),
|
|
10530
|
+
[externalClaimingKeys, internalClaimingIds]
|
|
10531
|
+
);
|
|
10532
|
+
const invalidateClaimUiState = (0, import_react12.useCallback)(() => {
|
|
10533
|
+
(0, import_hooks32.invalidateBalanceQueries)(queryClient);
|
|
10534
|
+
(0, import_hooks32.invalidatePositionQueries)(queryClient);
|
|
10535
|
+
queryClient.invalidateQueries({
|
|
10536
|
+
queryKey: import_hooks32.executionKeys.claimablePositionsCount(),
|
|
10537
|
+
refetchType: "active"
|
|
10538
|
+
});
|
|
10539
|
+
(0, import_hooks32.invalidateUserActivityQueries)(queryClient);
|
|
10540
|
+
}, [queryClient]);
|
|
10541
|
+
const claim = (0, import_react12.useCallback)(
|
|
10542
|
+
(_0) => __async(null, [_0], function* ({ claimKey, winningOutcomeIds, payload }) {
|
|
10543
|
+
if (activeClaimKeysRef.current.has(claimKey) || Boolean(externalClaimingKeys == null ? void 0 : externalClaimingKeys[claimKey]) || internalClaimingIds[claimKey]) {
|
|
10544
|
+
return;
|
|
10545
|
+
}
|
|
10546
|
+
activeClaimKeysRef.current.add(claimKey);
|
|
10547
|
+
setSubmittingClaimKeys((prev) => __spreadProps(__spreadValues({}, prev), { [claimKey]: true }));
|
|
10548
|
+
const pendingToastId = toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.pendingMessage, {
|
|
10549
|
+
title: claimNotificationLabels.pendingTitle,
|
|
10550
|
+
tone: "info"
|
|
10551
|
+
});
|
|
10552
|
+
if (pendingToastId != null) {
|
|
10553
|
+
pendingClaimToastIdsRef.current[claimKey] = pendingToastId;
|
|
10554
|
+
}
|
|
10555
|
+
if (onClaim) {
|
|
10556
|
+
try {
|
|
10557
|
+
yield onClaim(payload);
|
|
10558
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
10559
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
10560
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
10561
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.successMessage, {
|
|
10562
|
+
title: claimNotificationLabels.successTitle,
|
|
10563
|
+
tone: "success"
|
|
10564
|
+
});
|
|
10565
|
+
} catch (err) {
|
|
10566
|
+
const error = toClaimError(err);
|
|
10567
|
+
console.error("[useClaimWinnings] redeem failed", error);
|
|
10568
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
10569
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
10570
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
10571
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
|
|
10572
|
+
title: claimNotificationLabels.failedTitle,
|
|
10573
|
+
tone: "error"
|
|
10574
|
+
});
|
|
10575
|
+
onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
|
|
10576
|
+
throw error;
|
|
10577
|
+
} finally {
|
|
10578
|
+
invalidateClaimUiState();
|
|
10579
|
+
activeClaimKeysRef.current.delete(claimKey);
|
|
10580
|
+
setSubmittingClaimKeys((prev) => {
|
|
10581
|
+
const _a = prev, { [claimKey]: _removed } = _a, rest = __objRest(_a, [__restKey(claimKey)]);
|
|
10582
|
+
return rest;
|
|
10583
|
+
});
|
|
10584
|
+
}
|
|
10585
|
+
return;
|
|
10586
|
+
}
|
|
10587
|
+
if (winningOutcomeIds.length === 0) {
|
|
10588
|
+
const error = new Error(claimNotificationLabels.missingOutcomeMessage);
|
|
10589
|
+
console.error("[useClaimWinnings] redeem failed", error);
|
|
10590
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
10591
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
10592
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
10593
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
|
|
10594
|
+
title: claimNotificationLabels.failedTitle,
|
|
10595
|
+
tone: "error"
|
|
10596
|
+
});
|
|
10597
|
+
onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
|
|
10598
|
+
invalidateClaimUiState();
|
|
10599
|
+
activeClaimKeysRef.current.delete(claimKey);
|
|
10600
|
+
setSubmittingClaimKeys((prev) => {
|
|
10601
|
+
const _a = prev, { [claimKey]: _removed } = _a, rest = __objRest(_a, [__restKey(claimKey)]);
|
|
10602
|
+
return rest;
|
|
10603
|
+
});
|
|
10604
|
+
throw error;
|
|
10605
|
+
}
|
|
10606
|
+
try {
|
|
10607
|
+
const response = yield redeemMutation.mutateAsync({
|
|
10608
|
+
venueMarketOutcomeIds: winningOutcomeIds
|
|
10609
|
+
});
|
|
10610
|
+
const expectedOutcomeIds = [];
|
|
10611
|
+
const preFailedOutcomeIds = [];
|
|
10612
|
+
const preFailedReasons = {};
|
|
10613
|
+
const preConfirmedOutcomeIds = [];
|
|
10614
|
+
const preConfirmedTxHashes = {};
|
|
10615
|
+
for (const result of response.results) {
|
|
10616
|
+
if (result.status === "submitted") {
|
|
10617
|
+
expectedOutcomeIds.push(result.venueMarketOutcomeId);
|
|
10618
|
+
} else if (result.status === "confirmed") {
|
|
10619
|
+
preConfirmedOutcomeIds.push(result.venueMarketOutcomeId);
|
|
10620
|
+
preConfirmedTxHashes[result.venueMarketOutcomeId] = result.txHash;
|
|
10621
|
+
} else if (result.status === "ineligible" || result.status === "rejected") {
|
|
10622
|
+
preFailedOutcomeIds.push(result.venueMarketOutcomeId);
|
|
10623
|
+
preFailedReasons[result.venueMarketOutcomeId] = result.reason;
|
|
10624
|
+
}
|
|
10625
|
+
}
|
|
10626
|
+
if (expectedOutcomeIds.length > 0) {
|
|
10627
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
10628
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
10629
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
10630
|
+
submittedClaimToastKeysRef.current.add(claimKey);
|
|
10631
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.submittedMessage, {
|
|
10632
|
+
title: claimNotificationLabels.submittedTitle,
|
|
10633
|
+
tone: "success"
|
|
10634
|
+
});
|
|
10635
|
+
}
|
|
10636
|
+
setActiveRedeems((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
10637
|
+
[claimKey]: {
|
|
10638
|
+
redeemId: response.redeemId,
|
|
10639
|
+
expectedOutcomeIds,
|
|
10640
|
+
preFailedOutcomeIds,
|
|
10641
|
+
preFailedReasons,
|
|
10642
|
+
preConfirmedOutcomeIds,
|
|
10643
|
+
preConfirmedTxHashes
|
|
10644
|
+
}
|
|
10645
|
+
}));
|
|
10646
|
+
yield queryClient.invalidateQueries({ queryKey: ["current-user"] });
|
|
10647
|
+
} catch (err) {
|
|
10648
|
+
const error = toClaimError(err);
|
|
10649
|
+
console.error("[useClaimWinnings] redeem failed", error);
|
|
10650
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
10651
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
10652
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
10653
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
|
|
10654
|
+
title: claimNotificationLabels.failedTitle,
|
|
10655
|
+
tone: "error"
|
|
10656
|
+
});
|
|
10657
|
+
onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
|
|
10658
|
+
throw error;
|
|
10659
|
+
} finally {
|
|
10660
|
+
activeClaimKeysRef.current.delete(claimKey);
|
|
10661
|
+
setSubmittingClaimKeys((prev) => {
|
|
10662
|
+
const _a = prev, { [claimKey]: _removed } = _a, rest = __objRest(_a, [__restKey(claimKey)]);
|
|
10663
|
+
return rest;
|
|
10664
|
+
});
|
|
10665
|
+
}
|
|
10666
|
+
}),
|
|
10667
|
+
[
|
|
10668
|
+
claimNotificationLabels,
|
|
10669
|
+
externalClaimingKeys,
|
|
10670
|
+
internalClaimingIds,
|
|
10671
|
+
invalidateClaimUiState,
|
|
10672
|
+
onClaim,
|
|
10673
|
+
onClaimSubmitError,
|
|
10674
|
+
queryClient,
|
|
10675
|
+
redeemMutation,
|
|
10676
|
+
toastCtx
|
|
10677
|
+
]
|
|
10678
|
+
);
|
|
10679
|
+
const firedTerminalRef = (0, import_react12.useRef)({});
|
|
10680
|
+
(0, import_react12.useEffect)(() => {
|
|
10681
|
+
var _a, _b;
|
|
10682
|
+
for (const [claimKey, active] of Object.entries(activeRedeems)) {
|
|
10683
|
+
const state = lifecycleStates[active.redeemId];
|
|
10684
|
+
if (!state || !state.terminal) continue;
|
|
10685
|
+
if (firedTerminalRef.current[active.redeemId]) continue;
|
|
10686
|
+
firedTerminalRef.current[active.redeemId] = true;
|
|
10687
|
+
onClaimResult == null ? void 0 : onClaimResult(claimKey, {
|
|
10688
|
+
allConfirmed: state.allConfirmed,
|
|
10689
|
+
anyFailed: state.anyFailed,
|
|
10690
|
+
errorMessage: state.errorMessage
|
|
10691
|
+
});
|
|
10692
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
10693
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
10694
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
10695
|
+
if (state.allConfirmed) {
|
|
10696
|
+
if (!submittedClaimToastKeysRef.current.has(claimKey)) {
|
|
10697
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.successMessage, {
|
|
10698
|
+
title: claimNotificationLabels.successTitle,
|
|
10699
|
+
tone: "success"
|
|
10700
|
+
});
|
|
10701
|
+
}
|
|
10702
|
+
} else if (state.anyFailed) {
|
|
10703
|
+
const hasConfirmedLeg = Object.values(state.legs).some((leg) => leg.status === "confirmed");
|
|
10704
|
+
if (hasConfirmedLeg) {
|
|
10705
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.partialMessage((_a = state.errorMessage) != null ? _a : void 0), {
|
|
10706
|
+
title: claimNotificationLabels.partialTitle,
|
|
10707
|
+
tone: "warning"
|
|
10708
|
+
});
|
|
10709
|
+
} else {
|
|
10710
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage((_b = state.errorMessage) != null ? _b : void 0), {
|
|
10711
|
+
title: claimNotificationLabels.failedTitle,
|
|
10712
|
+
tone: "error"
|
|
10713
|
+
});
|
|
10714
|
+
}
|
|
10715
|
+
}
|
|
10716
|
+
submittedClaimToastKeysRef.current.delete(claimKey);
|
|
10717
|
+
invalidateClaimUiState();
|
|
10718
|
+
delete firedTerminalRef.current[active.redeemId];
|
|
10719
|
+
setActiveRedeems((prev) => {
|
|
10720
|
+
const _a2 = prev, { [claimKey]: _removed } = _a2, rest = __objRest(_a2, [__restKey(claimKey)]);
|
|
10721
|
+
return rest;
|
|
10722
|
+
});
|
|
10723
|
+
}
|
|
10724
|
+
}, [
|
|
10725
|
+
activeRedeems,
|
|
10726
|
+
claimNotificationLabels,
|
|
10727
|
+
invalidateClaimUiState,
|
|
10728
|
+
lifecycleStates,
|
|
10729
|
+
onClaimResult,
|
|
10730
|
+
toastCtx
|
|
10731
|
+
]);
|
|
10732
|
+
return { claim, claimingKeys, isClaiming };
|
|
10733
|
+
}
|
|
10734
|
+
|
|
10735
|
+
// src/trading/use-resolved-market-claim.ts
|
|
10736
|
+
var import_hooks33 = require("@agg-build/hooks");
|
|
10737
|
+
var import_react13 = require("react");
|
|
10738
|
+
var sharesFormatter = new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 });
|
|
10739
|
+
var dateFormatter = new Intl.DateTimeFormat("en-US", {
|
|
10740
|
+
month: "short",
|
|
10741
|
+
day: "numeric",
|
|
10742
|
+
year: "numeric"
|
|
10743
|
+
});
|
|
10744
|
+
var formatResolutionDate = (value) => {
|
|
10745
|
+
if (!value) return "";
|
|
10746
|
+
const date = new Date(value);
|
|
10747
|
+
if (Number.isNaN(date.getTime())) return "";
|
|
10748
|
+
return dateFormatter.format(date);
|
|
10749
|
+
};
|
|
10750
|
+
function useResolvedMarketClaim(options = {}) {
|
|
10751
|
+
var _a;
|
|
10752
|
+
const { market, enabled = true, executionMode } = options;
|
|
10753
|
+
const { isAuthenticated } = (0, import_hooks33.useAggAuthState)();
|
|
10754
|
+
const tradingState = (0, import_react13.useMemo)(() => (0, import_hooks33.resolveMarketTradingState)(market), [market]);
|
|
10755
|
+
const isResolved = tradingState.kind === "resolved";
|
|
10756
|
+
const marketId = (_a = market == null ? void 0 : market.id) != null ? _a : null;
|
|
10757
|
+
const shouldFetch = Boolean(enabled && isAuthenticated && isResolved && marketId);
|
|
10758
|
+
const { positions } = (0, import_hooks33.useExecutionPositions)(__spreadValues({
|
|
10759
|
+
enabled: shouldFetch,
|
|
10760
|
+
status: "active",
|
|
10761
|
+
limit: 50
|
|
10762
|
+
}, executionMode === "paper" ? { mode: "paper" } : {}));
|
|
10763
|
+
const claimWinnings = useClaimWinnings();
|
|
10764
|
+
return (0, import_react13.useMemo)(() => {
|
|
10765
|
+
var _a2, _b, _c;
|
|
10766
|
+
if (!shouldFetch || !marketId) return void 0;
|
|
10767
|
+
const group = positions.find(
|
|
10768
|
+
(candidate) => candidate.targetMarketId === marketId
|
|
10769
|
+
);
|
|
10770
|
+
if (!group || group.venueMarket.status !== "resolved") return void 0;
|
|
10771
|
+
const winningOutcomes = group.venueMarket.venueMarketOutcomes.filter(
|
|
10772
|
+
(outcome) => outcome.winner === true && outcome.totalSize > 0
|
|
10773
|
+
);
|
|
10774
|
+
if (winningOutcomes.length === 0) return void 0;
|
|
10775
|
+
const totals = (0, import_hooks33.computeClosedPositionTotals)(group);
|
|
10776
|
+
const winningShares = winningOutcomes.reduce((sum, outcome) => sum + outcome.totalSize, 0);
|
|
10777
|
+
const winningOutcomeLabel = ((_b = (_a2 = winningOutcomes[0]) == null ? void 0 : _a2.title) == null ? void 0 : _b.trim()) || ((_c = winningOutcomes[0]) == null ? void 0 : _c.label) || "";
|
|
10778
|
+
const claimKey = group.targetMarketId;
|
|
10779
|
+
const canClaim = group.redeemStatus === "eligible" && totals.winningOutcomeIds.length > 0;
|
|
10780
|
+
return {
|
|
10781
|
+
resolutionDateLabel: formatResolutionDate(group.resolutionDate),
|
|
10782
|
+
winningOutcomeLabel,
|
|
10783
|
+
sharesLabel: `${sharesFormatter.format(winningShares)} ${winningOutcomeLabel}`.trim(),
|
|
10784
|
+
// Payout is always shown with 2 decimals (e.g. "$8.50"), matching the
|
|
10785
|
+
// resolved-earnings design and the profile positions list.
|
|
10786
|
+
totalPayoutLabel: formatUsd(totals.amountWon, {
|
|
10787
|
+
minimumFractionDigits: 2,
|
|
10788
|
+
maximumFractionDigits: 2
|
|
10789
|
+
}),
|
|
10790
|
+
isClaiming: claimWinnings.isClaiming(claimKey),
|
|
10791
|
+
onClaim: canClaim ? () => {
|
|
10792
|
+
void claimWinnings.claim({
|
|
10793
|
+
claimKey,
|
|
10794
|
+
winningOutcomeIds: totals.winningOutcomeIds
|
|
10795
|
+
});
|
|
10796
|
+
} : void 0
|
|
10797
|
+
};
|
|
10798
|
+
}, [claimWinnings, marketId, positions, shouldFetch]);
|
|
10799
|
+
}
|
|
10225
10800
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10226
10801
|
0 && (module.exports = {
|
|
10227
10802
|
PlaceOrder,
|
|
@@ -10242,5 +10817,7 @@ var import_hooks30 = require("@agg-build/hooks");
|
|
|
10242
10817
|
getTradingVenueLabel,
|
|
10243
10818
|
parseAmount,
|
|
10244
10819
|
parseVenue,
|
|
10245
|
-
|
|
10820
|
+
useClaimWinnings,
|
|
10821
|
+
useEventTradingContext,
|
|
10822
|
+
useResolvedMarketClaim
|
|
10246
10823
|
});
|