@omnigateway/pokemon 1.1.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ui/index.js CHANGED
@@ -1,14 +1,14 @@
1
- import{definePluginUI as It,useLive as $t}from"@omnigateway/dashboard-sdk";import{useMutation as fe,useQuery as at,useQueryClient as wt}from"@tanstack/react-query";import{useState as st}from"react";var dt={rareCandy:{blurb:"Injects 100.0M growth. Priced at five times what it grants.",emoji:"\uD83C\uDF6C",consumable:!0},mint:{blurb:"Rerolls this companion's nature. Cosmetic, and cheap enough to reroll again.",emoji:"\uD83C\uDF3F",consumable:!0},shinyCharm:{blurb:"Kept, never spent. Raises every future hatch from 1 in 64 to 1 in 48.",emoji:"✨",consumable:!1},everstone:{blurb:"Pins this companion: it will not evolve, reveal, or graduate.",emoji:"\uD83E\uDEA8",consumable:!0},lure:{blurb:"Next egg prefers a species the Dex has not collected. A preference, never a veto.",emoji:"\uD83C\uDF6F",consumable:!0},sootheBell:{blurb:"This companion grows 25% faster. Bound to it, and never repays its price.",emoji:"\uD83D\uDD14",consumable:!0},incense:{blurb:"Next egg leans toward a longer evolution line. Buys events, not value.",emoji:"\uD83D\uDD6F️",consumable:!0},repel:{blurb:"Next egg will not hatch one named line.",emoji:"\uD83D\uDEAB",consumable:!0}};function L(e){return ye.get(e)??{blurb:"",emoji:"❔",consumable:!0}}var ye=new Map(Object.entries(dt)),Dt=[...ye].filter(([,e])=>e.consumable).map(([e])=>e),ve="\uD83E\uDD5A";function ke(e){return e===null?"Sends this companion off and starts again.":`Sends this companion off for an egg guaranteed to hatch ${e} or better.`}function R(e,t,o){return`/api/plugins/${e}/sprite/${t}${o?"?shiny=1":""}`}function Ie(e,t){return`/api/plugins/${e}/item-sprite/${t}`}function h(e){if(e>=1e9)return`${(e/1e9).toFixed(2)}B`;if(e>=1e6)return`${(e/1e6).toFixed(1)}M`;return e.toLocaleString()}function T(e,t){return e??`#${t}`}function E(e,t,o){return`${e??`Species ${t}`}${o?", shiny":""}`}function N(e){return e.replace(/([A-Z])/g," $1").toLowerCase()}function $e(e){if(e.kind==="item")return N(e.item);return e.tier===null?"fresh egg":`fresh egg (${e.tier}+)`}var we=[null,"common","uncommon","rare","legendary"],Ce=60000,Se=60*Ce;function M(e,t,o){if(!e)return"egg";if(t===null)return"sleep";let i=o-t;if(i<5*Ce)return"working";if(i<Se)return"idle";if(i<8*Se)return"tired";return"sleep"}import{useState as ut}from"react";import r from"styled-components";var l={xs:"4px",sm:"8px",md:"12px",lg:"20px",xl:"32px"},B="192px",de="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",O=r.section`
1
+ import{definePluginUI as an,useLive as sn}from"@omnigateway/dashboard-sdk";import{useMutation as we,useQuery as Pt,useQueryClient as ln}from"@tanstack/react-query";import{useState as Lt}from"react";var Ht={rareCandy:{blurb:"Injects 100.0M growth. Priced at five times what it grants.",emoji:"\uD83C\uDF6C",consumable:!0},mint:{blurb:"Rerolls this companion's nature. Cosmetic, and cheap enough to reroll again.",emoji:"\uD83C\uDF3F",consumable:!0},shinyCharm:{blurb:"Kept, never spent. Raises every future hatch from 1 in 64 to 1 in 48.",emoji:"✨",consumable:!1},everstone:{blurb:"Pins this companion: it will not evolve, reveal, or graduate.",emoji:"\uD83E\uDEA8",consumable:!0},lure:{blurb:"Next egg prefers a species the Dex has not collected. A preference, never a veto.",emoji:"\uD83C\uDF6F",consumable:!0},sootheBell:{blurb:"This companion grows 25% faster. Bound to it, and never repays its price.",emoji:"\uD83D\uDD14",consumable:!0},incense:{blurb:"Next egg leans toward a longer evolution line. Buys events, not value.",emoji:"\uD83D\uDD6F️",consumable:!0},repel:{blurb:"Next egg will not hatch one named line.",emoji:"\uD83D\uDEAB",consumable:!0}};function M(e){return Ce.get(e)??{blurb:"",emoji:"❔",consumable:!0}}var Ce=new Map(Object.entries(Ht)),un=[...Ce].filter(([,e])=>e.consumable).map(([e])=>e),De="\uD83E\uDD5A";function Re(e){return e===null?"Sends this companion off and starts again.":`Sends this companion off for an egg guaranteed to hatch ${e} or better.`}function T(e,t,r){return`/api/plugins/${e}/sprite/${t}${r?"?shiny=1":""}`}function ge(e,t){return`/api/plugins/${e}/item-sprite/${t}`}var Kt="incubating";function Ee(e){return ge(e,Kt)}function b(e){if(e>=1e9)return`${(e/1e9).toFixed(2)}B`;if(e>=1e6)return`${(e/1e6).toFixed(1)}M`;return e.toLocaleString()}var _t=new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"long",year:"numeric"}),Gt=new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1});function q(e){let t=new Date(e);return`${_t.format(t)}, at ${Gt.format(t)}`}function Ne(e,t){return e??`#${t}`}function N(e,t,r){return`${e??`Species ${t}`}${r?", shiny":""}`}function B(e){return e.replace(/([A-Z])/g," $1").toLowerCase()}function Ae(e){if(e.kind==="item")return B(e.item);return e.tier===null?"fresh egg":`fresh egg (${e.tier}+)`}var Fe=[null,"common","uncommon","rare","legendary"],Pe=60000,Te=60*Pe;function O(e,t,r){if(!e)return"egg";if(t===null)return"sleep";let s=r-t;if(s<5*Pe)return"working";if(s<Te)return"idle";if(s<8*Te)return"tired";return"sleep"}import{useState as zt}from"react";import n from"styled-components";var o={xs:"4px",sm:"8px",md:"12px",lg:"20px",xl:"32px"},E="192px",H="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",Le="96px",Ot=o.lg,z=n.section`
2
2
  background: var(--panel);
3
3
  border: 1px solid var(--rule);
4
4
  border-radius: 8px;
5
- padding: ${l.lg};
5
+ padding: ${o.lg};
6
6
  color: var(--ink);
7
- `,ue=r.h3`
7
+ `,he=n.h3`
8
8
  display: flex;
9
9
  align-items: center;
10
- gap: ${l.md};
11
- margin: ${l.xl} 0 ${l.md};
10
+ gap: ${o.md};
11
+ margin: ${o.xl} 0 ${o.md};
12
12
  font-size: 11px;
13
13
  font-weight: 600;
14
14
  letter-spacing: 0.12em;
@@ -21,18 +21,18 @@ import{definePluginUI as It,useLive as $t}from"@omnigateway/dashboard-sdk";impor
21
21
  height: 1px;
22
22
  background: var(--rule);
23
23
  }
24
- `,Re=r(ue)`
24
+ `,Me=n(he)`
25
25
  &::after {
26
26
  content: none;
27
27
  }
28
- `,Te=r.span`
28
+ `,Be=n.span`
29
29
  flex: 1;
30
30
  height: 1px;
31
31
  background: var(--rule);
32
- `,De=r.button`
32
+ `,He=n.button`
33
33
  display: flex;
34
34
  align-items: center;
35
- gap: ${l.sm};
35
+ gap: ${o.sm};
36
36
  flex: 1;
37
37
  padding: 0;
38
38
  background: none;
@@ -52,7 +52,7 @@ import{definePluginUI as It,useLive as $t}from"@omnigateway/dashboard-sdk";impor
52
52
  outline-offset: 4px;
53
53
  border-radius: 2px;
54
54
  }
55
- `,Ee=r.span`
55
+ `,Ke=n.span`
56
56
  display: inline-block;
57
57
  font-size: 9px;
58
58
  line-height: 1;
@@ -62,46 +62,46 @@ import{definePluginUI as It,useLive as $t}from"@omnigateway/dashboard-sdk";impor
62
62
  @media (prefers-reduced-motion: reduce) {
63
63
  transition: none;
64
64
  }
65
- `,Pe=r.span`
65
+ `,_e=n.span`
66
66
  color: var(--ink-faint);
67
67
  letter-spacing: 0.08em;
68
68
  white-space: nowrap;
69
- `,I=r.div`
69
+ `,R=n.div`
70
70
  display: flex;
71
- gap: ${l.md};
71
+ gap: ${o.md};
72
72
  align-items: center;
73
73
  flex-wrap: wrap;
74
- `,Ae=r(I)`
74
+ `,Ge=n(R)`
75
75
  h2 {
76
76
  margin: 0;
77
77
  }
78
- `,x=r.span`
78
+ `,k=n.span`
79
79
  color: var(--ink-dim);
80
- `,_=r(x)`
80
+ `,U=n(k)`
81
81
  display: block;
82
- margin-top: ${l.sm};
82
+ margin-top: ${o.sm};
83
83
 
84
84
  /* Two facts about one meter are closer to each other than either is to the
85
85
  meter, because that is what they are: "stage 1 of 2" and the tokens under
86
86
  it are one reading, not two. Spaced evenly they read as a list of unrelated
87
87
  numbers that happen to be stacked. */
88
88
  & + & {
89
- margin-top: ${l.xs};
89
+ margin-top: ${o.xs};
90
90
  }
91
- `,Le=r.p`
91
+ `,Oe=n.p`
92
92
  color: var(--ink-dim);
93
- margin: ${l.xs} 0 ${l.lg};
94
- `,ce=r.p`
93
+ margin: ${o.xs} 0 ${o.lg};
94
+ `,fe=n.p`
95
95
  color: var(--warn);
96
96
  background: var(--warn-wash);
97
97
  border-radius: 6px;
98
- padding: ${l.md};
99
- margin: ${l.md} 0 0;
100
- `,b=r.span`
98
+ padding: ${o.md};
99
+ margin: ${o.md} 0 0;
100
+ `,S=n.span`
101
101
  display: inline-flex;
102
102
  align-items: center;
103
- gap: ${l.xs};
104
- padding: 2px ${l.sm};
103
+ gap: ${o.xs};
104
+ padding: 2px ${o.sm};
105
105
  border: 1px solid var(--rule);
106
106
  border-radius: 999px;
107
107
  font-size: 11px;
@@ -109,36 +109,47 @@ import{definePluginUI as It,useLive as $t}from"@omnigateway/dashboard-sdk";impor
109
109
  text-transform: uppercase;
110
110
  color: var(--ink-dim);
111
111
  white-space: nowrap;
112
- `,Ne=r(I)`
113
- margin: ${l.xs} 0 ${l.sm};
114
- `,V=r(b)`
112
+ `,ze=n(R)`
113
+ margin: ${o.xs} 0 ${o.sm};
114
+ `,Y=n(S)`
115
115
  border-color: var(--rule-strong);
116
116
  color: var(--ink);
117
117
  font-weight: 600;
118
- `,z=r.img`
119
- width: ${B};
120
- height: ${B};
118
+ `,J=n.img`
119
+ width: ${E};
120
+ height: ${E};
121
121
  image-rendering: pixelated;
122
- `,q=r.div`
122
+ `,Ue=n.div`
123
123
  box-sizing: border-box;
124
- width: ${B};
125
- height: ${B};
124
+ width: ${E};
125
+ height: ${E};
126
126
  border-radius: 50% 50% 45% 45%;
127
127
  background: var(--panel-sunk);
128
128
  border: 2px solid var(--rule-strong);
129
- `,Be=r.div`
129
+ `,je=n.span`
130
+ display: inline-flex;
131
+ align-items: center;
132
+ justify-content: center;
133
+ flex: none;
134
+ width: ${E};
135
+ height: ${E};
136
+ `,Ve=n.img`
137
+ width: 180px;
138
+ height: 180px;
139
+ image-rendering: pixelated;
140
+ `,We=n.div`
130
141
  box-sizing: border-box;
131
- width: ${B};
132
- height: ${B};
142
+ width: ${E};
143
+ height: ${E};
133
144
  border-radius: 6px;
134
145
  background: var(--warn-wash);
135
146
  border: 2px dashed var(--warn);
136
- `,k=r.button`
147
+ `,I=n.button`
137
148
  background: var(--panel-raised);
138
149
  border: 1px solid var(--rule);
139
150
  border-radius: 6px;
140
151
  color: var(--ink);
141
- padding: ${l.sm} ${l.md};
152
+ padding: ${o.sm} ${o.md};
142
153
  font: inherit;
143
154
  cursor: pointer;
144
155
 
@@ -158,22 +169,22 @@ import{definePluginUI as It,useLive as $t}from"@omnigateway/dashboard-sdk";impor
158
169
  color: var(--ink-faint);
159
170
  cursor: not-allowed;
160
171
  }
161
- `,K=r.span`
162
- font-family: ${de};
172
+ `,K=n.span`
173
+ font-family: ${H};
163
174
  font-variant-numeric: tabular-nums;
164
- `,Ke=r.div`
175
+ `,qe=n.div`
165
176
  display: flex;
166
177
  gap: 3px;
167
178
  min-width: 240px;
168
179
  max-width: 340px;
169
- `,Fe=r.div`
180
+ `,Ye=n.div`
170
181
  flex: 1;
171
182
  height: 10px;
172
183
  background: var(--panel-sunk);
173
184
  border: 1px solid var(--rule);
174
185
  border-radius: 3px;
175
186
  overflow: hidden;
176
- `,me=r.div`
187
+ `,xe=n.div`
177
188
  height: 100%;
178
189
  background: var(--accent);
179
190
  width: ${(e)=>Math.min(100,Math.max(0,e.$pct))}%;
@@ -182,99 +193,296 @@ import{definePluginUI as It,useLive as $t}from"@omnigateway/dashboard-sdk";impor
182
193
  @media (prefers-reduced-motion: reduce) {
183
194
  transition: none;
184
195
  }
185
- `,Me=r.dl`
196
+ `,Je=n.dl`
186
197
  display: flex;
187
198
  flex-wrap: wrap;
188
- gap: ${l.xl};
189
- margin: ${l.lg} 0 0;
190
- padding-top: ${l.lg};
199
+ gap: ${o.xl};
200
+ margin: ${o.lg} 0 0;
201
+ padding-top: ${o.lg};
191
202
  border-top: 1px solid var(--rule);
192
- `,J=r.div`
203
+ `,Q=n.div`
193
204
  display: flex;
194
205
  flex-direction: column;
195
206
  gap: 2px;
196
- `,Q=r.dt`
207
+ `,X=n.dt`
197
208
  font-size: 11px;
198
209
  letter-spacing: 0.08em;
199
210
  text-transform: uppercase;
200
211
  color: var(--ink-faint);
201
- `,Y=r.dd`
212
+ `,Z=n.dd`
202
213
  margin: 0;
203
- font-family: ${de};
214
+ font-family: ${H};
204
215
  font-variant-numeric: tabular-nums;
205
216
  font-size: 18px;
206
217
  color: var(--ink);
207
- `,Oe=r.div`
218
+ `,Qe=n.div`
208
219
  display: grid;
209
220
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
210
- gap: ${l.md};
211
- `,_e=r.button`
221
+ gap: ${o.md};
222
+ `,Xe=n.button`
212
223
  margin: 0;
213
224
  display: flex;
214
225
  flex-direction: column;
215
226
  align-items: center;
216
227
  gap: 2px;
217
- padding: ${l.xs};
218
- background: ${(e)=>e.$open?"var(--accent-wash)":"none"};
219
- border: 1px solid ${(e)=>e.$open?"var(--accent)":"transparent"};
228
+ padding: ${o.sm};
229
+ background: ${(e)=>e.$open?"var(--accent-wash)":"var(--panel-sunk)"};
230
+ border: 1px solid ${(e)=>e.$open?"var(--accent)":"var(--rule)"};
220
231
  border-radius: 8px;
221
232
  color: inherit;
222
233
  font: inherit;
223
234
  cursor: pointer;
224
235
 
225
236
  &:hover {
226
- border-color: ${(e)=>e.$open?"var(--accent)":"var(--rule)"};
237
+ border-color: ${(e)=>e.$open?"var(--accent)":"var(--rule-strong)"};
227
238
  }
228
239
  &:focus-visible {
229
240
  outline: 2px solid var(--accent);
230
241
  outline-offset: 2px;
231
242
  }
232
- `,Ge=r.div`
233
- grid-column: 1 / -1;
243
+ `,A=n.span`
244
+ font-family: ${H};
245
+ font-variant-numeric: tabular-nums;
246
+ font-size: 0.8em;
247
+ color: var(--ink-faint);
248
+ `,Ze=n.h3`
234
249
  display: flex;
235
- gap: ${l.lg};
236
- padding: ${l.md};
237
- background: var(--panel-sunk);
238
- border: 1px solid var(--rule);
239
- border-radius: 8px;
240
- `,He=r.div`
250
+ align-items: baseline;
251
+ gap: ${o.sm};
252
+ `,et=n(R)`
253
+ margin: 0 0 ${o.md};
254
+ `,tt=n.dialog`
255
+ /* The close control anchors to this box rather than to the viewport, which is
256
+ what an absolutely-positioned child of a top-layer element gets otherwise. */
257
+ position: relative;
258
+ margin: auto;
259
+ width: min(520px, calc(100vw - ${o.lg} * 2));
260
+ max-height: calc(100vh - ${o.xl} * 2);
261
+ overflow: auto;
262
+ padding: 0;
263
+ background: var(--panel-raised);
264
+ border: 1px solid var(--rule-strong);
265
+ border-radius: 12px;
266
+ box-shadow: var(--shadow);
267
+ color: var(--ink);
268
+
269
+ &::backdrop {
270
+ background: color-mix(in srgb, var(--panel-sunk) 70%, transparent);
271
+ }
272
+
273
+ /* One transition, on open only. A record appearing instantly at full size in
274
+ the middle of the page reads as a jump cut; 120ms of rise is enough to say
275
+ it came from the grid. Nothing else in this dialog animates — the chain and
276
+ the log are information, and information that moves is harder to read. */
277
+ &[open] {
278
+ animation: dex-record-in 120ms ease-out;
279
+ }
280
+
281
+ @keyframes dex-record-in {
282
+ from {
283
+ opacity: 0;
284
+ transform: translateY(4px);
285
+ }
286
+ }
287
+
288
+ @media (prefers-reduced-motion: reduce) {
289
+ &[open] {
290
+ animation: none;
291
+ }
292
+ }
293
+ `,nt=n.div`
294
+ display: flex;
295
+ flex-direction: column;
296
+ `,ot=n.div`
297
+ display: flex;
298
+ align-items: center;
299
+ gap: ${o.lg};
300
+ padding: ${o.lg};
301
+
302
+ img {
303
+ box-sizing: content-box;
304
+ width: ${Le};
305
+ height: ${Le};
306
+ padding: ${Ot};
307
+ image-rendering: pixelated;
308
+ background: var(--panel-sunk);
309
+ border: 1px solid var(--rule);
310
+ border-radius: 8px;
311
+ flex: none;
312
+ }
313
+
314
+ /* Below this the plate is wider than a phone, and a 128px sprite beside a
315
+ name that has to wrap is worse than the two stacked. */
316
+ @media (max-width: 420px) {
317
+ flex-direction: column;
318
+ align-items: flex-start;
319
+ gap: ${o.md};
320
+ }
321
+ `,rt=n.div`
322
+ display: flex;
323
+ flex-direction: column;
324
+ gap: ${o.lg};
325
+ padding: ${o.lg};
326
+ border-top: 1px solid var(--rule);
327
+ `,j=n.section`
328
+ display: flex;
329
+ flex-direction: column;
330
+ gap: ${o.sm};
331
+ `,be=n.span`
332
+ font-family: ${H};
333
+ font-variant-numeric: tabular-nums;
334
+ `,V=n.div`
335
+ display: flex;
336
+ align-items: baseline;
337
+ justify-content: space-between;
338
+ gap: ${o.sm};
339
+ font-size: 10px;
340
+ letter-spacing: 0.12em;
341
+ text-transform: uppercase;
342
+ color: var(--ink-faint);
343
+ `,it=n.button`
344
+ position: absolute;
345
+ top: ${o.md};
346
+ right: ${o.md};
347
+ /* 28px square. Smaller than the 44px a touch target wants, and deliberately:
348
+ this is a modal with three other ways out — Escape, the backdrop, and the
349
+ cell that opened it — so the control is a convenience rather than the only
350
+ exit. Sized to sit inside the plate's padding without displacing it. */
351
+ display: flex;
352
+ align-items: center;
353
+ justify-content: center;
354
+ width: 28px;
355
+ height: 28px;
356
+ background: none;
357
+ border: 1px solid transparent;
358
+ border-radius: 6px;
359
+ color: var(--ink-faint);
360
+ font: inherit;
361
+ line-height: 1;
362
+ cursor: pointer;
363
+
364
+ &:hover {
365
+ color: var(--ink);
366
+ border-color: var(--rule);
367
+ }
368
+ &:focus-visible {
369
+ outline: 2px solid var(--accent);
370
+ outline-offset: 2px;
371
+ }
372
+ `,at=n.div`
241
373
  display: flex;
242
374
  flex-direction: column;
243
375
  align-items: flex-start;
244
- gap: ${l.sm};
376
+ gap: ${o.sm};
245
377
  min-width: 0;
246
- `,Ue=r.div`
378
+ `,st=n.div`
247
379
  display: flex;
248
- align-items: center;
249
- gap: ${l.sm};
380
+ align-items: stretch;
250
381
  flex-wrap: wrap;
251
- `,je=r.figure`
382
+ gap: ${o.xs};
383
+ `,lt=n.span`
384
+ align-self: center;
385
+ width: ${o.md};
386
+ height: 1px;
387
+ background: var(--rule-strong);
388
+ flex: none;
389
+ `,dt=n.figure`
252
390
  margin: 0;
253
391
  display: flex;
254
392
  flex-direction: column;
255
393
  align-items: center;
256
- gap: 2px;
394
+ gap: ${o.xs};
395
+ width: 76px;
396
+ padding: ${o.sm} ${o.xs};
397
+ background: ${(e)=>e.$here?"var(--accent-wash)":"var(--panel-sunk)"};
398
+ border: 1px solid ${(e)=>e.$here?"var(--accent)":"var(--rule)"};
399
+ border-radius: 8px;
257
400
 
258
401
  img {
259
402
  width: 48px;
260
403
  height: 48px;
261
404
  image-rendering: pixelated;
262
405
  }
263
- `,Z=r.figcaption`
406
+
407
+ /* Both slots, not just the caption. The number is its own element now — the
408
+ same shape the grid cell uses — so a rule naming figcaption alone would
409
+ leave the marked tile's number at the dimmer weight and half-state it. */
410
+ figcaption,
411
+ span {
412
+ color: ${(e)=>e.$here?"var(--ink)":"var(--ink-dim)"};
413
+ }
414
+ `,ee=n.figcaption`
264
415
  color: var(--ink-dim);
265
416
  font-size: 11px;
266
417
  text-align: center;
267
418
  overflow-wrap: anywhere;
268
- `,Ve=r.div`
419
+ `,pt=n.h4`
420
+ margin: 0;
421
+ display: flex;
422
+ align-items: baseline;
423
+ gap: ${o.sm};
424
+ font-size: 18px;
425
+
426
+ /* The number is the identity in a Pokédex and the name is the annotation, so
427
+ here it is set at the heading's own size rather than at the 0.8em
428
+ SpeciesNumber uses elsewhere. It stays mono and faint, so it reads as a
429
+ register mark beside the name rather than competing with it. */
430
+ ${A} {
431
+ font-size: 1em;
432
+ }
433
+ `,ct=n.ul`
434
+ margin: 0;
435
+ padding: 0;
436
+ list-style: none;
437
+ display: flex;
438
+ flex-direction: column;
439
+ `,ut=n.li`
440
+ display: grid;
441
+ /* max-content rather than a fixed ch measure, because a written-out date is
442
+ not a fixed width — "3 September 2026" and "22 May 2026" differ by four
443
+ characters. A grid column is shared by every row, so this resolves to the
444
+ widest date in the list once and every row aligns to it. A ch figure would
445
+ have to be guessed against the longest month and would be wrong in one
446
+ direction or the other. */
447
+ grid-template-columns: max-content 1fr auto;
448
+ gap: ${o.sm};
449
+ align-items: baseline;
450
+ padding: ${o.sm} 0;
451
+ color: var(--ink-dim);
452
+ font-size: 11px;
453
+
454
+ & + & {
455
+ border-top: 1px solid var(--rule);
456
+ }
457
+
458
+ /* A full date, a nature and a mark do not fit on one line of a phone. The
459
+ date takes its own row and the other two sit under it, which keeps the
460
+ column alignment where there is room for it and drops it where there is
461
+ not. */
462
+ @media (max-width: 420px) {
463
+ grid-template-columns: 1fr auto;
464
+
465
+ & > :first-child {
466
+ grid-column: 1 / -1;
467
+ }
468
+ }
469
+ `,mt=n.span`
470
+ font-family: ${H};
471
+ font-variant-numeric: tabular-nums;
472
+ color: var(--ink);
473
+ `,gt=n.span`
474
+ color: var(--ink);
475
+ font-weight: 600;
476
+ `,ht=n.div`
269
477
  display: grid;
270
478
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
271
- gap: ${l.md};
272
- `,ze=r.button`
479
+ gap: ${o.md};
480
+ `,ft=n.button`
273
481
  display: flex;
274
482
  flex-direction: column;
275
483
  align-items: center;
276
- gap: ${l.sm};
277
- padding: ${l.md};
484
+ gap: ${o.sm};
485
+ padding: ${o.md};
278
486
  background: var(--panel-raised);
279
487
  border: 1px solid var(--rule);
280
488
  border-radius: 8px;
@@ -290,42 +498,42 @@ import{definePluginUI as It,useLive as $t}from"@omnigateway/dashboard-sdk";impor
290
498
  outline: 2px solid var(--accent);
291
499
  outline-offset: 2px;
292
500
  }
293
- `,W=r.span`
294
- font-family: ${de};
501
+ `,te=n.span`
502
+ font-family: ${H};
295
503
  font-size: 12px;
296
504
  color: var(--ink-dim);
297
505
  overflow-wrap: anywhere;
298
- `,X=r.div`
506
+ `,ne=n.div`
299
507
  display: grid;
300
508
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
301
- gap: ${l.md};
302
- `,ee=r.div`
509
+ gap: ${o.md};
510
+ `,oe=n.div`
303
511
  display: flex;
304
512
  flex-direction: column;
305
- gap: ${l.sm};
306
- padding: ${l.md};
513
+ gap: ${o.sm};
514
+ padding: ${o.md};
307
515
  background: var(--panel-sunk);
308
516
  border: 1px solid var(--rule);
309
517
  border-radius: 8px;
310
- `,te=r.div`
518
+ `,re=n.div`
311
519
  display: flex;
312
520
  align-items: center;
313
- gap: ${l.sm};
314
- `,ne=r.span`
521
+ gap: ${o.sm};
522
+ `,ie=n.span`
315
523
  flex: 1;
316
524
  overflow-wrap: anywhere;
317
- `,oe=r.p`
525
+ `,ae=n.p`
318
526
  margin: 0;
319
527
  color: var(--ink-dim);
320
528
  font-size: 12px;
321
529
  line-height: 1.45;
322
- `,re=r.div`
530
+ `,se=n.div`
323
531
  display: flex;
324
532
  align-items: center;
325
533
  justify-content: flex-end;
326
- gap: ${l.sm};
534
+ gap: ${o.sm};
327
535
  margin-top: auto;
328
- `,qe=r.span`
536
+ `,xt=n.span`
329
537
  display: inline-flex;
330
538
  align-items: center;
331
539
  justify-content: center;
@@ -334,8 +542,8 @@ import{definePluginUI as It,useLive as $t}from"@omnigateway/dashboard-sdk";impor
334
542
  height: 32px;
335
543
  font-size: 20px;
336
544
  line-height: 1;
337
- `,Je=r.img`
545
+ `,bt=n.img`
338
546
  width: 32px;
339
547
  height: 32px;
340
548
  image-rendering: pixelated;
341
- `;import{jsx as Qe}from"react/jsx-runtime";function ie({item:e,emoji:t,pluginId:o}){let[i,d]=ut(!1);return Qe(qe,{"aria-hidden":"true",children:i?t:Qe(Je,{alt:"",onError:()=>d(!0),src:Ie(o,e)})})}import{jsx as P,jsxs as ae}from"react/jsx-runtime";function Ye({inventory:e,onUse:t,pending:o,pluginId:i}){let d=Object.entries(e).filter(([,p])=>p>0);if(d.length===0)return P(x,{children:"Nothing in the bag."});return P(X,{children:d.map(([p,n])=>{let a=L(p);return ae(ee,{children:[ae(te,{children:[P(ie,{emoji:a.emoji,item:p,pluginId:i}),P(ne,{children:N(p)}),ae(K,{children:["×",n]})]}),P(oe,{children:a.blurb}),P(re,{children:a.consumable?ae(k,{disabled:o,onClick:()=>t(p),type:"button",children:["Use ",N(p)]}):P(x,{children:"held"})})]},p)})})}import{Fragment as ct,useState as Ze}from"react";import{jsx as y,jsxs as w,Fragment as gt}from"react/jsx-runtime";function We({entries:e,pluginId:t}){let[o,i]=Ze(null),[d,p]=Ze(null);if(e.length===0)return y(x,{children:"Nothing graduated yet."});let n=o===null?e:e.filter((a)=>a.rarity===o);return w(gt,{children:[y(I,{children:we.map((a)=>y(k,{"aria-pressed":o===a,onClick:()=>{i(a),p(null)},type:"button",children:a??"all"},a??"all"))}),n.length===0?w(x,{children:["No ",o," graduates yet."]}):y(Oe,{children:n.map((a)=>{let s=d===a.id,S=`dex-detail-${a.id}`;return w(ct,{children:[w(_e,{$open:s,"aria-controls":S,"aria-expanded":s,onClick:()=>p(s?null:a.id),type:"button",children:[y("img",{alt:`${a.rarity}${a.isShiny?" shiny":""} ${a.name??`species ${a.finalId}`}`,src:R(t,a.finalId,a.isShiny),style:{width:"64px",height:"64px",imageRendering:"pixelated"}}),y(Z,{children:T(a.name,a.finalId)}),a.nature===null?null:y(Z,{children:a.nature})]}),s?y(mt,{entry:a,id:S,pluginId:t}):null]},a.id)})})]})}function mt({entry:e,id:t,pluginId:o}){return w(Ge,{id:t,children:[y("img",{alt:E(e.name,e.finalId,e.isShiny),src:R(o,e.finalId,e.isShiny),style:{width:"96px",height:"96px",imageRendering:"pixelated"}}),w(He,{children:[y("strong",{children:T(e.name,e.finalId)}),w(I,{children:[y(b,{children:e.rarity}),e.isShiny?y(V,{children:"✦ shiny"}):null,e.nature===null?null:y(b,{children:e.nature})]}),y(Ue,{children:e.chainOrder.map((i,d)=>w(je,{children:[y("img",{alt:E(null,i,!1),src:R(o,i,!1)}),y(Z,{children:i===e.finalId?T(e.name,i):`#${i}`})]},`${i}-${d}`))}),w(x,{children:["caught ",new Date(e.caughtAt).toLocaleDateString()]})]})]})}import{jsx as ge,jsxs as ht}from"react/jsx-runtime";function he({stages:e,stageIndex:t,progress:o,threshold:i,label:d,valueText:p}){let n=o/Math.max(1,i)*100;return ge(Ke,{"aria-label":d,"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":o,"aria-valuetext":p,role:"progressbar",children:Array.from({length:Math.max(1,e)},(a,s)=>ht(Fe,{children:[s<t?ge(me,{$pct:100}):null,s===t?ge(me,{$pct:n}):null]},s))})}function Xe(e,t,o,i){return`stage ${t+1} of ${e}, ${h(o)} of ${h(i)} tokens`}import{jsx as c,jsxs as m,Fragment as G}from"react/jsx-runtime";function et({view:e,activity:t,pluginId:o,onRelease:i,releasing:d}){let p=e.state;if(p===null)return null;let{active:n}=p,a=n===null?null:n.plannedPath[n.stageIndex]??null;return m(G,{children:[m(I,{children:[a===null?c(q,{"aria-label":"An egg, not yet hatched",role:"img"}):c(z,{alt:E(e.name,a,n?.isShiny===!0),src:R(o,a,n?.isShiny===!0)}),m("div",{children:[c("h3",{children:a===null?"Egg":T(e.name,a)}),m(Ne,{children:[n===null?p.eggTier===null?null:m(b,{children:[p.eggTier,"+ guaranteed"]}):m(G,{children:[c(b,{children:n.rarity}),n.isShiny?m(V,{children:[c("span",{"aria-hidden":"true",children:"✦"}),"shiny"]}):null,c(b,{children:n.nature}),n.dittoDisguise===null||n.dittoRevealed?null:c(b,{children:"?"}),n.everstone?c(b,{children:"everstone"}):null,n.soothe?c(b,{children:"soothe bell"}):null]}),c(b,{"aria-label":`Activity: ${t}`,role:"status",children:t})]}),n===null?m(G,{children:[c(he,{label:"Incubation",progress:e.progress,stageIndex:0,stages:1,threshold:e.nextThreshold,valueText:`${h(e.progress)} of ${h(e.nextThreshold)} tokens incubated`}),m(_,{children:[h(e.progress)," / ",h(e.nextThreshold)," tokens incubated"]})]}):m(G,{children:[c(he,{label:"Growth to the next evolution",progress:e.progress,stageIndex:n.stageIndex,stages:n.plannedPath.length,threshold:e.nextThreshold,valueText:Xe(n.plannedPath.length,n.stageIndex,e.progress,e.nextThreshold)}),m(_,{children:["Stage ",n.stageIndex+1," of ",n.plannedPath.length]}),n.everstone?m(G,{children:[m(_,{children:["Held at this stage · ",h(e.progress)," banked"]}),c(k,{disabled:d,onClick:i,type:"button",children:"Release"})]}):m(_,{children:[h(e.progress)," / ",h(e.nextThreshold)," to the next stage"]})]})]})]}),m(Me,{children:[m(J,{children:[c(Q,{children:"Earned"}),c(Y,{children:h(e.tokensTotal)})]}),m(J,{children:[c(Q,{children:"To spend"}),c(Y,{children:h(e.wallet)})]}),m(J,{children:[c(Q,{children:"Graduated"}),c(Y,{children:e.dex.length.toLocaleString()})]})]})]})}import{useState as ft}from"react";import{jsx as v,jsxs as se}from"react/jsx-runtime";function tt({keys:e,onPick:t,pluginId:o,rosterFailed:i}){let[d,p]=ft("");return se(O,{children:[v("h2",{children:"Companion"}),v(Le,{children:"Each API key raises its own Pokémon on the tokens it spends. Pick a key."}),e.length>0?v(Ve,{children:e.map((n)=>v(xt,{entry:n,onPick:t,pluginId:o},n.apiKeyId))}):v(x,{children:i?"The list of keys could not be loaded. Enter a key id below to reach a companion directly.":"No key has spent a token yet. A companion appears the first time a key serves a request."}),v(ue,{children:"Or by key id"}),v("form",{onSubmit:(n)=>{n.preventDefault();let a=d.trim();if(a!=="")t(a)},children:se(I,{children:[v("input",{"aria-label":"API key id",onChange:(n)=>p(n.target.value),placeholder:"key id",value:d}),v(k,{type:"submit",children:"Show"})]})})]})}function xt({entry:e,onPick:t,pluginId:o}){let i=M(e.speciesId!==null,e.lastCreditAt,Date.now());return se(ze,{onClick:()=>t(e.apiKeyId),type:"button",children:[e.unreadable?v(Be,{"aria-label":"This key's save could not be read",role:"img"}):e.speciesId===null?v(q,{"aria-label":"An egg, not yet hatched",role:"img"}):v(z,{alt:E(e.name,e.speciesId,e.isShiny),src:R(o,e.speciesId,e.isShiny)}),v("strong",{children:e.unreadable?"Save unreadable":e.speciesId===null?"Egg":T(e.name,e.speciesId)}),e.rarity===null?null:v(b,{children:e.rarity}),v(W,{children:e.apiKeyId}),se(x,{children:[v(K,{children:h(e.tokensTotal)}),e.unreadable?null:` · ${i}`]})]})}import{useId as bt,useState as yt}from"react";import{jsx as H,jsxs as nt,Fragment as kt}from"react/jsx-runtime";var F={shop:!0,bag:!0,dex:!0},ot=(e)=>`plugin:${e}:sections`;function vt(e){try{let t=globalThis.localStorage?.getItem(ot(e));if(t===null||t===void 0)return F;let o=JSON.parse(t);if(typeof o!=="object"||o===null)return F;let i=o;return{shop:typeof i.shop==="boolean"?i.shop:F.shop,bag:typeof i.bag==="boolean"?i.bag:F.bag,dex:typeof i.dex==="boolean"?i.dex:F.dex}}catch{return F}}function rt(e){let[t,o]=yt(()=>vt(e));return{open:t,toggle:(d)=>{o((p)=>{let n={...p,[d]:!p[d]};try{globalThis.localStorage?.setItem(ot(e),JSON.stringify(n))}catch{}return n})}}}function le({title:e,count:t,open:o,onToggle:i,children:d}){let p=bt();return nt(kt,{children:[H(Re,{children:nt(De,{"aria-controls":p,"aria-expanded":o,onClick:i,type:"button",children:[H(Ee,{$open:o,children:"▶"}),e,H(Te,{}),H(Pe,{children:t})]})}),o?H("div",{id:p,children:d}):null]})}import{jsx as A,jsxs as pe}from"react/jsx-runtime";function it({offers:e,wallet:t,onBuy:o,pending:i,inventory:d,hasCompanion:p,pluginId:n}){return A(X,{children:e.map((a)=>{let{entry:s,price:S}=a,C=St(s,d),u=s.kind==="egg"&&!p,D=s.kind==="item"?N(s.item):"fresh egg";return pe(ee,{children:[pe(te,{children:[A(ie,{emoji:s.kind==="item"?L(s.item).emoji:ve,item:s.kind==="item"?s.item:"egg",pluginId:n}),A(ne,{children:D}),C?A(x,{children:"owned"}):A(K,{children:h(S)})]}),s.kind==="egg"&&s.tier!==null?pe(b,{children:[s.tier,"+"]}):null,A(oe,{children:s.kind==="item"?L(s.item).blurb:ke(s.tier)}),A(re,{children:pe(k,{disabled:C||u||t<S||i,onClick:()=>o(s),type:"button",children:["Buy ",$e(s)]})})]},s.kind==="item"?`item:${s.item}`:`egg:${s.tier??""}`)})})}function St(e,t){if(e.kind!=="item")return!1;return!L(e.item).consumable&&(t[e.item]??0)>0}import{jsx as f,jsxs as xe,Fragment as Tt}from"react/jsx-runtime";var lt=1e4;function Ct({pluginId:e,api:t}){let[o,i]=st({at:"start"}),d=wt(),{cadence:p}=$t(),n=at({queryKey:["roster"],queryFn:()=>t.get("keys"),refetchInterval:p(lt)}),a=n.data?.keys??[];if(o.at==="start"&&!n.isPending){let g=a.length===1?a[0]:void 0;i(g===void 0?{at:"roster"}:{at:"key",apiKeyId:g.apiKeyId})}let s=o.at==="key"?o.apiKeyId:null,S=at({queryKey:["companion",s],queryFn:()=>t.get(`keys/${s}`),enabled:s!==null,refetchInterval:p(lt)}),[C,u]=st(null),D=()=>{d.invalidateQueries({queryKey:["companion",s]}),d.invalidateQueries({queryKey:["roster"]})},U=fe({mutationFn:(g)=>t.post(`keys/${s}/purchase`,g),onMutate:()=>u(null),onError:(g)=>u(g instanceof Error?g.message:"the purchase was refused"),onSuccess:D}),j=fe({mutationFn:(g)=>t.post(`keys/${s}/use`,{item:g}),onMutate:()=>u(null),onError:(g)=>u(g instanceof Error?g.message:"the item could not be used"),onSuccess:D}),be=fe({mutationFn:()=>t.post(`keys/${s}/unpin`),onMutate:()=>u(null),onError:(g)=>u(g instanceof Error?g.message:"the companion could not be released"),onSuccess:D});if(n.isPending)return f(O,{children:"Loading…"});if(s===null)return f(tt,{keys:a,onPick:(g)=>i({at:"key",apiKeyId:g}),pluginId:e,rosterFailed:n.isError});return xe(O,{children:[xe(Ae,{children:[f("h2",{children:"Companion"}),f(W,{children:s}),f(k,{onClick:()=>i({at:"roster"}),type:"button",children:"All keys"})]}),f(Rt,{buy:U.mutate,buying:U.isPending,keyId:s,onRelease:()=>be.mutate(),onUse:j.mutate,pluginId:e,query:S,refusal:C,releasing:be.isPending,using:j.isPending})]})}function Rt({query:e,pluginId:t,buy:o,onUse:i,onRelease:d,buying:p,using:n,releasing:a,refusal:s}){let{open:S,toggle:C}=rt(t);if(e.isPending)return f(x,{children:"Loading…"});if(e.isError||e.data===void 0)return f(x,{children:"No companion for that key yet."});let u=e.data;if(u.state===null)return f(ce,{children:"This key's save could not be read. It has been left untouched rather than replaced — nothing has been lost, but it needs looking at."});let D=M(u.state.active!==null,u.lastCreditAt,Date.now()),U=Object.values(u.state.inventory).filter((j)=>j>0).length;return xe(Tt,{children:[f(et,{activity:D,onRelease:d,pluginId:t,releasing:a,view:u}),f(le,{count:pt(u.shop.length,"offer"),onToggle:()=>C("shop"),open:S.shop,title:"Shop",children:f(it,{hasCompanion:u.state.active!==null,inventory:u.state.inventory,offers:u.shop,onBuy:o,pending:p,pluginId:t,wallet:u.wallet})}),f(le,{count:`${U} held`,onToggle:()=>C("bag"),open:S.bag,title:"Bag",children:f(Ye,{inventory:u.state.inventory,onUse:i,pending:n,pluginId:t})}),s===null?null:f(ce,{role:"alert",children:s}),f(le,{count:pt(u.dex.length,"graduate"),onToggle:()=>C("dex"),open:S.dex,title:"Pokédex",children:f(We,{entries:u.dex,pluginId:t})})]})}function pt(e,t){return`${e} ${t}${e===1?"":"s"}`}var An=It({mount:Ct});export{M as activityOf,An as default};
549
+ `;import{jsx as yt}from"react/jsx-runtime";function le({item:e,emoji:t,pluginId:r}){let[s,c]=zt(!1);return yt(xt,{"aria-hidden":"true",children:s?t:yt(bt,{alt:"",onError:()=>c(!0),src:ge(r,e)})})}import{jsx as F,jsxs as de}from"react/jsx-runtime";function vt({inventory:e,onUse:t,pending:r,pluginId:s}){let c=Object.entries(e).filter(([,d])=>d>0);if(c.length===0)return F(k,{children:"Nothing in the bag."});return F(ne,{children:c.map(([d,a])=>{let l=M(d);return de(oe,{children:[de(re,{children:[F(le,{emoji:l.emoji,item:d,pluginId:s}),F(ie,{children:B(d)}),de(K,{children:["×",a]})]}),F(ae,{children:l.blurb}),F(se,{children:l.consumable?de(I,{disabled:r,onClick:()=>t(d),type:"button",children:["Use ",B(d)]}):F(k,{children:"held"})})]},d)})})}import{Fragment as Ut,useCallback as jt,useEffect as Vt,useMemo as kt,useRef as $t,useState as St}from"react";import{jsx as u,jsxs as g,Fragment as Yt}from"react/jsx-runtime";var Wt="—",ye="✦";function It({entries:e,pluginId:t}){let[r,s]=St(null),[c,d]=St(null),a=$t(null),l=jt(()=>{d(null),a.current?.focus()},[]),i=kt(()=>new Set(e.map((p)=>p.speciesId)),[e]),w=kt(()=>{let p=new Map;for(let D of e)if(D.name!==null)p.set(D.speciesId,D.name);return p},[e]);if(e.length===0)return u(k,{children:"Nothing caught yet."});let C=r===null?e:e.filter((p)=>p.rarity===r),m=e.find((p)=>p.speciesId===c);return g(Yt,{children:[u(et,{children:Fe.map((p)=>u(I,{"aria-pressed":r===p,onClick:()=>s(p),type:"button",children:p??"all"},p??"all"))}),C.length===0?g(k,{children:["No ",r," species yet."]}):u(Qe,{children:C.map((p)=>{let D=c===p.speciesId;return g(Xe,{$open:D,"aria-haspopup":"dialog",onClick:(L)=>{a.current=L.currentTarget,d(p.speciesId)},type:"button",children:[u("img",{alt:`${p.rarity}${p.isShiny?" shiny":""} ${p.name??`species ${p.speciesId}`}`,src:T(t,p.speciesId,p.isShiny),style:{width:"64px",height:"64px",imageRendering:"pixelated"}}),g(A,{children:["#",p.speciesId]}),p.name===null?null:u(ee,{children:p.name}),wt(p)===null?null:u(ee,{children:wt(p)})]},p.speciesId)})}),m===void 0?null:u(qt,{entry:m,names:w,obtained:i,onClose:l,pluginId:t})]})}function wt(e){let t=[e.isShiny?ye:null,e.catches.length>1?`× ${e.catches.length}`:null].filter((r)=>r!==null);return t.length===0?null:t.join(" ")}function qt({entry:e,names:t,obtained:r,onClose:s,pluginId:c}){let d=$t(null),a=`dex-record-${e.speciesId}`;return Vt(()=>{let l=d.current;if(l===null)return;return l.showModal(),()=>{if(l.open)l.close()}},[]),g(tt,{"aria-labelledby":a,onClick:(l)=>{if(l.target===l.currentTarget)s()},onClose:s,ref:d,children:[u(it,{"aria-label":"Close",onClick:s,type:"button",children:"✕"}),g(nt,{children:[g(ot,{children:[u("img",{alt:N(e.name,e.speciesId,e.isShiny),src:T(c,e.speciesId,e.isShiny)}),g(at,{children:[g(pt,{id:a,children:[g(A,{children:["#",e.speciesId]}),e.name===null?null:e.name]}),g(R,{children:[u(S,{children:e.rarity}),e.isShiny?g(Y,{children:[ye," shiny"]}):null]})]})]}),g(rt,{children:[g(j,{children:[u(V,{children:e.catches.length>0&&e.firstCaughtExact?"first caught":"line graduated"}),u(be,{children:e.catches.length===0?Wt:q(e.firstCaughtAt)})]}),g(j,{children:[u(V,{children:e.lines.length>1?"evolutions":"evolution"}),e.lines.map((l)=>u(st,{children:l.filter((i)=>r.has(i)).map((i,w)=>g(Ut,{children:[w===0?null:u(lt,{"aria-hidden":"true"}),g(dt,{$here:i===e.speciesId,"aria-current":i===e.speciesId?"true":void 0,children:[u("img",{alt:N(t.get(i)??null,i,!1),src:T(c,i,!1)}),g(A,{children:["#",i]}),t.has(i)?u(ee,{children:t.get(i)}):null]})]},`${i}-${w}`))},l.join("-")))]}),e.catches.length===0?null:g(j,{children:[g(V,{children:[u("span",{children:e.catches.length===1?"encounter":"encounters"}),e.catches.length>1?u("span",{children:e.catches.length}):null]}),u(ct,{children:e.catches.map((l)=>g(ut,{children:[u(mt,{children:q(l.enteredAt??l.caughtAt)}),u("span",{children:l.nature??""}),l.isShiny?u(gt,{children:ye}):u("span",{})]},l.id))})]}),e.catches.length===0?g(j,{children:[u(V,{children:"encounter"}),u(be,{children:q(e.firstCaughtAt)})]}):null]})]})]})}import{useState as Jt}from"react";import{jsx as ve}from"react/jsx-runtime";function pe({pluginId:e}){let[t,r]=Jt(!1);if(t)return ve(Ue,{"aria-label":Ct,role:"img"});return ve(je,{children:ve(Ve,{alt:Ct,onError:()=>r(!0),src:Ee(e)})})}var Ct="An egg, not yet hatched";import{jsx as ke,jsxs as Qt}from"react/jsx-runtime";function Se({stages:e,stageIndex:t,progress:r,threshold:s,label:c,valueText:d}){let a=r/Math.max(1,s)*100;return ke(qe,{"aria-label":c,"aria-valuemax":s,"aria-valuemin":0,"aria-valuenow":r,"aria-valuetext":d,role:"progressbar",children:Array.from({length:Math.max(1,e)},(l,i)=>Qt(Ye,{children:[i<t?ke(xe,{$pct:100}):null,i===t?ke(xe,{$pct:a}):null]},i))})}function Dt(e,t,r,s){return`stage ${t+1} of ${e}, ${b(r)} of ${b(s)} tokens`}import{jsx as h,jsxs as f,Fragment as _}from"react/jsx-runtime";function Rt({view:e,activity:t,pluginId:r,onRelease:s,releasing:c}){let d=e.state;if(d===null)return null;let{active:a}=d,l=a===null?null:a.plannedPath[a.stageIndex]??null;return f(_,{children:[f(R,{children:[l===null?h(pe,{pluginId:r}):h(J,{alt:N(e.name,l,a?.isShiny===!0),src:T(r,l,a?.isShiny===!0)}),f("div",{children:[h(Ze,{children:l===null?"Egg":f(_,{children:[f(A,{children:["#",l]}),e.name===null?null:h("span",{children:e.name})]})}),f(ze,{children:[a===null?d.eggTier===null?null:f(S,{children:[d.eggTier,"+ guaranteed"]}):f(_,{children:[h(S,{children:a.rarity}),a.isShiny?f(Y,{children:[h("span",{"aria-hidden":"true",children:"✦"}),"shiny"]}):null,h(S,{children:a.nature}),a.dittoDisguise===null||a.dittoRevealed?null:h(S,{children:"?"}),a.everstone?h(S,{children:"everstone"}):null,a.soothe?h(S,{children:"soothe bell"}):null]}),h(S,{"aria-label":`Activity: ${t}`,role:"status",children:t})]}),a===null?f(_,{children:[h(Se,{label:"Incubation",progress:e.progress,stageIndex:0,stages:1,threshold:e.nextThreshold,valueText:`${b(e.progress)} of ${b(e.nextThreshold)} tokens incubated`}),f(U,{children:[b(e.progress)," / ",b(e.nextThreshold)," tokens incubated"]})]}):f(_,{children:[h(Se,{label:"Growth to the next evolution",progress:e.progress,stageIndex:a.stageIndex,stages:a.plannedPath.length,threshold:e.nextThreshold,valueText:Dt(a.plannedPath.length,a.stageIndex,e.progress,e.nextThreshold)}),f(U,{children:["Stage ",a.stageIndex+1," of ",a.plannedPath.length]}),a.everstone?f(_,{children:[f(U,{children:["Held at this stage · ",b(e.progress)," banked"]}),h(I,{disabled:c,onClick:s,type:"button",children:"Release"})]}):f(U,{children:[b(e.progress)," / ",b(e.nextThreshold)," to the next stage"]})]})]})]}),f(Je,{children:[f(Q,{children:[h(X,{children:"Earned"}),h(Z,{children:b(e.tokensTotal)})]}),f(Q,{children:[h(X,{children:"To spend"}),h(Z,{children:b(e.wallet)})]}),f(Q,{children:[h(X,{children:"Graduated"}),h(Z,{children:e.dex.length.toLocaleString()})]})]})]})}import{useState as Xt}from"react";import{jsx as v,jsxs as ce}from"react/jsx-runtime";function Tt({keys:e,onPick:t,pluginId:r,rosterFailed:s}){let[c,d]=Xt("");return ce(z,{children:[v("h2",{children:"Companion"}),v(Oe,{children:"Each API key raises its own Pokémon on the tokens it spends. Pick a key."}),e.length>0?v(ht,{children:e.map((a)=>v(Zt,{entry:a,onPick:t,pluginId:r},a.apiKeyId))}):v(k,{children:s?"The list of keys could not be loaded. Enter a key id below to reach a companion directly.":"No key has spent a token yet. A companion appears the first time a key serves a request."}),v(he,{children:"Or by key id"}),v("form",{onSubmit:(a)=>{a.preventDefault();let l=c.trim();if(l!=="")t(l)},children:ce(R,{children:[v("input",{"aria-label":"API key id",onChange:(a)=>d(a.target.value),placeholder:"key id",value:c}),v(I,{type:"submit",children:"Show"})]})})]})}function Zt({entry:e,onPick:t,pluginId:r}){let s=O(e.speciesId!==null,e.lastCreditAt,Date.now());return ce(ft,{onClick:()=>t(e.apiKeyId),type:"button",children:[e.unreadable?v(We,{"aria-label":"This key's save could not be read",role:"img"}):e.speciesId===null?v(pe,{pluginId:r}):v(J,{alt:N(e.name,e.speciesId,e.isShiny),src:T(r,e.speciesId,e.isShiny)}),v("strong",{children:e.unreadable?"Save unreadable":e.speciesId===null?"Egg":Ne(e.name,e.speciesId)}),e.rarity===null?null:v(S,{children:e.rarity}),v(te,{children:e.apiKeyId}),ce(k,{children:[v(K,{children:b(e.tokensTotal)}),e.unreadable?null:` · ${s}`]})]})}import{useId as en,useState as tn}from"react";import{jsx as W,jsxs as Et,Fragment as on}from"react/jsx-runtime";var G={shop:!0,bag:!0,dex:!0},Nt=(e)=>`plugin:${e}:sections`;function nn(e){try{let t=globalThis.localStorage?.getItem(Nt(e));if(t===null||t===void 0)return G;let r=JSON.parse(t);if(typeof r!=="object"||r===null)return G;let s=r;return{shop:typeof s.shop==="boolean"?s.shop:G.shop,bag:typeof s.bag==="boolean"?s.bag:G.bag,dex:typeof s.dex==="boolean"?s.dex:G.dex}}catch{return G}}function At(e){let[t,r]=tn(()=>nn(e));return{open:t,toggle:(c)=>{r((d)=>{let a={...d,[c]:!d[c]};try{globalThis.localStorage?.setItem(Nt(e),JSON.stringify(a))}catch{}return a})}}}function ue({title:e,count:t,open:r,onToggle:s,children:c}){let d=en();return Et(on,{children:[W(Me,{children:Et(He,{"aria-controls":d,"aria-expanded":r,onClick:s,type:"button",children:[W(Ke,{$open:r,children:"▶"}),e,W(Be,{}),W(_e,{children:t})]})}),r?W("div",{id:d,children:c}):null]})}import{jsx as P,jsxs as me}from"react/jsx-runtime";function Ft({offers:e,wallet:t,onBuy:r,pending:s,inventory:c,hasCompanion:d,pluginId:a}){return P(ne,{children:e.map((l)=>{let{entry:i,price:w}=l,C=rn(i,c),m=i.kind==="egg"&&!d,p=i.kind==="item"?B(i.item):"fresh egg";return me(oe,{children:[me(re,{children:[P(le,{emoji:i.kind==="item"?M(i.item).emoji:De,item:i.kind==="item"?i.item:"egg",pluginId:a}),P(ie,{children:p}),C?P(k,{children:"owned"}):P(K,{children:b(w)})]}),i.kind==="egg"&&i.tier!==null?me(S,{children:[i.tier,"+"]}):null,P(ae,{children:i.kind==="item"?M(i.item).blurb:Re(i.tier)}),P(se,{children:me(I,{disabled:C||m||t<w||s,onClick:()=>r(i),type:"button",children:["Buy ",Ae(i)]})})]},i.kind==="item"?`item:${i.item}`:`egg:${i.tier??""}`)})})}function rn(e,t){if(e.kind!=="item")return!1;return!M(e.item).consumable&&(t[e.item]??0)>0}import{jsx as y,jsxs as $e,Fragment as cn}from"react/jsx-runtime";var Mt=1e4;function dn({pluginId:e,api:t}){let[r,s]=Lt({at:"start"}),c=ln(),{cadence:d}=sn(),a=Pt({queryKey:["roster"],queryFn:()=>t.get("keys"),refetchInterval:d(Mt)}),l=a.data?.keys??[];if(r.at==="start"&&!a.isPending){let x=l.length===1?l[0]:void 0;s(x===void 0?{at:"roster"}:{at:"key",apiKeyId:x.apiKeyId})}let i=r.at==="key"?r.apiKeyId:null,w=Pt({queryKey:["companion",i],queryFn:()=>t.get(`keys/${i}`),enabled:i!==null,refetchInterval:d(Mt)}),[C,m]=Lt(null),p=()=>{c.invalidateQueries({queryKey:["companion",i]}),c.invalidateQueries({queryKey:["roster"]})},D=we({mutationFn:(x)=>t.post(`keys/${i}/purchase`,x),onMutate:()=>m(null),onError:(x)=>m(x instanceof Error?x.message:"the purchase was refused"),onSuccess:p}),L=we({mutationFn:(x)=>t.post(`keys/${i}/use`,{item:x}),onMutate:()=>m(null),onError:(x)=>m(x instanceof Error?x.message:"the item could not be used"),onSuccess:p}),Ie=we({mutationFn:()=>t.post(`keys/${i}/unpin`),onMutate:()=>m(null),onError:(x)=>m(x instanceof Error?x.message:"the companion could not be released"),onSuccess:p});if(a.isPending)return y(z,{children:"Loading…"});if(i===null)return y(Tt,{keys:l,onPick:(x)=>s({at:"key",apiKeyId:x}),pluginId:e,rosterFailed:a.isError});return $e(z,{children:[$e(Ge,{children:[y("h2",{children:"Companion"}),y(te,{children:i}),y(I,{onClick:()=>s({at:"roster"}),type:"button",children:"All keys"})]}),y(pn,{buy:D.mutate,buying:D.isPending,keyId:i,onRelease:()=>Ie.mutate(),onUse:L.mutate,pluginId:e,query:w,refusal:C,releasing:Ie.isPending,using:L.isPending})]})}function pn({query:e,pluginId:t,buy:r,onUse:s,onRelease:c,buying:d,using:a,releasing:l,refusal:i}){let{open:w,toggle:C}=At(t);if(e.isPending)return y(k,{children:"Loading…"});if(e.isError||e.data===void 0)return y(k,{children:"No companion for that key yet."});let m=e.data;if(m.state===null)return y(fe,{children:"This key's save could not be read. It has been left untouched rather than replaced — nothing has been lost, but it needs looking at."});let p=O(m.state.active!==null,m.lastCreditAt,Date.now()),D=Object.values(m.state.inventory).filter((L)=>L>0).length;return $e(cn,{children:[y(Rt,{activity:p,onRelease:c,pluginId:t,releasing:l,view:m}),y(ue,{count:Bt(m.shop.length,"offer"),onToggle:()=>C("shop"),open:w.shop,title:"Shop",children:y(Ft,{hasCompanion:m.state.active!==null,inventory:m.state.inventory,offers:m.shop,onBuy:r,pending:d,pluginId:t,wallet:m.wallet})}),y(ue,{count:`${D} held`,onToggle:()=>C("bag"),open:w.bag,title:"Bag",children:y(vt,{inventory:m.state.inventory,onUse:s,pending:a,pluginId:t})}),i===null?null:y(fe,{role:"alert",children:i}),y(ue,{count:Bt(m.dex.length,"species","species"),onToggle:()=>C("dex"),open:w.dex,title:"Pokédex",children:y(It,{entries:m.dex,pluginId:t})})]})}function Bt(e,t,r=`${t}s`){return`${e} ${e===1?t:r}`}var So=an({mount:dn});export{O as activityOf,So as default};