/**
 * Copyright IBM Corp. 2020, 2026
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

import { __toESM } from "../../_virtual/_rolldown/runtime.js";
import { require_classnames } from "../../node_modules/classnames/index.js";
import { ToolbarContext, blockClass as blockClass$1 } from "./Toolbar.js";
import React, { forwardRef, useContext } from "react";
import { bool, func, node, string } from "prop-types";
import { IconButton } from "@carbon/react";

//#region src/components/Toolbar/ToolbarButton.tsx
/**
* Copyright IBM Corp. 2021, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
var import_classnames = /* @__PURE__ */ __toESM(require_classnames());
const blockClass = `${blockClass$1}__button`;
/** Toolbar buttons are common functions performed as part of a products interface or an open window.  */
const ToolbarButton = forwardRef(({ caret = false, children, className, renderIcon, iconDescription: deprecated_iconDescription = "", label, ...rest }, ref) => {
	const Icon = renderIcon;
	return /* @__PURE__ */ React.createElement(IconButton, {
		align: useContext(ToolbarContext)?.vertical ? "right" : "top",
		...rest,
		label: label ?? deprecated_iconDescription,
		ref,
		className: (0, import_classnames.default)(className, { [`${blockClass}--caret`]: caret }),
		kind: "ghost",
		size: "md"
	}, /* @__PURE__ */ React.createElement(React.Fragment, null, Icon ? /* @__PURE__ */ React.createElement(Icon, null) : null, children, caret && /* @__PURE__ */ React.createElement("span", { className: `${blockClass}__caret` })));
});
ToolbarButton.displayName = "ToolbarButton";
const deprecatedProps = { iconDescription: string };
ToolbarButton.propTypes = {
	caret: bool,
	children: node,
	className: string,
	label: string.isRequired,
	renderIcon: func.isRequired,
	...deprecatedProps
};

//#endregion
export { ToolbarButton };