@nivaro/react 0.3.0 → 0.3.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/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +341 -0
- package/dist/index.js +764 -723
- package/dist/shared/components/ClientChaosToolbar.js +410 -0
- package/dist/shared/components/LoadErrorNote.js +49 -0
- package/dist/shared/components/PretendDown.js +258 -0
- package/dist/shared/components/ProfileView.js +54 -49
- package/dist/shared/components/QueryErrorState.js +16 -0
- package/dist/shared/components/ReportView.js +1351 -1338
- package/dist/shared/components/WidgetSlot.js +438 -418
- package/dist/shared/components/chaos/DeclareIncidentButton.js +72 -0
- package/dist/shared/components/chaos/DrillBanner.js +119 -0
- package/dist/shared/components/chaos/DrillTag.js +62 -0
- package/dist/shared/components/chaos/GameDayStrip.js +61 -0
- package/dist/shared/components/client-chaos-gate.js +51 -0
- package/dist/shared/components/integrations/console/SignalCard.js +172 -167
- package/dist/shared/components/layout-editor/EditorTopBar.js +108 -105
- package/dist/shared/components/layout-editor/LayoutEditor.js +514 -508
- package/dist/shared/components/notifications/NotificationAnalyticsView.js +18 -10
- package/dist/shared/components/pipeline/PipelineEditorView.js +495 -479
- package/dist/shared/components/pipeline/TeamsView.js +184 -169
- package/dist/shared/lib/client-chaos.js +359 -0
- package/dist/shared/lib/load-error.js +26 -0
- package/dist/shared/lib/socket-realtime.js +31 -30
- package/dist/shared/lib/worker-socket.js +108 -89
- package/package.json +1 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsxs as t, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as y, useQuery as x } from "@tanstack/react-query";
|
|
3
|
+
import { Siren as w } from "lucide-react";
|
|
4
|
+
import { useState as i } from "react";
|
|
5
|
+
import { useNivaroClient as k } from "../../context.js";
|
|
6
|
+
import { post as N } from "../../lib/commands.js";
|
|
7
|
+
import { cn as l } from "../../lib/utils.js";
|
|
8
|
+
const u = ["chaos-declared-at"];
|
|
9
|
+
function F({ className: a }) {
|
|
10
|
+
const m = k(), [b, n] = i(!1), [o, s] = i(!1), p = y(), { data: d = null } = x({
|
|
11
|
+
queryKey: u,
|
|
12
|
+
queryFn: () => null,
|
|
13
|
+
enabled: !1,
|
|
14
|
+
staleTime: Number.POSITIVE_INFINITY
|
|
15
|
+
}), [h, c] = i(!1), f = async () => {
|
|
16
|
+
var r;
|
|
17
|
+
s(!0), c(!1);
|
|
18
|
+
try {
|
|
19
|
+
const v = await m.request(N("/chaos/declare", {}));
|
|
20
|
+
p.setQueryData(u, ((r = v.data) == null ? void 0 : r.at) ?? (/* @__PURE__ */ new Date()).toISOString()), n(!1);
|
|
21
|
+
} catch {
|
|
22
|
+
c(!0);
|
|
23
|
+
} finally {
|
|
24
|
+
s(!1);
|
|
25
|
+
}
|
|
26
|
+
}, g = (r) => new Date(r).toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
|
|
27
|
+
return b ? /* @__PURE__ */ t("span", { className: l("inline-flex items-center gap-1.5 text-[12px]", a), children: [
|
|
28
|
+
/* @__PURE__ */ e("span", { className: "whitespace-nowrap opacity-80", children: "Declare an incident now?" }),
|
|
29
|
+
/* @__PURE__ */ e(
|
|
30
|
+
"button",
|
|
31
|
+
{
|
|
32
|
+
type: "button",
|
|
33
|
+
disabled: o,
|
|
34
|
+
onClick: () => void f(),
|
|
35
|
+
className: "h-7 whitespace-nowrap rounded-md border border-red-300 bg-white px-2.5 font-medium text-red-700 transition-colors duration-150 hover:border-red-400 hover:bg-red-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-400 disabled:opacity-40 dark:border-red-800 dark:bg-red-950/60 dark:text-red-200 dark:hover:border-red-700 dark:hover:bg-red-900/50",
|
|
36
|
+
children: o ? "Declaring…" : "Declare now"
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
/* @__PURE__ */ e(
|
|
40
|
+
"button",
|
|
41
|
+
{
|
|
42
|
+
type: "button",
|
|
43
|
+
disabled: o,
|
|
44
|
+
onClick: () => n(!1),
|
|
45
|
+
className: "h-7 whitespace-nowrap rounded-md px-2 opacity-80 transition-colors duration-150 hover:bg-black/[0.05] hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan dark:hover:bg-white/[0.08]",
|
|
46
|
+
children: "Cancel"
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
h && /* @__PURE__ */ e("span", { role: "alert", className: "font-medium text-red-700 dark:text-red-400", children: "Not recorded — try again" })
|
|
50
|
+
] }) : /* @__PURE__ */ t("span", { className: l("inline-flex items-center gap-2 text-[12px]", a), children: [
|
|
51
|
+
/* @__PURE__ */ t(
|
|
52
|
+
"button",
|
|
53
|
+
{
|
|
54
|
+
type: "button",
|
|
55
|
+
onClick: () => n(!0),
|
|
56
|
+
"data-tip": "Mark the moment you noticed something wrong",
|
|
57
|
+
className: "inline-flex h-7 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md border border-slate-200 bg-white px-2.5 font-medium text-slate-700 transition-colors duration-150 hover:border-red-300 hover:text-red-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan dark:border-border dark:bg-card dark:text-foreground dark:hover:border-red-800 dark:hover:text-red-400",
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ e(w, { className: "h-3.5 w-3.5 shrink-0", "aria-hidden": !0 }),
|
|
60
|
+
"Declare incident"
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
d && /* @__PURE__ */ t("span", { role: "status", className: "whitespace-nowrap opacity-75", children: [
|
|
65
|
+
"Declared at ",
|
|
66
|
+
g(d)
|
|
67
|
+
] })
|
|
68
|
+
] });
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
F as DeclareIncidentButton
|
|
72
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsx as l, jsxs as i } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as x, useQuery as v } from "@tanstack/react-query";
|
|
3
|
+
import { useState as w, useEffect as _ } from "react";
|
|
4
|
+
import { useNavigation as y, useOptionalNivaroClient as N } from "../../context.js";
|
|
5
|
+
import { get as k } from "../../lib/commands.js";
|
|
6
|
+
import { useLiveAvailable as D, useLiveEvent as I } from "../../lib/live.js";
|
|
7
|
+
import { DeclareIncidentButton as S } from "./DeclareIncidentButton.js";
|
|
8
|
+
import { GameDayStrip as A, useActiveGamedays as q } from "./GameDayStrip.js";
|
|
9
|
+
const m = ["chaos-armed"];
|
|
10
|
+
function f() {
|
|
11
|
+
const r = N(), o = x(), t = D(), { data: e } = v({
|
|
12
|
+
queryKey: m,
|
|
13
|
+
queryFn: () => r.request(k("/chaos/armed")).then((a) => a.data ?? { allowed: !1, armed: [] }).catch(() => ({ allowed: !1, armed: [] })),
|
|
14
|
+
enabled: !!r,
|
|
15
|
+
staleTime: 15e3,
|
|
16
|
+
refetchInterval: (a) => {
|
|
17
|
+
const d = a.state.data;
|
|
18
|
+
return d && !d.allowed ? !1 : t ? 12e4 : 3e4;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return I(
|
|
22
|
+
"chaos:armed",
|
|
23
|
+
(a) => {
|
|
24
|
+
Array.isArray(a == null ? void 0 : a.armed) ? o.setQueryData(m, { allowed: !0, armed: a.armed }) : o.invalidateQueries({ queryKey: m });
|
|
25
|
+
},
|
|
26
|
+
{ includeOwn: !0, enabled: !!r && (e == null ? void 0 : e.allowed) !== !1 }
|
|
27
|
+
), { allowed: (e == null ? void 0 : e.allowed) ?? !0, armed: (e == null ? void 0 : e.armed) ?? [], ready: !!e };
|
|
28
|
+
}
|
|
29
|
+
function E(r, o = Date.now()) {
|
|
30
|
+
const t = Math.max(0, Math.round((r - o) / 1e3));
|
|
31
|
+
return `${Math.floor(t / 60)}:${String(t % 60).padStart(2, "0")}`;
|
|
32
|
+
}
|
|
33
|
+
function B() {
|
|
34
|
+
const { armed: r, allowed: o } = f(), t = q(o);
|
|
35
|
+
return r.some((e) => e.ends_at > Date.now()) || t.some((e) => e.status === "running");
|
|
36
|
+
}
|
|
37
|
+
function K({ stopHref: r = "/chaos", canStop: o = !1 }) {
|
|
38
|
+
const { armed: t, allowed: e } = f(), { navigate: a, consoleUrl: d } = y(), [p, h] = w(() => Date.now()), s = t.filter((n) => n.ends_at > p);
|
|
39
|
+
if (_(() => {
|
|
40
|
+
if (!t.length) return;
|
|
41
|
+
const n = setInterval(() => h(Date.now()), 1e3);
|
|
42
|
+
return () => clearInterval(n);
|
|
43
|
+
}, [t.length]), s.length === 0) return /* @__PURE__ */ l(A, { enabled: e });
|
|
44
|
+
const c = s[0], u = d ? d(r) : r, g = s.reduce((n, b) => Math.min(n, b.ends_at), Number.POSITIVE_INFINITY);
|
|
45
|
+
return /* @__PURE__ */ i(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
role: "status",
|
|
49
|
+
"aria-live": "polite",
|
|
50
|
+
"data-drill-banner": !0,
|
|
51
|
+
"data-nvr-recording-hide": !0,
|
|
52
|
+
className: "relative flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-red-200 bg-red-50 px-4 py-1.5 text-[12.5px] text-red-900 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200",
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ l(
|
|
55
|
+
"span",
|
|
56
|
+
{
|
|
57
|
+
"aria-hidden": !0,
|
|
58
|
+
className: "pointer-events-none absolute inset-x-0 top-0 h-[3px] bg-[repeating-linear-gradient(135deg,rgb(239_68_68)_0_8px,transparent_8px_16px)] opacity-70 dark:bg-[repeating-linear-gradient(135deg,rgb(248_113_113)_0_8px,transparent_8px_16px)]"
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
/* @__PURE__ */ i("span", { className: "flex min-w-0 items-start gap-2 font-medium", children: [
|
|
62
|
+
/* @__PURE__ */ i("span", { className: "relative mt-[5px] flex h-2 w-2 shrink-0", "aria-hidden": !0, children: [
|
|
63
|
+
/* @__PURE__ */ l("span", { className: "absolute inline-flex h-full w-full animate-ping rounded-full bg-red-400 opacity-75 motion-reduce:animate-none" }),
|
|
64
|
+
/* @__PURE__ */ l("span", { className: "relative inline-flex h-2 w-2 rounded-full bg-red-500" })
|
|
65
|
+
] }),
|
|
66
|
+
/* @__PURE__ */ i("span", { className: "min-w-0", children: [
|
|
67
|
+
"Drill running: ",
|
|
68
|
+
c.label,
|
|
69
|
+
/* @__PURE__ */ i("span", { className: "font-normal", children: [
|
|
70
|
+
" on ",
|
|
71
|
+
c.target
|
|
72
|
+
] }),
|
|
73
|
+
s.length > 1 && /* @__PURE__ */ i(
|
|
74
|
+
"span",
|
|
75
|
+
{
|
|
76
|
+
className: "font-normal underline decoration-red-300 decoration-dotted underline-offset-2 dark:decoration-red-700",
|
|
77
|
+
"data-tip": s.slice(1).map((n) => `${n.label} on ${n.target}`).join(" · "),
|
|
78
|
+
children: [
|
|
79
|
+
" ",
|
|
80
|
+
"and ",
|
|
81
|
+
s.length - 1,
|
|
82
|
+
" more fault",
|
|
83
|
+
s.length > 2 ? "s" : ""
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
] })
|
|
88
|
+
] }),
|
|
89
|
+
/* @__PURE__ */ i("span", { className: "min-w-0 text-red-800/80 dark:text-red-300/80", children: [
|
|
90
|
+
c.started_by_name ? `started by ${c.started_by_name} · ` : "",
|
|
91
|
+
"ends in ",
|
|
92
|
+
/* @__PURE__ */ l("span", { className: "tabular-nums", children: E(g, p) }),
|
|
93
|
+
" · ",
|
|
94
|
+
"this is a planned test, not an outage"
|
|
95
|
+
] }),
|
|
96
|
+
/* @__PURE__ */ l(S, { className: "ml-auto" }),
|
|
97
|
+
o && u && /* @__PURE__ */ l(
|
|
98
|
+
"a",
|
|
99
|
+
{
|
|
100
|
+
href: u,
|
|
101
|
+
onClick: (n) => {
|
|
102
|
+
/^https?:/i.test(u) || (n.preventDefault(), a(u));
|
|
103
|
+
},
|
|
104
|
+
"data-tip": "Open the chaos console to stop it",
|
|
105
|
+
className: "inline-flex h-7 shrink-0 items-center rounded-md border border-red-300 bg-white px-2.5 text-[12px] font-medium text-red-700 transition-colors duration-150 hover:border-red-400 hover:bg-red-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-400 dark:border-red-800 dark:bg-red-950/60 dark:text-red-200 dark:hover:border-red-700 dark:hover:bg-red-900/50",
|
|
106
|
+
children: "Stop"
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
m as ARMED_FAULTS_KEY,
|
|
115
|
+
K as DrillBanner,
|
|
116
|
+
E as drillCountdown,
|
|
117
|
+
f as useArmedFaults,
|
|
118
|
+
B as useDrillBannerShowing
|
|
119
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsxs as s, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as c } from "@tanstack/react-query";
|
|
3
|
+
import { FlaskConical as u } from "lucide-react";
|
|
4
|
+
import { useNivaroClient as m } from "../../context.js";
|
|
5
|
+
import { get as f } from "../../lib/commands.js";
|
|
6
|
+
import { cn as h } from "../../lib/utils.js";
|
|
7
|
+
const p = ["chaos", "drill-windows"];
|
|
8
|
+
function y(e, t, a = Date.now()) {
|
|
9
|
+
if (!(e != null && e.length)) return null;
|
|
10
|
+
const r = t == null ? a : t instanceof Date ? t.getTime() : new Date(t).getTime();
|
|
11
|
+
if (!Number.isFinite(r)) return null;
|
|
12
|
+
let l = null;
|
|
13
|
+
for (const i of e) {
|
|
14
|
+
const n = Date.parse(i.started_at), o = i.ended_at ? Date.parse(i.ended_at) : a;
|
|
15
|
+
r >= n && r <= o + 6e4 && (!l || n > Date.parse(l.started_at)) && (l = i);
|
|
16
|
+
}
|
|
17
|
+
return l;
|
|
18
|
+
}
|
|
19
|
+
function I() {
|
|
20
|
+
const e = m(), { data: t } = c({
|
|
21
|
+
queryKey: p,
|
|
22
|
+
queryFn: () => e.request(f("/chaos/drill-windows")).then((a) => a.data ?? []).catch(() => []),
|
|
23
|
+
staleTime: 3e4,
|
|
24
|
+
refetchInterval: 6e4,
|
|
25
|
+
retry: !1
|
|
26
|
+
});
|
|
27
|
+
return t ?? [];
|
|
28
|
+
}
|
|
29
|
+
const b = {
|
|
30
|
+
drill: "chaos drill",
|
|
31
|
+
monkey: "Chaos Monkey drill",
|
|
32
|
+
gameday: "game day",
|
|
33
|
+
ci: "CI drill"
|
|
34
|
+
};
|
|
35
|
+
function N({
|
|
36
|
+
windows: e,
|
|
37
|
+
at: t,
|
|
38
|
+
className: a
|
|
39
|
+
}) {
|
|
40
|
+
const r = y(e, t);
|
|
41
|
+
return r ? /* @__PURE__ */ s(
|
|
42
|
+
"span",
|
|
43
|
+
{
|
|
44
|
+
"data-drill-tag": r.run_id,
|
|
45
|
+
"data-tip": `Fired during the ${b[r.kind] ?? "chaos drill"} “${r.label}”. It may or may not be caused by it; everyone who normally hears about it was told.`,
|
|
46
|
+
className: h(
|
|
47
|
+
"inline-flex shrink-0 items-center gap-1 rounded border border-dashed border-violet-300 bg-violet-50 px-1.5 py-px text-[10.5px] font-medium text-violet-800 dark:border-violet-500/40 dark:bg-violet-500/10 dark:text-violet-300",
|
|
48
|
+
a
|
|
49
|
+
),
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ d(u, { className: "h-3 w-3", "aria-hidden": !0 }),
|
|
52
|
+
"Drill"
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
) : null;
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
p as DRILL_WINDOWS_KEY,
|
|
59
|
+
N as DrillTag,
|
|
60
|
+
y as drillAt,
|
|
61
|
+
I as useDrillWindows
|
|
62
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsxs as t, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as o } from "@tanstack/react-query";
|
|
3
|
+
import { CalendarClock as i } from "lucide-react";
|
|
4
|
+
import { useOptionalNivaroClient as d } from "../../context.js";
|
|
5
|
+
import { get as l } from "../../lib/commands.js";
|
|
6
|
+
import { DeclareIncidentButton as c } from "./DeclareIncidentButton.js";
|
|
7
|
+
const m = ["chaos-gamedays-active"];
|
|
8
|
+
function u(a = !0) {
|
|
9
|
+
const e = d(), { data: r } = o({
|
|
10
|
+
queryKey: m,
|
|
11
|
+
queryFn: () => e.request(l("/chaos/gamedays/active")).then((n) => n.data ?? []).catch(() => []),
|
|
12
|
+
enabled: !!e && a,
|
|
13
|
+
staleTime: 3e4,
|
|
14
|
+
refetchInterval: 6e4
|
|
15
|
+
});
|
|
16
|
+
return r ?? [];
|
|
17
|
+
}
|
|
18
|
+
const p = {
|
|
19
|
+
lead: "You lead it",
|
|
20
|
+
scribe: "You are the scribe",
|
|
21
|
+
responder: "You are a responder"
|
|
22
|
+
};
|
|
23
|
+
function v({ enabled: a = !0 }) {
|
|
24
|
+
const e = u(a).filter((n) => n.status === "running");
|
|
25
|
+
if (!e.length) return null;
|
|
26
|
+
const r = e[0];
|
|
27
|
+
return /* @__PURE__ */ t(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
role: "status",
|
|
31
|
+
"data-gameday-strip": !0,
|
|
32
|
+
"data-nvr-recording-hide": !0,
|
|
33
|
+
className: "flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-slate-200 bg-slate-50 px-4 py-1.5 text-[12.5px] text-slate-800 dark:border-border dark:bg-muted/40 dark:text-foreground",
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ t("span", { className: "flex min-w-0 items-center gap-2 font-medium", children: [
|
|
36
|
+
/* @__PURE__ */ s(
|
|
37
|
+
i,
|
|
38
|
+
{
|
|
39
|
+
className: "h-3.5 w-3.5 shrink-0 text-nvr-navy dark:text-nvr-cyan",
|
|
40
|
+
"aria-hidden": !0
|
|
41
|
+
}
|
|
42
|
+
),
|
|
43
|
+
/* @__PURE__ */ t("span", { className: "min-w-0", children: [
|
|
44
|
+
"Game day in progress: ",
|
|
45
|
+
r.title
|
|
46
|
+
] })
|
|
47
|
+
] }),
|
|
48
|
+
/* @__PURE__ */ t("span", { className: "min-w-0 text-slate-600 dark:text-muted-foreground", children: [
|
|
49
|
+
p[r.role],
|
|
50
|
+
e.length > 1 ? ` · ${e.length - 1} more running` : ""
|
|
51
|
+
] }),
|
|
52
|
+
/* @__PURE__ */ s(c, { className: "ml-auto" })
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
m as ACTIVE_GAMEDAYS_KEY,
|
|
59
|
+
v as GameDayStrip,
|
|
60
|
+
u as useActiveGamedays
|
|
61
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useQuery as C } from "@tanstack/react-query";
|
|
2
|
+
import { useSyncExternalStore as u, useEffect as w } from "react";
|
|
3
|
+
import { useApiFetchConfig as g } from "../context.js";
|
|
4
|
+
import { subscribeClientChaos as c, getClientChaos as f, canUseClientChaos as m, stopClientChaos as S, pretendDownVersion as T } from "../lib/client-chaos.js";
|
|
5
|
+
const E = ["client-chaos", "status"];
|
|
6
|
+
function _(d) {
|
|
7
|
+
const t = m(d), { apiBase: r, authHeaders: h, credentials: p } = g(), s = C({
|
|
8
|
+
queryKey: [...E, r],
|
|
9
|
+
enabled: t,
|
|
10
|
+
staleTime: 6e4,
|
|
11
|
+
retry: !1,
|
|
12
|
+
queryFn: async () => {
|
|
13
|
+
var o, i;
|
|
14
|
+
try {
|
|
15
|
+
const a = await fetch(`${r}/chaos/status`, {
|
|
16
|
+
headers: h,
|
|
17
|
+
credentials: p,
|
|
18
|
+
cache: "no-store"
|
|
19
|
+
});
|
|
20
|
+
if (a.status === 404) return { present: !1, allowed: !1, reason: null };
|
|
21
|
+
const e = await a.json().catch(() => null);
|
|
22
|
+
return a.ok ? {
|
|
23
|
+
present: !0,
|
|
24
|
+
allowed: ((o = e == null ? void 0 : e.data) == null ? void 0 : o.allowed) === !0,
|
|
25
|
+
reason: ((i = e == null ? void 0 : e.data) == null ? void 0 : i.reason) ?? null
|
|
26
|
+
} : {
|
|
27
|
+
present: !0,
|
|
28
|
+
allowed: !1,
|
|
29
|
+
reason: (e == null ? void 0 : e.error) ?? `The server said ${a.status}.`
|
|
30
|
+
};
|
|
31
|
+
} catch {
|
|
32
|
+
return { present: !1, allowed: !1, reason: null };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}), n = t ? s.data ? { loading: !1, ...s.data } : { loading: s.isLoading, present: !1, allowed: !1, reason: null } : { loading: !1, present: !1, allowed: !1, reason: null }, l = !n.loading && !n.allowed && (s.isFetched || !t);
|
|
36
|
+
return w(() => {
|
|
37
|
+
l && f() && S();
|
|
38
|
+
}, [l]), n;
|
|
39
|
+
}
|
|
40
|
+
function x() {
|
|
41
|
+
return u(c, f, () => null);
|
|
42
|
+
}
|
|
43
|
+
function D() {
|
|
44
|
+
return u(c, T, () => 0);
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
E as CLIENT_CHAOS_STATUS_KEY,
|
|
48
|
+
x as useClientChaos,
|
|
49
|
+
_ as useClientChaosGate,
|
|
50
|
+
D as usePretendDownVersion
|
|
51
|
+
};
|