import { lazy, Suspense, useEffect, useState } from "react";
import { useI18n } from "./contexts/I18nContext";
const HudWindow = lazy(() => import("./components/launch/HudWindow"));
const SourceSelector = lazy(() =>
import("./components/launch/SourceSelector").then((module) => ({
default: module.SourceSelector,
})),
);
const CountdownOverlay = lazy(() =>
import("./components/countdown/CountdownOverlay").then((module) => ({
default: module.CountdownOverlay,
})),
);
const UpdateToastWindow = lazy(() =>
import("./components/launch/UpdateToastWindow").then((module) => ({
default: module.UpdateToastWindow,
})),
);
const EditorWindow = lazy(() => import("./components/video-editor/EditorWindow"));
export default function App() {
const [windowType] = useState(
() => new URLSearchParams(window.location.search).get("windowType") || "",
);
const { t } = useI18n();
const appIconSrc = "/app-icons/recordly-128.png";
useEffect(() => {
document.documentElement.dataset.windowType = windowType;
if (
windowType === "hud-overlay" ||
windowType === "source-selector" ||
windowType === "countdown" ||
windowType === "update-toast"
) {
document.body.style.background = "transparent";
document.documentElement.style.background = "transparent";
document.getElementById("root")?.style.setProperty("background", "transparent");
}
if (windowType === "hud-overlay") {
document.documentElement.classList.add("hud-overlay-window");
document.body.classList.add("hud-overlay-window");
document.getElementById("root")?.classList.add("hud-overlay-window");
window.electronAPI?.hudOverlaySetIgnoreMouse?.(true);
} else if (windowType === "update-toast") {
document.documentElement.style.overflow = "visible";
document.body.style.overflow = "visible";
document.getElementById("root")?.style.setProperty("overflow", "visible");
}
}, [windowType]);
useEffect(() => {
document.title =
windowType === "editor"
? t("app.editorTitle", "Recordly Editor")
: t("app.name", "Recordly");
}, [windowType, t]);
let content;
switch (windowType) {
case "hud-overlay":
content =
{t("app.subtitle", "Screen recording and editing")}