'use client';

import { createContext, useContext } from 'react';

type SidebarPreferenceContextValue = {
  initialSidebarCollapsed: boolean;
};

const SidebarPreferenceContext =
  createContext<SidebarPreferenceContextValue>({
    initialSidebarCollapsed: false
  });

type SidebarPreferenceProviderProps = {
  children: React.ReactNode;
  initialSidebarCollapsed: boolean;
};

export function SidebarPreferenceProvider({
  children,
  initialSidebarCollapsed
}: SidebarPreferenceProviderProps) {
  return (
    <SidebarPreferenceContext.Provider value={{ initialSidebarCollapsed }}>
      {children}
    </SidebarPreferenceContext.Provider>
  );
}

export function useSidebarPreference() {
  return useContext(SidebarPreferenceContext);
}
