@agg-market/ui 5.0.0 → 6.0.0

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 (517) hide show
  1. package/README.md +26 -26
  2. package/dist/auth.d.mts +1 -0
  3. package/dist/auth.d.ts +1 -0
  4. package/dist/{connect-button.js → auth.js} +6 -4
  5. package/dist/auth.mjs +8 -0
  6. package/dist/chunk-2ICOSP7N.mjs +1211 -0
  7. package/dist/chunk-5ZKPBMRK.mjs +2411 -0
  8. package/dist/{chunk-5K7VXAYM.mjs → chunk-ADGL6RFX.mjs} +2 -4
  9. package/dist/chunk-BXW3VIKV.mjs +90 -0
  10. package/dist/{chart.js → chunk-CN7GI2RJ.mjs} +250 -103
  11. package/dist/chunk-G6YKGVQR.mjs +769 -0
  12. package/dist/{chunk-PZTHM6WG.mjs → chunk-HI4EEDN5.mjs} +897 -357
  13. package/dist/{chunk-5ADMXO3Y.mjs → chunk-INRG3D4M.mjs} +5 -11
  14. package/dist/{chunk-QDMHLRDY.mjs → chunk-JE3Z52FD.mjs} +90 -38
  15. package/dist/chunk-KZOQW6NT.mjs +0 -0
  16. package/dist/chunk-LMOJKJOY.mjs +2616 -0
  17. package/dist/{chunk-YJA5VQW6.mjs → chunk-MHCHR65A.mjs} +2 -4
  18. package/dist/{chunk-IGPNIM2B.mjs → chunk-PASXFYKQ.mjs} +2 -4
  19. package/dist/chunk-UBBOLLOS.mjs +999 -0
  20. package/dist/events.d.mts +1 -0
  21. package/dist/events.d.ts +1 -0
  22. package/dist/{event-market-page.js → events.js} +4579 -4935
  23. package/dist/events.mjs +17 -0
  24. package/dist/index.d.mts +1 -79
  25. package/dist/index.d.ts +1 -79
  26. package/dist/index.js +6839 -6839
  27. package/dist/index.mjs +66 -170
  28. package/dist/modals.d.mts +1 -0
  29. package/dist/modals.d.ts +1 -0
  30. package/dist/{deposit-modal.js → modals.js} +1771 -6
  31. package/dist/modals.mjs +25 -0
  32. package/dist/pages.d.mts +1 -0
  33. package/dist/pages.d.ts +1 -0
  34. package/dist/{home-page.js → pages.js} +3868 -6
  35. package/dist/pages.mjs +16 -0
  36. package/dist/primitives.d.mts +1 -0
  37. package/dist/primitives.d.ts +1 -0
  38. package/dist/{market-details.js → primitives.js} +3302 -3729
  39. package/dist/{icon.mjs → primitives.mjs} +56 -9
  40. package/dist/trading.d.mts +1 -0
  41. package/dist/trading.d.ts +1 -0
  42. package/dist/{event-list.js → trading.js} +1426 -1467
  43. package/dist/trading.mjs +65 -0
  44. package/dist/types/auth/connect-button/connect-button.constants.d.mts +10 -0
  45. package/dist/types/auth/connect-button/connect-button.constants.d.ts +10 -0
  46. package/dist/{connect-button.d.mts → types/auth/connect-button/connect-button.types.d.mts} +5 -12
  47. package/dist/{connect-button.d.ts → types/auth/connect-button/connect-button.types.d.ts} +5 -12
  48. package/dist/types/auth/connect-button/index.d.mts +7 -0
  49. package/dist/types/auth/connect-button/index.d.ts +7 -0
  50. package/dist/types/auth/index.d.mts +1 -0
  51. package/dist/types/auth/index.d.ts +1 -0
  52. package/dist/types/constants.d.mts +1 -0
  53. package/dist/types/constants.d.ts +1 -0
  54. package/dist/types/deposit/deposit-modal.constants.d.mts +9 -0
  55. package/dist/types/deposit/deposit-modal.constants.d.ts +9 -0
  56. package/dist/{deposit-modal.d.mts → types/deposit/deposit-modal.types.d.mts} +3 -10
  57. package/dist/{deposit-modal.d.ts → types/deposit/deposit-modal.types.d.ts} +3 -10
  58. package/dist/types/deposit/index.d.mts +6 -0
  59. package/dist/types/deposit/index.d.ts +6 -0
  60. package/dist/types/deposit/steps/card-deposit.d.mts +7 -0
  61. package/dist/types/deposit/steps/card-deposit.d.ts +7 -0
  62. package/dist/types/deposit/steps/crypto-transfer.d.mts +7 -0
  63. package/dist/types/deposit/steps/crypto-transfer.d.ts +7 -0
  64. package/dist/types/deposit/steps/deposit-method.d.mts +7 -0
  65. package/dist/types/deposit/steps/deposit-method.d.ts +7 -0
  66. package/dist/types/deposit/steps/kalshi-deposit.d.mts +5 -0
  67. package/dist/types/deposit/steps/kalshi-deposit.d.ts +5 -0
  68. package/dist/types/deposit/steps/venue-selection.d.mts +7 -0
  69. package/dist/types/deposit/steps/venue-selection.d.ts +7 -0
  70. package/dist/types/events/index.d.mts +4 -0
  71. package/dist/types/events/index.d.ts +4 -0
  72. package/dist/types/events/item/event-list-item.constants.d.mts +1 -0
  73. package/dist/types/events/item/event-list-item.constants.d.ts +1 -0
  74. package/dist/types/events/item/event-list-item.types.d.mts +46 -0
  75. package/dist/types/events/item/event-list-item.types.d.ts +46 -0
  76. package/dist/types/events/item/event-list-item.utils.d.mts +23 -0
  77. package/dist/types/events/item/event-list-item.utils.d.ts +23 -0
  78. package/dist/types/events/item/index.d.mts +6 -0
  79. package/dist/types/events/item/index.d.ts +6 -0
  80. package/dist/types/events/item-details/event-list-item-details.constants.d.mts +10 -0
  81. package/dist/types/events/item-details/event-list-item-details.constants.d.ts +10 -0
  82. package/dist/types/events/item-details/event-list-item-details.types.d.mts +53 -0
  83. package/dist/types/events/item-details/event-list-item-details.types.d.ts +53 -0
  84. package/dist/types/events/item-details/event-list-item-details.utils.d.mts +26 -0
  85. package/dist/types/events/item-details/event-list-item-details.utils.d.ts +26 -0
  86. package/dist/types/events/item-details/index.d.mts +6 -0
  87. package/dist/types/events/item-details/index.d.ts +6 -0
  88. package/dist/types/events/list/event-list.constants.d.mts +3 -0
  89. package/dist/types/events/list/event-list.constants.d.ts +3 -0
  90. package/dist/types/events/list/event-list.types.d.mts +21 -0
  91. package/dist/types/events/list/event-list.types.d.ts +21 -0
  92. package/dist/types/events/list/event-list.utils.d.mts +6 -0
  93. package/dist/types/events/list/event-list.utils.d.ts +6 -0
  94. package/dist/types/events/list/index.d.mts +6 -0
  95. package/dist/types/events/list/index.d.ts +6 -0
  96. package/dist/types/events/market-details/index.d.mts +6 -0
  97. package/dist/types/events/market-details/index.d.ts +6 -0
  98. package/dist/types/events/market-details/market-details.constants.d.mts +9 -0
  99. package/dist/types/events/market-details/market-details.constants.d.ts +9 -0
  100. package/dist/types/events/market-details/market-details.types.d.mts +63 -0
  101. package/dist/types/events/market-details/market-details.types.d.ts +63 -0
  102. package/dist/types/events/market-details/market-details.utils.d.mts +46 -0
  103. package/dist/types/events/market-details/market-details.utils.d.ts +46 -0
  104. package/dist/types/index.d.mts +9 -0
  105. package/dist/types/index.d.ts +9 -0
  106. package/dist/types/modals/index.d.mts +4 -0
  107. package/dist/types/modals/index.d.ts +4 -0
  108. package/dist/types/onboarding/index.d.mts +11 -0
  109. package/dist/types/onboarding/index.d.ts +11 -0
  110. package/dist/types/onboarding/onboarding-modal.constants.d.mts +10 -0
  111. package/dist/types/onboarding/onboarding-modal.constants.d.ts +10 -0
  112. package/dist/types/onboarding/onboarding-modal.types.d.mts +55 -0
  113. package/dist/types/onboarding/onboarding-modal.types.d.ts +55 -0
  114. package/dist/types/onboarding/steps/connect-accounts.d.mts +5 -0
  115. package/dist/types/onboarding/steps/connect-accounts.d.ts +5 -0
  116. package/dist/types/onboarding/steps/connect-kalshi-modal.d.mts +5 -0
  117. package/dist/types/onboarding/steps/connect-kalshi-modal.d.ts +5 -0
  118. package/dist/types/onboarding/steps/connect-onchain-modal.d.mts +5 -0
  119. package/dist/types/onboarding/steps/connect-onchain-modal.d.ts +5 -0
  120. package/dist/types/onboarding/steps/how-it-works.d.mts +5 -0
  121. package/dist/types/onboarding/steps/how-it-works.d.ts +5 -0
  122. package/dist/types/onboarding/steps/profile-setup.d.mts +5 -0
  123. package/dist/types/onboarding/steps/profile-setup.d.ts +5 -0
  124. package/dist/types/pages/event-market/event-market.types.d.mts +42 -0
  125. package/dist/types/pages/event-market/event-market.types.d.ts +42 -0
  126. package/dist/types/pages/event-market/index.d.mts +6 -0
  127. package/dist/types/pages/event-market/index.d.ts +6 -0
  128. package/dist/types/pages/home/home.constants.d.mts +8 -0
  129. package/dist/types/pages/home/home.constants.d.ts +8 -0
  130. package/dist/{home-page.d.ts → types/pages/home/home.types.d.mts} +8 -18
  131. package/dist/{home-page.d.mts → types/pages/home/home.types.d.ts} +8 -18
  132. package/dist/types/pages/home/home.utils.d.mts +3 -0
  133. package/dist/types/pages/home/home.utils.d.ts +3 -0
  134. package/dist/types/pages/home/index.d.mts +6 -0
  135. package/dist/types/pages/home/index.d.ts +6 -0
  136. package/dist/types/pages/index.d.mts +3 -0
  137. package/dist/types/pages/index.d.ts +3 -0
  138. package/dist/types/pages/user-profile/components/activity-row.d.mts +10 -0
  139. package/dist/types/pages/user-profile/components/activity-row.d.ts +10 -0
  140. package/dist/types/pages/user-profile/components/balance-display.d.mts +12 -0
  141. package/dist/types/pages/user-profile/components/balance-display.d.ts +12 -0
  142. package/dist/types/pages/user-profile/components/balances-card.d.mts +12 -0
  143. package/dist/types/pages/user-profile/components/balances-card.d.ts +12 -0
  144. package/dist/types/pages/user-profile/components/default-avatar.d.mts +8 -0
  145. package/dist/types/pages/user-profile/components/default-avatar.d.ts +8 -0
  146. package/dist/types/pages/user-profile/components/empty-state.d.mts +10 -0
  147. package/dist/types/pages/user-profile/components/empty-state.d.ts +10 -0
  148. package/dist/types/pages/user-profile/components/position-row.d.mts +10 -0
  149. package/dist/types/pages/user-profile/components/position-row.d.ts +10 -0
  150. package/dist/types/pages/user-profile/components/positions-activity.d.mts +14 -0
  151. package/dist/types/pages/user-profile/components/positions-activity.d.ts +14 -0
  152. package/dist/types/pages/user-profile/components/user-info-card.d.mts +11 -0
  153. package/dist/types/pages/user-profile/components/user-info-card.d.ts +11 -0
  154. package/dist/types/pages/user-profile/index.d.mts +6 -0
  155. package/dist/types/pages/user-profile/index.d.ts +6 -0
  156. package/dist/types/pages/user-profile/user-profile.constants.d.mts +9 -0
  157. package/dist/types/pages/user-profile/user-profile.constants.d.ts +9 -0
  158. package/dist/{user-profile-page.d.ts → types/pages/user-profile/user-profile.types.d.mts} +12 -22
  159. package/dist/{user-profile-page.d.mts → types/pages/user-profile/user-profile.types.d.ts} +12 -22
  160. package/dist/types/primitives/badge/badge.constants.d.mts +4 -0
  161. package/dist/types/primitives/badge/badge.constants.d.ts +4 -0
  162. package/dist/types/primitives/badge/badge.types.d.mts +18 -0
  163. package/dist/types/primitives/badge/badge.types.d.ts +18 -0
  164. package/dist/types/primitives/badge/index.d.mts +7 -0
  165. package/dist/types/primitives/badge/index.d.ts +7 -0
  166. package/dist/types/primitives/button/button.constants.d.mts +6 -0
  167. package/dist/types/primitives/button/button.constants.d.ts +6 -0
  168. package/dist/types/primitives/button/button.types.d.mts +12 -0
  169. package/dist/types/primitives/button/button.types.d.ts +12 -0
  170. package/dist/types/primitives/button/index.d.mts +6 -0
  171. package/dist/types/primitives/button/index.d.ts +6 -0
  172. package/dist/types/primitives/card/card.types.d.mts +3 -0
  173. package/dist/types/primitives/card/card.types.d.ts +3 -0
  174. package/dist/types/primitives/card/index.d.mts +6 -0
  175. package/dist/types/primitives/card/index.d.ts +6 -0
  176. package/dist/{chart.d.mts → types/primitives/chart/index.d.mts} +7 -10
  177. package/dist/{chart.d.ts → types/primitives/chart/index.d.ts} +7 -10
  178. package/dist/types/primitives/hello-world.d.mts +4 -0
  179. package/dist/types/primitives/hello-world.d.ts +4 -0
  180. package/dist/types/primitives/icon/icon.constants.d.mts +2 -0
  181. package/dist/types/primitives/icon/icon.constants.d.ts +2 -0
  182. package/dist/types/primitives/icon/icon.types.d.mts +9 -0
  183. package/dist/types/primitives/icon/icon.types.d.ts +9 -0
  184. package/dist/types/primitives/icon/icon.utils.d.mts +2 -0
  185. package/dist/types/primitives/icon/icon.utils.d.ts +2 -0
  186. package/dist/types/primitives/icon/index.d.mts +46 -0
  187. package/dist/types/primitives/icon/index.d.ts +46 -0
  188. package/dist/types/primitives/icon/registry.d.mts +166 -0
  189. package/dist/types/primitives/icon/registry.d.ts +166 -0
  190. package/dist/types/primitives/icon/svg/arrow-trend-up.d.mts +5 -0
  191. package/dist/types/primitives/icon/svg/arrow-trend-up.d.ts +5 -0
  192. package/dist/types/primitives/icon/svg/arrows-to-dot.d.mts +5 -0
  193. package/dist/types/primitives/icon/svg/arrows-to-dot.d.ts +5 -0
  194. package/dist/types/primitives/icon/svg/bank.d.mts +5 -0
  195. package/dist/types/primitives/icon/svg/bank.d.ts +5 -0
  196. package/dist/types/primitives/icon/svg/best-prices.d.mts +5 -0
  197. package/dist/types/primitives/icon/svg/best-prices.d.ts +5 -0
  198. package/dist/types/primitives/icon/svg/bolt.d.mts +5 -0
  199. package/dist/types/primitives/icon/svg/bolt.d.ts +5 -0
  200. package/dist/types/primitives/icon/svg/check-badge.d.mts +5 -0
  201. package/dist/types/primitives/icon/svg/check-badge.d.ts +5 -0
  202. package/dist/types/primitives/icon/svg/check-circle.d.mts +5 -0
  203. package/dist/types/primitives/icon/svg/check-circle.d.ts +5 -0
  204. package/dist/types/primitives/icon/svg/chevron-down.d.mts +5 -0
  205. package/dist/types/primitives/icon/svg/chevron-down.d.ts +5 -0
  206. package/dist/types/primitives/icon/svg/chevron-left.d.mts +5 -0
  207. package/dist/types/primitives/icon/svg/chevron-left.d.ts +5 -0
  208. package/dist/types/primitives/icon/svg/chevron-right.d.mts +5 -0
  209. package/dist/types/primitives/icon/svg/chevron-right.d.ts +5 -0
  210. package/dist/types/primitives/icon/svg/chevron-up.d.mts +5 -0
  211. package/dist/types/primitives/icon/svg/chevron-up.d.ts +5 -0
  212. package/dist/types/primitives/icon/svg/close.d.mts +5 -0
  213. package/dist/types/primitives/icon/svg/close.d.ts +5 -0
  214. package/dist/types/primitives/icon/svg/copy.d.mts +5 -0
  215. package/dist/types/primitives/icon/svg/copy.d.ts +5 -0
  216. package/dist/types/primitives/icon/svg/create-account.d.mts +5 -0
  217. package/dist/types/primitives/icon/svg/create-account.d.ts +5 -0
  218. package/dist/types/primitives/icon/svg/credit-card.d.mts +5 -0
  219. package/dist/types/primitives/icon/svg/credit-card.d.ts +5 -0
  220. package/dist/types/primitives/icon/svg/disconnect.d.mts +5 -0
  221. package/dist/types/primitives/icon/svg/disconnect.d.ts +5 -0
  222. package/dist/types/primitives/icon/svg/discord.d.mts +5 -0
  223. package/dist/types/primitives/icon/svg/discord.d.ts +5 -0
  224. package/dist/types/primitives/icon/svg/document.d.mts +5 -0
  225. package/dist/types/primitives/icon/svg/document.d.ts +5 -0
  226. package/dist/types/primitives/icon/svg/dots-horizontal.d.mts +5 -0
  227. package/dist/types/primitives/icon/svg/dots-horizontal.d.ts +5 -0
  228. package/dist/types/primitives/icon/svg/download.d.mts +5 -0
  229. package/dist/types/primitives/icon/svg/download.d.ts +5 -0
  230. package/dist/types/primitives/icon/svg/email.d.mts +5 -0
  231. package/dist/types/primitives/icon/svg/email.d.ts +5 -0
  232. package/dist/types/primitives/icon/svg/external-link.d.mts +5 -0
  233. package/dist/types/primitives/icon/svg/external-link.d.ts +5 -0
  234. package/dist/types/primitives/icon/svg/info.d.mts +5 -0
  235. package/dist/types/primitives/icon/svg/info.d.ts +5 -0
  236. package/dist/types/primitives/icon/svg/link-accounts.d.mts +5 -0
  237. package/dist/types/primitives/icon/svg/link-accounts.d.ts +5 -0
  238. package/dist/types/primitives/icon/svg/pencil.d.mts +5 -0
  239. package/dist/types/primitives/icon/svg/pencil.d.ts +5 -0
  240. package/dist/types/primitives/icon/svg/play-square.d.mts +5 -0
  241. package/dist/types/primitives/icon/svg/play-square.d.ts +5 -0
  242. package/dist/types/primitives/icon/svg/profile.d.mts +5 -0
  243. package/dist/types/primitives/icon/svg/profile.d.ts +5 -0
  244. package/dist/types/primitives/icon/svg/revenue-alt.d.mts +5 -0
  245. package/dist/types/primitives/icon/svg/revenue-alt.d.ts +5 -0
  246. package/dist/types/primitives/icon/svg/search.d.mts +5 -0
  247. package/dist/types/primitives/icon/svg/search.d.ts +5 -0
  248. package/dist/types/primitives/icon/svg/shield-trust.d.mts +5 -0
  249. package/dist/types/primitives/icon/svg/shield-trust.d.ts +5 -0
  250. package/dist/types/primitives/icon/svg/stay-in-control.d.mts +5 -0
  251. package/dist/types/primitives/icon/svg/stay-in-control.d.ts +5 -0
  252. package/dist/types/primitives/icon/svg/telegram.d.mts +5 -0
  253. package/dist/types/primitives/icon/svg/telegram.d.ts +5 -0
  254. package/dist/types/primitives/icon/svg/triangle-down.d.mts +5 -0
  255. package/dist/types/primitives/icon/svg/triangle-down.d.ts +5 -0
  256. package/dist/types/primitives/icon/svg/triangle-up-filled.d.mts +5 -0
  257. package/dist/types/primitives/icon/svg/triangle-up-filled.d.ts +5 -0
  258. package/dist/types/primitives/icon/svg/triangle-up.d.mts +5 -0
  259. package/dist/types/primitives/icon/svg/triangle-up.d.ts +5 -0
  260. package/dist/types/primitives/icon/svg/twitter.d.mts +5 -0
  261. package/dist/types/primitives/icon/svg/twitter.d.ts +5 -0
  262. package/dist/types/primitives/icon/svg/upload.d.mts +5 -0
  263. package/dist/types/primitives/icon/svg/upload.d.ts +5 -0
  264. package/dist/types/primitives/icon/svg/wallet-avatar.d.mts +5 -0
  265. package/dist/types/primitives/icon/svg/wallet-avatar.d.ts +5 -0
  266. package/dist/types/primitives/icon/svg/wallet.d.mts +5 -0
  267. package/dist/types/primitives/icon/svg/wallet.d.ts +5 -0
  268. package/dist/types/primitives/icon/svg/warning-filled.d.mts +5 -0
  269. package/dist/types/primitives/icon/svg/warning-filled.d.ts +5 -0
  270. package/dist/types/primitives/icon/svg/warning.d.mts +5 -0
  271. package/dist/types/primitives/icon/svg/warning.d.ts +5 -0
  272. package/dist/types/primitives/icon/types.d.mts +5 -0
  273. package/dist/types/primitives/icon/types.d.ts +5 -0
  274. package/dist/types/primitives/index.d.mts +17 -0
  275. package/dist/types/primitives/index.d.ts +17 -0
  276. package/dist/types/primitives/loading-icon/index.d.mts +11 -0
  277. package/dist/types/primitives/loading-icon/index.d.ts +11 -0
  278. package/dist/types/primitives/modal/index.d.mts +10 -0
  279. package/dist/types/primitives/modal/index.d.ts +10 -0
  280. package/dist/types/primitives/modal/modal.types.d.mts +54 -0
  281. package/dist/types/primitives/modal/modal.types.d.ts +54 -0
  282. package/dist/{number-value.d.mts → types/primitives/number-value.d.mts} +3 -5
  283. package/dist/{number-value.d.ts → types/primitives/number-value.d.ts} +3 -5
  284. package/dist/types/primitives/search/index.d.mts +6 -0
  285. package/dist/types/primitives/search/index.d.ts +6 -0
  286. package/dist/types/primitives/search/search-empty-icon.d.mts +5 -0
  287. package/dist/types/primitives/search/search-empty-icon.d.ts +5 -0
  288. package/dist/types/primitives/search/search.types.d.mts +96 -0
  289. package/dist/types/primitives/search/search.types.d.ts +96 -0
  290. package/dist/{select.d.mts → types/primitives/select/index.d.mts} +3 -5
  291. package/dist/{select.d.ts → types/primitives/select/index.d.ts} +3 -5
  292. package/dist/types/primitives/skeleton/index.d.mts +7 -0
  293. package/dist/types/primitives/skeleton/index.d.ts +7 -0
  294. package/dist/types/primitives/skeleton/skeleton-block.d.mts +8 -0
  295. package/dist/types/primitives/skeleton/skeleton-block.d.ts +8 -0
  296. package/dist/{skeleton.d.mts → types/primitives/skeleton/skeleton.types.d.mts} +6 -9
  297. package/dist/{skeleton.d.ts → types/primitives/skeleton/skeleton.types.d.ts} +6 -9
  298. package/dist/types/primitives/skeleton/views/event-list-item-details-skeleton-view.d.mts +5 -0
  299. package/dist/types/primitives/skeleton/views/event-list-item-details-skeleton-view.d.ts +5 -0
  300. package/dist/types/primitives/skeleton/views/event-list-item-skeleton-view.d.mts +9 -0
  301. package/dist/types/primitives/skeleton/views/event-list-item-skeleton-view.d.ts +9 -0
  302. package/dist/types/primitives/skeleton/views/event-list-skeleton-view.d.mts +5 -0
  303. package/dist/types/primitives/skeleton/views/event-list-skeleton-view.d.ts +5 -0
  304. package/dist/types/primitives/skeleton/views/market-details-skeleton-view.d.mts +12 -0
  305. package/dist/types/primitives/skeleton/views/market-details-skeleton-view.d.ts +12 -0
  306. package/dist/types/primitives/skeleton/views/place-order-skeleton-view.d.mts +5 -0
  307. package/dist/types/primitives/skeleton/views/place-order-skeleton-view.d.ts +5 -0
  308. package/dist/types/primitives/skeleton/views/settlement-skeleton-view.d.mts +5 -0
  309. package/dist/types/primitives/skeleton/views/settlement-skeleton-view.d.ts +5 -0
  310. package/dist/{state-message.d.mts → types/primitives/state-message/index.d.mts} +2 -3
  311. package/dist/{state-message.d.ts → types/primitives/state-message/index.d.ts} +2 -3
  312. package/dist/{switch-button.d.mts → types/primitives/switch-button/index.d.mts} +4 -7
  313. package/dist/{switch-button.d.ts → types/primitives/switch-button/index.d.ts} +4 -7
  314. package/dist/types/primitives/tabs/index.d.mts +6 -0
  315. package/dist/types/primitives/tabs/index.d.ts +6 -0
  316. package/dist/types/primitives/tabs/tabs.types.d.mts +24 -0
  317. package/dist/types/primitives/tabs/tabs.types.d.ts +24 -0
  318. package/dist/types/primitives/tabs/tabs.utils.d.mts +14 -0
  319. package/dist/types/primitives/tabs/tabs.utils.d.ts +14 -0
  320. package/dist/types/primitives/typography/index.d.mts +7 -0
  321. package/dist/types/primitives/typography/index.d.ts +7 -0
  322. package/dist/types/primitives/typography/typography.constants.d.mts +3 -0
  323. package/dist/types/primitives/typography/typography.constants.d.ts +3 -0
  324. package/dist/types/primitives/typography/typography.types.d.mts +8 -0
  325. package/dist/types/primitives/typography/typography.types.d.ts +8 -0
  326. package/dist/types/primitives/venue-logo/index.d.mts +8 -0
  327. package/dist/types/primitives/venue-logo/index.d.ts +8 -0
  328. package/dist/types/primitives/venue-logo/logo-props.d.mts +10 -0
  329. package/dist/types/primitives/venue-logo/logo-props.d.ts +10 -0
  330. package/dist/types/primitives/venue-logo/svg/logo-kalshi.d.mts +5 -0
  331. package/dist/types/primitives/venue-logo/svg/logo-kalshi.d.ts +5 -0
  332. package/dist/types/primitives/venue-logo/svg/logo-opinion.d.mts +5 -0
  333. package/dist/types/primitives/venue-logo/svg/logo-opinion.d.ts +5 -0
  334. package/dist/types/primitives/venue-logo/svg/logo-polymarket.d.mts +5 -0
  335. package/dist/types/primitives/venue-logo/svg/logo-polymarket.d.ts +5 -0
  336. package/dist/types/primitives/venue-logo/svg/logo-probable.d.mts +5 -0
  337. package/dist/types/primitives/venue-logo/svg/logo-probable.d.ts +5 -0
  338. package/dist/types/primitives/venue-logo/venue-logo.constants.d.mts +9 -0
  339. package/dist/types/primitives/venue-logo/venue-logo.constants.d.ts +9 -0
  340. package/dist/types/primitives/venue-logo/venue-logo.types.d.mts +17 -0
  341. package/dist/types/primitives/venue-logo/venue-logo.types.d.ts +17 -0
  342. package/dist/types/profile/index.d.mts +6 -0
  343. package/dist/types/profile/index.d.ts +6 -0
  344. package/dist/types/profile/profile-modal.constants.d.mts +17 -0
  345. package/dist/types/profile/profile-modal.constants.d.ts +17 -0
  346. package/dist/{profile-modal.d.mts → types/profile/profile-modal.types.d.mts} +4 -11
  347. package/dist/{profile-modal.d.ts → types/profile/profile-modal.types.d.ts} +4 -11
  348. package/dist/types/profile/tabs/about-tab.d.mts +16 -0
  349. package/dist/types/profile/tabs/about-tab.d.ts +16 -0
  350. package/dist/types/profile/tabs/accounts-wallets-tab.d.mts +18 -0
  351. package/dist/types/profile/tabs/accounts-wallets-tab.d.ts +18 -0
  352. package/dist/types/shared/constants.d.mts +23 -0
  353. package/dist/types/shared/constants.d.ts +23 -0
  354. package/dist/types/shared/query-error.d.mts +2 -0
  355. package/dist/types/shared/query-error.d.ts +2 -0
  356. package/dist/types/shared/types.d.mts +1 -0
  357. package/dist/types/shared/types.d.ts +1 -0
  358. package/dist/types/shared/utils.d.mts +15 -0
  359. package/dist/types/shared/utils.d.ts +15 -0
  360. package/dist/types/trading/index.d.mts +4 -0
  361. package/dist/types/trading/index.d.ts +4 -0
  362. package/dist/{place-order.d.ts → types/trading/place-order/index.d.mts} +3 -7
  363. package/dist/{place-order.d.mts → types/trading/place-order/index.d.ts} +3 -7
  364. package/dist/{settlement.d.ts → types/trading/settlement/index.d.mts} +3 -7
  365. package/dist/{settlement.d.mts → types/trading/settlement/index.d.ts} +3 -7
  366. package/dist/{types-BImwqY4o.d.ts → types/trading/types.d.mts} +35 -38
  367. package/dist/{types-BImwqY4o.d.mts → types/trading/types.d.ts} +35 -38
  368. package/dist/types/trading/utils.d.mts +16 -0
  369. package/dist/types/trading/utils.d.ts +16 -0
  370. package/dist/types/withdraw/index.d.mts +6 -0
  371. package/dist/types/withdraw/index.d.ts +6 -0
  372. package/dist/types/withdraw/steps/kalshi-withdraw.d.mts +5 -0
  373. package/dist/types/withdraw/steps/kalshi-withdraw.d.ts +5 -0
  374. package/dist/types/withdraw/steps/venue-selection.d.mts +6 -0
  375. package/dist/types/withdraw/steps/venue-selection.d.ts +6 -0
  376. package/dist/types/withdraw/steps/withdraw-amount.d.mts +8 -0
  377. package/dist/types/withdraw/steps/withdraw-amount.d.ts +8 -0
  378. package/dist/types/withdraw/steps/withdraw-method.d.mts +7 -0
  379. package/dist/types/withdraw/steps/withdraw-method.d.ts +7 -0
  380. package/dist/types/withdraw/withdraw-modal.constants.d.mts +9 -0
  381. package/dist/types/withdraw/withdraw-modal.constants.d.ts +9 -0
  382. package/dist/{withdraw-modal.d.mts → types/withdraw/withdraw-modal.types.d.mts} +3 -10
  383. package/dist/{withdraw-modal.d.ts → types/withdraw/withdraw-modal.types.d.ts} +3 -10
  384. package/package.json +33 -283
  385. package/dist/badge.d.mts +0 -28
  386. package/dist/badge.d.ts +0 -28
  387. package/dist/badge.js +0 -110
  388. package/dist/badge.mjs +0 -9
  389. package/dist/button.d.mts +0 -20
  390. package/dist/button.d.ts +0 -20
  391. package/dist/button.js +0 -183
  392. package/dist/button.mjs +0 -8
  393. package/dist/card.d.mts +0 -10
  394. package/dist/card.d.ts +0 -10
  395. package/dist/card.js +0 -88
  396. package/dist/card.mjs +0 -7
  397. package/dist/chart.mjs +0 -8
  398. package/dist/chunk-34IRJYSU.mjs +0 -146
  399. package/dist/chunk-3QLOUBDJ.mjs +0 -483
  400. package/dist/chunk-3W7NBJLU.mjs +0 -371
  401. package/dist/chunk-4343LYSH.mjs +0 -45
  402. package/dist/chunk-4S3I6X7F.mjs +0 -855
  403. package/dist/chunk-4VUDTWH7.mjs +0 -42
  404. package/dist/chunk-6JG6I5AY.mjs +0 -654
  405. package/dist/chunk-BNDFQPHF.mjs +0 -9
  406. package/dist/chunk-CTYJVVHJ.mjs +0 -334
  407. package/dist/chunk-DHBHKIJR.mjs +0 -1049
  408. package/dist/chunk-ERGNR6UQ.mjs +0 -67
  409. package/dist/chunk-FO263M3V.mjs +0 -10
  410. package/dist/chunk-FO2QCB4Z.mjs +0 -35
  411. package/dist/chunk-GFBF2J3Y.mjs +0 -328
  412. package/dist/chunk-GJ4U5NCE.mjs +0 -134
  413. package/dist/chunk-K6IJ4WBM.mjs +0 -67
  414. package/dist/chunk-KAGYJ4XT.mjs +0 -126
  415. package/dist/chunk-KIYMVWL4.mjs +0 -280
  416. package/dist/chunk-LCZKSITC.mjs +0 -162
  417. package/dist/chunk-M4RJHRFT.mjs +0 -445
  418. package/dist/chunk-MJHKBCXQ.mjs +0 -379
  419. package/dist/chunk-MKVGQ7AS.mjs +0 -168
  420. package/dist/chunk-NDG43KGL.mjs +0 -44
  421. package/dist/chunk-NH2G3POM.mjs +0 -470
  422. package/dist/chunk-OBCHURW5.mjs +0 -64
  423. package/dist/chunk-OJVTGNIF.mjs +0 -230
  424. package/dist/chunk-PORVP72S.mjs +0 -277
  425. package/dist/chunk-Q6DGDBPV.mjs +0 -774
  426. package/dist/chunk-QLMVKLNJ.mjs +0 -669
  427. package/dist/chunk-S3H63TQ5.mjs +0 -537
  428. package/dist/chunk-T7TATHPD.mjs +0 -313
  429. package/dist/chunk-XUCS575S.mjs +0 -65
  430. package/dist/chunk-ZFMCCBP6.mjs +0 -25
  431. package/dist/connect-button.mjs +0 -14
  432. package/dist/deposit-modal.mjs +0 -15
  433. package/dist/event-list-item-details.d.mts +0 -11
  434. package/dist/event-list-item-details.d.ts +0 -11
  435. package/dist/event-list-item-details.js +0 -3711
  436. package/dist/event-list-item-details.mjs +0 -23
  437. package/dist/event-list-item-details.types-CMbXOrT-.d.ts +0 -53
  438. package/dist/event-list-item-details.types-DekJKeMD.d.mts +0 -53
  439. package/dist/event-list-item.d.mts +0 -10
  440. package/dist/event-list-item.d.ts +0 -10
  441. package/dist/event-list-item.js +0 -2821
  442. package/dist/event-list-item.mjs +0 -20
  443. package/dist/event-list-item.types-Y6IeJ4e4.d.mts +0 -46
  444. package/dist/event-list-item.types-Y6IeJ4e4.d.ts +0 -46
  445. package/dist/event-list.d.mts +0 -9
  446. package/dist/event-list.d.ts +0 -9
  447. package/dist/event-list.mjs +0 -23
  448. package/dist/event-list.types-CkAAUqwW.d.mts +0 -13
  449. package/dist/event-list.types-CkAAUqwW.d.ts +0 -13
  450. package/dist/event-market-page.d.mts +0 -52
  451. package/dist/event-market-page.d.ts +0 -52
  452. package/dist/event-market-page.mjs +0 -30
  453. package/dist/hello-world.d.mts +0 -8
  454. package/dist/hello-world.d.ts +0 -8
  455. package/dist/hello-world.js +0 -92
  456. package/dist/hello-world.mjs +0 -8
  457. package/dist/home-page.mjs +0 -24
  458. package/dist/icon.d.mts +0 -193
  459. package/dist/icon.d.ts +0 -193
  460. package/dist/icon.js +0 -1465
  461. package/dist/loading-icon.d.mts +0 -14
  462. package/dist/loading-icon.d.ts +0 -14
  463. package/dist/loading-icon.js +0 -112
  464. package/dist/loading-icon.mjs +0 -8
  465. package/dist/market-details.d.mts +0 -73
  466. package/dist/market-details.d.ts +0 -73
  467. package/dist/market-details.mjs +0 -24
  468. package/dist/modal.d.mts +0 -66
  469. package/dist/modal.d.ts +0 -66
  470. package/dist/modal.js +0 -321
  471. package/dist/modal.mjs +0 -9
  472. package/dist/number-value.js +0 -67
  473. package/dist/number-value.mjs +0 -7
  474. package/dist/onboarding-modal.d.mts +0 -88
  475. package/dist/onboarding-modal.d.ts +0 -88
  476. package/dist/onboarding-modal.js +0 -2836
  477. package/dist/onboarding-modal.mjs +0 -24
  478. package/dist/place-order.js +0 -3248
  479. package/dist/place-order.mjs +0 -18
  480. package/dist/profile-modal.js +0 -2447
  481. package/dist/profile-modal.mjs +0 -14
  482. package/dist/registry-DfSCFAdC.d.mts +0 -178
  483. package/dist/registry-DfSCFAdC.d.ts +0 -178
  484. package/dist/search.d.mts +0 -51
  485. package/dist/search.d.ts +0 -51
  486. package/dist/search.js +0 -1957
  487. package/dist/search.mjs +0 -13
  488. package/dist/select.js +0 -1552
  489. package/dist/select.mjs +0 -11
  490. package/dist/settlement.js +0 -2445
  491. package/dist/settlement.mjs +0 -15
  492. package/dist/skeleton.js +0 -490
  493. package/dist/skeleton.mjs +0 -10
  494. package/dist/state-message.js +0 -1629
  495. package/dist/state-message.mjs +0 -14
  496. package/dist/switch-button.js +0 -191
  497. package/dist/switch-button.mjs +0 -7
  498. package/dist/tabs.d.mts +0 -31
  499. package/dist/tabs.d.ts +0 -31
  500. package/dist/tabs.js +0 -2078
  501. package/dist/tabs.mjs +0 -12
  502. package/dist/types-BVj9ky9P.d.mts +0 -3
  503. package/dist/types-BVj9ky9P.d.ts +0 -3
  504. package/dist/typography.d.mts +0 -18
  505. package/dist/typography.d.ts +0 -18
  506. package/dist/typography.js +0 -93
  507. package/dist/typography.mjs +0 -9
  508. package/dist/user-profile-page.js +0 -3081
  509. package/dist/user-profile-page.mjs +0 -15
  510. package/dist/venue-logo.d.mts +0 -13
  511. package/dist/venue-logo.d.ts +0 -13
  512. package/dist/venue-logo.js +0 -323
  513. package/dist/venue-logo.mjs +0 -10
  514. package/dist/venue-logo.types-CGUc22ly.d.mts +0 -19
  515. package/dist/venue-logo.types-Dqr39S1-.d.ts +0 -19
  516. package/dist/withdraw-modal.js +0 -2449
  517. package/dist/withdraw-modal.mjs +0 -14
@@ -56,12 +56,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
56
56
  ));
57
57
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
58
 
59
- // src/pages/home/index.tsx
60
- var home_exports = {};
61
- __export(home_exports, {
62
- HomePage: () => HomePage
59
+ // src/pages/index.ts
60
+ var pages_exports = {};
61
+ __export(pages_exports, {
62
+ EventMarketPage: () => EventMarketPage,
63
+ HomePage: () => HomePage,
64
+ UserProfilePage: () => UserProfilePage
63
65
  });
64
- module.exports = __toCommonJS(home_exports);
66
+ module.exports = __toCommonJS(pages_exports);
67
+
68
+ // src/pages/home/index.tsx
65
69
  var import_react5 = require("react");
66
70
  var import_hooks15 = require("@agg-market/hooks");
67
71
 
@@ -1552,6 +1556,21 @@ var import_hooks5 = require("@agg-market/hooks");
1552
1556
 
1553
1557
  // src/events/item-details/event-list-item-details.constants.ts
1554
1558
  var detailsBaseCardClassName = "w-full overflow-hidden gap-6 p-5 md:gap-8 md:p-10";
1559
+ var eventListItemDetailsTimeRanges = [
1560
+ "1H",
1561
+ "6H",
1562
+ "1D",
1563
+ "1W",
1564
+ "1M",
1565
+ "ALL"
1566
+ ];
1567
+ var lineColorByVenue = {
1568
+ polymarket: "#2e5cff",
1569
+ kalshi: "#00d295",
1570
+ probable: "#f05923",
1571
+ opinion: "#020205"
1572
+ };
1573
+ var fallbackLineColors = ["#2e5cff", "#00d295", "#f05923", "#020205"];
1555
1574
 
1556
1575
  // src/primitives/skeleton/views/event-list-item-details-skeleton-view.tsx
1557
1576
  var import_jsx_runtime47 = require("react/jsx-runtime");
@@ -1600,6 +1619,14 @@ var import_hooks6 = require("@agg-market/hooks");
1600
1619
 
1601
1620
  // src/events/market-details/market-details.constants.ts
1602
1621
  var marketDetailsBaseCardClassName = "w-full overflow-hidden rounded-agg-lg border border-agg-separator bg-agg-secondary text-agg-foreground shadow-none hover:shadow-none";
1622
+ var getMarketDetailsTabs = (labels) => {
1623
+ return [
1624
+ { value: "order-book", label: labels.marketDetails.tabs.orderBook },
1625
+ { value: "graph", label: labels.marketDetails.tabs.graph }
1626
+ ];
1627
+ };
1628
+ var marketDetailsDefaultIsOpened = false;
1629
+ var orderBookRowLimitDefault = 4;
1603
1630
 
1604
1631
  // src/primitives/skeleton/views/market-details-skeleton-view.tsx
1605
1632
  var import_jsx_runtime48 = require("react/jsx-runtime");
@@ -4060,7 +4087,3842 @@ var HomePage = ({
4060
4087
  ] });
4061
4088
  };
4062
4089
  HomePage.displayName = "HomePage";
4090
+
4091
+ // src/pages/event-market/index.tsx
4092
+ var import_react12 = require("react");
4093
+ var import_hooks23 = require("@agg-market/hooks");
4094
+ var import_dayjs6 = __toESM(require("dayjs"));
4095
+
4096
+ // src/events/item-details/index.tsx
4097
+ var import_react8 = require("react");
4098
+ var import_hooks18 = require("@agg-market/hooks");
4099
+
4100
+ // src/primitives/chart/index.tsx
4101
+ var import_dayjs2 = __toESM(require("dayjs"));
4102
+ var import_hooks17 = require("@agg-market/hooks");
4103
+ var import_react7 = require("react");
4104
+ var import_liveline = require("liveline");
4105
+
4106
+ // src/primitives/switch-button/index.tsx
4107
+ var import_react6 = require("react");
4108
+ var import_hooks16 = require("@agg-market/hooks");
4109
+ var import_jsx_runtime67 = require("react/jsx-runtime");
4110
+ var resolveActiveIndex = (options, value) => {
4111
+ const activeIndex = options.findIndex((option) => option.value === value);
4112
+ if (activeIndex >= 0)
4113
+ return activeIndex;
4114
+ return 0;
4115
+ };
4116
+ var resolveNextEnabledIndex = (options, currentIndex, direction) => {
4117
+ if (options.length <= 1)
4118
+ return currentIndex;
4119
+ const step = direction === "next" ? 1 : -1;
4120
+ for (let offset = 1; offset <= options.length; offset += 1) {
4121
+ const candidateIndex = (currentIndex + step * offset + options.length) % options.length;
4122
+ const candidate = options[candidateIndex];
4123
+ if (candidate && !candidate.disabled) {
4124
+ return candidateIndex;
4125
+ }
4126
+ }
4127
+ return currentIndex;
4128
+ };
4129
+ var SwitchButton = ({
4130
+ options,
4131
+ value,
4132
+ onValueChange,
4133
+ ariaLabel,
4134
+ className
4135
+ }) => {
4136
+ const { enableAnimations } = (0, import_hooks16.useSdkUiConfig)();
4137
+ const activeIndex = (0, import_react6.useMemo)(() => {
4138
+ return resolveActiveIndex(options, value);
4139
+ }, [options, value]);
4140
+ const [isAnimating, setIsAnimating] = (0, import_react6.useState)(false);
4141
+ const [lastAnimatedIndex, setLastAnimatedIndex] = (0, import_react6.useState)(activeIndex);
4142
+ (0, import_react6.useEffect)(() => {
4143
+ if (lastAnimatedIndex === activeIndex) {
4144
+ return;
4145
+ }
4146
+ setLastAnimatedIndex(activeIndex);
4147
+ if (!enableAnimations) {
4148
+ setIsAnimating(false);
4149
+ return;
4150
+ }
4151
+ setIsAnimating(true);
4152
+ const timeoutId = window.setTimeout(() => {
4153
+ setIsAnimating(false);
4154
+ }, 350);
4155
+ return () => {
4156
+ window.clearTimeout(timeoutId);
4157
+ };
4158
+ }, [activeIndex, enableAnimations, lastAnimatedIndex]);
4159
+ if (options.length === 0) {
4160
+ return null;
4161
+ }
4162
+ const handleKeyDown = (event, optionIndex) => {
4163
+ if ((event == null ? void 0 : event.key) !== "ArrowLeft" && (event == null ? void 0 : event.key) !== "ArrowRight") {
4164
+ return;
4165
+ }
4166
+ event == null ? void 0 : event.preventDefault();
4167
+ const nextOptionIndex = resolveNextEnabledIndex(
4168
+ options,
4169
+ optionIndex,
4170
+ event.key === "ArrowRight" ? "next" : "previous"
4171
+ );
4172
+ const nextOption = options[nextOptionIndex];
4173
+ if (!nextOption || nextOption.disabled) {
4174
+ return;
4175
+ }
4176
+ onValueChange(nextOption.value);
4177
+ };
4178
+ return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
4179
+ "div",
4180
+ {
4181
+ className: cn(
4182
+ "group/agg-switch",
4183
+ "inline-flex min-w-0 rounded-agg-full bg-agg-secondary-hover font-agg-sans",
4184
+ getMotionClassName(enableAnimations, "transition-background duration-200 ease-in-out"),
4185
+ "cursor-pointer hover:bg-agg-tertiary",
4186
+ className
4187
+ ),
4188
+ children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
4189
+ "div",
4190
+ {
4191
+ className: "relative grid min-w-0 flex-1 items-center",
4192
+ style: {
4193
+ gridTemplateColumns: `repeat(${options.length}, minmax(0, 1fr))`
4194
+ },
4195
+ role: "tablist",
4196
+ "aria-label": ariaLabel,
4197
+ children: [
4198
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
4199
+ "span",
4200
+ {
4201
+ className: cn(
4202
+ "pointer-events-none absolute inset-y-0 left-0 rounded-agg-full border-2 border-agg-primary bg-agg-secondary",
4203
+ getMotionClassName(
4204
+ enableAnimations,
4205
+ "transition-transform duration-500 ease-[cubic-bezier(0.77,0,0.175,1)]"
4206
+ )
4207
+ ),
4208
+ style: {
4209
+ width: `${100 / options.length}%`,
4210
+ transform: `translateX(${activeIndex * 100}%) scaleX(${isAnimating ? 1.08 : 1})`
4211
+ },
4212
+ "aria-hidden": "true"
4213
+ }
4214
+ ),
4215
+ options.map((option, optionIndex) => {
4216
+ var _a;
4217
+ const isActive = optionIndex === activeIndex;
4218
+ return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
4219
+ "button",
4220
+ {
4221
+ type: "button",
4222
+ role: "tab",
4223
+ "aria-selected": isActive,
4224
+ "aria-label": (_a = option.ariaLabel) != null ? _a : void 0,
4225
+ tabIndex: isActive ? 0 : -1,
4226
+ disabled: option.disabled,
4227
+ className: cn(
4228
+ "relative z-10 min-w-0 rounded-agg-full px-5 py-1.5 font-agg-sans text-agg-base leading-agg-6 text-agg-foreground",
4229
+ getMotionClassName(
4230
+ enableAnimations,
4231
+ "transition-[colors] duration-200 ease-in-out"
4232
+ ),
4233
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-2 focus-visible:ring-offset-agg-secondary-hover",
4234
+ "cursor-pointer disabled:cursor-not-allowed disabled:text-agg-muted-foreground",
4235
+ isActive ? "font-agg-bold" : "font-agg-normal"
4236
+ ),
4237
+ onClick: (e) => {
4238
+ e.preventDefault();
4239
+ e.stopPropagation();
4240
+ if (option.disabled || isActive)
4241
+ return;
4242
+ onValueChange(option.value);
4243
+ },
4244
+ onKeyDown: (event) => {
4245
+ handleKeyDown(event, optionIndex);
4246
+ },
4247
+ children: option.label
4248
+ },
4249
+ option.value
4250
+ );
4251
+ })
4252
+ ]
4253
+ }
4254
+ )
4255
+ }
4256
+ );
4257
+ };
4258
+ SwitchButton.displayName = "SwitchButton";
4259
+
4260
+ // src/primitives/chart/index.tsx
4261
+ var import_jsx_runtime68 = require("react/jsx-runtime");
4262
+ var normalizeSeries = (series) => {
4263
+ return series.map((seriesItem) => {
4264
+ const pointsByTime = /* @__PURE__ */ new Map();
4265
+ seriesItem.points.forEach((point) => {
4266
+ if (!Number.isFinite(point.time) || !Number.isFinite(point.value)) {
4267
+ return;
4268
+ }
4269
+ pointsByTime.set(Math.floor(point.time), point.value);
4270
+ });
4271
+ const sortedPoints = [...pointsByTime.entries()].sort((left, right) => left[0] - right[0]).map(([time, value]) => ({
4272
+ time,
4273
+ value
4274
+ }));
4275
+ return __spreadProps(__spreadValues({}, seriesItem), {
4276
+ points: sortedPoints
4277
+ });
4278
+ }).filter((seriesItem) => seriesItem.points.length > 0);
4279
+ };
4280
+ var defaultValueFormatter = (value) => {
4281
+ return `${Math.round(value)}%`;
4282
+ };
4283
+ var resolveTimeFormatter = (windowSeconds) => {
4284
+ return (timestamp) => {
4285
+ if (!Number.isFinite(timestamp))
4286
+ return "";
4287
+ if (windowSeconds <= 48 * 60 * 60) {
4288
+ return import_dayjs2.default.unix(timestamp).format("HH:mm");
4289
+ }
4290
+ if (windowSeconds <= 14 * 24 * 60 * 60) {
4291
+ return import_dayjs2.default.unix(timestamp).format("MMM D HH:mm");
4292
+ }
4293
+ return import_dayjs2.default.unix(timestamp).format("MMM D");
4294
+ };
4295
+ };
4296
+ var toLivelinePoints = (points) => {
4297
+ return points.map((point) => ({
4298
+ time: point.time,
4299
+ value: point.value
4300
+ }));
4301
+ };
4302
+ var resolveWindowSeconds = (normalizedSeries) => {
4303
+ const timestamps = normalizedSeries.flatMap(
4304
+ (seriesItem) => seriesItem.points.map((point) => point.time)
4305
+ );
4306
+ if (timestamps.length <= 1)
4307
+ return 30;
4308
+ const minTimestamp = Math.min(...timestamps);
4309
+ const maxTimestamp = Math.max(...timestamps);
4310
+ const span = maxTimestamp - minTimestamp;
4311
+ if (!Number.isFinite(span) || span <= 0)
4312
+ return 30;
4313
+ return Math.max(1, Math.floor(span));
4314
+ };
4315
+ var resolveLatestValue = (points) => {
4316
+ const latestPoint = points[points.length - 1];
4317
+ if (!latestPoint)
4318
+ return 0;
4319
+ return latestPoint.value;
4320
+ };
4321
+ var resolveActiveSeriesId = (series, activeSeriesId) => {
4322
+ var _a, _b;
4323
+ if (activeSeriesId) {
4324
+ const matchingSeries = series.find((seriesItem) => seriesItem.id === activeSeriesId);
4325
+ if (matchingSeries) {
4326
+ return matchingSeries.id;
4327
+ }
4328
+ }
4329
+ return (_b = (_a = series[0]) == null ? void 0 : _a.id) != null ? _b : "";
4330
+ };
4331
+ var formatDefaultSeriesLabel = (seriesItem) => {
4332
+ return seriesItem.id.charAt(0).toUpperCase() + seriesItem.id.slice(1);
4333
+ };
4334
+ var renderDefaultSeriesControls = ({
4335
+ series,
4336
+ activeSeriesId,
4337
+ handleSeriesChange,
4338
+ defaultSeriesSwitchClassName,
4339
+ seriesSwitchAriaLabel,
4340
+ formatSeriesOptionAriaLabel
4341
+ }) => {
4342
+ return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
4343
+ SwitchButton,
4344
+ {
4345
+ ariaLabel: seriesSwitchAriaLabel,
4346
+ className: defaultSeriesSwitchClassName,
4347
+ options: series.map((seriesItem) => ({
4348
+ value: seriesItem.id,
4349
+ label: formatDefaultSeriesLabel(seriesItem),
4350
+ ariaLabel: formatSeriesOptionAriaLabel(formatDefaultSeriesLabel(seriesItem))
4351
+ })),
4352
+ value: activeSeriesId,
4353
+ onValueChange: handleSeriesChange
4354
+ }
4355
+ );
4356
+ };
4357
+ var resolveSelectedSeries = (series, activeSeriesId) => {
4358
+ const availableSeriesIds = new Set(series.map((seriesItem) => seriesItem.id));
4359
+ if (!availableSeriesIds.has(activeSeriesId)) {
4360
+ return series[0];
4361
+ }
4362
+ return series.find((seriesItem) => seriesItem.id === activeSeriesId);
4363
+ };
4364
+ var LineChart = ({
4365
+ series,
4366
+ height = 280,
4367
+ width,
4368
+ classNames,
4369
+ isLoading = false,
4370
+ showSeriesControls = true,
4371
+ renderSeriesControls
4372
+ }) => {
4373
+ var _a, _b;
4374
+ const labels = (0, import_hooks17.useLabels)();
4375
+ const { theme } = (0, import_hooks17.useSdkUiConfig)();
4376
+ const normalizedSeries = (0, import_react7.useMemo)(() => {
4377
+ return normalizeSeries(series);
4378
+ }, [series]);
4379
+ const [activeSeriesId, setActiveSeriesId] = (0, import_react7.useState)(
4380
+ () => resolveActiveSeriesId(normalizedSeries, null)
4381
+ );
4382
+ (0, import_react7.useEffect)(() => {
4383
+ setActiveSeriesId(
4384
+ (currentActiveSeriesId) => resolveActiveSeriesId(normalizedSeries, currentActiveSeriesId)
4385
+ );
4386
+ }, [normalizedSeries]);
4387
+ const livelineTheme = theme;
4388
+ const handleSeriesChange = (seriesId) => {
4389
+ setActiveSeriesId(seriesId);
4390
+ };
4391
+ const primarySeries = (0, import_react7.useMemo)(() => {
4392
+ return resolveSelectedSeries(normalizedSeries, activeSeriesId);
4393
+ }, [activeSeriesId, normalizedSeries]);
4394
+ const primaryData = (0, import_react7.useMemo)(() => {
4395
+ if (!primarySeries) {
4396
+ return [];
4397
+ }
4398
+ return toLivelinePoints(primarySeries.points);
4399
+ }, [primarySeries]);
4400
+ const primaryValue = (0, import_react7.useMemo)(() => {
4401
+ if (!primarySeries) {
4402
+ return 0;
4403
+ }
4404
+ return resolveLatestValue(primarySeries.points);
4405
+ }, [primarySeries]);
4406
+ const livelineSeries = (0, import_react7.useMemo)(() => {
4407
+ return normalizedSeries.map((seriesItem) => ({
4408
+ id: seriesItem.id,
4409
+ color: seriesItem.color,
4410
+ data: toLivelinePoints(seriesItem.points),
4411
+ value: resolveLatestValue(seriesItem.points)
4412
+ }));
4413
+ }, [normalizedSeries]);
4414
+ const windowSeconds = (0, import_react7.useMemo)(() => {
4415
+ return resolveWindowSeconds(normalizedSeries);
4416
+ }, [normalizedSeries]);
4417
+ const timeFormatter = (0, import_react7.useMemo)(() => {
4418
+ return resolveTimeFormatter(windowSeconds);
4419
+ }, [windowSeconds]);
4420
+ const seriesControls = showSeriesControls && normalizedSeries.length > 0 ? (_a = renderSeriesControls == null ? void 0 : renderSeriesControls({
4421
+ series: normalizedSeries,
4422
+ activeSeriesId,
4423
+ handleSeriesChange
4424
+ })) != null ? _a : normalizedSeries.length > 1 ? renderDefaultSeriesControls({
4425
+ series: normalizedSeries,
4426
+ activeSeriesId,
4427
+ handleSeriesChange,
4428
+ defaultSeriesSwitchClassName: classNames == null ? void 0 : classNames.defaultSeriesSwitch,
4429
+ seriesSwitchAriaLabel: labels.common.lineChartSeriesSwitchAria,
4430
+ formatSeriesOptionAriaLabel: labels.common.lineChartSeriesOptionAria
4431
+ }) : null : null;
4432
+ return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: cn("group/agg-chart", "w-full", classNames == null ? void 0 : classNames.root), style: { width }, children: [
4433
+ !isLoading && seriesControls ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: cn("mb-3", classNames == null ? void 0 : classNames.controls), children: seriesControls }) : null,
4434
+ /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
4435
+ "div",
4436
+ {
4437
+ className: cn(
4438
+ "overflow-hidden [&>div:not(.agg-livechart):first-of-type]:hidden!",
4439
+ classNames == null ? void 0 : classNames.chartViewport
4440
+ ),
4441
+ style: { height },
4442
+ role: "img",
4443
+ "aria-label": labels.common.lineChartAria,
4444
+ children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
4445
+ import_liveline.Liveline,
4446
+ {
4447
+ className: cn("h-full w-full agg-livechart", classNames == null ? void 0 : classNames.liveline),
4448
+ data: primaryData,
4449
+ value: primaryValue,
4450
+ series: livelineSeries,
4451
+ color: (_b = primarySeries == null ? void 0 : primarySeries.color) != null ? _b : "var(--agg-color-primary)",
4452
+ theme: livelineTheme,
4453
+ grid: true,
4454
+ momentum: false,
4455
+ pulse: false,
4456
+ window: windowSeconds,
4457
+ formatValue: defaultValueFormatter,
4458
+ formatTime: timeFormatter,
4459
+ padding: {
4460
+ top: 12,
4461
+ right: 80,
4462
+ bottom: 28,
4463
+ left: 12
4464
+ },
4465
+ loading: isLoading
4466
+ }
4467
+ )
4468
+ }
4469
+ )
4470
+ ] });
4471
+ };
4472
+ LineChart.displayName = "LineChart";
4473
+
4474
+ // src/events/item-details/event-list-item-details.utils.ts
4475
+ var import_dayjs3 = __toESM(require("dayjs"));
4476
+ var normalizeLabel = (value) => {
4477
+ return value.trim().toLowerCase();
4478
+ };
4479
+ var isDateLikeLabel = (value) => {
4480
+ if (!value.trim())
4481
+ return false;
4482
+ return (0, import_dayjs3.default)(value).isValid();
4483
+ };
4484
+ var formatDateLabel = (value) => {
4485
+ if (!isDateLikeLabel(value))
4486
+ return value;
4487
+ return (0, import_dayjs3.default)(value).format("MMM D, YYYY");
4488
+ };
4489
+ var getDefaultSelectedTimeRange = (value) => {
4490
+ if (!value)
4491
+ return "1M";
4492
+ return value;
4493
+ };
4494
+ var getTimeWindowByRange = (range) => {
4495
+ const endTs = (0, import_dayjs3.default)().unix();
4496
+ if (range === "1H") {
4497
+ return {
4498
+ startTs: import_dayjs3.default.unix(endTs).subtract(1, "hour").unix(),
4499
+ endTs,
4500
+ intervalMinutes: 5
4501
+ };
4502
+ }
4503
+ if (range === "6H") {
4504
+ return {
4505
+ startTs: import_dayjs3.default.unix(endTs).subtract(6, "hour").unix(),
4506
+ endTs,
4507
+ intervalMinutes: 15
4508
+ };
4509
+ }
4510
+ if (range === "1D") {
4511
+ return {
4512
+ startTs: import_dayjs3.default.unix(endTs).subtract(1, "day").unix(),
4513
+ endTs,
4514
+ intervalMinutes: 30
4515
+ };
4516
+ }
4517
+ if (range === "1W") {
4518
+ return {
4519
+ startTs: import_dayjs3.default.unix(endTs).subtract(7, "day").unix(),
4520
+ endTs,
4521
+ intervalMinutes: 60
4522
+ };
4523
+ }
4524
+ if (range === "1M") {
4525
+ return {
4526
+ startTs: import_dayjs3.default.unix(endTs).subtract(1, "month").unix(),
4527
+ endTs,
4528
+ intervalMinutes: 240
4529
+ };
4530
+ }
4531
+ return {
4532
+ startTs: import_dayjs3.default.unix(endTs).subtract(6, "month").unix(),
4533
+ endTs,
4534
+ intervalMinutes: 720
4535
+ };
4536
+ };
4537
+ var resolveOutcomeLabels = (venueMarkets) => {
4538
+ var _a;
4539
+ const primaryMarket = selectPrimaryVenueMarket(venueMarkets);
4540
+ const initialLabels = ((_a = primaryMarket == null ? void 0 : primaryMarket.venueMarketOutcomes) != null ? _a : []).map(
4541
+ (outcome) => resolveOutcomeTitle(outcome)
4542
+ );
4543
+ const labels = new Set(initialLabels);
4544
+ venueMarkets.forEach((market) => {
4545
+ sortOutcomes(market.venueMarketOutcomes).forEach((outcome) => {
4546
+ labels.add(resolveOutcomeTitle(outcome));
4547
+ });
4548
+ });
4549
+ return [...labels];
4550
+ };
4551
+ var resolveDefaultOutcomeLabel = (outcomeLabels) => {
4552
+ return outcomeLabels[0];
4553
+ };
4554
+ var matchOutcomeByLabel = (outcome, selectedOutcomeLabel) => {
4555
+ const normalizedSelectedLabel = normalizeLabel(selectedOutcomeLabel);
4556
+ const resolvedTitle = resolveOutcomeTitle(outcome);
4557
+ return normalizeLabel(resolvedTitle) === normalizedSelectedLabel || normalizeLabel(outcome.label) === normalizedSelectedLabel;
4558
+ };
4559
+ var resolveOutcomesByVenue = (venueMarkets, selectedOutcomeLabel) => {
4560
+ return venueMarkets.map((market) => {
4561
+ const matchedOutcome = sortOutcomes(market.venueMarketOutcomes).find((outcome) => {
4562
+ return matchOutcomeByLabel(outcome, selectedOutcomeLabel);
4563
+ });
4564
+ if (!matchedOutcome)
4565
+ return null;
4566
+ return {
4567
+ venue: market.venue,
4568
+ market,
4569
+ outcome: matchedOutcome
4570
+ };
4571
+ }).filter((item) => item != null);
4572
+ };
4573
+ var buildPriceHistoryGroups = (selectedOutcomes, fallbackMarketId) => {
4574
+ const marketIdByVenue = /* @__PURE__ */ new Map();
4575
+ selectedOutcomes.forEach(({ venue, market }) => {
4576
+ var _a, _b;
4577
+ const marketWithCanonicalId = market;
4578
+ const canonicalMarketId = (_a = marketWithCanonicalId.marketId) != null ? _a : fallbackMarketId;
4579
+ if (!canonicalMarketId)
4580
+ return;
4581
+ if (!marketIdByVenue.has(venue)) {
4582
+ marketIdByVenue.set(venue, /* @__PURE__ */ new Set());
4583
+ }
4584
+ (_b = marketIdByVenue.get(venue)) == null ? void 0 : _b.add(canonicalMarketId);
4585
+ });
4586
+ return [...marketIdByVenue.entries()].map(([venue, marketIds]) => ({
4587
+ venue,
4588
+ venueMarketOutcomeIds: [...marketIds]
4589
+ })).filter((group) => group.venueMarketOutcomeIds.length > 0);
4590
+ };
4591
+ var resolveSeriesColor = (venue, index) => {
4592
+ var _a;
4593
+ const colorFromVenue = lineColorByVenue[venue];
4594
+ if (colorFromVenue)
4595
+ return colorFromVenue;
4596
+ return (_a = fallbackLineColors[index % fallbackLineColors.length]) != null ? _a : "#2e5cff";
4597
+ };
4598
+
4599
+ // src/events/item-details/index.tsx
4600
+ var import_jsx_runtime69 = require("react/jsx-runtime");
4601
+ var EventListItemDetailsLoadingState = ({
4602
+ classNames,
4603
+ ariaLabel
4604
+ }) => {
4605
+ const labels = (0, import_hooks18.useLabels)();
4606
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
4607
+ Skeleton,
4608
+ {
4609
+ view: "event-list-item-details",
4610
+ className: classNames == null ? void 0 : classNames.root,
4611
+ ariaLabel: ariaLabel != null ? ariaLabel : labels.eventItemDetails.loading
4612
+ }
4613
+ );
4614
+ };
4615
+ var EventListItemDetailsUnavailableState = ({
4616
+ classNames,
4617
+ ariaLabel
4618
+ }) => {
4619
+ const labels = (0, import_hooks18.useLabels)();
4620
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
4621
+ Card,
4622
+ {
4623
+ className: cn(detailsBaseCardClassName, classNames == null ? void 0 : classNames.root),
4624
+ role: "status",
4625
+ "aria-label": ariaLabel != null ? ariaLabel : labels.eventItemDetails.unavailableAria,
4626
+ children: /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: cn("flex flex-col gap-1", classNames == null ? void 0 : classNames.header), children: [
4627
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Typography, { variant: "body-large-strong", className: cn("truncate", classNames == null ? void 0 : classNames.title), children: labels.eventItemDetails.unavailableTitle }),
4628
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Typography, { variant: "body", className: "text-agg-muted-foreground", children: labels.eventItemDetails.unavailableDescription })
4629
+ ] })
4630
+ }
4631
+ );
4632
+ };
4633
+ var EventListItemDetailsNotFoundState = ({
4634
+ classNames,
4635
+ ariaLabel
4636
+ }) => {
4637
+ const labels = (0, import_hooks18.useLabels)();
4638
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Card, { className: cn(detailsBaseCardClassName, classNames == null ? void 0 : classNames.root), children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
4639
+ StateMessage,
4640
+ {
4641
+ ariaLabel: ariaLabel != null ? ariaLabel : labels.eventItemDetails.notFoundAria,
4642
+ title: labels.eventItemDetails.notFoundTitle,
4643
+ description: labels.eventItemDetails.notFoundDescription,
4644
+ className: "min-h-[280px] md:min-h-[320px]"
4645
+ }
4646
+ ) });
4647
+ };
4648
+ var probabilityModeOrder = ["yes", "no"];
4649
+ var clampProbability = (value) => {
4650
+ if (value < 0)
4651
+ return 0;
4652
+ if (value > 1)
4653
+ return 1;
4654
+ return value;
4655
+ };
4656
+ var resolveAverageProbability = (values) => {
4657
+ const validValues = values.filter((value) => value != null);
4658
+ if (validValues.length === 0)
4659
+ return void 0;
4660
+ return validValues.reduce((sum, value) => sum + value, 0) / validValues.length;
4661
+ };
4662
+ var resolveOutcomeCandidateIds = (market, outcome) => {
4663
+ var _a, _b;
4664
+ const marketWithCanonicalId = market;
4665
+ return [
4666
+ outcome.id,
4667
+ (_a = outcome.externalIdentifier) != null ? _a : void 0,
4668
+ market.externalIdentifier,
4669
+ (_b = marketWithCanonicalId.marketId) != null ? _b : void 0
4670
+ ].filter((value) => typeof value === "string" && value.trim().length > 0);
4671
+ };
4672
+ var EventListItemDetailsGraphSection = ({
4673
+ venueMarkets,
4674
+ canonicalMarketId,
4675
+ selectedOutcomeLabel,
4676
+ onSelectedOutcomeLabelChange,
4677
+ switchLabels,
4678
+ isDateOutcomeMarket,
4679
+ classNames,
4680
+ showVenueLogo,
4681
+ venueInfo,
4682
+ formatPercent,
4683
+ selectedTimeRange
4684
+ }) => {
4685
+ const labels = (0, import_hooks18.useLabels)();
4686
+ const [selectedVenue, setSelectedVenue] = (0, import_react8.useState)(null);
4687
+ const [activeProbabilityMode, setActiveProbabilityMode] = (0, import_react8.useState)("yes");
4688
+ const probabilityModeConfigs = (0, import_react8.useMemo)(() => {
4689
+ if (isDateOutcomeMarket) {
4690
+ return {
4691
+ yes: {
4692
+ switchLabel: switchLabels[0],
4693
+ sourceOutcomeLabel: selectedOutcomeLabel,
4694
+ transformProbability: (value) => value
4695
+ },
4696
+ no: {
4697
+ switchLabel: switchLabels[1],
4698
+ sourceOutcomeLabel: selectedOutcomeLabel,
4699
+ transformProbability: (value) => 1 - value
4700
+ }
4701
+ };
4702
+ }
4703
+ return {
4704
+ yes: {
4705
+ switchLabel: switchLabels[0],
4706
+ sourceOutcomeLabel: switchLabels[0],
4707
+ transformProbability: (value) => value
4708
+ },
4709
+ no: {
4710
+ switchLabel: switchLabels[1],
4711
+ sourceOutcomeLabel: switchLabels[1],
4712
+ transformProbability: (value) => value
4713
+ }
4714
+ };
4715
+ }, [isDateOutcomeMarket, selectedOutcomeLabel, switchLabels]);
4716
+ const selectedOutcomesByMode = (0, import_react8.useMemo)(() => {
4717
+ return {
4718
+ yes: resolveOutcomesByVenue(venueMarkets, probabilityModeConfigs.yes.sourceOutcomeLabel),
4719
+ no: resolveOutcomesByVenue(venueMarkets, probabilityModeConfigs.no.sourceOutcomeLabel)
4720
+ };
4721
+ }, [
4722
+ probabilityModeConfigs.no.sourceOutcomeLabel,
4723
+ probabilityModeConfigs.yes.sourceOutcomeLabel,
4724
+ venueMarkets
4725
+ ]);
4726
+ (0, import_react8.useEffect)(() => {
4727
+ if (isDateOutcomeMarket) {
4728
+ return;
4729
+ }
4730
+ const nextMode = selectedOutcomeLabel === probabilityModeConfigs.no.sourceOutcomeLabel ? "no" : "yes";
4731
+ setActiveProbabilityMode(nextMode);
4732
+ }, [isDateOutcomeMarket, probabilityModeConfigs.no.sourceOutcomeLabel, selectedOutcomeLabel]);
4733
+ const normalizedVenueDataByMode = (0, import_react8.useMemo)(() => {
4734
+ const buildModeData = (mode) => {
4735
+ const modeConfig = probabilityModeConfigs[mode];
4736
+ return selectedOutcomesByMode[mode].map((outcomeByVenue, index) => {
4737
+ const rawProbability = normalizeProbability(outcomeByVenue.outcome.price);
4738
+ const transformedProbability = rawProbability == null ? void 0 : clampProbability(modeConfig.transformProbability(rawProbability));
4739
+ return {
4740
+ venue: outcomeByVenue.venue,
4741
+ venueLabel: resolveVenueLabel(outcomeByVenue.venue, venueInfo, labels),
4742
+ market: outcomeByVenue.market,
4743
+ outcome: outcomeByVenue.outcome,
4744
+ probability: transformedProbability,
4745
+ color: resolveSeriesColor(outcomeByVenue.venue, index)
4746
+ };
4747
+ });
4748
+ };
4749
+ return {
4750
+ yes: buildModeData("yes"),
4751
+ no: buildModeData("no")
4752
+ };
4753
+ }, [labels, probabilityModeConfigs, selectedOutcomesByMode, venueInfo]);
4754
+ const allOutcomesForHistory = (0, import_react8.useMemo)(() => {
4755
+ const outcomeByModeAndId = /* @__PURE__ */ new Map();
4756
+ probabilityModeOrder.forEach((mode) => {
4757
+ selectedOutcomesByMode[mode].forEach((outcomeByVenue) => {
4758
+ outcomeByModeAndId.set(
4759
+ `${outcomeByVenue.venue}:${outcomeByVenue.outcome.id}`,
4760
+ outcomeByVenue
4761
+ );
4762
+ });
4763
+ });
4764
+ return [...outcomeByModeAndId.values()];
4765
+ }, [selectedOutcomesByMode]);
4766
+ const priceHistoryGroups = (0, import_react8.useMemo)(() => {
4767
+ return buildPriceHistoryGroups(allOutcomesForHistory, canonicalMarketId);
4768
+ }, [allOutcomesForHistory, canonicalMarketId]);
4769
+ const timeWindow = (0, import_react8.useMemo)(() => {
4770
+ return getTimeWindowByRange(selectedTimeRange);
4771
+ }, [selectedTimeRange]);
4772
+ const {
4773
+ data: priceHistoryData,
4774
+ isLoading: isPriceHistoryLoading,
4775
+ error: priceHistoryError,
4776
+ results: priceHistoryResults
4777
+ } = (0, import_hooks18.usePriceHistory)(__spreadProps(__spreadValues({
4778
+ groups: priceHistoryGroups
4779
+ }, timeWindow), {
4780
+ enabled: priceHistoryGroups.length > 0
4781
+ }));
4782
+ const priceHistoryByVenue = (0, import_react8.useMemo)(() => {
4783
+ const historyByVenue = /* @__PURE__ */ new Map();
4784
+ if (!(priceHistoryData == null ? void 0 : priceHistoryData.length)) {
4785
+ return historyByVenue;
4786
+ }
4787
+ priceHistoryData.forEach((historyItem) => {
4788
+ const venue = historyItem.venue;
4789
+ const venueHistory = historyByVenue.get(venue);
4790
+ if (venueHistory) {
4791
+ venueHistory.push(historyItem);
4792
+ return;
4793
+ }
4794
+ historyByVenue.set(venue, [historyItem]);
4795
+ });
4796
+ return historyByVenue;
4797
+ }, [priceHistoryData]);
4798
+ const chartSeriesByMode = (0, import_react8.useMemo)(() => {
4799
+ const buildSeries = (mode) => {
4800
+ const modeConfig = probabilityModeConfigs[mode];
4801
+ const chartSeries = [];
4802
+ normalizedVenueDataByMode[mode].forEach((venueData) => {
4803
+ var _a;
4804
+ const venueHistory = priceHistoryByVenue.get(venueData.venue);
4805
+ if (!(venueHistory == null ? void 0 : venueHistory.length))
4806
+ return;
4807
+ const candidateIds = resolveOutcomeCandidateIds(venueData.market, venueData.outcome);
4808
+ const matchingHistory = (_a = venueHistory.find((historyItem) => candidateIds.includes(historyItem.marketId))) != null ? _a : venueHistory.length === 1 ? venueHistory[0] : void 0;
4809
+ if (!matchingHistory)
4810
+ return;
4811
+ const points = matchingHistory.points.map((point) => {
4812
+ const probability = normalizeProbability(point.price);
4813
+ if (probability == null || !Number.isFinite(point.timestamp))
4814
+ return null;
4815
+ return {
4816
+ time: point.timestamp,
4817
+ value: clampProbability(modeConfig.transformProbability(probability)) * 100
4818
+ };
4819
+ }).filter((point) => point != null);
4820
+ if (points.length === 0)
4821
+ return;
4822
+ chartSeries.push({
4823
+ id: `${mode}-${venueData.venue}-${matchingHistory.marketId}`,
4824
+ venue: venueData.venue,
4825
+ color: venueData.color,
4826
+ points,
4827
+ lineWidth: 2,
4828
+ lineStyle: "solid"
4829
+ });
4830
+ });
4831
+ return chartSeries;
4832
+ };
4833
+ return {
4834
+ yes: buildSeries("yes"),
4835
+ no: buildSeries("no")
4836
+ };
4837
+ }, [normalizedVenueDataByMode, priceHistoryByVenue, probabilityModeConfigs]);
4838
+ const visibleChartSeries = (0, import_react8.useMemo)(() => {
4839
+ const modeSeries = chartSeriesByMode[activeProbabilityMode];
4840
+ if (!selectedVenue)
4841
+ return modeSeries;
4842
+ return modeSeries.filter((seriesItem) => seriesItem.venue === selectedVenue);
4843
+ }, [activeProbabilityMode, chartSeriesByMode, selectedVenue]);
4844
+ const segmentedDisplayItems = (0, import_react8.useMemo)(() => {
4845
+ return probabilityModeOrder.map((mode) => {
4846
+ const averageProbability = resolveAverageProbability(
4847
+ normalizedVenueDataByMode[mode].map((venueData) => venueData.probability)
4848
+ );
4849
+ const suffix = averageProbability == null ? "" : ` ${formatPercent(averageProbability)}`;
4850
+ const switchLabel = probabilityModeConfigs[mode].switchLabel;
4851
+ return {
4852
+ mode,
4853
+ display: `${switchLabel}${suffix}`
4854
+ };
4855
+ });
4856
+ }, [formatPercent, normalizedVenueDataByMode, probabilityModeConfigs]);
4857
+ const activeModeVenueData = normalizedVenueDataByMode[activeProbabilityMode];
4858
+ (0, import_react8.useEffect)(() => {
4859
+ if (!selectedVenue) {
4860
+ return;
4861
+ }
4862
+ if (activeModeVenueData.some((item) => item.venue === selectedVenue)) {
4863
+ return;
4864
+ }
4865
+ setSelectedVenue(null);
4866
+ }, [activeModeVenueData, selectedVenue]);
4867
+ const handleProbabilityModeChange = (nextMode) => {
4868
+ setActiveProbabilityMode(nextMode);
4869
+ if (isDateOutcomeMarket) {
4870
+ return;
4871
+ }
4872
+ onSelectedOutcomeLabelChange(probabilityModeConfigs[nextMode].sourceOutcomeLabel);
4873
+ };
4874
+ const handleVenueToggle = (venue) => {
4875
+ setSelectedVenue((currentSelectedVenue) => {
4876
+ if (currentSelectedVenue === venue)
4877
+ return null;
4878
+ return venue;
4879
+ });
4880
+ };
4881
+ const handleRetryPriceHistory = () => {
4882
+ void Promise.all(priceHistoryResults.map((result) => result.refetch()));
4883
+ };
4884
+ if (priceHistoryError) {
4885
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
4886
+ "div",
4887
+ {
4888
+ className: cn(
4889
+ "w-full rounded-agg-xl border border-agg-separator bg-agg-secondary",
4890
+ classNames == null ? void 0 : classNames.chart
4891
+ ),
4892
+ children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
4893
+ StateMessage,
4894
+ {
4895
+ ariaLabel: labels.eventItemDetails.chartUnavailableAria,
4896
+ tone: "warning",
4897
+ title: labels.eventItemDetails.chartUnavailableTitle,
4898
+ description: labels.eventItemDetails.chartUnavailableDescription,
4899
+ actionLabel: labels.common.retry,
4900
+ onAction: handleRetryPriceHistory,
4901
+ className: "min-h-[300px] px-5 py-10 md:px-10"
4902
+ }
4903
+ )
4904
+ }
4905
+ );
4906
+ }
4907
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
4908
+ LineChart,
4909
+ {
4910
+ classNames: { root: classNames == null ? void 0 : classNames.chart },
4911
+ series: visibleChartSeries,
4912
+ height: 300,
4913
+ isLoading: isPriceHistoryLoading,
4914
+ showSeriesControls: activeModeVenueData.length > 0 || segmentedDisplayItems.length > 0,
4915
+ renderSeriesControls: () => {
4916
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
4917
+ "div",
4918
+ {
4919
+ className: cn("flex flex-row items-center justify-between gap-4", classNames == null ? void 0 : classNames.summary),
4920
+ children: [
4921
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
4922
+ "div",
4923
+ {
4924
+ className: cn(
4925
+ "flex min-w-0 gap-2 overflow-x-auto pb-1 md:flex-wrap md:overflow-visible md:pb-0",
4926
+ classNames == null ? void 0 : classNames.outcomeBadges
4927
+ ),
4928
+ children: activeModeVenueData.map((venueData) => {
4929
+ var _a;
4930
+ const text = venueData.probability == null ? "-" : formatPercent(venueData.probability);
4931
+ const isActiveVenue = selectedVenue === venueData.venue;
4932
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
4933
+ "button",
4934
+ {
4935
+ type: "button",
4936
+ "aria-label": `${venueData.venueLabel} ${text}`,
4937
+ "aria-pressed": isActiveVenue,
4938
+ className: cn(
4939
+ "rounded-agg-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-2 focus-visible:ring-offset-agg-secondary-hover"
4940
+ ),
4941
+ children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
4942
+ Badge,
4943
+ {
4944
+ text,
4945
+ size: "large",
4946
+ prefix: showVenueLogo ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
4947
+ VenueLogo,
4948
+ {
4949
+ venue: venueData.venue,
4950
+ size: "small",
4951
+ title: (_a = venueInfo == null ? void 0 : venueInfo[venueData.venue]) == null ? void 0 : _a.label
4952
+ }
4953
+ ) : void 0,
4954
+ classNames: {
4955
+ root: cn("h-9 shrink-0 border-2 px-4 text-agg-base leading-agg-6")
4956
+ },
4957
+ isActive: isActiveVenue,
4958
+ onClick: (e) => {
4959
+ e.preventDefault();
4960
+ e.stopPropagation();
4961
+ handleVenueToggle(venueData.venue);
4962
+ }
4963
+ }
4964
+ )
4965
+ },
4966
+ `${activeProbabilityMode}-${venueData.market.id}-${venueData.outcome.id}`
4967
+ );
4968
+ })
4969
+ }
4970
+ ),
4971
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
4972
+ SwitchButton,
4973
+ {
4974
+ ariaLabel: labels.eventItemDetails.outcomeSelectorAria,
4975
+ className: cn("w-full md:w-fit", classNames == null ? void 0 : classNames.segmentedControl),
4976
+ value: activeProbabilityMode,
4977
+ onValueChange: handleProbabilityModeChange,
4978
+ options: segmentedDisplayItems.map((segmentedItem) => ({
4979
+ value: segmentedItem.mode,
4980
+ label: segmentedItem.display,
4981
+ ariaLabel: segmentedItem.display
4982
+ }))
4983
+ }
4984
+ )
4985
+ ]
4986
+ }
4987
+ );
4988
+ }
4989
+ }
4990
+ );
4991
+ };
4992
+ var EventListItemDetailsContent = ({
4993
+ event,
4994
+ title,
4995
+ image,
4996
+ showVenueLogo = true,
4997
+ classNames,
4998
+ venueInfo,
4999
+ detailsStats,
5000
+ ariaLabel,
5001
+ defaultTimeRange
5002
+ }) => {
5003
+ var _a, _b;
5004
+ const config = (0, import_hooks18.useSdkUiConfig)();
5005
+ const labels = (0, import_hooks18.useLabels)();
5006
+ const venueMarkets = (0, import_react8.useMemo)(() => {
5007
+ var _a2, _b2, _c;
5008
+ return (_c = (_b2 = (_a2 = event.markets) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.venueMarkets) != null ? _c : [];
5009
+ }, [event.markets]);
5010
+ const primaryVenueMarket = (0, import_react8.useMemo)(() => {
5011
+ return selectPrimaryVenueMarket(venueMarkets);
5012
+ }, [venueMarkets]);
5013
+ const outcomeLabels = (0, import_react8.useMemo)(() => {
5014
+ return resolveOutcomeLabels(venueMarkets);
5015
+ }, [venueMarkets]);
5016
+ const [selectedOutcomeLabel, setSelectedOutcomeLabel] = (0, import_react8.useState)(() => {
5017
+ return resolveDefaultOutcomeLabel(outcomeLabels);
5018
+ });
5019
+ const [selectedTimeRange, setSelectedTimeRange] = (0, import_react8.useState)(() => {
5020
+ return getDefaultSelectedTimeRange(defaultTimeRange);
5021
+ });
5022
+ (0, import_react8.useEffect)(() => {
5023
+ setSelectedTimeRange(getDefaultSelectedTimeRange(defaultTimeRange));
5024
+ }, [defaultTimeRange]);
5025
+ const resolvedTitle = resolveTileTitle(event, primaryVenueMarket, title);
5026
+ const resolvedImage = resolveTileImage(event, primaryVenueMarket, image);
5027
+ const isDateOutcomeMarket = outcomeLabels.length > 2 && outcomeLabels.every(isDateLikeLabel);
5028
+ const outcomeSelectorLabels = outcomeLabels;
5029
+ const probabilityByLabel = (0, import_react8.useMemo)(() => {
5030
+ return new Map(
5031
+ outcomeLabels.map((label) => {
5032
+ const outcomesByVenue = resolveOutcomesByVenue(venueMarkets, label);
5033
+ const probabilities = outcomesByVenue.map((item) => normalizeProbability(item.outcome.price)).filter((value) => value != null);
5034
+ if (probabilities.length === 0) {
5035
+ return [label, void 0];
5036
+ }
5037
+ const averageProbability = probabilities.reduce((sum, value) => sum + value, 0) / probabilities.length;
5038
+ return [label, averageProbability];
5039
+ })
5040
+ );
5041
+ }, [outcomeLabels, venueMarkets]);
5042
+ const mainOutcomeLabel = (0, import_react8.useMemo)(() => {
5043
+ if (outcomeLabels.length === 0)
5044
+ return void 0;
5045
+ return [...outcomeLabels].sort((left, right) => {
5046
+ var _a2, _b2;
5047
+ const leftProbability = (_a2 = probabilityByLabel.get(left)) != null ? _a2 : -1;
5048
+ const rightProbability = (_b2 = probabilityByLabel.get(right)) != null ? _b2 : -1;
5049
+ return rightProbability - leftProbability;
5050
+ })[0];
5051
+ }, [outcomeLabels, probabilityByLabel]);
5052
+ (0, import_react8.useEffect)(() => {
5053
+ if (!outcomeLabels.length) {
5054
+ setSelectedOutcomeLabel(void 0);
5055
+ return;
5056
+ }
5057
+ if (selectedOutcomeLabel && outcomeLabels.includes(selectedOutcomeLabel)) {
5058
+ return;
5059
+ }
5060
+ const fallbackOutcomeLabel = isDateOutcomeMarket ? resolveDefaultOutcomeLabel(outcomeLabels) : mainOutcomeLabel != null ? mainOutcomeLabel : resolveDefaultOutcomeLabel(outcomeLabels);
5061
+ setSelectedOutcomeLabel(fallbackOutcomeLabel);
5062
+ }, [isDateOutcomeMarket, mainOutcomeLabel, outcomeLabels, selectedOutcomeLabel]);
5063
+ const switchLabels = (0, import_react8.useMemo)(() => {
5064
+ var _a2, _b2;
5065
+ if (isDateOutcomeMarket) {
5066
+ return [labels.eventItemDetails.yes, labels.eventItemDetails.no];
5067
+ }
5068
+ const sortedOutcomeLabels = [...outcomeLabels].sort((left, right) => {
5069
+ var _a3, _b3;
5070
+ const leftProbability = (_a3 = probabilityByLabel.get(left)) != null ? _a3 : -1;
5071
+ const rightProbability = (_b3 = probabilityByLabel.get(right)) != null ? _b3 : -1;
5072
+ return rightProbability - leftProbability;
5073
+ });
5074
+ const firstLabel = (_a2 = sortedOutcomeLabels[0]) != null ? _a2 : labels.eventItemDetails.yes;
5075
+ const secondLabel = (_b2 = sortedOutcomeLabels.find((label) => label !== firstLabel)) != null ? _b2 : firstLabel;
5076
+ return [firstLabel, secondLabel];
5077
+ }, [
5078
+ isDateOutcomeMarket,
5079
+ labels.eventItemDetails.no,
5080
+ labels.eventItemDetails.yes,
5081
+ outcomeLabels,
5082
+ probabilityByLabel
5083
+ ]);
5084
+ const volumeLabel = (0, import_react8.useMemo)(() => {
5085
+ var _a2;
5086
+ const resolvedVolume = typeof event.volume === "number" ? event.volume : (_a2 = primaryVenueMarket == null ? void 0 : primaryVenueMarket.volume) != null ? _a2 : void 0;
5087
+ if (typeof resolvedVolume !== "number")
5088
+ return "";
5089
+ return `${config.formatCompactCurrency(resolvedVolume)} ${labels.eventItemDetails.volumeSuffix}`;
5090
+ }, [config, event.volume, labels.eventItemDetails.volumeSuffix, primaryVenueMarket == null ? void 0 : primaryVenueMarket.volume]);
5091
+ if (!primaryVenueMarket || !selectedOutcomeLabel) {
5092
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(EventListItemDetailsUnavailableState, { classNames, ariaLabel });
5093
+ }
5094
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
5095
+ Card,
5096
+ {
5097
+ className: cn(detailsBaseCardClassName, classNames == null ? void 0 : classNames.root),
5098
+ "aria-label": ariaLabel != null ? ariaLabel : resolvedTitle,
5099
+ children: [
5100
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
5101
+ "div",
5102
+ {
5103
+ className: cn(
5104
+ "flex flex-row gap-3 md:gap-4",
5105
+ "items-center justify-start",
5106
+ classNames == null ? void 0 : classNames.header
5107
+ ),
5108
+ children: [
5109
+ resolvedImage ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
5110
+ "img",
5111
+ {
5112
+ src: resolvedImage,
5113
+ alt: "",
5114
+ className: "size-10 rounded-agg-lg object-cover md:size-[60px]"
5115
+ }
5116
+ ) : null,
5117
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-3", children: [
5118
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
5119
+ Typography,
5120
+ {
5121
+ variant: "body-strong",
5122
+ className: cn(
5123
+ "min-w-0 text-agg-base font-agg-bold! leading-agg-6 md:text-agg-2xl md:leading-agg-8",
5124
+ "truncate text-wrap wrap-break-word line-clamp-2",
5125
+ classNames == null ? void 0 : classNames.title
5126
+ ),
5127
+ children: resolvedTitle
5128
+ }
5129
+ ),
5130
+ outcomeSelectorLabels.length > 2 ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
5131
+ "div",
5132
+ {
5133
+ className: cn(
5134
+ "flex items-center gap-2 overflow-x-auto pb-1 md:flex-wrap md:overflow-visible md:pb-0",
5135
+ classNames == null ? void 0 : classNames.headerPills
5136
+ ),
5137
+ children: outcomeSelectorLabels.map((outcomeSelectorLabel) => {
5138
+ const isActive = outcomeSelectorLabel === selectedOutcomeLabel;
5139
+ const displayLabel = isDateLikeLabel(outcomeSelectorLabel) ? formatDateLabel(outcomeSelectorLabel) : outcomeSelectorLabel;
5140
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
5141
+ Button,
5142
+ {
5143
+ size: "small",
5144
+ variant: "secondary",
5145
+ "aria-pressed": isActive,
5146
+ className: cn(
5147
+ "h-auto shrink-0 rounded-agg-full px-4 py-1.5 text-agg-sm leading-agg-5",
5148
+ "border-2",
5149
+ isActive ? "border-agg-primary bg-agg-secondary text-agg-foreground font-agg-bold" : "border-transparent bg-agg-secondary-hover text-agg-foreground font-agg-normal"
5150
+ ),
5151
+ onClick: () => setSelectedOutcomeLabel(outcomeSelectorLabel),
5152
+ children: displayLabel
5153
+ },
5154
+ outcomeSelectorLabel
5155
+ );
5156
+ })
5157
+ }
5158
+ ) : null
5159
+ ] })
5160
+ ]
5161
+ }
5162
+ ),
5163
+ detailsStats && detailsStats.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: cn("flex flex-wrap items-start gap-4 md:gap-6", classNames == null ? void 0 : classNames.headerStats), children: detailsStats.map((statItem) => {
5164
+ const deltaClassName = statItem.deltaTone === "positive" ? "text-agg-success!" : statItem.deltaTone === "negative" ? "text-agg-error!" : "text-agg-muted-foreground";
5165
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "flex flex-col gap-1", children: [
5166
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Typography, { variant: "caption-caps", className: "text-agg-muted-foreground", children: statItem.label }),
5167
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "flex items-baseline gap-1", children: [
5168
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
5169
+ Typography,
5170
+ {
5171
+ variant: "body",
5172
+ className: "text-agg-lg leading-agg-7 text-agg-foreground",
5173
+ children: statItem.value
5174
+ }
5175
+ ),
5176
+ statItem.delta ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Typography, { variant: "label", className: cn(deltaClassName), children: statItem.delta }) : null
5177
+ ] })
5178
+ ] }, `${statItem.label}-${statItem.value}`);
5179
+ }) }) : null,
5180
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
5181
+ EventListItemDetailsGraphSection,
5182
+ {
5183
+ venueMarkets,
5184
+ canonicalMarketId: (_b = (_a = event.markets) == null ? void 0 : _a[0]) == null ? void 0 : _b.id,
5185
+ selectedOutcomeLabel,
5186
+ onSelectedOutcomeLabelChange: setSelectedOutcomeLabel,
5187
+ switchLabels,
5188
+ isDateOutcomeMarket,
5189
+ classNames,
5190
+ showVenueLogo,
5191
+ venueInfo,
5192
+ formatPercent: config.formatPercent,
5193
+ selectedTimeRange
5194
+ }
5195
+ ),
5196
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: cn("flex flex-wrap items-center justify-between gap-4", classNames == null ? void 0 : classNames.footer), children: [
5197
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Typography, { variant: "label", className: "text-agg-muted-foreground", children: volumeLabel || "-" }),
5198
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: cn("flex items-center gap-2 md:gap-3", classNames == null ? void 0 : classNames.timeRange), children: eventListItemDetailsTimeRanges.map((timeRange) => {
5199
+ const isActive = timeRange === selectedTimeRange;
5200
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
5201
+ Button,
5202
+ {
5203
+ size: "small",
5204
+ variant: "tertiary",
5205
+ className: cn(
5206
+ "h-auto min-w-0 rounded-none px-0 py-0 text-agg-xs leading-agg-4 md:text-agg-sm md:leading-agg-5",
5207
+ "border-0 bg-transparent shadow-none",
5208
+ "hover:text-agg-foreground!",
5209
+ isActive ? "font-agg-bold! text-agg-foreground!" : "font-agg-normal! text-agg-muted-foreground!"
5210
+ ),
5211
+ "aria-pressed": isActive,
5212
+ onClick: () => setSelectedTimeRange(timeRange),
5213
+ children: timeRange === "ALL" ? labels.eventItemDetails.allTimeRange : timeRange
5214
+ },
5215
+ timeRange
5216
+ );
5217
+ }) })
5218
+ ] })
5219
+ ]
5220
+ }
5221
+ );
5222
+ };
5223
+ var EventListItemDetailsByEventId = (_a) => {
5224
+ var _b = _a, {
5225
+ eventId
5226
+ } = _b, rest = __objRest(_b, [
5227
+ "eventId"
5228
+ ]);
5229
+ const {
5230
+ event: fetchedEvent,
5231
+ error,
5232
+ isError,
5233
+ isLoading
5234
+ } = (0, import_hooks18.useEvent)(eventId, {
5235
+ enabled: !!eventId
5236
+ });
5237
+ const resolvedEvent = (0, import_react8.useMemo)(() => {
5238
+ return resolveEventListItemEvent(fetchedEvent);
5239
+ }, [fetchedEvent]);
5240
+ if (!eventId) {
5241
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
5242
+ EventListItemDetailsUnavailableState,
5243
+ {
5244
+ classNames: rest.classNames,
5245
+ ariaLabel: rest.ariaLabel
5246
+ }
5247
+ );
5248
+ }
5249
+ if (isLoading) {
5250
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(EventListItemDetailsLoadingState, { classNames: rest.classNames, ariaLabel: rest.ariaLabel });
5251
+ }
5252
+ if (isErrorWithStatus(error, 404)) {
5253
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(EventListItemDetailsNotFoundState, { classNames: rest.classNames, ariaLabel: rest.ariaLabel });
5254
+ }
5255
+ if (!fetchedEvent && !isError) {
5256
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(EventListItemDetailsLoadingState, { classNames: rest.classNames, ariaLabel: rest.ariaLabel });
5257
+ }
5258
+ if (!resolvedEvent) {
5259
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
5260
+ EventListItemDetailsUnavailableState,
5261
+ {
5262
+ classNames: rest.classNames,
5263
+ ariaLabel: rest.ariaLabel
5264
+ }
5265
+ );
5266
+ }
5267
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(EventListItemDetailsContent, __spreadValues({ event: resolvedEvent }, rest));
5268
+ };
5269
+ var EventListItemDetails = (props) => {
5270
+ if (props.isLoading) {
5271
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(EventListItemDetailsLoadingState, { classNames: props.classNames, ariaLabel: props.ariaLabel });
5272
+ }
5273
+ if ("event" in props && props.event) {
5274
+ const _a = props, { event } = _a, rest = __objRest(_a, ["event"]);
5275
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(EventListItemDetailsContent, __spreadValues({ event }, rest));
5276
+ }
5277
+ if ("eventId" in props && typeof props.eventId === "string") {
5278
+ const {
5279
+ title: titleOverride,
5280
+ image: imageOverride,
5281
+ showVenueLogo: showVenueLogoOverride,
5282
+ classNames,
5283
+ venueInfo,
5284
+ detailsStats,
5285
+ ariaLabel: ariaLabelOverride,
5286
+ defaultTimeRange: defaultTimeRangeOverride
5287
+ } = props;
5288
+ const byEventIdProps = {
5289
+ eventId: props.eventId,
5290
+ isLoading: false,
5291
+ title: titleOverride,
5292
+ image: imageOverride,
5293
+ showVenueLogo: showVenueLogoOverride,
5294
+ classNames,
5295
+ venueInfo,
5296
+ detailsStats,
5297
+ ariaLabel: ariaLabelOverride,
5298
+ defaultTimeRange: defaultTimeRangeOverride
5299
+ };
5300
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(EventListItemDetailsByEventId, __spreadValues({}, byEventIdProps));
5301
+ }
5302
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
5303
+ EventListItemDetailsUnavailableState,
5304
+ {
5305
+ classNames: props.classNames,
5306
+ ariaLabel: props.ariaLabel
5307
+ }
5308
+ );
5309
+ };
5310
+ EventListItemDetails.displayName = "EventListItemDetails";
5311
+
5312
+ // src/events/market-details/index.tsx
5313
+ var import_react9 = require("react");
5314
+ var import_hooks19 = require("@agg-market/hooks");
5315
+
5316
+ // src/events/market-details/market-details.utils.ts
5317
+ var import_dayjs4 = __toESM(require("dayjs"));
5318
+ var import_zod = require("zod");
5319
+ var MarketDetailsTabSchema = import_zod.z.enum(["order-book", "graph", "other"]);
5320
+ var OrderBookLevelSchema = import_zod.z.object({
5321
+ price: import_zod.z.number().min(0).max(1),
5322
+ size: import_zod.z.number().nonnegative()
5323
+ });
5324
+ var OrderBookRowSchema = import_zod.z.object({
5325
+ id: import_zod.z.string(),
5326
+ venue: import_zod.z.enum(["kalshi", "polymarket"]),
5327
+ price: import_zod.z.number().min(0).max(1),
5328
+ size: import_zod.z.number().nonnegative(),
5329
+ total: import_zod.z.number().nonnegative(),
5330
+ tone: import_zod.z.enum(["positive", "negative"])
5331
+ });
5332
+ var normalizeLabel2 = (value) => {
5333
+ return value.trim().toLowerCase();
5334
+ };
5335
+ var hasBinaryLabels = (labels) => {
5336
+ const normalizedLabels = labels.map(normalizeLabel2);
5337
+ return normalizedLabels.includes("yes") && normalizedLabels.includes("no");
5338
+ };
5339
+ var resolveInitialTab = (defaultTab) => {
5340
+ const parsedTab = MarketDetailsTabSchema.safeParse(defaultTab);
5341
+ if (parsedTab.success)
5342
+ return parsedTab.data;
5343
+ return "order-book";
5344
+ };
5345
+ var resolveMarket = (event, marketId) => {
5346
+ if (!event.markets.length)
5347
+ return void 0;
5348
+ if (!marketId)
5349
+ return event.markets[0];
5350
+ return event.markets.find((market) => market.id === marketId);
5351
+ };
5352
+ var resolveDisplayOutcomeLabels = (labels) => {
5353
+ if (!hasBinaryLabels(labels))
5354
+ return labels;
5355
+ return ["Yes", "No"].filter(
5356
+ (label) => labels.some((value) => normalizeLabel2(value) === normalizeLabel2(label))
5357
+ );
5358
+ };
5359
+ var resolveInitialOutcomeLabel = (labels, defaultOutcomeLabel) => {
5360
+ var _a;
5361
+ if (labels.length === 0)
5362
+ return void 0;
5363
+ if (defaultOutcomeLabel) {
5364
+ const matchedLabel = labels.find(
5365
+ (label) => normalizeLabel2(label) === normalizeLabel2(defaultOutcomeLabel)
5366
+ );
5367
+ if (matchedLabel)
5368
+ return matchedLabel;
5369
+ }
5370
+ if (hasBinaryLabels(labels)) {
5371
+ return (_a = labels.find((label) => normalizeLabel2(label) === "yes")) != null ? _a : labels[0];
5372
+ }
5373
+ return labels[0];
5374
+ };
5375
+ var resolveAverageProbabilityByLabel = (venueMarkets, labels) => {
5376
+ return new Map(
5377
+ labels.map((label) => {
5378
+ const matchingOutcomes = resolveOutcomesByVenue(venueMarkets, label);
5379
+ const probabilities = matchingOutcomes.map((item) => normalizeProbability(item.outcome.price)).filter((value) => value != null);
5380
+ if (!probabilities.length) {
5381
+ return [label, void 0];
5382
+ }
5383
+ const averageProbability = probabilities.reduce((sum, value) => sum + value, 0) / probabilities.length;
5384
+ return [label, averageProbability];
5385
+ })
5386
+ );
5387
+ };
5388
+ var formatProbabilityPercent = (value) => {
5389
+ if (value == null)
5390
+ return "-";
5391
+ return `${Math.round(value * 100)}%`;
5392
+ };
5393
+ var formatProbabilityCents = (value) => {
5394
+ if (value == null)
5395
+ return "-";
5396
+ const cents = (value * 100).toFixed(1).replace(/\.0$/, "");
5397
+ return `${cents}\xA2`;
5398
+ };
5399
+ var resolveOutcomeTone = (label, index) => {
5400
+ const normalizedLabel = normalizeLabel2(label);
5401
+ if (normalizedLabel === "yes" || normalizedLabel === "up" || normalizedLabel === "buy") {
5402
+ return "positive";
5403
+ }
5404
+ if (normalizedLabel === "no" || normalizedLabel === "down" || normalizedLabel === "sell") {
5405
+ return "negative";
5406
+ }
5407
+ return index === 0 ? "positive" : "negative";
5408
+ };
5409
+ var resolveHeaderOutcomeItems = (venueMarkets, defaultOutcomeLabel) => {
5410
+ const labels = resolveDisplayOutcomeLabels(resolveOutcomeLabels(venueMarkets));
5411
+ const probabilityByLabel = resolveAverageProbabilityByLabel(venueMarkets, labels);
5412
+ return labels.slice(0, 2).map((label, index) => {
5413
+ var _a;
5414
+ return {
5415
+ label,
5416
+ probability: probabilityByLabel.get(label),
5417
+ tone: resolveOutcomeTone(label, index),
5418
+ isDefault: normalizeLabel2(label) === normalizeLabel2((_a = defaultOutcomeLabel != null ? defaultOutcomeLabel : labels[0]) != null ? _a : "")
5419
+ };
5420
+ });
5421
+ };
5422
+ var resolveSubtitle = ({
5423
+ venueMarkets,
5424
+ volume,
5425
+ formatCompactCurrency,
5426
+ labels
5427
+ }) => {
5428
+ const { venueCount } = getVenueSummary(venueMarkets);
5429
+ const parts = [
5430
+ `${venueCount} ${venueCount === 1 ? labels.marketDetails.meta.venueSingular : labels.marketDetails.meta.venuePlural}`
5431
+ ];
5432
+ if (typeof volume === "number") {
5433
+ parts.push(`${formatCompactCurrency(volume)} ${labels.marketDetails.meta.volumeSuffix}`);
5434
+ }
5435
+ return parts.join(" \xB7 ");
5436
+ };
5437
+ var resolveOrderBookRows = ({
5438
+ data,
5439
+ side
5440
+ }) => {
5441
+ if (!(data == null ? void 0 : data.length))
5442
+ return [];
5443
+ const tone = side === "asks" ? "negative" : "positive";
5444
+ const rows = data.flatMap((result) => {
5445
+ var _a;
5446
+ return ((_a = result.orderbook[side]) != null ? _a : []).flatMap(
5447
+ (level, index) => {
5448
+ const parsedLevel = OrderBookLevelSchema.safeParse(level);
5449
+ if (!parsedLevel.success)
5450
+ return [];
5451
+ const parsedRow = OrderBookRowSchema.safeParse({
5452
+ id: `${result.market.id}-${side}-${index}-${parsedLevel.data.price}`,
5453
+ venue: result.market.venue,
5454
+ price: parsedLevel.data.price,
5455
+ size: parsedLevel.data.size,
5456
+ total: parsedLevel.data.price * parsedLevel.data.size,
5457
+ tone
5458
+ });
5459
+ if (!parsedRow.success)
5460
+ return [];
5461
+ return [parsedRow.data];
5462
+ }
5463
+ );
5464
+ });
5465
+ const sortedRows = [...rows].sort((left, right) => {
5466
+ if (side === "asks")
5467
+ return left.price - right.price;
5468
+ return right.price - left.price;
5469
+ });
5470
+ const maxTotal = sortedRows.reduce((currentMax, row) => Math.max(currentMax, row.total), 0) || 1;
5471
+ return sortedRows.map((row) => __spreadProps(__spreadValues({}, row), {
5472
+ barScale: row.total / maxTotal
5473
+ }));
5474
+ };
5475
+ var resolveOtherTabRows = (market, labels) => {
5476
+ var _a;
5477
+ const rows = [];
5478
+ rows.push({
5479
+ label: labels.marketDetails.meta.status,
5480
+ value: (_a = market.status) != null ? _a : labels.marketDetails.meta.unknown
5481
+ });
5482
+ if (market.creationDate) {
5483
+ rows.push({
5484
+ label: labels.marketDetails.meta.created,
5485
+ value: (0, import_dayjs4.default)(market.creationDate).format("MMM D, YYYY")
5486
+ });
5487
+ }
5488
+ if (market.startDate) {
5489
+ rows.push({
5490
+ label: labels.marketDetails.meta.opens,
5491
+ value: (0, import_dayjs4.default)(market.startDate).format("MMM D, YYYY")
5492
+ });
5493
+ }
5494
+ if (market.endDate) {
5495
+ rows.push({
5496
+ label: labels.marketDetails.meta.closes,
5497
+ value: (0, import_dayjs4.default)(market.endDate).format("MMM D, YYYY")
5498
+ });
5499
+ }
5500
+ if (rows.length === 1) {
5501
+ rows.push({
5502
+ label: labels.marketDetails.meta.markets,
5503
+ value: `${market.venueMarkets.length}`
5504
+ });
5505
+ }
5506
+ return rows;
5507
+ };
5508
+ var buildMarketDetailsModel = ({
5509
+ event,
5510
+ marketId,
5511
+ title,
5512
+ image,
5513
+ formatCompactCurrency,
5514
+ labels
5515
+ }) => {
5516
+ var _a;
5517
+ const market = resolveMarket(event, marketId);
5518
+ if (!market)
5519
+ return void 0;
5520
+ const primaryVenueMarket = selectPrimaryVenueMarket(market.venueMarkets);
5521
+ if (!primaryVenueMarket)
5522
+ return void 0;
5523
+ const resolvedTitle = resolveTileTitle(event, primaryVenueMarket, title);
5524
+ const resolvedImage = resolveTileImage(event, primaryVenueMarket, image);
5525
+ const resolvedVolume = typeof market.volume === "number" ? market.volume : (_a = primaryVenueMarket.volume) != null ? _a : void 0;
5526
+ const subtitle = resolveSubtitle({
5527
+ venueMarkets: market.venueMarkets,
5528
+ volume: resolvedVolume,
5529
+ formatCompactCurrency,
5530
+ labels
5531
+ });
5532
+ const outcomeLabels = resolveDisplayOutcomeLabels(resolveOutcomeLabels(market.venueMarkets));
5533
+ const probabilityByLabel = resolveAverageProbabilityByLabel(market.venueMarkets, outcomeLabels);
5534
+ return {
5535
+ market,
5536
+ primaryVenueMarket,
5537
+ title: resolvedTitle,
5538
+ image: resolvedImage,
5539
+ subtitle,
5540
+ outcomeLabels,
5541
+ probabilityByLabel
5542
+ };
5543
+ };
5544
+
5545
+ // src/events/market-details/index.tsx
5546
+ var import_jsx_runtime70 = require("react/jsx-runtime");
5547
+ var MarketDetailsLoadingState = ({
5548
+ isOpened = marketDetailsDefaultIsOpened,
5549
+ ariaLabel,
5550
+ classNames
5551
+ }) => {
5552
+ const labels = (0, import_hooks19.useLabels)();
5553
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
5554
+ Skeleton,
5555
+ {
5556
+ view: isOpened ? "market-details-detailed" : "market-details-minified",
5557
+ className: classNames == null ? void 0 : classNames.root,
5558
+ ariaLabel: ariaLabel != null ? ariaLabel : labels.marketDetails.loading
5559
+ }
5560
+ );
5561
+ };
5562
+ var MarketDetailsUnavailableState = ({
5563
+ ariaLabel,
5564
+ classNames
5565
+ }) => {
5566
+ const labels = (0, import_hooks19.useLabels)();
5567
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
5568
+ Card,
5569
+ {
5570
+ className: cn(marketDetailsBaseCardClassName, classNames == null ? void 0 : classNames.root),
5571
+ role: "status",
5572
+ "aria-label": ariaLabel != null ? ariaLabel : labels.marketDetails.unavailableAria,
5573
+ children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex flex-col gap-1 p-5", children: [
5574
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Typography, { variant: "body-large-strong", children: labels.marketDetails.unavailableTitle }),
5575
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Typography, { variant: "label", className: "text-agg-muted-foreground", children: labels.marketDetails.unavailableDescription })
5576
+ ] })
5577
+ }
5578
+ );
5579
+ };
5580
+ var MarketDetailsNotFoundState = ({
5581
+ ariaLabel,
5582
+ classNames
5583
+ }) => {
5584
+ const labels = (0, import_hooks19.useLabels)();
5585
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Card, { className: cn(marketDetailsBaseCardClassName, "p-0", classNames == null ? void 0 : classNames.root), children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
5586
+ StateMessage,
5587
+ {
5588
+ ariaLabel: ariaLabel != null ? ariaLabel : labels.marketDetails.notFoundAria,
5589
+ title: labels.marketDetails.notFoundTitle,
5590
+ description: labels.marketDetails.notFoundDescription,
5591
+ className: "min-h-[280px] md:min-h-[320px]"
5592
+ }
5593
+ ) });
5594
+ };
5595
+ var OrderBookRows = ({
5596
+ rows,
5597
+ title,
5598
+ formatNumber,
5599
+ formatCurrency,
5600
+ visibleRows
5601
+ }) => {
5602
+ const labels = (0, import_hooks19.useLabels)();
5603
+ const isAsks = title === labels.marketDetails.asks;
5604
+ const priceClassName = isAsks ? "text-agg-orderbook-ask" : "text-agg-orderbook-bid";
5605
+ const barClassName = isAsks ? "bg-agg-orderbook-ask/10" : "bg-agg-orderbook-bid/10";
5606
+ const maxVisibleRows = Math.max(1, visibleRows);
5607
+ const orderBookRowHeightPx = 28;
5608
+ const orderBookDividerHeightPx = 1;
5609
+ const orderBookRowGapPx = 8;
5610
+ const orderBookVisibleHeightPx = maxVisibleRows * orderBookRowHeightPx + Math.max(0, maxVisibleRows - 1) * (orderBookDividerHeightPx + orderBookRowGapPx);
5611
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex flex-col gap-2", children: [
5612
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Typography, { variant: "caption-caps", children: title }),
5613
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
5614
+ "div",
5615
+ {
5616
+ className: "overflow-y-auto pr-1 flex flex-col gap-2",
5617
+ style: { maxHeight: `${orderBookVisibleHeightPx}px` },
5618
+ role: "region",
5619
+ "aria-label": `${title} order book levels`,
5620
+ children: rows.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex flex-col gap-2", children: [
5621
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "grid grid-cols-[52px_1fr_1fr_52px] items-center gap-2 md:grid-cols-[88px_1fr_1fr_minmax(120px,220px)] md:gap-6", children: [
5622
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex items-center gap-1 md:gap-3", children: [
5623
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(VenueLogo, { venue: row.venue, size: "small" }),
5624
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
5625
+ "span",
5626
+ {
5627
+ className: cn(
5628
+ "text-agg-xs font-agg-bold leading-agg-4 md:text-agg-sm md:leading-agg-5",
5629
+ priceClassName
5630
+ ),
5631
+ children: formatProbabilityCents(row.price)
5632
+ }
5633
+ )
5634
+ ] }),
5635
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "truncate text-agg-xs leading-agg-4 text-center text-agg-foreground md:text-agg-sm md:leading-agg-5", children: formatNumber(row.size) }),
5636
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "truncate text-agg-xs leading-agg-4 text-center text-agg-foreground md:text-agg-sm md:leading-agg-5", children: formatCurrency(row.total) }),
5637
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
5638
+ "div",
5639
+ {
5640
+ "aria-hidden": "true",
5641
+ className: cn("h-2 rounded-agg-full", barClassName),
5642
+ style: {
5643
+ width: `${Math.max(20, Math.round(row.barScale * 100))}%`
5644
+ }
5645
+ }
5646
+ ) })
5647
+ ] }),
5648
+ index < rows.length - 1 ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "h-px w-full bg-agg-separator" }) : null
5649
+ ] }, row.id))
5650
+ }
5651
+ )
5652
+ ] });
5653
+ };
5654
+ var getOutcomeButtonClassName = ({
5655
+ enableAnimations,
5656
+ isPositive,
5657
+ isActive
5658
+ }) => {
5659
+ const defaultStateClassName = isPositive ? "border-[#18c15c]/50 bg-[#18c15c]/5 text-agg-foreground hover:bg-[#18c15c]/10" : "border-[#e5455f]/50 bg-[#e5455f]/5 text-agg-foreground hover:bg-[#e5455f]/10";
5660
+ const activeStateClassName = isPositive ? "border-transparent bg-[#18c15c] text-agg-on-primary" : "border-transparent bg-[#e5455f] text-agg-on-primary";
5661
+ return cn(
5662
+ "h-auto min-h-10 flex-1 rounded-agg-full border px-4 py-1.5 text-agg-base leading-agg-6 shadow-none md:flex-none md:min-w-[168px]",
5663
+ getMotionClassName(enableAnimations, "transition-all duration-300 ease-in-out"),
5664
+ isActive ? activeStateClassName : defaultStateClassName,
5665
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-2 focus-visible:ring-offset-agg-secondary-hover",
5666
+ "cursor-pointer disabled:cursor-not-allowed disabled:text-agg-muted-foreground",
5667
+ isActive ? "font-agg-bold" : "font-agg-normal"
5668
+ );
5669
+ };
5670
+ var MarketDetailsContent = ({
5671
+ event,
5672
+ marketId,
5673
+ title,
5674
+ image,
5675
+ isOpened: defaultIsOpened = marketDetailsDefaultIsOpened,
5676
+ onOpenChange,
5677
+ defaultTab,
5678
+ defaultOutcomeLabel,
5679
+ defaultTimeRange = "1M",
5680
+ orderBookDepth = orderBookRowLimitDefault,
5681
+ ariaLabel,
5682
+ classNames,
5683
+ otherContent
5684
+ }) => {
5685
+ const config = (0, import_hooks19.useSdkUiConfig)();
5686
+ const labels = (0, import_hooks19.useLabels)();
5687
+ const detailsContentId = (0, import_react9.useId)();
5688
+ const model = (0, import_react9.useMemo)(() => {
5689
+ return buildMarketDetailsModel({
5690
+ event,
5691
+ marketId,
5692
+ title,
5693
+ image,
5694
+ formatCompactCurrency: config.formatCompactCurrency,
5695
+ labels
5696
+ });
5697
+ }, [config.formatCompactCurrency, event, image, labels, marketId, title]);
5698
+ const resolvedMarket = (0, import_react9.useMemo)(() => {
5699
+ return resolveMarket(event, marketId);
5700
+ }, [event, marketId]);
5701
+ const marketDetailsTabs = (0, import_react9.useMemo)(() => {
5702
+ return getMarketDetailsTabs(labels);
5703
+ }, [labels]);
5704
+ const [selectedTab, setSelectedTab] = (0, import_react9.useState)(
5705
+ () => resolveInitialTab(defaultTab)
5706
+ );
5707
+ const [isOpened, setIsOpened] = (0, import_react9.useState)(defaultIsOpened);
5708
+ (0, import_react9.useEffect)(() => {
5709
+ setSelectedTab(resolveInitialTab(defaultTab));
5710
+ }, [defaultTab]);
5711
+ const [selectedTimeRange, setSelectedTimeRange] = (0, import_react9.useState)(defaultTimeRange);
5712
+ (0, import_react9.useEffect)(() => {
5713
+ setSelectedTimeRange(defaultTimeRange);
5714
+ }, [defaultTimeRange]);
5715
+ const [selectedOutcomeLabel, setSelectedOutcomeLabel] = (0, import_react9.useState)(
5716
+ () => {
5717
+ var _a;
5718
+ return resolveInitialOutcomeLabel((_a = model == null ? void 0 : model.outcomeLabels) != null ? _a : [], defaultOutcomeLabel);
5719
+ }
5720
+ );
5721
+ const [selectedGraphVenue, setSelectedGraphVenue] = (0, import_react9.useState)(null);
5722
+ (0, import_react9.useEffect)(() => {
5723
+ var _a;
5724
+ setSelectedOutcomeLabel(
5725
+ resolveInitialOutcomeLabel((_a = model == null ? void 0 : model.outcomeLabels) != null ? _a : [], defaultOutcomeLabel)
5726
+ );
5727
+ }, [defaultOutcomeLabel, model == null ? void 0 : model.outcomeLabels]);
5728
+ const headerOutcomeItems = (0, import_react9.useMemo)(() => {
5729
+ if (!model)
5730
+ return [];
5731
+ return resolveHeaderOutcomeItems(model.market.venueMarkets, selectedOutcomeLabel);
5732
+ }, [model, selectedOutcomeLabel]);
5733
+ const headlineProbability = (0, import_react9.useMemo)(() => {
5734
+ if (!model || !selectedOutcomeLabel)
5735
+ return void 0;
5736
+ return model.probabilityByLabel.get(selectedOutcomeLabel);
5737
+ }, [model, selectedOutcomeLabel]);
5738
+ const outcomesByLabel = (0, import_react9.useMemo)(() => {
5739
+ const outcomesByLabelMap = /* @__PURE__ */ new Map();
5740
+ if (!model) {
5741
+ return outcomesByLabelMap;
5742
+ }
5743
+ headerOutcomeItems.forEach((headerOutcomeItem) => {
5744
+ outcomesByLabelMap.set(
5745
+ headerOutcomeItem.label,
5746
+ resolveOutcomesByVenue(model.market.venueMarkets, headerOutcomeItem.label)
5747
+ );
5748
+ });
5749
+ return outcomesByLabelMap;
5750
+ }, [headerOutcomeItems, model]);
5751
+ const selectedOutcomesByVenue = (0, import_react9.useMemo)(() => {
5752
+ var _a;
5753
+ if (!selectedOutcomeLabel)
5754
+ return [];
5755
+ return (_a = outcomesByLabel.get(selectedOutcomeLabel)) != null ? _a : [];
5756
+ }, [outcomesByLabel, selectedOutcomeLabel]);
5757
+ const timeWindow = (0, import_react9.useMemo)(() => {
5758
+ return getTimeWindowByRange(selectedTimeRange);
5759
+ }, [selectedTimeRange]);
5760
+ const graphOutcomes = (0, import_react9.useMemo)(() => {
5761
+ const uniqueOutcomesByVenueAndId = /* @__PURE__ */ new Map();
5762
+ outcomesByLabel.forEach((outcomes) => {
5763
+ outcomes.forEach((outcomeByVenue) => {
5764
+ uniqueOutcomesByVenueAndId.set(
5765
+ `${outcomeByVenue.venue}:${outcomeByVenue.outcome.id}`,
5766
+ outcomeByVenue
5767
+ );
5768
+ });
5769
+ });
5770
+ return [...uniqueOutcomesByVenueAndId.values()];
5771
+ }, [outcomesByLabel]);
5772
+ const canonicalMarketIdForHistory = model == null ? void 0 : model.market.id;
5773
+ const priceHistoryGroups = (0, import_react9.useMemo)(() => {
5774
+ return buildPriceHistoryGroups(graphOutcomes, canonicalMarketIdForHistory);
5775
+ }, [canonicalMarketIdForHistory, graphOutcomes]);
5776
+ const { data: priceHistoryData, isLoading: isPriceHistoryLoading } = (0, import_hooks19.usePriceHistory)(__spreadProps(__spreadValues({
5777
+ groups: priceHistoryGroups
5778
+ }, timeWindow), {
5779
+ enabled: isOpened && selectedTab === "graph" && priceHistoryGroups.length > 0
5780
+ }));
5781
+ const orderBookInputs = (0, import_react9.useMemo)(() => {
5782
+ return selectedOutcomesByVenue.map(({ market, outcome }) => ({
5783
+ market,
5784
+ outcome,
5785
+ liveUpdate: true
5786
+ }));
5787
+ }, [selectedOutcomesByVenue]);
5788
+ const {
5789
+ data: orderBookData,
5790
+ isLoading: isOrderBookLoading,
5791
+ error: orderBookError,
5792
+ results: orderBookResults
5793
+ } = (0, import_hooks19.useOrderBook)({
5794
+ orderbooks: orderBookInputs,
5795
+ enabled: isOpened && selectedTab === "order-book" && orderBookInputs.length > 0
5796
+ });
5797
+ const askRows = (0, import_react9.useMemo)(() => {
5798
+ return resolveOrderBookRows({
5799
+ data: orderBookData,
5800
+ side: "asks"
5801
+ });
5802
+ }, [orderBookData]);
5803
+ const bidRows = (0, import_react9.useMemo)(() => {
5804
+ return resolveOrderBookRows({
5805
+ data: orderBookData,
5806
+ side: "bids"
5807
+ });
5808
+ }, [orderBookData]);
5809
+ const priceHistoryByVenue = (0, import_react9.useMemo)(() => {
5810
+ const historyByVenue = /* @__PURE__ */ new Map();
5811
+ if (!(priceHistoryData == null ? void 0 : priceHistoryData.length)) {
5812
+ return historyByVenue;
5813
+ }
5814
+ priceHistoryData.forEach((historyItem) => {
5815
+ const venue = historyItem.venue;
5816
+ const venueHistory = historyByVenue.get(venue);
5817
+ if (venueHistory) {
5818
+ venueHistory.push(historyItem);
5819
+ return;
5820
+ }
5821
+ historyByVenue.set(venue, [historyItem]);
5822
+ });
5823
+ return historyByVenue;
5824
+ }, [priceHistoryData]);
5825
+ const graphSeriesByOutcomeLabel = (0, import_react9.useMemo)(() => {
5826
+ const seriesByOutcomeLabel = /* @__PURE__ */ new Map();
5827
+ const resolveOutcomeCandidateIds2 = (outcomeByVenue) => {
5828
+ var _a, _b;
5829
+ const marketWithCanonicalId = outcomeByVenue.market;
5830
+ return [
5831
+ outcomeByVenue.outcome.id,
5832
+ (_a = outcomeByVenue.outcome.externalIdentifier) != null ? _a : void 0,
5833
+ outcomeByVenue.market.externalIdentifier,
5834
+ (_b = marketWithCanonicalId.marketId) != null ? _b : void 0,
5835
+ canonicalMarketIdForHistory
5836
+ ].filter((value) => typeof value === "string" && value.trim().length > 0);
5837
+ };
5838
+ headerOutcomeItems.forEach((headerOutcomeItem) => {
5839
+ var _a;
5840
+ const outcomes = (_a = outcomesByLabel.get(headerOutcomeItem.label)) != null ? _a : [];
5841
+ const graphSeries2 = [];
5842
+ outcomes.forEach((outcomeByVenue, index) => {
5843
+ var _a2;
5844
+ const venueHistory = priceHistoryByVenue.get(outcomeByVenue.venue);
5845
+ if (!(venueHistory == null ? void 0 : venueHistory.length))
5846
+ return;
5847
+ const candidateIds = resolveOutcomeCandidateIds2(outcomeByVenue);
5848
+ const matchingHistory = (_a2 = venueHistory.find((historyItem) => candidateIds.includes(historyItem.marketId))) != null ? _a2 : venueHistory.length === 1 ? venueHistory[0] : void 0;
5849
+ if (!matchingHistory)
5850
+ return;
5851
+ const points = matchingHistory.points.map((point) => ({
5852
+ time: point.timestamp,
5853
+ value: point.price * 100
5854
+ })).filter((point) => Number.isFinite(point.time) && Number.isFinite(point.value));
5855
+ if (points.length === 0)
5856
+ return;
5857
+ graphSeries2.push({
5858
+ id: `${headerOutcomeItem.label}-${outcomeByVenue.venue}-${matchingHistory.marketId}`,
5859
+ venue: outcomeByVenue.venue,
5860
+ color: resolveSeriesColor(outcomeByVenue.venue, index),
5861
+ points
5862
+ });
5863
+ });
5864
+ seriesByOutcomeLabel.set(headerOutcomeItem.label, graphSeries2);
5865
+ });
5866
+ return seriesByOutcomeLabel;
5867
+ }, [canonicalMarketIdForHistory, headerOutcomeItems, outcomesByLabel, priceHistoryByVenue]);
5868
+ const graphSeries = (0, import_react9.useMemo)(() => {
5869
+ var _a;
5870
+ if (!selectedOutcomeLabel)
5871
+ return [];
5872
+ const seriesForOutcomeLabel = (_a = graphSeriesByOutcomeLabel.get(selectedOutcomeLabel)) != null ? _a : [];
5873
+ if (!selectedGraphVenue)
5874
+ return seriesForOutcomeLabel;
5875
+ return seriesForOutcomeLabel.filter((seriesItem) => seriesItem.venue === selectedGraphVenue);
5876
+ }, [graphSeriesByOutcomeLabel, selectedGraphVenue, selectedOutcomeLabel]);
5877
+ const otherRows = (0, import_react9.useMemo)(() => {
5878
+ if (!model)
5879
+ return [];
5880
+ return resolveOtherTabRows(model.market, labels);
5881
+ }, [labels, model]);
5882
+ const isOrderBookNotFound = isErrorWithStatus(orderBookError, 404);
5883
+ const hasOrderBookError = !!orderBookError && !isOrderBookNotFound;
5884
+ const hasNoOrderBook = isOrderBookNotFound || !isOrderBookLoading && !hasOrderBookError && (orderBookInputs.length === 0 || askRows.length === 0 && bidRows.length === 0);
5885
+ const handleOutcomeKeyDown = (eventToHandle) => {
5886
+ var _a;
5887
+ if ((eventToHandle == null ? void 0 : eventToHandle.key) !== "ArrowLeft" && (eventToHandle == null ? void 0 : eventToHandle.key) !== "ArrowRight") {
5888
+ return;
5889
+ }
5890
+ if (headerOutcomeItems.length <= 1)
5891
+ return;
5892
+ const activeIndex = headerOutcomeItems.findIndex((item) => {
5893
+ return item.label === selectedOutcomeLabel;
5894
+ });
5895
+ const direction = eventToHandle.key === "ArrowRight" ? 1 : -1;
5896
+ const nextIndex = activeIndex < 0 ? 0 : (activeIndex + direction + headerOutcomeItems.length) % headerOutcomeItems.length;
5897
+ setSelectedOutcomeLabel((_a = headerOutcomeItems[nextIndex]) == null ? void 0 : _a.label);
5898
+ };
5899
+ const handleToggleExpanded = (event2) => {
5900
+ if (event2 && "key" in event2 && (event2 == null ? void 0 : event2.key) !== "Enter" && (event2 == null ? void 0 : event2.key) !== " ") {
5901
+ return;
5902
+ }
5903
+ event2 == null ? void 0 : event2.preventDefault();
5904
+ event2 == null ? void 0 : event2.stopPropagation();
5905
+ setIsOpened((prev) => {
5906
+ const next = !prev;
5907
+ onOpenChange == null ? void 0 : onOpenChange(next);
5908
+ return next;
5909
+ });
5910
+ };
5911
+ const handleGraphVenueToggle = (venue) => {
5912
+ setSelectedGraphVenue((currentVenue) => {
5913
+ if (currentVenue === venue)
5914
+ return null;
5915
+ return venue;
5916
+ });
5917
+ };
5918
+ const handleRetryOrderBook = () => {
5919
+ void Promise.all(orderBookResults.map((result) => result.refetch()));
5920
+ };
5921
+ (0, import_react9.useEffect)(() => {
5922
+ if (!selectedGraphVenue) {
5923
+ return;
5924
+ }
5925
+ if (selectedOutcomesByVenue.some((item) => item.venue === selectedGraphVenue)) {
5926
+ return;
5927
+ }
5928
+ setSelectedGraphVenue(null);
5929
+ }, [selectedGraphVenue, selectedOutcomesByVenue]);
5930
+ if (marketId && !resolvedMarket) {
5931
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(MarketDetailsNotFoundState, { ariaLabel, classNames });
5932
+ }
5933
+ if (!model) {
5934
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(MarketDetailsUnavailableState, { ariaLabel, classNames });
5935
+ }
5936
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
5937
+ Card,
5938
+ {
5939
+ className: cn(
5940
+ "w-full rounded-agg-2xl text-left outline-none",
5941
+ marketDetailsBaseCardClassName,
5942
+ classNames == null ? void 0 : classNames.root
5943
+ ),
5944
+ children: [
5945
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
5946
+ "div",
5947
+ {
5948
+ className: cn(
5949
+ "cursor-pointer disabled:cursor-default",
5950
+ "flex flex-wrap flex-row items-center justify-between gap-3 px-5 py-4",
5951
+ isOpened && "pb-3",
5952
+ classNames == null ? void 0 : classNames.header
5953
+ ),
5954
+ "aria-expanded": isOpened,
5955
+ "aria-controls": detailsContentId,
5956
+ role: "button",
5957
+ tabIndex: 0,
5958
+ "aria-label": isOpened ? labels.marketDetails.toggleCloseDetailsAria(model.title) : labels.marketDetails.toggleOpenDetailsAria(model.title),
5959
+ onClick: handleToggleExpanded,
5960
+ onKeyDown: handleToggleExpanded,
5961
+ children: [
5962
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex min-w-52 items-center gap-3 md:gap-4", children: [
5963
+ model.image ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
5964
+ "img",
5965
+ {
5966
+ src: model.image,
5967
+ alt: "",
5968
+ className: "size-12 rounded-agg-lg object-cover md:size-[60px]"
5969
+ }
5970
+ ) : null,
5971
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex min-w-0 flex-col", children: [
5972
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Typography, { as: "h3", variant: "body-large-strong", className: "truncate", children: model.title }),
5973
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Typography, { variant: "label", className: "truncate text-agg-muted-foreground", children: model.subtitle }) })
5974
+ ] })
5975
+ ] }),
5976
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Typography, { as: "div", variant: "heading", className: "shrink-0", children: formatProbabilityPercent(headlineProbability) }),
5977
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
5978
+ "div",
5979
+ {
5980
+ className: "flex gap-2",
5981
+ role: "tablist",
5982
+ "aria-label": labels.marketDetails.marketOutcomesAria,
5983
+ tabIndex: 0,
5984
+ onKeyDown: (e) => handleOutcomeKeyDown(e),
5985
+ children: headerOutcomeItems.map((item) => {
5986
+ const isPositive = item.tone === "positive";
5987
+ const isActiveOutcome = item.label === selectedOutcomeLabel;
5988
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
5989
+ "button",
5990
+ {
5991
+ type: "button",
5992
+ role: "tab",
5993
+ "aria-selected": isActiveOutcome,
5994
+ tabIndex: isActiveOutcome ? 0 : -1,
5995
+ className: getOutcomeButtonClassName({
5996
+ enableAnimations: config.enableAnimations,
5997
+ isPositive,
5998
+ isActive: isActiveOutcome
5999
+ }),
6000
+ onClick: (e) => {
6001
+ e.preventDefault();
6002
+ e.stopPropagation();
6003
+ setSelectedOutcomeLabel(item.label);
6004
+ },
6005
+ children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { className: "inline-flex items-center gap-2", children: [
6006
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6007
+ VenueLogo,
6008
+ {
6009
+ venue: isPositive ? "polymarket" : "probable",
6010
+ size: "small",
6011
+ color: isActiveOutcome ? "var(--agg-color-on-primary)" : void 0
6012
+ }
6013
+ ),
6014
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6015
+ Typography,
6016
+ {
6017
+ variant: isActiveOutcome ? "body-strong" : "body",
6018
+ className: cn(
6019
+ "text-agg-base leading-agg-6",
6020
+ isActiveOutcome ? "text-agg-on-primary" : "text-agg-foreground"
6021
+ ),
6022
+ children: `${item.label} ${formatProbabilityCents(item.probability)}`
6023
+ }
6024
+ )
6025
+ ] })
6026
+ },
6027
+ item.label
6028
+ );
6029
+ })
6030
+ }
6031
+ )
6032
+ ]
6033
+ }
6034
+ ),
6035
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6036
+ "div",
6037
+ {
6038
+ id: detailsContentId,
6039
+ className: cn(
6040
+ "grid overflow-hidden",
6041
+ getMotionClassName(config.enableAnimations, "transition-all duration-500 ease-in-out"),
6042
+ isOpened ? "grid-rows-[1fr] opacity-100" : "pointer-events-none grid-rows-[0fr] opacity-0"
6043
+ ),
6044
+ "aria-hidden": !isOpened,
6045
+ children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "min-h-0", children: [
6046
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "h-px w-full bg-agg-separator" }),
6047
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
6048
+ "div",
6049
+ {
6050
+ className: cn(
6051
+ getMotionClassName(
6052
+ config.enableAnimations,
6053
+ "transition-all duration-500 ease-in-out"
6054
+ ),
6055
+ isOpened ? cn(
6056
+ "translate-y-0 opacity-100",
6057
+ getMotionClassName(config.enableAnimations, "delay-100")
6058
+ ) : "translate-y-5 opacity-0"
6059
+ ),
6060
+ children: [
6061
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: cn("block", classNames == null ? void 0 : classNames.tabs), children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6062
+ Tabs,
6063
+ {
6064
+ ariaLabel: labels.marketDetails.tabsAria,
6065
+ items: marketDetailsTabs,
6066
+ value: selectedTab === "other" ? "order-book" : selectedTab,
6067
+ onChange: (nextValue) => setSelectedTab(nextValue),
6068
+ variant: "underline",
6069
+ className: "w-full px-5"
6070
+ }
6071
+ ) }),
6072
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "h-px w-full bg-agg-separator" }),
6073
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: cn("p-5", classNames == null ? void 0 : classNames.content), children: [
6074
+ selectedTab === "order-book" ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: cn("flex flex-col gap-5", classNames == null ? void 0 : classNames.orderBook), children: isOrderBookLoading ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(MarketDetailsOderbookSkeleton, {}) : hasOrderBookError ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6075
+ StateMessage,
6076
+ {
6077
+ ariaLabel: labels.marketDetails.orderBookUnavailableAria,
6078
+ tone: "warning",
6079
+ title: labels.marketDetails.orderBookUnavailableTitle,
6080
+ description: labels.marketDetails.orderBookUnavailableDescription,
6081
+ actionLabel: labels.common.retry,
6082
+ onAction: handleRetryOrderBook,
6083
+ className: "min-h-[248px] px-5 py-10 md:min-h-[272px]"
6084
+ }
6085
+ ) : hasNoOrderBook ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6086
+ StateMessage,
6087
+ {
6088
+ ariaLabel: labels.marketDetails.orderBookEmptyAria,
6089
+ title: labels.marketDetails.orderBookEmptyTitle,
6090
+ description: labels.marketDetails.orderBookEmptyDescription,
6091
+ className: "min-h-[248px] px-5 py-10 md:min-h-[272px]"
6092
+ }
6093
+ ) : /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [
6094
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6095
+ OrderBookRows,
6096
+ {
6097
+ rows: askRows,
6098
+ title: labels.marketDetails.asks,
6099
+ formatNumber: config.formatNumber,
6100
+ formatCurrency: config.formatCurrency,
6101
+ visibleRows: orderBookDepth
6102
+ }
6103
+ ),
6104
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6105
+ OrderBookRows,
6106
+ {
6107
+ rows: bidRows,
6108
+ title: labels.marketDetails.bids,
6109
+ formatNumber: config.formatNumber,
6110
+ formatCurrency: config.formatCurrency,
6111
+ visibleRows: orderBookDepth
6112
+ }
6113
+ )
6114
+ ] }) }) : null,
6115
+ selectedTab === "graph" ? /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: cn("flex flex-col gap-5", classNames == null ? void 0 : classNames.graph), children: [
6116
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6117
+ LineChart,
6118
+ {
6119
+ series: graphSeries,
6120
+ height: 260,
6121
+ isLoading: isPriceHistoryLoading,
6122
+ classNames: { root: "w-full" },
6123
+ showSeriesControls: selectedOutcomesByVenue.length > 0 || headerOutcomeItems.length > 0,
6124
+ renderSeriesControls: () => {
6125
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex flex-col gap-4 md:flex-row md:items-center md:justify-between", children: [
6126
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "flex flex-wrap gap-2", children: selectedOutcomesByVenue.map((item) => {
6127
+ const probability = formatProbabilityPercent(item.outcome.price);
6128
+ const isActiveVenue = selectedGraphVenue === item.venue;
6129
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
6130
+ "button",
6131
+ {
6132
+ type: "button",
6133
+ "aria-label": `${item.venue} ${probability}`,
6134
+ "aria-pressed": isActiveVenue,
6135
+ className: cn(
6136
+ "inline-flex items-center gap-2 rounded-agg-full border-2 px-4 py-2",
6137
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-2 focus-visible:ring-offset-agg-secondary-hover",
6138
+ isActiveVenue ? "border-agg-primary bg-agg-secondary" : "border-transparent bg-agg-secondary-hover"
6139
+ ),
6140
+ onClick: (e) => {
6141
+ e.preventDefault();
6142
+ e.stopPropagation();
6143
+ handleGraphVenueToggle(item.venue);
6144
+ },
6145
+ children: [
6146
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(VenueLogo, { venue: item.venue, size: "small" }),
6147
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: probability })
6148
+ ]
6149
+ },
6150
+ `${item.market.id}-${item.outcome.id}`
6151
+ );
6152
+ }) }),
6153
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6154
+ SwitchButton,
6155
+ {
6156
+ ariaLabel: labels.marketDetails.outcomeSelectorAria,
6157
+ className: "shrink-0",
6158
+ value: selectedOutcomeLabel != null ? selectedOutcomeLabel : "",
6159
+ onValueChange: (nextValue) => setSelectedOutcomeLabel(nextValue),
6160
+ options: headerOutcomeItems.map((item) => ({
6161
+ value: item.label,
6162
+ label: `${item.label} ${formatProbabilityCents(item.probability)}`,
6163
+ ariaLabel: labels.marketDetails.showOutcomeAria(item.label)
6164
+ }))
6165
+ }
6166
+ )
6167
+ ] });
6168
+ }
6169
+ }
6170
+ ),
6171
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
6172
+ "div",
6173
+ {
6174
+ className: cn(
6175
+ "flex flex-col gap-3 text-agg-sm leading-agg-5 text-agg-muted-foreground md:flex-row md:items-center md:justify-between",
6176
+ classNames == null ? void 0 : classNames.footer
6177
+ ),
6178
+ children: [
6179
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { children: typeof model.market.volume === "number" ? `${config.formatCompactCurrency(model.market.volume)} ${labels.marketDetails.meta.volumeSuffix}` : labels.marketDetails.volumeUnavailable }),
6180
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "flex flex-wrap items-center gap-3 md:gap-4", children: eventListItemDetailsTimeRanges.map((timeRange) => {
6181
+ const isActive = selectedTimeRange === timeRange;
6182
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6183
+ "button",
6184
+ {
6185
+ type: "button",
6186
+ className: cn(
6187
+ "cursor-pointer text-agg-sm leading-agg-5",
6188
+ isActive ? "font-agg-bold text-agg-foreground" : "font-agg-normal text-agg-muted-foreground"
6189
+ ),
6190
+ "aria-pressed": isActive,
6191
+ onClick: (e) => {
6192
+ e.preventDefault();
6193
+ e.stopPropagation();
6194
+ setSelectedTimeRange(timeRange);
6195
+ },
6196
+ children: timeRange === "ALL" ? labels.eventItemDetails.allTimeRange : timeRange
6197
+ },
6198
+ timeRange
6199
+ );
6200
+ }) })
6201
+ ]
6202
+ }
6203
+ )
6204
+ ] }) : null,
6205
+ selectedTab === "other" ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "flex flex-col gap-4", children: otherContent != null ? otherContent : /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "grid grid-cols-1 gap-3", children: otherRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
6206
+ "div",
6207
+ {
6208
+ className: "flex items-center justify-between rounded-agg-xl bg-agg-secondary-hover px-4 py-3",
6209
+ children: [
6210
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Typography, { variant: "label", className: "text-agg-muted-foreground", children: row.label }),
6211
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Typography, { variant: "body", className: "text-right", children: row.value })
6212
+ ]
6213
+ },
6214
+ row.label
6215
+ )) }) }) : null
6216
+ ] })
6217
+ ]
6218
+ }
6219
+ )
6220
+ ] })
6221
+ }
6222
+ )
6223
+ ]
6224
+ }
6225
+ );
6226
+ };
6227
+ var MarketDetails = (props) => {
6228
+ var _a;
6229
+ const [uncontrolledIsOpened, setUncontrolledIsOpened] = (0, import_react9.useState)(
6230
+ (_a = props.defaultIsOpened) != null ? _a : marketDetailsDefaultIsOpened
6231
+ );
6232
+ (0, import_react9.useEffect)(() => {
6233
+ if (typeof props.isOpened !== "boolean")
6234
+ return;
6235
+ setUncontrolledIsOpened(props.isOpened);
6236
+ }, [props.isOpened]);
6237
+ const resolvedIsOpened = typeof props.isOpened === "boolean" ? props.isOpened : uncontrolledIsOpened;
6238
+ const handleOpenChange = (nextIsOpened) => {
6239
+ var _a2;
6240
+ if (typeof props.isOpened !== "boolean") {
6241
+ setUncontrolledIsOpened(nextIsOpened);
6242
+ }
6243
+ (_a2 = props.onOpenChange) == null ? void 0 : _a2.call(props, nextIsOpened);
6244
+ };
6245
+ const hasEventProp = "event" in props && !!props.event;
6246
+ const {
6247
+ event: fetchedEvent,
6248
+ error: eventError,
6249
+ isLoading: isFetchingEvent
6250
+ } = (0, import_hooks19.useEvent)(hasEventProp ? void 0 : props.eventId, {
6251
+ enabled: !props.isLoading && !hasEventProp && !!props.eventId
6252
+ });
6253
+ if (props.isLoading) {
6254
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6255
+ MarketDetailsLoadingState,
6256
+ {
6257
+ isOpened: resolvedIsOpened,
6258
+ ariaLabel: props.ariaLabel,
6259
+ classNames: props.classNames
6260
+ }
6261
+ );
6262
+ }
6263
+ if ("event" in props && props.event) {
6264
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6265
+ MarketDetailsContent,
6266
+ __spreadProps(__spreadValues({}, props), {
6267
+ isOpened: resolvedIsOpened,
6268
+ onOpenChange: handleOpenChange,
6269
+ event: props.event
6270
+ })
6271
+ );
6272
+ }
6273
+ if (isFetchingEvent) {
6274
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6275
+ MarketDetailsLoadingState,
6276
+ {
6277
+ isOpened: resolvedIsOpened,
6278
+ ariaLabel: props.ariaLabel,
6279
+ classNames: props.classNames
6280
+ }
6281
+ );
6282
+ }
6283
+ if (!fetchedEvent) {
6284
+ if (isErrorWithStatus(eventError, 404)) {
6285
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(MarketDetailsNotFoundState, { ariaLabel: props.ariaLabel, classNames: props.classNames });
6286
+ }
6287
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(MarketDetailsUnavailableState, { ariaLabel: props.ariaLabel, classNames: props.classNames });
6288
+ }
6289
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
6290
+ MarketDetailsContent,
6291
+ __spreadProps(__spreadValues({}, props), {
6292
+ isOpened: resolvedIsOpened,
6293
+ onOpenChange: handleOpenChange,
6294
+ event: fetchedEvent
6295
+ })
6296
+ );
6297
+ };
6298
+ MarketDetails.displayName = "MarketDetails";
6299
+
6300
+ // src/trading/place-order/index.tsx
6301
+ var import_react10 = require("react");
6302
+ var import_hooks21 = require("@agg-market/hooks");
6303
+
6304
+ // src/trading/utils.ts
6305
+ var import_hooks20 = require("@agg-market/hooks");
6306
+ var import_dayjs5 = __toESM(require("dayjs"));
6307
+ var defaultLabels = (0, import_hooks20.resolveAggUiLabels)("en-US");
6308
+ var defaultSettlementSectionLabel = defaultLabels.trading.settlementSection;
6309
+ var defaultSettlementDifferencesTitle = defaultLabels.trading.settlementDifferencesTitle;
6310
+ var defaultTradingDisclaimer = defaultLabels.trading.disclaimer;
6311
+ var getTradingDateLabel = (value) => {
6312
+ const parsedValue = (0, import_dayjs5.default)(value);
6313
+ if (!parsedValue.isValid()) {
6314
+ return typeof value === "string" ? value : "";
6315
+ }
6316
+ return parsedValue.format("MMM D, YYYY");
6317
+ };
6318
+ var getTradingVenueLabel = (venue, label) => {
6319
+ if (label)
6320
+ return label;
6321
+ return defaultLabels.venues[venue];
6322
+ };
6323
+
6324
+ // src/trading/place-order/index.tsx
6325
+ var import_jsx_runtime71 = require("react/jsx-runtime");
6326
+ var WarningFilledIcon2 = ({ className }) => {
6327
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
6328
+ "svg",
6329
+ {
6330
+ viewBox: "0 0 16 16",
6331
+ fill: "none",
6332
+ className: cn("text-agg-warning", className),
6333
+ "aria-hidden": "true",
6334
+ children: [
6335
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("path", { d: "M8 1.33301L15.3333 14.6663H0.666656L8 1.33301Z", fill: "currentColor" }),
6336
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("path", { d: "M8 5.33301V8.66634", stroke: "white", strokeWidth: "1.4", strokeLinecap: "round" }),
6337
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("circle", { cx: "8", cy: "11.1667", r: "0.833333", fill: "white" })
6338
+ ]
6339
+ }
6340
+ );
6341
+ };
6342
+ var ErrorFilledIcon = ({ className }) => {
6343
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
6344
+ "svg",
6345
+ {
6346
+ viewBox: "0 0 16 16",
6347
+ fill: "none",
6348
+ className: cn("text-agg-error", className),
6349
+ "aria-hidden": "true",
6350
+ children: [
6351
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("circle", { cx: "8", cy: "8", r: "8", fill: "currentColor" }),
6352
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("path", { d: "M8 4.16699V8.50033", stroke: "white", strokeWidth: "1.4", strokeLinecap: "round" }),
6353
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("circle", { cx: "8", cy: "11.167", r: "0.833333", fill: "white" })
6354
+ ]
6355
+ }
6356
+ );
6357
+ };
6358
+ var getPlaceOrderContainerClassName = () => {
6359
+ return "overflow-hidden rounded-agg-xl border border-agg-border bg-agg-secondary shadow-none hover:shadow-none";
6360
+ };
6361
+ var getRoutingCardClassName = (isHighlighted) => {
6362
+ if (!isHighlighted) {
6363
+ return "border-agg-border bg-agg-secondary";
6364
+ }
6365
+ return "border-agg-trade-highlight-border bg-agg-trade-highlight-surface";
6366
+ };
6367
+ var getResultValueClassName = (tone) => {
6368
+ if (tone === "default")
6369
+ return "text-agg-foreground";
6370
+ return "text-agg-success";
6371
+ };
6372
+ var negativeOutcomePattern = /\b(no|down|against|under|lose|false)\b/i;
6373
+ var resolveIsPositiveOutcome = (outcome, index) => {
6374
+ const outcomeText = `${outcome.id} ${outcome.label}`;
6375
+ if (negativeOutcomePattern.test(outcomeText))
6376
+ return false;
6377
+ if (index === 1)
6378
+ return false;
6379
+ return true;
6380
+ };
6381
+ var getOutcomeButtonClassName2 = ({
6382
+ enableAnimations,
6383
+ isActive,
6384
+ isPositive
6385
+ }) => {
6386
+ return cn(
6387
+ "flex-1 cursor-pointer rounded-agg-full border px-6 py-2.5 text-agg-base leading-agg-6",
6388
+ getMotionClassName(enableAnimations, "transition-all duration-300 ease-in-out"),
6389
+ isActive ? isPositive ? "border-transparent bg-[#18c15c] font-agg-bold text-agg-on-primary" : "border-transparent bg-[#e5455f] font-agg-bold text-agg-on-primary" : "border-transparent bg-agg-secondary-hover font-agg-normal text-agg-foreground hover:bg-agg-tertiary"
6390
+ );
6391
+ };
6392
+ var getStatusContent = ({
6393
+ placement,
6394
+ status,
6395
+ onStatusAction
6396
+ }) => {
6397
+ if (!status || status.placement !== placement)
6398
+ return null;
6399
+ if (status.tone === "warning") {
6400
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex items-center justify-center gap-2", children: [
6401
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(WarningFilledIcon2, { className: "h-4 w-4 shrink-0" }),
6402
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: status.message })
6403
+ ] });
6404
+ }
6405
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex items-center gap-3 rounded-agg-lg bg-agg-status-error-surface px-3 py-2.5", children: [
6406
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
6407
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ErrorFilledIcon, { className: "h-4 w-4 shrink-0" }),
6408
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "min-w-0 flex-1 text-agg-sm leading-agg-5 text-agg-foreground", children: status.message })
6409
+ ] }),
6410
+ status.actionLabel ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
6411
+ "button",
6412
+ {
6413
+ type: "button",
6414
+ className: "shrink-0 text-agg-sm font-agg-bold leading-agg-5 text-agg-primary",
6415
+ "aria-label": status.actionLabel,
6416
+ onClick: onStatusAction,
6417
+ children: status.actionLabel
6418
+ }
6419
+ ) : null
6420
+ ] });
6421
+ };
6422
+ var PlaceOrder = ({
6423
+ title,
6424
+ marketDate,
6425
+ marketImageUrl,
6426
+ activeTab,
6427
+ buyLabel,
6428
+ sellLabel,
6429
+ outcomes,
6430
+ selectedOutcomeId,
6431
+ primaryMetric,
6432
+ routing,
6433
+ result,
6434
+ actionLabel,
6435
+ disclaimer = defaultTradingDisclaimer,
6436
+ isDismissible = false,
6437
+ isLoading = false,
6438
+ status,
6439
+ className,
6440
+ isPrimaryActionDisabled = false,
6441
+ isPrimaryActionLoading = false,
6442
+ onClose,
6443
+ onOutcomeChange,
6444
+ onPrimaryAction,
6445
+ onStatusAction,
6446
+ onTabChange
6447
+ }) => {
6448
+ const { enableAnimations } = (0, import_hooks21.useSdkUiConfig)();
6449
+ const labels = (0, import_hooks21.useLabels)();
6450
+ const resolvedDisclaimer = disclaimer === defaultTradingDisclaimer ? labels.trading.disclaimer : disclaimer;
6451
+ if (isLoading) {
6452
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
6453
+ Skeleton,
6454
+ {
6455
+ ariaLabel: labels.common.loading,
6456
+ className,
6457
+ view: skeletonViews.placeOrder
6458
+ }
6459
+ );
6460
+ }
6461
+ const [internalTab, setInternalTab] = (0, import_react10.useState)(activeTab);
6462
+ const [internalOutcomeId, setInternalOutcomeId] = (0, import_react10.useState)(selectedOutcomeId);
6463
+ (0, import_react10.useEffect)(() => {
6464
+ setInternalTab(activeTab);
6465
+ }, [activeTab]);
6466
+ (0, import_react10.useEffect)(() => {
6467
+ setInternalOutcomeId(selectedOutcomeId);
6468
+ }, [selectedOutcomeId]);
6469
+ const resolvedTab = onTabChange ? activeTab : internalTab;
6470
+ const resolvedOutcomeId = onOutcomeChange ? selectedOutcomeId : internalOutcomeId;
6471
+ const hasHighlightedRouting = routing.tone === "highlighted";
6472
+ const dateLabel = getTradingDateLabel(marketDate);
6473
+ const tabItems2 = (0, import_react10.useMemo)(() => {
6474
+ return [
6475
+ { value: "buy", label: buyLabel },
6476
+ { value: "sell", label: sellLabel }
6477
+ ];
6478
+ }, [buyLabel, sellLabel]);
6479
+ const handleTabChange = (nextTab) => {
6480
+ if (!onTabChange) {
6481
+ setInternalTab(nextTab);
6482
+ }
6483
+ onTabChange == null ? void 0 : onTabChange(nextTab);
6484
+ };
6485
+ const handleOutcomeChange = (nextOutcomeId) => {
6486
+ if (!onOutcomeChange) {
6487
+ setInternalOutcomeId(nextOutcomeId);
6488
+ }
6489
+ onOutcomeChange == null ? void 0 : onOutcomeChange(nextOutcomeId);
6490
+ };
6491
+ const actionButton = /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
6492
+ Button,
6493
+ {
6494
+ size: "large",
6495
+ className: "w-full",
6496
+ disabled: isPrimaryActionDisabled,
6497
+ isLoading: isPrimaryActionLoading,
6498
+ "aria-label": actionLabel,
6499
+ onClick: onPrimaryAction,
6500
+ children: actionLabel
6501
+ }
6502
+ );
6503
+ const contentBody = /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex flex-col gap-6 p-5", children: [
6504
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex flex-col gap-2", children: [
6505
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex items-start justify-between gap-5", children: [
6506
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex min-w-0 flex-1 items-center gap-3", children: [
6507
+ marketImageUrl ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
6508
+ "img",
6509
+ {
6510
+ src: marketImageUrl,
6511
+ alt: "",
6512
+ className: "h-12 w-12 shrink-0 rounded-agg-lg object-cover"
6513
+ }
6514
+ ) : null,
6515
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "min-w-0 text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: title })
6516
+ ] }),
6517
+ isDismissible ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
6518
+ "button",
6519
+ {
6520
+ type: "button",
6521
+ "aria-label": labels.common.close,
6522
+ className: "shrink-0 text-agg-foreground",
6523
+ onClick: onClose,
6524
+ children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
6525
+ Icon,
6526
+ {
6527
+ name: "close",
6528
+ size: "medium",
6529
+ className: "h-6 w-6 text-agg-foreground",
6530
+ color: "currentColor"
6531
+ }
6532
+ )
6533
+ }
6534
+ ) : null
6535
+ ] }),
6536
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: dateLabel })
6537
+ ] }),
6538
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
6539
+ Tabs,
6540
+ {
6541
+ ariaLabel: labels.common.tabsAria,
6542
+ items: tabItems2,
6543
+ value: resolvedTab,
6544
+ onChange: handleTabChange,
6545
+ variant: "underline",
6546
+ size: "s",
6547
+ overflowBehavior: "scroll",
6548
+ classNames: {
6549
+ root: "w-full",
6550
+ tabList: "w-full"
6551
+ }
6552
+ }
6553
+ ),
6554
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex flex-col gap-4", children: [
6555
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "flex w-full gap-2", children: outcomes.map((outcome, index) => {
6556
+ const isActive = outcome.id === resolvedOutcomeId;
6557
+ const isPositive = resolveIsPositiveOutcome(outcome, index);
6558
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
6559
+ "button",
6560
+ {
6561
+ type: "button",
6562
+ className: getOutcomeButtonClassName2({
6563
+ enableAnimations,
6564
+ isActive,
6565
+ isPositive
6566
+ }),
6567
+ "aria-pressed": isActive,
6568
+ "aria-label": `${outcome.label} ${outcome.priceLabel}`,
6569
+ onClick: () => handleOutcomeChange(outcome.id),
6570
+ children: `${outcome.label} ${outcome.priceLabel}`
6571
+ },
6572
+ outcome.id
6573
+ );
6574
+ }) }),
6575
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
6576
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex flex-col", children: [
6577
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: primaryMetric.label }),
6578
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "text-agg-sm leading-agg-5 text-agg-muted-foreground", children: primaryMetric.hint })
6579
+ ] }),
6580
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "text-agg-3xl font-agg-bold leading-agg-9 text-agg-foreground", children: primaryMetric.value })
6581
+ ] })
6582
+ ] }),
6583
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex flex-col gap-2", children: [
6584
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
6585
+ "div",
6586
+ {
6587
+ className: cn(
6588
+ "relative overflow-hidden rounded-agg-lg border p-3",
6589
+ getRoutingCardClassName(hasHighlightedRouting)
6590
+ ),
6591
+ children: [
6592
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
6593
+ "div",
6594
+ {
6595
+ className: cn(
6596
+ "pointer-events-none absolute inset-x-0 bottom-0 h-11 bg-linear-to-b from-transparent to-agg-trade-highlight-glow",
6597
+ hasHighlightedRouting ? "opacity-100" : "opacity-0"
6598
+ )
6599
+ }
6600
+ ),
6601
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "relative flex flex-col gap-3", children: [
6602
+ routing.rows.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex flex-col gap-3", children: [
6603
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
6604
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex min-w-0 items-center gap-2", children: [
6605
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
6606
+ VenueLogo,
6607
+ {
6608
+ venue: row.venue,
6609
+ size: "small",
6610
+ ariaLabel: getTradingVenueLabel(row.venue)
6611
+ }
6612
+ ),
6613
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "truncate text-agg-base leading-agg-6 text-agg-foreground", children: row.label })
6614
+ ] }),
6615
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "shrink-0 text-agg-base leading-agg-6 text-agg-foreground", children: row.priceLabel })
6616
+ ] }),
6617
+ index < routing.rows.length - 1 ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
6618
+ "div",
6619
+ {
6620
+ className: cn(
6621
+ "h-px w-full",
6622
+ hasHighlightedRouting ? "bg-agg-trade-highlight-border" : "bg-agg-separator"
6623
+ )
6624
+ }
6625
+ ) : null
6626
+ ] }, `${row.venue}-${row.label}`)),
6627
+ routing.highlightLabel ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "text-center text-agg-sm font-agg-bold leading-agg-5 uppercase text-agg-trade-highlight-accent", children: routing.highlightLabel }) : null
6628
+ ] })
6629
+ ]
6630
+ }
6631
+ ),
6632
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "text-agg-sm leading-agg-5 text-agg-muted-foreground", children: routing.helperLabel })
6633
+ ] }),
6634
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
6635
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "flex flex-col", children: [
6636
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: result.label }),
6637
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "text-agg-sm leading-agg-5 text-agg-muted-foreground", children: result.hint })
6638
+ ] }),
6639
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
6640
+ "p",
6641
+ {
6642
+ className: cn(
6643
+ "text-agg-3xl font-agg-bold leading-agg-9",
6644
+ getResultValueClassName(result.tone)
6645
+ ),
6646
+ children: result.value
6647
+ }
6648
+ )
6649
+ ] }),
6650
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
6651
+ getStatusContent({
6652
+ placement: "above-action",
6653
+ status,
6654
+ onStatusAction
6655
+ }),
6656
+ actionButton,
6657
+ getStatusContent({
6658
+ placement: "below-action",
6659
+ status,
6660
+ onStatusAction
6661
+ })
6662
+ ] }),
6663
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "text-center text-agg-xs leading-agg-4 text-agg-muted-foreground", children: resolvedDisclaimer })
6664
+ ] });
6665
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Card, { className: cn(getPlaceOrderContainerClassName(), className), children: contentBody });
6666
+ };
6667
+ PlaceOrder.displayName = "PlaceOrder";
6668
+
6669
+ // src/trading/settlement/index.tsx
6670
+ var import_react11 = require("react");
6671
+ var import_hooks22 = require("@agg-market/hooks");
6672
+ var import_jsx_runtime72 = require("react/jsx-runtime");
6673
+ var getSettlementHeaderClassName = () => {
6674
+ return "flex items-center justify-between gap-4";
6675
+ };
6676
+ var Settlement = ({
6677
+ sectionLabel = defaultSettlementSectionLabel,
6678
+ question,
6679
+ differencesTitle = defaultSettlementDifferencesTitle,
6680
+ differences,
6681
+ venues,
6682
+ defaultExpandedVenue,
6683
+ expandedVenue,
6684
+ isLoading = false,
6685
+ onExpandedVenueChange,
6686
+ onShowMore,
6687
+ className
6688
+ }) => {
6689
+ var _a, _b;
6690
+ const labels = (0, import_hooks22.useLabels)();
6691
+ const { enableAnimations } = (0, import_hooks22.useSdkUiConfig)();
6692
+ const resolvedSectionLabel = sectionLabel === defaultSettlementSectionLabel ? labels.trading.settlementSection : sectionLabel;
6693
+ const resolvedDifferencesTitle = differencesTitle === defaultSettlementDifferencesTitle ? labels.trading.settlementDifferencesTitle : differencesTitle;
6694
+ const [internalExpandedVenue, setInternalExpandedVenue] = (0, import_react11.useState)(
6695
+ (_b = defaultExpandedVenue != null ? defaultExpandedVenue : (_a = venues[0]) == null ? void 0 : _a.venue) != null ? _b : null
6696
+ );
6697
+ const [expandedDescriptionByVenue, setExpandedDescriptionByVenue] = (0, import_react11.useState)({});
6698
+ const [overflowingDescriptionByVenue, setOverflowingDescriptionByVenue] = (0, import_react11.useState)({});
6699
+ const [collapsedDescriptionByVenue, setCollapsedDescriptionByVenue] = (0, import_react11.useState)({});
6700
+ const descriptionWrapperRefs = (0, import_react11.useRef)(/* @__PURE__ */ new Map());
6701
+ const descriptionMeasureRefs = (0, import_react11.useRef)(/* @__PURE__ */ new Map());
6702
+ (0, import_react11.useEffect)(() => {
6703
+ if (expandedVenue === void 0)
6704
+ return;
6705
+ setInternalExpandedVenue(expandedVenue);
6706
+ }, [expandedVenue]);
6707
+ const resolvedExpandedVenue = expandedVenue === void 0 ? internalExpandedVenue : expandedVenue;
6708
+ const handleVenueClick = (venue) => {
6709
+ const nextVenue = resolvedExpandedVenue === venue ? null : venue;
6710
+ if (expandedVenue === void 0) {
6711
+ setInternalExpandedVenue(nextVenue);
6712
+ }
6713
+ onExpandedVenueChange == null ? void 0 : onExpandedVenueChange(nextVenue);
6714
+ };
6715
+ const handleDescriptionWrapperRef = (0, import_react11.useCallback)(
6716
+ (venue, element) => {
6717
+ if (!element) {
6718
+ descriptionWrapperRefs.current.delete(venue);
6719
+ return;
6720
+ }
6721
+ descriptionWrapperRefs.current.set(venue, element);
6722
+ },
6723
+ []
6724
+ );
6725
+ const handleDescriptionMeasureRef = (0, import_react11.useCallback)(
6726
+ (venue, element) => {
6727
+ if (!element) {
6728
+ descriptionMeasureRefs.current.delete(venue);
6729
+ return;
6730
+ }
6731
+ descriptionMeasureRefs.current.set(venue, element);
6732
+ },
6733
+ []
6734
+ );
6735
+ const updateDescriptionLayout = (0, import_react11.useCallback)(
6736
+ (venue, description, showMoreLabel) => {
6737
+ const descriptionWrapperElement = descriptionWrapperRefs.current.get(venue);
6738
+ const descriptionMeasureElement = descriptionMeasureRefs.current.get(venue);
6739
+ if (!descriptionWrapperElement || !descriptionMeasureElement)
6740
+ return;
6741
+ const wrapperWidth = descriptionWrapperElement.clientWidth;
6742
+ if (wrapperWidth <= 0)
6743
+ return;
6744
+ const computedStyles = window.getComputedStyle(descriptionWrapperElement);
6745
+ const parsedLineHeight = Number.parseFloat(computedStyles.lineHeight);
6746
+ const lineHeight = Number.isFinite(parsedLineHeight) ? parsedLineHeight : 20;
6747
+ const maxHeight = lineHeight * 2 + 1;
6748
+ descriptionMeasureElement.style.width = `${wrapperWidth}px`;
6749
+ const getHeight = (value) => {
6750
+ descriptionMeasureElement.textContent = value;
6751
+ return descriptionMeasureElement.scrollHeight;
6752
+ };
6753
+ const fullHeight = getHeight(description);
6754
+ if (fullHeight <= maxHeight) {
6755
+ setOverflowingDescriptionByVenue((currentState) => {
6756
+ if (currentState[venue] === false)
6757
+ return currentState;
6758
+ return __spreadProps(__spreadValues({}, currentState), {
6759
+ [venue]: false
6760
+ });
6761
+ });
6762
+ setCollapsedDescriptionByVenue((currentState) => {
6763
+ if (currentState[venue] === description)
6764
+ return currentState;
6765
+ return __spreadProps(__spreadValues({}, currentState), {
6766
+ [venue]: description
6767
+ });
6768
+ });
6769
+ return;
6770
+ }
6771
+ const suffix = `... ${showMoreLabel}`;
6772
+ let left = 0;
6773
+ let right = description.length;
6774
+ let bestLength = 0;
6775
+ while (left <= right) {
6776
+ const middle = Math.floor((left + right) / 2);
6777
+ const candidate = description.slice(0, middle).trimEnd();
6778
+ const candidateHeight = getHeight(`${candidate}${suffix}`);
6779
+ if (candidateHeight <= maxHeight) {
6780
+ bestLength = middle;
6781
+ left = middle + 1;
6782
+ continue;
6783
+ }
6784
+ right = middle - 1;
6785
+ }
6786
+ const collapsedDescription = description.slice(0, bestLength).trimEnd();
6787
+ setOverflowingDescriptionByVenue((currentState) => {
6788
+ if (currentState[venue] === true)
6789
+ return currentState;
6790
+ return __spreadProps(__spreadValues({}, currentState), {
6791
+ [venue]: true
6792
+ });
6793
+ });
6794
+ setCollapsedDescriptionByVenue((currentState) => {
6795
+ if (currentState[venue] === collapsedDescription)
6796
+ return currentState;
6797
+ return __spreadProps(__spreadValues({}, currentState), {
6798
+ [venue]: collapsedDescription
6799
+ });
6800
+ });
6801
+ },
6802
+ []
6803
+ );
6804
+ (0, import_react11.useEffect)(() => {
6805
+ if (typeof window === "undefined")
6806
+ return;
6807
+ if (!resolvedExpandedVenue)
6808
+ return;
6809
+ if (expandedDescriptionByVenue[resolvedExpandedVenue])
6810
+ return;
6811
+ const expandedVenueItem = venues.find((venueItem) => venueItem.venue === resolvedExpandedVenue);
6812
+ if (!expandedVenueItem)
6813
+ return;
6814
+ const frameId = window.requestAnimationFrame(() => {
6815
+ var _a2;
6816
+ updateDescriptionLayout(
6817
+ resolvedExpandedVenue,
6818
+ expandedVenueItem.description,
6819
+ (_a2 = expandedVenueItem.showMoreLabel) != null ? _a2 : "Show more"
6820
+ );
6821
+ });
6822
+ return () => {
6823
+ window.cancelAnimationFrame(frameId);
6824
+ };
6825
+ }, [expandedDescriptionByVenue, resolvedExpandedVenue, updateDescriptionLayout, venues]);
6826
+ (0, import_react11.useEffect)(() => {
6827
+ if (!resolvedExpandedVenue)
6828
+ return;
6829
+ if (expandedDescriptionByVenue[resolvedExpandedVenue])
6830
+ return;
6831
+ if (typeof ResizeObserver === "undefined")
6832
+ return;
6833
+ const expandedVenueItem = venues.find((venueItem) => venueItem.venue === resolvedExpandedVenue);
6834
+ if (!expandedVenueItem)
6835
+ return;
6836
+ const descriptionWrapperElement = descriptionWrapperRefs.current.get(resolvedExpandedVenue);
6837
+ if (!descriptionWrapperElement)
6838
+ return;
6839
+ const resizeObserver = new ResizeObserver(() => {
6840
+ var _a2;
6841
+ updateDescriptionLayout(
6842
+ resolvedExpandedVenue,
6843
+ expandedVenueItem.description,
6844
+ (_a2 = expandedVenueItem.showMoreLabel) != null ? _a2 : "Show more"
6845
+ );
6846
+ });
6847
+ resizeObserver.observe(descriptionWrapperElement);
6848
+ return () => {
6849
+ resizeObserver.disconnect();
6850
+ };
6851
+ }, [expandedDescriptionByVenue, resolvedExpandedVenue, updateDescriptionLayout, venues]);
6852
+ const handleDescriptionShowMoreClick = (event, venue) => {
6853
+ event == null ? void 0 : event.stopPropagation();
6854
+ setExpandedDescriptionByVenue((currentState) => {
6855
+ if (currentState[venue])
6856
+ return currentState;
6857
+ return __spreadProps(__spreadValues({}, currentState), {
6858
+ [venue]: true
6859
+ });
6860
+ });
6861
+ onShowMore == null ? void 0 : onShowMore(venue);
6862
+ };
6863
+ if (isLoading) {
6864
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
6865
+ Skeleton,
6866
+ {
6867
+ ariaLabel: labels.trading.settlementLoading,
6868
+ className,
6869
+ view: skeletonViews.settlement
6870
+ }
6871
+ );
6872
+ }
6873
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
6874
+ Card,
6875
+ {
6876
+ className: cn(
6877
+ "flex flex-col w-full gap-5 rounded-agg-xl border border-agg-separator bg-agg-secondary p-5 shadow-none hover:shadow-none",
6878
+ className
6879
+ ),
6880
+ children: [
6881
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: getSettlementHeaderClassName(), children: [
6882
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("p", { className: "text-agg-xs font-agg-bold leading-agg-4 uppercase text-agg-muted-foreground", children: resolvedSectionLabel }),
6883
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("p", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: question })
6884
+ ] }),
6885
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "flex flex-col gap-2", children: [
6886
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("p", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: resolvedDifferencesTitle }),
6887
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("ul", { className: "list-disc pl-5 text-agg-sm leading-agg-5 text-agg-foreground", children: differences.map((difference) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("li", { children: difference }, difference)) })
6888
+ ] }),
6889
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "h-px w-full bg-agg-separator" }),
6890
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "flex flex-col gap-3", children: venues.map((venue) => {
6891
+ var _a2, _b2;
6892
+ const venueLabel = getTradingVenueLabel(venue.venue, venue.label);
6893
+ const isExpanded = resolvedExpandedVenue === venue.venue;
6894
+ const isDescriptionExpanded = !!expandedDescriptionByVenue[venue.venue];
6895
+ const isDescriptionOverflowing = !!overflowingDescriptionByVenue[venue.venue];
6896
+ const shouldShowDescriptionCta = isExpanded && isDescriptionOverflowing && !isDescriptionExpanded;
6897
+ const resolvedShowMoreLabel = (_a2 = venue.showMoreLabel) != null ? _a2 : "Show more";
6898
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "flex flex-col", children: [
6899
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
6900
+ "button",
6901
+ {
6902
+ type: "button",
6903
+ className: cn(
6904
+ "flex items-center gap-2 text-left",
6905
+ "cursor-pointer disabled:cursor-not-allowed hover:opacity-50",
6906
+ getMotionClassName(
6907
+ enableAnimations,
6908
+ "transition-[opacity,color] duration-200 ease-in-out"
6909
+ )
6910
+ ),
6911
+ "aria-expanded": isExpanded,
6912
+ "aria-label": labels.trading.settlementDetailsAria(venueLabel),
6913
+ onClick: () => handleVenueClick(venue.venue),
6914
+ children: [
6915
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
6916
+ VenueLogo,
6917
+ {
6918
+ venue: venue.venue,
6919
+ size: "small",
6920
+ ariaLabel: venueLabel
6921
+ }
6922
+ ),
6923
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
6924
+ "span",
6925
+ {
6926
+ className: cn(
6927
+ "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground",
6928
+ isExpanded ? "text-agg-primary" : "text-agg-foreground"
6929
+ ),
6930
+ children: venueLabel
6931
+ }
6932
+ ),
6933
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
6934
+ Icon,
6935
+ {
6936
+ name: isExpanded ? "chevron-up" : "chevron-down",
6937
+ size: "small",
6938
+ className: "text-agg-foreground",
6939
+ color: "currentColor"
6940
+ }
6941
+ )
6942
+ ]
6943
+ }
6944
+ ),
6945
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
6946
+ "div",
6947
+ {
6948
+ "aria-hidden": !isExpanded,
6949
+ className: cn(
6950
+ "grid overflow-hidden",
6951
+ isExpanded ? "mt-2 grid-rows-[1fr] opacity-100" : "mt-0 grid-rows-[0fr] opacity-0",
6952
+ !isExpanded && "pointer-events-none",
6953
+ getMotionClassName(
6954
+ enableAnimations,
6955
+ "transition-[grid-template-rows,opacity,margin-top] duration-300 ease-in-out"
6956
+ )
6957
+ ),
6958
+ children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
6959
+ "div",
6960
+ {
6961
+ ref: (element) => handleDescriptionWrapperRef(venue.venue, element),
6962
+ className: "relative min-h-0",
6963
+ children: [
6964
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("p", { className: "min-h-0 text-agg-sm leading-agg-5 text-agg-foreground", children: [
6965
+ isDescriptionExpanded || !isDescriptionOverflowing ? venue.description : (_b2 = collapsedDescriptionByVenue[venue.venue]) != null ? _b2 : venue.description,
6966
+ shouldShowDescriptionCta ? /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
6967
+ "... ",
6968
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
6969
+ "button",
6970
+ {
6971
+ type: "button",
6972
+ tabIndex: isExpanded ? 0 : -1,
6973
+ className: cn(
6974
+ "cursor-pointer disabled:cursor-not-allowed",
6975
+ "text-agg-sm leading-agg-5 text-agg-foreground underline-offset-2 hover:underline hover:font-agg-bold",
6976
+ getMotionClassName(
6977
+ enableAnimations,
6978
+ "transition-[text-decoration] duration-200 ease-in-out"
6979
+ )
6980
+ ),
6981
+ "aria-label": labels.trading.settlementShowMoreAria(
6982
+ resolvedShowMoreLabel,
6983
+ venueLabel
6984
+ ),
6985
+ onClick: (event) => handleDescriptionShowMoreClick(event, venue.venue),
6986
+ children: resolvedShowMoreLabel
6987
+ }
6988
+ )
6989
+ ] }) : null
6990
+ ] }),
6991
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
6992
+ "p",
6993
+ {
6994
+ ref: (element) => handleDescriptionMeasureRef(venue.venue, element),
6995
+ "aria-hidden": true,
6996
+ className: "pointer-events-none invisible fixed top-0 left-0 -z-10 whitespace-normal text-agg-sm leading-agg-5"
6997
+ }
6998
+ )
6999
+ ]
7000
+ }
7001
+ )
7002
+ }
7003
+ )
7004
+ ] }, venue.venue);
7005
+ }) })
7006
+ ]
7007
+ }
7008
+ );
7009
+ };
7010
+ Settlement.displayName = "Settlement";
7011
+
7012
+ // src/pages/event-market/index.tsx
7013
+ var import_jsx_runtime73 = require("react/jsx-runtime");
7014
+ var getMarketDateValue = (market, fallbackIndex) => {
7015
+ var _a, _b, _c;
7016
+ const candidateDate = (_c = (_b = (_a = market.endDate) != null ? _a : market.startDate) != null ? _b : market.creationDate) != null ? _c : null;
7017
+ if (!candidateDate)
7018
+ return Number.MAX_SAFE_INTEGER - 1 + fallbackIndex;
7019
+ const parsedDate = (0, import_dayjs6.default)(candidateDate);
7020
+ if (!parsedDate.isValid()) {
7021
+ return Number.MAX_SAFE_INTEGER - 1 + fallbackIndex;
7022
+ }
7023
+ return parsedDate.valueOf();
7024
+ };
7025
+ var resolveHeroMarketId = (event, heroMarketId) => {
7026
+ var _a, _b;
7027
+ if (!((_a = event == null ? void 0 : event.markets) == null ? void 0 : _a.length))
7028
+ return void 0;
7029
+ if (heroMarketId) {
7030
+ const matchingHeroMarket = event.markets.find(
7031
+ (market) => market.id === heroMarketId
7032
+ );
7033
+ if (matchingHeroMarket)
7034
+ return matchingHeroMarket.id;
7035
+ }
7036
+ return (_b = event.markets[0]) == null ? void 0 : _b.id;
7037
+ };
7038
+ var buildHeroEvent = (event, heroMarketId) => {
7039
+ if (!heroMarketId)
7040
+ return void 0;
7041
+ const heroMarket = event.markets.find((market) => market.id === heroMarketId);
7042
+ if (!heroMarket)
7043
+ return void 0;
7044
+ return __spreadProps(__spreadValues({}, event), {
7045
+ markets: [heroMarket]
7046
+ });
7047
+ };
7048
+ var resolveDetailedMarkets = (event, heroMarketId) => {
7049
+ return event.markets.filter((market) => market.id !== heroMarketId).map((market, index) => ({
7050
+ market,
7051
+ index
7052
+ })).sort(
7053
+ (leftItem, rightItem) => {
7054
+ return getMarketDateValue(leftItem.market, leftItem.index) - getMarketDateValue(rightItem.market, rightItem.index);
7055
+ }
7056
+ ).map((item) => item.market);
7057
+ };
7058
+ var resolveInitialExpandedMarketId = (detailedMarkets, defaultExpandedMarketId) => {
7059
+ var _a, _b;
7060
+ if (!detailedMarkets.length)
7061
+ return null;
7062
+ if (defaultExpandedMarketId) {
7063
+ const matchingMarket = detailedMarkets.find((market) => market.id === defaultExpandedMarketId);
7064
+ if (matchingMarket)
7065
+ return matchingMarket.id;
7066
+ }
7067
+ return (_b = (_a = detailedMarkets[0]) == null ? void 0 : _a.id) != null ? _b : null;
7068
+ };
7069
+ var EventMarketPageUnavailableState = ({
7070
+ ariaLabel
7071
+ }) => {
7072
+ const labels = (0, import_hooks23.useLabels)();
7073
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
7074
+ Card,
7075
+ {
7076
+ className: "rounded-agg-xl border border-agg-separator bg-agg-secondary p-6 shadow-none hover:shadow-none",
7077
+ role: "status",
7078
+ "aria-label": ariaLabel != null ? ariaLabel : labels.eventMarketPage.unavailableAria,
7079
+ children: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "flex flex-col gap-1", children: [
7080
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Typography, { variant: "body-large-strong", children: labels.eventMarketPage.unavailableTitle }),
7081
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Typography, { variant: "label", className: "text-agg-muted-foreground", children: labels.eventMarketPage.unavailableDescription })
7082
+ ] })
7083
+ }
7084
+ );
7085
+ };
7086
+ var EventMarketPageNotFoundState = ({
7087
+ ariaLabel
7088
+ }) => {
7089
+ const labels = (0, import_hooks23.useLabels)();
7090
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Card, { className: "overflow-hidden rounded-agg-xl border border-agg-separator bg-agg-secondary p-0 shadow-none hover:shadow-none", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
7091
+ StateMessage,
7092
+ {
7093
+ ariaLabel: ariaLabel != null ? ariaLabel : labels.eventItemDetails.notFoundAria,
7094
+ title: labels.eventItemDetails.notFoundTitle,
7095
+ description: labels.eventItemDetails.notFoundDescription,
7096
+ className: "min-h-[320px] md:min-h-[360px]"
7097
+ }
7098
+ ) });
7099
+ };
7100
+ var EventMarketPageLoadingState = ({
7101
+ placeOrder,
7102
+ settlement,
7103
+ classNames
7104
+ }) => {
7105
+ const labels = (0, import_hooks23.useLabels)();
7106
+ const fallbackSettlement = settlement != null ? settlement : {
7107
+ sectionLabel: labels.trading.settlementSection,
7108
+ question: labels.eventMarketPage.loadingSettlementQuestion,
7109
+ differencesTitle: labels.eventMarketPage.loadingSettlementDifferencesTitle,
7110
+ differences: [labels.eventMarketPage.loadingSettlementPlaceholder],
7111
+ venues: [
7112
+ {
7113
+ venue: "polymarket",
7114
+ description: labels.eventMarketPage.loadingSettlementPlaceholder
7115
+ }
7116
+ ]
7117
+ };
7118
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("section", { className: cn("w-full", classNames == null ? void 0 : classNames.root), children: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
7119
+ "div",
7120
+ {
7121
+ className: cn(
7122
+ "mx-auto flex w-full max-w-[1200px] flex-col gap-6 px-3 py-3 md:px-6 md:py-6 lg:flex-row lg:items-start lg:gap-8",
7123
+ classNames == null ? void 0 : classNames.content
7124
+ ),
7125
+ children: [
7126
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: cn("flex min-w-0 flex-1 flex-col gap-6", classNames == null ? void 0 : classNames.main), children: [
7127
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
7128
+ EventListItemDetails,
7129
+ {
7130
+ isLoading: true,
7131
+ classNames: {
7132
+ root: classNames == null ? void 0 : classNames.hero
7133
+ }
7134
+ }
7135
+ ),
7136
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: cn("flex flex-col gap-3", classNames == null ? void 0 : classNames.markets), children: [
7137
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(MarketDetails, { isLoading: true, isOpened: true, classNames: { root: "w-full" } }),
7138
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(MarketDetails, { isLoading: true, isOpened: false, classNames: { root: "w-full" } }),
7139
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(MarketDetails, { isLoading: true, isOpened: false, classNames: { root: "w-full" } })
7140
+ ] }),
7141
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "md:hidden", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Settlement, __spreadProps(__spreadValues({}, fallbackSettlement), { isLoading: true, className: classNames == null ? void 0 : classNames.settlement })) }),
7142
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "hidden md:block", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Settlement, __spreadProps(__spreadValues({}, fallbackSettlement), { isLoading: true, className: classNames == null ? void 0 : classNames.settlement })) }),
7143
+ placeOrder ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "md:hidden", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(PlaceOrder, __spreadProps(__spreadValues({}, placeOrder), { isLoading: true, className: classNames == null ? void 0 : classNames.mobileTrade })) }) : null
7144
+ ] }),
7145
+ placeOrder ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
7146
+ "aside",
7147
+ {
7148
+ className: cn(
7149
+ "hidden w-full shrink-0 lg:sticky lg:top-6 lg:block lg:w-[343px]",
7150
+ classNames == null ? void 0 : classNames.sidebar
7151
+ ),
7152
+ children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(PlaceOrder, __spreadProps(__spreadValues({}, placeOrder), { isLoading: true, className: classNames == null ? void 0 : classNames.trade }))
7153
+ }
7154
+ ) : null
7155
+ ]
7156
+ }
7157
+ ) });
7158
+ };
7159
+ var EventMarketPageContent = ({
7160
+ event,
7161
+ heroMarketId,
7162
+ defaultExpandedMarketId,
7163
+ expandedMarketId,
7164
+ onExpandedMarketChange,
7165
+ heroDefaultTimeRange,
7166
+ placeOrder,
7167
+ settlement,
7168
+ classNames,
7169
+ ariaLabel
7170
+ }) => {
7171
+ const labels = (0, import_hooks23.useLabels)();
7172
+ const resolvedHeroMarketId = (0, import_react12.useMemo)(() => {
7173
+ return resolveHeroMarketId(event, heroMarketId);
7174
+ }, [event, heroMarketId]);
7175
+ const heroEvent = (0, import_react12.useMemo)(() => {
7176
+ return buildHeroEvent(event, resolvedHeroMarketId);
7177
+ }, [event, resolvedHeroMarketId]);
7178
+ const detailedMarkets = (0, import_react12.useMemo)(() => {
7179
+ return resolveDetailedMarkets(event, resolvedHeroMarketId);
7180
+ }, [event, resolvedHeroMarketId]);
7181
+ const [internalExpandedMarketId, setInternalExpandedMarketId] = (0, import_react12.useState)(() => {
7182
+ return resolveInitialExpandedMarketId(detailedMarkets, defaultExpandedMarketId);
7183
+ });
7184
+ (0, import_react12.useEffect)(() => {
7185
+ if (typeof expandedMarketId === "undefined")
7186
+ return;
7187
+ setInternalExpandedMarketId(expandedMarketId);
7188
+ }, [expandedMarketId]);
7189
+ (0, import_react12.useEffect)(() => {
7190
+ if (typeof expandedMarketId !== "undefined")
7191
+ return;
7192
+ setInternalExpandedMarketId((currentExpandedMarketId) => {
7193
+ if (currentExpandedMarketId && detailedMarkets.some((market) => market.id === currentExpandedMarketId)) {
7194
+ return currentExpandedMarketId;
7195
+ }
7196
+ return resolveInitialExpandedMarketId(detailedMarkets, defaultExpandedMarketId);
7197
+ });
7198
+ }, [defaultExpandedMarketId, detailedMarkets, expandedMarketId]);
7199
+ const resolvedExpandedMarketId = typeof expandedMarketId === "undefined" ? internalExpandedMarketId : expandedMarketId;
7200
+ const handleExpandedMarketChange = (marketId, isOpened) => {
7201
+ const nextExpandedMarketId = isOpened ? marketId : null;
7202
+ if (typeof expandedMarketId === "undefined") {
7203
+ setInternalExpandedMarketId(nextExpandedMarketId);
7204
+ }
7205
+ onExpandedMarketChange == null ? void 0 : onExpandedMarketChange(nextExpandedMarketId);
7206
+ };
7207
+ if (!heroEvent || !event.markets.length) {
7208
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(EventMarketPageUnavailableState, { ariaLabel });
7209
+ }
7210
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("section", { className: cn("w-full", classNames == null ? void 0 : classNames.root), "aria-label": ariaLabel != null ? ariaLabel : event.title, children: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
7211
+ "div",
7212
+ {
7213
+ className: cn(
7214
+ "mx-auto flex w-full max-w-[1200px] flex-row gap-6 px-3 py-3 md:px-6 md:py-6 lg:flex-row lg:items-start lg:gap-8",
7215
+ classNames == null ? void 0 : classNames.content
7216
+ ),
7217
+ children: [
7218
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: cn("flex min-w-0 flex-1 flex-col gap-6", classNames == null ? void 0 : classNames.main), children: [
7219
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
7220
+ EventListItemDetails,
7221
+ {
7222
+ event: heroEvent,
7223
+ defaultTimeRange: heroDefaultTimeRange,
7224
+ classNames: {
7225
+ root: classNames == null ? void 0 : classNames.hero
7226
+ }
7227
+ }
7228
+ ),
7229
+ detailedMarkets.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: cn("flex flex-col gap-3", classNames == null ? void 0 : classNames.markets), children: detailedMarkets.map((market) => {
7230
+ const isOpened = resolvedExpandedMarketId === market.id;
7231
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
7232
+ MarketDetails,
7233
+ {
7234
+ event,
7235
+ marketId: market.id,
7236
+ isOpened,
7237
+ defaultTab: "order-book",
7238
+ ariaLabel: market.endDate && (0, import_dayjs6.default)(market.endDate).isValid() ? labels.eventMarketPage.marketDetailsAriaByDate(
7239
+ (0, import_dayjs6.default)(market.endDate).format("MMM D, YYYY")
7240
+ ) : labels.eventMarketPage.marketDetailsAriaByQuestion(market.question),
7241
+ onOpenChange: (nextIsOpened) => handleExpandedMarketChange(market.id, nextIsOpened)
7242
+ },
7243
+ market.id
7244
+ );
7245
+ }) }) : null,
7246
+ settlement ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "md:hidden", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Settlement, __spreadProps(__spreadValues({}, settlement), { className: classNames == null ? void 0 : classNames.settlement })) }) : null,
7247
+ settlement ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "hidden md:block", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Settlement, __spreadProps(__spreadValues({}, settlement), { className: classNames == null ? void 0 : classNames.settlement })) }) : null
7248
+ ] }),
7249
+ placeOrder ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("aside", { className: cn("w-full lg:block lg:max-w-[360px]", classNames == null ? void 0 : classNames.sidebar), children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(PlaceOrder, __spreadProps(__spreadValues({}, placeOrder), { className: classNames == null ? void 0 : classNames.trade })) }) : null
7250
+ ]
7251
+ }
7252
+ ) });
7253
+ };
7254
+ var EventMarketPage = (props) => {
7255
+ const hasEventProp = "event" in props && !!props.event;
7256
+ const {
7257
+ event: fetchedEvent,
7258
+ error: eventError,
7259
+ isLoading: isFetchingEvent
7260
+ } = (0, import_hooks23.useEvent)(hasEventProp ? void 0 : props.eventId, {
7261
+ enabled: !props.isLoading && !hasEventProp && !!props.eventId
7262
+ });
7263
+ if (props.isLoading) {
7264
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(EventMarketPageLoadingState, { placeOrder: props.placeOrder, settlement: props.settlement });
7265
+ }
7266
+ if ("event" in props && props.event) {
7267
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(EventMarketPageContent, __spreadProps(__spreadValues({}, props), { event: props.event }));
7268
+ }
7269
+ if (isFetchingEvent) {
7270
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
7271
+ EventMarketPageLoadingState,
7272
+ {
7273
+ placeOrder: props.placeOrder,
7274
+ settlement: props.settlement,
7275
+ classNames: props.classNames
7276
+ }
7277
+ );
7278
+ }
7279
+ if (!fetchedEvent) {
7280
+ if (isErrorWithStatus(eventError, 404)) {
7281
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(EventMarketPageNotFoundState, { ariaLabel: props.ariaLabel });
7282
+ }
7283
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(EventMarketPageUnavailableState, { ariaLabel: props.ariaLabel });
7284
+ }
7285
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(EventMarketPageContent, __spreadProps(__spreadValues({}, props), { event: fetchedEvent }));
7286
+ };
7287
+ EventMarketPage.displayName = "EventMarketPage";
7288
+
7289
+ // src/pages/user-profile/components/balance-display.tsx
7290
+ var import_react13 = require("react");
7291
+
7292
+ // src/pages/user-profile/user-profile.constants.ts
7293
+ var USER_PROFILE_TAB_POSITIONS = "positions";
7294
+ var USER_PROFILE_TAB_ACTIVITY = "activity";
7295
+ var USER_PROFILE_TIME_RANGES = ["1D", "1W", "1M", "All"];
7296
+ var USER_PROFILE_POSITION_FILTERS = [
7297
+ { value: "active", label: "Active" },
7298
+ { value: "closed", label: "Closed" }
7299
+ ];
7300
+
7301
+ // src/pages/user-profile/components/balance-display.tsx
7302
+ var import_jsx_runtime74 = require("react/jsx-runtime");
7303
+ var BalanceDisplay = ({
7304
+ balance,
7305
+ defaultTimeRange = "All",
7306
+ onTimeRangeChange,
7307
+ className
7308
+ }) => {
7309
+ var _a, _b;
7310
+ const [activeRange, setActiveRange] = (0, import_react13.useState)(defaultTimeRange);
7311
+ const currentBalance = balance == null ? void 0 : balance[activeRange];
7312
+ const handleRangeChange = (range) => {
7313
+ setActiveRange(range);
7314
+ onTimeRangeChange == null ? void 0 : onTimeRangeChange(range);
7315
+ };
7316
+ return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
7317
+ "div",
7318
+ {
7319
+ className: cn(
7320
+ "flex items-end justify-between overflow-clip rounded-agg-md border border-agg-separator bg-agg-secondary p-5",
7321
+ className
7322
+ ),
7323
+ children: [
7324
+ /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "flex items-end gap-3", children: [
7325
+ /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "agg-type-display text-agg-foreground", children: (_a = currentBalance == null ? void 0 : currentBalance.totalLabel) != null ? _a : "$0.00" }),
7326
+ /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "font-agg-sans text-agg-base leading-6 font-agg-normal text-agg-muted-foreground", children: "Profit/Loss" }),
7327
+ /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "flex items-center gap-1", children: [
7328
+ /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
7329
+ "span",
7330
+ {
7331
+ className: cn(
7332
+ "font-agg-sans text-agg-base leading-6 font-agg-bold",
7333
+ (currentBalance == null ? void 0 : currentBalance.isPositive) ? "text-agg-success" : "text-agg-error"
7334
+ ),
7335
+ children: (_b = currentBalance == null ? void 0 : currentBalance.changePercentLabel) != null ? _b : "0%"
7336
+ }
7337
+ ),
7338
+ /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
7339
+ Icon,
7340
+ {
7341
+ name: "triangle-up-filled",
7342
+ size: "small",
7343
+ className: cn(
7344
+ (currentBalance == null ? void 0 : currentBalance.isPositive) ? "text-agg-success" : "rotate-180 text-agg-error"
7345
+ )
7346
+ }
7347
+ )
7348
+ ] })
7349
+ ] }),
7350
+ /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("div", { className: "flex w-[100px] items-center justify-between", children: USER_PROFILE_TIME_RANGES.map((range) => {
7351
+ const isActive = range === activeRange;
7352
+ return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
7353
+ "button",
7354
+ {
7355
+ type: "button",
7356
+ onClick: () => handleRangeChange(range),
7357
+ className: cn(
7358
+ "cursor-pointer bg-transparent font-agg-sans text-agg-sm leading-agg-5",
7359
+ isActive ? "font-agg-bold text-agg-foreground" : "font-agg-normal text-agg-muted-foreground hover:text-agg-foreground"
7360
+ ),
7361
+ children: range
7362
+ },
7363
+ range
7364
+ );
7365
+ }) })
7366
+ ]
7367
+ }
7368
+ );
7369
+ };
7370
+ BalanceDisplay.displayName = "BalanceDisplay";
7371
+
7372
+ // src/pages/user-profile/components/balances-card.tsx
7373
+ var import_jsx_runtime75 = require("react/jsx-runtime");
7374
+ var BalancesCard = ({
7375
+ venueBalances = [],
7376
+ onDeposit,
7377
+ onWithdraw,
7378
+ className
7379
+ }) => {
7380
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
7381
+ "div",
7382
+ {
7383
+ className: cn(
7384
+ "flex flex-col gap-4 rounded-agg-md border border-agg-separator bg-agg-secondary p-5",
7385
+ className
7386
+ ),
7387
+ children: [
7388
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("h3", { className: "agg-type-body-large-strong text-agg-foreground", children: "Balances" }),
7389
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "relative min-h-0 flex-1 overflow-clip", children: [
7390
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "flex max-h-full flex-col gap-3 overflow-y-auto pr-1", children: venueBalances.map((balance, idx) => /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "flex items-center justify-between", children: [
7391
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "flex items-center gap-1.5", children: [
7392
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(VenueLogo, { venue: balance.venue, size: "small" }),
7393
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "font-agg-sans text-agg-base leading-6 font-agg-normal text-agg-foreground capitalize", children: balance.venue })
7394
+ ] }),
7395
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "font-agg-sans text-agg-base leading-6 font-agg-bold text-agg-foreground", children: balance.balanceLabel })
7396
+ ] }, `${balance.venue}-${idx}`)) }),
7397
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
7398
+ "div",
7399
+ {
7400
+ "aria-hidden": true,
7401
+ className: "pointer-events-none absolute bottom-0 left-0 h-10 w-full bg-gradient-to-b from-transparent to-white"
7402
+ }
7403
+ )
7404
+ ] }),
7405
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "flex items-center gap-3", children: [
7406
+ onDeposit ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Button, { variant: "primary", size: "small", onClick: onDeposit, className: "flex-1", children: "Deposit" }) : null,
7407
+ onWithdraw ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Button, { variant: "secondary", size: "small", onClick: onWithdraw, className: "flex-1", children: "Withdraw" }) : null
7408
+ ] })
7409
+ ]
7410
+ }
7411
+ );
7412
+ };
7413
+ BalancesCard.displayName = "BalancesCard";
7414
+
7415
+ // src/pages/user-profile/components/positions-activity.tsx
7416
+ var import_react14 = require("react");
7417
+
7418
+ // src/pages/user-profile/components/activity-row.tsx
7419
+ var import_jsx_runtime76 = require("react/jsx-runtime");
7420
+ var ActivityRow = ({ activity, onClick }) => {
7421
+ const handleClick = () => {
7422
+ onClick == null ? void 0 : onClick(activity);
7423
+ };
7424
+ return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
7425
+ "button",
7426
+ {
7427
+ type: "button",
7428
+ className: cn(
7429
+ "flex w-full items-center gap-6 rounded-agg-sm p-0 text-left",
7430
+ "hover:bg-agg-secondary-hover focus-visible:outline-none focus-visible:bg-agg-secondary-hover",
7431
+ "cursor-pointer"
7432
+ ),
7433
+ onClick: handleClick,
7434
+ children: [
7435
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { className: "w-[60px] shrink-0 font-agg-sans text-agg-base leading-agg-6 font-agg-normal text-agg-foreground", children: activity.type }),
7436
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: "flex min-w-0 flex-1 items-center gap-4", children: [
7437
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(VenueLogo, { venue: activity.venue, size: "small", className: "shrink-0" }),
7438
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: "flex min-w-0 flex-1 items-center gap-4", children: [
7439
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
7440
+ "img",
7441
+ {
7442
+ src: activity.thumbnailSrc,
7443
+ alt: "",
7444
+ className: "h-[60px] w-[60px] shrink-0 rounded-agg-sm object-cover"
7445
+ }
7446
+ ),
7447
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-2 justify-center", children: [
7448
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { className: "min-w-full overflow-hidden text-ellipsis whitespace-nowrap font-agg-sans text-agg-base leading-agg-6 font-agg-bold text-agg-foreground", children: activity.title }),
7449
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: "flex items-center gap-3", children: [
7450
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", { className: "inline-flex items-center justify-center gap-1.5 rounded-full bg-agg-secondary-hover px-4 py-1.5", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", { className: "font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground whitespace-nowrap", children: activity.outcomeLabel }) }),
7451
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", { className: "font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-black whitespace-nowrap", children: activity.sharesLabel })
7452
+ ] })
7453
+ ] })
7454
+ ] })
7455
+ ] }),
7456
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: "flex w-[120px] shrink-0 flex-col items-end justify-center gap-1 text-agg-base leading-agg-6 whitespace-nowrap", children: [
7457
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { className: "font-agg-sans font-agg-bold text-black", children: activity.amountLabel }),
7458
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { className: "font-agg-sans font-agg-normal text-agg-muted-foreground", children: activity.timeLabel })
7459
+ ] })
7460
+ ]
7461
+ }
7462
+ );
7463
+ };
7464
+ ActivityRow.displayName = "ActivityRow";
7465
+
7466
+ // src/pages/user-profile/components/empty-state.tsx
7467
+ var import_jsx_runtime77 = require("react/jsx-runtime");
7468
+ var EmptyIcon = () => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
7469
+ "svg",
7470
+ {
7471
+ width: "40",
7472
+ height: "40",
7473
+ viewBox: "0 0 40 40",
7474
+ fill: "none",
7475
+ xmlns: "http://www.w3.org/2000/svg",
7476
+ className: "text-agg-muted-foreground",
7477
+ "aria-hidden": true,
7478
+ children: [
7479
+ /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
7480
+ "path",
7481
+ {
7482
+ d: "M33.3333 5H6.66667C5.74619 5 5 5.74619 5 6.66667V33.3333C5 34.2538 5.74619 35 6.66667 35H33.3333C34.2538 35 35 34.2538 35 33.3333V6.66667C35 5.74619 34.2538 5 33.3333 5Z",
7483
+ stroke: "currentColor",
7484
+ strokeWidth: "1.5",
7485
+ strokeLinecap: "round",
7486
+ strokeLinejoin: "round"
7487
+ }
7488
+ ),
7489
+ /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
7490
+ "path",
7491
+ {
7492
+ d: "M14.1667 16.6667C15.5474 16.6667 16.6667 15.5474 16.6667 14.1667C16.6667 12.786 15.5474 11.6667 14.1667 11.6667C12.786 11.6667 11.6667 12.786 11.6667 14.1667C11.6667 15.5474 12.786 16.6667 14.1667 16.6667Z",
7493
+ stroke: "currentColor",
7494
+ strokeWidth: "1.5",
7495
+ strokeLinecap: "round",
7496
+ strokeLinejoin: "round"
7497
+ }
7498
+ ),
7499
+ /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
7500
+ "path",
7501
+ {
7502
+ d: "M35 25L26.6667 16.6667L6.66667 36.6667",
7503
+ stroke: "currentColor",
7504
+ strokeWidth: "1.5",
7505
+ strokeLinecap: "round",
7506
+ strokeLinejoin: "round"
7507
+ }
7508
+ )
7509
+ ]
7510
+ }
7511
+ );
7512
+ var EmptyState = ({ title, description, className }) => {
7513
+ return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
7514
+ "div",
7515
+ {
7516
+ className: cn("flex flex-col items-center justify-center gap-8 p-10", className),
7517
+ role: "status",
7518
+ "aria-live": "polite",
7519
+ children: /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: "flex flex-col items-center gap-5", children: [
7520
+ /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(EmptyIcon, {}),
7521
+ /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: "flex flex-col items-center gap-1 text-center text-agg-foreground", children: [
7522
+ /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("p", { className: "font-agg-sans text-agg-base leading-agg-6 font-agg-bold", children: title }),
7523
+ description ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("p", { className: "font-agg-sans text-agg-sm leading-agg-5 font-agg-normal", children: description }) : null
7524
+ ] })
7525
+ ] })
7526
+ }
7527
+ );
7528
+ };
7529
+ EmptyState.displayName = "EmptyState";
7530
+
7531
+ // src/pages/user-profile/components/position-row.tsx
7532
+ var import_jsx_runtime78 = require("react/jsx-runtime");
7533
+ var PositionRow = ({ position, onClick }) => {
7534
+ const handleClick = () => {
7535
+ onClick == null ? void 0 : onClick(position);
7536
+ };
7537
+ return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
7538
+ "button",
7539
+ {
7540
+ type: "button",
7541
+ className: cn(
7542
+ "flex w-full items-center gap-6 rounded-agg-sm p-0 text-left",
7543
+ "hover:bg-agg-secondary-hover focus-visible:outline-none focus-visible:bg-agg-secondary-hover",
7544
+ "cursor-pointer"
7545
+ ),
7546
+ onClick: handleClick,
7547
+ children: [
7548
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "flex min-w-0 flex-1 items-center gap-4", children: [
7549
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(VenueLogo, { venue: position.venue, size: "small", className: "shrink-0" }),
7550
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "flex min-w-0 flex-1 items-center gap-4", children: [
7551
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
7552
+ "img",
7553
+ {
7554
+ src: position.thumbnailSrc,
7555
+ alt: "",
7556
+ className: "h-[60px] w-[60px] shrink-0 rounded-agg-sm object-cover"
7557
+ }
7558
+ ),
7559
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-2 justify-center", children: [
7560
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("p", { className: "min-w-full overflow-hidden text-ellipsis whitespace-nowrap font-agg-sans text-agg-base leading-agg-6 font-agg-bold text-agg-foreground", children: position.title }),
7561
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "flex items-center gap-3", children: [
7562
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "inline-flex items-center justify-center gap-1.5 rounded-full bg-agg-secondary-hover px-4 py-1.5", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground whitespace-nowrap", children: position.outcomeLabel }) }),
7563
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-black whitespace-nowrap", children: position.sharesLabel })
7564
+ ] })
7565
+ ] })
7566
+ ] })
7567
+ ] }),
7568
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("p", { className: "w-[120px] shrink-0 agg-type-title text-agg-foreground", children: position.averageLabel }),
7569
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("p", { className: "w-[120px] shrink-0 agg-type-title text-agg-foreground", children: position.currentLabel }),
7570
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "flex items-center gap-6 shrink-0", children: [
7571
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "flex w-[140px] flex-col items-end justify-center gap-1 text-agg-base leading-agg-6 whitespace-nowrap", children: [
7572
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("p", { className: "font-agg-sans font-agg-bold text-black", children: position.valueLabel }),
7573
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
7574
+ "p",
7575
+ {
7576
+ className: cn(
7577
+ "font-agg-sans font-agg-normal",
7578
+ position.isPnlPositive ? "text-[#00c853]" : "text-[#e5455f]"
7579
+ ),
7580
+ children: position.pnlLabel
7581
+ }
7582
+ )
7583
+ ] }),
7584
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Icon, { name: "chevron-right", size: "small", className: "shrink-0 text-agg-muted-foreground" })
7585
+ ] })
7586
+ ]
7587
+ }
7588
+ );
7589
+ };
7590
+ PositionRow.displayName = "PositionRow";
7591
+
7592
+ // src/pages/user-profile/components/positions-activity.tsx
7593
+ var import_jsx_runtime79 = require("react/jsx-runtime");
7594
+ var tabItems = [
7595
+ { value: USER_PROFILE_TAB_POSITIONS, label: "Positions" },
7596
+ { value: USER_PROFILE_TAB_ACTIVITY, label: "Activity" }
7597
+ ];
7598
+ var PositionsActivity = ({
7599
+ activePositions = [],
7600
+ closedPositions = [],
7601
+ activities = [],
7602
+ onPositionClick,
7603
+ onActivityClick,
7604
+ className
7605
+ }) => {
7606
+ const [activeTab, setActiveTab] = (0, import_react14.useState)(USER_PROFILE_TAB_POSITIONS);
7607
+ const [positionFilter, setPositionFilter] = (0, import_react14.useState)("active");
7608
+ const [searchValue, setSearchValue] = (0, import_react14.useState)("");
7609
+ const isPositionsTab = activeTab === USER_PROFILE_TAB_POSITIONS;
7610
+ const filteredPositions = (0, import_react14.useMemo)(() => {
7611
+ const positions = positionFilter === "active" ? activePositions : closedPositions;
7612
+ if (!searchValue.trim())
7613
+ return positions;
7614
+ const query = searchValue.toLowerCase();
7615
+ return positions.filter((p) => p.title.toLowerCase().includes(query));
7616
+ }, [activePositions, closedPositions, positionFilter, searchValue]);
7617
+ const filteredActivities = (0, import_react14.useMemo)(() => {
7618
+ if (!searchValue.trim())
7619
+ return activities;
7620
+ const query = searchValue.toLowerCase();
7621
+ return activities.filter((a) => a.title.toLowerCase().includes(query));
7622
+ }, [activities, searchValue]);
7623
+ const handleSearchChange = (event) => {
7624
+ setSearchValue(event.target.value);
7625
+ };
7626
+ return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
7627
+ "div",
7628
+ {
7629
+ className: cn(
7630
+ "flex flex-col items-start overflow-clip rounded-agg-md border border-agg-separator bg-agg-secondary",
7631
+ className
7632
+ ),
7633
+ children: [
7634
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
7635
+ Tabs,
7636
+ {
7637
+ items: tabItems,
7638
+ value: activeTab,
7639
+ onChange: setActiveTab,
7640
+ variant: "underline",
7641
+ className: "w-full [&>div]:w-full"
7642
+ }
7643
+ ),
7644
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "flex w-full flex-col gap-6 p-6", children: [
7645
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "flex items-start gap-5", children: [
7646
+ isPositionsTab ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "flex h-10 w-[270px] shrink-0 items-stretch overflow-clip rounded-agg-sm border border-agg-separator", children: USER_PROFILE_POSITION_FILTERS.map((filter, idx) => {
7647
+ const isActive = filter.value === positionFilter;
7648
+ return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "flex flex-1 items-stretch", children: [
7649
+ idx > 0 ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "w-px bg-agg-separator", "aria-hidden": true }) : null,
7650
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
7651
+ "button",
7652
+ {
7653
+ type: "button",
7654
+ onClick: () => setPositionFilter(filter.value),
7655
+ className: cn(
7656
+ "flex flex-1 items-center justify-center px-4 py-3 font-agg-sans text-agg-base leading-agg-6 cursor-pointer",
7657
+ isActive ? "bg-agg-secondary-hover font-agg-bold text-agg-primary" : "bg-agg-secondary font-agg-normal text-agg-foreground hover:bg-agg-secondary-hover"
7658
+ ),
7659
+ children: filter.label
7660
+ }
7661
+ )
7662
+ ] }, filter.value);
7663
+ }) }) : null,
7664
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("label", { className: "flex min-w-0 flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "flex h-10 w-full items-center gap-3 rounded-agg-sm border border-agg-separator bg-agg-secondary px-3 py-2.5 focus-within:border-2 focus-within:border-agg-primary", children: [
7665
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Icon, { name: "search", size: "small", className: "shrink-0 text-agg-muted-foreground" }),
7666
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
7667
+ "input",
7668
+ {
7669
+ value: searchValue,
7670
+ onChange: handleSearchChange,
7671
+ placeholder: "Search...",
7672
+ className: cn(
7673
+ "h-6 w-full min-w-0 border-0 bg-transparent p-0",
7674
+ "font-agg-sans text-agg-base leading-agg-6 font-agg-normal text-agg-foreground",
7675
+ "placeholder:text-agg-muted-foreground",
7676
+ "outline-none focus:outline-none"
7677
+ )
7678
+ }
7679
+ )
7680
+ ] }) })
7681
+ ] }),
7682
+ isPositionsTab && filteredPositions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "flex items-center gap-6 px-0", children: [
7683
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { className: "min-w-0 flex-1 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-muted-foreground", children: "Market" }),
7684
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { className: "w-[120px] shrink-0 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-muted-foreground", children: "Average" }),
7685
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { className: "w-[120px] shrink-0 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-muted-foreground", children: "Current" }),
7686
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { className: "w-[184px] shrink-0 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-muted-foreground text-right", children: "Value" })
7687
+ ] }) : null,
7688
+ !isPositionsTab && filteredActivities.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "flex items-center gap-6 px-0", children: [
7689
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { className: "w-[60px] shrink-0 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-muted-foreground", children: "Type" }),
7690
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { className: "min-w-0 flex-1 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-muted-foreground", children: "Market" }),
7691
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { className: "w-[120px] shrink-0 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-muted-foreground text-right", children: "Amount" })
7692
+ ] }) : null,
7693
+ isPositionsTab ? filteredPositions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "flex flex-col gap-4", children: filteredPositions.map((position) => /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(PositionRow, { position, onClick: onPositionClick }, position.id)) }) : /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
7694
+ EmptyState,
7695
+ {
7696
+ title: "No positions yet",
7697
+ description: "Your open trades will appear here once you place an order."
7698
+ }
7699
+ ) : filteredActivities.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "flex flex-col gap-4", children: filteredActivities.map((activity) => /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ActivityRow, { activity, onClick: onActivityClick }, activity.id)) }) : /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
7700
+ EmptyState,
7701
+ {
7702
+ title: "No activity yet",
7703
+ description: "Your trading activity will appear here."
7704
+ }
7705
+ )
7706
+ ] })
7707
+ ]
7708
+ }
7709
+ );
7710
+ };
7711
+ PositionsActivity.displayName = "PositionsActivity";
7712
+
7713
+ // src/pages/user-profile/components/default-avatar.tsx
7714
+ var import_jsx_runtime80 = require("react/jsx-runtime");
7715
+ var DefaultAvatar = ({ className }) => {
7716
+ return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
7717
+ "svg",
7718
+ {
7719
+ xmlns: "http://www.w3.org/2000/svg",
7720
+ width: "120",
7721
+ height: "120",
7722
+ viewBox: "0 0 120 120",
7723
+ fill: "none",
7724
+ className: cn("shrink-0", className),
7725
+ "aria-hidden": true,
7726
+ children: [
7727
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("g", { clipPath: "url(#clip0_default_avatar)", children: [
7728
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
7729
+ "path",
7730
+ {
7731
+ d: "M60 120C93.1371 120 120 93.1371 120 60C120 26.8629 93.1371 0 60 0C26.8629 0 0 26.8629 0 60C0 93.1371 26.8629 120 60 120Z",
7732
+ fill: "white"
7733
+ }
7734
+ ),
7735
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
7736
+ "path",
7737
+ {
7738
+ d: "M60 120C93.1371 120 120 93.1371 120 60C120 26.8629 93.1371 0 60 0C26.8629 0 0 26.8629 0 60C0 93.1371 26.8629 120 60 120Z",
7739
+ fill: "black",
7740
+ fillOpacity: "0.1"
7741
+ }
7742
+ ),
7743
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
7744
+ "path",
7745
+ {
7746
+ d: "M73.7338 64.1259C80.4187 59.6756 84.8276 52.0804 84.8276 43.4487C84.8276 29.7376 73.7111 18.6211 60 18.6211C46.2890 18.6211 35.1724 29.7376 35.1724 43.4487C35.1724 52.0804 39.5814 59.6756 46.2662 64.1259C46.2662 64.1259 46.2683 64.1280 46.2704 64.1280C46.2683 64.1280 46.2683 64.1259 46.2683 64.1259C30.2669 68.9487 17.8076 81.9356 13.7959 98.2742L13.7980 98.2763C14.4518 99.0645 15.1304 99.8342 15.8235 100.589C15.9911 100.774 16.1669 100.949 16.3387 101.129C16.8724 101.696 17.4124 102.255 17.9669 102.801C18.1966 103.027 18.4304 103.244 18.6642 103.465C19.1773 103.954 19.6966 104.436 20.2262 104.905C20.4890 105.137 20.7559 105.367 21.0207 105.594C21.5400 106.039 22.0656 106.476 22.6014 106.902C22.8828 107.127 23.1662 107.349 23.4497 107.570C23.9918 107.988 24.5421 108.394 25.0987 108.791C25.3862 108.996 25.6697 109.205 25.9614 109.405C26.5490 109.811 27.1469 110.200 27.7490 110.585C28.0200 110.756 28.2849 110.934 28.5580 111.104C29.2531 111.532 29.9607 111.942 30.6745 112.343C30.8628 112.449 31.0469 112.562 31.2373 112.666C32.1600 113.171 33.0973 113.655 34.0490 114.112C34.0718 114.122 34.0966 114.133 34.1193 114.143C35.0276 114.578 35.9504 114.989 36.8835 115.378C37.1731 115.500 37.4690 115.608 37.7607 115.724C38.4352 115.993 39.1097 116.258 39.7966 116.502C40.1607 116.632 40.5290 116.750 40.8952 116.874C41.5200 117.085 42.1490 117.290 42.7821 117.478C43.1835 117.598 43.5869 117.710 43.9924 117.822C44.6049 117.991 45.2214 118.153 45.8442 118.304C46.2642 118.405 46.6862 118.502 47.1104 118.596C47.7331 118.732 48.3580 118.856 48.9869 118.972C49.4131 119.051 49.8373 119.131 50.2676 119.200C50.9173 119.305 51.5711 119.394 52.2269 119.479C52.6407 119.533 53.0524 119.593 53.4683 119.636C54.1924 119.715 54.9228 119.771 55.6531 119.822C56.0069 119.847 56.3566 119.885 56.7104 119.903C57.8007 119.965 58.8952 120 60 120C61.1049 120 62.1993 119.965 63.2897 119.907C63.6435 119.889 63.9952 119.851 64.3469 119.827C65.0793 119.775 65.8097 119.719 66.5318 119.640C66.9476 119.595 67.3593 119.537 67.7731 119.483C68.4290 119.398 69.0828 119.309 69.7324 119.204C70.1607 119.134 70.5869 119.055 71.0131 118.976C71.6421 118.860 72.2690 118.736 72.8897 118.600C73.3138 118.507 73.7359 118.409 74.1559 118.308C74.7766 118.157 75.3931 117.996 76.0076 117.826C76.4111 117.714 76.8166 117.602 77.2180 117.482C77.8531 117.292 78.4800 117.087 79.1049 116.878C79.4711 116.754 79.8414 116.636 80.2035 116.506C80.8883 116.260 81.5649 115.997 82.2393 115.728C82.5311 115.612 82.8269 115.502 83.1166 115.382C84.0456 114.994 84.9642 114.586 85.8683 114.151C85.8952 114.139 85.9242 114.127 85.9511 114.114C86.9028 113.657 87.8400 113.173 88.7628 112.668C88.9531 112.565 89.1373 112.451 89.3256 112.345C90.0393 111.944 90.7469 111.534 91.4421 111.106C91.7152 110.938 91.9821 110.760 92.2511 110.587C92.8531 110.202 93.4511 109.811 94.0387 109.407C94.3283 109.207 94.6138 109.000 94.9014 108.793C95.4580 108.394 96.0083 107.988 96.5504 107.572C96.8359 107.353 97.1173 107.129 97.3987 106.904C97.9324 106.478 98.4600 106.041 98.9793 105.596C99.2462 105.369 99.5131 105.139 99.7738 104.907C100.303 104.438 100.823 103.956 101.336 103.467C101.568 103.246 101.803 103.027 102.033 102.803C102.588 102.257 103.130 101.698 103.661 101.131C103.831 100.949 104.007 100.774 104.177 100.591C104.870 99.8363 105.548 99.0666 106.202 98.2783L106.204 98.2763C102.195 81.9356 89.7352 68.9487 73.7338 64.1259Z",
7747
+ fill: "black",
7748
+ fillOpacity: "0.1"
7749
+ }
7750
+ )
7751
+ ] }),
7752
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("clipPath", { id: "clip0_default_avatar", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("rect", { width: "120", height: "120", fill: "white" }) }) })
7753
+ ]
7754
+ }
7755
+ );
7756
+ };
7757
+ DefaultAvatar.displayName = "DefaultAvatar";
7758
+
7759
+ // src/pages/user-profile/components/user-info-card.tsx
7760
+ var import_jsx_runtime81 = require("react/jsx-runtime");
7761
+ var UserInfoCard = ({
7762
+ user,
7763
+ onEditProfile,
7764
+ className
7765
+ }) => {
7766
+ var _a, _b, _c;
7767
+ const evmExchanges = ((_a = user.connectedExchanges) != null ? _a : []).filter((ex) => ex.venue !== "kalshi");
7768
+ const totalExchangeCount = (_c = (_b = user.connectedExchanges) == null ? void 0 : _b.length) != null ? _c : 0;
7769
+ const hasEvmExchanges = evmExchanges.length > 0;
7770
+ return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
7771
+ "div",
7772
+ {
7773
+ className: cn(
7774
+ "flex flex-col items-start rounded-agg-md border border-agg-separator bg-agg-secondary p-5",
7775
+ className
7776
+ ),
7777
+ children: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex w-full items-start gap-5", children: [
7778
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "shrink-0", children: user.avatarUrl ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
7779
+ "img",
7780
+ {
7781
+ src: user.avatarUrl,
7782
+ alt: user.username,
7783
+ className: "h-[120px] w-[120px] rounded-full object-cover"
7784
+ }
7785
+ ) : /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(DefaultAvatar, { className: "h-[120px] w-[120px]" }) }),
7786
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-4", children: [
7787
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
7788
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex items-center gap-2", children: [
7789
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("h2", { className: "agg-type-heading text-agg-foreground", children: user.username }),
7790
+ user.socialLinks && user.socialLinks.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "flex items-center gap-2", children: user.socialLinks.map((social) => {
7791
+ const iconName = social.platform === "twitter" ? "twitter" : social.platform === "discord" ? "discord" : "telegram";
7792
+ return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
7793
+ "span",
7794
+ {
7795
+ className: "flex size-8 shrink-0 items-center justify-center rounded-full border border-agg-separator bg-agg-secondary",
7796
+ children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(Icon, { name: iconName, size: "small", className: "text-agg-foreground" })
7797
+ },
7798
+ social.platform
7799
+ );
7800
+ }) }) : null
7801
+ ] }),
7802
+ onEditProfile ? /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
7803
+ "button",
7804
+ {
7805
+ type: "button",
7806
+ onClick: onEditProfile,
7807
+ className: "flex shrink-0 cursor-pointer items-center gap-1.5 bg-transparent text-agg-primary hover:opacity-80",
7808
+ children: [
7809
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(Icon, { name: "pencil", size: "small", className: "text-agg-primary" }),
7810
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "text-agg-base font-agg-bold leading-6", children: "Edit" })
7811
+ ]
7812
+ }
7813
+ ) : null
7814
+ ] }),
7815
+ totalExchangeCount > 0 || user.socialHandle ? /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex flex-col gap-3", children: [
7816
+ hasEvmExchanges ? /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex items-center gap-3", children: [
7817
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "flex items-center", children: evmExchanges.map((exchange, idx) => /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
7818
+ "div",
7819
+ {
7820
+ className: cn(
7821
+ "relative flex h-5 w-5 shrink-0 items-center justify-center overflow-hidden rounded-[4px]",
7822
+ idx > 0 && "-ml-2"
7823
+ ),
7824
+ style: { zIndex: evmExchanges.length - idx },
7825
+ children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(VenueLogo, { venue: exchange.venue, size: "small", className: "h-5 w-5" })
7826
+ },
7827
+ `${exchange.venue}-${idx}`
7828
+ )) }),
7829
+ user.displayAddress ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "text-agg-base font-agg-normal leading-6 text-agg-foreground", children: user.displayAddress }) : null,
7830
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex items-center gap-1", children: [
7831
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("span", { className: "text-agg-sm font-agg-normal leading-5 text-agg-muted-foreground", children: [
7832
+ totalExchangeCount,
7833
+ " exchange",
7834
+ totalExchangeCount !== 1 ? "s" : ""
7835
+ ] }),
7836
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(Icon, { name: "info", size: "small", className: "text-agg-muted-foreground" })
7837
+ ] })
7838
+ ] }) : null,
7839
+ user.socialHandle ? /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex items-center gap-3", children: [
7840
+ user.socialHandleVenue ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "flex h-5 w-5 shrink-0 items-center justify-center overflow-hidden rounded-[4px]", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(VenueLogo, { venue: user.socialHandleVenue, size: "small", className: "h-5 w-5" }) }) : null,
7841
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "text-agg-base font-agg-normal leading-6 text-agg-foreground", children: user.socialHandle })
7842
+ ] }) : null
7843
+ ] }) : null
7844
+ ] })
7845
+ ] })
7846
+ }
7847
+ );
7848
+ };
7849
+ UserInfoCard.displayName = "UserInfoCard";
7850
+
7851
+ // src/pages/user-profile/index.tsx
7852
+ var import_jsx_runtime82 = require("react/jsx-runtime");
7853
+ var UserProfilePage = ({
7854
+ user,
7855
+ venueBalances,
7856
+ balance,
7857
+ defaultTimeRange,
7858
+ onTimeRangeChange,
7859
+ activePositions,
7860
+ closedPositions,
7861
+ activities,
7862
+ onEditProfile,
7863
+ onDeposit,
7864
+ onWithdraw,
7865
+ onPositionClick,
7866
+ onActivityClick,
7867
+ classNames
7868
+ }) => {
7869
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "box-border w-full overflow-x-hidden p-10", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
7870
+ "section",
7871
+ {
7872
+ className: cn(
7873
+ "flex w-full flex-col gap-10 rounded-agg-xl border border-agg-separator bg-agg-secondary p-10 overflow-clip",
7874
+ classNames == null ? void 0 : classNames.root
7875
+ ),
7876
+ children: [
7877
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: cn("flex items-stretch gap-6", classNames == null ? void 0 : classNames.topRow), children: [
7878
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: cn("flex min-w-0 flex-1 flex-col gap-6", classNames == null ? void 0 : classNames.leftColumn), children: [
7879
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
7880
+ UserInfoCard,
7881
+ {
7882
+ user,
7883
+ onEditProfile,
7884
+ className: classNames == null ? void 0 : classNames.userInfoCard
7885
+ }
7886
+ ),
7887
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
7888
+ BalanceDisplay,
7889
+ {
7890
+ balance,
7891
+ defaultTimeRange,
7892
+ onTimeRangeChange,
7893
+ className: classNames == null ? void 0 : classNames.balanceDisplay
7894
+ }
7895
+ )
7896
+ ] }),
7897
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "relative w-[465px] shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
7898
+ BalancesCard,
7899
+ {
7900
+ venueBalances,
7901
+ onDeposit,
7902
+ onWithdraw,
7903
+ className: cn("absolute inset-0", classNames == null ? void 0 : classNames.balancesCard)
7904
+ }
7905
+ ) })
7906
+ ] }),
7907
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
7908
+ PositionsActivity,
7909
+ {
7910
+ activePositions,
7911
+ closedPositions,
7912
+ activities,
7913
+ onPositionClick,
7914
+ onActivityClick,
7915
+ className: classNames == null ? void 0 : classNames.positionsActivity
7916
+ }
7917
+ )
7918
+ ]
7919
+ }
7920
+ ) });
7921
+ };
7922
+ UserProfilePage.displayName = "UserProfilePage";
4063
7923
  // Annotate the CommonJS export names for ESM import in node:
4064
7924
  0 && (module.exports = {
4065
- HomePage
7925
+ EventMarketPage,
7926
+ HomePage,
7927
+ UserProfilePage
4066
7928
  });