import { a as IconSize, n as AnalyticsId, s as LanguageLocales } from "./constants2.js";
import { t as Icon_default } from "./Icon.js";
import { n as useLanguage } from "./useLanguage.js";
import { t as LazyIcon_default } from "./LazyIcon.js";
import { t as Title_default } from "./Title2.js";
import classNames from "classnames";
import { useId, useState } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import styles from "./components/InfoTeaser/styles.module.scss";
var HN_Designsystem_InfoTeaser_en_GB_default = {
	expandButtonOpen: "Show less",
	expandButtonClose: "Show more"
};
var HN_Designsystem_InfoTeaser_nb_NO_default = {
	expandButtonOpen: "Vis mindre",
	expandButtonClose: "Vis mer"
};
const getResources = (language) => {
	switch (language) {
		case LanguageLocales.ENGLISH: return HN_Designsystem_InfoTeaser_en_GB_default;
		case LanguageLocales.NORWEGIAN:
		default: return HN_Designsystem_InfoTeaser_nb_NO_default;
	}
};
var InfoTeaser = (props) => {
	const { buttonClassName, children, className, htmlMarkup = "div", resources, svgIcon, testId, title, titleHtmlMarkup = "h2", collapsedMaxHeight } = props;
	const [expanded, setExpanded] = useState(false);
	const { language } = useLanguage(LanguageLocales.NORWEGIAN);
	const defaultResources = getResources(language);
	const infoteaserTextId = useId();
	const mergedResources = {
		...defaultResources,
		...resources
	};
	return /* @__PURE__ */ jsxs(htmlMarkup, {
		className: styles.wrapper,
		"data-testid": testId,
		"data-analyticsid": AnalyticsId.InfoTeaser,
		children: [/* @__PURE__ */ jsxs("div", {
			className: classNames(styles.infoteaser, className, { [styles["infoteaser--collapsed"]]: !expanded }),
			style: { maxHeight: !expanded ? collapsedMaxHeight ? collapsedMaxHeight : "12.25rem" : void 0 },
			children: [
				svgIcon && (typeof svgIcon === "string" ? /* @__PURE__ */ jsx(LazyIcon_default, {
					iconName: svgIcon,
					size: IconSize.Small,
					className: styles.infoteaser__icon
				}) : /* @__PURE__ */ jsx(Icon_default, {
					svgIcon,
					size: IconSize.Small,
					className: styles.infoteaser__icon
				})),
				/* @__PURE__ */ jsx(Title_default, {
					testId: "titleId",
					htmlMarkup: titleHtmlMarkup,
					appearance: "title4",
					className: styles.infoteaser__title,
					children: title
				}),
				/* @__PURE__ */ jsx("div", {
					className: styles.infoteaser__text,
					"aria-hidden": expanded ? false : true,
					id: infoteaserTextId,
					children
				})
			]
		}), /* @__PURE__ */ jsx("button", {
			type: "button",
			className: classNames(styles.infoteaser__button, buttonClassName),
			onClick: () => {
				setExpanded(!expanded);
			},
			"aria-expanded": expanded,
			"aria-controls": infoteaserTextId,
			children: expanded ? mergedResources.expandButtonOpen : mergedResources.expandButtonClose
		})]
	});
};
var InfoTeaser_default$1 = InfoTeaser;
export { InfoTeaser_default$1 as t };

//# sourceMappingURL=InfoTeaser.js.map