@omnigateway/pokemon 1.0.2 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -70,8 +70,7 @@ from one readable file. It constrains honest code and not hostile code.
70
70
  The plugin degrades rather than failing when a capability is absent. With no
71
71
  `net`, an incubating egg holds its progress instead of losing it, and both
72
72
  sprite routes answer `503` — the panel then draws each item as an emoji, which
73
- is the same thing it draws before the cache has filled and the same thing it
74
- draws for `mint`, whose icon does not exist upstream at all.
73
+ is the same thing it draws before the cache has filled.
75
74
 
76
75
  ## Nintendo and Game Freak intellectual property
77
76
 
@@ -108,6 +107,27 @@ is deliberate: a plugin developed inside the monorepo can reach packages an
108
107
  installed plugin cannot, and a build that only succeeds there proves nothing
109
108
  about one that has to run anywhere else.
110
109
 
110
+ `@omnigateway/dashboard-sdk` is an **external** of the UI build, alongside React
111
+ and friends — the console serves one copy of each through its import map.
112
+ (`@omnigateway/plugin-api` is not: it is a runtime dependency of the *server*
113
+ half and is bundled into it, and the panel never imports it.)
114
+
115
+ The SDK is the easiest external to forget, because it is the one package here
116
+ that is obviously ours, and forgetting it fails silently: the SDK holds the
117
+ console's LIVE switch in a React context, so a bundled copy is a second context,
118
+ and the panel stops refreshing without an error anywhere.
119
+ `test/package.test.ts` checks the built bundle still imports it and carries no
120
+ `createContext` of its own.
121
+
122
+ ## The console's LIVE switch
123
+
124
+ The panel polls, because growth arrives from requests it cannot hear about. It
125
+ polls on the console's cadence rather than its own: the chassis bar's LIVE
126
+ control pauses every screen at once, this panel included, and there is
127
+ deliberately no per-panel refresh setting. Paused means it stops refetching, not
128
+ that it stops working — an operator who pauses still sees the companion they
129
+ opened.
130
+
111
131
  ## Licence
112
132
 
113
133
  MIT. See [LICENSE](LICENSE). The licence covers this plugin's code and not the
package/omni-plugin.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "id": "pokemon",
3
3
  "name": "Pok\u00e9mon Companion",
4
- "version": "1.0.2",
4
+ "version": "1.1.1",
5
5
  "api": 1,
6
- "sdk": "^0.1.0",
6
+ "sdk": "^0.1.1",
7
7
  "server": "server/index.js",
8
8
  "ui": "ui/index.js",
9
9
  "nav": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnigateway/pokemon",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "description": "A Pokémon companion for OmniGateway. Each gateway key raises one that hatches, evolves, and graduates into a Pokédex on the tokens that key spends.",
5
5
  "license": "MIT",
6
6
  "author": "Harismawan <mail@harismawan.com>",
package/server/index.js CHANGED
@@ -60,7 +60,9 @@ var ITEM_SPRITE_FILES = {
60
60
  repel: "repel",
61
61
  incense: "luck-incense",
62
62
  lure: "honey",
63
- egg: "lucky-egg"
63
+ mint: "mental-herb",
64
+ egg: "lucky-egg",
65
+ incubating: "mystery-egg"
64
66
  };
65
67
  var ITEM_SPRITE_NAMES = new Map(Object.entries(ITEM_SPRITE_FILES));
66
68
  var FRESH_EGG_BASE_PRICE = 1e9;
package/ui/index.js CHANGED
@@ -1,10 +1,10 @@
1
- function ue(e){return e}import{useMutation as xe,useQuery as at,useQueryClient as vt}from"@tanstack/react-query";import{useState as st}from"react";var pt={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 N(e){return ye.get(e)??{blurb:"",emoji:"❔",consumable:!0}}var ye=new Map(Object.entries(pt)),Gt=[...ye].filter(([,e])=>e.consumable).map(([e])=>e),ke="\uD83E\uDD5A";function Se(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,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 R(e,t){return e??`#${t}`}function P(e,t,o){return`${e??`Species ${t}`}${o?", shiny":""}`}function L(e){return e.replace(/([A-Z])/g," $1").toLowerCase()}function we(e){if(e.kind==="item")return L(e.item);return e.tier===null?"fresh egg":`fresh egg (${e.tier}+)`}var $e=[null,"common","uncommon","rare","legendary"],Ce=60000,ve=60*Ce;function _(e,t,o){if(!e)return"egg";if(t===null)return"sleep";let a=o-t;if(a<5*Ce)return"working";if(a<ve)return"idle";if(a<8*ve)return"tired";return"sleep"}import{useState as ut}from"react";import i 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",M=i.section`
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`
2
2
  background: var(--panel);
3
3
  border: 1px solid var(--rule);
4
4
  border-radius: 8px;
5
5
  padding: ${l.lg};
6
6
  color: var(--ink);
7
- `,ce=i.h3`
7
+ `,me=n.h3`
8
8
  display: flex;
9
9
  align-items: center;
10
10
  gap: ${l.md};
@@ -21,15 +21,15 @@ function ue(e){return e}import{useMutation as xe,useQuery as at,useQueryClient a
21
21
  height: 1px;
22
22
  background: var(--rule);
23
23
  }
24
- `,Te=i(ce)`
24
+ `,De=n(me)`
25
25
  &::after {
26
26
  content: none;
27
27
  }
28
- `,Re=i.span`
28
+ `,Ne=n.span`
29
29
  flex: 1;
30
30
  height: 1px;
31
31
  background: var(--rule);
32
- `,Pe=i.button`
32
+ `,Pe=n.button`
33
33
  display: flex;
34
34
  align-items: center;
35
35
  gap: ${l.sm};
@@ -52,7 +52,7 @@ function ue(e){return e}import{useMutation as xe,useQuery as at,useQueryClient a
52
52
  outline-offset: 4px;
53
53
  border-radius: 2px;
54
54
  }
55
- `,Ae=i.span`
55
+ `,Ae=n.span`
56
56
  display: inline-block;
57
57
  font-size: 9px;
58
58
  line-height: 1;
@@ -62,22 +62,22 @@ function ue(e){return e}import{useMutation as xe,useQuery as at,useQueryClient a
62
62
  @media (prefers-reduced-motion: reduce) {
63
63
  transition: none;
64
64
  }
65
- `,Ee=i.span`
65
+ `,Le=n.span`
66
66
  color: var(--ink-faint);
67
67
  letter-spacing: 0.08em;
68
68
  white-space: nowrap;
69
- `,w=i.div`
69
+ `,w=n.div`
70
70
  display: flex;
71
71
  gap: ${l.md};
72
72
  align-items: center;
73
73
  flex-wrap: wrap;
74
- `,De=i(w)`
74
+ `,Be=n(w)`
75
75
  h2 {
76
76
  margin: 0;
77
77
  }
78
- `,x=i.span`
78
+ `,x=n.span`
79
79
  color: var(--ink-dim);
80
- `,F=i(x)`
80
+ `,G=n(x)`
81
81
  display: block;
82
82
  margin-top: ${l.sm};
83
83
 
@@ -88,16 +88,16 @@ function ue(e){return e}import{useMutation as xe,useQuery as at,useQueryClient a
88
88
  & + & {
89
89
  margin-top: ${l.xs};
90
90
  }
91
- `,Ne=i.p`
91
+ `,Fe=n.p`
92
92
  color: var(--ink-dim);
93
93
  margin: ${l.xs} 0 ${l.lg};
94
- `,ge=i.p`
94
+ `,ge=n.p`
95
95
  color: var(--warn);
96
96
  background: var(--warn-wash);
97
97
  border-radius: 6px;
98
98
  padding: ${l.md};
99
99
  margin: ${l.md} 0 0;
100
- `,b=i.span`
100
+ `,b=n.span`
101
101
  display: inline-flex;
102
102
  align-items: center;
103
103
  gap: ${l.xs};
@@ -109,31 +109,42 @@ function ue(e){return e}import{useMutation as xe,useQuery as at,useQueryClient a
109
109
  text-transform: uppercase;
110
110
  color: var(--ink-dim);
111
111
  white-space: nowrap;
112
- `,Le=i(w)`
112
+ `,Ke=n(w)`
113
113
  margin: ${l.xs} 0 ${l.sm};
114
- `,j=i(b)`
114
+ `,V=n(b)`
115
115
  border-color: var(--rule-strong);
116
116
  color: var(--ink);
117
117
  font-weight: 600;
118
- `,z=i.img`
119
- width: ${B};
120
- height: ${B};
118
+ `,q=n.img`
119
+ width: ${E};
120
+ height: ${E};
121
121
  image-rendering: pixelated;
122
- `,q=i.div`
122
+ `,Me=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=i.div`
129
+ `,Oe=n.span`
130
+ display: inline-flex;
131
+ align-items: center;
132
+ justify-content: center;
133
+ flex: none;
134
+ width: ${E};
135
+ height: ${E};
136
+ `,_e=n.img`
137
+ width: 180px;
138
+ height: 180px;
139
+ image-rendering: pixelated;
140
+ `,Ge=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
- `,v=i.button`
147
+ `,v=n.button`
137
148
  background: var(--panel-raised);
138
149
  border: 1px solid var(--rule);
139
150
  border-radius: 6px;
@@ -158,22 +169,22 @@ function ue(e){return e}import{useMutation as xe,useQuery as at,useQueryClient a
158
169
  color: var(--ink-faint);
159
170
  cursor: not-allowed;
160
171
  }
161
- `,O=i.span`
162
- font-family: ${de};
172
+ `,B=n.span`
173
+ font-family: ${z};
163
174
  font-variant-numeric: tabular-nums;
164
- `,Oe=i.div`
175
+ `,He=n.div`
165
176
  display: flex;
166
177
  gap: 3px;
167
178
  min-width: 240px;
168
179
  max-width: 340px;
169
- `,Ke=i.div`
180
+ `,Ue=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=i.div`
187
+ `,he=n.div`
177
188
  height: 100%;
178
189
  background: var(--accent);
179
190
  width: ${(e)=>Math.min(100,Math.max(0,e.$pct))}%;
@@ -182,54 +193,65 @@ function ue(e){return e}import{useMutation as xe,useQuery as at,useQueryClient a
182
193
  @media (prefers-reduced-motion: reduce) {
183
194
  transition: none;
184
195
  }
185
- `,_e=i.dl`
196
+ `,je=n.dl`
186
197
  display: flex;
187
198
  flex-wrap: wrap;
188
199
  gap: ${l.xl};
189
200
  margin: ${l.lg} 0 0;
190
201
  padding-top: ${l.lg};
191
202
  border-top: 1px solid var(--rule);
192
- `,J=i.div`
203
+ `,J=n.div`
193
204
  display: flex;
194
205
  flex-direction: column;
195
206
  gap: 2px;
196
- `,Q=i.dt`
207
+ `,Q=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
- `,W=i.dd`
212
+ `,Y=n.dd`
202
213
  margin: 0;
203
- font-family: ${de};
214
+ font-family: ${z};
204
215
  font-variant-numeric: tabular-nums;
205
216
  font-size: 18px;
206
217
  color: var(--ink);
207
- `,Me=i.div`
218
+ `,ze=n.div`
208
219
  display: grid;
209
220
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
210
221
  gap: ${l.md};
211
- `,Fe=i.button`
222
+ `,Ve=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: ${l.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
- `,Ue=i.div`
243
+ `,Z=n.span`
244
+ font-family: ${z};
245
+ font-variant-numeric: tabular-nums;
246
+ font-size: 0.8em;
247
+ color: var(--ink-faint);
248
+ `,qe=n.h3`
249
+ display: flex;
250
+ align-items: baseline;
251
+ gap: ${l.sm};
252
+ `,Je=n(w)`
253
+ margin: 0 0 ${l.md};
254
+ `,Qe=n.div`
233
255
  grid-column: 1 / -1;
234
256
  display: flex;
235
257
  gap: ${l.lg};
@@ -237,18 +259,18 @@ function ue(e){return e}import{useMutation as xe,useQuery as at,useQueryClient a
237
259
  background: var(--panel-sunk);
238
260
  border: 1px solid var(--rule);
239
261
  border-radius: 8px;
240
- `,Ge=i.div`
262
+ `,Ye=n.div`
241
263
  display: flex;
242
264
  flex-direction: column;
243
265
  align-items: flex-start;
244
266
  gap: ${l.sm};
245
267
  min-width: 0;
246
- `,He=i.div`
268
+ `,Ze=n.div`
247
269
  display: flex;
248
270
  align-items: center;
249
271
  gap: ${l.sm};
250
272
  flex-wrap: wrap;
251
- `,Ve=i.figure`
273
+ `,We=n.figure`
252
274
  margin: 0;
253
275
  display: flex;
254
276
  flex-direction: column;
@@ -260,16 +282,16 @@ function ue(e){return e}import{useMutation as xe,useQuery as at,useQueryClient a
260
282
  height: 48px;
261
283
  image-rendering: pixelated;
262
284
  }
263
- `,Y=i.figcaption`
285
+ `,W=n.figcaption`
264
286
  color: var(--ink-dim);
265
287
  font-size: 11px;
266
288
  text-align: center;
267
289
  overflow-wrap: anywhere;
268
- `,je=i.div`
290
+ `,Xe=n.div`
269
291
  display: grid;
270
292
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
271
293
  gap: ${l.md};
272
- `,ze=i.button`
294
+ `,et=n.button`
273
295
  display: flex;
274
296
  flex-direction: column;
275
297
  align-items: center;
@@ -290,16 +312,16 @@ function ue(e){return e}import{useMutation as xe,useQuery as at,useQueryClient a
290
312
  outline: 2px solid var(--accent);
291
313
  outline-offset: 2px;
292
314
  }
293
- `,Z=i.span`
294
- font-family: ${de};
315
+ `,X=n.span`
316
+ font-family: ${z};
295
317
  font-size: 12px;
296
318
  color: var(--ink-dim);
297
319
  overflow-wrap: anywhere;
298
- `,X=i.div`
320
+ `,ee=n.div`
299
321
  display: grid;
300
322
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
301
323
  gap: ${l.md};
302
- `,ee=i.div`
324
+ `,te=n.div`
303
325
  display: flex;
304
326
  flex-direction: column;
305
327
  gap: ${l.sm};
@@ -307,25 +329,25 @@ function ue(e){return e}import{useMutation as xe,useQuery as at,useQueryClient a
307
329
  background: var(--panel-sunk);
308
330
  border: 1px solid var(--rule);
309
331
  border-radius: 8px;
310
- `,te=i.div`
332
+ `,ne=n.div`
311
333
  display: flex;
312
334
  align-items: center;
313
335
  gap: ${l.sm};
314
- `,ne=i.span`
336
+ `,oe=n.span`
315
337
  flex: 1;
316
338
  overflow-wrap: anywhere;
317
- `,oe=i.p`
339
+ `,re=n.p`
318
340
  margin: 0;
319
341
  color: var(--ink-dim);
320
342
  font-size: 12px;
321
343
  line-height: 1.45;
322
- `,re=i.div`
344
+ `,ie=n.div`
323
345
  display: flex;
324
346
  align-items: center;
325
347
  justify-content: flex-end;
326
348
  gap: ${l.sm};
327
349
  margin-top: auto;
328
- `,qe=i.span`
350
+ `,tt=n.span`
329
351
  display: inline-flex;
330
352
  align-items: center;
331
353
  justify-content: center;
@@ -334,8 +356,8 @@ function ue(e){return e}import{useMutation as xe,useQuery as at,useQueryClient a
334
356
  height: 32px;
335
357
  font-size: 20px;
336
358
  line-height: 1;
337
- `,Je=i.img`
359
+ `,nt=n.img`
338
360
  width: 32px;
339
361
  height: 32px;
340
362
  image-rendering: pixelated;
341
- `;import{jsx as Qe}from"react/jsx-runtime";function ie({item:e,emoji:t,pluginId:o}){let[a,u]=ut(!1);return Qe(qe,{"aria-hidden":"true",children:a?t:Qe(Je,{alt:"",onError:()=>u(!0),src:Ie(o,e)})})}import{jsx as A,jsxs as ae}from"react/jsx-runtime";function We({inventory:e,onUse:t,pending:o,pluginId:a}){let u=Object.entries(e).filter(([,s])=>s>0);if(u.length===0)return A(x,{children:"Nothing in the bag."});return A(X,{children:u.map(([s,r])=>{let n=N(s);return ae(ee,{children:[ae(te,{children:[A(ie,{emoji:n.emoji,item:s,pluginId:a}),A(ne,{children:L(s)}),ae(O,{children:["×",r]})]}),A(oe,{children:n.blurb}),A(re,{children:n.consumable?ae(v,{disabled:o,onClick:()=>t(s),type:"button",children:["Use ",L(s)]}):A(x,{children:"held"})})]},s)})})}import{Fragment as dt,useState as Ye}from"react";import{jsx as y,jsxs as C,Fragment as gt}from"react/jsx-runtime";function Ze({entries:e,pluginId:t}){let[o,a]=Ye(null),[u,s]=Ye(null);if(e.length===0)return y(x,{children:"Nothing graduated yet."});let r=o===null?e:e.filter((n)=>n.rarity===o);return C(gt,{children:[y(w,{children:$e.map((n)=>y(v,{"aria-pressed":o===n,onClick:()=>{a(n),s(null)},type:"button",children:n??"all"},n??"all"))}),r.length===0?C(x,{children:["No ",o," graduates yet."]}):y(Me,{children:r.map((n)=>{let p=u===n.id,I=`dex-detail-${n.id}`;return C(dt,{children:[C(Fe,{$open:p,"aria-controls":I,"aria-expanded":p,onClick:()=>s(p?null:n.id),type:"button",children:[y("img",{alt:`${n.rarity}${n.isShiny?" shiny":""} ${n.name??`species ${n.finalId}`}`,src:T(t,n.finalId,n.isShiny),style:{width:"64px",height:"64px",imageRendering:"pixelated"}}),y(Y,{children:R(n.name,n.finalId)}),n.nature===null?null:y(Y,{children:n.nature})]}),p?y(ct,{entry:n,id:I,pluginId:t}):null]},n.id)})})]})}function ct({entry:e,id:t,pluginId:o}){return C(Ue,{id:t,children:[y("img",{alt:P(e.name,e.finalId,e.isShiny),src:T(o,e.finalId,e.isShiny),style:{width:"96px",height:"96px",imageRendering:"pixelated"}}),C(Ge,{children:[y("strong",{children:R(e.name,e.finalId)}),C(w,{children:[y(b,{children:e.rarity}),e.isShiny?y(j,{children:"✦ shiny"}):null,e.nature===null?null:y(b,{children:e.nature})]}),y(He,{children:e.chainOrder.map((a,u)=>C(Ve,{children:[y("img",{alt:P(null,a,!1),src:T(o,a,!1)}),y(Y,{children:a===e.finalId?R(e.name,a):`#${a}`})]},`${a}-${u}`))}),C(x,{children:["caught ",new Date(e.caughtAt).toLocaleDateString()]})]})]})}import{jsx as he,jsxs as mt}from"react/jsx-runtime";function fe({stages:e,stageIndex:t,progress:o,threshold:a,label:u,valueText:s}){let r=o/Math.max(1,a)*100;return he(Oe,{"aria-label":u,"aria-valuemax":a,"aria-valuemin":0,"aria-valuenow":o,"aria-valuetext":s,role:"progressbar",children:Array.from({length:Math.max(1,e)},(n,p)=>mt(Ke,{children:[p<t?he(me,{$pct:100}):null,p===t?he(me,{$pct:r}):null]},p))})}function Xe(e,t,o,a){return`stage ${t+1} of ${e}, ${h(o)} of ${h(a)} tokens`}import{jsx as c,jsxs as g,Fragment as U}from"react/jsx-runtime";function et({view:e,activity:t,pluginId:o,onRelease:a,releasing:u}){let s=e.state;if(s===null)return null;let{active:r}=s,n=r===null?null:r.plannedPath[r.stageIndex]??null;return g(U,{children:[g(w,{children:[n===null?c(q,{"aria-label":"An egg, not yet hatched",role:"img"}):c(z,{alt:P(e.name,n,r?.isShiny===!0),src:T(o,n,r?.isShiny===!0)}),g("div",{children:[c("h3",{children:n===null?"Egg":R(e.name,n)}),g(Le,{children:[r===null?s.eggTier===null?null:g(b,{children:[s.eggTier,"+ guaranteed"]}):g(U,{children:[c(b,{children:r.rarity}),r.isShiny?g(j,{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?g(U,{children:[c(fe,{label:"Incubation",progress:e.progress,stageIndex:0,stages:1,threshold:e.nextThreshold,valueText:`${h(e.progress)} of ${h(e.nextThreshold)} tokens incubated`}),g(F,{children:[h(e.progress)," / ",h(e.nextThreshold)," tokens incubated"]})]}):g(U,{children:[c(fe,{label:"Growth to the next evolution",progress:e.progress,stageIndex:r.stageIndex,stages:r.plannedPath.length,threshold:e.nextThreshold,valueText:Xe(r.plannedPath.length,r.stageIndex,e.progress,e.nextThreshold)}),g(F,{children:["Stage ",r.stageIndex+1," of ",r.plannedPath.length]}),r.everstone?g(U,{children:[g(F,{children:["Held at this stage · ",h(e.progress)," banked"]}),c(v,{disabled:u,onClick:a,type:"button",children:"Release"})]}):g(F,{children:[h(e.progress)," / ",h(e.nextThreshold)," to the next stage"]})]})]})]}),g(_e,{children:[g(J,{children:[c(Q,{children:"Earned"}),c(W,{children:h(e.tokensTotal)})]}),g(J,{children:[c(Q,{children:"To spend"}),c(W,{children:h(e.wallet)})]}),g(J,{children:[c(Q,{children:"Graduated"}),c(W,{children:e.dex.length.toLocaleString()})]})]})]})}import{useState as ht}from"react";import{jsx as k,jsxs as se}from"react/jsx-runtime";function tt({keys:e,onPick:t,pluginId:o,rosterFailed:a}){let[u,s]=ht("");return se(M,{children:[k("h2",{children:"Companion"}),k(Ne,{children:"Each API key raises its own Pokémon on the tokens it spends. Pick a key."}),e.length>0?k(je,{children:e.map((r)=>k(ft,{entry:r,onPick:t,pluginId:o},r.apiKeyId))}):k(x,{children:a?"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."}),k(ce,{children:"Or by key id"}),k("form",{onSubmit:(r)=>{r.preventDefault();let n=u.trim();if(n!=="")t(n)},children:se(w,{children:[k("input",{"aria-label":"API key id",onChange:(r)=>s(r.target.value),placeholder:"key id",value:u}),k(v,{type:"submit",children:"Show"})]})})]})}function ft({entry:e,onPick:t,pluginId:o}){let a=_(e.speciesId!==null,e.lastCreditAt,Date.now());return se(ze,{onClick:()=>t(e.apiKeyId),type:"button",children:[e.unreadable?k(Be,{"aria-label":"This key's save could not be read",role:"img"}):e.speciesId===null?k(q,{"aria-label":"An egg, not yet hatched",role:"img"}):k(z,{alt:P(e.name,e.speciesId,e.isShiny),src:T(o,e.speciesId,e.isShiny)}),k("strong",{children:e.unreadable?"Save unreadable":e.speciesId===null?"Egg":R(e.name,e.speciesId)}),e.rarity===null?null:k(b,{children:e.rarity}),k(Z,{children:e.apiKeyId}),se(x,{children:[k(O,{children:h(e.tokensTotal)}),e.unreadable?null:` · ${a}`]})]})}import{useId as xt,useState as bt}from"react";import{jsx as G,jsxs as nt,Fragment as kt}from"react/jsx-runtime";var K={shop:!0,bag:!0,dex:!0},ot=(e)=>`plugin:${e}:sections`;function yt(e){try{let t=globalThis.localStorage?.getItem(ot(e));if(t===null||t===void 0)return K;let o=JSON.parse(t);if(typeof o!=="object"||o===null)return K;let a=o;return{shop:typeof a.shop==="boolean"?a.shop:K.shop,bag:typeof a.bag==="boolean"?a.bag:K.bag,dex:typeof a.dex==="boolean"?a.dex:K.dex}}catch{return K}}function rt(e){let[t,o]=bt(()=>yt(e));return{open:t,toggle:(u)=>{o((s)=>{let r={...s,[u]:!s[u]};try{globalThis.localStorage?.setItem(ot(e),JSON.stringify(r))}catch{}return r})}}}function le({title:e,count:t,open:o,onToggle:a,children:u}){let s=xt();return nt(kt,{children:[G(Te,{children:nt(Pe,{"aria-controls":s,"aria-expanded":o,onClick:a,type:"button",children:[G(Ae,{$open:o,children:"▶"}),e,G(Re,{}),G(Ee,{children:t})]})}),o?G("div",{id:s,children:u}):null]})}import{jsx as E,jsxs as pe}from"react/jsx-runtime";function it({offers:e,wallet:t,onBuy:o,pending:a,inventory:u,hasCompanion:s,pluginId:r}){return E(X,{children:e.map((n)=>{let{entry:p,price:I}=n,S=St(p,u),d=p.kind==="egg"&&!s,D=p.kind==="item"?L(p.item):"fresh egg";return pe(ee,{children:[pe(te,{children:[E(ie,{emoji:p.kind==="item"?N(p.item).emoji:ke,item:p.kind==="item"?p.item:"egg",pluginId:r}),E(ne,{children:D}),S?E(x,{children:"owned"}):E(O,{children:h(I)})]}),p.kind==="egg"&&p.tier!==null?pe(b,{children:[p.tier,"+"]}):null,E(oe,{children:p.kind==="item"?N(p.item).blurb:Se(p.tier)}),E(re,{children:pe(v,{disabled:S||d||t<I||a,onClick:()=>o(p),type:"button",children:["Buy ",we(p)]})})]},p.kind==="item"?`item:${p.item}`:`egg:${p.tier??""}`)})})}function St(e,t){if(e.kind!=="item")return!1;return!N(e.item).consumable&&(t[e.item]??0)>0}import{jsx as f,jsxs as be,Fragment as Ct}from"react/jsx-runtime";var It=15000;function wt({pluginId:e,api:t}){let[o,a]=st({at:"start"}),u=vt(),s=at({queryKey:["roster"],queryFn:()=>t.get("keys")}),r=s.data?.keys??[];if(o.at==="start"&&!s.isPending){let m=r.length===1?r[0]:void 0;a(m===void 0?{at:"roster"}:{at:"key",apiKeyId:m.apiKeyId})}let n=o.at==="key"?o.apiKeyId:null,p=at({queryKey:["companion",n],queryFn:()=>t.get(`keys/${n}`),enabled:n!==null,refetchInterval:It}),[I,S]=st(null),d=()=>{u.invalidateQueries({queryKey:["companion",n]}),u.invalidateQueries({queryKey:["roster"]})},D=xe({mutationFn:(m)=>t.post(`keys/${n}/purchase`,m),onMutate:()=>S(null),onError:(m)=>S(m instanceof Error?m.message:"the purchase was refused"),onSuccess:d}),H=xe({mutationFn:(m)=>t.post(`keys/${n}/use`,{item:m}),onMutate:()=>S(null),onError:(m)=>S(m instanceof Error?m.message:"the item could not be used"),onSuccess:d}),V=xe({mutationFn:()=>t.post(`keys/${n}/unpin`),onMutate:()=>S(null),onError:(m)=>S(m instanceof Error?m.message:"the companion could not be released"),onSuccess:d});if(s.isPending)return f(M,{children:"Loading…"});if(n===null)return f(tt,{keys:r,onPick:(m)=>a({at:"key",apiKeyId:m}),pluginId:e,rosterFailed:s.isError});return be(M,{children:[be(De,{children:[f("h2",{children:"Companion"}),f(Z,{children:n}),f(v,{onClick:()=>a({at:"roster"}),type:"button",children:"All keys"})]}),f($t,{buy:D.mutate,buying:D.isPending,keyId:n,onRelease:()=>V.mutate(),onUse:H.mutate,pluginId:e,query:p,refusal:I,releasing:V.isPending,using:H.isPending})]})}function $t({query:e,pluginId:t,buy:o,onUse:a,onRelease:u,buying:s,using:r,releasing:n,refusal:p}){let{open:I,toggle:S}=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 d=e.data;if(d.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 D=_(d.state.active!==null,d.lastCreditAt,Date.now()),H=Object.values(d.state.inventory).filter((V)=>V>0).length;return be(Ct,{children:[f(et,{activity:D,onRelease:u,pluginId:t,releasing:n,view:d}),f(le,{count:lt(d.shop.length,"offer"),onToggle:()=>S("shop"),open:I.shop,title:"Shop",children:f(it,{hasCompanion:d.state.active!==null,inventory:d.state.inventory,offers:d.shop,onBuy:o,pending:s,pluginId:t,wallet:d.wallet})}),f(le,{count:`${H} held`,onToggle:()=>S("bag"),open:I.bag,title:"Bag",children:f(We,{inventory:d.state.inventory,onUse:a,pending:r,pluginId:t})}),p===null?null:f(ge,{role:"alert",children:p}),f(le,{count:lt(d.dex.length,"graduate"),onToggle:()=>S("dex"),open:I.dex,title:"Pokédex",children:f(Ze,{entries:d.dex,pluginId:t})})]})}function lt(e,t){return`${e} ${t}${e===1?"":"s"}`}var jn=ue({mount:wt});export{_ as activityOf,jn as default};
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};