import React, { useContext, useMemo } from "react";
import classnames from "classnames";
import { Button } from "../button";
import ActionBarContext from "./ActionBarContext";
import ConfigProviderContext from "../config-provider/ConfigProviderContext";
const ActionBarButton = (props) => {
  const {
    type,
    icon,
    text,
    color,
    loading,
    disabled,
    index = 1
  } = props;
  const {
    prefixCls,
    createNamespace
  } = useContext(ConfigProviderContext);
  const [bem] = createNamespace("action-bar-button", prefixCls);
  const {
    parent
  } = useContext(ActionBarContext);
  const isFirst = useMemo(() => {
    if (parent) {
      const prev = parent.children[index - 1];
      return !(prev && "isButton" in prev.type);
    }
    return false;
  }, [index, parent]);
  const isLast = useMemo(() => {
    if (parent) {
      const next = parent.children[index + 1];
      return !(next && "isButton" in next.type);
    }
    return false;
  }, [index, parent]);
  return /* @__PURE__ */ React.createElement(Button, {
    className: classnames(props.className, bem([type, {
      last: isLast,
      first: isFirst
    }])),
    style: props.style,
    size: "large",
    type,
    icon,
    color,
    loading,
    disabled,
    onClick: props.onClick
  }, props.children ? props.children : text);
};
const ActionBarButtonNameSpace = Object.assign(ActionBarButton, {
  isButton: true
});
var stdin_default = ActionBarButtonNameSpace;
export {
  stdin_default as default
};
