@elizaos/plugin-polymarket-app 2.0.3-beta.6 → 2.0.3-beta.7

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 (95) hide show
  1. package/dist/PolymarketAppView.d.ts +3 -0
  2. package/dist/PolymarketAppView.d.ts.map +1 -0
  3. package/dist/PolymarketAppView.helpers.d.ts +10 -0
  4. package/dist/PolymarketAppView.helpers.d.ts.map +1 -0
  5. package/dist/PolymarketAppView.helpers.js +30 -0
  6. package/dist/PolymarketAppView.helpers.js.map +1 -0
  7. package/dist/PolymarketAppView.interact.d.ts +3 -0
  8. package/dist/PolymarketAppView.interact.d.ts.map +1 -0
  9. package/dist/PolymarketAppView.interact.js +70 -0
  10. package/dist/PolymarketAppView.interact.js.map +1 -0
  11. package/dist/PolymarketAppView.js +704 -0
  12. package/dist/PolymarketAppView.js.map +1 -0
  13. package/dist/PolymarketPositionsPanel.d.ts +13 -0
  14. package/dist/PolymarketPositionsPanel.d.ts.map +1 -0
  15. package/dist/PolymarketPositionsPanel.js +349 -0
  16. package/dist/PolymarketPositionsPanel.js.map +1 -0
  17. package/dist/PolymarketView.d.ts +13 -0
  18. package/dist/PolymarketView.d.ts.map +1 -0
  19. package/dist/PolymarketView.js +58 -0
  20. package/dist/PolymarketView.js.map +1 -0
  21. package/dist/__fixtures__/contract.d.ts +9 -0
  22. package/dist/__fixtures__/contract.d.ts.map +1 -0
  23. package/dist/__fixtures__/contract.js +263 -0
  24. package/dist/__fixtures__/contract.js.map +1 -0
  25. package/dist/actions.d.ts +39 -0
  26. package/dist/actions.d.ts.map +1 -0
  27. package/dist/actions.js +661 -0
  28. package/dist/actions.js.map +1 -0
  29. package/dist/client.d.ts +25 -0
  30. package/dist/client.d.ts.map +1 -0
  31. package/dist/client.js +42 -0
  32. package/dist/client.js.map +1 -0
  33. package/dist/components/PolymarketSpatialView.d.ts +34 -0
  34. package/dist/components/PolymarketSpatialView.d.ts.map +1 -0
  35. package/dist/components/PolymarketSpatialView.js +248 -0
  36. package/dist/components/PolymarketSpatialView.js.map +1 -0
  37. package/dist/index.d.ts +14 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +24 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/orderbook.d.ts +15 -0
  42. package/dist/orderbook.d.ts.map +1 -0
  43. package/dist/orderbook.js +45 -0
  44. package/dist/orderbook.js.map +1 -0
  45. package/dist/plugin.d.ts +3 -0
  46. package/dist/plugin.d.ts.map +1 -0
  47. package/dist/plugin.js +108 -0
  48. package/dist/plugin.js.map +1 -0
  49. package/dist/polymarket-app.d.ts +4 -0
  50. package/dist/polymarket-app.d.ts.map +1 -0
  51. package/dist/polymarket-app.js +18 -0
  52. package/dist/polymarket-app.js.map +1 -0
  53. package/dist/polymarket-contracts.d.ts +162 -0
  54. package/dist/polymarket-contracts.d.ts.map +1 -0
  55. package/dist/polymarket-contracts.js +16 -0
  56. package/dist/polymarket-contracts.js.map +1 -0
  57. package/dist/polymarket-view-bundle.d.ts +3 -0
  58. package/dist/polymarket-view-bundle.d.ts.map +1 -0
  59. package/dist/polymarket-view-bundle.js +7 -0
  60. package/dist/polymarket-view-bundle.js.map +1 -0
  61. package/dist/provider-text.d.ts +5 -0
  62. package/dist/provider-text.d.ts.map +1 -0
  63. package/dist/provider-text.js +44 -0
  64. package/dist/provider-text.js.map +1 -0
  65. package/dist/provider.d.ts +3 -0
  66. package/dist/provider.d.ts.map +1 -0
  67. package/dist/provider.js +21 -0
  68. package/dist/provider.js.map +1 -0
  69. package/dist/register-routes.d.ts +2 -0
  70. package/dist/register-routes.d.ts.map +1 -0
  71. package/dist/register-routes.js +6 -0
  72. package/dist/register-routes.js.map +1 -0
  73. package/dist/register-terminal-view.d.ts +15 -0
  74. package/dist/register-terminal-view.d.ts.map +1 -0
  75. package/dist/register-terminal-view.js +25 -0
  76. package/dist/register-terminal-view.js.map +1 -0
  77. package/dist/register.d.ts +2 -0
  78. package/dist/register.d.ts.map +1 -0
  79. package/dist/register.js +17 -0
  80. package/dist/register.js.map +1 -0
  81. package/dist/routes.d.ts +7 -0
  82. package/dist/routes.d.ts.map +1 -0
  83. package/dist/routes.js +455 -0
  84. package/dist/routes.js.map +1 -0
  85. package/dist/ui.d.ts +6 -0
  86. package/dist/ui.d.ts.map +1 -0
  87. package/dist/ui.js +11 -0
  88. package/dist/ui.js.map +1 -0
  89. package/dist/usePolymarketState.d.ts +13 -0
  90. package/dist/usePolymarketState.d.ts.map +1 -0
  91. package/dist/usePolymarketState.js +59 -0
  92. package/dist/usePolymarketState.js.map +1 -0
  93. package/dist/views/bundle.js +535 -0
  94. package/dist/views/bundle.js.map +1 -0
  95. package/package.json +6 -6
@@ -0,0 +1,704 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Button } from "@elizaos/app-core";
3
+ import { useAgentElement } from "@elizaos/ui/agent-surface";
4
+ import { ArrowLeft } from "lucide-react";
5
+ import { useEffect } from "react";
6
+ import { PolymarketPositionsPanel } from "./PolymarketPositionsPanel.js";
7
+ import { usePolymarketState } from "./usePolymarketState.js";
8
+ const ACCENT = "var(--accent, #ff8a24)";
9
+ const ACCENT_LIGHT = "#ffb066";
10
+ const ACCENT_SUBTLE = "var(--accent-subtle, rgba(255,138,36,0.12))";
11
+ const TXT = "var(--txt, #111)";
12
+ const MUTED = "var(--muted, rgba(0,0,0,0.58))";
13
+ const BORDER = "var(--border, rgba(0,0,0,0.12))";
14
+ const SURFACE = "var(--surface, rgba(0,0,0,0.04))";
15
+ function priceToPercent(price) {
16
+ if (price == null) return null;
17
+ const n = Number(price);
18
+ if (!Number.isFinite(n)) return null;
19
+ return Math.round(n * 100);
20
+ }
21
+ function shortNumber(value) {
22
+ if (value == null) return null;
23
+ const n = Number(value);
24
+ if (!Number.isFinite(n)) return value;
25
+ if (n >= 1e6) return `$${(n / 1e6).toFixed(1)}M`;
26
+ if (n >= 1e3) return `$${(n / 1e3).toFixed(1)}K`;
27
+ return `$${n.toFixed(0)}`;
28
+ }
29
+ function PolymarketAppView({ exitToApps, t }) {
30
+ const {
31
+ status,
32
+ markets,
33
+ selectedMarket,
34
+ setSelectedMarket,
35
+ positions,
36
+ loading,
37
+ error,
38
+ refresh
39
+ } = usePolymarketState();
40
+ const selectedMarketId = selectedMarket?.id;
41
+ useEffect(() => {
42
+ const interval = setInterval(() => {
43
+ void refresh();
44
+ }, 2e4);
45
+ return () => clearInterval(interval);
46
+ }, [refresh]);
47
+ const backLabel = t("nav.back", { defaultValue: "Back" });
48
+ const back = useAgentElement({
49
+ id: "action-back",
50
+ role: "button",
51
+ label: backLabel,
52
+ group: "polymarket-nav",
53
+ description: "Exit Polymarket and return to the apps list"
54
+ });
55
+ const showEmpty = !loading && markets.length === 0;
56
+ return /* @__PURE__ */ jsxs(
57
+ "div",
58
+ {
59
+ "data-testid": "polymarket-shell",
60
+ className: "fixed inset-0 z-50 flex h-[100vh] flex-col overflow-hidden bg-bg supports-[height:100dvh]:h-[100dvh]",
61
+ children: [
62
+ /* @__PURE__ */ jsx("style", { children: "@keyframes pmShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}" }),
63
+ /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center justify-between px-3 py-2", children: /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-3", children: [
64
+ /* @__PURE__ */ jsx(
65
+ Button,
66
+ {
67
+ ref: back.ref,
68
+ ...back.agentProps,
69
+ variant: "ghost",
70
+ size: "icon",
71
+ className: "h-9 w-9 shrink-0 text-muted hover:text-txt",
72
+ onClick: exitToApps,
73
+ "aria-label": backLabel,
74
+ children: /* @__PURE__ */ jsx(ArrowLeft, { className: "h-4 w-4" })
75
+ }
76
+ ),
77
+ /* @__PURE__ */ jsxs(
78
+ "div",
79
+ {
80
+ className: "min-w-0",
81
+ style: { display: "flex", alignItems: "center", gap: 8 },
82
+ children: [
83
+ /* @__PURE__ */ jsx(PolymarketGlyph, { size: 22 }),
84
+ /* @__PURE__ */ jsx("h1", { className: "truncate text-base font-semibold text-txt", children: "Polymarket" })
85
+ ]
86
+ }
87
+ )
88
+ ] }) }),
89
+ /* @__PURE__ */ jsx("div", { className: "chat-native-scrollbar flex-1 overflow-y-auto px-3 py-3 sm:px-5", children: /* @__PURE__ */ jsx("div", { className: "mx-auto flex max-w-3xl flex-col gap-3", children: selectedMarket ? /* @__PURE__ */ jsx(
90
+ MarketDetail,
91
+ {
92
+ market: selectedMarket,
93
+ onBack: () => setSelectedMarket(null)
94
+ }
95
+ ) : showEmpty ? /* @__PURE__ */ jsx(DisconnectedState, { status, error }) : /* @__PURE__ */ jsxs(
96
+ "section",
97
+ {
98
+ style: { display: "flex", flexDirection: "column", gap: 12 },
99
+ children: [
100
+ /* @__PURE__ */ jsx(ReadinessStrip, { status }),
101
+ status?.account?.ready ? /* @__PURE__ */ jsx(
102
+ PolymarketPositionsPanel,
103
+ {
104
+ positions: positions?.positions ?? [],
105
+ summary: positions?.summary ?? null,
106
+ blockedReason: status.account?.reason ?? null
107
+ }
108
+ ) : null,
109
+ loading && markets.length === 0 ? /* @__PURE__ */ jsx("div", { style: { display: "grid", gap: 10 }, children: [0, 1, 2, 3].map((i) => /* @__PURE__ */ jsx(MarketSkeleton, {}, i)) }) : /* @__PURE__ */ jsx("div", { style: { display: "grid", gap: 10 }, children: markets.slice(0, 24).map((market) => /* @__PURE__ */ jsx(
110
+ MarketCard,
111
+ {
112
+ market,
113
+ active: selectedMarketId === market.id,
114
+ onSelect: setSelectedMarket
115
+ },
116
+ market.id
117
+ )) })
118
+ ]
119
+ }
120
+ ) }) })
121
+ ]
122
+ }
123
+ );
124
+ }
125
+ function PolymarketGlyph({ size = 28 }) {
126
+ return /* @__PURE__ */ jsxs(
127
+ "svg",
128
+ {
129
+ width: size,
130
+ height: size,
131
+ viewBox: "0 0 32 32",
132
+ role: "img",
133
+ "aria-hidden": "true",
134
+ style: { display: "block" },
135
+ children: [
136
+ /* @__PURE__ */ jsx("title", { children: "Polymarket" }),
137
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: "pmYes", x1: "0", y1: "0", x2: "1", y2: "1", children: [
138
+ /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: ACCENT }),
139
+ /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: ACCENT_LIGHT })
140
+ ] }) }),
141
+ /* @__PURE__ */ jsx(
142
+ "circle",
143
+ {
144
+ cx: "16",
145
+ cy: "16",
146
+ r: "15",
147
+ fill: "none",
148
+ stroke: BORDER,
149
+ strokeWidth: "2"
150
+ }
151
+ ),
152
+ /* @__PURE__ */ jsx(
153
+ "path",
154
+ {
155
+ d: "M16 1 A15 15 0 0 1 31 16 L16 16 Z",
156
+ fill: "url(#pmYes)",
157
+ opacity: "0.85"
158
+ }
159
+ ),
160
+ /* @__PURE__ */ jsx("circle", { cx: "16", cy: "16", r: "6", fill: "var(--bg, #fff)" }),
161
+ /* @__PURE__ */ jsx("circle", { cx: "16", cy: "16", r: "2.5", fill: ACCENT })
162
+ ]
163
+ }
164
+ );
165
+ }
166
+ function StateDot({ ready }) {
167
+ return /* @__PURE__ */ jsx(
168
+ "span",
169
+ {
170
+ style: {
171
+ width: 8,
172
+ height: 8,
173
+ borderRadius: 99,
174
+ background: ready ? ACCENT : MUTED,
175
+ boxShadow: ready ? `0 0 0 3px ${ACCENT_SUBTLE}` : "none",
176
+ flexShrink: 0
177
+ }
178
+ }
179
+ );
180
+ }
181
+ function CapabilityChip({
182
+ label,
183
+ ready,
184
+ hint
185
+ }) {
186
+ return /* @__PURE__ */ jsxs(
187
+ "div",
188
+ {
189
+ title: hint,
190
+ style: {
191
+ display: "inline-flex",
192
+ alignItems: "center",
193
+ gap: 7,
194
+ padding: "4px 2px",
195
+ fontSize: 13,
196
+ fontWeight: 600,
197
+ color: TXT
198
+ },
199
+ children: [
200
+ /* @__PURE__ */ jsx(StateDot, { ready }),
201
+ label,
202
+ /* @__PURE__ */ jsx("span", { style: { color: MUTED, fontWeight: 500, fontSize: 12 }, children: ready ? "on" : "off" })
203
+ ]
204
+ }
205
+ );
206
+ }
207
+ function ReadinessStrip({
208
+ status
209
+ }) {
210
+ const reads = status?.publicReads.ready ?? false;
211
+ const trading = status?.trading.ready ?? false;
212
+ return /* @__PURE__ */ jsxs(
213
+ "div",
214
+ {
215
+ style: {
216
+ display: "flex",
217
+ flexWrap: "wrap",
218
+ gap: 8,
219
+ alignItems: "center"
220
+ },
221
+ children: [
222
+ /* @__PURE__ */ jsx(
223
+ CapabilityChip,
224
+ {
225
+ label: "Read-only",
226
+ ready: reads,
227
+ hint: "Public market data (no credentials needed)"
228
+ }
229
+ ),
230
+ /* @__PURE__ */ jsx(
231
+ CapabilityChip,
232
+ {
233
+ label: "Trading",
234
+ ready: trading,
235
+ hint: status?.trading.reason ?? "Signed order placement"
236
+ }
237
+ )
238
+ ]
239
+ }
240
+ );
241
+ }
242
+ function DisconnectedState({
243
+ status,
244
+ error
245
+ }) {
246
+ const reads = status?.publicReads.ready ?? false;
247
+ const trading = status?.trading.ready ?? false;
248
+ return /* @__PURE__ */ jsxs(
249
+ "section",
250
+ {
251
+ style: {
252
+ display: "flex",
253
+ flexDirection: "column",
254
+ alignItems: "center",
255
+ textAlign: "center",
256
+ gap: 16,
257
+ padding: "48px 20px",
258
+ margin: "auto 0"
259
+ },
260
+ children: [
261
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(PolymarketGlyph, { size: 52 }) }),
262
+ /* @__PURE__ */ jsxs("div", { style: { maxWidth: 360 }, children: [
263
+ /* @__PURE__ */ jsx(
264
+ "h2",
265
+ {
266
+ title: error ? "Markets unavailable" : "None",
267
+ style: {
268
+ margin: 0,
269
+ fontSize: 19,
270
+ fontWeight: 700,
271
+ color: TXT
272
+ },
273
+ children: error ? "Unavailable" : "None"
274
+ }
275
+ ),
276
+ error ? /* @__PURE__ */ jsx(
277
+ "p",
278
+ {
279
+ className: "sr-only",
280
+ style: {
281
+ margin: "8px 0 0",
282
+ fontSize: 14,
283
+ color: MUTED,
284
+ lineHeight: 1.5
285
+ },
286
+ children: "Couldn't reach Polymarket right now. Try again in a moment."
287
+ }
288
+ ) : null
289
+ ] }),
290
+ /* @__PURE__ */ jsxs(
291
+ "div",
292
+ {
293
+ style: {
294
+ display: "flex",
295
+ flexWrap: "wrap",
296
+ gap: 8,
297
+ justifyContent: "center"
298
+ },
299
+ children: [
300
+ /* @__PURE__ */ jsx(
301
+ CapabilityChip,
302
+ {
303
+ label: "Read-only",
304
+ ready: reads,
305
+ hint: "Public market data (no credentials needed)"
306
+ }
307
+ ),
308
+ /* @__PURE__ */ jsx(
309
+ CapabilityChip,
310
+ {
311
+ label: "Trading",
312
+ ready: trading,
313
+ hint: status?.trading.reason ?? "Signed order placement"
314
+ }
315
+ )
316
+ ]
317
+ }
318
+ ),
319
+ !trading && status?.trading.missing.length ? /* @__PURE__ */ jsxs(
320
+ "p",
321
+ {
322
+ className: "sr-only",
323
+ style: {
324
+ margin: 0,
325
+ fontSize: 12,
326
+ color: MUTED,
327
+ maxWidth: 360
328
+ },
329
+ children: [
330
+ "To enable trading, configure",
331
+ " ",
332
+ /* @__PURE__ */ jsx("code", { style: { fontSize: 11, color: MUTED }, children: status.trading.missing.join(", ") }),
333
+ " ",
334
+ "in Settings."
335
+ ]
336
+ }
337
+ ) : null
338
+ ]
339
+ }
340
+ );
341
+ }
342
+ function MarketSkeleton() {
343
+ return /* @__PURE__ */ jsx(
344
+ "div",
345
+ {
346
+ style: {
347
+ height: 66,
348
+ background: `linear-gradient(90deg, ${SURFACE} 0%, var(--bg-hover, rgba(0,0,0,0.06)) 50%, ${SURFACE} 100%)`,
349
+ backgroundSize: "200% 100%",
350
+ animation: "pmShimmer 1.4s ease-in-out infinite"
351
+ }
352
+ }
353
+ );
354
+ }
355
+ function OutcomeChip({
356
+ name,
357
+ percent,
358
+ rank
359
+ }) {
360
+ const lead = rank === 0;
361
+ return /* @__PURE__ */ jsxs(
362
+ "div",
363
+ {
364
+ style: {
365
+ display: "inline-flex",
366
+ alignItems: "center",
367
+ gap: 6,
368
+ padding: "2px 0",
369
+ fontSize: 12.5,
370
+ fontWeight: 600,
371
+ color: TXT,
372
+ maxWidth: "100%"
373
+ },
374
+ children: [
375
+ /* @__PURE__ */ jsx(
376
+ "span",
377
+ {
378
+ style: {
379
+ maxWidth: 130,
380
+ overflow: "hidden",
381
+ textOverflow: "ellipsis",
382
+ whiteSpace: "nowrap"
383
+ },
384
+ children: name
385
+ }
386
+ ),
387
+ percent != null ? /* @__PURE__ */ jsxs(
388
+ "span",
389
+ {
390
+ style: {
391
+ color: lead ? ACCENT : MUTED,
392
+ fontVariantNumeric: "tabular-nums"
393
+ },
394
+ children: [
395
+ percent,
396
+ "%"
397
+ ]
398
+ }
399
+ ) : null
400
+ ]
401
+ }
402
+ );
403
+ }
404
+ function MarketCard({
405
+ market,
406
+ active,
407
+ onSelect
408
+ }) {
409
+ const label = market.question ?? market.slug ?? market.id;
410
+ const { ref, agentProps } = useAgentElement({
411
+ id: `market-${market.id}`,
412
+ role: "list-item",
413
+ label,
414
+ group: "polymarket-markets",
415
+ status: active ? "active" : "inactive",
416
+ description: `Select the ${label} market`
417
+ });
418
+ const volume = shortNumber(market.volume24hr ?? market.volume);
419
+ const liquidity = shortNumber(market.liquidity);
420
+ const outcomes = market.outcomes.slice(0, 3);
421
+ return /* @__PURE__ */ jsxs(
422
+ "button",
423
+ {
424
+ ref,
425
+ ...agentProps,
426
+ type: "button",
427
+ onClick: () => onSelect(market),
428
+ "aria-current": active ? "true" : void 0,
429
+ style: {
430
+ display: "flex",
431
+ gap: 12,
432
+ width: "100%",
433
+ textAlign: "left",
434
+ padding: "10px 4px",
435
+ border: "none",
436
+ borderLeft: active ? `2px solid ${ACCENT}` : "2px solid transparent",
437
+ background: "transparent",
438
+ cursor: "pointer",
439
+ font: "inherit",
440
+ color: TXT,
441
+ alignItems: "flex-start"
442
+ },
443
+ children: [
444
+ /* @__PURE__ */ jsx(
445
+ "span",
446
+ {
447
+ style: {
448
+ width: 40,
449
+ height: 40,
450
+ flexShrink: 0,
451
+ display: "flex",
452
+ alignItems: "center",
453
+ justifyContent: "center",
454
+ overflow: "hidden"
455
+ },
456
+ children: market.icon || market.image ? /* @__PURE__ */ jsx(
457
+ "img",
458
+ {
459
+ src: market.icon ?? market.image ?? "",
460
+ alt: "",
461
+ style: { width: "100%", height: "100%", objectFit: "cover" }
462
+ }
463
+ ) : /* @__PURE__ */ jsx(PolymarketGlyph, { size: 24 })
464
+ }
465
+ ),
466
+ /* @__PURE__ */ jsxs(
467
+ "span",
468
+ {
469
+ style: {
470
+ minWidth: 0,
471
+ flex: 1,
472
+ display: "flex",
473
+ flexDirection: "column",
474
+ gap: 8
475
+ },
476
+ children: [
477
+ /* @__PURE__ */ jsx(
478
+ "span",
479
+ {
480
+ style: {
481
+ fontSize: 14,
482
+ fontWeight: 600,
483
+ lineHeight: 1.35,
484
+ color: TXT,
485
+ display: "-webkit-box",
486
+ WebkitLineClamp: 2,
487
+ WebkitBoxOrient: "vertical",
488
+ overflow: "hidden"
489
+ },
490
+ children: label
491
+ }
492
+ ),
493
+ /* @__PURE__ */ jsx("span", { style: { display: "flex", flexWrap: "wrap", gap: 6 }, children: outcomes.map((outcome, i) => /* @__PURE__ */ jsx(
494
+ OutcomeChip,
495
+ {
496
+ name: outcome.name,
497
+ percent: priceToPercent(outcome.price),
498
+ rank: i
499
+ },
500
+ outcome.name
501
+ )) }),
502
+ /* @__PURE__ */ jsxs("span", { style: { display: "flex", gap: 14, fontSize: 12, color: MUTED }, children: [
503
+ volume ? /* @__PURE__ */ jsxs("span", { children: [
504
+ "Vol ",
505
+ volume
506
+ ] }) : null,
507
+ liquidity ? /* @__PURE__ */ jsxs("span", { children: [
508
+ "Liq ",
509
+ liquidity
510
+ ] }) : null,
511
+ market.category ? /* @__PURE__ */ jsx("span", { children: market.category }) : null
512
+ ] })
513
+ ]
514
+ }
515
+ )
516
+ ]
517
+ }
518
+ );
519
+ }
520
+ function MarketDetail({
521
+ market,
522
+ onBack
523
+ }) {
524
+ return /* @__PURE__ */ jsxs("section", { style: { minWidth: 0 }, children: [
525
+ /* @__PURE__ */ jsxs(
526
+ "button",
527
+ {
528
+ type: "button",
529
+ onClick: onBack,
530
+ style: {
531
+ display: "inline-flex",
532
+ alignItems: "center",
533
+ gap: 6,
534
+ marginBottom: 16,
535
+ background: "transparent",
536
+ border: "none",
537
+ font: "inherit",
538
+ fontSize: 12.5,
539
+ fontWeight: 600,
540
+ color: MUTED,
541
+ cursor: "pointer"
542
+ },
543
+ children: [
544
+ /* @__PURE__ */ jsx(ArrowLeft, { style: { width: 14, height: 14 } }),
545
+ "Markets"
546
+ ]
547
+ }
548
+ ),
549
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "flex-start", gap: 12 }, children: [
550
+ /* @__PURE__ */ jsx(
551
+ "span",
552
+ {
553
+ style: {
554
+ width: 44,
555
+ height: 44,
556
+ flexShrink: 0,
557
+ display: "flex",
558
+ alignItems: "center",
559
+ justifyContent: "center",
560
+ overflow: "hidden"
561
+ },
562
+ children: market.icon || market.image ? /* @__PURE__ */ jsx(
563
+ "img",
564
+ {
565
+ src: market.icon ?? market.image ?? "",
566
+ alt: "",
567
+ style: { width: "100%", height: "100%", objectFit: "cover" }
568
+ }
569
+ ) : /* @__PURE__ */ jsx(PolymarketGlyph, { size: 26 })
570
+ }
571
+ ),
572
+ /* @__PURE__ */ jsx(
573
+ "h2",
574
+ {
575
+ style: {
576
+ margin: 0,
577
+ fontSize: 19,
578
+ fontWeight: 700,
579
+ lineHeight: 1.3,
580
+ color: TXT
581
+ },
582
+ children: market.question ?? market.slug
583
+ }
584
+ )
585
+ ] }),
586
+ /* @__PURE__ */ jsxs(
587
+ "div",
588
+ {
589
+ style: { display: "flex", gap: 24, marginTop: 18, flexWrap: "wrap" },
590
+ children: [
591
+ /* @__PURE__ */ jsx(Metric, { label: "Volume", value: shortNumber(market.volume) ?? "\u2014" }),
592
+ /* @__PURE__ */ jsx(
593
+ Metric,
594
+ {
595
+ label: "Liquidity",
596
+ value: shortNumber(market.liquidity) ?? "\u2014"
597
+ }
598
+ ),
599
+ /* @__PURE__ */ jsx(
600
+ Metric,
601
+ {
602
+ label: "Last trade",
603
+ value: priceToPercent(market.lastTradePrice) != null ? `${priceToPercent(market.lastTradePrice)}%` : "\u2014"
604
+ }
605
+ )
606
+ ]
607
+ }
608
+ ),
609
+ /* @__PURE__ */ jsxs("div", { style: { marginTop: 24 }, children: [
610
+ /* @__PURE__ */ jsx(
611
+ "div",
612
+ {
613
+ style: {
614
+ paddingBottom: 4,
615
+ fontSize: 12,
616
+ fontWeight: 600,
617
+ color: MUTED
618
+ },
619
+ children: "Outcomes"
620
+ }
621
+ ),
622
+ market.outcomes.map((outcome, i) => {
623
+ const pct = priceToPercent(outcome.price);
624
+ return /* @__PURE__ */ jsxs(
625
+ "div",
626
+ {
627
+ style: {
628
+ padding: "11px 0",
629
+ display: "flex",
630
+ flexDirection: "column",
631
+ gap: 6
632
+ },
633
+ children: [
634
+ /* @__PURE__ */ jsxs(
635
+ "div",
636
+ {
637
+ style: {
638
+ display: "flex",
639
+ justifyContent: "space-between",
640
+ gap: 12,
641
+ fontSize: 13.5
642
+ },
643
+ children: [
644
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 600, color: TXT }, children: outcome.name }),
645
+ /* @__PURE__ */ jsx(
646
+ "span",
647
+ {
648
+ style: { fontWeight: 700, color: i === 0 ? ACCENT : MUTED },
649
+ children: pct != null ? `${pct}%` : "n/a"
650
+ }
651
+ )
652
+ ]
653
+ }
654
+ ),
655
+ pct != null ? /* @__PURE__ */ jsx(
656
+ "div",
657
+ {
658
+ style: {
659
+ height: 6,
660
+ background: SURFACE,
661
+ overflow: "hidden"
662
+ },
663
+ children: /* @__PURE__ */ jsx(
664
+ "div",
665
+ {
666
+ style: {
667
+ width: `${pct}%`,
668
+ height: "100%",
669
+ background: i === 0 ? ACCENT : MUTED
670
+ }
671
+ }
672
+ )
673
+ }
674
+ ) : null
675
+ ]
676
+ },
677
+ outcome.name
678
+ );
679
+ })
680
+ ] })
681
+ ] });
682
+ }
683
+ function Metric({ label, value }) {
684
+ return /* @__PURE__ */ jsxs("div", { style: { flex: "1 1 90px", minWidth: 90 }, children: [
685
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 11.5, color: MUTED }, children: label }),
686
+ /* @__PURE__ */ jsx(
687
+ "div",
688
+ {
689
+ style: {
690
+ marginTop: 4,
691
+ fontSize: 15,
692
+ fontWeight: 700,
693
+ color: TXT,
694
+ fontVariantNumeric: "tabular-nums"
695
+ },
696
+ children: value
697
+ }
698
+ )
699
+ ] });
700
+ }
701
+ export {
702
+ PolymarketAppView
703
+ };
704
+ //# sourceMappingURL=PolymarketAppView.js.map