import { create } from "zustand";

export type RecordingMode = "video" | "audio";

const KEY = "llink:recording-mode";

interface MediaSettingsState {
  recordingMode: RecordingMode;
  setRecordingMode: (mode: RecordingMode) => void;
}

export const useMediaSettingsStore = create<MediaSettingsState>((set) => ({
  recordingMode: (() => {
    const stored = localStorage.getItem(KEY);
    return stored === "audio" ? "audio" : "video";
  })(),
  setRecordingMode: (mode) => {
    localStorage.setItem(KEY, mode);
    set({ recordingMode: mode });
  },
}));
