@omnigateway/pokemon 1.1.1 → 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 Lt,useLive as Bt}from"@omnigateway/dashboard-sdk";import{useMutation as ye,useQuery as ht,useQueryClient as Ft}from"@tanstack/react-query";import{useState as ft}from"react";var yt={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 A(e){return ke.get(e)??{blurb:"",emoji:"❔",consumable:!0}}var ke=new Map(Object.entries(yt)),_t=[...ke].filter(([,e])=>e.consumable).map(([e])=>e),Ie="\uD83E\uDD5A";function $e(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 ce(e,t){return`/api/plugins/${e}/item-sprite/${t}`}var St="incubating";function Ce(e){return ce(e,St)}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 M(e,t){return e??`#${t}`}function D(e,t,o){return`${e??`Species ${t}`}${o?", shiny":""}`}function L(e){return e.replace(/([A-Z])/g," $1").toLowerCase()}function Re(e){if(e.kind==="item")return L(e.item);return e.tier===null?"fresh egg":`fresh egg (${e.tier}+)`}var Ee=[null,"common","uncommon","rare","legendary"],Te=60000,we=60*Te;function O(e,t,o){if(!e)return"egg";if(t===null)return"sleep";let i=o-t;if(i<5*Te)return"working";if(i<we)return"idle";if(i<8*we)return"tired";return"sleep"}import{useState as vt}from"react";import n from"styled-components";var l={xs:"4px",sm:"8px",md:"12px",lg:"20px",xl:"32px"},E="192px",z="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",_=n.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
- `,me=n.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 Lt,useLive as Bt}from"@omnigateway/dashboard-sdk";impor
21
21
  height: 1px;
22
22
  background: var(--rule);
23
23
  }
24
- `,De=n(me)`
24
+ `,Me=n(he)`
25
25
  &::after {
26
26
  content: none;
27
27
  }
28
- `,Ne=n.span`
28
+ `,Be=n.span`
29
29
  flex: 1;
30
30
  height: 1px;
31
31
  background: var(--rule);
32
- `,Pe=n.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 Lt,useLive as Bt}from"@omnigateway/dashboard-sdk";impor
52
52
  outline-offset: 4px;
53
53
  border-radius: 2px;
54
54
  }
55
- `,Ae=n.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 Lt,useLive as Bt}from"@omnigateway/dashboard-sdk";impor
62
62
  @media (prefers-reduced-motion: reduce) {
63
63
  transition: none;
64
64
  }
65
- `,Le=n.span`
65
+ `,_e=n.span`
66
66
  color: var(--ink-faint);
67
67
  letter-spacing: 0.08em;
68
68
  white-space: nowrap;
69
- `,w=n.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
- `,Be=n(w)`
74
+ `,Ge=n(R)`
75
75
  h2 {
76
76
  margin: 0;
77
77
  }
78
- `,x=n.span`
78
+ `,k=n.span`
79
79
  color: var(--ink-dim);
80
- `,G=n(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
- `,Fe=n.p`
91
+ `,Oe=n.p`
92
92
  color: var(--ink-dim);
93
- margin: ${l.xs} 0 ${l.lg};
94
- `,ge=n.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=n.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,47 +109,47 @@ import{definePluginUI as Lt,useLive as Bt}from"@omnigateway/dashboard-sdk";impor
109
109
  text-transform: uppercase;
110
110
  color: var(--ink-dim);
111
111
  white-space: nowrap;
112
- `,Ke=n(w)`
113
- margin: ${l.xs} 0 ${l.sm};
114
- `,V=n(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
- `,q=n.img`
118
+ `,J=n.img`
119
119
  width: ${E};
120
120
  height: ${E};
121
121
  image-rendering: pixelated;
122
- `,Me=n.div`
122
+ `,Ue=n.div`
123
123
  box-sizing: border-box;
124
124
  width: ${E};
125
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
- `,Oe=n.span`
129
+ `,je=n.span`
130
130
  display: inline-flex;
131
131
  align-items: center;
132
132
  justify-content: center;
133
133
  flex: none;
134
134
  width: ${E};
135
135
  height: ${E};
136
- `,_e=n.img`
136
+ `,Ve=n.img`
137
137
  width: 180px;
138
138
  height: 180px;
139
139
  image-rendering: pixelated;
140
- `,Ge=n.div`
140
+ `,We=n.div`
141
141
  box-sizing: border-box;
142
142
  width: ${E};
143
143
  height: ${E};
144
144
  border-radius: 6px;
145
145
  background: var(--warn-wash);
146
146
  border: 2px dashed var(--warn);
147
- `,v=n.button`
147
+ `,I=n.button`
148
148
  background: var(--panel-raised);
149
149
  border: 1px solid var(--rule);
150
150
  border-radius: 6px;
151
151
  color: var(--ink);
152
- padding: ${l.sm} ${l.md};
152
+ padding: ${o.sm} ${o.md};
153
153
  font: inherit;
154
154
  cursor: pointer;
155
155
 
@@ -169,22 +169,22 @@ import{definePluginUI as Lt,useLive as Bt}from"@omnigateway/dashboard-sdk";impor
169
169
  color: var(--ink-faint);
170
170
  cursor: not-allowed;
171
171
  }
172
- `,B=n.span`
173
- font-family: ${z};
172
+ `,K=n.span`
173
+ font-family: ${H};
174
174
  font-variant-numeric: tabular-nums;
175
- `,He=n.div`
175
+ `,qe=n.div`
176
176
  display: flex;
177
177
  gap: 3px;
178
178
  min-width: 240px;
179
179
  max-width: 340px;
180
- `,Ue=n.div`
180
+ `,Ye=n.div`
181
181
  flex: 1;
182
182
  height: 10px;
183
183
  background: var(--panel-sunk);
184
184
  border: 1px solid var(--rule);
185
185
  border-radius: 3px;
186
186
  overflow: hidden;
187
- `,he=n.div`
187
+ `,xe=n.div`
188
188
  height: 100%;
189
189
  background: var(--accent);
190
190
  width: ${(e)=>Math.min(100,Math.max(0,e.$pct))}%;
@@ -193,39 +193,39 @@ import{definePluginUI as Lt,useLive as Bt}from"@omnigateway/dashboard-sdk";impor
193
193
  @media (prefers-reduced-motion: reduce) {
194
194
  transition: none;
195
195
  }
196
- `,je=n.dl`
196
+ `,Je=n.dl`
197
197
  display: flex;
198
198
  flex-wrap: wrap;
199
- gap: ${l.xl};
200
- margin: ${l.lg} 0 0;
201
- padding-top: ${l.lg};
199
+ gap: ${o.xl};
200
+ margin: ${o.lg} 0 0;
201
+ padding-top: ${o.lg};
202
202
  border-top: 1px solid var(--rule);
203
- `,J=n.div`
203
+ `,Q=n.div`
204
204
  display: flex;
205
205
  flex-direction: column;
206
206
  gap: 2px;
207
- `,Q=n.dt`
207
+ `,X=n.dt`
208
208
  font-size: 11px;
209
209
  letter-spacing: 0.08em;
210
210
  text-transform: uppercase;
211
211
  color: var(--ink-faint);
212
- `,Y=n.dd`
212
+ `,Z=n.dd`
213
213
  margin: 0;
214
- font-family: ${z};
214
+ font-family: ${H};
215
215
  font-variant-numeric: tabular-nums;
216
216
  font-size: 18px;
217
217
  color: var(--ink);
218
- `,ze=n.div`
218
+ `,Qe=n.div`
219
219
  display: grid;
220
220
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
221
- gap: ${l.md};
222
- `,Ve=n.button`
221
+ gap: ${o.md};
222
+ `,Xe=n.button`
223
223
  margin: 0;
224
224
  display: flex;
225
225
  flex-direction: column;
226
226
  align-items: center;
227
227
  gap: 2px;
228
- padding: ${l.sm};
228
+ padding: ${o.sm};
229
229
  background: ${(e)=>e.$open?"var(--accent-wash)":"var(--panel-sunk)"};
230
230
  border: 1px solid ${(e)=>e.$open?"var(--accent)":"var(--rule)"};
231
231
  border-radius: 8px;
@@ -240,63 +240,249 @@ import{definePluginUI as Lt,useLive as Bt}from"@omnigateway/dashboard-sdk";impor
240
240
  outline: 2px solid var(--accent);
241
241
  outline-offset: 2px;
242
242
  }
243
- `,Z=n.span`
244
- font-family: ${z};
243
+ `,A=n.span`
244
+ font-family: ${H};
245
245
  font-variant-numeric: tabular-nums;
246
246
  font-size: 0.8em;
247
247
  color: var(--ink-faint);
248
- `,qe=n.h3`
248
+ `,Ze=n.h3`
249
249
  display: flex;
250
250
  align-items: baseline;
251
- gap: ${l.sm};
252
- `,Je=n(w)`
253
- margin: 0 0 ${l.md};
254
- `,Qe=n.div`
255
- grid-column: 1 / -1;
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`
256
294
  display: flex;
257
- gap: ${l.lg};
258
- padding: ${l.md};
259
- background: var(--panel-sunk);
260
- border: 1px solid var(--rule);
261
- border-radius: 8px;
262
- `,Ye=n.div`
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`
263
373
  display: flex;
264
374
  flex-direction: column;
265
375
  align-items: flex-start;
266
- gap: ${l.sm};
376
+ gap: ${o.sm};
267
377
  min-width: 0;
268
- `,Ze=n.div`
378
+ `,st=n.div`
269
379
  display: flex;
270
- align-items: center;
271
- gap: ${l.sm};
380
+ align-items: stretch;
272
381
  flex-wrap: wrap;
273
- `,We=n.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`
274
390
  margin: 0;
275
391
  display: flex;
276
392
  flex-direction: column;
277
393
  align-items: center;
278
- 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;
279
400
 
280
401
  img {
281
402
  width: 48px;
282
403
  height: 48px;
283
404
  image-rendering: pixelated;
284
405
  }
285
- `,W=n.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`
286
415
  color: var(--ink-dim);
287
416
  font-size: 11px;
288
417
  text-align: center;
289
418
  overflow-wrap: anywhere;
290
- `,Xe=n.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`
291
477
  display: grid;
292
478
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
293
- gap: ${l.md};
294
- `,et=n.button`
479
+ gap: ${o.md};
480
+ `,ft=n.button`
295
481
  display: flex;
296
482
  flex-direction: column;
297
483
  align-items: center;
298
- gap: ${l.sm};
299
- padding: ${l.md};
484
+ gap: ${o.sm};
485
+ padding: ${o.md};
300
486
  background: var(--panel-raised);
301
487
  border: 1px solid var(--rule);
302
488
  border-radius: 8px;
@@ -312,42 +498,42 @@ import{definePluginUI as Lt,useLive as Bt}from"@omnigateway/dashboard-sdk";impor
312
498
  outline: 2px solid var(--accent);
313
499
  outline-offset: 2px;
314
500
  }
315
- `,X=n.span`
316
- font-family: ${z};
501
+ `,te=n.span`
502
+ font-family: ${H};
317
503
  font-size: 12px;
318
504
  color: var(--ink-dim);
319
505
  overflow-wrap: anywhere;
320
- `,ee=n.div`
506
+ `,ne=n.div`
321
507
  display: grid;
322
508
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
323
- gap: ${l.md};
324
- `,te=n.div`
509
+ gap: ${o.md};
510
+ `,oe=n.div`
325
511
  display: flex;
326
512
  flex-direction: column;
327
- gap: ${l.sm};
328
- padding: ${l.md};
513
+ gap: ${o.sm};
514
+ padding: ${o.md};
329
515
  background: var(--panel-sunk);
330
516
  border: 1px solid var(--rule);
331
517
  border-radius: 8px;
332
- `,ne=n.div`
518
+ `,re=n.div`
333
519
  display: flex;
334
520
  align-items: center;
335
- gap: ${l.sm};
336
- `,oe=n.span`
521
+ gap: ${o.sm};
522
+ `,ie=n.span`
337
523
  flex: 1;
338
524
  overflow-wrap: anywhere;
339
- `,re=n.p`
525
+ `,ae=n.p`
340
526
  margin: 0;
341
527
  color: var(--ink-dim);
342
528
  font-size: 12px;
343
529
  line-height: 1.45;
344
- `,ie=n.div`
530
+ `,se=n.div`
345
531
  display: flex;
346
532
  align-items: center;
347
533
  justify-content: flex-end;
348
- gap: ${l.sm};
534
+ gap: ${o.sm};
349
535
  margin-top: auto;
350
- `,tt=n.span`
536
+ `,xt=n.span`
351
537
  display: inline-flex;
352
538
  align-items: center;
353
539
  justify-content: center;
@@ -356,8 +542,8 @@ import{definePluginUI as Lt,useLive as Bt}from"@omnigateway/dashboard-sdk";impor
356
542
  height: 32px;
357
543
  font-size: 20px;
358
544
  line-height: 1;
359
- `,nt=n.img`
545
+ `,bt=n.img`
360
546
  width: 32px;
361
547
  height: 32px;
362
548
  image-rendering: pixelated;
363
- `;import{jsx as ot}from"react/jsx-runtime";function ae({item:e,emoji:t,pluginId:o}){let[i,d]=vt(!1);return ot(tt,{"aria-hidden":"true",children:i?t:ot(nt,{alt:"",onError:()=>d(!0),src:ce(o,e)})})}import{jsx as N,jsxs as se}from"react/jsx-runtime";function rt({inventory:e,onUse:t,pending:o,pluginId:i}){let d=Object.entries(e).filter(([,p])=>p>0);if(d.length===0)return N(x,{children:"Nothing in the bag."});return N(ee,{children:d.map(([p,r])=>{let a=A(p);return se(te,{children:[se(ne,{children:[N(ae,{emoji:a.emoji,item:p,pluginId:i}),N(oe,{children:L(p)}),se(B,{children:["×",r]})]}),N(re,{children:a.blurb}),N(ie,{children:a.consumable?se(v,{disabled:o,onClick:()=>t(p),type:"button",children:["Use ",L(p)]}):N(x,{children:"held"})})]},p)})})}import{Fragment as kt,useState as it}from"react";import{jsx as y,jsxs as I,Fragment as $t}from"react/jsx-runtime";function at({entries:e,pluginId:t}){let[o,i]=it(null),[d,p]=it(null);if(e.length===0)return y(x,{children:"Nothing graduated yet."});let r=o===null?e:e.filter((a)=>a.rarity===o);return I($t,{children:[y(Je,{children:Ee.map((a)=>y(v,{"aria-pressed":o===a,onClick:()=>{i(a),p(null)},type:"button",children:a??"all"},a??"all"))}),r.length===0?I(x,{children:["No ",o," graduates yet."]}):y(ze,{children:r.map((a)=>{let s=d===a.id,k=`dex-detail-${a.id}`;return I(kt,{children:[I(Ve,{$open:s,"aria-controls":k,"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"}}),I(Z,{children:["#",a.finalId]}),a.name===null?null:y(W,{children:a.name}),a.nature===null?null:y(W,{children:a.nature})]}),s?y(It,{entry:a,id:k,pluginId:t}):null]},a.id)})})]})}function It({entry:e,id:t,pluginId:o}){return I(Qe,{id:t,children:[y("img",{alt:D(e.name,e.finalId,e.isShiny),src:R(o,e.finalId,e.isShiny),style:{width:"96px",height:"96px",imageRendering:"pixelated"}}),I(Ye,{children:[y("strong",{children:M(e.name,e.finalId)}),I(w,{children:[y(b,{children:e.rarity}),e.isShiny?y(V,{children:"✦ shiny"}):null,e.nature===null?null:y(b,{children:e.nature})]}),y(Ze,{children:e.chainOrder.map((i,d)=>I(We,{children:[y("img",{alt:D(null,i,!1),src:R(o,i,!1)}),y(W,{children:i===e.finalId?M(e.name,i):`#${i}`})]},`${i}-${d}`))}),I(x,{children:["caught ",new Date(e.caughtAt).toLocaleDateString()]})]})]})}import{useState as wt}from"react";import{jsx as fe}from"react/jsx-runtime";function le({pluginId:e}){let[t,o]=wt(!1);if(t)return fe(Me,{"aria-label":st,role:"img"});return fe(Oe,{children:fe(_e,{alt:st,onError:()=>o(!0),src:Ce(e)})})}var st="An egg, not yet hatched";import{jsx as xe,jsxs as Ct}from"react/jsx-runtime";function be({stages:e,stageIndex:t,progress:o,threshold:i,label:d,valueText:p}){let r=o/Math.max(1,i)*100;return xe(He,{"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)=>Ct(Ue,{children:[s<t?xe(he,{$pct:100}):null,s===t?xe(he,{$pct:r}):null]},s))})}function lt(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 F}from"react/jsx-runtime";function pt({view:e,activity:t,pluginId:o,onRelease:i,releasing:d}){let p=e.state;if(p===null)return null;let{active:r}=p,a=r===null?null:r.plannedPath[r.stageIndex]??null;return m(F,{children:[m(w,{children:[a===null?c(le,{pluginId:o}):c(q,{alt:D(e.name,a,r?.isShiny===!0),src:R(o,a,r?.isShiny===!0)}),m("div",{children:[c(qe,{children:a===null?"Egg":m(F,{children:[m(Z,{children:["#",a]}),e.name===null?null:c("span",{children:e.name})]})}),m(Ke,{children:[r===null?p.eggTier===null?null:m(b,{children:[p.eggTier,"+ guaranteed"]}):m(F,{children:[c(b,{children:r.rarity}),r.isShiny?m(V,{children:[c("span",{"aria-hidden":"true",children:"✦"}),"shiny"]}):null,c(b,{children:r.nature}),r.dittoDisguise===null||r.dittoRevealed?null:c(b,{children:"?"}),r.everstone?c(b,{children:"everstone"}):null,r.soothe?c(b,{children:"soothe bell"}):null]}),c(b,{"aria-label":`Activity: ${t}`,role:"status",children:t})]}),r===null?m(F,{children:[c(be,{label:"Incubation",progress:e.progress,stageIndex:0,stages:1,threshold:e.nextThreshold,valueText:`${h(e.progress)} of ${h(e.nextThreshold)} tokens incubated`}),m(G,{children:[h(e.progress)," / ",h(e.nextThreshold)," tokens incubated"]})]}):m(F,{children:[c(be,{label:"Growth to the next evolution",progress:e.progress,stageIndex:r.stageIndex,stages:r.plannedPath.length,threshold:e.nextThreshold,valueText:lt(r.plannedPath.length,r.stageIndex,e.progress,e.nextThreshold)}),m(G,{children:["Stage ",r.stageIndex+1," of ",r.plannedPath.length]}),r.everstone?m(F,{children:[m(G,{children:["Held at this stage · ",h(e.progress)," banked"]}),c(v,{disabled:d,onClick:i,type:"button",children:"Release"})]}):m(G,{children:[h(e.progress)," / ",h(e.nextThreshold)," to the next stage"]})]})]})]}),m(je,{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 Rt}from"react";import{jsx as S,jsxs as pe}from"react/jsx-runtime";function dt({keys:e,onPick:t,pluginId:o,rosterFailed:i}){let[d,p]=Rt("");return pe(_,{children:[S("h2",{children:"Companion"}),S(Fe,{children:"Each API key raises its own Pokémon on the tokens it spends. Pick a key."}),e.length>0?S(Xe,{children:e.map((r)=>S(Et,{entry:r,onPick:t,pluginId:o},r.apiKeyId))}):S(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."}),S(me,{children:"Or by key id"}),S("form",{onSubmit:(r)=>{r.preventDefault();let a=d.trim();if(a!=="")t(a)},children:pe(w,{children:[S("input",{"aria-label":"API key id",onChange:(r)=>p(r.target.value),placeholder:"key id",value:d}),S(v,{type:"submit",children:"Show"})]})})]})}function Et({entry:e,onPick:t,pluginId:o}){let i=O(e.speciesId!==null,e.lastCreditAt,Date.now());return pe(et,{onClick:()=>t(e.apiKeyId),type:"button",children:[e.unreadable?S(Ge,{"aria-label":"This key's save could not be read",role:"img"}):e.speciesId===null?S(le,{pluginId:o}):S(q,{alt:D(e.name,e.speciesId,e.isShiny),src:R(o,e.speciesId,e.isShiny)}),S("strong",{children:e.unreadable?"Save unreadable":e.speciesId===null?"Egg":M(e.name,e.speciesId)}),e.rarity===null?null:S(b,{children:e.rarity}),S(X,{children:e.apiKeyId}),pe(x,{children:[S(B,{children:h(e.tokensTotal)}),e.unreadable?null:` · ${i}`]})]})}import{useId as Tt,useState as Dt}from"react";import{jsx as H,jsxs as ut,Fragment as Pt}from"react/jsx-runtime";var K={shop:!0,bag:!0,dex:!0},ct=(e)=>`plugin:${e}:sections`;function Nt(e){try{let t=globalThis.localStorage?.getItem(ct(e));if(t===null||t===void 0)return K;let o=JSON.parse(t);if(typeof o!=="object"||o===null)return K;let i=o;return{shop:typeof i.shop==="boolean"?i.shop:K.shop,bag:typeof i.bag==="boolean"?i.bag:K.bag,dex:typeof i.dex==="boolean"?i.dex:K.dex}}catch{return K}}function mt(e){let[t,o]=Dt(()=>Nt(e));return{open:t,toggle:(d)=>{o((p)=>{let r={...p,[d]:!p[d]};try{globalThis.localStorage?.setItem(ct(e),JSON.stringify(r))}catch{}return r})}}}function de({title:e,count:t,open:o,onToggle:i,children:d}){let p=Tt();return ut(Pt,{children:[H(De,{children:ut(Pe,{"aria-controls":p,"aria-expanded":o,onClick:i,type:"button",children:[H(Ae,{$open:o,children:"▶"}),e,H(Ne,{}),H(Le,{children:t})]})}),o?H("div",{id:p,children:d}):null]})}import{jsx as P,jsxs as ue}from"react/jsx-runtime";function gt({offers:e,wallet:t,onBuy:o,pending:i,inventory:d,hasCompanion:p,pluginId:r}){return P(ee,{children:e.map((a)=>{let{entry:s,price:k}=a,C=At(s,d),u=s.kind==="egg"&&!p,T=s.kind==="item"?L(s.item):"fresh egg";return ue(te,{children:[ue(ne,{children:[P(ae,{emoji:s.kind==="item"?A(s.item).emoji:Ie,item:s.kind==="item"?s.item:"egg",pluginId:r}),P(oe,{children:T}),C?P(x,{children:"owned"}):P(B,{children:h(k)})]}),s.kind==="egg"&&s.tier!==null?ue(b,{children:[s.tier,"+"]}):null,P(re,{children:s.kind==="item"?A(s.item).blurb:$e(s.tier)}),P(ie,{children:ue(v,{disabled:C||u||t<k||i,onClick:()=>o(s),type:"button",children:["Buy ",Re(s)]})})]},s.kind==="item"?`item:${s.item}`:`egg:${s.tier??""}`)})})}function At(e,t){if(e.kind!=="item")return!1;return!A(e.item).consumable&&(t[e.item]??0)>0}import{jsx as f,jsxs as Se,Fragment as Ot}from"react/jsx-runtime";var xt=1e4;function Kt({pluginId:e,api:t}){let[o,i]=ft({at:"start"}),d=Ft(),{cadence:p}=Bt(),r=ht({queryKey:["roster"],queryFn:()=>t.get("keys"),refetchInterval:p(xt)}),a=r.data?.keys??[];if(o.at==="start"&&!r.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,k=ht({queryKey:["companion",s],queryFn:()=>t.get(`keys/${s}`),enabled:s!==null,refetchInterval:p(xt)}),[C,u]=ft(null),T=()=>{d.invalidateQueries({queryKey:["companion",s]}),d.invalidateQueries({queryKey:["roster"]})},U=ye({mutationFn:(g)=>t.post(`keys/${s}/purchase`,g),onMutate:()=>u(null),onError:(g)=>u(g instanceof Error?g.message:"the purchase was refused"),onSuccess:T}),j=ye({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:T}),ve=ye({mutationFn:()=>t.post(`keys/${s}/unpin`),onMutate:()=>u(null),onError:(g)=>u(g instanceof Error?g.message:"the companion could not be released"),onSuccess:T});if(r.isPending)return f(_,{children:"Loading…"});if(s===null)return f(dt,{keys:a,onPick:(g)=>i({at:"key",apiKeyId:g}),pluginId:e,rosterFailed:r.isError});return Se(_,{children:[Se(Be,{children:[f("h2",{children:"Companion"}),f(X,{children:s}),f(v,{onClick:()=>i({at:"roster"}),type:"button",children:"All keys"})]}),f(Mt,{buy:U.mutate,buying:U.isPending,keyId:s,onRelease:()=>ve.mutate(),onUse:j.mutate,pluginId:e,query:k,refusal:C,releasing:ve.isPending,using:j.isPending})]})}function Mt({query:e,pluginId:t,buy:o,onUse:i,onRelease:d,buying:p,using:r,releasing:a,refusal:s}){let{open:k,toggle:C}=mt(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(ge,{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 T=O(u.state.active!==null,u.lastCreditAt,Date.now()),U=Object.values(u.state.inventory).filter((j)=>j>0).length;return Se(Ot,{children:[f(pt,{activity:T,onRelease:d,pluginId:t,releasing:a,view:u}),f(de,{count:bt(u.shop.length,"offer"),onToggle:()=>C("shop"),open:k.shop,title:"Shop",children:f(gt,{hasCompanion:u.state.active!==null,inventory:u.state.inventory,offers:u.shop,onBuy:o,pending:p,pluginId:t,wallet:u.wallet})}),f(de,{count:`${U} held`,onToggle:()=>C("bag"),open:k.bag,title:"Bag",children:f(rt,{inventory:u.state.inventory,onUse:i,pending:r,pluginId:t})}),s===null?null:f(ge,{role:"alert",children:s}),f(de,{count:bt(u.dex.length,"graduate"),onToggle:()=>C("dex"),open:k.dex,title:"Pokédex",children:f(at,{entries:u.dex,pluginId:t})})]})}function bt(e,t){return`${e} ${t}${e===1?"":"s"}`}var Yn=Lt({mount:Kt});export{O as activityOf,Yn 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};