import { n as AnalyticsId, s as LanguageLocales } from "./constants2.js";
import { t as usePseudoClasses } from "./usePseudoClasses.js";
import { t as ArrowUpRight_default } from "./ArrowUpRight.js";
import { n as useLanguage } from "./useLanguage.js";
import { i as renderElementHeader } from "./ElementHeader.js";
import { n as listEditModeWrapperClassnames, t as ListEditMode_default } from "./ListEditMode.js";
import { t as ChevronRight_default } from "./ChevronRight.js";
import classNames from "classnames";
import React from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import LinkListStyles from "./components/LinkList/styles.module.scss";
var HN_Designsystem_LinkList_en_GB_default = { editMode_deleteButtonAriaLabel: "Delete" };
var HN_Designsystem_LinkList_nb_NO_default = { editMode_deleteButtonAriaLabel: "Slett" };
const getResources = (language) => {
	switch (language) {
		case LanguageLocales.ENGLISH: return HN_Designsystem_LinkList_en_GB_default;
		case LanguageLocales.NORWEGIAN:
		default: return HN_Designsystem_LinkList_nb_NO_default;
	}
};
const Link = (props) => {
	const { children, className = "", color = "white", icon, image, size = "medium", chevron = false, linkRef, status = "none", testId, target, variant, htmlMarkup = "a", highlightText, editMode = false, contentId, resources, ref, external = false, ...restProps } = props;
	const { refObject, isHovered } = usePseudoClasses(linkRef);
	const isFill = variant === "fill";
	const isFillNegative = variant === "fill-negative";
	const isOutline = variant === "outline";
	const isLine = variant === "line";
	const liClasses = classNames(LinkListStyles["link-list"], {
		[LinkListStyles["link-list__list-item--line"]]: isLine,
		[LinkListStyles["link-list__list-item--outline"]]: isOutline,
		[LinkListStyles[`link-list__list-item--outline--${color}`]]: isOutline
	});
	const linkClasses = classNames(LinkListStyles["link-list__anchor"], LinkListStyles[`link-list__anchor--${color}`], {
		[LinkListStyles[`link-list__anchor--line--${color}`]]: isLine,
		[LinkListStyles["link-list__anchor--fill"]]: isFill,
		[LinkListStyles[`link-list__anchor--fill--${color}`]]: isFill,
		[LinkListStyles["link-list__anchor--outline"]]: isOutline,
		[LinkListStyles[`link-list__anchor--outline--${color}`]]: isOutline,
		[LinkListStyles["link-list__anchor--fill-negative"]]: isFillNegative,
		[LinkListStyles[`link-list__anchor--fill-negative--${color}`]]: isFillNegative,
		[LinkListStyles[`link-list__anchor--${size}`]]: size,
		[LinkListStyles["link-list__anchor--button"]]: htmlMarkup === "button",
		[LinkListStyles["link-list__anchor--new"]]: status === "new"
	}, className);
	const statusMarkerClasses = classNames(LinkListStyles["link-list__status-marker"], { [LinkListStyles["link-list__status-marker--new"]]: status === "new" });
	const imageContainer = /* @__PURE__ */ jsx("span", {
		className: LinkListStyles["link-list__image-container"],
		children: image
	});
	let chevronIcon = void 0;
	if (external) chevronIcon = ArrowUpRight_default;
	else if (chevron) chevronIcon = ChevronRight_default;
	return editMode ? /* @__PURE__ */ jsx("div", {
		id: contentId,
		className: liClasses,
		"data-testid": testId,
		"data-analyticsid": AnalyticsId.Link,
		children: /* @__PURE__ */ jsxs("div", {
			className: linkClasses,
			children: [/* @__PURE__ */ jsx("div", { className: statusMarkerClasses }), renderElementHeader(children, {
				titleHtmlMarkup: "span",
				size,
				parentType: "linklist",
				chevronIcon,
				icon: icon ?? imageContainer,
				highlightText
			})]
		})
	}) : /* @__PURE__ */ jsx("li", {
		className: liClasses,
		ref,
		"data-testid": testId,
		"data-analyticsid": AnalyticsId.Link,
		children: htmlMarkup === "a" ? /* @__PURE__ */ jsxs("a", {
			className: linkClasses,
			ref: refObject,
			rel: target === "_blank" ? "noopener noreferrer" : void 0,
			target,
			...restProps,
			children: [/* @__PURE__ */ jsx("div", { className: statusMarkerClasses }), renderElementHeader(children, {
				titleHtmlMarkup: "span",
				isHovered,
				size,
				parentType: "linklist",
				chevronIcon,
				icon: icon ?? imageContainer,
				highlightText
			})]
		}) : htmlMarkup === "button" && /* @__PURE__ */ jsxs("button", {
			className: linkClasses,
			ref: refObject,
			type: "button",
			...restProps,
			children: [/* @__PURE__ */ jsx("div", { className: statusMarkerClasses }), renderElementHeader(children, {
				titleHtmlMarkup: "span",
				isHovered,
				size,
				parentType: "linklist",
				chevronIcon,
				icon: icon ?? imageContainer,
				highlightText
			})]
		})
	});
};
var LinkListComponent = (props) => {
	const { children, className = "", chevron = false, size = "medium", color = "white", testId, variant = "line", highlightText, editMode = false, resources, ref } = props;
	const { language } = useLanguage(LanguageLocales.NORWEGIAN);
	const mergedResources = {
		...getResources(language),
		...resources
	};
	return /* @__PURE__ */ jsx("ul", {
		ref,
		className: classNames(LinkListStyles["link-list"], className, {
			[LinkListStyles[`link-list--outline--${color}`]]: variant === "outline",
			[listEditModeWrapperClassnames]: editMode
		}),
		"data-testid": testId,
		"data-analyticsid": AnalyticsId.LinkList,
		children: React.Children.map(children, (child, index) => {
			if (React.isValidElement(child) && child.type === Link) if (editMode) {
				const deleteAriaLabel = child.props.resources?.editMode_deleteButtonAriaLabel ?? mergedResources.editMode_deleteButtonAriaLabel;
				const itemId = `linklist-item-${index}`;
				return /* @__PURE__ */ jsx(ListEditMode_default, {
					color,
					variant,
					onDelete: child.props.onDelete,
					contentId: itemId,
					deleteButtonAriaLabel: deleteAriaLabel,
					children: React.cloneElement(child, {
						color,
						size,
						chevron: false,
						variant,
						highlightText,
						editMode: true,
						contentId: itemId
					})
				});
			} else return React.cloneElement(child, {
				color,
				size,
				chevron,
				variant,
				highlightText,
				editMode: false
			});
			return null;
		})
	});
};
const LinkList = LinkListComponent;
LinkList.displayName = "LinkList";
LinkList.Link = Link;
Link.displayName = "LinkList.Link";
var LinkList_default$1 = LinkList;
export { Link as n, LinkList as r, LinkList_default$1 as t };

//# sourceMappingURL=LinkList.js.map