// ../src/helpers/formatClassString.ts
var formatClassString = (classesArray) => {
  return classesArray.filter((x) => !!x).join(" ");
};

// ../src/foundations/icons/sprite.svg
import { h } from "preact";
import { jsx, jsxs } from "preact/jsx-runtime";

// ../src/components/icon-sprite/icon-sprite.tsx
import { jsx as jsx2 } from "preact/jsx-runtime";
var IconUse = ({ iconName, classNames, attributes }) => {
  const componentClassName = "ds-icon";
  const classes = formatClassString([
    componentClassName,
    `${componentClassName}--sprite`,
    `${componentClassName}--${iconName}`,
    classNames
  ]);
  return /* @__PURE__ */ jsx2("i", { className: classes, ...attributes, children: /* @__PURE__ */ jsx2("svg", { children: /* @__PURE__ */ jsx2("use", { xlinkHref: `#ds-${iconName}` }) }) });
};

// ../src/components/spinner/spinner.tsx
import { jsx as jsx3 } from "preact/jsx-runtime";
var Spinner = ({ variant = "primary", size = "large", forcePx, classNames, attributes }) => {
  const componentClassName = "ds-spinner";
  const classes = formatClassString([
    `${componentClassName}`,
    `${componentClassName}--${variant}`,
    `${componentClassName}--${size}`,
    forcePx && "ds-force-px",
    classNames
  ]);
  return /* @__PURE__ */ jsx3("span", { className: classes, ...attributes, children: /* @__PURE__ */ jsx3("span", { className: `${componentClassName}__inner` }) });
};
var spinner_default = Spinner;

// ../src/components/text-button/text-button.tsx
import { jsx as jsx4, jsxs as jsxs2 } from "preact/jsx-runtime";
var TextButton = ({
  text,
  href,
  type = "button",
  iconName,
  iconPosition = "none",
  size,
  fullWidth = false,
  mobileFullWidth = false,
  hideTextOnMobile = false,
  loading = false,
  disabled = false,
  forcePx = false,
  classNames = "",
  attributes = {}
}) => {
  const iconSvg = iconName && iconPosition !== "none" ? /* @__PURE__ */ jsx4(IconUse, { iconName, attributes: { "aria-hidden": "true" } }) : null;
  const componentClassName = "ds-text-btn";
  const classNamePrefix = `${componentClassName}--`;
  const classes = [
    componentClassName,
    size && `${classNamePrefix}${size}`,
    fullWidth && `${classNamePrefix}full-width`,
    mobileFullWidth && `${classNamePrefix}mobile-full-width`,
    iconSvg && `${classNamePrefix}icon-${iconPosition}`,
    hideTextOnMobile && `${classNamePrefix}icon-only-mobile`,
    loading && "ds-loading",
    forcePx && "ds-force-px",
    classNames
  ].filter(Boolean).join(" ");
  const ariaLabel = attributes["aria-label"] || text;
  const spinnerSize = size === "sm" ? "xsmall" : "small";
  const loadingHtml = loading ? /* @__PURE__ */ jsx4(spinner_default, { size: spinnerSize, variant: "primary", forcePx, attributes: { "aria-hidden": "true" } }) : null;
  if (href) {
    return /* @__PURE__ */ jsxs2("a", { href: href || "#", "aria-label": ariaLabel, className: classes, ...attributes, children: [
      /* @__PURE__ */ jsx4("span", { className: "ds-text-btn__text", "aria-hidden": "true", children: text }),
      iconSvg,
      loadingHtml
    ] });
  }
  return /* @__PURE__ */ jsxs2("button", { type, "aria-label": ariaLabel, className: classes, disabled, ...attributes, children: [
    /* @__PURE__ */ jsx4("span", { className: "ds-text-btn__text", "aria-hidden": "true", children: text }),
    iconSvg,
    loadingHtml
  ] });
};

// ../src/components/pagination/pagination.tsx
import { jsx as jsx5, jsxs as jsxs3 } from "preact/jsx-runtime";
var Pagination = ({
  pages,
  previousLabel,
  previousUrl,
  previousClassNames,
  previousAttributes,
  nextLabel,
  nextUrl,
  nextClassNames,
  nextAttributes,
  classNames,
  attributes
}) => {
  const componentClassName = "ds-pagination";
  const classes = formatClassString([componentClassName, !pages ? `${componentClassName}--simple` : "", classNames]);
  const isPrevDisabled = !previousUrl;
  const prevClasses = formatClassString([
    `${componentClassName}__prev`,
    previousClassNames,
    isPrevDisabled ? "invisible" : ""
  ]);
  const nextClasses = formatClassString([`${componentClassName}__next`, nextClassNames, !nextUrl ? "invisible" : ""]);
  return /* @__PURE__ */ jsxs3("nav", { className: classes, ...attributes, children: [
    /* @__PURE__ */ jsx5(
      TextButton,
      {
        text: previousLabel || "F\xF6reg\xE5ende",
        size: "lg",
        hideTextOnMobile: !!pages,
        iconPosition: "left",
        iconName: "arrow_back",
        classNames: prevClasses,
        attributes: previousAttributes,
        href: previousUrl,
        disabled: isPrevDisabled
      }
    ),
    pages && /* @__PURE__ */ jsx5("div", { className: `${componentClassName}__pages`, children: pages.map((pageObj) => {
      const page = pageObj;
      const pageClass = componentClassName + "__page";
      const ariaLabelProp = !page.attributes?.["aria-label"] ? { "aria-label": `sida ${page.label}` } : {};
      return page.current ? /* @__PURE__ */ jsx5(
        "span",
        {
          className: `${pageClass} ${pageClass}--current`,
          "aria-current": "page",
          ...ariaLabelProp,
          ...page.attributes,
          children: page.label
        }
      ) : /* @__PURE__ */ jsx5("a", { href: page.url, className: pageClass, ...ariaLabelProp, ...page.attributes, children: page.label });
    }) }),
    /* @__PURE__ */ jsx5(
      TextButton,
      {
        text: nextLabel || "N\xE4sta",
        size: "lg",
        hideTextOnMobile: !!pages,
        iconPosition: "right",
        iconName: "arrow_forward",
        classNames: `${componentClassName}__next ${nextClasses || ""}`,
        attributes: nextAttributes,
        href: nextUrl,
        disabled: !nextUrl
      }
    )
  ] });
};
export {
  Pagination
};
//# sourceMappingURL=pagination.js.map
