/**
 * 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.
 */

const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../node_modules/classnames/index.js");
const require_TruncatedText = require("../../TruncatedText/TruncatedText.js");
const require_context = require("./context.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _carbon_react = require("@carbon/react");
let _carbon_react_icons = require("@carbon/react/icons");
//#region src/components/Tearsheet/next/TearsheetHeaderContent.tsx
/**
* Copyright IBM Corp. 2025
*
* 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__ */ require_runtime.__toESM(require_index.default);
const TearsheetHeaderContent = react.default.forwardRef((props, ref) => {
	const { children, label, title, description, headerActions, titleStart, titleEnd, ...rest } = props;
	const carbonPrefix = (0, _carbon_react.usePrefix)();
	const { isSm, onClose, decorator, closeIconDescription, hideCloseButton = false } = (0, react.useContext)(require_context.TearsheetContext);
	const normalizedDecorator = (0, react.isValidElement)(decorator) && decorator.type === _carbon_react.AILabel ? (0, react.cloneElement)(decorator, { size: "sm" }) : decorator;
	const headerContent = /* @__PURE__ */ react.default.createElement("div", { className: `${require_context.blockClass}__header-content` }, label ? /* @__PURE__ */ react.default.createElement("div", { className: `${require_context.blockClass}__header-label` }, label) : null, /* @__PURE__ */ react.default.createElement("div", { className: `${require_context.blockClass}__content__title-wrapper` }, /* @__PURE__ */ react.default.createElement("h2", { className: (0, import_classnames.default)(`${require_context.blockClass}__header-title`) }, titleStart ? /* @__PURE__ */ react.default.createElement("span", { className: `${require_context.blockClass}__title-start` }, titleStart) : null, /* @__PURE__ */ react.default.createElement(require_TruncatedText.TruncatedText, {
		id: `${require_context.blockClass}__header-title__truncatedText`,
		className: `${require_context.blockClass}__content__title`,
		align: "bottom",
		autoAlign: true,
		value: title
	}), titleEnd ? /* @__PURE__ */ react.default.createElement("span", { className: `${require_context.blockClass}__title-end` }, titleEnd) : null)), /* @__PURE__ */ react.default.createElement("div", { className: `${require_context.blockClass}__header-description` }, description), children && /* @__PURE__ */ react.default.createElement("div", { className: `${require_context.blockClass}__header-content--extra` }, children));
	const headerActionsElement = headerActions && /* @__PURE__ */ react.default.createElement("div", { className: `${require_context.blockClass}__header-actions` }, headerActions);
	const decoratorElement = decorator && /* @__PURE__ */ react.default.createElement("div", { className: `${require_context.blockClass}__decorator` }, normalizedDecorator);
	const closeButtonElement = !hideCloseButton && /* @__PURE__ */ react.default.createElement("div", { className: `${require_context.blockClass}__close-button ${carbonPrefix}--modal-close-button` }, /* @__PURE__ */ react.default.createElement(_carbon_react.IconButton, {
		className: `${carbonPrefix}--modal-close`,
		label: closeIconDescription || "Close",
		onClick: onClose,
		align: "left"
	}, /* @__PURE__ */ react.default.createElement(_carbon_react_icons.Close, {
		size: 20,
		"aria-hidden": "true",
		tabIndex: "-1",
		className: `${carbonPrefix}--modal-close__icon`
	})));
	return /* @__PURE__ */ react.default.createElement("div", {
		className: `${require_context.blockClass}__header-content-wrapper`,
		ref
	}, !isSm ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, headerActionsElement, decoratorElement, closeButtonElement, headerContent) : /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, decoratorElement, closeButtonElement, headerContent, headerActionsElement));
});
//#endregion
exports.default = TearsheetHeaderContent;
