/**
 * liveTvSlice — Live TV channel data.
 * CLAUDE.md defines this slice. The live TV section is driven by the home
 * section list (type 9 = Channel, screen_layout = "channel") and by the
 * channel detail slice. This slice holds any standalone live-TV state.
 */
import { createSlice } from "@reduxjs/toolkit";
import type { RootState } from "@/store/store";

interface LiveTvState {
  activeChannelId: number | null;
}

const initialState: LiveTvState = {
  activeChannelId: null,
};

export const liveTvSlice = createSlice({
  name: "liveTv",
  initialState,
  reducers: {
    setActiveChannel: (state, action) => {
      state.activeChannelId = action.payload;
    },
    clearActiveChannel: (state) => {
      state.activeChannelId = null;
    },
  },
});

export const { setActiveChannel, clearActiveChannel } = liveTvSlice.actions;
export default liveTvSlice.reducer;

export const selectActiveChannelId = (s: RootState) => s.liveTv.activeChannelId;
