/**
 * 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_settings = require("../../../settings.js");
const require_context = require("./context.js");
const require_utils = require("./utils.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/PageHeader/next/PageHeaderScrollButton.tsx
/**
* Copyright IBM Corp. 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.
*/
var import_classnames = /* @__PURE__ */ require_runtime.__toESM(require_index.default);
const PageHeaderScrollButton = react.default.forwardRef(function PageHeaderExpander({ className, children, label, onClick, collapseText = "Collapse", expandText = "Expand", ...other }, ref) {
	const { refs, observerState } = require_context.usePageHeader();
	const fullyCollapsed = observerState.fullyCollapsed;
	const handleScroller = (isFullyCollapsed) => {
		if (!refs?.contentRef?.current) return;
		const scrollableTarget = require_utils.scrollableAncestor(refs?.contentRef.current);
		if (!isFullyCollapsed) {
			const pageHeaderContentHeight = refs?.contentRef.current.offsetHeight;
			scrollableTarget?.scrollTo({
				top: pageHeaderContentHeight,
				behavior: "smooth"
			});
		} else scrollableTarget?.scrollTo({
			top: 0,
			behavior: "smooth"
		});
	};
	return /* @__PURE__ */ react.default.createElement(_carbon_react.IconButton, {
		ref,
		label: fullyCollapsed ? expandText : collapseText,
		size: "md",
		kind: "ghost",
		autoAlign: true,
		...other,
		onClick: (event) => {
			onClick?.(event);
			handleScroller(!!fullyCollapsed);
		},
		className: (0, import_classnames.default)(className, `${require_settings.pkg.prefix}--page-header--scroller-button`)
	}, /* @__PURE__ */ react.default.createElement(_carbon_react_icons.ChevronUp, { className: (0, import_classnames.default)(`${require_settings.pkg.prefix}--page-header--scroller-button-icon`, { [`${require_settings.pkg.prefix}--page-header--scroller-button-icon-collapsed`]: fullyCollapsed }) }));
});
PageHeaderScrollButton.displayName = "PageHeaderScrollButton";
//#endregion
exports.PageHeaderScrollButton = PageHeaderScrollButton;
