"use client";
import * as React from 'react';
import { cn } from '@hanzo/ui/lib/utils';
import { jsx, jsxs } from 'react/jsx-runtime';

var CodeTabs = React.forwardRef(
  ({ className, tabs = [], defaultTab = 0, ...props }, ref) => {
    const [activeTab, setActiveTab] = React.useState(defaultTab);
    if (tabs.length === 0) {
      return /* @__PURE__ */ jsx(
        "div",
        {
          ref,
          className: cn(
            "rounded-lg border bg-card p-6 text-card-foreground shadow-sm",
            className
          ),
          ...props,
          children: /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "No code tabs available. Add tabs to display code snippets." })
        }
      );
    }
    return /* @__PURE__ */ jsxs(
      "div",
      {
        ref,
        className: cn(
          "rounded-lg border bg-card text-card-foreground shadow-sm",
          className
        ),
        ...props,
        children: [
          /* @__PURE__ */ jsx("div", { className: "border-b", children: /* @__PURE__ */ jsx("div", { className: "flex gap-1 p-2", children: tabs.map((tab, index) => /* @__PURE__ */ jsx(
            "button",
            {
              onClick: () => setActiveTab(index),
              className: cn(
                "rounded-md px-4 py-2 text-sm font-medium transition-colors",
                activeTab === index ? "bg-primary text-primary-foreground" : "hover:bg-muted"
              ),
              children: tab.label
            },
            index
          )) }) }),
          /* @__PURE__ */ jsx("div", { className: "p-4", children: /* @__PURE__ */ jsx("pre", { className: "overflow-x-auto rounded-md bg-muted p-4", children: /* @__PURE__ */ jsx("code", { className: "text-sm", children: tabs[activeTab]?.code }) }) })
        ]
      }
    );
  }
);
CodeTabs.displayName = "CodeTabs";

export { CodeTabs };
