import React from "react";
import { ToggleSwitch } from "../ui/ToggleSwitch";
import { useSettings } from "../../hooks/useSettings";

interface AlwaysOnMicrophoneProps {
  descriptionMode?: "inline" | "tooltip";
  grouped?: boolean;
}

export const AlwaysOnMicrophone: React.FC<AlwaysOnMicrophoneProps> = ({
  descriptionMode = "tooltip",
  grouped = false,
}) => {
  const { getSetting, updateSetting, isUpdating } = useSettings();

  const alwaysOnMode = getSetting("always_on_microphone") || false;

  return (
    <ToggleSwitch
      checked={alwaysOnMode}
      onChange={(enabled) => updateSetting("always_on_microphone", enabled)}
      isUpdating={isUpdating("always_on_microphone")}
      label="Always-On Microphone"
      description="Keep microphone active for low latency recording. This may prevent your computer from sleeping."
      descriptionMode={descriptionMode}
      grouped={grouped}
    />
  );
};
