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 }: { children: ReactNode }) {
const { t } = useTranslation();
return (
{t("settings.runtimeConfig.advancedOptions")}
>}
>
{children}
);
}
export function SettingsFeature({
title, enabled, onChange, disabled, initialOpen = false, error, children,
}: {
title: string;
enabled: boolean;
onChange: (enabled: boolean) => void;
disabled?: boolean;
initialOpen?: boolean;
error?: string;
children?: ReactNode;
}) {
const { t } = useTranslation();
const [open, setOpen] = useState(initialOpen && enabled);
const section = useRef(null);
useEffect(() => {
if (initialOpen && enabled) {
setOpen(true);
section.current?.scrollIntoView?.({ block: "nearest" });
}
}, [initialOpen, enabled]);
return (
{error && !open ? {error}
: null}
);
}