import React, { useContext } from "react";
import classNames from "classnames";
import ConfigProviderContext from "../config-provider/ConfigProviderContext";
import SidebarContext from "./SidebarContext";
const Sidebar = (props) => {
  const {
    prefixCls,
    createNamespace
  } = useContext(ConfigProviderContext);
  const [bem] = createNamespace("sidebar", prefixCls);
  const getActive = () => +props.value;
  const setActive = (value) => {
    var _a;
    if (value !== getActive()) {
      (_a = props.onChange) == null ? void 0 : _a.call(props, value);
    }
  };
  return /* @__PURE__ */ React.createElement(SidebarContext.Provider, {
    value: {
      getActive,
      setActive
    }
  }, /* @__PURE__ */ React.createElement("div", {
    role: "tablist",
    className: classNames(bem())
  }, React.Children.toArray(props.children).filter(Boolean).map((child, index) => /* @__PURE__ */ React.cloneElement(child, {
    index
  }))));
};
Sidebar.defaultProps = {
  value: "0"
};
var stdin_default = Sidebar;
export {
  stdin_default as default
};
