astrogators-shared-ui 0.4.2 → 0.4.3

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/dist/index.js DELETED
@@ -1,789 +0,0 @@
1
- var ue = Object.defineProperty;
2
- var he = (e, s, t) => s in e ? ue(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
3
- var R = (e, s, t) => he(e, typeof s != "symbol" ? s + "" : s, t);
4
- import { jsx as r, jsxs as m, Fragment as ge } from "react/jsx-runtime";
5
- import ae, { createContext as fe, useState as b, useEffect as j, useCallback as S, useContext as pe } from "react";
6
- const ye = "_container_u3o0e_1", ve = "_padding_u3o0e_7", X = {
7
- container: ye,
8
- padding: ve,
9
- "maxWidth-sm": "_maxWidth-sm_u3o0e_12",
10
- "maxWidth-md": "_maxWidth-md_u3o0e_16",
11
- "maxWidth-lg": "_maxWidth-lg_u3o0e_20",
12
- "maxWidth-xl": "_maxWidth-xl_u3o0e_24",
13
- "maxWidth-full": "_maxWidth-full_u3o0e_28"
14
- }, vs = ({
15
- children: e,
16
- maxWidth: s = "xl",
17
- padding: t = !0,
18
- className: o = ""
19
- }) => /* @__PURE__ */ r(
20
- "div",
21
- {
22
- className: `${X.container} ${X[`maxWidth-${s}`]} ${t ? X.padding : ""} ${o}`,
23
- children: e
24
- }
25
- ), $e = "_topBar_10g3c_1", be = "_content_10g3c_13", we = "_left_10g3c_23", Ne = "_right_10g3c_30", Ae = "_logo_10g3c_36", P = {
26
- topBar: $e,
27
- content: be,
28
- left: we,
29
- right: Ne,
30
- logo: Ae
31
- }, $s = ({
32
- logo: e,
33
- leftContent: s,
34
- rightContent: t,
35
- className: o = ""
36
- }) => /* @__PURE__ */ r("header", { className: `${P.topBar} ${o}`, children: /* @__PURE__ */ m("div", { className: P.content, children: [
37
- /* @__PURE__ */ m("div", { className: P.left, children: [
38
- e && /* @__PURE__ */ r("div", { className: P.logo, children: e }),
39
- s
40
- ] }),
41
- /* @__PURE__ */ r("div", { className: P.right, children: t })
42
- ] }) }), Se = "_footer_zjuj8_1", xe = "_content_zjuj8_7", Te = "_defaultContent_zjuj8_13", Ce = "_copyright_zjuj8_21", ke = "_disclaimer_zjuj8_26", B = {
43
- footer: Se,
44
- content: xe,
45
- defaultContent: Te,
46
- copyright: Ce,
47
- disclaimer: ke
48
- }, bs = ({ children: e, className: s = "" }) => /* @__PURE__ */ r("footer", { className: `${B.footer} ${s}`, children: /* @__PURE__ */ r("div", { className: B.content, children: e || /* @__PURE__ */ m("div", { className: B.defaultContent, children: [
49
- /* @__PURE__ */ m("p", { className: B.copyright, children: [
50
- "© ",
51
- (/* @__PURE__ */ new Date()).getFullYear(),
52
- " The Astrogator's Table. All rights reserved."
53
- ] }),
54
- /* @__PURE__ */ r("p", { className: B.disclaimer, children: "Star Wars: Galaxy of Heroes is a trademark of Electronic Arts Inc." })
55
- ] }) }) }), Ee = "_button_159ms_1", We = "_sm_159ms_22", Ie = "_md_159ms_28", Le = "_lg_159ms_34", qe = "_primary_159ms_41", Re = "_secondary_159ms_55", Pe = "_outline_159ms_69", Be = "_ghost_159ms_80", Ue = "_danger_159ms_89", je = "_fullWidth_159ms_100", Fe = "_loading_159ms_105", De = "_loadingSpinner_159ms_110", Oe = "_spinner_159ms_116", ze = "_spin_159ms_116", Me = "_loadingText_159ms_131", x = {
56
- button: Ee,
57
- sm: We,
58
- md: Ie,
59
- lg: Le,
60
- primary: qe,
61
- secondary: Re,
62
- outline: Pe,
63
- ghost: Be,
64
- danger: Ue,
65
- fullWidth: je,
66
- loading: Fe,
67
- loadingSpinner: De,
68
- spinner: Oe,
69
- spin: ze,
70
- loadingText: Me
71
- }, M = ({
72
- children: e,
73
- variant: s = "primary",
74
- size: t = "md",
75
- fullWidth: o = !1,
76
- loading: _ = !1,
77
- disabled: g = !1,
78
- className: c = "",
79
- ...l
80
- }) => /* @__PURE__ */ r(
81
- "button",
82
- {
83
- className: `${x.button} ${x[s]} ${x[t]} ${o ? x.fullWidth : ""} ${_ ? x.loading : ""} ${c}`,
84
- disabled: g || _,
85
- ...l,
86
- children: _ ? /* @__PURE__ */ m("span", { className: x.loadingSpinner, children: [
87
- /* @__PURE__ */ r("span", { className: x.spinner }),
88
- /* @__PURE__ */ r("span", { className: x.loadingText, children: e })
89
- ] }) : e
90
- }
91
- ), Je = "_inputWrapper_15t4g_1", He = "_fullWidth_15t4g_7", Ye = "_label_15t4g_11", Ge = "_required_15t4g_20", Ke = "_input_15t4g_1", Ve = "_error_15t4g_55", Qe = "_errorText_15t4g_63", Xe = "_helperText_15t4g_68", T = {
92
- inputWrapper: Je,
93
- fullWidth: He,
94
- label: Ye,
95
- required: Ge,
96
- input: Ke,
97
- error: Ve,
98
- errorText: Qe,
99
- helperText: Xe
100
- }, ne = ae.forwardRef(
101
- ({
102
- label: e,
103
- error: s,
104
- helperText: t,
105
- fullWidth: o = !1,
106
- className: _ = "",
107
- id: g,
108
- ...c
109
- }, l) => {
110
- const i = g || `input-${Math.random().toString(36).substr(2, 9)}`, h = !!s;
111
- return /* @__PURE__ */ m("div", { className: `${T.inputWrapper} ${o ? T.fullWidth : ""} ${_}`, children: [
112
- e && /* @__PURE__ */ m("label", { htmlFor: i, className: T.label, children: [
113
- e,
114
- c.required && /* @__PURE__ */ r("span", { className: T.required, children: "*" })
115
- ] }),
116
- /* @__PURE__ */ r(
117
- "input",
118
- {
119
- ref: l,
120
- id: i,
121
- className: `${T.input} ${h ? T.error : ""}`,
122
- ...c
123
- }
124
- ),
125
- s && /* @__PURE__ */ r("span", { className: T.errorText, children: s }),
126
- t && !s && /* @__PURE__ */ r("span", { className: T.helperText, children: t })
127
- ] });
128
- }
129
- );
130
- ne.displayName = "Input";
131
- const Ze = "_selectWrapper_ir4bq_1", et = "_fullWidth_ir4bq_7", tt = "_label_ir4bq_11", st = "_required_ir4bq_20", ot = "_selectContainer_ir4bq_24", rt = "_select_ir4bq_1", at = "_error_ir4bq_63", nt = "_arrow_ir4bq_71", lt = "_errorText_ir4bq_81", ct = "_helperText_ir4bq_86", w = {
132
- selectWrapper: Ze,
133
- fullWidth: et,
134
- label: tt,
135
- required: st,
136
- selectContainer: ot,
137
- select: rt,
138
- error: at,
139
- arrow: nt,
140
- errorText: lt,
141
- helperText: ct
142
- }, le = ae.forwardRef(
143
- ({
144
- label: e,
145
- error: s,
146
- helperText: t,
147
- options: o,
148
- placeholder: _,
149
- fullWidth: g = !1,
150
- className: c = "",
151
- id: l,
152
- ...i
153
- }, h) => {
154
- const p = l || `select-${Math.random().toString(36).substr(2, 9)}`, N = !!s;
155
- return /* @__PURE__ */ m("div", { className: `${w.selectWrapper} ${g ? w.fullWidth : ""} ${c}`, children: [
156
- e && /* @__PURE__ */ m("label", { htmlFor: p, className: w.label, children: [
157
- e,
158
- i.required && /* @__PURE__ */ r("span", { className: w.required, children: "*" })
159
- ] }),
160
- /* @__PURE__ */ m("div", { className: w.selectContainer, children: [
161
- /* @__PURE__ */ m(
162
- "select",
163
- {
164
- ref: h,
165
- id: p,
166
- className: `${w.select} ${N ? w.error : ""}`,
167
- ...i,
168
- children: [
169
- _ && /* @__PURE__ */ r("option", { value: "", disabled: !0, children: _ }),
170
- o && o.map((f) => /* @__PURE__ */ r(
171
- "option",
172
- {
173
- value: f.value,
174
- disabled: f.disabled,
175
- children: f.label
176
- },
177
- f.value
178
- )),
179
- !o && i.children
180
- ]
181
- }
182
- ),
183
- /* @__PURE__ */ r("span", { className: w.arrow, children: "▼" })
184
- ] }),
185
- s && /* @__PURE__ */ r("span", { className: w.errorText, children: s }),
186
- t && !s && /* @__PURE__ */ r("span", { className: w.helperText, children: t })
187
- ] });
188
- }
189
- );
190
- le.displayName = "Select";
191
- const te = "astrogators_access_token", se = "astrogators_refresh_token", ce = () => localStorage.getItem(te), it = (e) => {
192
- localStorage.setItem(te, e);
193
- }, dt = () => {
194
- localStorage.removeItem(te);
195
- }, _t = () => localStorage.getItem(se), mt = (e) => {
196
- localStorage.setItem(se, e);
197
- }, ut = () => {
198
- localStorage.removeItem(se);
199
- }, ie = (e, s) => {
200
- it(e), mt(s);
201
- }, ee = () => {
202
- dt(), ut();
203
- }, ht = () => !!ce();
204
- class gt {
205
- constructor(s) {
206
- R(this, "baseURL");
207
- R(this, "onUnauthorized");
208
- R(this, "isRefreshing", !1);
209
- R(this, "refreshPromise", null);
210
- this.baseURL = s.baseURL, this.onUnauthorized = s.onUnauthorized;
211
- }
212
- async refreshAccessToken() {
213
- var _;
214
- const s = _t();
215
- if (!s)
216
- throw new Error("No refresh token available");
217
- const t = await fetch(`${this.baseURL}/api/v1/auth/refresh-token`, {
218
- method: "POST",
219
- headers: {
220
- "Content-Type": "application/json"
221
- },
222
- body: JSON.stringify({ refresh_token: s })
223
- });
224
- if (!t.ok)
225
- throw ee(), (_ = this.onUnauthorized) == null || _.call(this), new Error("Token refresh failed");
226
- const o = await t.json();
227
- return ie(o.access_token, s), o.access_token;
228
- }
229
- async request(s, t = {}) {
230
- const o = ce(), _ = {
231
- "Content-Type": "application/json",
232
- ...t.headers
233
- };
234
- o && (_.Authorization = `Bearer ${o}`);
235
- const g = `${this.baseURL}${s}`;
236
- let c = await fetch(g, {
237
- ...t,
238
- headers: _
239
- });
240
- if (c.status === 401 && o) {
241
- this.isRefreshing || (this.isRefreshing = !0, this.refreshPromise = this.refreshAccessToken().finally(() => {
242
- this.isRefreshing = !1, this.refreshPromise = null;
243
- }));
244
- try {
245
- const l = await this.refreshPromise;
246
- _.Authorization = `Bearer ${l}`, c = await fetch(g, {
247
- ...t,
248
- headers: _
249
- });
250
- } catch {
251
- throw new Error("Authentication failed");
252
- }
253
- }
254
- if (!c.ok) {
255
- const l = {
256
- message: c.statusText,
257
- status: c.status
258
- };
259
- try {
260
- const i = await c.json();
261
- if (c.status === 422 && Array.isArray(i.detail)) {
262
- const h = i.detail.map((p) => p.msg || "Validation error").join(", ");
263
- l.message = h;
264
- } else typeof i.detail == "string" ? l.message = i.detail : i.message && (l.message = i.message);
265
- l.detail = i.detail;
266
- } catch {
267
- }
268
- throw l;
269
- }
270
- return c.status === 204 ? {} : c.json();
271
- }
272
- async get(s, t) {
273
- return this.request(s, { ...t, method: "GET" });
274
- }
275
- async post(s, t, o) {
276
- return this.request(s, {
277
- ...o,
278
- method: "POST",
279
- body: t ? JSON.stringify(t) : void 0
280
- });
281
- }
282
- async put(s, t, o) {
283
- return this.request(s, {
284
- ...o,
285
- method: "PUT",
286
- body: t ? JSON.stringify(t) : void 0
287
- });
288
- }
289
- async patch(s, t, o) {
290
- return this.request(s, {
291
- ...o,
292
- method: "PATCH",
293
- body: t ? JSON.stringify(t) : void 0
294
- });
295
- }
296
- async delete(s, t) {
297
- return this.request(s, { ...t, method: "DELETE" });
298
- }
299
- }
300
- let y;
301
- const ft = (e) => {
302
- y = new gt(e);
303
- }, F = "astrogators_ally_codes", H = "astrogators_selected_ally_code", A = () => {
304
- try {
305
- const e = localStorage.getItem(F);
306
- return e ? JSON.parse(e) : [];
307
- } catch (e) {
308
- return console.error("Failed to read ally codes from localStorage:", e), [];
309
- }
310
- }, pt = (e) => {
311
- try {
312
- const s = A();
313
- if (s.some((o) => o.ally_code === e.ally_code))
314
- return;
315
- s.push(e), localStorage.setItem(F, JSON.stringify(s));
316
- } catch (s) {
317
- console.error("Failed to save ally code to localStorage:", s);
318
- }
319
- }, yt = (e) => {
320
- try {
321
- const t = A().filter((o) => o.ally_code !== e);
322
- localStorage.setItem(F, JSON.stringify(t));
323
- } catch (s) {
324
- console.error("Failed to remove ally code from localStorage:", s);
325
- }
326
- }, re = (e) => {
327
- try {
328
- const t = A().map(
329
- (o) => o.ally_code === e ? { ...o, last_used_at: (/* @__PURE__ */ new Date()).toISOString() } : o
330
- );
331
- localStorage.setItem(F, JSON.stringify(t));
332
- } catch (s) {
333
- console.error("Failed to update ally code last used:", s);
334
- }
335
- }, vt = () => localStorage.getItem(H), $t = (e) => {
336
- e ? localStorage.setItem(H, e) : localStorage.removeItem(H);
337
- }, bt = () => {
338
- localStorage.removeItem(F), localStorage.removeItem(H);
339
- }, de = fe(void 0), ws = ({ children: e, apiBaseUrl: s }) => {
340
- const [t, o] = b(null), [_, g] = b(!0), [c, l] = b([]), [i, h] = b(null), [p, N] = b(!1), [f, k] = b({
341
- show: !1,
342
- localStorageCodes: []
343
- });
344
- j(() => {
345
- ft({
346
- baseURL: s
347
- });
348
- }, [s]);
349
- const W = S(async () => {
350
- if (!ht()) {
351
- o(null), g(!1);
352
- return;
353
- }
354
- try {
355
- const a = await y.get("/api/v1/users/me");
356
- o(a);
357
- } catch (a) {
358
- console.error("Failed to fetch user:", a), o(null), ee();
359
- } finally {
360
- g(!1);
361
- }
362
- }, []);
363
- j(() => {
364
- W();
365
- }, [W]);
366
- const I = async (a) => {
367
- try {
368
- const n = await y.post("/api/v1/auth/login", a);
369
- ie(n.access_token, n.refresh_token);
370
- const u = await y.get("/api/v1/users/me");
371
- o(u);
372
- } catch (n) {
373
- throw console.error("Login failed:", n), n;
374
- }
375
- }, D = async (a) => {
376
- try {
377
- await y.post("/api/v1/auth/register", a);
378
- } catch (n) {
379
- throw console.error("Registration failed:", n), n;
380
- }
381
- }, O = () => {
382
- ee(), o(null), l([]), h(null), k({ show: !1, localStorageCodes: [] });
383
- }, Y = async () => {
384
- await W();
385
- }, G = async (a) => {
386
- try {
387
- return (await y.post(
388
- "/api/v1/auth/forgot-password",
389
- a
390
- )).message;
391
- } catch (n) {
392
- throw console.error("Forgot password failed:", n), n;
393
- }
394
- }, K = async (a) => {
395
- try {
396
- return (await y.post(
397
- "/api/v1/auth/reset-password",
398
- a
399
- )).message;
400
- } catch (n) {
401
- throw console.error("Reset password failed:", n), n;
402
- }
403
- }, V = async (a) => {
404
- try {
405
- return (await y.post(
406
- "/api/v1/auth/resend-verification",
407
- a
408
- )).message;
409
- } catch (n) {
410
- throw console.error("Resend verification failed:", n), n;
411
- }
412
- }, d = S(async () => {
413
- N(!0);
414
- try {
415
- if (t) {
416
- const n = await y.get("/api/v1/users/me/ally-codes");
417
- l(n.ally_codes);
418
- const u = A();
419
- u.length > 0 && k({
420
- show: !0,
421
- localStorageCodes: u.map((q) => q.ally_code)
422
- });
423
- } else {
424
- const n = A();
425
- l(n);
426
- }
427
- const a = vt();
428
- h(a);
429
- } catch (a) {
430
- console.error("Failed to fetch ally codes:", a), l([]);
431
- } finally {
432
- N(!1);
433
- }
434
- }, [t]), v = S(async (a) => {
435
- var n;
436
- if (!/^\d{9}$/.test(a))
437
- throw new Error("Ally code must be exactly 9 digits");
438
- if (t) {
439
- const u = await y.post(
440
- "/api/v1/users/me/ally-codes",
441
- { ally_code: a }
442
- );
443
- l((q) => [u, ...q]), c.length === 0 && z(a);
444
- } else {
445
- const u = await y.get(`/api/v1/player-data/player/${a}`);
446
- if (!u)
447
- throw new Error("Invalid ally code - player not found");
448
- const q = {
449
- ally_code: a,
450
- player_name: ((n = u == null ? void 0 : u.data) == null ? void 0 : n.name) || null,
451
- last_used_at: (/* @__PURE__ */ new Date()).toISOString()
452
- };
453
- pt(q), l(A()), c.length === 0 && z(a);
454
- }
455
- }, [t, c.length]), L = S(async (a) => {
456
- t && typeof a == "number" ? (await y.delete(`/api/v1/users/me/ally-codes/${a}`), l((n) => n.filter((u) => "id" in u && u.id !== a))) : !t && typeof a == "string" && (yt(a), l(A()), i === a && z(null));
457
- }, [t, i]), z = S((a) => {
458
- if (h(a), $t(a), a && t) {
459
- const n = c.find((u) => "ally_code" in u && u.ally_code === a);
460
- n && "id" in n && oe(n.id);
461
- } else a && !t && re(a);
462
- }, [t, c]), oe = S(async (a) => {
463
- t && typeof a == "number" ? (await y.put(`/api/v1/users/me/ally-codes/${a}/use`, {}), await d()) : !t && typeof a == "string" && (re(a), l(A()));
464
- }, [t, d]), Q = S(() => {
465
- k({ show: !1, localStorageCodes: [] });
466
- }, []), _e = S(async () => {
467
- if (!t) return;
468
- const a = A();
469
- for (const n of a)
470
- try {
471
- await v(n.ally_code);
472
- } catch (u) {
473
- console.error(`Failed to migrate ally code ${n.ally_code}:`, u);
474
- }
475
- bt(), Q();
476
- }, [t, v, Q]);
477
- j(() => {
478
- d();
479
- }, [d]);
480
- const me = {
481
- user: t,
482
- isAuthenticated: !!t,
483
- isLoading: _,
484
- login: I,
485
- register: D,
486
- logout: O,
487
- refreshUser: Y,
488
- forgotPassword: G,
489
- resetPassword: K,
490
- resendVerification: V,
491
- // Ally code values
492
- allyCodes: c,
493
- selectedAllyCode: i,
494
- isLoadingAllyCodes: p,
495
- fetchAllyCodes: d,
496
- addAllyCode: v,
497
- removeAllyCode: L,
498
- selectAllyCode: z,
499
- updateAllyCodeLastUsed: oe,
500
- migrationPrompt: f,
501
- dismissMigrationPrompt: Q,
502
- migrateLocalStorageCodes: _e
503
- };
504
- return /* @__PURE__ */ r(de.Provider, { value: me, children: e });
505
- }, wt = () => {
506
- const e = pe(de);
507
- if (e === void 0)
508
- throw new Error("useAuth must be used within an AuthProvider");
509
- return e;
510
- }, J = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e.slice(6, 9)}`, Ns = (e) => e.replace(/-/g, ""), Nt = "_allyCodeDropdown_1m0tw_1", At = "_select_1m0tw_8", St = "_manageButton_1m0tw_12", xt = "_managePanel_1m0tw_16", Tt = "_addSection_1m0tw_37", Ct = "_addInputGroup_1m0tw_43", kt = "_error_1m0tw_55", Et = "_success_1m0tw_61", Wt = "_codesList_1m0tw_67", It = "_codeItem_1m0tw_71", Lt = "_doneButton_1m0tw_88", $ = {
511
- allyCodeDropdown: Nt,
512
- select: At,
513
- manageButton: St,
514
- managePanel: xt,
515
- addSection: Tt,
516
- addInputGroup: Ct,
517
- error: kt,
518
- success: Et,
519
- codesList: Wt,
520
- codeItem: It,
521
- doneButton: Lt
522
- }, As = ({
523
- onAllyCodeSelected: e,
524
- className: s = ""
525
- }) => {
526
- const {
527
- allyCodes: t,
528
- selectedAllyCode: o,
529
- selectAllyCode: _,
530
- removeAllyCode: g,
531
- addAllyCode: c,
532
- isLoadingAllyCodes: l
533
- } = wt(), [i, h] = b(!1), [p, N] = b(""), [f, k] = b(""), [W, I] = b(""), [D, O] = b(!1), Y = t.map((d) => ({
534
- value: d.ally_code,
535
- label: d.player_name ? `${d.player_name} (${J(d.ally_code)})` : J(d.ally_code)
536
- })), G = (d) => {
537
- const v = d.target.value || null;
538
- _(v), e == null || e(v);
539
- }, K = async (d) => {
540
- const v = t.find((L) => L.ally_code === d);
541
- if (v) {
542
- const L = "id" in v ? v.id : v.ally_code;
543
- await g(L);
544
- }
545
- }, V = async () => {
546
- if (k(""), I(""), !/^\d{9}$/.test(p)) {
547
- k("Ally code must be exactly 9 digits");
548
- return;
549
- }
550
- O(!0);
551
- try {
552
- await c(p), I("Added successfully!"), N(""), setTimeout(() => I(""), 2e3);
553
- } catch (d) {
554
- k(d.message || "Failed to add ally code");
555
- } finally {
556
- O(!1);
557
- }
558
- };
559
- return t.length === 0 ? null : /* @__PURE__ */ m("div", { className: `${$.allyCodeDropdown} ${s}`, children: [
560
- /* @__PURE__ */ r(
561
- le,
562
- {
563
- options: Y,
564
- value: o || "",
565
- onChange: G,
566
- placeholder: "Select ally code",
567
- disabled: l,
568
- className: $.select
569
- }
570
- ),
571
- i && /* @__PURE__ */ m("div", { className: $.managePanel, children: [
572
- /* @__PURE__ */ r("h4", { children: "Manage Ally Codes" }),
573
- /* @__PURE__ */ m("div", { className: $.addSection, children: [
574
- /* @__PURE__ */ m("div", { className: $.addInputGroup, children: [
575
- /* @__PURE__ */ r(
576
- ne,
577
- {
578
- type: "text",
579
- placeholder: "9-digit ally code",
580
- value: p,
581
- onChange: (d) => N(d.target.value.replace(/\D/g, "").slice(0, 9)),
582
- disabled: D
583
- }
584
- ),
585
- /* @__PURE__ */ r(
586
- M,
587
- {
588
- variant: "primary",
589
- size: "sm",
590
- onClick: V,
591
- loading: D,
592
- disabled: p.length !== 9,
593
- children: "Add"
594
- }
595
- )
596
- ] }),
597
- f && /* @__PURE__ */ r("div", { className: $.error, children: f }),
598
- W && /* @__PURE__ */ r("div", { className: $.success, children: W })
599
- ] }),
600
- /* @__PURE__ */ r("div", { className: $.codesList, children: t.map((d) => /* @__PURE__ */ m("div", { className: $.codeItem, children: [
601
- /* @__PURE__ */ r("span", { children: d.player_name ? `${d.player_name} (${J(d.ally_code)})` : J(d.ally_code) }),
602
- /* @__PURE__ */ r(
603
- M,
604
- {
605
- variant: "ghost",
606
- size: "sm",
607
- onClick: () => K(d.ally_code),
608
- children: "Remove"
609
- }
610
- )
611
- ] }, d.ally_code)) }),
612
- /* @__PURE__ */ r(
613
- M,
614
- {
615
- variant: "secondary",
616
- size: "sm",
617
- onClick: () => h(!1),
618
- className: $.doneButton,
619
- children: "Done"
620
- }
621
- )
622
- ] }),
623
- /* @__PURE__ */ r(
624
- M,
625
- {
626
- variant: "ghost",
627
- size: "sm",
628
- onClick: () => h(!i),
629
- className: $.manageButton,
630
- children: "Manage"
631
- }
632
- )
633
- ] });
634
- }, qt = "_card_b4471_1", Rt = "_chamfered_b4471_8", Pt = "_elevated_b4471_17", Bt = "_outline_b4471_22", Ut = "_hoverable_b4471_45", U = {
635
- card: qt,
636
- chamfered: Rt,
637
- default: "_default_b4471_13",
638
- elevated: Pt,
639
- outline: Bt,
640
- "padding-none": "_padding-none_b4471_28",
641
- "padding-sm": "_padding-sm_b4471_32",
642
- "padding-md": "_padding-md_b4471_36",
643
- "padding-lg": "_padding-lg_b4471_40",
644
- hoverable: Ut
645
- }, Ss = ({
646
- children: e,
647
- variant: s = "default",
648
- chamfered: t = !1,
649
- chamferSize: o = "md",
650
- padding: _ = "md",
651
- hoverable: g = !1,
652
- showDiagonalBorders: c = !1,
653
- diagonalBorderColor: l,
654
- className: i = "",
655
- onClick: h,
656
- style: p
657
- }) => {
658
- const N = t ? o === "asymmetric" ? "chamfered-box-asymmetric" : o === "sm" ? "chamfered-box-sm" : o === "lg" ? "chamfered-box-lg" : "chamfered-box" : "", f = l ? { color: l } : void 0;
659
- return /* @__PURE__ */ m(
660
- "div",
661
- {
662
- className: `${U.card} ${t ? U.chamfered : ""} ${U[s]} ${U[`padding-${_}`]} ${N} ${g ? U.hoverable : ""} ${i}`,
663
- onClick: h,
664
- role: h ? "button" : void 0,
665
- tabIndex: h ? 0 : void 0,
666
- style: p,
667
- children: [
668
- c && /* @__PURE__ */ m(ge, { children: [
669
- /* @__PURE__ */ r("div", { className: "chamfered-diagonal-border chamfered-diagonal-tl", style: f }),
670
- /* @__PURE__ */ r("div", { className: "chamfered-diagonal-border chamfered-diagonal-tr", style: f }),
671
- /* @__PURE__ */ r("div", { className: "chamfered-diagonal-border chamfered-diagonal-bl", style: f }),
672
- /* @__PURE__ */ r("div", { className: `chamfered-diagonal-border ${o === "asymmetric" ? "chamfered-diagonal-br-large" : "chamfered-diagonal-br"}`, style: f })
673
- ] }),
674
- e
675
- ]
676
- }
677
- );
678
- }, jt = "_badge_rk7t5_1", Ft = "_sm_rk7t5_11", Dt = "_md_rk7t5_16", Ot = "_lg_rk7t5_21", zt = "_primary_rk7t5_32", Mt = "_secondary_rk7t5_37", Jt = "_success_rk7t5_42", Ht = "_warning_rk7t5_47", Yt = "_error_rk7t5_52", Gt = "_info_rk7t5_57", Z = {
679
- badge: jt,
680
- sm: Ft,
681
- md: Dt,
682
- lg: Ot,
683
- default: "_default_rk7t5_27",
684
- primary: zt,
685
- secondary: Mt,
686
- success: Jt,
687
- warning: Ht,
688
- error: Yt,
689
- info: Gt
690
- }, xs = ({
691
- children: e,
692
- variant: s = "default",
693
- size: t = "md",
694
- className: o = ""
695
- }) => /* @__PURE__ */ r("span", { className: `${Z.badge} ${Z[s]} ${Z[t]} ${o}`, children: e }), Kt = "_overlay_1b3yt_1", Vt = "_fadeIn_1b3yt_1", Qt = "_modal_1b3yt_13", Xt = "_slideUp_1b3yt_1", Zt = "_sm_1b3yt_25", es = "_md_1b3yt_30", ts = "_lg_1b3yt_35", ss = "_xl_1b3yt_40", os = "_header_1b3yt_45", rs = "_title_1b3yt_53", as = "_closeButton_1b3yt_60", ns = "_content_1b3yt_78", E = {
696
- overlay: Kt,
697
- fadeIn: Vt,
698
- modal: Qt,
699
- slideUp: Xt,
700
- sm: Zt,
701
- md: es,
702
- lg: ts,
703
- xl: ss,
704
- header: os,
705
- title: rs,
706
- closeButton: as,
707
- content: ns
708
- }, Ts = ({
709
- isOpen: e,
710
- onClose: s,
711
- title: t,
712
- children: o,
713
- size: _ = "md",
714
- closeOnOverlayClick: g = !0,
715
- className: c = ""
716
- }) => {
717
- if (j(() => (e ? document.body.style.overflow = "hidden" : document.body.style.overflow = "unset", () => {
718
- document.body.style.overflow = "unset";
719
- }), [e]), j(() => {
720
- const i = (h) => {
721
- h.key === "Escape" && e && s();
722
- };
723
- return document.addEventListener("keydown", i), () => document.removeEventListener("keydown", i);
724
- }, [e, s]), !e) return null;
725
- const l = (i) => {
726
- g && i.target === i.currentTarget && s();
727
- };
728
- return /* @__PURE__ */ r("div", { className: E.overlay, onClick: l, children: /* @__PURE__ */ m("div", { className: `${E.modal} ${E[_]} ${c}`, role: "dialog", "aria-modal": "true", children: [
729
- t && /* @__PURE__ */ m("div", { className: E.header, children: [
730
- /* @__PURE__ */ r("h2", { className: E.title, children: t }),
731
- /* @__PURE__ */ r("button", { className: E.closeButton, onClick: s, "aria-label": "Close modal", children: "✕" })
732
- ] }),
733
- /* @__PURE__ */ r("div", { className: E.content, children: o })
734
- ] }) });
735
- }, ls = "_spinner_1uhnh_2", cs = "_spin_1uhnh_2", is = "_sm_1uhnh_9", ds = "_md_1uhnh_15", _s = "_lg_1uhnh_21", ms = "_dots_1uhnh_34", us = "_dot_1uhnh_34", hs = "_bounce_1uhnh_1", gs = "_visuallyHidden_1uhnh_91", C = {
736
- spinner: ls,
737
- spin: cs,
738
- sm: is,
739
- md: ds,
740
- lg: _s,
741
- dots: ms,
742
- dot: us,
743
- bounce: hs,
744
- visuallyHidden: gs
745
- }, Cs = ({
746
- size: e = "md",
747
- variant: s = "spinner",
748
- className: t = ""
749
- }) => s === "dots" ? /* @__PURE__ */ m("div", { className: `${C.dots} ${C[e]} ${t}`, children: [
750
- /* @__PURE__ */ r("span", { className: C.dot }),
751
- /* @__PURE__ */ r("span", { className: C.dot }),
752
- /* @__PURE__ */ r("span", { className: C.dot })
753
- ] }) : /* @__PURE__ */ r("div", { className: `${C.spinner} ${C[e]} ${t}`, role: "status", children: /* @__PURE__ */ r("span", { className: C.visuallyHidden, children: "Loading..." }) });
754
- export {
755
- As as AllyCodeDropdown,
756
- gt as ApiClient,
757
- ws as AuthProvider,
758
- xs as Badge,
759
- M as Button,
760
- Ss as Card,
761
- vs as Container,
762
- bs as Footer,
763
- ne as Input,
764
- Cs as Loader,
765
- Ts as Modal,
766
- le as Select,
767
- $s as TopBar,
768
- y as apiClient,
769
- bt as clearAllyCodes,
770
- ee as clearTokens,
771
- J as formatAllyCode,
772
- ce as getAccessToken,
773
- A as getAllyCodesFromStorage,
774
- _t as getRefreshToken,
775
- vt as getSelectedAllyCode,
776
- ft as initializeApiClient,
777
- ht as isAuthenticated,
778
- dt as removeAccessToken,
779
- yt as removeAllyCodeFromStorage,
780
- ut as removeRefreshToken,
781
- pt as saveAllyCodeToStorage,
782
- it as setAccessToken,
783
- mt as setRefreshToken,
784
- $t as setSelectedAllyCode,
785
- ie as setTokens,
786
- Ns as unformatAllyCode,
787
- re as updateAllyCodeLastUsed,
788
- wt as useAuth
789
- };