strapi-plugin-magic-sessionmanager 4.22.0 → 4.23.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +163 -119
  3. package/dist/admin/ActiveImpersonationsCard-CbyOAlrL.mjs +396 -0
  4. package/dist/admin/ActiveImpersonationsCard-D1CVmV-w.js +395 -0
  5. package/dist/admin/{Analytics-WbCUmkQQ.mjs → Analytics-DGAHD19E.mjs} +1 -1
  6. package/dist/admin/{Analytics-DeDLGiCe.js → Analytics-_WA68oHb.js} +1 -1
  7. package/dist/admin/{App-Bkv-W0Sv.js → App-CfhAQ17e.js} +304 -104
  8. package/dist/admin/{App-C4bihk2K.mjs → App-VB66H73A.mjs} +276 -76
  9. package/dist/admin/ImpersonationTabBanner-B6Ps5-oe.mjs +244 -0
  10. package/dist/admin/ImpersonationTabBanner-DdwXNmh4.js +244 -0
  11. package/dist/admin/{OnlineUsersWidget-q0Z6nbbO.mjs → OnlineUsersWidget-2u-fYMb7.mjs} +1 -1
  12. package/dist/admin/{OnlineUsersWidget-CSvNe2rC.js → OnlineUsersWidget-CmBqFLAA.js} +1 -1
  13. package/dist/admin/{Settings-xokFI5LO.js → Settings-BBs2FDp7.js} +87 -266
  14. package/dist/admin/{Settings-avD0DbXP.mjs → Settings-CKDNGJhl.mjs} +79 -258
  15. package/dist/admin/{de-BQlEdBMr.mjs → de-CK-HuY41.mjs} +48 -7
  16. package/dist/admin/{de-HcJ19LKI.js → de-CSRQPn6F.js} +48 -7
  17. package/dist/admin/{en-DI-98CPM.js → en-DCtAgGEa.js} +48 -7
  18. package/dist/admin/{en-DzuXWL1W.mjs → en-KZ5ajaAR.mjs} +48 -7
  19. package/dist/admin/{es-BfyED9YI.mjs → es-B7k8taWV.mjs} +48 -7
  20. package/dist/admin/{es-Cm0Eklav.js → es-CKT00l4K.js} +48 -7
  21. package/dist/admin/{fr-C3nzszsI.js → fr-B2EdBFSb.js} +48 -7
  22. package/dist/admin/{fr-CzFNGWq0.mjs → fr-Q2gmYqCn.mjs} +48 -7
  23. package/dist/admin/{index-6zc5D8eb.mjs → index-BPbs1GyP.mjs} +386 -61
  24. package/dist/admin/{index-Dk5Jqe5U.js → index-Cho0XGZ1.js} +340 -15
  25. package/dist/admin/index.js +1 -1
  26. package/dist/admin/index.mjs +2 -2
  27. package/dist/admin/{pt-BPZ6chPT.js → pt-CcMUcqDy.js} +48 -7
  28. package/dist/admin/{pt-DmyQnGI_.mjs → pt-CmxZTaf2.mjs} +48 -7
  29. package/dist/admin/useBreakpoint-CoBfu0Ov.js +62 -0
  30. package/dist/admin/useBreakpoint-CuyIc2qy.mjs +63 -0
  31. package/dist/server/index.js +1809 -400
  32. package/dist/server/index.mjs +1809 -400
  33. package/package.json +9 -4
  34. package/dist/admin/dashboardModel-BBNRgcEr.mjs +0 -170
  35. package/dist/admin/dashboardModel-D4389iIV.js +0 -169
@@ -0,0 +1,244 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useState, useRef } from "react";
3
+ import { createRoot } from "react-dom/client";
4
+ import { IntlProvider } from "react-intl";
5
+ import { lightTheme, DesignSystemProvider, darkTheme, Box, Flex, Typography, VisuallyHidden, Button, Loader } from "@strapi/design-system";
6
+ import { f as pluginId, aQ as readTabState, a1 as useSettingsTranslate, a5 as formatClock, aR as secondsUntil } from "./index-BPbs1GyP.mjs";
7
+ import { u as useBreakpoint } from "./useBreakpoint-CuyIc2qy.mjs";
8
+ const BANNER_HEIGHT = "4.8rem";
9
+ const POLL_MS = 30 * 1e3;
10
+ function useTabState() {
11
+ const [state, setState] = useState(() => readTabState(window));
12
+ useEffect(() => {
13
+ const update = () => setState(readTabState(window));
14
+ window.addEventListener("msm-impersonation-change", update);
15
+ return () => window.removeEventListener("msm-impersonation-change", update);
16
+ }, []);
17
+ return state;
18
+ }
19
+ function useCountdown(iso) {
20
+ const [seconds, setSeconds] = useState(() => secondsUntil(iso));
21
+ useEffect(() => {
22
+ const timer = window.setInterval(() => setSeconds(secondsUntil(iso)), 1e3);
23
+ return () => window.clearInterval(timer);
24
+ }, [iso]);
25
+ return seconds;
26
+ }
27
+ const ActiveBar = ({ state, actions }) => {
28
+ const { t } = useSettingsTranslate();
29
+ const seconds = useCountdown(state.expiresAt);
30
+ const [ending, setEnding] = useState(false);
31
+ const { isBelowMedium } = useBreakpoint();
32
+ const expiredOnce = useRef(false);
33
+ const impersonation = state.impersonation || {};
34
+ useEffect(() => {
35
+ if (seconds > 0 || expiredOnce.current) return;
36
+ expiredOnce.current = true;
37
+ actions.end("expired");
38
+ }, [seconds, actions]);
39
+ useEffect(() => {
40
+ const check = async () => {
41
+ try {
42
+ const response = await window.fetch(
43
+ `${actions.backendURL()}/${pluginId}/admin-impersonation/self`,
44
+ { headers: { Authorization: `Bearer ${state.token}`, Accept: "application/json" } }
45
+ );
46
+ if (response.status === 401) actions.markEnded("ended");
47
+ } catch {
48
+ }
49
+ };
50
+ const timer = window.setInterval(check, POLL_MS);
51
+ return () => window.clearInterval(timer);
52
+ }, [actions, state.token]);
53
+ return /* @__PURE__ */ jsx(
54
+ Box,
55
+ {
56
+ background: "neutral800",
57
+ paddingLeft: 4,
58
+ paddingRight: 4,
59
+ paddingTop: 2,
60
+ paddingBottom: 2,
61
+ height: BANNER_HEIGHT,
62
+ "data-impersonation-banner": "",
63
+ children: /* @__PURE__ */ jsxs(Flex, { height: "100%", gap: 3, alignItems: "center", justifyContent: "space-between", children: [
64
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", minWidth: 0, wrap: "wrap", children: [
65
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral0", ellipsis: true, children: isBelowMedium ? /* @__PURE__ */ jsxs(Fragment, { children: [
66
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: t("impersonation.tab.banner.signedInAs", "Signed in as {name}", { name: "" }) }),
67
+ impersonation.targetName || "—"
68
+ ] }) : t("impersonation.tab.banner.signedInAs", "Signed in as {name}", {
69
+ name: impersonation.targetName || "—"
70
+ }) }),
71
+ /* @__PURE__ */ jsx(
72
+ Box,
73
+ {
74
+ background: impersonation.allowChanges ? "danger600" : "neutral0",
75
+ hasRadius: true,
76
+ paddingLeft: 2,
77
+ paddingRight: 2,
78
+ children: /* @__PURE__ */ jsx(
79
+ Typography,
80
+ {
81
+ variant: "sigma",
82
+ textColor: impersonation.allowChanges ? "neutral0" : "neutral800",
83
+ children: impersonation.allowChanges ? t("impersonation.tab.banner.changes", "Changes allowed") : t("impersonation.tab.banner.readOnly", "Read-only")
84
+ }
85
+ )
86
+ }
87
+ ),
88
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral0", "aria-live": "off", children: t("impersonation.tab.banner.endsIn", "Ends in {time}", {
89
+ time: formatClock(seconds)
90
+ }) })
91
+ ] }),
92
+ /* @__PURE__ */ jsx(
93
+ Button,
94
+ {
95
+ size: "S",
96
+ variant: "danger",
97
+ loading: ending,
98
+ onClick: async () => {
99
+ setEnding(true);
100
+ await actions.end("ended");
101
+ },
102
+ children: isBelowMedium ? t("impersonation.tab.banner.endShort", "End") : t("impersonation.tab.banner.end", "End impersonation")
103
+ }
104
+ )
105
+ ] })
106
+ }
107
+ );
108
+ };
109
+ const Overlay = ({ state, actions }) => {
110
+ const { t } = useSettingsTranslate();
111
+ const heading = useRef(null);
112
+ useEffect(() => {
113
+ heading.current?.focus();
114
+ }, [state.phase]);
115
+ const landing = state.phase === "landing";
116
+ const failed = state.phase === "failed";
117
+ let title;
118
+ let body;
119
+ if (landing) {
120
+ title = t("impersonation.tab.landing.title", "Signing in as another admin…");
121
+ body = null;
122
+ } else if (failed) {
123
+ title = t("impersonation.tab.failed.title", "The sign-in did not work");
124
+ body = t(
125
+ "impersonation.tab.failed.body",
126
+ "The link was already used or is older than one minute. Start again from the Admin panel page of the Session Manager."
127
+ );
128
+ } else {
129
+ title = state.reason === "expired" ? t("impersonation.tab.ended.expiredTitle", "The impersonation timed out") : t("impersonation.tab.ended.title", "The impersonation ended");
130
+ body = t(
131
+ "impersonation.tab.ended.body",
132
+ "You are no longer signed in as {name}. Your other tabs were not affected. You can close this tab.",
133
+ { name: state.impersonation?.targetName || "—" }
134
+ );
135
+ }
136
+ return /* @__PURE__ */ jsx(
137
+ Box,
138
+ {
139
+ position: "fixed",
140
+ top: 0,
141
+ left: 0,
142
+ right: 0,
143
+ bottom: 0,
144
+ background: "neutral100",
145
+ zIndex: 1e3,
146
+ padding: 4,
147
+ "data-impersonation-overlay": state.phase,
148
+ children: /* @__PURE__ */ jsx(Flex, { height: "100%", justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsx(
149
+ Box,
150
+ {
151
+ background: "neutral0",
152
+ hasRadius: true,
153
+ shadow: "popupShadow",
154
+ padding: 6,
155
+ maxWidth: "48rem",
156
+ width: "100%",
157
+ role: "dialog",
158
+ "aria-modal": "true",
159
+ "aria-labelledby": "msm-impersonation-overlay-title",
160
+ children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
161
+ /* @__PURE__ */ jsx(
162
+ Typography,
163
+ {
164
+ id: "msm-impersonation-overlay-title",
165
+ variant: "beta",
166
+ tag: "h1",
167
+ textColor: "neutral800",
168
+ tabIndex: -1,
169
+ ref: heading,
170
+ style: { outline: "none" },
171
+ children: title
172
+ }
173
+ ),
174
+ landing ? /* @__PURE__ */ jsx(Loader, { small: true, children: title }) : null,
175
+ body ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", tag: "p", children: body }) : null,
176
+ !landing ? /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", justifyContent: "flex-end", children: [
177
+ /* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: () => actions.leave(), children: t("impersonation.tab.backToMyAdmin", "Back to my admin panel") }),
178
+ /* @__PURE__ */ jsx(Button, { onClick: () => window.close(), children: t("impersonation.tab.close", "Close tab") })
179
+ ] }) : null
180
+ ] })
181
+ }
182
+ ) })
183
+ }
184
+ );
185
+ };
186
+ const ImpersonationTabUi = ({ actions }) => {
187
+ const state = useTabState();
188
+ useEffect(() => {
189
+ const root = document.documentElement;
190
+ if (state?.phase === "active") root.setAttribute("data-msm-impersonating", "");
191
+ else root.removeAttribute("data-msm-impersonating");
192
+ }, [state?.phase]);
193
+ if (!state) return null;
194
+ if (state.phase === "active") return /* @__PURE__ */ jsx(ActiveBar, { state, actions });
195
+ return /* @__PURE__ */ jsx(Overlay, { state, actions });
196
+ };
197
+ function currentTheme() {
198
+ let stored;
199
+ try {
200
+ stored = window.localStorage.getItem("STRAPI_THEME") || "system";
201
+ } catch {
202
+ stored = "system";
203
+ }
204
+ const dark = stored === "dark" || stored === "system" && window.matchMedia?.("(prefers-color-scheme: dark)").matches;
205
+ return dark ? darkTheme : lightTheme;
206
+ }
207
+ const LOADERS = {
208
+ en: () => import("./en-KZ5ajaAR.mjs"),
209
+ de: () => import("./de-CK-HuY41.mjs"),
210
+ es: () => import("./es-B7k8taWV.mjs"),
211
+ fr: () => import("./fr-Q2gmYqCn.mjs"),
212
+ pt: () => import("./pt-CmxZTaf2.mjs")
213
+ };
214
+ async function mountImpersonationBanner(actions) {
215
+ if (document.getElementById("msm-impersonation-root")) return;
216
+ let locale;
217
+ try {
218
+ const stored = window.localStorage.getItem("strapi-admin-language") || "en";
219
+ locale = LOADERS[stored] ? stored : "en";
220
+ } catch {
221
+ locale = "en";
222
+ }
223
+ const raw = (await LOADERS[locale]()).default;
224
+ const messages = Object.fromEntries(
225
+ Object.entries(raw).map(([key, value]) => [`${pluginId}.${key}`, value])
226
+ );
227
+ const style = document.createElement("style");
228
+ style.textContent = `html[data-msm-impersonating] body { padding-top: ${BANNER_HEIGHT}; }
229
+ ${lightTheme.breakpoints.large} {
230
+ html[data-msm-impersonating] #strapi nav { top: ${BANNER_HEIGHT}; height: calc(100dvh - ${BANNER_HEIGHT}); }
231
+ }
232
+ #msm-impersonation-root { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; }`;
233
+ document.head.appendChild(style);
234
+ const container = document.createElement("div");
235
+ container.id = "msm-impersonation-root";
236
+ document.body.prepend(container);
237
+ createRoot(container).render(
238
+ /* @__PURE__ */ jsx(IntlProvider, { locale, messages, defaultLocale: "en", children: /* @__PURE__ */ jsx(DesignSystemProvider, { locale, theme: currentTheme(), children: /* @__PURE__ */ jsx(ImpersonationTabUi, { actions }) }) })
239
+ );
240
+ }
241
+ export {
242
+ BANNER_HEIGHT,
243
+ mountImpersonationBanner
244
+ };
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
+ const client = require("react-dom/client");
6
+ const reactIntl = require("react-intl");
7
+ const designSystem = require("@strapi/design-system");
8
+ const index = require("./index-Cho0XGZ1.js");
9
+ const useBreakpoint = require("./useBreakpoint-CoBfu0Ov.js");
10
+ const BANNER_HEIGHT = "4.8rem";
11
+ const POLL_MS = 30 * 1e3;
12
+ function useTabState() {
13
+ const [state, setState] = react.useState(() => index.readTabState(window));
14
+ react.useEffect(() => {
15
+ const update = () => setState(index.readTabState(window));
16
+ window.addEventListener("msm-impersonation-change", update);
17
+ return () => window.removeEventListener("msm-impersonation-change", update);
18
+ }, []);
19
+ return state;
20
+ }
21
+ function useCountdown(iso) {
22
+ const [seconds, setSeconds] = react.useState(() => index.secondsUntil(iso));
23
+ react.useEffect(() => {
24
+ const timer = window.setInterval(() => setSeconds(index.secondsUntil(iso)), 1e3);
25
+ return () => window.clearInterval(timer);
26
+ }, [iso]);
27
+ return seconds;
28
+ }
29
+ const ActiveBar = ({ state, actions }) => {
30
+ const { t } = index.useSettingsTranslate();
31
+ const seconds = useCountdown(state.expiresAt);
32
+ const [ending, setEnding] = react.useState(false);
33
+ const { isBelowMedium } = useBreakpoint.useBreakpoint();
34
+ const expiredOnce = react.useRef(false);
35
+ const impersonation = state.impersonation || {};
36
+ react.useEffect(() => {
37
+ if (seconds > 0 || expiredOnce.current) return;
38
+ expiredOnce.current = true;
39
+ actions.end("expired");
40
+ }, [seconds, actions]);
41
+ react.useEffect(() => {
42
+ const check = async () => {
43
+ try {
44
+ const response = await window.fetch(
45
+ `${actions.backendURL()}/${index.pluginId}/admin-impersonation/self`,
46
+ { headers: { Authorization: `Bearer ${state.token}`, Accept: "application/json" } }
47
+ );
48
+ if (response.status === 401) actions.markEnded("ended");
49
+ } catch {
50
+ }
51
+ };
52
+ const timer = window.setInterval(check, POLL_MS);
53
+ return () => window.clearInterval(timer);
54
+ }, [actions, state.token]);
55
+ return /* @__PURE__ */ jsxRuntime.jsx(
56
+ designSystem.Box,
57
+ {
58
+ background: "neutral800",
59
+ paddingLeft: 4,
60
+ paddingRight: 4,
61
+ paddingTop: 2,
62
+ paddingBottom: 2,
63
+ height: BANNER_HEIGHT,
64
+ "data-impersonation-banner": "",
65
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { height: "100%", gap: 3, alignItems: "center", justifyContent: "space-between", children: [
66
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", minWidth: 0, wrap: "wrap", children: [
67
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral0", ellipsis: true, children: isBelowMedium ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
68
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("impersonation.tab.banner.signedInAs", "Signed in as {name}", { name: "" }) }),
69
+ impersonation.targetName || "—"
70
+ ] }) : t("impersonation.tab.banner.signedInAs", "Signed in as {name}", {
71
+ name: impersonation.targetName || "—"
72
+ }) }),
73
+ /* @__PURE__ */ jsxRuntime.jsx(
74
+ designSystem.Box,
75
+ {
76
+ background: impersonation.allowChanges ? "danger600" : "neutral0",
77
+ hasRadius: true,
78
+ paddingLeft: 2,
79
+ paddingRight: 2,
80
+ children: /* @__PURE__ */ jsxRuntime.jsx(
81
+ designSystem.Typography,
82
+ {
83
+ variant: "sigma",
84
+ textColor: impersonation.allowChanges ? "neutral0" : "neutral800",
85
+ children: impersonation.allowChanges ? t("impersonation.tab.banner.changes", "Changes allowed") : t("impersonation.tab.banner.readOnly", "Read-only")
86
+ }
87
+ )
88
+ }
89
+ ),
90
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral0", "aria-live": "off", children: t("impersonation.tab.banner.endsIn", "Ends in {time}", {
91
+ time: index.formatClock(seconds)
92
+ }) })
93
+ ] }),
94
+ /* @__PURE__ */ jsxRuntime.jsx(
95
+ designSystem.Button,
96
+ {
97
+ size: "S",
98
+ variant: "danger",
99
+ loading: ending,
100
+ onClick: async () => {
101
+ setEnding(true);
102
+ await actions.end("ended");
103
+ },
104
+ children: isBelowMedium ? t("impersonation.tab.banner.endShort", "End") : t("impersonation.tab.banner.end", "End impersonation")
105
+ }
106
+ )
107
+ ] })
108
+ }
109
+ );
110
+ };
111
+ const Overlay = ({ state, actions }) => {
112
+ const { t } = index.useSettingsTranslate();
113
+ const heading = react.useRef(null);
114
+ react.useEffect(() => {
115
+ heading.current?.focus();
116
+ }, [state.phase]);
117
+ const landing = state.phase === "landing";
118
+ const failed = state.phase === "failed";
119
+ let title;
120
+ let body;
121
+ if (landing) {
122
+ title = t("impersonation.tab.landing.title", "Signing in as another admin…");
123
+ body = null;
124
+ } else if (failed) {
125
+ title = t("impersonation.tab.failed.title", "The sign-in did not work");
126
+ body = t(
127
+ "impersonation.tab.failed.body",
128
+ "The link was already used or is older than one minute. Start again from the Admin panel page of the Session Manager."
129
+ );
130
+ } else {
131
+ title = state.reason === "expired" ? t("impersonation.tab.ended.expiredTitle", "The impersonation timed out") : t("impersonation.tab.ended.title", "The impersonation ended");
132
+ body = t(
133
+ "impersonation.tab.ended.body",
134
+ "You are no longer signed in as {name}. Your other tabs were not affected. You can close this tab.",
135
+ { name: state.impersonation?.targetName || "—" }
136
+ );
137
+ }
138
+ return /* @__PURE__ */ jsxRuntime.jsx(
139
+ designSystem.Box,
140
+ {
141
+ position: "fixed",
142
+ top: 0,
143
+ left: 0,
144
+ right: 0,
145
+ bottom: 0,
146
+ background: "neutral100",
147
+ zIndex: 1e3,
148
+ padding: 4,
149
+ "data-impersonation-overlay": state.phase,
150
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { height: "100%", justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
151
+ designSystem.Box,
152
+ {
153
+ background: "neutral0",
154
+ hasRadius: true,
155
+ shadow: "popupShadow",
156
+ padding: 6,
157
+ maxWidth: "48rem",
158
+ width: "100%",
159
+ role: "dialog",
160
+ "aria-modal": "true",
161
+ "aria-labelledby": "msm-impersonation-overlay-title",
162
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
163
+ /* @__PURE__ */ jsxRuntime.jsx(
164
+ designSystem.Typography,
165
+ {
166
+ id: "msm-impersonation-overlay-title",
167
+ variant: "beta",
168
+ tag: "h1",
169
+ textColor: "neutral800",
170
+ tabIndex: -1,
171
+ ref: heading,
172
+ style: { outline: "none" },
173
+ children: title
174
+ }
175
+ ),
176
+ landing ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: title }) : null,
177
+ body ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", tag: "p", children: body }) : null,
178
+ !landing ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", justifyContent: "flex-end", children: [
179
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: () => actions.leave(), children: t("impersonation.tab.backToMyAdmin", "Back to my admin panel") }),
180
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: () => window.close(), children: t("impersonation.tab.close", "Close tab") })
181
+ ] }) : null
182
+ ] })
183
+ }
184
+ ) })
185
+ }
186
+ );
187
+ };
188
+ const ImpersonationTabUi = ({ actions }) => {
189
+ const state = useTabState();
190
+ react.useEffect(() => {
191
+ const root = document.documentElement;
192
+ if (state?.phase === "active") root.setAttribute("data-msm-impersonating", "");
193
+ else root.removeAttribute("data-msm-impersonating");
194
+ }, [state?.phase]);
195
+ if (!state) return null;
196
+ if (state.phase === "active") return /* @__PURE__ */ jsxRuntime.jsx(ActiveBar, { state, actions });
197
+ return /* @__PURE__ */ jsxRuntime.jsx(Overlay, { state, actions });
198
+ };
199
+ function currentTheme() {
200
+ let stored;
201
+ try {
202
+ stored = window.localStorage.getItem("STRAPI_THEME") || "system";
203
+ } catch {
204
+ stored = "system";
205
+ }
206
+ const dark = stored === "dark" || stored === "system" && window.matchMedia?.("(prefers-color-scheme: dark)").matches;
207
+ return dark ? designSystem.darkTheme : designSystem.lightTheme;
208
+ }
209
+ const LOADERS = {
210
+ en: () => Promise.resolve().then(() => require("./en-DCtAgGEa.js")),
211
+ de: () => Promise.resolve().then(() => require("./de-CSRQPn6F.js")),
212
+ es: () => Promise.resolve().then(() => require("./es-CKT00l4K.js")),
213
+ fr: () => Promise.resolve().then(() => require("./fr-B2EdBFSb.js")),
214
+ pt: () => Promise.resolve().then(() => require("./pt-CcMUcqDy.js"))
215
+ };
216
+ async function mountImpersonationBanner(actions) {
217
+ if (document.getElementById("msm-impersonation-root")) return;
218
+ let locale;
219
+ try {
220
+ const stored = window.localStorage.getItem("strapi-admin-language") || "en";
221
+ locale = LOADERS[stored] ? stored : "en";
222
+ } catch {
223
+ locale = "en";
224
+ }
225
+ const raw = (await LOADERS[locale]()).default;
226
+ const messages = Object.fromEntries(
227
+ Object.entries(raw).map(([key, value]) => [`${index.pluginId}.${key}`, value])
228
+ );
229
+ const style = document.createElement("style");
230
+ style.textContent = `html[data-msm-impersonating] body { padding-top: ${BANNER_HEIGHT}; }
231
+ ${designSystem.lightTheme.breakpoints.large} {
232
+ html[data-msm-impersonating] #strapi nav { top: ${BANNER_HEIGHT}; height: calc(100dvh - ${BANNER_HEIGHT}); }
233
+ }
234
+ #msm-impersonation-root { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; }`;
235
+ document.head.appendChild(style);
236
+ const container = document.createElement("div");
237
+ container.id = "msm-impersonation-root";
238
+ document.body.prepend(container);
239
+ client.createRoot(container).render(
240
+ /* @__PURE__ */ jsxRuntime.jsx(reactIntl.IntlProvider, { locale, messages, defaultLocale: "en", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.DesignSystemProvider, { locale, theme: currentTheme(), children: /* @__PURE__ */ jsxRuntime.jsx(ImpersonationTabUi, { actions }) }) })
241
+ );
242
+ }
243
+ exports.BANNER_HEIGHT = BANNER_HEIGHT;
244
+ exports.mountImpersonationBanner = mountImpersonationBanner;
@@ -6,7 +6,7 @@ import { Flex, Loader, Button, Box, Typography } from "@strapi/design-system";
6
6
  import { User, Lightning, Clock, Lock, WarningCircle } from "@strapi/icons";
7
7
  import * as StrapiAdmin from "@strapi/strapi/admin";
8
8
  import { useFetchClient } from "@strapi/strapi/admin";
9
- import { l as logSafeAdminError, F as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-6zc5D8eb.mjs";
9
+ import { l as logSafeAdminError, F as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-BPbs1GyP.mjs";
10
10
  function normalizeUserCounts(response) {
11
11
  const totalUsers = response?.data?.totalUsers;
12
12
  const blockedUsers = response?.data?.blockedUsers;
@@ -7,7 +7,7 @@ const styled = require("styled-components");
7
7
  const designSystem = require("@strapi/design-system");
8
8
  const icons = require("@strapi/icons");
9
9
  const StrapiAdmin = require("@strapi/strapi/admin");
10
- const index = require("./index-Dk5Jqe5U.js");
10
+ const index = require("./index-Cho0XGZ1.js");
11
11
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
12
12
  function _interopNamespace(e) {
13
13
  if (e && e.__esModule) return e;