import { createContext, useContext, ReactNode } from 'react';

export interface CardStackContextType {
  isVisible: boolean;
  getAnimationProps: () => { isVisible: boolean };
  itemRefs?: Record<string, HTMLElement | null>;
}

const CardStackContext = createContext<CardStackContextType | undefined>(undefined);

export function useCardStack() {
  const context = useContext(CardStackContext);
  if (!context) {
    return {
      isVisible: false,
      getAnimationProps: () => ({ isVisible: false }),
      itemRefs: {}
    };
  }
  return context;
}

export function CardStackProvider({ children, value }: { children: ReactNode; value: CardStackContextType }) {
  return (
    <CardStackContext.Provider value={value}>
      {children}
    </CardStackContext.Provider>
  );
}

export default CardStackContext;
