"use client";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_chunk = require("../../chunk-BN4qSVkS.cjs");
const require_components_typography_base_Headline = require("../typography/base/Headline.cjs");
const require_utils_isReactNodeWithChildren = require("../../utils/isReactNodeWithChildren.cjs");
let react = require("react");
react = require_chunk.__toESM(react);
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
//#region src/components/documentation/DocsHeadline.tsx
const getHeadlineText = (element) => {
	if (typeof element === "string") return element;
	if (Array.isArray(element)) return getHeadlineText(element[0]);
	if (require_utils_isReactNodeWithChildren.isReactNodeWithChildren(element)) return getHeadlineText(element.props.children);
	throw new Error("Could not find text in Headline element: " + (typeof element === "object" ? JSON.stringify(element) : String(element)));
};
/**
* Assumes the element is a header element containing a link with an href.
* Getting the id from the href ensures we get the id that remains
* compatible with the links generated automatically in the markdown
* with the rehypeAutolinkHeadings plugin. Otherwise, anchor links will not
* work.
*/
const getHeaderId = (element) => {
	if (react.default.isValidElement(element) && element?.type === "a" && "href" in element.props) {
		const props = element.props;
		return getHeaderId(props.href);
	}
	if (typeof element === "string") return element.replace("#", "");
	if (Array.isArray(element)) return getHeaderId(element[0]);
	if (require_utils_isReactNodeWithChildren.isReactNodeWithChildren(element)) return getHeaderId(element.props.children);
	throw new Error("Could not find text in Headline element: " + (typeof element === "object" ? JSON.stringify(element) : String(element)));
};
const toKebabCase = (str) => {
	return str.replaceAll(" ", "-").toLowerCase();
};
const DocsHeadline = ({ children, color, size = "Medium", heading = "h1", onClick, textAlign, underline = false }) => {
	return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_components_typography_base_Headline.StyledHeadline, {
		as: heading,
		id: toKebabCase(getHeaderId(children)),
		size,
		colorProp: color,
		displayProp: "block",
		hideOverflow: false,
		textAlign,
		onClick,
		underline,
		block: true,
		children
	});
};
//#endregion
exports.DocsHeadline = DocsHeadline;
exports.getHeadlineText = getHeadlineText;
