/**
 * 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_devtools = require('../../global/js/utils/devtools.js');
const require_context = require('./context.js');
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
prop_types = require_runtime.__toESM(prop_types);
let _carbon_react = require("@carbon/react");

//#region src/components/InterstitialScreen/InterstitialScreenHeader.tsx
/**
* Copyright IBM Corp. 2024, 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 InterstitialScreenHeader = react.default.forwardRef((props, ref) => {
	const { className = "", headerTitle, headerSubTitle, closeIconDescription, hideProgressIndicator, children, ...rest } = props;
	const { bodyChildrenData, isFullScreen, progStep, handleClose, stepCount } = react.default.useContext(require_context.InterstitialScreenContext);
	const headerBlockClass = `${require_context.blockClass}--internal-header`;
	const carbonPrefix = (0, _carbon_react.usePrefix)();
	const headerContent = () => {
		return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, (headerTitle || headerSubTitle) && /* @__PURE__ */ react.default.createElement("div", { className: `${require_context.blockClass}--titleContainer` }, headerTitle && /* @__PURE__ */ react.default.createElement("h1", null, headerTitle), headerSubTitle && /* @__PURE__ */ react.default.createElement("h2", null, headerSubTitle)), children, !hideProgressIndicator && bodyChildrenData && Array.isArray(bodyChildrenData) && /* @__PURE__ */ react.default.createElement("div", { className: `${require_context.blockClass}--progress` }, /* @__PURE__ */ react.default.createElement(_carbon_react.ProgressIndicator, {
			vertical: false,
			currentIndex: progStep
		}, bodyChildrenData?.map((child, idx) => {
			if (react.default.isValidElement(child)) {
				const stepKey = `${child.props?.stepTitle?.replace(/\s+/g, "") || "step"}-${idx}`;
				return /* @__PURE__ */ react.default.createElement(_carbon_react.ProgressStep, {
					key: stepKey,
					label: child.props.stepTitle ?? `Step ${idx + 1}`,
					translateWithId: child.props.translateWithId
				});
			}
		})), /* @__PURE__ */ react.default.createElement("div", {
			"aria-live": "polite",
			"aria-atomic": "true",
			className: `${carbonPrefix}--visually-hidden`
		}, "Step ", progStep + 1, " of ", stepCount)));
	};
	const closeModal = () => {
		handleClose?.("close");
	};
	return isFullScreen ? /* @__PURE__ */ react.default.createElement("header", {
		ref,
		role: "presentation",
		className: (0, import_classnames.default)(headerBlockClass, className, { [`${headerBlockClass}--has-title`]: headerTitle || headerSubTitle || children }),
		...require_devtools.getDevtoolsProps("InterstitialScreenHeader"),
		...rest
	}, headerContent()) : /* @__PURE__ */ react.default.createElement(_carbon_react.ModalHeader, {
		ref,
		className: (0, import_classnames.default)(headerBlockClass, className, { [`${headerBlockClass}--has-title`]: headerTitle || headerSubTitle || children }),
		closeModal,
		iconDescription: closeIconDescription,
		...require_devtools.getDevtoolsProps("InterstitialScreenHeader"),
		...rest
	}, headerContent());
});
InterstitialScreenHeader.propTypes = {
	children: prop_types.default.node,
	className: prop_types.default.string,
	closeIconDescription: prop_types.default.string,
	headerSubTitle: prop_types.default.string,
	headerTitle: prop_types.default.string,
	hideProgressIndicator: prop_types.default.bool
};

//#endregion
exports.default = InterstitialScreenHeader;