@agg-build/ui 4.7.4 → 4.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/{chunk-2347CDTT.mjs → chunk-GG57TRNE.mjs} +393 -155
  2. package/dist/{chunk-CB3DDQBP.mjs → chunk-GKYBQEBC.mjs} +462 -171
  3. package/dist/{chunk-3X5ICUUC.mjs → chunk-GVIS3YXU.mjs} +2 -2
  4. package/dist/{chunk-XR6C3MZX.mjs → chunk-H7L4HDXS.mjs} +266 -162
  5. package/dist/{chunk-UQ7XJIAZ.mjs → chunk-NYL6A6AD.mjs} +953 -785
  6. package/dist/{chunk-MAQ52KM5.mjs → chunk-TNNLRRHC.mjs} +1 -1
  7. package/dist/{chunk-VQTOMYOA.mjs → chunk-XQLLZTEW.mjs} +296 -166
  8. package/dist/events.js +1195 -1041
  9. package/dist/events.mjs +3 -3
  10. package/dist/index.js +4726 -3772
  11. package/dist/index.mjs +58 -19
  12. package/dist/modals.js +1886 -1181
  13. package/dist/modals.mjs +12 -4
  14. package/dist/pages.js +3551 -2872
  15. package/dist/pages.mjs +6 -6
  16. package/dist/primitives.js +953 -785
  17. package/dist/primitives.mjs +1 -1
  18. package/dist/styles.css +1 -1
  19. package/dist/tailwind.css +1 -1
  20. package/dist/trading.js +2255 -1710
  21. package/dist/trading.mjs +10 -6
  22. package/dist/types/index.d.mts +1 -0
  23. package/dist/types/index.d.ts +1 -0
  24. package/dist/types/kyc/index.d.mts +3 -0
  25. package/dist/types/kyc/index.d.ts +3 -0
  26. package/dist/types/kyc/shared-kyc-modal.d.mts +12 -0
  27. package/dist/types/kyc/shared-kyc-modal.d.ts +12 -0
  28. package/dist/types/kyc/shared-kyc.d.mts +31 -0
  29. package/dist/types/kyc/shared-kyc.d.ts +31 -0
  30. package/dist/types/kyc/use-shared-kyc-flow.d.mts +19 -0
  31. package/dist/types/kyc/use-shared-kyc-flow.d.ts +19 -0
  32. package/dist/types/modals/index.d.mts +2 -0
  33. package/dist/types/modals/index.d.ts +2 -0
  34. package/dist/types/pages/event-market/event-market.shared.d.mts +2 -1
  35. package/dist/types/pages/event-market/event-market.shared.d.ts +2 -1
  36. package/dist/types/pages/event-market/event-market.types.d.mts +2 -0
  37. package/dist/types/pages/event-market/event-market.types.d.ts +2 -0
  38. package/dist/types/pages/event-market/sports-event-market-page.d.mts +1 -1
  39. package/dist/types/pages/event-market/sports-event-market-page.d.ts +1 -1
  40. package/dist/types/pages/user-profile/components/positions-value-card.d.mts +17 -1
  41. package/dist/types/pages/user-profile/components/positions-value-card.d.ts +17 -1
  42. package/dist/types/pages/user-profile/components/user-info-card.d.mts +11 -1
  43. package/dist/types/pages/user-profile/components/user-info-card.d.ts +11 -1
  44. package/dist/types/paper-trading/index.d.mts +6 -0
  45. package/dist/types/paper-trading/index.d.ts +6 -0
  46. package/dist/types/paper-trading/paper-onboarding-modal.d.mts +15 -0
  47. package/dist/types/paper-trading/paper-onboarding-modal.d.ts +15 -0
  48. package/dist/types/paper-trading/paper-onboarding-modal.types.d.mts +33 -0
  49. package/dist/types/paper-trading/paper-onboarding-modal.types.d.ts +33 -0
  50. package/dist/types/paper-trading/paper-trading-badge.d.mts +50 -0
  51. package/dist/types/paper-trading/paper-trading-badge.d.ts +50 -0
  52. package/dist/types/paper-trading/paper-trading-onboarding.d.mts +16 -0
  53. package/dist/types/paper-trading/paper-trading-onboarding.d.ts +16 -0
  54. package/dist/types/primitives/header/header.types.d.mts +16 -0
  55. package/dist/types/primitives/header/header.types.d.ts +16 -0
  56. package/dist/types/primitives/header/index.d.mts +1 -1
  57. package/dist/types/primitives/header/index.d.ts +1 -1
  58. package/dist/types/primitives/icon/registry.d.mts +20 -0
  59. package/dist/types/primitives/icon/registry.d.ts +20 -0
  60. package/dist/types/primitives/icon/svg/paper-buying-power.d.mts +11 -0
  61. package/dist/types/primitives/icon/svg/paper-buying-power.d.ts +11 -0
  62. package/dist/types/primitives/icon/svg/paper-earnings.d.mts +11 -0
  63. package/dist/types/primitives/icon/svg/paper-earnings.d.ts +11 -0
  64. package/dist/types/primitives/icon/svg/paper-onboarding-funds.d.mts +12 -0
  65. package/dist/types/primitives/icon/svg/paper-onboarding-funds.d.ts +12 -0
  66. package/dist/types/primitives/icon/svg/paper-onboarding-markets.d.mts +12 -0
  67. package/dist/types/primitives/icon/svg/paper-onboarding-markets.d.ts +12 -0
  68. package/dist/types/primitives/icon/svg/paper-onboarding-performance.d.mts +12 -0
  69. package/dist/types/primitives/icon/svg/paper-onboarding-performance.d.ts +12 -0
  70. package/dist/types/primitives/modal/modal.types.d.mts +6 -0
  71. package/dist/types/primitives/modal/modal.types.d.ts +6 -0
  72. package/dist/types/trading/index.d.mts +1 -0
  73. package/dist/types/trading/index.d.ts +1 -0
  74. package/dist/types/trading/place-order/index.d.mts +1 -1
  75. package/dist/types/trading/place-order/index.d.ts +1 -1
  76. package/dist/types/trading/place-order/index.place-order.types.d.mts +8 -0
  77. package/dist/types/trading/place-order/index.place-order.types.d.ts +8 -0
  78. package/dist/types/trading/types.d.mts +2 -0
  79. package/dist/types/trading/types.d.ts +2 -0
  80. package/package.json +3 -3
@@ -9,12 +9,13 @@ import {
9
9
  getTradingVenueLabel,
10
10
  prepareSettlementDifferences,
11
11
  resolveOrderEligibilityMessage
12
- } from "./chunk-MAQ52KM5.mjs";
12
+ } from "./chunk-TNNLRRHC.mjs";
13
13
  import {
14
14
  ConnectKalshiModal,
15
15
  GeoBlockBanner,
16
+ SharedKycModal,
16
17
  subscribeAggDepositNotification
17
- } from "./chunk-XR6C3MZX.mjs";
18
+ } from "./chunk-H7L4HDXS.mjs";
18
19
  import {
19
20
  AGG_TERMS_OF_SERVICE_URL,
20
21
  Button,
@@ -47,7 +48,7 @@ import {
47
48
  resolveResolvedOutcomeLabel,
48
49
  skeletonViews,
49
50
  useOptionalToast
50
- } from "./chunk-UQ7XJIAZ.mjs";
51
+ } from "./chunk-NYL6A6AD.mjs";
51
52
 
52
53
  // src/trading/types.ts
53
54
  import { Venue, enumGuard, isFiniteNonNeg, safeParse } from "@agg-build/sdk";
@@ -158,19 +159,221 @@ import {
158
159
  useSdkUiConfig,
159
160
  useSmartRoute,
160
161
  useVenueKeyStatus,
161
- useVenueSellQuotes
162
+ useVenueSellQuotes,
163
+ useResolvedExecutionMode
162
164
  } from "@agg-build/hooks";
163
165
  import {
164
166
  adjustLimitPriceRawToTick,
165
167
  LIMIT_PRICE_RAW_SCALE as LIMIT_ORDER_RAW_SCALE,
166
- Venue as Venue3
168
+ Venue as Venue4
167
169
  } from "@agg-build/sdk";
168
170
  import NumberFlow from "@number-flow/react";
169
171
  import * as Popover from "@radix-ui/react-popover";
170
172
  import dayjs from "dayjs";
171
173
  import timezone from "dayjs/plugin/timezone";
172
174
  import utc from "dayjs/plugin/utc";
173
- import { Fragment as Fragment2, useCallback as useCallback2, useEffect as useEffect2, useId, useMemo, useRef as useRef2, useState } from "react";
175
+ import { Fragment as Fragment2, useCallback as useCallback3, useEffect as useEffect3, useId, useMemo, useRef as useRef3, useState as useState2 } from "react";
176
+
177
+ // src/kyc/shared-kyc.ts
178
+ import { Venue as Venue2 } from "@agg-build/sdk";
179
+ var TEMPORARY_SHARED_KYC_VENUES = /* @__PURE__ */ new Set([Venue2.novig, Venue2.prophetx]);
180
+ var venueRequiresSharedKyc = ({
181
+ venue,
182
+ requiresKyc
183
+ }) => {
184
+ if (requiresKyc != null) return requiresKyc;
185
+ if (!venue) return false;
186
+ return TEMPORARY_SHARED_KYC_VENUES.has(venue.trim().toLowerCase());
187
+ };
188
+ var createAggClientSharedKycInitiator = (client) => {
189
+ return ({ venue, redirectUri }) => client.initiateKyc(venue, redirectUri);
190
+ };
191
+
192
+ // src/kyc/use-shared-kyc-flow.ts
193
+ import { useCallback, useEffect, useRef, useState } from "react";
194
+ var SHARED_KYC_PENDING_STORAGE_KEY = "agg_shared_kyc_pending";
195
+ var KYC_RETURN_VENUE_PARAM = "venue";
196
+ var KYC_RETURN_STATUS_PARAM = "kyc_status";
197
+ var readPendingState = () => {
198
+ var _a;
199
+ if (typeof window === "undefined") return null;
200
+ const rawValue = window.sessionStorage.getItem(SHARED_KYC_PENDING_STORAGE_KEY);
201
+ if (!rawValue) return null;
202
+ try {
203
+ const parsed = JSON.parse(rawValue);
204
+ if (!parsed.venue) return null;
205
+ return { venue: parsed.venue, userId: (_a = parsed.userId) != null ? _a : null };
206
+ } catch (e) {
207
+ return null;
208
+ }
209
+ };
210
+ var clearPendingState = () => {
211
+ if (typeof window === "undefined") return;
212
+ window.sessionStorage.removeItem(SHARED_KYC_PENDING_STORAGE_KEY);
213
+ };
214
+ var cleanReturnUrl = () => {
215
+ const url = new URL(window.location.href);
216
+ url.searchParams.delete(KYC_RETURN_VENUE_PARAM);
217
+ url.searchParams.delete(KYC_RETURN_STATUS_PARAM);
218
+ window.history.replaceState(null, "", `${url.pathname}${url.search}${url.hash}`);
219
+ };
220
+ var useSharedKycFlow = ({
221
+ integration,
222
+ userId,
223
+ fallbackErrorMessage
224
+ }) => {
225
+ const [activeVenue, setActiveVenue] = useState(null);
226
+ const [errorMessage, setErrorMessage] = useState();
227
+ const [isModalOpen, setIsModalOpen] = useState(false);
228
+ const [modalState, setModalState] = useState("initial");
229
+ const returnRequestRef = useRef(null);
230
+ const ownerId = userId != null ? userId : null;
231
+ const currentUserRef = useRef(ownerId);
232
+ currentUserRef.current = ownerId;
233
+ const modalOwnerRef = useRef(ownerId);
234
+ const inFlightRef = useRef(null);
235
+ const integrationRef = useRef(integration);
236
+ integrationRef.current = integration;
237
+ const fallbackRef = useRef(fallbackErrorMessage);
238
+ fallbackRef.current = fallbackErrorMessage;
239
+ const integrationEnabled = integration !== void 0;
240
+ useEffect(
241
+ () => () => {
242
+ var _a, _b;
243
+ if (((_a = inFlightRef.current) == null ? void 0 : _a.ownerId) === ownerId) inFlightRef.current = null;
244
+ if (currentUserRef.current !== ownerId) {
245
+ if (((_b = returnRequestRef.current) == null ? void 0 : _b.ownerId) === ownerId) returnRequestRef.current = null;
246
+ if (modalOwnerRef.current === ownerId) modalOwnerRef.current = void 0;
247
+ }
248
+ },
249
+ [ownerId]
250
+ );
251
+ const closeModal = useCallback(() => {
252
+ if (modalState === "initiating") return;
253
+ setIsModalOpen(false);
254
+ setErrorMessage(void 0);
255
+ if (modalState !== "success") setModalState("initial");
256
+ }, [modalState]);
257
+ const openForVenue = useCallback(
258
+ (venue) => {
259
+ if ((integration == null ? void 0 : integration.status) === "verified") return;
260
+ modalOwnerRef.current = ownerId;
261
+ setActiveVenue(venue);
262
+ setErrorMessage(void 0);
263
+ setModalState("initial");
264
+ setIsModalOpen(true);
265
+ },
266
+ [integration == null ? void 0 : integration.status, ownerId]
267
+ );
268
+ const startVerification = useCallback(() => __async(null, null, function* () {
269
+ var _a, _b, _c;
270
+ if (!activeVenue || !integration || integration.status === "verified") return;
271
+ if (modalOwnerRef.current !== ownerId || ((_a = inFlightRef.current) == null ? void 0 : _a.ownerId) === ownerId) return;
272
+ const token = /* @__PURE__ */ Symbol("kyc-initiation");
273
+ inFlightRef.current = { ownerId, token };
274
+ const isCurrent = () => {
275
+ var _a2;
276
+ return currentUserRef.current === ownerId && ((_a2 = inFlightRef.current) == null ? void 0 : _a2.token) === token;
277
+ };
278
+ setErrorMessage(void 0);
279
+ setModalState("initiating");
280
+ try {
281
+ if (modalState === "pending") {
282
+ const status = yield integration.refreshStatus();
283
+ if (!isCurrent()) return;
284
+ setModalState(status === "verified" ? "success" : "pending");
285
+ return;
286
+ }
287
+ const redirectUri = window.location.href;
288
+ const result = yield integration.initiateVerification({ venue: activeVenue, redirectUri });
289
+ if (!isCurrent()) return;
290
+ if (!result.kycUrl) {
291
+ const status = yield integration.refreshStatus();
292
+ if (!isCurrent()) return;
293
+ if (status === "verified") {
294
+ clearPendingState();
295
+ setModalState("success");
296
+ return;
297
+ }
298
+ throw new Error(fallbackErrorMessage);
299
+ }
300
+ window.sessionStorage.setItem(
301
+ SHARED_KYC_PENDING_STORAGE_KEY,
302
+ JSON.stringify({ venue: activeVenue, userId: userId != null ? userId : null })
303
+ );
304
+ ((_b = integration.navigate) != null ? _b : window.location.assign.bind(window.location))(result.kycUrl);
305
+ } catch (error) {
306
+ if (!isCurrent()) return;
307
+ clearPendingState();
308
+ setErrorMessage(
309
+ error instanceof Error && error.message ? error.message : fallbackErrorMessage
310
+ );
311
+ setModalState(modalState === "pending" ? "pending" : "error");
312
+ } finally {
313
+ if (((_c = inFlightRef.current) == null ? void 0 : _c.token) === token) inFlightRef.current = null;
314
+ }
315
+ }), [activeVenue, fallbackErrorMessage, integration, modalState, userId, ownerId]);
316
+ useEffect(() => {
317
+ const activeIntegration = integrationRef.current;
318
+ if (!activeIntegration || typeof window === "undefined") return;
319
+ const pendingState = readPendingState();
320
+ if (!pendingState || pendingState.userId !== ownerId) return;
321
+ const url = new URL(window.location.href);
322
+ if (url.searchParams.get(KYC_RETURN_VENUE_PARAM) !== pendingState.venue || !url.searchParams.has(KYC_RETURN_STATUS_PARAM)) {
323
+ return;
324
+ }
325
+ if (!returnRequestRef.current || returnRequestRef.current.ownerId !== ownerId || returnRequestRef.current.venue !== pendingState.venue) {
326
+ returnRequestRef.current = {
327
+ ownerId,
328
+ venue: pendingState.venue,
329
+ promise: Promise.resolve().then(() => activeIntegration.refreshStatus())
330
+ };
331
+ }
332
+ const statusRequest = returnRequestRef.current.promise;
333
+ modalOwnerRef.current = ownerId;
334
+ setActiveVenue(pendingState.venue);
335
+ setIsModalOpen(true);
336
+ setModalState("initiating");
337
+ let cancelled = false;
338
+ const isCurrent = () => !cancelled && currentUserRef.current === ownerId;
339
+ const refreshStatus = () => __async(null, null, function* () {
340
+ try {
341
+ const status = yield statusRequest;
342
+ if (!isCurrent()) return;
343
+ if (status === "verified") {
344
+ setModalState("success");
345
+ } else {
346
+ setModalState("pending");
347
+ }
348
+ } catch (error) {
349
+ if (!isCurrent()) return;
350
+ setErrorMessage(
351
+ error instanceof Error && error.message ? error.message : fallbackRef.current
352
+ );
353
+ setModalState("error");
354
+ } finally {
355
+ if (isCurrent()) {
356
+ clearPendingState();
357
+ cleanReturnUrl();
358
+ }
359
+ }
360
+ });
361
+ void refreshStatus();
362
+ return () => {
363
+ cancelled = true;
364
+ };
365
+ }, [integrationEnabled, ownerId]);
366
+ const isCurrentModalOpen = isModalOpen && modalOwnerRef.current === ownerId;
367
+ return {
368
+ activeVenue: modalOwnerRef.current === ownerId ? activeVenue : null,
369
+ errorMessage: modalOwnerRef.current === ownerId ? errorMessage : void 0,
370
+ isModalOpen: isCurrentModalOpen,
371
+ modalState: modalOwnerRef.current !== ownerId ? "initial" : isCurrentModalOpen && (integration == null ? void 0 : integration.status) === "verified" ? "success" : modalState,
372
+ closeModal,
373
+ openForVenue,
374
+ startVerification
375
+ };
376
+ };
174
377
 
175
378
  // src/notifications/agg-notification-events-provider.tsx
176
379
  import {
@@ -182,7 +385,7 @@ import {
182
385
  useOptionalAggClient,
183
386
  useUserActivity
184
387
  } from "@agg-build/hooks";
185
- import { useCallback, useEffect, useRef } from "react";
388
+ import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2 } from "react";
186
389
  import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
187
390
  function AggNotificationEventsProvider({
188
391
  children,
@@ -271,12 +474,12 @@ function AggNotificationEventsBridge({ enabled, depositActivityLimit }) {
271
474
  const notificationsFeatureEnabled = features.enableNotifications !== false;
272
475
  const effectivelyEnabled = enabled && notificationsFeatureEnabled;
273
476
  const currentUserId = (_a = user == null ? void 0 : user.id) != null ? _a : null;
274
- const firedKeysRef = useRef(/* @__PURE__ */ new Set());
275
- const depositStatusesRef = useRef(/* @__PURE__ */ new Map());
276
- const hasSeededDepositStatusesRef = useRef(false);
277
- const recentClientDepositFingerprintsRef = useRef(/* @__PURE__ */ new Map());
278
- const lastUserIdRef = useRef("uninitialized");
279
- useEffect(() => {
477
+ const firedKeysRef = useRef2(/* @__PURE__ */ new Set());
478
+ const depositStatusesRef = useRef2(/* @__PURE__ */ new Map());
479
+ const hasSeededDepositStatusesRef = useRef2(false);
480
+ const recentClientDepositFingerprintsRef = useRef2(/* @__PURE__ */ new Map());
481
+ const lastUserIdRef = useRef2("uninitialized");
482
+ useEffect2(() => {
280
483
  if (lastUserIdRef.current === currentUserId) return;
281
484
  lastUserIdRef.current = currentUserId;
282
485
  firedKeysRef.current = /* @__PURE__ */ new Set();
@@ -285,7 +488,7 @@ function AggNotificationEventsBridge({ enabled, depositActivityLimit }) {
285
488
  hasSeededDepositStatusesRef.current = false;
286
489
  recentClientDepositFingerprintsRef.current = /* @__PURE__ */ new Map();
287
490
  }, [currentUserId]);
288
- const fireOnce = useCallback(
491
+ const fireOnce = useCallback2(
289
492
  (key, tone, title, message, detail) => {
290
493
  if (!effectivelyEnabled) return;
291
494
  const toast = toastCtx == null ? void 0 : toastCtx.toast;
@@ -296,7 +499,7 @@ function AggNotificationEventsBridge({ enabled, depositActivityLimit }) {
296
499
  },
297
500
  [effectivelyEnabled, toastCtx]
298
501
  );
299
- const orderEventCallback = useCallback(
502
+ const orderEventCallback = useCallback2(
300
503
  (event) => {
301
504
  if (!effectivelyEnabled || !isAuthenticated) return;
302
505
  if (!currentUserId || event.userId !== currentUserId) return;
@@ -306,7 +509,7 @@ function AggNotificationEventsBridge({ enabled, depositActivityLimit }) {
306
509
  [currentUserId, effectivelyEnabled, fireOnce, isAuthenticated, labels]
307
510
  );
308
511
  useOnOrderEvent(orderEventCallback);
309
- const withdrawalCallback = useCallback(
512
+ const withdrawalCallback = useCallback2(
310
513
  (event) => {
311
514
  if (!effectivelyEnabled || !isAuthenticated) return;
312
515
  if (!currentUserId || event.userId !== currentUserId) return;
@@ -317,7 +520,7 @@ function AggNotificationEventsBridge({ enabled, depositActivityLimit }) {
317
520
  [currentUserId, effectivelyEnabled, fireOnce, isAuthenticated, labels]
318
521
  );
319
522
  useOnWithdrawalLifecycle(withdrawalCallback);
320
- useEffect(() => {
523
+ useEffect2(() => {
321
524
  if (!effectivelyEnabled || !isAuthenticated || !currentUserId) return;
322
525
  return subscribeAggDepositNotification((event) => {
323
526
  handleClientDepositNotification({
@@ -334,7 +537,7 @@ function AggNotificationEventsBridge({ enabled, depositActivityLimit }) {
334
537
  enabled: effectivelyEnabled && isAuthenticated && currentUserId !== null
335
538
  });
336
539
  const depositActivities = depositActivity.activities;
337
- useEffect(() => {
540
+ useEffect2(() => {
338
541
  if (!effectivelyEnabled || !isAuthenticated || !currentUserId) return;
339
542
  if (!depositActivity.isSuccess) return;
340
543
  handleDepositActivities({
@@ -541,7 +744,7 @@ var requestAggWithdrawModalOpen = () => {
541
744
 
542
745
  // src/trading/fund-kalshi-modal.tsx
543
746
  import { useLabels } from "@agg-build/hooks";
544
- import { Venue as Venue2 } from "@agg-build/sdk";
747
+ import { Venue as Venue3 } from "@agg-build/sdk";
545
748
  import * as Dialog from "@radix-ui/react-dialog";
546
749
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
547
750
  var FundKalshiModal = ({ open, onOpenChange }) => {
@@ -563,7 +766,7 @@ var FundKalshiModal = ({ open, onOpenChange }) => {
563
766
  }
564
767
  ),
565
768
  /* @__PURE__ */ jsx3(Modal.Body, { classNames: { root: "!px-5 !py-12 sm:!px-10" }, children: /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center gap-8 text-center", children: [
566
- /* @__PURE__ */ jsx3(VenueLogo, { venue: Venue2.kalshi, variant: "logo", size: "large", className: "size-[60px]" }),
769
+ /* @__PURE__ */ jsx3(VenueLogo, { venue: Venue3.kalshi, variant: "logo", size: "large", className: "size-[60px]" }),
567
770
  /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center gap-4", children: [
568
771
  /* @__PURE__ */ jsx3(Dialog.Title, { className: "text-agg-2xl font-agg-bold leading-agg-8 text-agg-foreground", children: modalLabels.title }),
569
772
  /* @__PURE__ */ jsx3(Dialog.Description, { className: "max-w-[520px] text-agg-base leading-agg-6 text-agg-foreground", children: modalLabels.description })
@@ -1162,16 +1365,18 @@ var mapQuoteDataToRoutingRows = (quoteData, tradeSide = "buy") => {
1162
1365
  amount: fill.venueQty * fill.avgPrice
1163
1366
  }, tradeSide === "sell" ? { minimumFractionDigits: 2, maximumFractionDigits: 2 } : {}));
1164
1367
  const allocationSharesLabel = `${formatFlooredShareAmount(fill.venueQty, 2)} shares`;
1165
- return {
1368
+ const requiresSharedKyc = venueRequiresSharedKyc({ venue: fill.venue });
1369
+ return __spreadProps(__spreadValues({
1166
1370
  venue: fill.venue,
1167
1371
  label: tradeSide === "sell" ? allocationSharesLabel : allocationValueLabel,
1168
- priceLabel: getTradingRoutePriceLabel(fill.avgPrice),
1372
+ priceLabel: getTradingRoutePriceLabel(fill.avgPrice)
1373
+ }, requiresSharedKyc ? { requiresSharedKyc: true } : {}), {
1169
1374
  resultLabel: tradeSide === "sell" ? allocationValueLabel : getTradingValueLabel({
1170
1375
  amount: fill.venueQty,
1171
1376
  minimumFractionDigits: 2,
1172
1377
  maximumFractionDigits: 2
1173
1378
  })
1174
- };
1379
+ });
1175
1380
  });
1176
1381
  };
1177
1382
  var deriveAggregateOrderStatus = (orderIds, terminalEvents) => {
@@ -1329,6 +1534,9 @@ var buildLiveRouteCards = ({
1329
1534
  const primaryVenue = (_a = quoteData.fills[0]) == null ? void 0 : _a.venue;
1330
1535
  const parsedPrimaryVenue = parseVenue(primaryVenue);
1331
1536
  const isSplit = quoteData.fills.length > 1;
1537
+ const primaryRequiresSharedKyc = quoteData.fills.some(
1538
+ (fill) => venueRequiresSharedKyc({ venue: fill.venue })
1539
+ );
1332
1540
  const averageExecutionPrice = (_b = getPlaceOrderAverageExecutionPrice(quoteData)) != null ? _b : void 0;
1333
1541
  const primaryWinnerVenue = quoteData.fills.length === 1 ? primaryVenue : void 0;
1334
1542
  const isPrimaryRouteGeoBlocked = quoteData.fills.length > 0 && quoteData.fills.some((f) => geoBlockedVenues.has(f.venue));
@@ -1344,6 +1552,7 @@ var buildLiveRouteCards = ({
1344
1552
  quoteData,
1345
1553
  value: primaryResult.value,
1346
1554
  venue: parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0,
1555
+ requiresSharedKyc: primaryRequiresSharedKyc,
1347
1556
  isUnavailable: true
1348
1557
  } : {
1349
1558
  id: "live-route",
@@ -1358,10 +1567,11 @@ var buildLiveRouteCards = ({
1358
1567
  description: labels.splitOrderDescription,
1359
1568
  value: primaryResult.value,
1360
1569
  venue: isSplit ? void 0 : parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0,
1361
- executionPrice: averageExecutionPrice
1570
+ executionPrice: averageExecutionPrice,
1571
+ requiresSharedKyc: primaryRequiresSharedKyc
1362
1572
  } : null;
1363
1573
  const soloCards = ((_c = quoteData.venueSoloQuotes) != null ? _c : []).filter(
1364
- (sq) => sq.status === "ok" && sq.avgPrice !== null && sq.filledQty > 0 && // No `sq.quoteId` requirement: a solo is preview-only whenever its own
1574
+ (sq) => sq.status === "ok" && sq.unavailableReason !== "venue_unavailable" && sq.avgPrice !== null && sq.filledQty > 0 && // No `sq.quoteId` requirement: a solo is preview-only whenever its own
1365
1575
  // funding lane is short (API nulls the quoteId), which is NOT always the
1366
1576
  // whole-quote `insufficient_balance` case — an off-chain winner (Kalshi
1367
1577
  // settles from venue cash) keeps the quote `ok` while the on-chain solo
@@ -1387,6 +1597,7 @@ var buildLiveRouteCards = ({
1387
1597
  maximumFractionDigits: 2
1388
1598
  }),
1389
1599
  venue,
1600
+ requiresSharedKyc: venueRequiresSharedKyc({ venue: sq.venue }),
1390
1601
  isUnavailable: true
1391
1602
  };
1392
1603
  }
@@ -1423,23 +1634,32 @@ var buildLiveRouteCards = ({
1423
1634
  minimumFractionDigits: 2,
1424
1635
  maximumFractionDigits: 2
1425
1636
  }),
1426
- venue
1637
+ venue,
1638
+ requiresSharedKyc: venueRequiresSharedKyc({ venue: sq.venue })
1427
1639
  };
1428
1640
  });
1429
- const unavailableCards = ((_d = quoteData.venueSoloQuotes) != null ? _d : []).filter((sq) => sq.status === "unavailable").map((sq) => {
1641
+ const unavailableCards = ((_d = quoteData.venueSoloQuotes) != null ? _d : []).filter((sq) => sq.status === "unavailable" || sq.unavailableReason === "venue_unavailable").map((sq) => {
1430
1642
  const parsedVenue = parseVenue(sq.venue);
1431
1643
  const venue = parsedVenue.success ? parsedVenue.data : void 0;
1432
- return {
1644
+ const temporarilyUnavailable = sq.unavailableReason === "venue_unavailable";
1645
+ const hasPreview = temporarilyUnavailable && sq.filledQty > 0;
1646
+ return __spreadProps(__spreadValues({
1433
1647
  id: `live-unavailable-${sq.venue}`,
1434
- hint: labels.venueUnavailableInRegion,
1648
+ hint: temporarilyUnavailable ? labels.venueTemporarilyUnavailable : labels.venueUnavailableInRegion,
1435
1649
  kind: "venue",
1436
1650
  label: getTradingVenueLabel(venue),
1437
- numericValue: 0,
1438
- quoteData,
1439
- value: "",
1651
+ numericValue: hasPreview ? sq.filledQty : 0,
1652
+ quoteData: __spreadProps(__spreadValues({}, quoteData), { quoteId: "" }),
1653
+ value: hasPreview ? getTradingValueLabel({
1654
+ amount: sq.filledQty,
1655
+ minimumFractionDigits: 2,
1656
+ maximumFractionDigits: 2
1657
+ }) : ""
1658
+ }, hasPreview && isFiniteNonNegativePrice(sq.avgPrice) ? { executionPrice: sq.avgPrice } : {}), {
1440
1659
  venue,
1660
+ requiresSharedKyc: venueRequiresSharedKyc({ venue: sq.venue }),
1441
1661
  isUnavailable: true
1442
- };
1662
+ });
1443
1663
  });
1444
1664
  const baseCards = (primaryCard ? [primaryCard, ...soloCards] : soloCards).sort(
1445
1665
  (left, right) => right.numericValue - left.numericValue
@@ -3482,24 +3702,24 @@ var PlaceOrderSlippageControl = ({
3482
3702
  }) => {
3483
3703
  var _a, _b;
3484
3704
  const labels = useLabels2();
3485
- const containerRef = useRef2(null);
3486
- const triggerRef = useRef2(null);
3487
- const inputRef = useRef2(null);
3705
+ const containerRef = useRef3(null);
3706
+ const triggerRef = useRef3(null);
3707
+ const inputRef = useRef3(null);
3488
3708
  const warningId = useId();
3489
3709
  const defaultValue = finalizePercentageValue(slippageDefaultValue);
3490
3710
  const committedValue = finalizePercentageValue(slippageValue) || defaultValue;
3491
- const [draftValue, setDraftValue] = useState(committedValue);
3492
- const [isEditing, setIsEditing] = useState(
3711
+ const [draftValue, setDraftValue] = useState2(committedValue);
3712
+ const [isEditing, setIsEditing] = useState2(
3493
3713
  () => isPercentageBelowMinimum(committedValue, slippageMinimumValue)
3494
3714
  );
3495
- const [shouldFocusInput, setShouldFocusInput] = useState(false);
3496
- useEffect2(() => {
3715
+ const [shouldFocusInput, setShouldFocusInput] = useState2(false);
3716
+ useEffect3(() => {
3497
3717
  setDraftValue(committedValue);
3498
3718
  if (isPercentageBelowMinimum(committedValue, slippageMinimumValue)) {
3499
3719
  setIsEditing(true);
3500
3720
  }
3501
3721
  }, [committedValue, slippageMinimumValue]);
3502
- useEffect2(() => {
3722
+ useEffect3(() => {
3503
3723
  if (!shouldFocusInput) return;
3504
3724
  requestAnimationFrame(() => {
3505
3725
  var _a2, _b2;
@@ -3881,10 +4101,11 @@ var PlaceOrderResolvedView = ({
3881
4101
  }
3882
4102
  );
3883
4103
  };
3884
- var renderRouteBreakdownRow = (row) => {
4104
+ var renderRouteBreakdownRow = (row, sharedKycStatus, tradingLabels) => {
3885
4105
  var _a, _b;
3886
4106
  const venueLabel = getTradingVenueLabel(row.venue);
3887
4107
  const rowKey = `${row.venue}-${row.label}-${row.priceLabel}-${(_a = row.resultLabel) != null ? _a : ""}`;
4108
+ const showSharedKycRequirement = row.requiresSharedKyc === true && sharedKycStatus !== void 0 && sharedKycStatus !== "verified";
3888
4109
  return /* @__PURE__ */ jsxs6(
3889
4110
  "div",
3890
4111
  {
@@ -3892,7 +4113,10 @@ var renderRouteBreakdownRow = (row) => {
3892
4113
  children: [
3893
4114
  /* @__PURE__ */ jsxs6("div", { className: "agg-route-breakdown-market flex min-w-0 items-center gap-2", children: [
3894
4115
  /* @__PURE__ */ jsx7(VenueLogo, { venue: row.venue, className: "size-3!", ariaLabel: venueLabel }),
3895
- /* @__PURE__ */ jsx7("p", { className: "agg-route-breakdown-label truncate text-agg-sm leading-agg-5 text-agg-foreground", children: row.label })
4116
+ /* @__PURE__ */ jsxs6("div", { className: "flex min-w-0 flex-col", children: [
4117
+ /* @__PURE__ */ jsx7("p", { className: "agg-route-breakdown-label truncate text-agg-sm leading-agg-5 text-agg-foreground", children: row.label }),
4118
+ showSharedKycRequirement ? /* @__PURE__ */ jsx7("p", { className: "text-agg-xs leading-agg-4 text-agg-muted-foreground", children: tradingLabels.sharedKyc.required }) : null
4119
+ ] })
3896
4120
  ] }),
3897
4121
  /* @__PURE__ */ jsxs6("div", { className: "agg-route-breakdown-value flex shrink-0 items-center gap-2 text-agg-sm leading-agg-5", children: [
3898
4122
  /* @__PURE__ */ jsx7("p", { className: "text-agg-muted-foreground", children: row.priceLabel }),
@@ -3919,11 +4143,14 @@ var renderRouteCard = ({
3919
4143
  isExpanded,
3920
4144
  isSelected,
3921
4145
  onSelect,
4146
+ sharedKycStatus,
3922
4147
  tradingLabels
3923
4148
  }) => {
3924
4149
  var _a, _b, _c;
4150
+ const showSharedKycRequirement = card.requiresSharedKyc === true && sharedKycStatus !== void 0 && sharedKycStatus !== "verified" && !card.isUnavailable;
3925
4151
  const showSplitDetails = isSelected && isExpanded && card.kind === "split" && !!((_a = card.rows) == null ? void 0 : _a.length);
3926
- const ariaLabel = [card.label, card.hint, card.value].filter(Boolean).join(" ");
4152
+ const displayedHint = showSharedKycRequirement ? tradingLabels.sharedKyc.required : card.hint;
4153
+ const ariaLabel = [card.label, displayedHint, card.value].filter(Boolean).join(" ");
3927
4154
  return /* @__PURE__ */ jsx7(
3928
4155
  "button",
3929
4156
  {
@@ -3976,7 +4203,7 @@ var renderRouteCard = ({
3976
4203
  className: "shrink-0 text-agg-muted-foreground",
3977
4204
  "aria-hidden": "true"
3978
4205
  }
3979
- ) : card.insufficientInventory ? /* @__PURE__ */ jsx7(
4206
+ ) : showSharedKycRequirement || card.insufficientInventory ? /* @__PURE__ */ jsx7(
3980
4207
  Icon,
3981
4208
  {
3982
4209
  name: "warning",
@@ -3994,7 +4221,7 @@ var renderRouteCard = ({
3994
4221
  }
3995
4222
  ) : null
3996
4223
  ] }),
3997
- card.hint ? /* @__PURE__ */ jsx7("p", { className: "agg-route-card-hint text-agg-xs leading-agg-4 text-agg-muted-foreground", children: card.hint }) : null
4224
+ card.hint ? /* @__PURE__ */ jsx7("p", { className: "agg-route-card-hint text-agg-xs leading-agg-4 text-agg-muted-foreground", children: displayedHint }) : null
3998
4225
  ] })
3999
4226
  ] }),
4000
4227
  /* @__PURE__ */ jsx7(
@@ -4011,7 +4238,9 @@ var renderRouteCard = ({
4011
4238
  ] }),
4012
4239
  showSplitDetails ? /* @__PURE__ */ jsxs6(Fragment3, { children: [
4013
4240
  /* @__PURE__ */ jsx7("p", { className: "agg-route-card-description text-agg-xs leading-agg-4 text-agg-foreground", children: (_b = card.description) != null ? _b : tradingLabels.splitOrderDescription }),
4014
- /* @__PURE__ */ jsx7("div", { className: "agg-route-breakdown flex flex-col gap-3", children: (_c = card.rows) == null ? void 0 : _c.map((row) => renderRouteBreakdownRow(row)) })
4241
+ /* @__PURE__ */ jsx7("div", { className: "agg-route-breakdown flex flex-col gap-3", children: (_c = card.rows) == null ? void 0 : _c.map(
4242
+ (row) => renderRouteBreakdownRow(row, sharedKycStatus, tradingLabels)
4243
+ ) })
4015
4244
  ] }) : null
4016
4245
  ] })
4017
4246
  }
@@ -4030,6 +4259,7 @@ var PlaceOrder = ({
4030
4259
  onAmountChange,
4031
4260
  onClose,
4032
4261
  onConnectKalshi,
4262
+ sharedKyc,
4033
4263
  onOutcomeChange,
4034
4264
  onPrimaryAction,
4035
4265
  onBeforePrimaryAction,
@@ -4041,13 +4271,12 @@ var PlaceOrder = ({
4041
4271
  showResolvingState = false,
4042
4272
  midpointsResult
4043
4273
  }) => {
4044
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha;
4274
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca;
4045
4275
  const {
4046
4276
  enableDebug: isExecutionDebugEnabled,
4047
- features: { enableAnimations, showFeesBreakdown, showLimitOrders },
4277
+ features: { enableAnimations, showFeesBreakdown, showLimitOrders: limitOrdersFeature },
4048
4278
  formatting: { formatPrice },
4049
- general: { locale },
4050
- trading: { executionMode: configuredExecutionMode = "live" } = { executionMode: "live" }
4279
+ general: { locale }
4051
4280
  } = useSdkUiConfig();
4052
4281
  const labels = useLabels2();
4053
4282
  const tradingLabels = labels.trading;
@@ -4114,8 +4343,13 @@ var PlaceOrder = ({
4114
4343
  );
4115
4344
  const isResolvedOutcomeCtaLocked = resolvedEventTradingState.kind === "resolved" || resolvedTradingState.kind === "resolved";
4116
4345
  const { isAuthenticated, user } = useAggAuthContext();
4117
- const resolvedExecutionMode = executionMode != null ? executionMode : configuredExecutionMode;
4118
- const isPaperMode = resolvedExecutionMode === "paper";
4346
+ const sharedKycFlow = useSharedKycFlow({
4347
+ integration: sharedKyc,
4348
+ userId: isAuthenticated ? user == null ? void 0 : user.id : null,
4349
+ fallbackErrorMessage: tradingLabels.sharedKyc.modal.error
4350
+ });
4351
+ const { executionMode: resolvedExecutionMode, isPaperMode } = useResolvedExecutionMode(executionMode);
4352
+ const showLimitOrders = limitOrdersFeature && !isPaperMode;
4119
4353
  const liveBalanceState = useAggBalanceState();
4120
4354
  const paperBalancesQuery = useManagedBalances({
4121
4355
  enabled: Boolean(isAuthenticated && isPaperMode),
@@ -4143,11 +4377,11 @@ var PlaceOrder = ({
4143
4377
  const queryClient = useQueryClient();
4144
4378
  const { disabledVenues, isLoading: isAppConfigLoading } = useAppConfig();
4145
4379
  const { data: kalshiKeyStatus, refetch: refetchKalshiKeyStatus } = useVenueKeyStatus(
4146
- Venue3.kalshi,
4380
+ Venue4.kalshi,
4147
4381
  isAuthenticated
4148
4382
  );
4149
- const [isConnectKalshiModalOpen, setIsConnectKalshiModalOpen] = useState(false);
4150
- const [isFundKalshiModalOpen, setIsFundKalshiModalOpen] = useState(false);
4383
+ const [isConnectKalshiModalOpen, setIsConnectKalshiModalOpen] = useState2(false);
4384
+ const [isFundKalshiModalOpen, setIsFundKalshiModalOpen] = useState2(false);
4151
4385
  const livePrices = useLiveOutcomePrices(
4152
4386
  scopedSelectedMarket ? [scopedSelectedMarket] : void 0
4153
4387
  );
@@ -4163,32 +4397,32 @@ var PlaceOrder = ({
4163
4397
  () => mergeBestPricesPreferringLive(clusterBestPricesRest, wsBestPrices),
4164
4398
  [clusterBestPricesRest, wsBestPrices]
4165
4399
  );
4166
- const [internalTab, setInternalTab] = useState("buy");
4167
- const [executionType, setExecutionType] = useState("market");
4168
- const [selectedLimitVenue, setSelectedLimitVenue] = useState(null);
4169
- const [limitPrice, setLimitPrice] = useState(0.5);
4170
- const [limitPriceInputValue, setLimitPriceInputValue] = useState(formatLimitPriceInputValue(0.5));
4171
- const [limitPriceInputError, setLimitPriceInputError] = useState(null);
4172
- const [limitExpirationType, setLimitExpirationType] = useState("GTC");
4173
- const [limitExpirationDate, setLimitExpirationDate] = useState(void 0);
4174
- const [limitExpirationTime, setLimitExpirationTime] = useState("17:00");
4175
- const [limitExpirationDraftDate, setLimitExpirationDraftDate] = useState();
4176
- const [limitExpirationDraftTime, setLimitExpirationDraftTime] = useState("17:00");
4177
- const [limitExpirationPickerView, setLimitExpirationPickerView] = useState("options");
4178
- const [isLimitExpirationPickerOpen, setIsLimitExpirationPickerOpen] = useState(false);
4179
- const [internalAmount, setInternalAmount] = useState(PLACE_ORDER_DEFAULT_AMOUNT);
4180
- const [sellFilledForOutcomeId, setSellFilledForOutcomeId] = useState(null);
4181
- const [internalSlippage] = useState(DEFAULT_SLIPPAGE_VALUE);
4182
- const [isRoutesExpanded, setIsRoutesExpanded] = useState(false);
4183
- const [selectedRouteCardId, setSelectedRouteCardId] = useState(null);
4184
- const [manualRouteSelectionIdentity, setManualRouteSelectionIdentity] = useState(
4400
+ const [internalTab, setInternalTab] = useState2("buy");
4401
+ const [executionType, setExecutionType] = useState2("market");
4402
+ const [selectedLimitVenue, setSelectedLimitVenue] = useState2(null);
4403
+ const [limitPrice, setLimitPrice] = useState2(0.5);
4404
+ const [limitPriceInputValue, setLimitPriceInputValue] = useState2(formatLimitPriceInputValue(0.5));
4405
+ const [limitPriceInputError, setLimitPriceInputError] = useState2(null);
4406
+ const [limitExpirationType, setLimitExpirationType] = useState2("GTC");
4407
+ const [limitExpirationDate, setLimitExpirationDate] = useState2(void 0);
4408
+ const [limitExpirationTime, setLimitExpirationTime] = useState2("17:00");
4409
+ const [limitExpirationDraftDate, setLimitExpirationDraftDate] = useState2();
4410
+ const [limitExpirationDraftTime, setLimitExpirationDraftTime] = useState2("17:00");
4411
+ const [limitExpirationPickerView, setLimitExpirationPickerView] = useState2("options");
4412
+ const [isLimitExpirationPickerOpen, setIsLimitExpirationPickerOpen] = useState2(false);
4413
+ const [internalAmount, setInternalAmount] = useState2(PLACE_ORDER_DEFAULT_AMOUNT);
4414
+ const [sellFilledForOutcomeId, setSellFilledForOutcomeId] = useState2(null);
4415
+ const [internalSlippage] = useState2(DEFAULT_SLIPPAGE_VALUE);
4416
+ const [isRoutesExpanded, setIsRoutesExpanded] = useState2(false);
4417
+ const [selectedRouteCardId, setSelectedRouteCardId] = useState2(null);
4418
+ const [manualRouteSelectionIdentity, setManualRouteSelectionIdentity] = useState2(
4185
4419
  null
4186
4420
  );
4187
- const [isSplitDetailOpen, setIsSplitDetailOpen] = useState(false);
4188
- const [buyGeoBlockSnapshot, setBuyGeoBlockSnapshot] = useState(null);
4189
- const [submissionFeedback, setSubmissionFeedback] = useState(null);
4190
- const [submissionProgressState, setSubmissionProgressState] = useState(null);
4191
- const [isBeforeActionPending, setIsBeforeActionPending] = useState(false);
4421
+ const [isSplitDetailOpen, setIsSplitDetailOpen] = useState2(false);
4422
+ const [buyGeoBlockSnapshot, setBuyGeoBlockSnapshot] = useState2(null);
4423
+ const [submissionFeedback, setSubmissionFeedback] = useState2(null);
4424
+ const [submissionProgressState, setSubmissionProgressState] = useState2(null);
4425
+ const [isBeforeActionPending, setIsBeforeActionPending] = useState2(false);
4192
4426
  const outcomes = useMemo(
4193
4427
  () => mapVenueMarketOutcomesToPlaceOrderOutcomes(scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes),
4194
4428
  [scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes]
@@ -4216,25 +4450,25 @@ var PlaceOrder = ({
4216
4450
  scopedSelectedOutcomeId,
4217
4451
  tradingContext == null ? void 0 : tradingContext.tradeSide
4218
4452
  ]);
4219
- const buyTabRef = useRef2(null);
4220
- const sellTabRef = useRef2(null);
4221
- const expirationTriggerRef = useRef2(null);
4222
- const limitPriceInitializedForOutcomeRef = useRef2(void 0);
4223
- const expirationOptionRefs = useRef2([]);
4224
- const shouldFocusExpirationOptionsRef = useRef2(false);
4453
+ const buyTabRef = useRef3(null);
4454
+ const sellTabRef = useRef3(null);
4455
+ const expirationTriggerRef = useRef3(null);
4456
+ const limitPriceInitializedForOutcomeRef = useRef3(void 0);
4457
+ const expirationOptionRefs = useRef3([]);
4458
+ const shouldFocusExpirationOptionsRef = useRef3(false);
4225
4459
  const expirationTimeInputId = useId();
4226
- const executionDebugStoreRef = useRef2(null);
4227
- const executionDebugAttemptIdRef = useRef2(null);
4228
- const submittedSelectionRef = useRef2(null);
4229
- const lastValidRouteCardsRef = useRef2(null);
4230
- useEffect2(() => {
4460
+ const executionDebugStoreRef = useRef3(null);
4461
+ const executionDebugAttemptIdRef = useRef3(null);
4462
+ const submittedSelectionRef = useRef3(null);
4463
+ const lastValidRouteCardsRef = useRef3(null);
4464
+ useEffect3(() => {
4231
4465
  if (!isExecutionDebugEnabled) {
4232
4466
  executionDebugStoreRef.current = null;
4233
4467
  return;
4234
4468
  }
4235
4469
  executionDebugStoreRef.current = enableExecutionDebugInBrowser();
4236
4470
  }, [isExecutionDebugEnabled]);
4237
- useEffect2(() => {
4471
+ useEffect3(() => {
4238
4472
  var _a2;
4239
4473
  if (!isLimitExpirationPickerOpen) return;
4240
4474
  if (limitExpirationPickerView !== "options") return;
@@ -4242,7 +4476,7 @@ var PlaceOrder = ({
4242
4476
  (_a2 = expirationOptionRefs.current[LIMIT_EXPIRATION_OPTION_COUNT - 1]) == null ? void 0 : _a2.focus();
4243
4477
  shouldFocusExpirationOptionsRef.current = false;
4244
4478
  }, [isLimitExpirationPickerOpen, limitExpirationPickerView]);
4245
- useEffect2(() => {
4479
+ useEffect3(() => {
4246
4480
  if (!isExecutionDebugEnabled) return;
4247
4481
  const store = executionDebugStoreRef.current;
4248
4482
  if (!store) return;
@@ -4379,7 +4613,7 @@ var PlaceOrder = ({
4379
4613
  }
4380
4614
  return automaticLimitVenueOption;
4381
4615
  }, [automaticLimitVenueOption, availableLimitVenueOptions, selectedLimitVenue]);
4382
- useEffect2(() => {
4616
+ useEffect3(() => {
4383
4617
  if (!selectedLimitVenue || !geoBlockedLimitVenues.has(selectedLimitVenue)) return;
4384
4618
  setSelectedLimitVenue(null);
4385
4619
  }, [geoBlockedLimitVenues, selectedLimitVenue]);
@@ -4408,7 +4642,7 @@ var PlaceOrder = ({
4408
4642
  } : {}), {
4409
4643
  refreshContext: smartRouteRefreshContext
4410
4644
  }));
4411
- useEffect2(() => {
4645
+ useEffect3(() => {
4412
4646
  var _a2, _b2, _c2;
4413
4647
  if (isSell || smartRoute.isFetching || ((_a2 = smartRoute.data) == null ? void 0 : _a2.venueMarketOutcomeId) !== scopedSelectedOutcomeId) {
4414
4648
  return;
@@ -4491,7 +4725,7 @@ var PlaceOrder = ({
4491
4725
  );
4492
4726
  const isAtMaxSellableShares = isSell && maxSellableShares > 0 && Math.abs(internalAmount - maxSellableShares) < 1e-9;
4493
4727
  const isSellAmountAboveAvailability = isSell && ((_t = smartRoute.data) == null ? void 0 : _t.venueMarketOutcomeId) === scopedSelectedOutcomeId && typeof ((_u = smartRoute.data.positionAvailability) == null ? void 0 : _u.totalSellableShares) === "number" && internalAmount > maxSellableShares;
4494
- useEffect2(() => {
4728
+ useEffect3(() => {
4495
4729
  if (submissionProgressState != null) return;
4496
4730
  if (!isSell || isCurrentSellableSharesLoading) return;
4497
4731
  if (scopedSelectedOutcomeId === sellFilledForOutcomeId) return;
@@ -4507,7 +4741,7 @@ var PlaceOrder = ({
4507
4741
  onAmountChange,
4508
4742
  submissionProgressState
4509
4743
  ]);
4510
- useEffect2(() => {
4744
+ useEffect3(() => {
4511
4745
  var _a2, _b2;
4512
4746
  if (submissionProgressState != null || !isSell) return;
4513
4747
  if (((_a2 = smartRoute.data) == null ? void 0 : _a2.venueMarketOutcomeId) !== scopedSelectedOutcomeId) return;
@@ -4594,7 +4828,7 @@ var PlaceOrder = ({
4594
4828
  selectedRouteCardId,
4595
4829
  (_B = smartRoute.data) == null ? void 0 : _B.status
4596
4830
  ]);
4597
- useEffect2(() => {
4831
+ useEffect3(() => {
4598
4832
  if (routeCards.length === 0) {
4599
4833
  if (isRouteCardsTransient) return;
4600
4834
  setSelectedRouteCardId(null);
@@ -4618,19 +4852,19 @@ var PlaceOrder = ({
4618
4852
  selectedRouteCardId
4619
4853
  ]);
4620
4854
  const isSubmissionLocked = submissionProgressState != null;
4621
- const isSubmissionLockedRef = useRef2(isSubmissionLocked);
4855
+ const isSubmissionLockedRef = useRef3(isSubmissionLocked);
4622
4856
  isSubmissionLockedRef.current = isSubmissionLocked;
4623
- useEffect2(() => {
4857
+ useEffect3(() => {
4624
4858
  if (isSubmissionLockedRef.current) return;
4625
4859
  setSubmissionFeedback(null);
4626
4860
  setSubmissionProgressState(null);
4627
4861
  }, [executionType, internalAmount, internalSlippage, internalTab, scopedSelectedOutcomeId]);
4628
- useEffect2(() => {
4862
+ useEffect3(() => {
4629
4863
  if (showLimitOrders || executionType !== "limit") return;
4630
4864
  setExecutionType("market");
4631
4865
  setIsLimitExpirationPickerOpen(false);
4632
4866
  }, [executionType, showLimitOrders]);
4633
- useEffect2(() => {
4867
+ useEffect3(() => {
4634
4868
  if (executionType !== "limit") {
4635
4869
  limitPriceInitializedForOutcomeRef.current = void 0;
4636
4870
  return;
@@ -4643,10 +4877,10 @@ var PlaceOrder = ({
4643
4877
  setLimitPriceInputValue(formatLimitPriceInputValue(nextLimitPrice));
4644
4878
  setLimitPriceInputError(null);
4645
4879
  }, [executionType, scopedSelectedOutcomeId, selectedOutcomeDisplayPrice]);
4646
- useEffect2(() => {
4880
+ useEffect3(() => {
4647
4881
  setSelectedLimitVenue(null);
4648
4882
  }, [scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id, scopedSelectedOutcomeId]);
4649
- useEffect2(() => {
4883
+ useEffect3(() => {
4650
4884
  setSelectedRouteCardId(null);
4651
4885
  setManualRouteSelectionIdentity(null);
4652
4886
  setIsRoutesExpanded(false);
@@ -4654,8 +4888,18 @@ var PlaceOrder = ({
4654
4888
  }, [executionType, internalTab, scopedSelectedOutcomeId]);
4655
4889
  const orderedRouteCards = routeCards;
4656
4890
  const selectedRouteCard = (_D = (_C = orderedRouteCards.find((card) => card.id === resolvedSelectedRouteCardId)) != null ? _C : orderedRouteCards[0]) != null ? _D : null;
4891
+ const selectedSharedKycVenue = useMemo(() => {
4892
+ var _a2, _b2;
4893
+ const candidateVenue = isLimitOrder ? selectedLimitVenueOption == null ? void 0 : selectedLimitVenueOption.venue : (_b2 = (_a2 = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData.fills.find(
4894
+ (fill) => venueRequiresSharedKyc({ venue: fill.venue })
4895
+ )) == null ? void 0 : _a2.venue) != null ? _b2 : selectedRouteCard == null ? void 0 : selectedRouteCard.venue;
4896
+ if (!venueRequiresSharedKyc({ venue: candidateVenue })) return null;
4897
+ const parsedVenue = parseVenue(candidateVenue);
4898
+ return parsedVenue.success ? parsedVenue.data : null;
4899
+ }, [isLimitOrder, selectedLimitVenueOption == null ? void 0 : selectedLimitVenueOption.venue, selectedRouteCard]);
4900
+ const needsSharedKycVerification = !isPaperMode && isAuthenticated && sharedKyc !== void 0 && selectedSharedKycVenue !== null && sharedKyc.status !== "verified";
4657
4901
  const isKalshiRoute = useMemo(() => {
4658
- if (isLimitOrder) return (selectedLimitVenueOption == null ? void 0 : selectedLimitVenueOption.venue) === Venue3.kalshi;
4902
+ if (isLimitOrder) return (selectedLimitVenueOption == null ? void 0 : selectedLimitVenueOption.venue) === Venue4.kalshi;
4659
4903
  if (selectedRouteCard) {
4660
4904
  return selectedRouteCard.venue === "kalshi" || selectedRouteCard.quoteData.fills.some((f) => f.venue === "kalshi");
4661
4905
  }
@@ -4670,7 +4914,6 @@ var PlaceOrder = ({
4670
4914
  [user == null ? void 0 : user.venueAccounts]
4671
4915
  );
4672
4916
  const isKalshiAccountActive = (_F = kalshiKeyStatus == null ? void 0 : kalshiKeyStatus.connected) != null ? _F : (legacyKalshiAccount == null ? void 0 : legacyKalshiAccount.status) === "active";
4673
- const isKalshiVerified = ((_G = kalshiKeyStatus == null ? void 0 : kalshiKeyStatus.kycStatus) != null ? _G : legacyKalshiAccount == null ? void 0 : legacyKalshiAccount.kycStatus) === "verified";
4674
4917
  const hasKalshiConnectionState = kalshiKeyStatus !== void 0 || (user == null ? void 0 : user.venueAccounts) != null;
4675
4918
  const isKalshiAvailable = getVenueAvailabilityState({
4676
4919
  venueId: "kalshi",
@@ -4678,13 +4921,13 @@ var PlaceOrder = ({
4678
4921
  isConfigLoading: isAppConfigLoading
4679
4922
  }) === "available";
4680
4923
  const needsKalshiConnection = isAuthenticated && hasKalshiConnectionState && isKalshiAvailable && isKalshiRoute && !isKalshiAccountActive;
4681
- const handleVerifyKalshi = useCallback2(
4924
+ const handleVerifyKalshi = useCallback3(
4682
4925
  (credentials) => __async(null, null, function* () {
4683
4926
  if (onConnectKalshi) {
4684
4927
  yield onConnectKalshi(credentials);
4685
4928
  } else {
4686
4929
  yield aggClient.upsertVenueKey({
4687
- venue: Venue3.kalshi,
4930
+ venue: Venue4.kalshi,
4688
4931
  credentials: {
4689
4932
  keyId: credentials.apiKeyId,
4690
4933
  privateKey: credentials.privateKey
@@ -4696,9 +4939,7 @@ var PlaceOrder = ({
4696
4939
  }),
4697
4940
  [aggClient, onConnectKalshi, refetchKalshiKeyStatus]
4698
4941
  );
4699
- const needsKycVerification = isAuthenticated && hasKalshiConnectionState && isKalshiRoute && isKalshiAccountActive && !isKalshiVerified;
4700
- const verifyKalshiConnectionLabel = (_K = (_J = (_I = (_H = labels.onboarding) == null ? void 0 : _H.connectKalshiModal) == null ? void 0 : _I.actions) == null ? void 0 : _J.verifyConnection) != null ? _K : tradingLabels.kycRequired;
4701
- const handleRouteCardSelect = useCallback2(
4942
+ const handleRouteCardSelect = useCallback3(
4702
4943
  (cardId) => {
4703
4944
  const card = routeCards.find((routeCard) => routeCard.id === cardId);
4704
4945
  if (!card || card.isUnavailable) return;
@@ -4730,22 +4971,22 @@ var PlaceOrder = ({
4730
4971
  ]
4731
4972
  );
4732
4973
  const executionProgress = useExecutionProgress({
4733
- orderIds: (_L = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) != null ? _L : null,
4734
- quoteId: (_M = submissionProgressState == null ? void 0 : submissionProgressState.quoteId) != null ? _M : null,
4974
+ orderIds: (_G = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) != null ? _G : null,
4975
+ quoteId: (_H = submissionProgressState == null ? void 0 : submissionProgressState.quoteId) != null ? _H : null,
4735
4976
  mode: isPaperMode ? "paper" : void 0,
4736
- enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((_N = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _N.length)
4977
+ enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((_I = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _I.length)
4737
4978
  });
4738
- const executionProgressFloorRef = useRef2({
4979
+ const executionProgressFloorRef = useRef3({
4739
4980
  quoteId: null,
4740
4981
  value: 0
4741
4982
  });
4742
- const selectedOutcomeLabel = (_Q = (_P = (_O = outcomes.find((outcome) => outcome.id === scopedSelectedOutcomeId)) == null ? void 0 : _O.label) != null ? _P : scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.label) != null ? _Q : "";
4743
- const headerImage = (_S = (_R = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.image) != null ? _R : scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.image) != null ? _S : null;
4744
- const headerTitle = (_U = (_T = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _T : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _U : "";
4745
- const headerSubtitle = (_V = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _V : "";
4746
- const executionDateSource = (_W = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.endDate) != null ? _W : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.endDate;
4983
+ const selectedOutcomeLabel = (_L = (_K = (_J = outcomes.find((outcome) => outcome.id === scopedSelectedOutcomeId)) == null ? void 0 : _J.label) != null ? _K : scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.label) != null ? _L : "";
4984
+ const headerImage = (_N = (_M = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.image) != null ? _M : scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.image) != null ? _N : null;
4985
+ const headerTitle = (_P = (_O = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _O : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _P : "";
4986
+ const headerSubtitle = (_Q = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _Q : "";
4987
+ const executionDateSource = (_R = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.endDate) != null ? _R : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.endDate;
4747
4988
  const executionDateLabel = executionDateSource ? getTradingDateLabel(executionDateSource) : "";
4748
- const executionQuoteData = (_Y = (_X = submissionProgressState == null ? void 0 : submissionProgressState.quoteData) != null ? _X : selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _Y : null;
4989
+ const executionQuoteData = (_T = (_S = submissionProgressState == null ? void 0 : submissionProgressState.quoteData) != null ? _S : selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _T : null;
4749
4990
  const executionOrderGroups = useMemo(() => {
4750
4991
  var _a2, _b2, _c2;
4751
4992
  if (!executionQuoteData) return [];
@@ -4766,7 +5007,7 @@ var PlaceOrder = ({
4766
5007
  executionProgress.terminalOrderEvents,
4767
5008
  executionQuoteData,
4768
5009
  internalTab,
4769
- (_Z = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _Z.length,
5010
+ (_U = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _U.length,
4770
5011
  tradingLabels
4771
5012
  ]);
4772
5013
  const executionProgressPercent = useMemo(() => {
@@ -4789,7 +5030,7 @@ var PlaceOrder = ({
4789
5030
  submissionProgressState == null ? void 0 : submissionProgressState.orderIds,
4790
5031
  submissionProgressState == null ? void 0 : submissionProgressState.quoteId
4791
5032
  ]);
4792
- const buildExecutionSummary = useCallback2(
5033
+ const buildExecutionSummary = useCallback3(
4793
5034
  (quoteData, executionVenue, orderId, partialFillSummary) => {
4794
5035
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2;
4795
5036
  if (!quoteData) return void 0;
@@ -4884,7 +5125,7 @@ var PlaceOrder = ({
4884
5125
  tradingLabels
4885
5126
  ]
4886
5127
  );
4887
- useEffect2(() => {
5128
+ useEffect3(() => {
4888
5129
  if (executionProgress.phase === "order_submitted") {
4889
5130
  const submittedOrder = executionProgress.submittedOrders[0];
4890
5131
  setSubmissionProgressState((prev) => {
@@ -4897,7 +5138,7 @@ var PlaceOrder = ({
4897
5138
  });
4898
5139
  }
4899
5140
  }, [executionProgress.phase, executionProgress.submittedOrders]);
4900
- useEffect2(() => {
5141
+ useEffect3(() => {
4901
5142
  var _a2, _b2;
4902
5143
  const dp = executionProgress.dagProgress;
4903
5144
  if (!dp) return;
@@ -4952,7 +5193,7 @@ var PlaceOrder = ({
4952
5193
  return __spreadProps(__spreadValues({}, prev), { dagProgress: dp });
4953
5194
  });
4954
5195
  }, [executionOrderGroups, executionProgress.dagProgress, tradingLabels]);
4955
- useEffect2(() => {
5196
+ useEffect3(() => {
4956
5197
  const orderIds = submissionProgressState == null ? void 0 : submissionProgressState.orderIds;
4957
5198
  if (!(orderIds == null ? void 0 : orderIds.length)) return;
4958
5199
  const aggregateStatus = deriveAggregateOrderStatus(
@@ -5013,7 +5254,7 @@ var PlaceOrder = ({
5013
5254
  tradingLabels
5014
5255
  ]);
5015
5256
  const estDurationMs = executionQuoteData && typeof executionQuoteData.estDurationMs === "number" ? executionQuoteData.estDurationMs : 6e4;
5016
- useEffect2(() => {
5257
+ useEffect3(() => {
5017
5258
  const phase = submissionProgressState == null ? void 0 : submissionProgressState.phase;
5018
5259
  if (phase !== "submitting" && phase !== "executing") return;
5019
5260
  const timeoutMs = Math.max(6e4, 2 * estDurationMs);
@@ -5028,7 +5269,7 @@ var PlaceOrder = ({
5028
5269
  }, timeoutMs);
5029
5270
  return () => clearTimeout(id);
5030
5271
  }, [submissionProgressState == null ? void 0 : submissionProgressState.phase, estDurationMs]);
5031
- const emitTerminalOrderNotifications = useCallback2(() => {
5272
+ const emitTerminalOrderNotifications = useCallback3(() => {
5032
5273
  const toast = toastCtx == null ? void 0 : toastCtx.toast;
5033
5274
  if (!toast) return;
5034
5275
  for (const event of executionProgress.terminalOrderEvents) {
@@ -5057,7 +5298,7 @@ var PlaceOrder = ({
5057
5298
  });
5058
5299
  }
5059
5300
  }, [executionProgress.terminalOrderEvents, labels, toastCtx]);
5060
- useEffect2(() => {
5301
+ useEffect3(() => {
5061
5302
  var _a2, _b2;
5062
5303
  if (!submissionProgressState) return;
5063
5304
  onExecutionStateChange == null ? void 0 : onExecutionStateChange(submissionProgressState);
@@ -5109,19 +5350,19 @@ var PlaceOrder = ({
5109
5350
  queryClient,
5110
5351
  submissionProgressState
5111
5352
  ]);
5112
- const activeQuoteData = isLimitOrder ? null : (__ = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? __ : scopedSmartRouteData;
5353
+ const activeQuoteData = isLimitOrder ? null : (_V = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _V : scopedSmartRouteData;
5113
5354
  const visibleMarketRouteCards = displayedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT && !isRoutesExpanded ? displayedRouteCards.slice(0, PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT) : displayedRouteCards;
5114
5355
  const hasEnteredAmount = internalAmount > 0;
5115
5356
  const isQuoteLoading = !isLimitOrder && hasEnteredAmount && (isSell && isQuoteInputEditing || smartRoute.isLoading || !isSell && smartRoute.isFetching || isSell && venueSellQuotes.isLoading);
5116
5357
  const routeLoadingMessage = isQuoteLoading ? smartRoute.loadingReason === "updating-route" ? tradingLabels.updatingRoute : smartRoute.loadingReason === "refreshing-quotes" ? tradingLabels.refreshingQuotes : tradingLabels.findingBestOdds : null;
5117
- const selectedRouteFills = (_$ = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData.fills) != null ? _$ : [];
5118
- const isKalshiOnlyRoute = isKalshiRoute && ((selectedRouteCard == null ? void 0 : selectedRouteCard.venue) === Venue3.kalshi || selectedRouteFills.length > 0 && selectedRouteFills.every((fill) => fill.venue === Venue3.kalshi));
5119
- const isOnchainOnlyRoute = !isKalshiRoute || selectedRouteFills.length > 0 && selectedRouteFills.every((fill) => fill.venue !== Venue3.kalshi);
5120
- const kalshiRequiredAmount = isSell ? 0 : selectedRouteFills.filter((fill) => fill.venue === Venue3.kalshi).reduce((total, fill) => total + fill.venueQty * fill.avgPrice, 0);
5121
- const onchainRequiredAmount = isSell ? 0 : selectedRouteFills.filter((fill) => fill.venue !== Venue3.kalshi).reduce((total, fill) => total + fill.venueQty * fill.avgPrice, 0);
5358
+ const selectedRouteFills = (_W = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData.fills) != null ? _W : [];
5359
+ const isKalshiOnlyRoute = isKalshiRoute && ((selectedRouteCard == null ? void 0 : selectedRouteCard.venue) === Venue4.kalshi || selectedRouteFills.length > 0 && selectedRouteFills.every((fill) => fill.venue === Venue4.kalshi));
5360
+ const isOnchainOnlyRoute = !isKalshiRoute || selectedRouteFills.length > 0 && selectedRouteFills.every((fill) => fill.venue !== Venue4.kalshi);
5361
+ const kalshiRequiredAmount = isSell ? 0 : selectedRouteFills.filter((fill) => fill.venue === Venue4.kalshi).reduce((total, fill) => total + fill.venueQty * fill.avgPrice, 0);
5362
+ const onchainRequiredAmount = isSell ? 0 : selectedRouteFills.filter((fill) => fill.venue !== Venue4.kalshi).reduce((total, fill) => total + fill.venueQty * fill.avgPrice, 0);
5122
5363
  const resolvedKalshiRequiredAmount = isKalshiOnlyRoute || isKalshiRoute && selectedRouteFills.length === 0 ? internalAmount : kalshiRequiredAmount;
5123
5364
  const resolvedOnchainRequiredAmount = isOnchainOnlyRoute || !isKalshiRoute && selectedRouteFills.length === 0 ? internalAmount : onchainRequiredAmount;
5124
- const isKalshiBalanceInsufficient = !isPaperMode && isKalshiRoute && resolvedKalshiRequiredAmount > ((_aa = liveBalanceState.kalshiBalance) != null ? _aa : 0);
5365
+ const isKalshiBalanceInsufficient = !isPaperMode && isKalshiRoute && resolvedKalshiRequiredAmount > ((_X = liveBalanceState.kalshiBalance) != null ? _X : 0);
5125
5366
  const isOnchainBalanceInsufficient = resolvedOnchainRequiredAmount > liveAvailableBalance;
5126
5367
  const isInsufficientBalance = !isSell && isAuthenticated && hasEnteredAmount && !isBalanceLoading && (isLimitOrder ? internalAmount > totalBalance : isPaperMode ? internalAmount > paperTotalBalance : isKalshiBalanceInsufficient || isOnchainBalanceInsufficient);
5127
5368
  const isQuoteInsufficientBalance = !isLimitOrder && (activeQuoteData == null ? void 0 : activeQuoteData.status) === "insufficient_balance";
@@ -5246,7 +5487,7 @@ var PlaceOrder = ({
5246
5487
  const averagePrice = selectedRouteCard.executionPrice;
5247
5488
  return averagePrice == null ? "" : tradingLabels.averagePrice(averagePrice);
5248
5489
  }, [selectedRouteCard, tradingLabels]);
5249
- const displayedToWinValue = (_ba = selectedRouteCard == null ? void 0 : selectedRouteCard.numericValue) != null ? _ba : 0;
5490
+ const displayedToWinValue = (_Y = selectedRouteCard == null ? void 0 : selectedRouteCard.numericValue) != null ? _Y : 0;
5250
5491
  const originalLimitPriceRaw = useMemo(() => toLimitPriceRaw(limitPrice), [limitPrice]);
5251
5492
  const limitPriceAdjustmentByVenue = useMemo(() => {
5252
5493
  var _a2;
@@ -5275,7 +5516,7 @@ var PlaceOrder = ({
5275
5516
  return adjustments;
5276
5517
  }, [internalTab, limitVenueQuoteByVenue, originalLimitPriceRaw, visibleLimitVenueOptions]);
5277
5518
  const selectedLimitPriceAdjustment = selectedLimitVenueOption ? limitPriceAdjustmentByVenue.get(selectedLimitVenueOption.venue) : void 0;
5278
- const selectedLimitPriceRaw = (_ca = selectedLimitPriceAdjustment == null ? void 0 : selectedLimitPriceAdjustment.adjustedPriceRaw) != null ? _ca : originalLimitPriceRaw;
5519
+ const selectedLimitPriceRaw = (_Z = selectedLimitPriceAdjustment == null ? void 0 : selectedLimitPriceAdjustment.adjustedPriceRaw) != null ? _Z : originalLimitPriceRaw;
5279
5520
  const limitPriceAdjustmentMessage = useMemo(() => {
5280
5521
  if (!selectedLimitVenueOption || !(selectedLimitPriceAdjustment == null ? void 0 : selectedLimitPriceAdjustment.adjusted) || !selectedLimitPriceAdjustment.tickSizeRaw) {
5281
5522
  return "";
@@ -5403,7 +5644,8 @@ var PlaceOrder = ({
5403
5644
  maximumFractionDigits: 2,
5404
5645
  minimumFractionDigits: 2
5405
5646
  }),
5406
- venue: option.venue
5647
+ venue: option.venue,
5648
+ requiresSharedKyc: venueRequiresSharedKyc({ venue: option.venue })
5407
5649
  };
5408
5650
  });
5409
5651
  }, [
@@ -5441,6 +5683,8 @@ var PlaceOrder = ({
5441
5683
  };
5442
5684
  const displayedLimitToWinHint = formatLimitPriceRawLabel(selectedLimitPriceRaw);
5443
5685
  const activeFeeBreakdown = activeQuoteData == null ? void 0 : activeQuoteData.feeBreakdown;
5686
+ const executionReserve = activeFeeBreakdown == null ? void 0 : activeFeeBreakdown.executionReserve;
5687
+ const executionReserveValue = typeof executionReserve === "number" && Number.isFinite(executionReserve) && executionReserve > 0 ? formatUsd(executionReserve, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) : null;
5444
5688
  const estimatedFeesValue = useMemo(() => {
5445
5689
  const totalFees = getSmartRouteTotalFees(activeFeeBreakdown);
5446
5690
  if (totalFees == null) return null;
@@ -5482,14 +5726,14 @@ var PlaceOrder = ({
5482
5726
  }, [activeFeeBreakdown, tradingLabels]);
5483
5727
  const isActionLoading = isPrimaryActionLoading || executeManaged.isPending || placeLimitOrder.isPending || isBeforeActionPending;
5484
5728
  const selectedLimitRouteCardId = selectedLimitVenueOption ? `limit-venue-${selectedLimitVenueOption.venue}-${selectedLimitVenueOption.venueMarketOutcomeId}` : null;
5485
- const selectedLimitRouteCard = selectedLimitRouteCardId ? (_da = limitRouteCards.find((card) => card.id === selectedLimitRouteCardId)) != null ? _da : null : null;
5486
- const selectedRouteGeoBlocked = isLimitOrder ? (_ea = selectedLimitRouteCard == null ? void 0 : selectedLimitRouteCard.isUnavailable) != null ? _ea : false : (_fa = selectedRouteCard == null ? void 0 : selectedRouteCard.isUnavailable) != null ? _fa : false;
5729
+ const selectedLimitRouteCard = selectedLimitRouteCardId ? (__ = limitRouteCards.find((card) => card.id === selectedLimitRouteCardId)) != null ? __ : null : null;
5730
+ const selectedRouteGeoBlocked = isLimitOrder ? (_$ = selectedLimitRouteCard == null ? void 0 : selectedLimitRouteCard.isUnavailable) != null ? _$ : false : (_aa = selectedRouteCard == null ? void 0 : selectedRouteCard.isUnavailable) != null ? _aa : false;
5487
5731
  const geoBlockedVenuesFromWarnings = useMemo(
5488
5732
  () => {
5489
5733
  var _a2;
5490
5734
  return extractGeoBlockedVenues((_a2 = smartRoute.data) == null ? void 0 : _a2.warnings);
5491
5735
  },
5492
- [(_ga = smartRoute.data) == null ? void 0 : _ga.warnings]
5736
+ [(_ba = smartRoute.data) == null ? void 0 : _ba.warnings]
5493
5737
  );
5494
5738
  const isPrimaryVenueGeoBlocked = useMemo(() => {
5495
5739
  var _a2, _b2;
@@ -5507,7 +5751,7 @@ var PlaceOrder = ({
5507
5751
  const isActionDisabled = isPrimaryActionDisabled || !orderEligibility.canPlaceOrder || isActionLoading || !hasEnteredAmount || !scopedSelectedMarket || isInsufficientBalance || isQuoteInsufficientBalance || isSell && isQuoteInputEditing || isSellAmountAboveAvailability || isBelowMinimum || !isLimitOrder && isQuoteLoading || isSelectedVenueInventoryInsufficient || (isLimitOrder ? !limitOrderPayload : !selectedRouteCard || !selectedRouteCard.quoteData.quoteId) || selectedRouteGeoBlocked || !isAuthenticated || !isLimitOrder && quoteStatus !== void 0;
5508
5752
  const shouldShowSmartRouting = orderEligibility.canPlaceOrder && hasEnteredAmount && !isBelowMinimum && (isLimitOrder ? limitRouteCards.length > 0 : displayedRouteCards.length > 0 || smartRoute.isFetching || smartRoute.isLoading || isSell && (venueSellQuotes.isFetching || venueSellQuotes.isLoading));
5509
5753
  const shouldShowRouteToggle = !isLimitOrder && !isQuoteLoading && displayedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT;
5510
- const handleReturnToOrderForm = useCallback2(() => {
5754
+ const handleReturnToOrderForm = useCallback3(() => {
5511
5755
  const submittedSelection = submittedSelectionRef.current;
5512
5756
  submittedSelectionRef.current = null;
5513
5757
  setSubmissionProgressState(null);
@@ -5529,7 +5773,7 @@ var PlaceOrder = ({
5529
5773
  const shareUrl = `https://twitter.com/intent/tweet?text=${encodeURIComponent(shareText)}`;
5530
5774
  window.open(shareUrl, "_blank", "noopener,noreferrer");
5531
5775
  };
5532
- const handleExecuteQuote = useCallback2(
5776
+ const handleExecuteQuote = useCallback3(
5533
5777
  (quoteData) => __async(null, null, function* () {
5534
5778
  var _a2, _b2, _c2;
5535
5779
  const quoteId = quoteData == null ? void 0 : quoteData.quoteId;
@@ -5646,7 +5890,7 @@ var PlaceOrder = ({
5646
5890
  venueSellQuotes.quotes
5647
5891
  ]
5648
5892
  );
5649
- const handlePlaceLimitOrder = useCallback2(
5893
+ const handlePlaceLimitOrder = useCallback3(
5650
5894
  (submissionLimitOrderPayload) => __async(null, null, function* () {
5651
5895
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
5652
5896
  if (!showLimitOrders) return;
@@ -5682,7 +5926,7 @@ var PlaceOrder = ({
5682
5926
  ) : sizeLabel;
5683
5927
  const eventTitle = (_b2 = (_a2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _a2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _b2 : "";
5684
5928
  const eventDateSource = (_c2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.endDate) != null ? _c2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.endDate;
5685
- const responseVenue = Venue3[response.venue];
5929
+ const responseVenue = Venue4[response.venue];
5686
5930
  setSubmissionProgressState({
5687
5931
  orderId: response.orderId,
5688
5932
  orderIds: [response.orderId],
@@ -5729,7 +5973,7 @@ var PlaceOrder = ({
5729
5973
  tradingLabels
5730
5974
  ]
5731
5975
  );
5732
- const handleSkipToSuccess = useCallback2(() => {
5976
+ const handleSkipToSuccess = useCallback3(() => {
5733
5977
  const primaryFilledEvent = executionProgress.terminalOrderEvents.find(
5734
5978
  (e) => e.event === "filled" || e.event === "partial_fill"
5735
5979
  );
@@ -5754,7 +5998,7 @@ var PlaceOrder = ({
5754
5998
  failureSummary,
5755
5999
  selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData
5756
6000
  ]);
5757
- useEffect2(() => {
6001
+ useEffect3(() => {
5758
6002
  if ((submissionProgressState == null ? void 0 : submissionProgressState.phase) !== "failed") return;
5759
6003
  if ((failureSummary == null ? void 0 : failureSummary.kind) !== "partial_fill") return;
5760
6004
  if (!shouldAutoSkipPartialFill) return;
@@ -5765,7 +6009,7 @@ var PlaceOrder = ({
5765
6009
  shouldAutoSkipPartialFill,
5766
6010
  submissionProgressState == null ? void 0 : submissionProgressState.phase
5767
6011
  ]);
5768
- const handleRetrySubmission = useCallback2(() => __async(null, null, function* () {
6012
+ const handleRetrySubmission = useCallback3(() => __async(null, null, function* () {
5769
6013
  var _a2, _b2, _c2, _d2, _e2;
5770
6014
  if (!orderEligibility.canPlaceOrder || !failureSummary || failureSummary.kind === "generic") {
5771
6015
  handleReturnToOrderForm();
@@ -6173,7 +6417,7 @@ var PlaceOrder = ({
6173
6417
  PlaceOrderResolvedView,
6174
6418
  {
6175
6419
  tradingState: resolvedReadOnlyTradingState,
6176
- resolutionTimestamp: (_ha = resolvedEventTradingState.resolvesAt) != null ? _ha : resolvedReadOnlyTradingState.resolvesAt,
6420
+ resolutionTimestamp: (_ca = resolvedEventTradingState.resolvesAt) != null ? _ca : resolvedReadOnlyTradingState.resolvesAt,
6177
6421
  resolvedClaim,
6178
6422
  classNames,
6179
6423
  className,
@@ -6497,6 +6741,31 @@ var PlaceOrder = ({
6497
6741
  ) : null
6498
6742
  ] }),
6499
6743
  /* @__PURE__ */ jsx7("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: estimatedFeesValue })
6744
+ ] }) : null,
6745
+ showFeesBreakdown && hasEnteredAmount && !isBelowMinimum && executionReserveValue ? /* @__PURE__ */ jsxs6("div", { className: "agg-order-reserve-section flex items-center justify-between gap-4", children: [
6746
+ /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-1.5", children: [
6747
+ /* @__PURE__ */ jsx7(
6748
+ Typography,
6749
+ {
6750
+ variant: "text-sm",
6751
+ className: "text-agg-sm leading-agg-5 text-agg-muted-foreground",
6752
+ children: tradingLabels.executionReserve
6753
+ }
6754
+ ),
6755
+ /* @__PURE__ */ jsx7(
6756
+ Tooltip,
6757
+ {
6758
+ "aria-label": tradingLabels.executionReserveTooltipAria,
6759
+ content: tradingLabels.executionReserveDescription,
6760
+ classNames: {
6761
+ content: "max-w-[320px]",
6762
+ icon: "h-3 w-3 text-agg-muted-foreground",
6763
+ trigger: "h-3 w-3 text-agg-muted-foreground"
6764
+ }
6765
+ }
6766
+ )
6767
+ ] }),
6768
+ /* @__PURE__ */ jsx7("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: executionReserveValue })
6500
6769
  ] }) : null
6501
6770
  ] }),
6502
6771
  shouldShowSmartRouting ? /* @__PURE__ */ jsxs6(
@@ -6539,6 +6808,7 @@ var PlaceOrder = ({
6539
6808
  isExpanded: card.kind === "split" ? isSplitDetailOpen : isRoutesExpanded,
6540
6809
  isSelected: !card.isUnavailable && card.id === (isLimitOrder ? selectedLimitRouteCardId : resolvedSelectedRouteCardId),
6541
6810
  onSelect: handleActiveRouteCardSelect,
6811
+ sharedKycStatus: isPaperMode ? void 0 : sharedKyc == null ? void 0 : sharedKyc.status,
6542
6812
  tradingLabels
6543
6813
  }) }, card.id);
6544
6814
  }) : null })
@@ -6785,7 +7055,7 @@ var PlaceOrder = ({
6785
7055
  }
6786
7056
  ) : null
6787
7057
  ] }) : null,
6788
- !submissionFeedback && !shouldShowGeoBlockBanner && orderEligibility.canPlaceOrder && !needsKalshiConnection && shouldShowInsufficientBalanceAlert ? /* @__PURE__ */ jsxs6(
7058
+ !submissionFeedback && !shouldShowGeoBlockBanner && orderEligibility.canPlaceOrder && !needsSharedKycVerification && !needsKalshiConnection && shouldShowInsufficientBalanceAlert ? /* @__PURE__ */ jsxs6(
6789
7059
  "div",
6790
7060
  {
6791
7061
  className: "agg-order-insufficient-balance-alert flex items-center justify-center gap-2",
@@ -6818,25 +7088,29 @@ var PlaceOrder = ({
6818
7088
  ]
6819
7089
  }
6820
7090
  ) : null,
6821
- !submissionFeedback && !shouldShowGeoBlockBanner && needsKalshiConnection ? /* @__PURE__ */ jsx7(
7091
+ !submissionFeedback && !shouldShowGeoBlockBanner && needsSharedKycVerification ? /* @__PURE__ */ jsx7(
6822
7092
  Button,
6823
7093
  {
6824
7094
  size: "large",
6825
7095
  variant: "primary",
6826
- className: "agg-order-connect-kalshi h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none",
6827
- "aria-label": tradingLabels.connectKalshi,
6828
- onClick: () => setIsConnectKalshiModalOpen(true),
6829
- children: tradingLabels.connectKalshi
7096
+ className: "agg-order-shared-kyc-action h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none",
7097
+ "aria-label": sharedKyc.status === "loading" ? tradingLabels.sharedKyc.checkingStatus : tradingLabels.sharedKyc.completeToTrade,
7098
+ disabled: sharedKyc.status === "loading",
7099
+ isLoading: sharedKyc.status === "loading",
7100
+ onClick: () => {
7101
+ if (selectedSharedKycVenue) sharedKycFlow.openForVenue(selectedSharedKycVenue);
7102
+ },
7103
+ children: sharedKyc.status === "loading" ? tradingLabels.sharedKyc.checkingStatus : tradingLabels.sharedKyc.completeToTrade
6830
7104
  }
6831
- ) : needsKycVerification && !submissionFeedback && !shouldShowGeoBlockBanner ? /* @__PURE__ */ jsx7(
7105
+ ) : !submissionFeedback && !shouldShowGeoBlockBanner && needsKalshiConnection ? /* @__PURE__ */ jsx7(
6832
7106
  Button,
6833
7107
  {
6834
7108
  size: "large",
6835
7109
  variant: "primary",
6836
- className: "agg-order-kyc-action h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none",
6837
- "aria-label": verifyKalshiConnectionLabel,
7110
+ className: "agg-order-connect-kalshi h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none",
7111
+ "aria-label": tradingLabels.connectKalshi,
6838
7112
  onClick: () => setIsConnectKalshiModalOpen(true),
6839
- children: verifyKalshiConnectionLabel
7113
+ children: tradingLabels.connectKalshi
6840
7114
  }
6841
7115
  ) : !submissionFeedback && !shouldShowGeoBlockBanner && isInsufficientBalance ? /* @__PURE__ */ jsx7(
6842
7116
  Button,
@@ -6925,6 +7199,20 @@ var PlaceOrder = ({
6925
7199
  ]
6926
7200
  }
6927
7201
  ),
7202
+ /* @__PURE__ */ jsx7(
7203
+ SharedKycModal,
7204
+ {
7205
+ open: sharedKycFlow.isModalOpen,
7206
+ state: sharedKycFlow.modalState,
7207
+ errorMessage: sharedKycFlow.errorMessage,
7208
+ onOpenChange: (nextOpen) => {
7209
+ if (!nextOpen) sharedKycFlow.closeModal();
7210
+ },
7211
+ onStartVerification: () => {
7212
+ void sharedKycFlow.startVerification();
7213
+ }
7214
+ }
7215
+ ),
6928
7216
  /* @__PURE__ */ jsx7(
6929
7217
  ConnectKalshiModal,
6930
7218
  {
@@ -6949,7 +7237,7 @@ import {
6949
7237
  useRedeem,
6950
7238
  useRedeemLifecycles
6951
7239
  } from "@agg-build/hooks";
6952
- import { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef3, useState as useState2 } from "react";
7240
+ import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo2, useRef as useRef4, useState as useState3 } from "react";
6953
7241
  var toClaimError = (err) => {
6954
7242
  if (err instanceof Error) return err;
6955
7243
  return new Error(String(err));
@@ -6961,11 +7249,11 @@ function useClaimWinnings(options = {}) {
6961
7249
  const toastCtx = useOptionalToast();
6962
7250
  const queryClient = useQueryClient2();
6963
7251
  const redeemMutation = useRedeem();
6964
- const [activeRedeems, setActiveRedeems] = useState2({});
6965
- const activeClaimKeysRef = useRef3(/* @__PURE__ */ new Set());
6966
- const pendingClaimToastIdsRef = useRef3({});
6967
- const submittedClaimToastKeysRef = useRef3(/* @__PURE__ */ new Set());
6968
- const [submittingClaimKeys, setSubmittingClaimKeys] = useState2({});
7252
+ const [activeRedeems, setActiveRedeems] = useState3({});
7253
+ const activeClaimKeysRef = useRef4(/* @__PURE__ */ new Set());
7254
+ const pendingClaimToastIdsRef = useRef4({});
7255
+ const submittedClaimToastKeysRef = useRef4(/* @__PURE__ */ new Set());
7256
+ const [submittingClaimKeys, setSubmittingClaimKeys] = useState3({});
6969
7257
  const lifecycleInputs = useMemo2(
6970
7258
  () => Object.values(activeRedeems),
6971
7259
  [activeRedeems]
@@ -6980,11 +7268,11 @@ function useClaimWinnings(options = {}) {
6980
7268
  return out;
6981
7269
  }, [activeRedeems, lifecycleStates, submittingClaimKeys]);
6982
7270
  const claimingKeys = externalClaimingKeys != null ? externalClaimingKeys : internalClaimingIds;
6983
- const isClaiming = useCallback3(
7271
+ const isClaiming = useCallback4(
6984
7272
  (claimKey) => Boolean(externalClaimingKeys == null ? void 0 : externalClaimingKeys[claimKey]) || Boolean(internalClaimingIds[claimKey]),
6985
7273
  [externalClaimingKeys, internalClaimingIds]
6986
7274
  );
6987
- const invalidateClaimUiState = useCallback3(() => {
7275
+ const invalidateClaimUiState = useCallback4(() => {
6988
7276
  invalidateBalanceQueries2(queryClient);
6989
7277
  invalidatePositionQueries2(queryClient);
6990
7278
  queryClient.invalidateQueries({
@@ -6993,7 +7281,7 @@ function useClaimWinnings(options = {}) {
6993
7281
  });
6994
7282
  invalidateUserActivityQueries(queryClient);
6995
7283
  }, [queryClient]);
6996
- const claim = useCallback3(
7284
+ const claim = useCallback4(
6997
7285
  (_0) => __async(null, [_0], function* ({ claimKey, winningOutcomeIds, payload }) {
6998
7286
  if (activeClaimKeysRef.current.has(claimKey) || Boolean(externalClaimingKeys == null ? void 0 : externalClaimingKeys[claimKey]) || internalClaimingIds[claimKey]) {
6999
7287
  return;
@@ -7131,8 +7419,8 @@ function useClaimWinnings(options = {}) {
7131
7419
  toastCtx
7132
7420
  ]
7133
7421
  );
7134
- const firedTerminalRef = useRef3({});
7135
- useEffect3(() => {
7422
+ const firedTerminalRef = useRef4({});
7423
+ useEffect4(() => {
7136
7424
  var _a, _b;
7137
7425
  for (const [claimKey, active] of Object.entries(activeRedeems)) {
7138
7426
  const state = lifecycleStates[active.redeemId];
@@ -7266,6 +7554,9 @@ export {
7266
7554
  parseVenue,
7267
7555
  parseAmount,
7268
7556
  SettlementDetails,
7557
+ venueRequiresSharedKyc,
7558
+ createAggClientSharedKycInitiator,
7559
+ useSharedKycFlow,
7269
7560
  DEPOSIT_MODAL_OPEN_EVENT,
7270
7561
  WITHDRAW_MODAL_OPEN_EVENT,
7271
7562
  requestAggDepositModalOpen,