import { n as AnalyticsId, s as LanguageLocales } from "../../constants2.js";
import { t as AnchorLink_default } from "../../AnchorLink.js";
import { n as useLanguage } from "../../useLanguage.js";
import { t as Close_default } from "../../Close.js";
import { n as PopOverVariant, t as PopOver_default } from "../../PopOver.js";
import classNames from "classnames";
import { jsx, jsxs } from "react/jsx-runtime";
import styles from "./styles.module.scss";
var HN_Designsystem_HelpBubble_nb_NO_default = { ariaLabel: "Hjelpetekst" };
const getResources = (language) => {
	switch (language) {
		case LanguageLocales.NORWEGIAN:
		default: return HN_Designsystem_HelpBubble_nb_NO_default;
	}
};
const HelpBubbleVariant = PopOverVariant;
var HelpBubble = (props) => {
	const { ariaLabelledById, children, className = "", noCloseButton, linkText = "Mer hjelp", linkUrl, linkTarget, onLinkClick, onClose, closeAriaLabel, showBubble, helpBubbleId, variant, controllerRef, resources, testId, ref } = props;
	const { language } = useLanguage(LanguageLocales.NORWEGIAN);
	if (!showBubble) return null;
	const mergedResources = {
		...getResources(language),
		...resources
	};
	const helpBubbleClasses = classNames(styles.helpbubble, className);
	const contentClasses = classNames(styles.helpbubble__content);
	const renderLink = () => {
		if (onLinkClick && linkText) return /* @__PURE__ */ jsx("button", {
			className: styles.helpbubble__link,
			onClick: onLinkClick,
			type: "button",
			children: linkText
		});
		else if (linkUrl && linkText) return /* @__PURE__ */ jsx(AnchorLink_default, {
			href: linkUrl,
			target: linkTarget,
			children: linkText
		});
	};
	const renderCloseButton = () => {
		if (noCloseButton) return;
		return /* @__PURE__ */ jsx(Close_default, {
			small: true,
			color: "plum",
			onClick: onClose,
			ariaLabel: closeAriaLabel,
			className: styles.helpbubble__close
		});
	};
	return /* @__PURE__ */ jsx(PopOver_default, {
		ariaLabel: mergedResources.ariaLabel,
		ariaLabelledById,
		id: helpBubbleId,
		variant,
		controllerRef,
		role: "group",
		ref,
		show: showBubble,
		testId,
		children: /* @__PURE__ */ jsxs("div", {
			className: helpBubbleClasses,
			"data-analyticsid": AnalyticsId.HelpBubble,
			children: [/* @__PURE__ */ jsxs("div", {
				className: contentClasses,
				children: [children, renderLink()]
			}), renderCloseButton()]
		})
	});
};
HelpBubble.displayName = "HelpBubble";
var HelpBubble_default = HelpBubble;
export { HelpBubbleVariant, HelpBubble_default as default };

//# sourceMappingURL=index.js.map