import Card from "../../../../ui/Card";
import { Tab, Tabs, TabList, TabPanel } from "react-tabs";
import "react-tabs/style/react-tabs.css";
import RegionSelector from "./RegionSelector";
import type { PaintedCell, Region } from "../../../../types/types";
import type { RefObject } from "react";
import CameraPanel from "./CameraPanel";

type CameraSettingsProps = {
  regions: Region[];
  selectedRegionIndex: number;
  onSelectRegion: (index: number) => void;
  onChangeRegionColour: (index: number, colour: string) => void;
  mode: string;
  onSelectMode: (mode: string) => void;
  setTabIndex: (tabIndex: number) => void;
  tabIndex: number;
  paintedCells: RefObject<Map<string, PaintedCell>>;
  onAddRegion: () => void;
  OnRemoveRegion: () => void;
};

const CameraSettings = ({
  regions,
  selectedRegionIndex,
  onSelectRegion,
  onChangeRegionColour,
  mode,
  onSelectMode,
  tabIndex,
  setTabIndex,
  paintedCells,
  onAddRegion,
  OnRemoveRegion,
}: CameraSettingsProps) => {
  return (
    <Card className="p-4 col-span-3 row-span-5 col-start-3 md:col-span-3 md:row-span-5 max-h-screen overflow-auto">
      <Tabs
        selectedTabClassName="bg-gray-300 text-gray-900 font-semibold border-none rounded-sm mb-1"
        className="react-tabs"
        onSelect={(index) => setTabIndex(index)}
      >
        <TabList>
          <Tab>Target Detection</Tab>
          <Tab>Camera 1</Tab>
          <Tab>Camera 2</Tab>
          <Tab>Camera 3</Tab>
        </TabList>
        <TabPanel>
          <RegionSelector
            regions={regions}
            selectedRegionIndex={selectedRegionIndex}
            onSelectRegion={onSelectRegion}
            onChangeRegionColour={onChangeRegionColour}
            mode={mode}
            onSelectMode={onSelectMode}
            paintedCells={paintedCells}
            onAddRegion={onAddRegion}
            OnRemoveRegion={OnRemoveRegion}
          />
        </TabPanel>
        <TabPanel>
          <CameraPanel tabIndex={tabIndex} />
        </TabPanel>
        <TabPanel>
          <CameraPanel tabIndex={tabIndex} />
        </TabPanel>
        <TabPanel>
          <CameraPanel tabIndex={tabIndex} />
        </TabPanel>
      </Tabs>
    </Card>
  );
};

export default CameraSettings;
