"use client"

import type { ReactNode } from "react"
import { cn } from "@/lib/utils"

export function AutomationBorderedFieldset({
  legend,
  children,
  className,
  legendClassName,
  contentClassName,
}: {
  legend: ReactNode
  children: ReactNode
  className?: string
  legendClassName?: string
  contentClassName?: string
}) {
  return (
    <fieldset
      className={cn("m-0 min-w-0 rounded-md border border-border p-0", className)}
    >
      <legend
        className={cn(
          "ml-2.5 w-auto max-w-[calc(100%-1.25rem)] px-1 text-sm font-medium leading-none text-foreground",
          legendClassName
        )}
      >
        {legend}
      </legend>
      <div className={cn("space-y-3 px-3 pb-3 pt-2", contentClassName)}>{children}</div>
    </fieldset>
  )
}
