import * as React from 'react'
import * as SeparatorPrimitive from '@radix-ui/react-separator'
import tw from 'twin.macro'
import type { TwStyle } from 'twin.macro'

type OrientationType = 'horizontal' | 'vertical'
const ORIENTATION_MAP = {
  horizontal: tw`h-[1px] w-full`,
  vertical: tw`h-full w-[1px]`,
} satisfies Record<OrientationType, TwStyle>
const Separator = React.forwardRef<
  React.ElementRef<typeof SeparatorPrimitive.Root>,
  React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
>(({ orientation = 'horizontal', decorative = true, ...props }, ref) => (
  <SeparatorPrimitive.Root
    ref={ref}
    decorative={decorative}
    orientation={orientation}
    css={[tw`bg-slate-200 dark:bg-slate-700`, ORIENTATION_MAP[orientation]]}
    {...props}
  />
))
Separator.displayName = SeparatorPrimitive.Root.displayName

const _Separator = Separator
export {
  _Separator as Separator,
  type OrientationType as SeparatorOrientationType,
  ORIENTATION_MAP as SEPARATOR_ORIENTATION_MAP,
}
