import { useEffect, useRef, useState, type ReactNode } from "react";
import { ChevronDown } from "lucide-react";
import { useTranslation } from "react-i18next";
import { ToggleButton } from "@/components/ui/toggle-button";
import { SettingsGroup, SettingsRow } from "@/components/settings/shared/SettingsControls";
import { Dialog, DialogContent, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
import { Disclosure } from "@/components/ui/disclosure";
export function SettingsAdvancedOptions({ children, initialOpen = false }: { children: ReactNode; initialOpen?: boolean }) {
const { t } = useTranslation();
return (
{t("settings.runtimeConfig.advancedOptions")}
>}
>
{children}
);
}
export function SettingsFeature({
title, enabled, onChange, disabled, initialOpen = false, error, children, onClose,
}: {
title: string;
enabled: boolean;
onChange: (enabled: boolean) => void;
disabled?: boolean;
initialOpen?: boolean;
error?: string;
children?: ReactNode;
onClose?: () => void;
}) {
const { t } = useTranslation();
const [open, setOpen] = useState(initialOpen && enabled);
const section = useRef(null);
const opener = useRef(null);
const changeOpen = (next: boolean) => {
if (next) opener.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
setOpen(next);
};
useEffect(() => {
if (initialOpen && enabled) {
setOpen(true);
section.current?.scrollIntoView?.({ block: "nearest" });
}
}, [initialOpen, enabled]);
return (
{error && !open ? {error}
: null}
);
}