astrogators-shared-ui 0.14.0 → 0.16.0
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 +21 -3
- package/dist/index.css +1 -1
- package/dist/index.js +817 -463
- package/dist/src/components/forms/AllyCodeDropdown.d.ts +10 -0
- package/dist/src/components/layout/AccountCluster.d.ts +13 -0
- package/dist/src/components/layout/MobileNavPanel.d.ts +24 -0
- package/dist/src/components/layout/NavBar.d.ts +33 -40
- package/dist/src/components/layout/NavBurger.d.ts +11 -0
- package/dist/src/components/layout/NavMenu.d.ts +17 -0
- package/dist/src/components/layout/index.d.ts +1 -1
- package/dist/src/hooks/useDismissableMenu.d.ts +18 -0
- package/dist/src/index.d.ts +3 -1
- package/dist/src/navigation/suiteNav.d.ts +28 -0
- package/dist/src/services/tokenRefresh.d.ts +5 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import e, { createContext as t,
|
|
2
|
-
import { Fragment as
|
|
3
|
-
|
|
1
|
+
import e, { createContext as t, forwardRef as n, useCallback as r, useContext as i, useEffect as a, useRef as o, useState as s } from "react";
|
|
2
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
3
|
+
import { createPortal as d } from "react-dom";
|
|
4
|
+
var f = {
|
|
4
5
|
container: "_container_u3o0e_1",
|
|
5
6
|
padding: "_padding_u3o0e_7",
|
|
6
7
|
"maxWidth-sm": "_maxWidth-sm_u3o0e_12",
|
|
@@ -8,221 +9,113 @@ var l = {
|
|
|
8
9
|
"maxWidth-lg": "_maxWidth-lg_u3o0e_20",
|
|
9
10
|
"maxWidth-xl": "_maxWidth-xl_u3o0e_24",
|
|
10
11
|
"maxWidth-full": "_maxWidth-full_u3o0e_28"
|
|
11
|
-
},
|
|
12
|
-
className: `${
|
|
12
|
+
}, p = ({ children: e, maxWidth: t = "xl", padding: n = !0, className: r = "", style: i }) => /* @__PURE__ */ l("div", {
|
|
13
|
+
className: `${f.container} ${f[`maxWidth-${t}`]} ${n ? f.padding : ""} ${r}`,
|
|
13
14
|
style: i,
|
|
14
15
|
children: e
|
|
15
|
-
}),
|
|
16
|
-
topBar: "
|
|
17
|
-
content: "
|
|
18
|
-
left: "
|
|
19
|
-
right: "
|
|
20
|
-
logo: "
|
|
21
|
-
},
|
|
22
|
-
className: `${
|
|
23
|
-
children: /* @__PURE__ */
|
|
24
|
-
className:
|
|
25
|
-
children: [/* @__PURE__ */
|
|
26
|
-
className:
|
|
27
|
-
children: [e && /* @__PURE__ */
|
|
28
|
-
className:
|
|
16
|
+
}), m = {
|
|
17
|
+
topBar: "_topBar_r058i_1",
|
|
18
|
+
content: "_content_r058i_17",
|
|
19
|
+
left: "_left_r058i_25",
|
|
20
|
+
right: "_right_r058i_32",
|
|
21
|
+
logo: "_logo_r058i_38"
|
|
22
|
+
}, h = ({ logo: e, leftContent: t, rightContent: n, className: r = "" }) => /* @__PURE__ */ l("header", {
|
|
23
|
+
className: `${m.topBar} ${r}`,
|
|
24
|
+
children: /* @__PURE__ */ u("div", {
|
|
25
|
+
className: m.content,
|
|
26
|
+
children: [/* @__PURE__ */ u("div", {
|
|
27
|
+
className: m.left,
|
|
28
|
+
children: [e && /* @__PURE__ */ l("div", {
|
|
29
|
+
className: m.logo,
|
|
29
30
|
children: e
|
|
30
31
|
}), t]
|
|
31
|
-
}), /* @__PURE__ */
|
|
32
|
-
className:
|
|
32
|
+
}), /* @__PURE__ */ l("div", {
|
|
33
|
+
className: m.right,
|
|
33
34
|
children: n
|
|
34
35
|
})]
|
|
35
36
|
})
|
|
36
|
-
}),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
secondary: "_secondary_159ms_55",
|
|
43
|
-
outline: "_outline_159ms_69",
|
|
44
|
-
ghost: "_ghost_159ms_80",
|
|
45
|
-
danger: "_danger_159ms_89",
|
|
46
|
-
fullWidth: "_fullWidth_159ms_100",
|
|
47
|
-
loading: "_loading_159ms_105",
|
|
48
|
-
loadingSpinner: "_loadingSpinner_159ms_110",
|
|
49
|
-
spinner: "_spinner_159ms_116",
|
|
50
|
-
spin: "_spin_159ms_116",
|
|
51
|
-
loadingText: "_loadingText_159ms_131"
|
|
52
|
-
}, m = ({ children: e, variant: t = "primary", size: n = "md", fullWidth: r = !1, loading: i = !1, disabled: a = !1, className: o = "", ...l }) => /* @__PURE__ */ s("button", {
|
|
53
|
-
className: `${p.button} ${p[t]} ${p[n]} ${r ? p.fullWidth : ""} ${i ? p.loading : ""} ${o}`,
|
|
54
|
-
disabled: a || i,
|
|
55
|
-
...l,
|
|
56
|
-
children: i ? /* @__PURE__ */ c("span", {
|
|
57
|
-
className: p.loadingSpinner,
|
|
58
|
-
children: [/* @__PURE__ */ s("span", { className: p.spinner }), /* @__PURE__ */ s("span", {
|
|
59
|
-
className: p.loadingText,
|
|
60
|
-
children: e
|
|
61
|
-
})]
|
|
62
|
-
}) : e
|
|
63
|
-
}), h = {
|
|
64
|
-
selectWrapper: "_selectWrapper_ir4bq_1",
|
|
65
|
-
fullWidth: "_fullWidth_ir4bq_7",
|
|
66
|
-
label: "_label_ir4bq_11",
|
|
67
|
-
required: "_required_ir4bq_20",
|
|
68
|
-
selectContainer: "_selectContainer_ir4bq_24",
|
|
69
|
-
select: "_select_ir4bq_1",
|
|
70
|
-
error: "_error_ir4bq_63",
|
|
71
|
-
arrow: "_arrow_ir4bq_71",
|
|
72
|
-
errorText: "_errorText_ir4bq_81",
|
|
73
|
-
helperText: "_helperText_ir4bq_86"
|
|
74
|
-
}, g = e.forwardRef(({ label: e, error: t, helperText: n, options: r, placeholder: i, fullWidth: a = !1, className: o = "", id: l, ...u }, d) => {
|
|
75
|
-
let f = l || `select-${Math.random().toString(36).substr(2, 9)}`, p = !!t;
|
|
76
|
-
return /* @__PURE__ */ c("div", {
|
|
77
|
-
className: `${h.selectWrapper} ${a ? h.fullWidth : ""} ${o}`,
|
|
78
|
-
children: [
|
|
79
|
-
e && /* @__PURE__ */ c("label", {
|
|
80
|
-
htmlFor: f,
|
|
81
|
-
className: h.label,
|
|
82
|
-
children: [e, u.required && /* @__PURE__ */ s("span", {
|
|
83
|
-
className: h.required,
|
|
84
|
-
children: "*"
|
|
85
|
-
})]
|
|
86
|
-
}),
|
|
87
|
-
/* @__PURE__ */ c("div", {
|
|
88
|
-
className: h.selectContainer,
|
|
89
|
-
children: [/* @__PURE__ */ c("select", {
|
|
90
|
-
ref: d,
|
|
91
|
-
id: f,
|
|
92
|
-
className: `${h.select} ${p ? h.error : ""}`,
|
|
93
|
-
...u,
|
|
94
|
-
children: [
|
|
95
|
-
i && /* @__PURE__ */ s("option", {
|
|
96
|
-
value: "",
|
|
97
|
-
disabled: !0,
|
|
98
|
-
children: i
|
|
99
|
-
}),
|
|
100
|
-
r && r.map((e) => /* @__PURE__ */ s("option", {
|
|
101
|
-
value: e.value,
|
|
102
|
-
disabled: e.disabled,
|
|
103
|
-
children: e.label
|
|
104
|
-
}, e.value)),
|
|
105
|
-
!r && u.children
|
|
106
|
-
]
|
|
107
|
-
}), /* @__PURE__ */ s("span", {
|
|
108
|
-
className: h.arrow,
|
|
109
|
-
children: "▼"
|
|
110
|
-
})]
|
|
111
|
-
}),
|
|
112
|
-
t && /* @__PURE__ */ s("span", {
|
|
113
|
-
className: h.errorText,
|
|
114
|
-
children: t
|
|
115
|
-
}),
|
|
116
|
-
n && !t && /* @__PURE__ */ s("span", {
|
|
117
|
-
className: h.helperText,
|
|
118
|
-
children: n
|
|
119
|
-
})
|
|
120
|
-
]
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
g.displayName = "Select";
|
|
124
|
-
var _ = {
|
|
125
|
-
inputWrapper: "_inputWrapper_15t4g_1",
|
|
126
|
-
fullWidth: "_fullWidth_15t4g_7",
|
|
127
|
-
label: "_label_15t4g_11",
|
|
128
|
-
required: "_required_15t4g_20",
|
|
129
|
-
input: "_input_15t4g_1",
|
|
130
|
-
error: "_error_15t4g_55",
|
|
131
|
-
errorText: "_errorText_15t4g_63",
|
|
132
|
-
helperText: "_helperText_15t4g_68"
|
|
133
|
-
}, v = e.forwardRef(({ label: e, error: t, helperText: n, fullWidth: r = !1, className: i = "", id: a, ...o }, l) => {
|
|
134
|
-
let u = a || `input-${Math.random().toString(36).substr(2, 9)}`, d = !!t;
|
|
135
|
-
return /* @__PURE__ */ c("div", {
|
|
136
|
-
className: `${_.inputWrapper} ${r ? _.fullWidth : ""} ${i}`,
|
|
137
|
-
children: [
|
|
138
|
-
e && /* @__PURE__ */ c("label", {
|
|
139
|
-
htmlFor: u,
|
|
140
|
-
className: _.label,
|
|
141
|
-
children: [e, o.required && /* @__PURE__ */ s("span", {
|
|
142
|
-
className: _.required,
|
|
143
|
-
children: "*"
|
|
144
|
-
})]
|
|
145
|
-
}),
|
|
146
|
-
/* @__PURE__ */ s("input", {
|
|
147
|
-
ref: l,
|
|
148
|
-
id: u,
|
|
149
|
-
className: `${_.input} ${d ? _.error : ""}`,
|
|
150
|
-
...o
|
|
151
|
-
}),
|
|
152
|
-
t && /* @__PURE__ */ s("span", {
|
|
153
|
-
className: _.errorText,
|
|
154
|
-
children: t
|
|
155
|
-
}),
|
|
156
|
-
n && !t && /* @__PURE__ */ s("span", {
|
|
157
|
-
className: _.helperText,
|
|
158
|
-
children: n
|
|
159
|
-
})
|
|
160
|
-
]
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
v.displayName = "Input";
|
|
164
|
-
//#endregion
|
|
165
|
-
//#region src/services/auth.ts
|
|
166
|
-
var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => localStorage.getItem(y), S = (e) => {
|
|
167
|
-
localStorage.setItem(y, e);
|
|
37
|
+
}), g = "astrogators_access_token", _ = "astrogators_refresh_token", v = () => localStorage.getItem(g), y = (e) => {
|
|
38
|
+
localStorage.setItem(g, e);
|
|
39
|
+
}, b = () => {
|
|
40
|
+
localStorage.removeItem(g);
|
|
41
|
+
}, x = () => localStorage.getItem(_), S = (e) => {
|
|
42
|
+
localStorage.setItem(_, e);
|
|
168
43
|
}, C = () => {
|
|
169
|
-
localStorage.removeItem(
|
|
170
|
-
}, w = (
|
|
171
|
-
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
}, D = (e
|
|
175
|
-
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
}, ee = () => !!x(), k = "", A, j = null, M = (e) => {
|
|
179
|
-
k = e.baseURL, A = e.onUnauthorized;
|
|
180
|
-
}, N = () => j || (j = (async () => {
|
|
181
|
-
let e = w();
|
|
44
|
+
localStorage.removeItem(_);
|
|
45
|
+
}, w = (e, t) => {
|
|
46
|
+
y(e), S(t);
|
|
47
|
+
}, T = () => {
|
|
48
|
+
b(), C();
|
|
49
|
+
}, E = () => !!v(), D = "", O, k = null, A = (e) => {
|
|
50
|
+
D = e.baseURL, O = e.onUnauthorized;
|
|
51
|
+
}, j = () => k || (k = (async () => {
|
|
52
|
+
let e = x();
|
|
182
53
|
if (!e) throw Error("No refresh token available");
|
|
183
|
-
let t = await fetch(`${
|
|
54
|
+
let t = await fetch(`${D}/api/v1/auth/refresh`, {
|
|
184
55
|
method: "POST",
|
|
185
56
|
headers: { "Content-Type": "application/json" },
|
|
186
57
|
body: JSON.stringify({ refresh_token: e })
|
|
187
58
|
});
|
|
188
|
-
if (!t.ok) throw
|
|
59
|
+
if (!t.ok) throw T(), O?.(), Error("Token refresh failed");
|
|
189
60
|
let n = await t.json();
|
|
190
|
-
return
|
|
61
|
+
return w(n.access_token, n.refresh_token), n.access_token;
|
|
191
62
|
})().finally(() => {
|
|
192
|
-
|
|
193
|
-
}),
|
|
63
|
+
k = null;
|
|
64
|
+
}), k), ee = 30, M = [700, 1500], N = new Set([
|
|
65
|
+
502,
|
|
66
|
+
503,
|
|
67
|
+
504
|
|
68
|
+
]), P = (e) => {
|
|
69
|
+
let t = (e ?? "GET").toUpperCase();
|
|
70
|
+
return t === "GET" || t === "HEAD" || t === "OPTIONS";
|
|
71
|
+
}, F = (e) => e == null || typeof e == "string", te = (e) => new Promise((t) => setTimeout(t, e)), I = async (e, t) => {
|
|
72
|
+
let n = P(t.method) && F(t.body), r = F(t.body), i;
|
|
73
|
+
for (let a = 0; a <= M.length; a++) {
|
|
74
|
+
a > 0 && await te(M[a - 1]);
|
|
75
|
+
let o = a < M.length;
|
|
76
|
+
try {
|
|
77
|
+
let r = await fetch(e, t);
|
|
78
|
+
if (o && n && N.has(r.status)) continue;
|
|
79
|
+
return r;
|
|
80
|
+
} catch (e) {
|
|
81
|
+
if (i = e, o && r) continue;
|
|
82
|
+
throw e;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
throw i ?? /* @__PURE__ */ Error("fetchWithRetry: retries exhausted");
|
|
86
|
+
}, ne = (e) => {
|
|
194
87
|
try {
|
|
195
88
|
let t = e.split(".")[1].replace(/-/g, "+").replace(/_/g, "/"), { exp: n } = JSON.parse(atob(t));
|
|
196
|
-
return typeof n == "number" && Date.now() / 1e3 >= n -
|
|
89
|
+
return typeof n == "number" && Date.now() / 1e3 >= n - ee;
|
|
197
90
|
} catch {
|
|
198
91
|
return !1;
|
|
199
92
|
}
|
|
200
|
-
},
|
|
201
|
-
let n =
|
|
202
|
-
if (n &&
|
|
203
|
-
n = await
|
|
93
|
+
}, re = async (e, t = {}) => {
|
|
94
|
+
let n = v();
|
|
95
|
+
if (n && ne(n)) try {
|
|
96
|
+
n = await j();
|
|
204
97
|
} catch {
|
|
205
|
-
n =
|
|
98
|
+
n = v();
|
|
206
99
|
}
|
|
207
100
|
let r = { ...t.headers };
|
|
208
101
|
n && (r.Authorization = `Bearer ${n}`);
|
|
209
|
-
let i = await
|
|
102
|
+
let i = await I(e, {
|
|
210
103
|
...t,
|
|
211
104
|
headers: r
|
|
212
105
|
});
|
|
213
106
|
if (i.status !== 401 || !n) return i;
|
|
214
107
|
try {
|
|
215
|
-
return r.Authorization = `Bearer ${await
|
|
108
|
+
return r.Authorization = `Bearer ${await j()}`, await I(e, {
|
|
216
109
|
...t,
|
|
217
110
|
headers: r
|
|
218
111
|
});
|
|
219
112
|
} catch {
|
|
220
113
|
return i;
|
|
221
114
|
}
|
|
222
|
-
},
|
|
115
|
+
}, ie = class {
|
|
223
116
|
baseURL;
|
|
224
117
|
constructor(e) {
|
|
225
|
-
this.baseURL = e.baseURL,
|
|
118
|
+
this.baseURL = e.baseURL, A({
|
|
226
119
|
baseURL: e.baseURL,
|
|
227
120
|
onUnauthorized: e.onUnauthorized
|
|
228
121
|
});
|
|
@@ -231,7 +124,7 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
|
|
|
231
124
|
let n = {
|
|
232
125
|
"Content-Type": "application/json",
|
|
233
126
|
...t.headers
|
|
234
|
-
}, r = await
|
|
127
|
+
}, r = await re(`${this.baseURL}${e}`, {
|
|
235
128
|
...t,
|
|
236
129
|
headers: n
|
|
237
130
|
});
|
|
@@ -281,53 +174,53 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
|
|
|
281
174
|
method: "DELETE"
|
|
282
175
|
});
|
|
283
176
|
}
|
|
284
|
-
},
|
|
285
|
-
|
|
286
|
-
},
|
|
177
|
+
}, L, ae = (e) => {
|
|
178
|
+
L = new ie(e);
|
|
179
|
+
}, R = "astrogators_ally_codes", oe = "astrogators_selected_ally_code", z = () => {
|
|
287
180
|
try {
|
|
288
|
-
let e = localStorage.getItem(
|
|
181
|
+
let e = localStorage.getItem(R);
|
|
289
182
|
return e ? JSON.parse(e) : [];
|
|
290
183
|
} catch (e) {
|
|
291
184
|
return console.error("Failed to read ally codes from localStorage:", e), [];
|
|
292
185
|
}
|
|
293
|
-
},
|
|
186
|
+
}, se = (e) => {
|
|
294
187
|
try {
|
|
295
|
-
let t =
|
|
188
|
+
let t = z();
|
|
296
189
|
if (t.some((t) => t.ally_code === e.ally_code)) return;
|
|
297
|
-
t.push(e), localStorage.setItem(
|
|
190
|
+
t.push(e), localStorage.setItem(R, JSON.stringify(t));
|
|
298
191
|
} catch (e) {
|
|
299
192
|
console.error("Failed to save ally code to localStorage:", e);
|
|
300
193
|
}
|
|
301
|
-
},
|
|
194
|
+
}, ce = (e) => {
|
|
302
195
|
try {
|
|
303
|
-
let t =
|
|
304
|
-
localStorage.setItem(
|
|
196
|
+
let t = z().filter((t) => t.ally_code !== e);
|
|
197
|
+
localStorage.setItem(R, JSON.stringify(t));
|
|
305
198
|
} catch (e) {
|
|
306
199
|
console.error("Failed to remove ally code from localStorage:", e);
|
|
307
200
|
}
|
|
308
|
-
},
|
|
201
|
+
}, le = (e) => {
|
|
309
202
|
try {
|
|
310
|
-
let t =
|
|
203
|
+
let t = z().map((t) => t.ally_code === e ? {
|
|
311
204
|
...t,
|
|
312
205
|
last_used_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
313
206
|
} : t);
|
|
314
|
-
localStorage.setItem(
|
|
207
|
+
localStorage.setItem(R, JSON.stringify(t));
|
|
315
208
|
} catch (e) {
|
|
316
209
|
console.error("Failed to update ally code last used:", e);
|
|
317
210
|
}
|
|
318
|
-
},
|
|
319
|
-
e ? localStorage.setItem(
|
|
320
|
-
},
|
|
321
|
-
localStorage.removeItem(
|
|
322
|
-
},
|
|
323
|
-
let [
|
|
211
|
+
}, ue = () => localStorage.getItem(oe), B = (e) => {
|
|
212
|
+
e ? localStorage.setItem(oe, e) : localStorage.removeItem(oe);
|
|
213
|
+
}, de = () => {
|
|
214
|
+
localStorage.removeItem(R), localStorage.removeItem(oe);
|
|
215
|
+
}, fe = t(void 0), pe = ({ children: e, apiBaseUrl: t }) => {
|
|
216
|
+
let [n, i] = s(null), [o, c] = s(!0), [u, d] = s(!0), [f, p] = s(!0), [m, h] = s([]), [g, _] = s(null), [v, y] = s(!1), [b, x] = s({
|
|
324
217
|
show: !1,
|
|
325
218
|
localStorageCodes: []
|
|
326
219
|
});
|
|
327
|
-
|
|
220
|
+
ae({ baseURL: t }), a(() => {
|
|
328
221
|
(async () => {
|
|
329
222
|
try {
|
|
330
|
-
d((await
|
|
223
|
+
d((await L.get("/api/v1/config/features")).auth_enabled);
|
|
331
224
|
} catch (e) {
|
|
332
225
|
console.error("Failed to fetch features:", e), d(!0);
|
|
333
226
|
} finally {
|
|
@@ -335,151 +228,151 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
|
|
|
335
228
|
}
|
|
336
229
|
})();
|
|
337
230
|
}, [t]);
|
|
338
|
-
let S =
|
|
339
|
-
if (!
|
|
340
|
-
|
|
231
|
+
let S = r(async () => {
|
|
232
|
+
if (!E()) {
|
|
233
|
+
i(null), c(!1);
|
|
341
234
|
return;
|
|
342
235
|
}
|
|
343
236
|
try {
|
|
344
|
-
|
|
237
|
+
i(await L.get("/api/v1/users/me"));
|
|
345
238
|
} catch (e) {
|
|
346
|
-
console.error("Failed to fetch user:", e),
|
|
239
|
+
console.error("Failed to fetch user:", e), i(null), T();
|
|
347
240
|
} finally {
|
|
348
|
-
|
|
241
|
+
c(!1);
|
|
349
242
|
}
|
|
350
243
|
}, []);
|
|
351
|
-
|
|
244
|
+
a(() => {
|
|
352
245
|
S();
|
|
353
246
|
}, [S]);
|
|
354
247
|
let C = async (e) => {
|
|
355
248
|
try {
|
|
356
|
-
let t = await
|
|
357
|
-
|
|
249
|
+
let t = await L.post("/api/v1/auth/login", e);
|
|
250
|
+
w(t.access_token, t.refresh_token), i(await L.get("/api/v1/users/me"));
|
|
358
251
|
} catch (e) {
|
|
359
252
|
throw console.error("Login failed:", e), e;
|
|
360
253
|
}
|
|
361
|
-
},
|
|
254
|
+
}, D = async (e) => {
|
|
362
255
|
try {
|
|
363
|
-
await
|
|
256
|
+
await L.post("/api/v1/auth/register", e);
|
|
364
257
|
} catch (e) {
|
|
365
258
|
throw console.error("Registration failed:", e), e;
|
|
366
259
|
}
|
|
367
|
-
},
|
|
368
|
-
|
|
260
|
+
}, O = () => {
|
|
261
|
+
T(), i(null), h([]), _(null), B(null), x({
|
|
369
262
|
show: !1,
|
|
370
263
|
localStorageCodes: []
|
|
371
264
|
});
|
|
372
|
-
},
|
|
265
|
+
}, k = async () => {
|
|
373
266
|
await S();
|
|
374
|
-
},
|
|
267
|
+
}, A = async (e) => {
|
|
375
268
|
try {
|
|
376
|
-
return (await
|
|
269
|
+
return (await L.post("/api/v1/auth/forgot-password", e)).message;
|
|
377
270
|
} catch (e) {
|
|
378
271
|
throw console.error("Forgot password failed:", e), e;
|
|
379
272
|
}
|
|
380
|
-
},
|
|
273
|
+
}, j = async (e) => {
|
|
381
274
|
try {
|
|
382
|
-
return (await
|
|
275
|
+
return (await L.post("/api/v1/auth/reset-password", e)).message;
|
|
383
276
|
} catch (e) {
|
|
384
277
|
throw console.error("Reset password failed:", e), e;
|
|
385
278
|
}
|
|
386
|
-
},
|
|
279
|
+
}, ee = async (e) => {
|
|
387
280
|
try {
|
|
388
|
-
return (await
|
|
281
|
+
return (await L.post("/api/v1/auth/resend-verification", e)).message;
|
|
389
282
|
} catch (e) {
|
|
390
283
|
throw console.error("Resend verification failed:", e), e;
|
|
391
284
|
}
|
|
392
|
-
}, M =
|
|
285
|
+
}, M = r(async () => {
|
|
393
286
|
y(!0);
|
|
394
287
|
try {
|
|
395
288
|
let e = [];
|
|
396
|
-
if (
|
|
397
|
-
let t = await
|
|
289
|
+
if (n) {
|
|
290
|
+
let t = await L.get("/api/v1/users/me/ally-codes");
|
|
398
291
|
h(t.ally_codes), e = t.ally_codes.map((e) => e.ally_code);
|
|
399
|
-
let n =
|
|
292
|
+
let n = z();
|
|
400
293
|
n.length > 0 && x({
|
|
401
294
|
show: !0,
|
|
402
295
|
localStorageCodes: n.map((e) => e.ally_code)
|
|
403
296
|
});
|
|
404
297
|
} else {
|
|
405
|
-
let t =
|
|
298
|
+
let t = z();
|
|
406
299
|
h(t), e = t.map((e) => e.ally_code);
|
|
407
300
|
}
|
|
408
|
-
let t =
|
|
409
|
-
_(
|
|
301
|
+
let t = ue(), r = t && e.includes(t) ? t : null;
|
|
302
|
+
_(r), r !== t && B(r);
|
|
410
303
|
} catch (e) {
|
|
411
304
|
console.error("Failed to fetch ally codes:", e), h([]);
|
|
412
305
|
} finally {
|
|
413
306
|
y(!1);
|
|
414
307
|
}
|
|
415
|
-
}, [
|
|
416
|
-
|
|
417
|
-
}, [
|
|
418
|
-
if (_(e),
|
|
308
|
+
}, [n]), N = r(async (e) => {
|
|
309
|
+
n && typeof e == "number" ? (await L.put(`/api/v1/users/me/ally-codes/${e}/use`, {}), await M()) : !n && typeof e == "string" && (le(e), h(z()));
|
|
310
|
+
}, [n, M]), P = r((e) => {
|
|
311
|
+
if (_(e), B(e), e && n) {
|
|
419
312
|
let t = m.find((t) => "ally_code" in t && t.ally_code === e);
|
|
420
313
|
t && "id" in t && N(t.id);
|
|
421
|
-
} else e && !
|
|
314
|
+
} else e && !n && le(e);
|
|
422
315
|
}, [
|
|
423
|
-
|
|
316
|
+
n,
|
|
424
317
|
m,
|
|
425
318
|
N
|
|
426
|
-
]), F =
|
|
319
|
+
]), F = r(async (e) => {
|
|
427
320
|
if (!/^\d{9}$/.test(e)) throw Error("Ally code must be exactly 9 digits");
|
|
428
|
-
if (
|
|
429
|
-
let t = await
|
|
321
|
+
if (n) {
|
|
322
|
+
let t = await L.post("/api/v1/users/me/ally-codes", { ally_code: e });
|
|
430
323
|
h((e) => [t, ...e]), m.length === 0 && P(e);
|
|
431
324
|
} else {
|
|
432
|
-
let t = await
|
|
325
|
+
let t = await L.get(`/api/v1/player-data/player/${e}`);
|
|
433
326
|
if (!t) throw Error("Invalid ally code - player not found");
|
|
434
|
-
|
|
327
|
+
se({
|
|
435
328
|
ally_code: e,
|
|
436
329
|
player_name: t.data?.name ?? null,
|
|
437
330
|
last_used_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
438
|
-
}), h(
|
|
331
|
+
}), h(z()), m.length === 0 && P(e);
|
|
439
332
|
}
|
|
440
333
|
}, [
|
|
441
|
-
|
|
334
|
+
n,
|
|
442
335
|
m.length,
|
|
443
336
|
P
|
|
444
|
-
]),
|
|
445
|
-
|
|
337
|
+
]), te = r(async (e) => {
|
|
338
|
+
n && typeof e == "number" ? (await L.delete(`/api/v1/users/me/ally-codes/${e}`), h((t) => t.filter((t) => "id" in t && t.id !== e))) : !n && typeof e == "string" && (ce(e), h(z()), g === e && P(null));
|
|
446
339
|
}, [
|
|
447
|
-
|
|
340
|
+
n,
|
|
448
341
|
g,
|
|
449
342
|
P
|
|
450
|
-
]),
|
|
343
|
+
]), I = r(() => {
|
|
451
344
|
x({
|
|
452
345
|
show: !1,
|
|
453
346
|
localStorageCodes: []
|
|
454
347
|
});
|
|
455
|
-
}, []),
|
|
456
|
-
if (!
|
|
457
|
-
let e =
|
|
348
|
+
}, []), ne = r(async () => {
|
|
349
|
+
if (!n) return;
|
|
350
|
+
let e = z();
|
|
458
351
|
for (let t of e) try {
|
|
459
352
|
await F(t.ally_code);
|
|
460
353
|
} catch (e) {
|
|
461
354
|
console.error(`Failed to migrate ally code ${t.ally_code}:`, e);
|
|
462
355
|
}
|
|
463
|
-
|
|
356
|
+
de(), I();
|
|
464
357
|
}, [
|
|
465
|
-
|
|
358
|
+
n,
|
|
466
359
|
F,
|
|
467
|
-
|
|
360
|
+
I
|
|
468
361
|
]);
|
|
469
|
-
|
|
362
|
+
a(() => {
|
|
470
363
|
M();
|
|
471
364
|
}, [M]);
|
|
472
|
-
let
|
|
473
|
-
user:
|
|
474
|
-
isAuthenticated: !!
|
|
475
|
-
isLoading:
|
|
365
|
+
let re = {
|
|
366
|
+
user: n,
|
|
367
|
+
isAuthenticated: !!n,
|
|
368
|
+
isLoading: o,
|
|
476
369
|
login: C,
|
|
477
|
-
register:
|
|
478
|
-
logout:
|
|
479
|
-
refreshUser:
|
|
480
|
-
forgotPassword:
|
|
481
|
-
resetPassword:
|
|
482
|
-
resendVerification:
|
|
370
|
+
register: D,
|
|
371
|
+
logout: O,
|
|
372
|
+
refreshUser: k,
|
|
373
|
+
forgotPassword: A,
|
|
374
|
+
resetPassword: j,
|
|
375
|
+
resendVerification: ee,
|
|
483
376
|
authEnabled: u,
|
|
484
377
|
isLoadingFeatures: f,
|
|
485
378
|
allyCodes: m,
|
|
@@ -487,229 +380,690 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
|
|
|
487
380
|
isLoadingAllyCodes: v,
|
|
488
381
|
fetchAllyCodes: M,
|
|
489
382
|
addAllyCode: F,
|
|
490
|
-
removeAllyCode:
|
|
383
|
+
removeAllyCode: te,
|
|
491
384
|
selectAllyCode: P,
|
|
492
385
|
updateAllyCodeLastUsed: N,
|
|
493
386
|
migrationPrompt: b,
|
|
494
|
-
dismissMigrationPrompt:
|
|
495
|
-
migrateLocalStorageCodes:
|
|
387
|
+
dismissMigrationPrompt: I,
|
|
388
|
+
migrateLocalStorageCodes: ne
|
|
496
389
|
};
|
|
497
|
-
return /* @__PURE__ */
|
|
498
|
-
value:
|
|
390
|
+
return /* @__PURE__ */ l(fe.Provider, {
|
|
391
|
+
value: re,
|
|
499
392
|
children: e
|
|
500
393
|
});
|
|
501
|
-
},
|
|
502
|
-
let e =
|
|
394
|
+
}, V = () => {
|
|
395
|
+
let e = i(fe);
|
|
503
396
|
if (e === void 0) throw Error("useAuth must be used within an AuthProvider");
|
|
504
397
|
return e;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
398
|
+
};
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/hooks/useDismissableMenu.ts
|
|
401
|
+
function me({ isOpen: e, onClose: t, triggerRef: n, panelRef: r }) {
|
|
402
|
+
a(() => {
|
|
403
|
+
if (!e) return;
|
|
404
|
+
let i = (e) => {
|
|
405
|
+
let i = e.target;
|
|
406
|
+
n.current?.contains(i) || r.current?.contains(i) || t();
|
|
407
|
+
}, a = (e) => {
|
|
408
|
+
e.key === "Escape" && (t(), n.current?.focus());
|
|
409
|
+
};
|
|
410
|
+
return document.addEventListener("mousedown", i), document.addEventListener("keydown", a), () => {
|
|
411
|
+
document.removeEventListener("mousedown", i), document.removeEventListener("keydown", a);
|
|
412
|
+
};
|
|
413
|
+
}, [
|
|
414
|
+
e,
|
|
415
|
+
t,
|
|
416
|
+
n,
|
|
417
|
+
r
|
|
418
|
+
]);
|
|
419
|
+
}
|
|
420
|
+
var H = {
|
|
421
|
+
navMenu: "_navMenu_b9xlf_1",
|
|
422
|
+
trigger: "_trigger_b9xlf_8",
|
|
423
|
+
tabActive: "_tabActive_b9xlf_29",
|
|
424
|
+
chevron: "_chevron_b9xlf_34",
|
|
425
|
+
panel: "_panel_b9xlf_43",
|
|
426
|
+
sectionLink: "_sectionLink_b9xlf_57",
|
|
427
|
+
sectionActive: "_sectionActive_b9xlf_71",
|
|
428
|
+
comingSoon: "_comingSoon_b9xlf_76"
|
|
429
|
+
}, he = ({ app: e, isCurrentApp: t, activeSectionId: n, isOpen: r, onOpenChange: i, onSectionClick: a }) => {
|
|
430
|
+
let { isAuthenticated: s, user: c } = V(), d = o(null), f = o(null), p = `navmenu-panel-${e.id}`;
|
|
431
|
+
me({
|
|
432
|
+
isOpen: r,
|
|
433
|
+
onClose: () => i(!1),
|
|
434
|
+
triggerRef: d,
|
|
435
|
+
panelRef: f
|
|
436
|
+
});
|
|
437
|
+
let m = e.sections.filter((e) => !(e.requiresAuth && !s || e.roles && (!c || !e.roles.includes(c.role)))), h = (e) => (n) => {
|
|
438
|
+
t && a?.(e, n), i(!1);
|
|
439
|
+
};
|
|
440
|
+
return /* @__PURE__ */ u("div", {
|
|
441
|
+
className: H.navMenu,
|
|
442
|
+
children: [/* @__PURE__ */ u("button", {
|
|
443
|
+
type: "button",
|
|
444
|
+
ref: d,
|
|
445
|
+
className: `${H.trigger} ${t ? H.tabActive : ""}`,
|
|
446
|
+
"aria-expanded": r,
|
|
447
|
+
"aria-controls": p,
|
|
448
|
+
"aria-haspopup": "true",
|
|
449
|
+
onClick: () => i(!r),
|
|
450
|
+
children: [e.label, /* @__PURE__ */ l("svg", {
|
|
451
|
+
className: H.chevron,
|
|
452
|
+
width: "10",
|
|
453
|
+
height: "6",
|
|
454
|
+
viewBox: "0 0 10 6",
|
|
455
|
+
"aria-hidden": "true",
|
|
456
|
+
children: /* @__PURE__ */ l("path", {
|
|
457
|
+
d: "M1 1l4 4 4-4",
|
|
458
|
+
stroke: "currentColor",
|
|
459
|
+
strokeWidth: "1.5",
|
|
460
|
+
fill: "none",
|
|
461
|
+
strokeLinecap: "round",
|
|
462
|
+
strokeLinejoin: "round"
|
|
463
|
+
})
|
|
464
|
+
})]
|
|
465
|
+
}), r && /* @__PURE__ */ l("div", {
|
|
466
|
+
id: p,
|
|
467
|
+
ref: f,
|
|
468
|
+
className: H.panel,
|
|
469
|
+
children: e.status === "coming-soon" ? /* @__PURE__ */ l("div", {
|
|
470
|
+
className: H.comingSoon,
|
|
471
|
+
children: "Coming soon"
|
|
472
|
+
}) : /* @__PURE__ */ l("nav", {
|
|
473
|
+
"aria-label": `${e.label} sections`,
|
|
474
|
+
onKeyDown: (e) => {
|
|
475
|
+
if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
|
|
476
|
+
let t = Array.from(e.currentTarget.querySelectorAll("a")), n = t.indexOf(document.activeElement);
|
|
477
|
+
n !== -1 && (e.preventDefault(), t[e.key === "ArrowDown" ? (n + 1) % t.length : (n - 1 + t.length) % t.length]?.focus());
|
|
478
|
+
},
|
|
479
|
+
children: m.map((e) => {
|
|
480
|
+
let r = t && n === e.id;
|
|
481
|
+
return /* @__PURE__ */ l("a", {
|
|
482
|
+
href: e.href,
|
|
483
|
+
className: `${H.sectionLink} ${r ? H.sectionActive : ""}`,
|
|
484
|
+
"aria-current": r ? "page" : void 0,
|
|
485
|
+
onClick: h(e),
|
|
486
|
+
children: e.label
|
|
487
|
+
}, e.id);
|
|
488
|
+
})
|
|
489
|
+
})
|
|
490
|
+
})]
|
|
491
|
+
});
|
|
492
|
+
}, ge = { burger: "_burger_javjr_1" }, _e = n(({ isOpen: e, onClick: t, controlsId: n }, r) => /* @__PURE__ */ l("button", {
|
|
493
|
+
ref: r,
|
|
494
|
+
type: "button",
|
|
495
|
+
className: ge.burger,
|
|
496
|
+
onClick: t,
|
|
497
|
+
"aria-expanded": e,
|
|
498
|
+
"aria-controls": n,
|
|
499
|
+
"aria-label": e ? "Close navigation menu" : "Open navigation menu",
|
|
500
|
+
children: e ? /* @__PURE__ */ l("svg", {
|
|
501
|
+
width: "20",
|
|
502
|
+
height: "20",
|
|
503
|
+
viewBox: "0 0 20 20",
|
|
504
|
+
"aria-hidden": "true",
|
|
505
|
+
children: /* @__PURE__ */ l("path", {
|
|
506
|
+
d: "M4 4l12 12M16 4L4 16",
|
|
507
|
+
stroke: "currentColor",
|
|
508
|
+
strokeWidth: "2",
|
|
509
|
+
strokeLinecap: "round"
|
|
510
|
+
})
|
|
511
|
+
}) : /* @__PURE__ */ l("svg", {
|
|
512
|
+
width: "20",
|
|
513
|
+
height: "20",
|
|
514
|
+
viewBox: "0 0 20 20",
|
|
515
|
+
"aria-hidden": "true",
|
|
516
|
+
children: /* @__PURE__ */ l("path", {
|
|
517
|
+
d: "M2 5h16M2 10h16M2 15h16",
|
|
518
|
+
stroke: "currentColor",
|
|
519
|
+
strokeWidth: "2",
|
|
520
|
+
strokeLinecap: "round"
|
|
521
|
+
})
|
|
522
|
+
})
|
|
523
|
+
}));
|
|
524
|
+
_e.displayName = "NavBurger";
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region src/navigation/suiteNav.ts
|
|
527
|
+
var ve = [
|
|
528
|
+
{
|
|
529
|
+
id: "mod-ledger",
|
|
530
|
+
label: "Mod Ledger",
|
|
531
|
+
href: "/mod-ledger/",
|
|
532
|
+
status: "available",
|
|
533
|
+
sections: [
|
|
534
|
+
{
|
|
535
|
+
id: "grid",
|
|
536
|
+
label: "Grid",
|
|
537
|
+
href: "/mod-ledger/"
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
id: "evaluations",
|
|
541
|
+
label: "Evaluations",
|
|
542
|
+
href: "/mod-ledger/evaluations"
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
id: "moderation",
|
|
546
|
+
label: "Moderation",
|
|
547
|
+
href: "/mod-ledger/moderation",
|
|
548
|
+
roles: ["admin", "mod"]
|
|
549
|
+
}
|
|
550
|
+
]
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
id: "navicharts",
|
|
554
|
+
label: "Navicharts",
|
|
555
|
+
href: "/navicharts/",
|
|
556
|
+
status: "available",
|
|
557
|
+
sections: [{
|
|
558
|
+
id: "library",
|
|
559
|
+
label: "My Star Charts",
|
|
560
|
+
href: "/navicharts/"
|
|
561
|
+
}]
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
id: "nightwatcher",
|
|
565
|
+
label: "Nightwatcher",
|
|
566
|
+
href: "/nightwatcher/",
|
|
567
|
+
status: "available",
|
|
568
|
+
sections: [{
|
|
569
|
+
id: "overview",
|
|
570
|
+
label: "Overview",
|
|
571
|
+
href: "/nightwatcher/"
|
|
572
|
+
}]
|
|
573
|
+
}
|
|
574
|
+
], U = {
|
|
575
|
+
selectWrapper: "_selectWrapper_ir4bq_1",
|
|
576
|
+
fullWidth: "_fullWidth_ir4bq_7",
|
|
577
|
+
label: "_label_ir4bq_11",
|
|
578
|
+
required: "_required_ir4bq_20",
|
|
579
|
+
selectContainer: "_selectContainer_ir4bq_24",
|
|
580
|
+
select: "_select_ir4bq_1",
|
|
581
|
+
error: "_error_ir4bq_63",
|
|
582
|
+
arrow: "_arrow_ir4bq_71",
|
|
583
|
+
errorText: "_errorText_ir4bq_81",
|
|
584
|
+
helperText: "_helperText_ir4bq_86"
|
|
585
|
+
}, ye = e.forwardRef(({ label: e, error: t, helperText: n, options: r, placeholder: i, fullWidth: a = !1, className: o = "", id: s, ...c }, d) => {
|
|
586
|
+
let f = s || `select-${Math.random().toString(36).substr(2, 9)}`, p = !!t;
|
|
587
|
+
return /* @__PURE__ */ u("div", {
|
|
588
|
+
className: `${U.selectWrapper} ${a ? U.fullWidth : ""} ${o}`,
|
|
589
|
+
children: [
|
|
590
|
+
e && /* @__PURE__ */ u("label", {
|
|
591
|
+
htmlFor: f,
|
|
592
|
+
className: U.label,
|
|
593
|
+
children: [e, c.required && /* @__PURE__ */ l("span", {
|
|
594
|
+
className: U.required,
|
|
595
|
+
children: "*"
|
|
596
|
+
})]
|
|
597
|
+
}),
|
|
598
|
+
/* @__PURE__ */ u("div", {
|
|
599
|
+
className: U.selectContainer,
|
|
600
|
+
children: [/* @__PURE__ */ u("select", {
|
|
601
|
+
ref: d,
|
|
602
|
+
id: f,
|
|
603
|
+
className: `${U.select} ${p ? U.error : ""}`,
|
|
604
|
+
...c,
|
|
605
|
+
children: [
|
|
606
|
+
i && /* @__PURE__ */ l("option", {
|
|
607
|
+
value: "",
|
|
608
|
+
disabled: !0,
|
|
609
|
+
children: i
|
|
610
|
+
}),
|
|
611
|
+
r && r.map((e) => /* @__PURE__ */ l("option", {
|
|
612
|
+
value: e.value,
|
|
613
|
+
disabled: e.disabled,
|
|
614
|
+
children: e.label
|
|
615
|
+
}, e.value)),
|
|
616
|
+
!r && c.children
|
|
617
|
+
]
|
|
618
|
+
}), /* @__PURE__ */ l("span", {
|
|
619
|
+
className: U.arrow,
|
|
620
|
+
children: "▼"
|
|
621
|
+
})]
|
|
622
|
+
}),
|
|
623
|
+
t && /* @__PURE__ */ l("span", {
|
|
624
|
+
className: U.errorText,
|
|
625
|
+
children: t
|
|
626
|
+
}),
|
|
627
|
+
n && !t && /* @__PURE__ */ l("span", {
|
|
628
|
+
className: U.helperText,
|
|
629
|
+
children: n
|
|
630
|
+
})
|
|
631
|
+
]
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
ye.displayName = "Select";
|
|
635
|
+
var W = {
|
|
636
|
+
button: "_button_159ms_1",
|
|
637
|
+
sm: "_sm_159ms_22",
|
|
638
|
+
md: "_md_159ms_28",
|
|
639
|
+
lg: "_lg_159ms_34",
|
|
640
|
+
primary: "_primary_159ms_41",
|
|
641
|
+
secondary: "_secondary_159ms_55",
|
|
642
|
+
outline: "_outline_159ms_69",
|
|
643
|
+
ghost: "_ghost_159ms_80",
|
|
644
|
+
danger: "_danger_159ms_89",
|
|
645
|
+
fullWidth: "_fullWidth_159ms_100",
|
|
646
|
+
loading: "_loading_159ms_105",
|
|
647
|
+
loadingSpinner: "_loadingSpinner_159ms_110",
|
|
648
|
+
spinner: "_spinner_159ms_116",
|
|
649
|
+
spin: "_spin_159ms_116",
|
|
650
|
+
loadingText: "_loadingText_159ms_131"
|
|
651
|
+
}, G = ({ children: e, variant: t = "primary", size: n = "md", fullWidth: r = !1, loading: i = !1, disabled: a = !1, className: o = "", ...s }) => /* @__PURE__ */ l("button", {
|
|
652
|
+
className: `${W.button} ${W[t]} ${W[n]} ${r ? W.fullWidth : ""} ${i ? W.loading : ""} ${o}`,
|
|
653
|
+
disabled: a || i,
|
|
654
|
+
...s,
|
|
655
|
+
children: i ? /* @__PURE__ */ u("span", {
|
|
656
|
+
className: W.loadingSpinner,
|
|
657
|
+
children: [/* @__PURE__ */ l("span", { className: W.spinner }), /* @__PURE__ */ l("span", {
|
|
658
|
+
className: W.loadingText,
|
|
659
|
+
children: e
|
|
660
|
+
})]
|
|
661
|
+
}) : e
|
|
662
|
+
}), K = {
|
|
663
|
+
inputWrapper: "_inputWrapper_15t4g_1",
|
|
664
|
+
fullWidth: "_fullWidth_15t4g_7",
|
|
665
|
+
label: "_label_15t4g_11",
|
|
666
|
+
required: "_required_15t4g_20",
|
|
667
|
+
input: "_input_15t4g_1",
|
|
668
|
+
error: "_error_15t4g_55",
|
|
669
|
+
errorText: "_errorText_15t4g_63",
|
|
670
|
+
helperText: "_helperText_15t4g_68"
|
|
671
|
+
}, be = e.forwardRef(({ label: e, error: t, helperText: n, fullWidth: r = !1, className: i = "", id: a, ...o }, s) => {
|
|
672
|
+
let c = a || `input-${Math.random().toString(36).substr(2, 9)}`, d = !!t;
|
|
673
|
+
return /* @__PURE__ */ u("div", {
|
|
674
|
+
className: `${K.inputWrapper} ${r ? K.fullWidth : ""} ${i}`,
|
|
675
|
+
children: [
|
|
676
|
+
e && /* @__PURE__ */ u("label", {
|
|
677
|
+
htmlFor: c,
|
|
678
|
+
className: K.label,
|
|
679
|
+
children: [e, o.required && /* @__PURE__ */ l("span", {
|
|
680
|
+
className: K.required,
|
|
681
|
+
children: "*"
|
|
682
|
+
})]
|
|
683
|
+
}),
|
|
684
|
+
/* @__PURE__ */ l("input", {
|
|
685
|
+
ref: s,
|
|
686
|
+
id: c,
|
|
687
|
+
className: `${K.input} ${d ? K.error : ""}`,
|
|
688
|
+
...o
|
|
689
|
+
}),
|
|
690
|
+
t && /* @__PURE__ */ l("span", {
|
|
691
|
+
className: K.errorText,
|
|
692
|
+
children: t
|
|
693
|
+
}),
|
|
694
|
+
n && !t && /* @__PURE__ */ l("span", {
|
|
695
|
+
className: K.helperText,
|
|
696
|
+
children: n
|
|
697
|
+
})
|
|
698
|
+
]
|
|
699
|
+
});
|
|
700
|
+
});
|
|
701
|
+
be.displayName = "Input";
|
|
702
|
+
//#endregion
|
|
703
|
+
//#region src/utils/formatAllyCode.ts
|
|
704
|
+
var q = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e.slice(6, 9)}`, xe = (e) => e.replace(/-/g, ""), J = {
|
|
705
|
+
allyCodeDropdown: "_allyCodeDropdown_1pawi_1",
|
|
706
|
+
select: "_select_1pawi_8",
|
|
707
|
+
manageButton: "_manageButton_1pawi_12",
|
|
708
|
+
managePanel: "_managePanel_1pawi_16",
|
|
709
|
+
addSection: "_addSection_1pawi_37",
|
|
710
|
+
addInputGroup: "_addInputGroup_1pawi_43",
|
|
711
|
+
error: "_error_1pawi_55",
|
|
712
|
+
success: "_success_1pawi_61",
|
|
713
|
+
codesList: "_codesList_1pawi_67",
|
|
714
|
+
codeItem: "_codeItem_1pawi_71",
|
|
715
|
+
doneButton: "_doneButton_1pawi_88",
|
|
716
|
+
inline: "_inline_1pawi_107"
|
|
717
|
+
}, Se = ({ onAllyCodeSelected: e, className: t = "", isOpen: n, onOpenChange: r, variant: i = "floating" }) => {
|
|
718
|
+
let { allyCodes: a, selectedAllyCode: c, selectAllyCode: d, removeAllyCode: f, addAllyCode: p, isLoadingAllyCodes: m } = V(), [h, g] = s(!1), _ = n ?? h, v = (e) => {
|
|
719
|
+
g(e), r?.(e);
|
|
720
|
+
}, [y, b] = s(""), [x, S] = s(""), [C, w] = s(""), [T, E] = s(!1), D = o(null), O = o(null);
|
|
721
|
+
me({
|
|
722
|
+
isOpen: _ && i === "floating",
|
|
723
|
+
onClose: () => v(!1),
|
|
724
|
+
triggerRef: D,
|
|
725
|
+
panelRef: O
|
|
726
|
+
});
|
|
727
|
+
let k = a.map((e) => ({
|
|
519
728
|
value: e.ally_code,
|
|
520
|
-
label: e.player_name ? `${e.player_name} (${
|
|
521
|
-
})),
|
|
729
|
+
label: e.player_name ? `${e.player_name} (${q(e.ally_code)})` : q(e.ally_code)
|
|
730
|
+
})), A = (t) => {
|
|
522
731
|
let n = t.target.value || null;
|
|
523
|
-
|
|
524
|
-
},
|
|
525
|
-
let t =
|
|
526
|
-
t && await
|
|
527
|
-
},
|
|
528
|
-
if (
|
|
529
|
-
|
|
732
|
+
d(n), e?.(n);
|
|
733
|
+
}, j = async (e) => {
|
|
734
|
+
let t = a.find((t) => t.ally_code === e);
|
|
735
|
+
t && await f("id" in t ? t.id : t.ally_code);
|
|
736
|
+
}, ee = async () => {
|
|
737
|
+
if (S(""), w(""), !/^\d{9}$/.test(y)) {
|
|
738
|
+
S("Ally code must be exactly 9 digits");
|
|
530
739
|
return;
|
|
531
740
|
}
|
|
532
|
-
|
|
741
|
+
E(!0);
|
|
533
742
|
try {
|
|
534
|
-
await
|
|
743
|
+
await p(y), w("Added successfully!"), b(""), setTimeout(() => w(""), 2e3);
|
|
535
744
|
} catch (e) {
|
|
536
|
-
|
|
745
|
+
S(e.message || "Failed to add ally code");
|
|
537
746
|
} finally {
|
|
538
|
-
|
|
747
|
+
E(!1);
|
|
539
748
|
}
|
|
540
|
-
},
|
|
541
|
-
return /* @__PURE__ */
|
|
542
|
-
className: `${
|
|
749
|
+
}, M = a.length > 0;
|
|
750
|
+
return /* @__PURE__ */ u("div", {
|
|
751
|
+
className: `${J.allyCodeDropdown} ${i === "inline" ? J.inline : ""} ${t}`,
|
|
543
752
|
children: [
|
|
544
|
-
|
|
545
|
-
options:
|
|
546
|
-
value:
|
|
547
|
-
onChange:
|
|
753
|
+
M && /* @__PURE__ */ l(ye, {
|
|
754
|
+
options: k,
|
|
755
|
+
value: c || "",
|
|
756
|
+
onChange: A,
|
|
548
757
|
placeholder: "Select ally code",
|
|
549
|
-
disabled:
|
|
550
|
-
className:
|
|
758
|
+
disabled: m,
|
|
759
|
+
className: J.select
|
|
551
760
|
}),
|
|
552
|
-
|
|
553
|
-
className:
|
|
761
|
+
_ && /* @__PURE__ */ u("div", {
|
|
762
|
+
className: J.managePanel,
|
|
763
|
+
ref: O,
|
|
764
|
+
id: "ally-code-manage-panel",
|
|
554
765
|
children: [
|
|
555
|
-
/* @__PURE__ */
|
|
556
|
-
/* @__PURE__ */
|
|
557
|
-
className:
|
|
766
|
+
/* @__PURE__ */ l("h4", { children: "Manage Ally Codes" }),
|
|
767
|
+
/* @__PURE__ */ u("div", {
|
|
768
|
+
className: J.addSection,
|
|
558
769
|
children: [
|
|
559
|
-
/* @__PURE__ */
|
|
560
|
-
className:
|
|
561
|
-
children: [/* @__PURE__ */
|
|
770
|
+
/* @__PURE__ */ u("div", {
|
|
771
|
+
className: J.addInputGroup,
|
|
772
|
+
children: [/* @__PURE__ */ l(be, {
|
|
562
773
|
type: "text",
|
|
563
774
|
placeholder: "9-digit ally code",
|
|
564
|
-
value:
|
|
565
|
-
onChange: (e) =>
|
|
566
|
-
disabled:
|
|
567
|
-
}), /* @__PURE__ */
|
|
775
|
+
value: y,
|
|
776
|
+
onChange: (e) => b(e.target.value.replace(/\D/g, "").slice(0, 9)),
|
|
777
|
+
disabled: T
|
|
778
|
+
}), /* @__PURE__ */ l(G, {
|
|
568
779
|
variant: "primary",
|
|
569
780
|
size: "sm",
|
|
570
|
-
onClick:
|
|
571
|
-
loading:
|
|
572
|
-
disabled:
|
|
781
|
+
onClick: ee,
|
|
782
|
+
loading: T,
|
|
783
|
+
disabled: y.length !== 9,
|
|
573
784
|
children: "Add"
|
|
574
785
|
})]
|
|
575
786
|
}),
|
|
576
|
-
|
|
577
|
-
className:
|
|
578
|
-
children:
|
|
787
|
+
x && /* @__PURE__ */ l("div", {
|
|
788
|
+
className: J.error,
|
|
789
|
+
children: x
|
|
579
790
|
}),
|
|
580
|
-
|
|
581
|
-
className:
|
|
582
|
-
children:
|
|
791
|
+
C && /* @__PURE__ */ l("div", {
|
|
792
|
+
className: J.success,
|
|
793
|
+
children: C
|
|
583
794
|
})
|
|
584
795
|
]
|
|
585
796
|
}),
|
|
586
|
-
/* @__PURE__ */
|
|
587
|
-
className:
|
|
588
|
-
children:
|
|
589
|
-
className:
|
|
590
|
-
children: [/* @__PURE__ */
|
|
797
|
+
/* @__PURE__ */ l("div", {
|
|
798
|
+
className: J.codesList,
|
|
799
|
+
children: a.map((e) => /* @__PURE__ */ u("div", {
|
|
800
|
+
className: J.codeItem,
|
|
801
|
+
children: [/* @__PURE__ */ l("span", { children: e.player_name ? `${e.player_name} (${q(e.ally_code)})` : q(e.ally_code) }), /* @__PURE__ */ l(G, {
|
|
591
802
|
variant: "ghost",
|
|
592
803
|
size: "sm",
|
|
593
|
-
onClick: () =>
|
|
804
|
+
onClick: () => j(e.ally_code),
|
|
594
805
|
children: "Remove"
|
|
595
806
|
})]
|
|
596
807
|
}, e.ally_code))
|
|
597
808
|
}),
|
|
598
|
-
/* @__PURE__ */
|
|
809
|
+
/* @__PURE__ */ l(G, {
|
|
599
810
|
variant: "secondary",
|
|
600
811
|
size: "sm",
|
|
601
|
-
onClick: () =>
|
|
602
|
-
className:
|
|
812
|
+
onClick: () => v(!1),
|
|
813
|
+
className: J.doneButton,
|
|
603
814
|
children: "Done"
|
|
604
815
|
})
|
|
605
816
|
]
|
|
606
817
|
}),
|
|
607
|
-
/* @__PURE__ */
|
|
818
|
+
/* @__PURE__ */ l("span", {
|
|
819
|
+
ref: D,
|
|
820
|
+
children: /* @__PURE__ */ l(G, {
|
|
821
|
+
variant: "ghost",
|
|
822
|
+
size: "sm",
|
|
823
|
+
onClick: () => v(!_),
|
|
824
|
+
className: J.manageButton,
|
|
825
|
+
"aria-expanded": _,
|
|
826
|
+
"aria-controls": "ally-code-manage-panel",
|
|
827
|
+
"aria-haspopup": "true",
|
|
828
|
+
children: M ? "Manage" : "+ Add ally code"
|
|
829
|
+
})
|
|
830
|
+
})
|
|
831
|
+
]
|
|
832
|
+
});
|
|
833
|
+
}, Ce = {
|
|
834
|
+
authCluster: "_authCluster_17o10_1",
|
|
835
|
+
userLink: "_userLink_17o10_7",
|
|
836
|
+
adminLink: "_adminLink_17o10_16"
|
|
837
|
+
}, we = ({ showAuth: e = !0 }) => {
|
|
838
|
+
let { user: t, isAuthenticated: n, logout: r, authEnabled: i } = V();
|
|
839
|
+
return e ? n ? /* @__PURE__ */ u("div", {
|
|
840
|
+
className: Ce.authCluster,
|
|
841
|
+
children: [
|
|
842
|
+
t?.role === "admin" && /* @__PURE__ */ l("a", {
|
|
843
|
+
href: "/admin/users",
|
|
844
|
+
className: Ce.adminLink,
|
|
845
|
+
children: "Admin"
|
|
846
|
+
}),
|
|
847
|
+
/* @__PURE__ */ l("a", {
|
|
848
|
+
href: "/profile",
|
|
849
|
+
className: Ce.userLink,
|
|
850
|
+
children: t?.username
|
|
851
|
+
}),
|
|
852
|
+
/* @__PURE__ */ l(G, {
|
|
608
853
|
variant: "ghost",
|
|
609
854
|
size: "sm",
|
|
610
|
-
onClick: () =>
|
|
611
|
-
|
|
612
|
-
|
|
855
|
+
onClick: () => {
|
|
856
|
+
r(), window.location.href = "/";
|
|
857
|
+
},
|
|
858
|
+
children: "Logout"
|
|
613
859
|
})
|
|
614
860
|
]
|
|
615
|
-
})
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
appNav: "_appNav_84pn2_9",
|
|
619
|
-
appName: "_appName_84pn2_15",
|
|
620
|
-
tabs: "_tabs_84pn2_29",
|
|
621
|
-
tab: "_tab_84pn2_29",
|
|
622
|
-
tabActive: "_tabActive_84pn2_56",
|
|
623
|
-
extrasGroup: "_extrasGroup_84pn2_64",
|
|
624
|
-
authCluster: "_authCluster_84pn2_70",
|
|
625
|
-
userLink: "_userLink_84pn2_76"
|
|
626
|
-
}, ue = ({ hubUrl: t = "/", appName: n, appHref: r = "/", navItems: i, showAllyCode: a = !1, showAuth: l = !0, rightExtras: u, className: d }) => {
|
|
627
|
-
let { user: p, isAuthenticated: h, logout: g, authEnabled: _ } = W(), v = () => {
|
|
628
|
-
g(), window.location.href = t;
|
|
629
|
-
}, y = !!u || a, b = !!(i && i.length > 0), x = !!n || b, S = l ? h ? /* @__PURE__ */ c("div", {
|
|
630
|
-
className: q.authCluster,
|
|
631
|
-
children: [/* @__PURE__ */ s("a", {
|
|
632
|
-
href: "/profile",
|
|
633
|
-
className: q.userLink,
|
|
634
|
-
children: p?.username
|
|
635
|
-
}), /* @__PURE__ */ s(m, {
|
|
636
|
-
variant: "ghost",
|
|
637
|
-
size: "sm",
|
|
638
|
-
onClick: v,
|
|
639
|
-
children: "Logout"
|
|
640
|
-
})]
|
|
641
|
-
}) : _ ? /* @__PURE__ */ c("div", {
|
|
642
|
-
className: q.authCluster,
|
|
643
|
-
children: [/* @__PURE__ */ s("a", {
|
|
861
|
+
}) : i ? /* @__PURE__ */ u("div", {
|
|
862
|
+
className: Ce.authCluster,
|
|
863
|
+
children: [/* @__PURE__ */ l("a", {
|
|
644
864
|
href: "/login",
|
|
645
|
-
children: /* @__PURE__ */
|
|
865
|
+
children: /* @__PURE__ */ l(G, {
|
|
646
866
|
variant: "ghost",
|
|
647
867
|
size: "sm",
|
|
648
868
|
children: "Login"
|
|
649
869
|
})
|
|
650
|
-
}), /* @__PURE__ */
|
|
870
|
+
}), /* @__PURE__ */ l("a", {
|
|
651
871
|
href: "/register",
|
|
652
|
-
children: /* @__PURE__ */
|
|
872
|
+
children: /* @__PURE__ */ l(G, {
|
|
653
873
|
variant: "primary",
|
|
654
874
|
size: "sm",
|
|
655
875
|
children: "Sign Up"
|
|
656
876
|
})
|
|
657
877
|
})]
|
|
658
878
|
}) : null : null;
|
|
659
|
-
|
|
879
|
+
}, Y = {
|
|
880
|
+
backdrop: "_backdrop_1n4uh_1",
|
|
881
|
+
panel: "_panel_1n4uh_11",
|
|
882
|
+
accordion: "_accordion_1n4uh_24",
|
|
883
|
+
accordionItem: "_accordionItem_1n4uh_29",
|
|
884
|
+
accordionHeader: "_accordionHeader_1n4uh_33",
|
|
885
|
+
currentApp: "_currentApp_1n4uh_48",
|
|
886
|
+
chevron: "_chevron_1n4uh_53",
|
|
887
|
+
chevronOpen: "_chevronOpen_1n4uh_58",
|
|
888
|
+
accordionPanel: "_accordionPanel_1n4uh_62",
|
|
889
|
+
sectionLink: "_sectionLink_1n4uh_68",
|
|
890
|
+
sectionActive: "_sectionActive_1n4uh_79",
|
|
891
|
+
comingSoon: "_comingSoon_1n4uh_85",
|
|
892
|
+
allySection: "_allySection_1n4uh_91",
|
|
893
|
+
extrasSection: "_extrasSection_1n4uh_92",
|
|
894
|
+
accountSection: "_accountSection_1n4uh_93"
|
|
895
|
+
}, Te = ({ isOpen: e, onClose: t, currentApp: n, activeSectionId: r, onSectionClick: i, rightExtras: c, showAuth: f, panelId: p, returnFocusRef: m }) => {
|
|
896
|
+
let { isAuthenticated: h, user: g } = V(), [_, v] = s(n === "hub" ? null : n), y = o(null);
|
|
897
|
+
if (a(() => (e ? document.body.style.overflow = "hidden" : document.body.style.overflow = "unset", () => {
|
|
898
|
+
document.body.style.overflow = "unset";
|
|
899
|
+
}), [e]), a(() => {
|
|
900
|
+
if (!e) return;
|
|
901
|
+
let r = (e) => {
|
|
902
|
+
e.key === "Escape" && (t(), m.current?.focus());
|
|
903
|
+
};
|
|
904
|
+
return document.addEventListener("keydown", r), v(n === "hub" ? null : n), y.current?.focus(), () => document.removeEventListener("keydown", r);
|
|
905
|
+
}, [e]), !e) return null;
|
|
906
|
+
let b = (e, r) => (a) => {
|
|
907
|
+
e === n && i?.(r, a), t();
|
|
908
|
+
};
|
|
909
|
+
return d(/* @__PURE__ */ l("div", {
|
|
910
|
+
className: Y.backdrop,
|
|
911
|
+
onClick: t,
|
|
912
|
+
children: /* @__PURE__ */ u("div", {
|
|
913
|
+
ref: y,
|
|
914
|
+
id: p,
|
|
915
|
+
role: "dialog",
|
|
916
|
+
"aria-modal": "true",
|
|
917
|
+
"aria-label": "Navigation menu",
|
|
918
|
+
tabIndex: -1,
|
|
919
|
+
className: Y.panel,
|
|
920
|
+
onClick: (e) => e.stopPropagation(),
|
|
921
|
+
children: [
|
|
922
|
+
/* @__PURE__ */ l("div", {
|
|
923
|
+
className: Y.accordion,
|
|
924
|
+
children: ve.map((e) => {
|
|
925
|
+
let t = _ === e.id, i = n === e.id, a = e.sections.filter((e) => !(e.requiresAuth && !h || e.roles && (!g || !e.roles.includes(g.role)))), o = `mobile-accordion-${e.id}`;
|
|
926
|
+
return /* @__PURE__ */ u("div", {
|
|
927
|
+
className: Y.accordionItem,
|
|
928
|
+
children: [/* @__PURE__ */ u("button", {
|
|
929
|
+
type: "button",
|
|
930
|
+
className: `${Y.accordionHeader} ${i ? Y.currentApp : ""}`,
|
|
931
|
+
"aria-expanded": t,
|
|
932
|
+
"aria-controls": o,
|
|
933
|
+
onClick: () => v(t ? null : e.id),
|
|
934
|
+
children: [e.label, /* @__PURE__ */ l("svg", {
|
|
935
|
+
className: `${Y.chevron} ${t ? Y.chevronOpen : ""}`,
|
|
936
|
+
width: "10",
|
|
937
|
+
height: "6",
|
|
938
|
+
viewBox: "0 0 10 6",
|
|
939
|
+
"aria-hidden": "true",
|
|
940
|
+
children: /* @__PURE__ */ l("path", {
|
|
941
|
+
d: "M1 1l4 4 4-4",
|
|
942
|
+
stroke: "currentColor",
|
|
943
|
+
strokeWidth: "1.5",
|
|
944
|
+
fill: "none",
|
|
945
|
+
strokeLinecap: "round",
|
|
946
|
+
strokeLinejoin: "round"
|
|
947
|
+
})
|
|
948
|
+
})]
|
|
949
|
+
}), t && /* @__PURE__ */ l("div", {
|
|
950
|
+
id: o,
|
|
951
|
+
className: Y.accordionPanel,
|
|
952
|
+
children: e.status === "coming-soon" ? /* @__PURE__ */ l("div", {
|
|
953
|
+
className: Y.comingSoon,
|
|
954
|
+
children: "Coming soon"
|
|
955
|
+
}) : a.map((t) => {
|
|
956
|
+
let n = i && r === t.id;
|
|
957
|
+
return /* @__PURE__ */ l("a", {
|
|
958
|
+
href: t.href,
|
|
959
|
+
className: `${Y.sectionLink} ${n ? Y.sectionActive : ""}`,
|
|
960
|
+
"aria-current": n ? "page" : void 0,
|
|
961
|
+
onClick: b(e.id, t),
|
|
962
|
+
children: t.label
|
|
963
|
+
}, t.id);
|
|
964
|
+
})
|
|
965
|
+
})]
|
|
966
|
+
}, e.id);
|
|
967
|
+
})
|
|
968
|
+
}),
|
|
969
|
+
/* @__PURE__ */ l("div", {
|
|
970
|
+
className: Y.allySection,
|
|
971
|
+
children: /* @__PURE__ */ l(Se, { variant: "inline" })
|
|
972
|
+
}),
|
|
973
|
+
c && /* @__PURE__ */ l("div", {
|
|
974
|
+
className: Y.extrasSection,
|
|
975
|
+
children: c
|
|
976
|
+
}),
|
|
977
|
+
/* @__PURE__ */ l("div", {
|
|
978
|
+
className: Y.accountSection,
|
|
979
|
+
children: /* @__PURE__ */ l(we, { showAuth: f })
|
|
980
|
+
})
|
|
981
|
+
]
|
|
982
|
+
})
|
|
983
|
+
}), document.body);
|
|
984
|
+
}, Ee = {
|
|
985
|
+
logoLink: "_logoLink_12f5f_3",
|
|
986
|
+
appMenus: "_appMenus_12f5f_10",
|
|
987
|
+
desktopRight: "_desktopRight_12f5f_19",
|
|
988
|
+
extrasGroup: "_extrasGroup_12f5f_25"
|
|
989
|
+
}, De = ({ currentApp: e, activeSectionId: t, onNavigate: n, rightExtras: r, showAuth: i = !0, className: d }) => {
|
|
990
|
+
let [f, p] = s(null), [m, g] = s(!1), _ = o(null), v = "suite-mobile-nav-panel";
|
|
991
|
+
return a(() => {
|
|
992
|
+
let e = window.matchMedia("(max-width: 768px)"), t = () => {
|
|
993
|
+
p(null), g(!1);
|
|
994
|
+
};
|
|
995
|
+
return e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
996
|
+
}, []), /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(h, {
|
|
660
997
|
className: d,
|
|
661
|
-
logo: /* @__PURE__ */
|
|
662
|
-
href:
|
|
663
|
-
className:
|
|
998
|
+
logo: /* @__PURE__ */ l("a", {
|
|
999
|
+
href: "/",
|
|
1000
|
+
className: Ee.logoLink,
|
|
664
1001
|
children: "The Astrogator's Table"
|
|
665
1002
|
}),
|
|
666
|
-
leftContent:
|
|
667
|
-
className:
|
|
668
|
-
children:
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
}),
|
|
691
|
-
|
|
692
|
-
|
|
1003
|
+
leftContent: /* @__PURE__ */ l("nav", {
|
|
1004
|
+
className: Ee.appMenus,
|
|
1005
|
+
children: ve.map((r) => /* @__PURE__ */ l(he, {
|
|
1006
|
+
app: r,
|
|
1007
|
+
isCurrentApp: e === r.id,
|
|
1008
|
+
activeSectionId: t,
|
|
1009
|
+
isOpen: f === r.id,
|
|
1010
|
+
onOpenChange: (e) => p(e ? r.id : null),
|
|
1011
|
+
onSectionClick: n
|
|
1012
|
+
}, r.id))
|
|
1013
|
+
}),
|
|
1014
|
+
rightContent: /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ u("div", {
|
|
1015
|
+
className: Ee.desktopRight,
|
|
1016
|
+
children: [
|
|
1017
|
+
r && /* @__PURE__ */ l("div", {
|
|
1018
|
+
className: Ee.extrasGroup,
|
|
1019
|
+
children: r
|
|
1020
|
+
}),
|
|
1021
|
+
/* @__PURE__ */ l(Se, {
|
|
1022
|
+
isOpen: f === "ally",
|
|
1023
|
+
onOpenChange: (e) => p(e ? "ally" : null)
|
|
1024
|
+
}),
|
|
1025
|
+
/* @__PURE__ */ l(we, { showAuth: i })
|
|
1026
|
+
]
|
|
1027
|
+
}), /* @__PURE__ */ l(_e, {
|
|
1028
|
+
ref: _,
|
|
1029
|
+
isOpen: m,
|
|
1030
|
+
onClick: () => {
|
|
1031
|
+
p(null), g((e) => !e);
|
|
1032
|
+
},
|
|
1033
|
+
controlsId: v
|
|
1034
|
+
})] })
|
|
1035
|
+
}), /* @__PURE__ */ l(Te, {
|
|
1036
|
+
isOpen: m,
|
|
1037
|
+
onClose: () => g(!1),
|
|
1038
|
+
currentApp: e,
|
|
1039
|
+
activeSectionId: t,
|
|
1040
|
+
onSectionClick: n,
|
|
1041
|
+
rightExtras: r,
|
|
1042
|
+
showAuth: i,
|
|
1043
|
+
panelId: v,
|
|
1044
|
+
returnFocusRef: _
|
|
1045
|
+
})] });
|
|
1046
|
+
}, X = {
|
|
693
1047
|
footer: "_footer_zjuj8_1",
|
|
694
1048
|
content: "_content_zjuj8_7",
|
|
695
1049
|
defaultContent: "_defaultContent_zjuj8_13",
|
|
696
1050
|
copyright: "_copyright_zjuj8_21",
|
|
697
1051
|
disclaimer: "_disclaimer_zjuj8_26"
|
|
698
|
-
},
|
|
699
|
-
className: `${
|
|
700
|
-
children: /* @__PURE__ */
|
|
701
|
-
className:
|
|
702
|
-
children: e || /* @__PURE__ */
|
|
703
|
-
className:
|
|
704
|
-
children: [/* @__PURE__ */
|
|
705
|
-
className:
|
|
1052
|
+
}, Oe = ({ children: e, className: t = "" }) => /* @__PURE__ */ l("footer", {
|
|
1053
|
+
className: `${X.footer} ${t}`,
|
|
1054
|
+
children: /* @__PURE__ */ l("div", {
|
|
1055
|
+
className: X.content,
|
|
1056
|
+
children: e || /* @__PURE__ */ u("div", {
|
|
1057
|
+
className: X.defaultContent,
|
|
1058
|
+
children: [/* @__PURE__ */ u("p", {
|
|
1059
|
+
className: X.copyright,
|
|
706
1060
|
children: [
|
|
707
1061
|
"© ",
|
|
708
1062
|
(/* @__PURE__ */ new Date()).getFullYear(),
|
|
709
1063
|
" The Astrogator's Table. All rights reserved."
|
|
710
1064
|
]
|
|
711
|
-
}), /* @__PURE__ */
|
|
712
|
-
className:
|
|
1065
|
+
}), /* @__PURE__ */ l("p", {
|
|
1066
|
+
className: X.disclaimer,
|
|
713
1067
|
children: "Star Wars: Galaxy of Heroes is a trademark of Electronic Arts Inc."
|
|
714
1068
|
})]
|
|
715
1069
|
})
|
|
@@ -717,11 +1071,11 @@ var y = "astrogators_access_token", b = "astrogators_refresh_token", x = () => l
|
|
|
717
1071
|
});
|
|
718
1072
|
//#endregion
|
|
719
1073
|
//#region src/utils/formatTime.ts
|
|
720
|
-
function
|
|
1074
|
+
function ke(e) {
|
|
721
1075
|
let t = /([zZ]|[+-]\d{2}:?\d{2})$/.test(e);
|
|
722
1076
|
return new Date(t ? e : `${e}Z`);
|
|
723
1077
|
}
|
|
724
|
-
function
|
|
1078
|
+
function Ae(e, t) {
|
|
725
1079
|
let n = Math.max(0, Math.floor((t - e.getTime()) / 1e3));
|
|
726
1080
|
if (n < 60) return `${n}s ago`;
|
|
727
1081
|
let r = Math.floor(n / 60);
|
|
@@ -729,38 +1083,38 @@ function pe(e, t) {
|
|
|
729
1083
|
let i = Math.floor(r / 60);
|
|
730
1084
|
return i < 24 ? `${i}h ago` : `${Math.floor(i / 24)}d ago`;
|
|
731
1085
|
}
|
|
732
|
-
function
|
|
1086
|
+
function je(e) {
|
|
733
1087
|
return `${Math.floor(e / 60)}:${(e % 60).toString().padStart(2, "0")}`;
|
|
734
1088
|
}
|
|
735
|
-
var
|
|
1089
|
+
var Me = {
|
|
736
1090
|
rosterRefresh: "_rosterRefresh_1rbul_3",
|
|
737
1091
|
updatedLabel: "_updatedLabel_1rbul_11",
|
|
738
1092
|
refreshButton: "_refreshButton_1rbul_19",
|
|
739
1093
|
spin: "_spin_1rbul_31"
|
|
740
|
-
},
|
|
741
|
-
let [
|
|
742
|
-
|
|
1094
|
+
}, Ne = ({ onRefresh: e, isRefreshing: t, cachedAt: n = null, refreshAvailableAt: r = null, labelPrefix: i = "Updated", className: o = "" }) => {
|
|
1095
|
+
let [c, d] = s(() => Date.now()), f = !!n || r != null && r > c;
|
|
1096
|
+
a(() => {
|
|
743
1097
|
if (!f) return;
|
|
744
1098
|
let e = setInterval(() => d(Date.now()), 1e3);
|
|
745
1099
|
return () => clearInterval(e);
|
|
746
1100
|
}, [f]);
|
|
747
|
-
let p = r ? Math.max(0, Math.ceil((r -
|
|
748
|
-
return /* @__PURE__ */
|
|
749
|
-
className: `${
|
|
750
|
-
children: [
|
|
751
|
-
className:
|
|
752
|
-
title:
|
|
753
|
-
children: p > 0 ? `${
|
|
754
|
-
}), /* @__PURE__ */
|
|
1101
|
+
let p = r ? Math.max(0, Math.ceil((r - c) / 1e3)) : 0, m = n ? Ae(ke(n), c) : null, h = t || p > 0, g = p > 0 ? `Fresh data available in ${je(p)}` : "Refresh roster";
|
|
1102
|
+
return /* @__PURE__ */ u("div", {
|
|
1103
|
+
className: `${Me.rosterRefresh} ${o}`,
|
|
1104
|
+
children: [m && /* @__PURE__ */ l("span", {
|
|
1105
|
+
className: Me.updatedLabel,
|
|
1106
|
+
title: g,
|
|
1107
|
+
children: p > 0 ? `${i} ${m} · fresh in ${je(p)}` : `${i} ${m}`
|
|
1108
|
+
}), /* @__PURE__ */ l(G, {
|
|
755
1109
|
variant: "outline",
|
|
756
1110
|
size: "sm",
|
|
757
1111
|
onClick: e,
|
|
758
|
-
disabled:
|
|
759
|
-
title:
|
|
1112
|
+
disabled: h,
|
|
1113
|
+
title: g,
|
|
760
1114
|
"aria-label": "Refresh roster",
|
|
761
|
-
className:
|
|
762
|
-
children: /* @__PURE__ */
|
|
763
|
-
className: t ?
|
|
1115
|
+
className: Me.refreshButton,
|
|
1116
|
+
children: /* @__PURE__ */ l("span", {
|
|
1117
|
+
className: t ? Me.spin : void 0,
|
|
764
1118
|
children: "⟳"
|
|
765
1119
|
})
|
|
766
1120
|
})]
|
|
@@ -776,37 +1130,37 @@ var X = {
|
|
|
776
1130
|
"padding-md": "_padding-md_1vw8g_43",
|
|
777
1131
|
"padding-lg": "_padding-lg_1vw8g_47",
|
|
778
1132
|
hoverable: "_hoverable_1vw8g_52"
|
|
779
|
-
},
|
|
780
|
-
let m = n ? r === "asymmetric" ? "chamfered-box-asymmetric" : r === "sm" ? "chamfered-box-sm" : r === "lg" ? "chamfered-box-lg" : "chamfered-box" : "", h =
|
|
1133
|
+
}, Pe = ({ children: e, variant: t = "default", chamfered: n = !1, chamferSize: r = "md", padding: i = "md", hoverable: a = !1, showDiagonalBorders: o = !0, edgeColor: s, className: d = "", onClick: f, style: p }) => {
|
|
1134
|
+
let m = n ? r === "asymmetric" ? "chamfered-box-asymmetric" : r === "sm" ? "chamfered-box-sm" : r === "lg" ? "chamfered-box-lg" : "chamfered-box" : "", h = s ?? (n ? "var(--color-border)" : void 0), g = h ? { color: h } : void 0, _ = h ? {
|
|
781
1135
|
...p,
|
|
782
1136
|
"--card-edge-color": h
|
|
783
1137
|
} : p;
|
|
784
|
-
return /* @__PURE__ */
|
|
1138
|
+
return /* @__PURE__ */ u("div", {
|
|
785
1139
|
className: `${Z.card} ${n ? Z.chamfered : ""} ${Z[t]} ${Z[`padding-${i}`]} ${m} ${a ? Z.hoverable : ""} ${d}`,
|
|
786
1140
|
onClick: f,
|
|
787
1141
|
role: f ? "button" : void 0,
|
|
788
1142
|
tabIndex: f ? 0 : void 0,
|
|
789
1143
|
style: _,
|
|
790
|
-
children: [n &&
|
|
791
|
-
/* @__PURE__ */
|
|
1144
|
+
children: [n && o && /* @__PURE__ */ u(c, { children: [
|
|
1145
|
+
/* @__PURE__ */ l("div", {
|
|
792
1146
|
className: "chamfered-diagonal-border chamfered-diagonal-tl",
|
|
793
1147
|
style: g
|
|
794
1148
|
}),
|
|
795
|
-
/* @__PURE__ */
|
|
1149
|
+
/* @__PURE__ */ l("div", {
|
|
796
1150
|
className: "chamfered-diagonal-border chamfered-diagonal-tr",
|
|
797
1151
|
style: g
|
|
798
1152
|
}),
|
|
799
|
-
/* @__PURE__ */
|
|
1153
|
+
/* @__PURE__ */ l("div", {
|
|
800
1154
|
className: "chamfered-diagonal-border chamfered-diagonal-bl",
|
|
801
1155
|
style: g
|
|
802
1156
|
}),
|
|
803
|
-
/* @__PURE__ */
|
|
1157
|
+
/* @__PURE__ */ l("div", {
|
|
804
1158
|
className: "chamfered-diagonal-border chamfered-diagonal-br",
|
|
805
1159
|
style: g
|
|
806
1160
|
})
|
|
807
1161
|
] }), e]
|
|
808
1162
|
});
|
|
809
|
-
},
|
|
1163
|
+
}, Fe = {
|
|
810
1164
|
badge: "_badge_rk7t5_1",
|
|
811
1165
|
sm: "_sm_rk7t5_11",
|
|
812
1166
|
md: "_md_rk7t5_16",
|
|
@@ -818,8 +1172,8 @@ var X = {
|
|
|
818
1172
|
warning: "_warning_rk7t5_47",
|
|
819
1173
|
error: "_error_rk7t5_52",
|
|
820
1174
|
info: "_info_rk7t5_57"
|
|
821
|
-
},
|
|
822
|
-
className: `${
|
|
1175
|
+
}, Ie = ({ children: e, variant: t = "default", size: n = "md", className: r = "" }) => /* @__PURE__ */ l("span", {
|
|
1176
|
+
className: `${Fe.badge} ${Fe[t]} ${Fe[n]} ${r}`,
|
|
823
1177
|
children: e
|
|
824
1178
|
}), Q = {
|
|
825
1179
|
overlay: "_overlay_1b3yt_1",
|
|
@@ -834,34 +1188,34 @@ var X = {
|
|
|
834
1188
|
title: "_title_1b3yt_53",
|
|
835
1189
|
closeButton: "_closeButton_1b3yt_60",
|
|
836
1190
|
content: "_content_1b3yt_78"
|
|
837
|
-
},
|
|
1191
|
+
}, Le = ({ isOpen: e, onClose: t, title: n, children: r, size: i = "md", closeOnOverlayClick: o = !0, className: s = "" }) => (a(() => (e ? document.body.style.overflow = "hidden" : document.body.style.overflow = "unset", () => {
|
|
838
1192
|
document.body.style.overflow = "unset";
|
|
839
|
-
}), [e]),
|
|
1193
|
+
}), [e]), a(() => {
|
|
840
1194
|
let n = (n) => {
|
|
841
1195
|
n.key === "Escape" && e && t();
|
|
842
1196
|
};
|
|
843
1197
|
return document.addEventListener("keydown", n), () => document.removeEventListener("keydown", n);
|
|
844
|
-
}, [e, t]), e ? /* @__PURE__ */
|
|
1198
|
+
}, [e, t]), e ? /* @__PURE__ */ l("div", {
|
|
845
1199
|
className: Q.overlay,
|
|
846
1200
|
onClick: (e) => {
|
|
847
1201
|
o && e.target === e.currentTarget && t();
|
|
848
1202
|
},
|
|
849
|
-
children: /* @__PURE__ */
|
|
850
|
-
className: `${Q.modal} ${Q[
|
|
1203
|
+
children: /* @__PURE__ */ u("div", {
|
|
1204
|
+
className: `${Q.modal} ${Q[i]} ${s}`,
|
|
851
1205
|
role: "dialog",
|
|
852
1206
|
"aria-modal": "true",
|
|
853
|
-
children: [n && /* @__PURE__ */
|
|
1207
|
+
children: [n && /* @__PURE__ */ u("div", {
|
|
854
1208
|
className: Q.header,
|
|
855
|
-
children: [/* @__PURE__ */
|
|
1209
|
+
children: [/* @__PURE__ */ l("h2", {
|
|
856
1210
|
className: Q.title,
|
|
857
1211
|
children: n
|
|
858
|
-
}), /* @__PURE__ */
|
|
1212
|
+
}), /* @__PURE__ */ l("button", {
|
|
859
1213
|
className: Q.closeButton,
|
|
860
1214
|
onClick: t,
|
|
861
1215
|
"aria-label": "Close modal",
|
|
862
1216
|
children: "✕"
|
|
863
1217
|
})]
|
|
864
|
-
}), /* @__PURE__ */
|
|
1218
|
+
}), /* @__PURE__ */ l("div", {
|
|
865
1219
|
className: Q.content,
|
|
866
1220
|
children: r
|
|
867
1221
|
})]
|
|
@@ -876,24 +1230,24 @@ var X = {
|
|
|
876
1230
|
dot: "_dot_1uhnh_34",
|
|
877
1231
|
bounce: "_bounce_1uhnh_1",
|
|
878
1232
|
visuallyHidden: "_visuallyHidden_1uhnh_91"
|
|
879
|
-
},
|
|
1233
|
+
}, Re = ({ size: e = "md", variant: t = "spinner", className: n = "" }) => t === "dots" ? /* @__PURE__ */ u("div", {
|
|
880
1234
|
className: `${$.dots} ${$[e]} ${n}`,
|
|
881
1235
|
children: [
|
|
882
|
-
/* @__PURE__ */
|
|
883
|
-
/* @__PURE__ */
|
|
884
|
-
/* @__PURE__ */
|
|
1236
|
+
/* @__PURE__ */ l("span", { className: $.dot }),
|
|
1237
|
+
/* @__PURE__ */ l("span", { className: $.dot }),
|
|
1238
|
+
/* @__PURE__ */ l("span", { className: $.dot })
|
|
885
1239
|
]
|
|
886
|
-
}) : /* @__PURE__ */
|
|
1240
|
+
}) : /* @__PURE__ */ l("div", {
|
|
887
1241
|
className: `${$.spinner} ${$[e]} ${n}`,
|
|
888
1242
|
role: "status",
|
|
889
|
-
children: /* @__PURE__ */
|
|
1243
|
+
children: /* @__PURE__ */ l("span", {
|
|
890
1244
|
className: $.visuallyHidden,
|
|
891
1245
|
children: "Loading..."
|
|
892
1246
|
})
|
|
893
|
-
}),
|
|
1247
|
+
}), ze = async (e) => {
|
|
894
1248
|
if (e.length === 0) return {};
|
|
895
|
-
let t = [...new Set(e)], n = await
|
|
1249
|
+
let t = [...new Set(e)], n = await L.get(`/api/v1/users/lookup?ids=${t.join(",")}`);
|
|
896
1250
|
return Object.fromEntries(n.users.map((e) => [e.id, e.username]));
|
|
897
1251
|
};
|
|
898
1252
|
//#endregion
|
|
899
|
-
export {
|
|
1253
|
+
export { Se as AllyCodeDropdown, ie as ApiClient, pe as AuthProvider, Ie as Badge, G as Button, Pe as Card, p as Container, Oe as Footer, be as Input, Re as Loader, Le as Modal, De as NavBar, Ne as RosterRefresh, ve as SUITE_NAV, ye as Select, h as TopBar, L as apiClient, re as authedFetch, de as clearAllyCodes, T as clearTokens, A as configureAuthRefresh, ze as fetchUsernames, q as formatAllyCode, je as formatCountdown, Ae as formatRelativeTime, v as getAccessToken, z as getAllyCodesFromStorage, x as getRefreshToken, ue as getSelectedAllyCode, ae as initializeApiClient, E as isAuthenticated, ke as parseBackendTimestamp, j as refreshAccessToken, b as removeAccessToken, ce as removeAllyCodeFromStorage, C as removeRefreshToken, se as saveAllyCodeToStorage, y as setAccessToken, S as setRefreshToken, B as setSelectedAllyCode, w as setTokens, xe as unformatAllyCode, le as updateAllyCodeLastUsed, V as useAuth };
|