// src/components/layout/Carousel.tsx
import {
  createContext as createContext2,
  forwardRef as forwardRef2,
  useCallback as useCallback2,
  useContext as useContext2,
  useEffect as useEffect2,
  useId,
  useMemo as useMemo2,
  useRef,
  useState as useState3
} from "react";
import clsx2 from "clsx";
import { ChevronLeft, ChevronRight } from "lucide-react";

// src/utils/array.ts
var defaultRangeOptions = {
  allowEmptyRange: false,
  stepSize: 1,
  exclusiveStart: false,
  exclusiveEnd: true
};
var range = (endOrRange, options) => {
  const { allowEmptyRange, stepSize, exclusiveStart, exclusiveEnd } = { ...defaultRangeOptions, ...options };
  let start = 0;
  let end;
  if (typeof endOrRange === "number") {
    end = endOrRange;
  } else {
    start = endOrRange[0];
    end = endOrRange[1];
  }
  if (!exclusiveEnd) {
    end -= 1;
  }
  if (exclusiveStart) {
    start += 1;
  }
  if (end - 1 < start) {
    if (!allowEmptyRange) {
      console.warn(`range: end (${end}) < start (${start}) should be allowed explicitly, set options.allowEmptyRange to true`);
    }
    return [];
  }
  return Array.from({ length: end - start }, (_, index) => index * stepSize + start);
};
var createLoopingListWithIndex = (list, startIndex = 0, length = 0, forwards = true) => {
  if (length < 0) {
    console.warn(`createLoopingList: length must be >= 0, given ${length}`);
  } else if (length === 0) {
    length = list.length;
  }
  const returnList = [];
  if (forwards) {
    for (let i = startIndex; returnList.length < length; i = (i + 1) % list.length) {
      returnList.push([i, list[i]]);
    }
  } else {
    for (let i = startIndex; returnList.length < length; i = i === 0 ? i = list.length - 1 : i - 1) {
      returnList.push([i, list[i]]);
    }
  }
  return returnList;
};
var moveItems = (list, move = 0) => {
  const result = [];
  let start = move;
  if (start < 0) {
    start = list.length - move;
  }
  start = start % list.length;
  for (let i = 0; i < list.length; i++) {
    result[i] = list[(i + start) % list.length];
  }
  return result;
};
function resolveSingleOrArray(value) {
  if (Array.isArray(value)) {
    return value;
  } else if (value) {
    return [value];
  }
  return [];
}
var ArrayUtil = {
  unique: (list) => {
    const seen = /* @__PURE__ */ new Set();
    return list.filter((item) => {
      if (seen.has(item)) {
        return false;
      }
      seen.add(item);
      return true;
    });
  },
  difference: (list, removeList) => {
    const remove = new Set(removeList);
    return list.filter((item) => !remove.has(item));
  },
  moveItems,
  resolveSingleOrArray
};

// src/components/user-action/Button.tsx
import { forwardRef } from "react";
import clsx from "clsx";
import { jsx, jsxs } from "react/jsx-runtime";
var ButtonColorUtil = {
  solid: ["primary", "secondary", "tertiary", "positive", "warning", "negative", "neutral"],
  text: ["primary", "negative", "neutral"],
  outline: ["primary"]
};
var IconButtonUtil = {
  icon: [...ButtonColorUtil.solid, "transparent"]
};
var paddingMapping = {
  none: "",
  small: "btn-sm",
  medium: "btn-md",
  large: "btn-lg"
};
var iconPaddingMapping = {
  none: "",
  tiny: "icon-btn-xs",
  small: "icon-btn-sm",
  medium: "icon-btn-md",
  large: "icon-btn-lg"
};
var ButtonUtil = {
  paddingMapping,
  iconPaddingMapping
};
var SolidButton = forwardRef(function SolidButton2({
  children,
  color = "primary",
  size = "medium",
  startIcon,
  endIcon,
  onClick,
  className,
  ...restProps
}, ref) {
  const colorClasses = {
    primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
    secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
    tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
    positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
    warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
    negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
    neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text"
  }[color];
  const iconColorClasses = {
    primary: "not-group-disabled:text-button-solid-primary-icon",
    secondary: "not-group-disabled:text-button-solid-secondary-icon",
    tertiary: "not-group-disabled:text-button-solid-tertiary-icon",
    positive: "not-group-disabled:text-button-solid-positive-icon",
    warning: "not-group-disabled:text-button-solid-warning-icon",
    negative: "not-group-disabled:text-button-solid-negative-icon",
    neutral: "not-group-disabled:text-button-solid-neutral-icon"
  }[color];
  return /* @__PURE__ */ jsxs(
    "button",
    {
      ref,
      onClick,
      className: clsx(
        "group font-semibold",
        colorClasses,
        "not-disabled:hover:brightness-90",
        "disabled:text-disabled disabled:bg-disabled-background",
        ButtonUtil.paddingMapping[size],
        className
      ),
      ...restProps,
      children: [
        startIcon && /* @__PURE__ */ jsx(
          "span",
          {
            className: clsx(
              iconColorClasses,
              "group-disabled:text-disabled-icon"
            ),
            children: startIcon
          }
        ),
        children,
        endIcon && /* @__PURE__ */ jsx(
          "span",
          {
            className: clsx(
              iconColorClasses,
              "group-disabled:text-disabled-icon"
            ),
            children: endIcon
          }
        )
      ]
    }
  );
});
var IconButton = forwardRef(function IconButton2({
  children,
  color = "primary",
  size = "medium",
  className,
  ...restProps
}, ref) {
  const colorClasses = {
    primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
    secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
    tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
    positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
    warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
    negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
    neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text",
    transparent: "not-disabled:bg-transparent"
  }[color];
  return /* @__PURE__ */ jsx(
    "button",
    {
      ref,
      className: clsx(
        colorClasses,
        "not-disabled:hover:brightness-90",
        "disabled:text-disabled",
        {
          "disabled:bg-disabled-background": color !== "transparent",
          "disabled:opacity-70": color === "transparent",
          "not-disabled:hover:bg-button-text-hover-background": color === "transparent"
        },
        ButtonUtil.iconPaddingMapping[size],
        className
      ),
      ...restProps,
      children
    }
  );
});

// src/i18n/LocaleProvider.tsx
import { createContext, useContext, useEffect, useMemo, useState as useState2 } from "react";

// src/hooks/useLocalStorage.ts
import { useCallback, useState } from "react";

// src/i18n/translations.ts
import { TranslationGen } from "@helpwave/internationalization";
var hightideTranslationLocales = ["de-DE", "en-US"];
var hightideTranslation = {
  "de-DE": {
    "add": `Hinzuf\xFCgen`,
    "age": `Alter`,
    "all": `Alle`,
    "apply": `Anwenden`,
    "back": `Zur\xFCck`,
    "cancel": `Abbrechen`,
    "carousel": `Karussell`,
    "change": `\xC4ndern`,
    "chooseLanguage": `W\xE4hle deine bevorzugte Sprache`,
    "chooseSlide": `W\xE4hle die angezeigte Slide aus`,
    "chooseTheme": `W\xE4hle dein bevorzugtes Farbschema.`,
    "clear": `L\xF6schen`,
    "click": `Klicken`,
    "clickToCopy": `Zum kopieren klicken`,
    "clickToSelect": `Zum Ausw\xE4hlen dr\xFCcken`,
    "close": `Schlie\xDFen`,
    "confirm": `Best\xE4tigen`,
    "copied": `Kopiert`,
    "copy": `Kopieren`,
    "create": `Erstellen`,
    "decline": `Ablehnen`,
    "delete": `L\xF6schen`,
    "discard": `Verwerfen`,
    "discardChanges": `\xC4nderungen Verwerfen`,
    "done": `Fertig`,
    "edit": `Bearbeiten`,
    "endDate": `Ende`,
    "enterText": `Text hier eingeben`,
    "entryDate": `Eintragsdatum`,
    "error": `Fehler`,
    "errorOccurred": `Ein Fehler ist aufgetreten`,
    "exit": `Beenden`,
    "fieldRequiredError": `Dieses Feld ist erforderlich.`,
    "filter": `Filter`,
    "gender": ({ gender }) => {
      return TranslationGen.resolveSelect(gender, {
        "male": `M\xE4nnlich`,
        "female": `Weiblich`,
        "other": `Divers`
      });
    },
    "goodToSeeYou": `Sch\xF6n dich zu sehen`,
    "identifier": `Identifikator`,
    "invalidEmail": `Die E-Mail ist ung\xFCltig.`,
    "invalidEmailError": `Bitte geben Sie eine g\xFCltige E-Mail-Adresse ein.`,
    "language": `Sprache`,
    "less": `Weniger`,
    "loading": `L\xE4dt`,
    "locale": `Locale`,
    "max": `Max`,
    "maxLengthError": `Maximale L\xE4nge \xFCberschritten.`,
    "min": `Min`,
    "minLengthError": `Mindestl\xE4nge nicht erreicht.`,
    "more": `Mehr`,
    "name": `Name`,
    "next": `Weiter`,
    "no": `Nein`,
    "none": `Nichts`,
    "notEmpty": `Das Feld darf nicht leer sein.`,
    "nothingFound": `Nichts gefunden`,
    "of": `von`,
    "optional": `Optional`,
    "outOfRangeNumber": ({ min, max }) => {
      return `Der Wert muss zwischen ${min} und ${max} liegen.`;
    },
    "outOfRangeSelectionItems": ({ min, max }) => {
      return `Es m\xFCssen zwischen ${min} und ${max} Elemente ausgew\xE4hlt werden.`;
    },
    "outOfRangeString": ({ min, max }) => {
      return `Der Wert muss zwischen ${min} und ${max} Zeichen lang sein.`;
    },
    "pleaseWait": `Bitte warten...`,
    "previous": `Vorherige`,
    "remove": `Entfernen`,
    "required": `Erforderlich`,
    "reset": `Zur\xFCcksetzen`,
    "save": `Speichern`,
    "saved": `Gespeichert`,
    "search": `Suche`,
    "select": `Select`,
    "selectOption": `Option ausw\xE4hlen`,
    "show": `Anzeigen`,
    "showLess": `Weniger anzeigen`,
    "showMore": `Mehr anzeigen`,
    "showSlide": ({ index }) => {
      return `Zeige Slide ${index}`;
    },
    "slide": `Slide`,
    "slideNavigation": `Slide Navigation`,
    "slideOf": ({ index, length }) => {
      return `Slide ${index} von ${length} slides`;
    },
    "startDate": `Start`,
    "street": `Stra\xDFe`,
    "submit": `Abschicken`,
    "success": `Erfolg`,
    "text": `Text`,
    "themeMode": ({ theme }) => {
      return TranslationGen.resolveSelect(theme, {
        "dark": `Dunkel`,
        "light": `Hell`,
        "system": `System`
      });
    },
    "themes": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Farbschema`,
        "other": `Farbschemas`
      });
    },
    "time.ago": `vor`,
    "time.agoDays": ({ days }) => {
      return `var ${days} Tagen`;
    },
    "time.april": `April`,
    "time.august": `August`,
    "time.century": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Jahrhundert`,
        "other": `Jahrhunderte`
      });
    },
    "time.day": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Tag`,
        "other": `Tage`
      });
    },
    "time.decade": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Jahrzehnt`,
        "other": `Jahrzehnte`
      });
    },
    "time.december": `December`,
    "time.february": `Febuar`,
    "time.hour": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Stunde`,
        "other": `Stunden`
      });
    },
    "time.in": `in`,
    "time.inDays": ({ days }) => {
      return `in ${days} Tagen`;
    },
    "time.january": `Januar`,
    "time.july": `Juli`,
    "time.june": `Juni`,
    "time.march": `M\xE4rz`,
    "time.may": `Mai`,
    "time.microsecond": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Mikrosekunde`,
        "other": `Mikrosekunden`
      });
    },
    "time.millisecond": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Millisekunde`,
        "other": `Millisekunden`
      });
    },
    "time.minute": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Minute`,
        "other": `Minuten`
      });
    },
    "time.month": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Monat`,
        "other": `Monate`
      });
    },
    "time.monthName": ({ month }) => {
      return TranslationGen.resolveSelect(month, {
        "january": `Januar`,
        "february": `Februar`,
        "march": `M\xE4rz`,
        "april": `April`,
        "may": `Mai`,
        "june": `Juni`,
        "july": `Juli`,
        "august": `August`,
        "september": `September`,
        "october": `Oktober`,
        "november": `November`,
        "december": `Dezember`,
        "other": `Unbekannter Monat`
      });
    },
    "time.nanosecond": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Nanosekunde`,
        "other": `Nanosekunden`
      });
    },
    "time.november": `November`,
    "time.october": `October`,
    "time.second": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Sekunde`,
        "other": `Sekunden`
      });
    },
    "time.september": `September`,
    "time.today": `Heute`,
    "time.tomorrow": `Morgen`,
    "time.year": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Jahr`,
        "other": `Jahre`
      });
    },
    "time.yesterday": `Gestern`,
    "tooFewSelectionItems": ({ min }) => {
      return `Es m\xFCssen mindestens ${min} Elemente ausgew\xE4hlt werden.`;
    },
    "tooLong": ({ max }) => {
      return `Der Wert darf h\xF6chstens ${max} Zeichen enthalten.`;
    },
    "tooManySelectionItems": ({ max }) => {
      return `Es m\xFCssen maximal ${max} Elemente ausgew\xE4hlt werden.`;
    },
    "tooShort": ({ min }) => {
      return `Der Wert muss mindestens ${min} Zeichen enthalten.`;
    },
    "unsavedChanges": `Ungespeicherte \xC4nderungen`,
    "unsavedChangesSaveQuestion": `M\xF6chtest du die \xC4nderungen speichern?`,
    "update": `Update`,
    "value": `Wert`,
    "welcome": `Willkommen`,
    "yes": `Ja`
  },
  "en-US": {
    "add": `Add`,
    "age": `Age`,
    "all": `All`,
    "apply": `Apply`,
    "back": `Back`,
    "cancel": `Cancel`,
    "carousel": `Carousel`,
    "change": `Change`,
    "chooseLanguage": `Choose your language`,
    "chooseSlide": `Choose slide to display`,
    "chooseTheme": `Choose your preferred color theme.`,
    "clear": `Clear`,
    "click": `Click`,
    "clickToCopy": `Click to Copy`,
    "clickToSelect": `Click to select`,
    "close": `Close`,
    "confirm": `Confirm`,
    "copied": `Copied`,
    "copy": `Copy`,
    "create": `Create`,
    "decline": `Decline`,
    "delete": `Delete`,
    "discard": `Discard`,
    "discardChanges": `Discard Changes`,
    "done": `Done`,
    "edit": `Edit`,
    "endDate": `End`,
    "enterText": `Enter text here`,
    "entryDate": `Entry Date`,
    "error": `Error`,
    "errorOccurred": `An error occurred`,
    "exit": `Exit`,
    "fieldRequiredError": `This field is required.`,
    "filter": `Filter`,
    "gender": ({ gender }) => {
      return TranslationGen.resolveSelect(gender, {
        "male": `Male`,
        "female": `Female`,
        "other": `Other`
      });
    },
    "goodToSeeYou": `Good to see you`,
    "identifier": `Identifier`,
    "invalidEmail": `The email is not valid.`,
    "invalidEmailError": `Please enter a valid email address.`,
    "language": `Language`,
    "less": `Less`,
    "loading": `Loading`,
    "locale": `Locale`,
    "max": `Max`,
    "maxLengthError": `Maximum length exceeded.`,
    "min": `Min`,
    "minLengthError": `Minimum length not met.`,
    "more": `More`,
    "name": `Name`,
    "next": `Next`,
    "no": `No`,
    "none": `None`,
    "notEmpty": `The field cannot be empty.`,
    "nothingFound": `Nothing found`,
    "of": `of`,
    "optional": `Optional`,
    "outOfRangeNumber": ({ min, max }) => {
      return `The value must be between ${min} and ${max}.`;
    },
    "outOfRangeSelectionItems": ({ min, max }) => {
      return `Between ${min} and ${max} items must be selected.`;
    },
    "outOfRangeString": ({ min, max }) => {
      return `The value needs to have between ${min} and ${max} characters.`;
    },
    "pleaseWait": `Please wait...`,
    "previous": `Previous`,
    "remove": `Remove`,
    "required": `Required`,
    "reset": `Reset`,
    "save": `Save`,
    "saved": `Saved`,
    "search": `Search`,
    "select": `Select`,
    "selectOption": `Select an option`,
    "show": `Show`,
    "showLess": `Show less`,
    "showMore": `Show more`,
    "showSlide": ({ index }) => {
      return `Show Slide ${index}`;
    },
    "slide": `Slide`,
    "slideNavigation": `Slide navigation`,
    "slideOf": ({ index, length }) => {
      return `Slide ${index} of ${length} slides`;
    },
    "startDate": `Start`,
    "street": `Street`,
    "submit": `Submit`,
    "success": `Success`,
    "text": `Text`,
    "themeMode": ({ theme }) => {
      return TranslationGen.resolveSelect(theme, {
        "dark": `Dark`,
        "light": `Light`,
        "system": `System`
      });
    },
    "themes": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Theme`,
        "other": `Themes`
      });
    },
    "time.ago": `ago`,
    "time.agoDays": ({ days }) => {
      return `days ${days} ago`;
    },
    "time.april": `April`,
    "time.august": `August`,
    "time.century": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Century`,
        "other": `Centuries`
      });
    },
    "time.day": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Day`,
        "other": `Days`
      });
    },
    "time.decade": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Decade`,
        "other": `Decades`
      });
    },
    "time.december": `December`,
    "time.february": `Febuary`,
    "time.hour": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Hour`,
        "other": `Hours`
      });
    },
    "time.in": `in`,
    "time.inDays": ({ days }) => {
      return `in ${days} days`;
    },
    "time.january": `January`,
    "time.july": `July`,
    "time.june": `June`,
    "time.march": `March`,
    "time.may": `May`,
    "time.microsecond": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Microsecond`,
        "other": `Microseconds`
      });
    },
    "time.millisecond": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Millisecond`,
        "other": `Milliseconds`
      });
    },
    "time.minute": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Minute`,
        "other": `Minutes`
      });
    },
    "time.month": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Month`,
        "other": `Months`
      });
    },
    "time.monthName": ({ month }) => {
      return TranslationGen.resolveSelect(month, {
        "january": `January`,
        "february": `February`,
        "march": `March`,
        "april": `April`,
        "may": `May`,
        "june": `June`,
        "july": `July`,
        "august": `August`,
        "september": `September`,
        "october": `October`,
        "november": `November`,
        "december": `December`,
        "other": `Unknown Month`
      });
    },
    "time.nanosecond": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Nanosecond`,
        "other": `Nanoseconds`
      });
    },
    "time.november": `November`,
    "time.october": `October`,
    "time.second": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Second`,
        "other": `Seconds`
      });
    },
    "time.september": `September`,
    "time.today": `Today`,
    "time.tomorrow": `Tomorrow`,
    "time.year": ({ count }) => {
      return TranslationGen.resolveSelect(count, {
        "=1": `Year`,
        "other": `Years`
      });
    },
    "time.yesterday": `Yesterday`,
    "tooFewSelectionItems": ({ min }) => {
      return `Select at least ${min} items.`;
    },
    "tooLong": ({ max }) => {
      return `The value requires less than ${max} characters.`;
    },
    "tooManySelectionItems": ({ max }) => {
      return `Select at most ${max} items.`;
    },
    "tooShort": ({ min }) => {
      return `The value requires at least ${min} characters.`;
    },
    "unsavedChanges": `Unsaved Changes`,
    "unsavedChangesSaveQuestion": `Do you want to save your changes?`,
    "update": `Update`,
    "value": `Value`,
    "welcome": `Welcome`,
    "yes": `Yes`
  }
};

// src/i18n/util.ts
var localsNames = {
  "en-US": "English (US)",
  "de-DE": "Deutsch"
};
var DEFAULT_LOCALE = "en-US";
function localeToLanguage(locale) {
  return locale.split("-")[0];
}
var LocalizationUtil = {
  locals: hightideTranslationLocales,
  localToLanguage: localeToLanguage,
  DEFAULT_LOCALE,
  languagesLocalNames: localsNames
};

// src/i18n/LocaleProvider.tsx
import { jsx as jsx2 } from "react/jsx-runtime";
var LocaleContext = createContext({
  locale: LocalizationUtil.DEFAULT_LOCALE,
  setLocale: (v) => v
});
var useLocale = () => {
  const context = useContext(LocaleContext);
  if (!context) {
    throw new Error("useLocale must be used within LocaleContext. Try adding a LocaleProvider around your app.");
  }
  return context;
};

// src/i18n/useHightideTranslation.ts
import { combineTranslation, ICUUtil } from "@helpwave/internationalization";
function useHightideTranslation(extensions, overwrites) {
  const { locale: inferredLocale } = useLocale();
  const locale = overwrites?.locale ?? inferredLocale;
  const translationExtensions = ArrayUtil.resolveSingleOrArray(extensions);
  return combineTranslation([
    ...translationExtensions,
    hightideTranslation
  ], locale);
}

// src/components/layout/Carousel.tsx
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
var CarouselContext = createContext2(null);
var useCarouselContext = () => {
  const context = useContext2(CarouselContext);
  if (!context) {
    console.error("useCarouselContext must be used within CarouselContext");
  }
  return context;
};
function CarouselTabs({
  onChange
}) {
  const translation = useHightideTranslation();
  const { id, slideCount, currentIndex, isLooping } = useCarouselContext();
  const tabRefs = useRef([]);
  const handleKeyDown = (event, index) => {
    let newIndex = index;
    if (event.key === "ArrowRight") {
      newIndex = isLooping ? (index + 1) % slideCount : Math.max(index + 1, slideCount - 1);
    } else if (event.key === "ArrowLeft") {
      newIndex = isLooping ? (index - 1 + slideCount) % slideCount : Math.max(index - 1, 0);
    } else {
      return;
    }
    event.preventDefault();
    onChange(newIndex);
    tabRefs.current[newIndex]?.focus();
  };
  return /* @__PURE__ */ jsx3(
    "div",
    {
      className: "flex-row-1 items-center justify-center w-full my-2",
      role: "tablist",
      "aria-label": translation("slideNavigation"),
      id: `${id}-tablist`,
      children: range(slideCount).map((index) => {
        const isSelected = currentIndex === index;
        return /* @__PURE__ */ jsx3(
          "button",
          {
            id: `${id}-tab-${index}`,
            ref: (el) => tabRefs.current[index] = el,
            onClick: () => onChange(index),
            onKeyDown: (e) => handleKeyDown(e, index),
            className: clsx2(
              "w-8 min-w-8 h-3 min-h-3 first:rounded-l-md last:rounded-r-md",
              {
                "bg-carousel-dot-disabled hover:bg-carousel-dot-active": currentIndex !== index,
                "bg-carousel-dot-active hover:brightness-90": currentIndex === index
              }
            ),
            role: "tab",
            tabIndex: isSelected ? 0 : -1,
            "aria-label": translation("showSlide", { index: index + 1 }),
            "aria-selected": isSelected,
            "aria-controls": `slide-${index}`,
            "aria-disabled": isSelected
          },
          index
        );
      })
    }
  );
}
var CarouselSlide = forwardRef2(
  function CarouselSlide2({
    index,
    isSelected,
    ...props
  }, ref) {
    const translation = useHightideTranslation();
    const { id, slideCount } = useCarouselContext();
    return /* @__PURE__ */ jsx3(
      "div",
      {
        ...props,
        ref,
        id: `${id}-slide-${index}`,
        className: clsx2("focus-style-none group/slide", props.className),
        tabIndex: isSelected ? 0 : void 0,
        role: "group",
        "aria-roledescription": translation("slide"),
        "aria-label": translation("slideOf", {
          index: index + 1,
          length: slideCount
        }),
        "aria-hidden": isSelected ? void 0 : true
      }
    );
  }
);
var Carousel = ({
  children,
  animationTime = 200,
  isLooping = false,
  isAutoPlaying = false,
  autoLoopingTimeOut = 5e3,
  autoLoopAnimationTime = 1e3,
  hintNext = false,
  arrows = false,
  dots = true,
  blurColor = "from-background",
  heightClassName = "h-96",
  slideClassName = "w-[70%] desktop:w-1/2",
  slideContainerProps,
  onSlideChanged,
  ...props
}) => {
  const translation = useHightideTranslation();
  const slideRefs = useRef([]);
  const [currentIndex, setCurrentIndex] = useState3(0);
  const [hasFocus, setHasFocus] = useState3(false);
  const [dragState, setDragState] = useState3();
  const isPaused = hasFocus;
  const carouselContainerRef = useRef(null);
  const [disableClick, setDisableClick] = useState3(false);
  const timeOut = useRef(void 0);
  const length = useMemo2(() => children.length, [children]);
  const paddingItemCount = 3;
  const generatedId = "carousel" + useId();
  const id = props.id ?? generatedId;
  if (isAutoPlaying && !isLooping) {
    console.error("When isAutoLooping is true, isLooping should also be true");
    isLooping = true;
  }
  autoLoopingTimeOut = Math.max(0, autoLoopingTimeOut);
  animationTime = Math.max(100, animationTime);
  autoLoopAnimationTime = Math.max(200, autoLoopAnimationTime);
  useEffect2(() => {
    const carousel = carouselContainerRef.current;
    if (carousel) {
      let onFocus = function() {
        setHasFocus(true);
      }, onBlur = function() {
        setHasFocus(false);
      };
      carousel?.addEventListener("focusin", onFocus);
      carousel?.addEventListener("focusout", onBlur);
      return () => {
        carousel?.removeEventListener("focusin", onFocus);
        carousel?.removeEventListener("focusin", onFocus);
      };
    }
  }, []);
  const getStyleOffset = (index) => {
    const baseOffset = -50 + (index - currentIndex) * 100;
    return `${baseOffset}%`;
  };
  const canGoLeft = () => {
    return isLooping || currentIndex !== 0;
  };
  const canGoRight = useCallback2(() => {
    return isLooping || currentIndex !== length - 1;
  }, [currentIndex, isLooping, length]);
  const left = () => {
    if (canGoLeft()) {
      setCurrentIndex(currentIndex - 1);
    }
  };
  const right = useCallback2(() => {
    if (canGoRight()) {
      setCurrentIndex((currentIndex + length + 1) % length);
    }
  }, [canGoRight, currentIndex, length]);
  useEffect2(() => {
    if (!timeOut.current && !isPaused) {
      if (autoLoopingTimeOut > 0) {
        timeOut.current = setTimeout(() => {
          right();
          timeOut.current = void 0;
        }, autoLoopingTimeOut);
      } else {
        right();
      }
    }
    if ((isPaused || !!dragState) && timeOut.current) {
      clearTimeout(timeOut.current);
      timeOut.current = void 0;
    }
  }, [right, isPaused, autoLoopingTimeOut, dragState]);
  let items = children.map((item, index) => ({
    index,
    item
  }));
  let before = [];
  let after = [];
  if (isLooping) {
    before = createLoopingListWithIndex(children, length - 1, paddingItemCount, false).reverse().map(([index, item]) => ({
      index,
      item
    }));
    after = createLoopingListWithIndex(children, 0, paddingItemCount).map(([index, item]) => ({
      index,
      item
    }));
    items = [...before, ...items, ...after];
  }
  const handlePointerDown = (e) => {
    setDragState({
      dragOffsetX: 0,
      dragStartX: e.clientX
    });
  };
  const handlePointerMove = (e) => {
    if (!dragState) return;
    setDragState((prevState) => ({ dragStartX: prevState.dragStartX, dragOffsetX: e.clientX - prevState.dragStartX }));
  };
  const handlePointerUp = () => {
    if (!dragState) return;
    if (dragState.dragOffsetX > 50) {
      left();
    } else if (dragState.dragOffsetX < -50) {
      right();
    }
    setDragState(void 0);
  };
  useEffect2(() => {
    setDisableClick(!dragState);
  }, [dragState]);
  useEffect2(() => {
    onSlideChanged?.(currentIndex);
  }, [currentIndex]);
  return /* @__PURE__ */ jsx3(CarouselContext.Provider, { value: { id, currentIndex, slideCount: length, isLooping }, children: /* @__PURE__ */ jsxs2(
    "div",
    {
      ref: carouselContainerRef,
      ...props,
      className: clsx2("flex-col-2 items-center w-full", props.className),
      id,
      role: "region",
      "aria-roledescription": translation("slide"),
      children: [
        /* @__PURE__ */ jsxs2(
          "div",
          {
            ...slideContainerProps,
            className: clsx2(`relative w-full overflow-hidden`, heightClassName, slideContainerProps?.className),
            children: [
              hintNext ? /* @__PURE__ */ jsxs2(
                "div",
                {
                  onPointerDown: handlePointerDown,
                  onPointerMove: handlePointerMove,
                  onPointerUp: handlePointerUp,
                  onPointerLeave: handlePointerUp,
                  className: clsx2(`flex-row-2 relative h-full`, heightClassName),
                  children: [
                    /* @__PURE__ */ jsx3("div", { className: "flex-row-2 relative h-full w-full px-2 overflow-hidden", children: items.map(({
                      item,
                      index
                    }, listIndex) => {
                      const isInItems = before.length <= listIndex && listIndex < items.length - after.length;
                      return /* @__PURE__ */ jsx3(
                        CarouselSlide,
                        {
                          ref: isInItems ? slideRefs[index] : void 0,
                          index,
                          isSelected: isInItems && currentIndex === index,
                          className: clsx2(
                            `absolute left-[50%] h-full overflow-hidden transition-transform ease-in-out`,
                            slideClassName
                          ),
                          onClick: () => !disableClick && setCurrentIndex(index),
                          style: {
                            translate: `calc(${getStyleOffset(listIndex - (isLooping ? paddingItemCount : 0))} + ${dragState ? dragState.dragOffsetX : 0}px)`,
                            transitionDuration: dragState ? "0ms" : (isAutoPlaying && !isPaused ? autoLoopAnimationTime : animationTime) + "ms"
                          },
                          children: item
                        },
                        listIndex
                      );
                    }) }),
                    /* @__PURE__ */ jsx3(
                      "div",
                      {
                        className: clsx2(`hidden desktop:block pointer-events-none absolute left-0 h-full w-[20%] bg-gradient-to-r to-transparent`, blurColor)
                      }
                    ),
                    /* @__PURE__ */ jsx3(
                      "div",
                      {
                        className: clsx2(`hidden desktop:block pointer-events-none absolute right-0 h-full w-[20%] bg-gradient-to-l to-transparent`, blurColor)
                      }
                    )
                  ]
                }
              ) : /* @__PURE__ */ jsx3(
                "div",
                {
                  ref: slideRefs[currentIndex],
                  className: clsx2("px-16 h-full"),
                  tabIndex: 0,
                  role: "group",
                  "aria-roledescription": translation("slide"),
                  "aria-label": translation("slideOf", {
                    index: currentIndex + 1,
                    length: items.length
                  }),
                  children: children[currentIndex]
                }
              ),
              arrows && /* @__PURE__ */ jsxs2(Fragment, { children: [
                /* @__PURE__ */ jsx3(
                  IconButton,
                  {
                    color: "neutral",
                    className: clsx2("absolute z-10 left-2 top-1/2 -translate-y-1/2 shadow-md", { hidden: !canGoLeft() }),
                    disabled: !canGoLeft(),
                    onClick: () => left(),
                    children: /* @__PURE__ */ jsx3(ChevronLeft, { size: 24 })
                  }
                ),
                /* @__PURE__ */ jsx3(
                  IconButton,
                  {
                    color: "neutral",
                    className: clsx2("absolute z-10 right-2 top-1/2 -translate-y-1/2 shadow-md", { hidden: !canGoRight() }),
                    disabled: !canGoRight(),
                    onClick: () => right(),
                    children: /* @__PURE__ */ jsx3(ChevronRight, { size: 24 })
                  }
                )
              ] })
            ]
          }
        ),
        dots && /* @__PURE__ */ jsx3(CarouselTabs, { onChange: setCurrentIndex })
      ]
    }
  ) });
};
export {
  Carousel,
  CarouselSlide,
  CarouselTabs as default
};
//# sourceMappingURL=Carousel.js.map