import { DrawerActions } from './components/Actions';
import { DrawerBody } from './components/Body';
import { DrawerContent } from './components/Content';
import { DrawerDoubleLayout } from './components/DoubleLayout';
import { DrawerFooter } from './components/Footer';
import { DrawerHeader } from './components/Header';
import { DrawerWrapper } from './components/Wrapper';
import { DrawerSizeContext } from './context';
import {
  type DrawerActionsProps,
  type DrawerBodyProps,
  type DrawerDoubleLayoutProps,
  type DrawerFooterProps,
  type DrawerHeaderProps,
  type DrawerProps,
  DrawerSize,
} from './types';

export { DrawerSizeContext };

export type { DrawerSizeContextValue } from './context';

/**
 * Main Drawer component - Uses composition components internally.
 * Drawer size (medium | large | taskFocus) is provided via DrawerSizeContext; clients can read or set it when enableTaskFocus is true.
 */
const Drawer = (props: DrawerProps) => {
  const {
    title = '',
    size = DrawerSize.SMALL,
    children,
    onClose,
    onBack,
    primaryButtonProps,
    secondaryButtonProps,
    footer,
    primaryContent,
    secondaryContent,
    hasBackButton,
    slotProps,
  } = props;

  return (
    <DrawerWrapper {...props}>
      <DrawerContent
        title={title}
        onClose={onClose}
        onBack={onBack}
        primaryButtonProps={primaryButtonProps}
        secondaryButtonProps={secondaryButtonProps}
        footer={footer}
        primaryContent={primaryContent}
        secondaryContent={secondaryContent}
        hasBackButton={hasBackButton}
        slotProps={slotProps}
        size={size}
        {...props}
      >
        {children}
      </DrawerContent>
    </DrawerWrapper>
  );
};

Drawer.Wrapper = DrawerWrapper;
Drawer.Header = DrawerHeader;
Drawer.Body = DrawerBody;
Drawer.DoubleLayout = DrawerDoubleLayout;
Drawer.Footer = DrawerFooter;
Drawer.Actions = DrawerActions;
Drawer.Content = DrawerContent;

export type {
  DrawerActionsProps,
  DrawerBodyProps,
  DrawerDoubleLayoutProps,
  DrawerFooterProps,
  DrawerHeaderProps,
  DrawerProps,
  DrawerSize,
};

export default Drawer;
