import { ReasoningStepRootProvider, useReasoningStepContext } from './context'
import {
  ReasoningStepHeader,
  ReasoningStepDetails,
  ReasoningStepDetailRow,
  ReasoningStepDefaultLayout,
} from './compound'
import type {
  ReasoningStepProps,
  ReasoningStepCompound,
  ReasoningStepDetail,
  ReasoningStepStatus,
} from './types'

// ===== ReasoningStep 便捷组件 =====

function ReasoningStepBase(props: ReasoningStepProps) {
  return (
    <ReasoningStepRootProvider {...props}>
      <ReasoningStepDefaultLayout />
    </ReasoningStepRootProvider>
  )
}

ReasoningStepBase.displayName = 'ReasoningStep'

// ===== 挂载复合组件 =====

type ReasoningStepBaseType = React.FC<ReasoningStepProps> & Partial<ReasoningStepCompound>

const ReasoningStepWithSlots = ReasoningStepBase as ReasoningStepBaseType

ReasoningStepWithSlots.Root = ReasoningStepRootProvider
ReasoningStepWithSlots.Header = ReasoningStepHeader
ReasoningStepWithSlots.Details = ReasoningStepDetails
ReasoningStepWithSlots.DetailRow = ReasoningStepDetailRow

export const ReasoningStep = ReasoningStepWithSlots as React.FC<ReasoningStepProps> &
  ReasoningStepCompound

// ===== 导出类型和工具 =====

export type { ReasoningStepProps, ReasoningStepDetail, ReasoningStepStatus }

export { useReasoningStepContext }
