// src/components/table/Table.tsx
import { useCallback as useCallback6, useEffect as useEffect14, useMemo as useMemo5, useRef as useRef8, useState as useState13 } from "react";
import clsx9 from "clsx";
import {
  flexRender,
  getCoreRowModel,
  getFilteredRowModel,
  getPaginationRowModel,
  getSortedRowModel,
  useReactTable
} from "@tanstack/react-table";

// 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 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/table/Table.tsx
import { Scrollbars } from "react-custom-scrollbars-2";

// src/utils/math.ts
var clamp = (value, range2 = [0, 1]) => {
  const [min, max] = range2;
  return Math.min(Math.max(value, min), max);
};

// src/components/table/TableCell.tsx
import { clsx } from "clsx";
import { jsx } from "react/jsx-runtime";
var TableCell = ({
  children,
  className
}) => {
  return /* @__PURE__ */ jsx("span", { className: clsx("block max-w-full overflow-ellipsis truncate", className), children });
};

// src/components/table/Filter.ts
var dateRange = (row, columnId, filterValue) => {
  const [min, max] = filterValue;
  const value = row.getValue(columnId);
  const date = value instanceof Date ? value : new Date(value);
  if (isNaN(date.getTime())) return false;
  if (min && date < min) return false;
  if (max && date > max) return false;
  return true;
};
var TableFilters = {
  dateRange
};

// src/hooks/useResizeCallbackWrapper.ts
import { useEffect } from "react";
var useResizeCallbackWrapper = (callback) => {
  useEffect(() => {
    window.addEventListener("resize", callback);
    return () => {
      window.removeEventListener("resize", callback);
    };
  }, [callback]);
};

// src/components/table/TableSortButton.tsx
import { ChevronDown, ChevronsUpDown, ChevronUp } from "lucide-react";

// src/components/user-action/Button.tsx
import { forwardRef } from "react";
import clsx2 from "clsx";
import { jsx as jsx2, 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: clsx2(
        "group font-semibold",
        colorClasses,
        "not-disabled:hover:brightness-90",
        "disabled:text-disabled disabled:bg-disabled-background",
        ButtonUtil.paddingMapping[size],
        className
      ),
      ...restProps,
      children: [
        startIcon && /* @__PURE__ */ jsx2(
          "span",
          {
            className: clsx2(
              iconColorClasses,
              "group-disabled:text-disabled-icon"
            ),
            children: startIcon
          }
        ),
        children,
        endIcon && /* @__PURE__ */ jsx2(
          "span",
          {
            className: clsx2(
              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__ */ jsx2(
    "button",
    {
      ref,
      className: clsx2(
        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/components/table/TableSortButton.tsx
import clsx3 from "clsx";
import { jsx as jsx3 } from "react/jsx-runtime";
var TableSortButton = ({
  sortDirection,
  invert = false,
  color = "neutral",
  className,
  ...buttonProps
}) => {
  let icon = /* @__PURE__ */ jsx3(ChevronsUpDown, { className: "w-full h-full" });
  if (sortDirection) {
    let usedSortDirection = sortDirection;
    if (invert) {
      usedSortDirection = usedSortDirection === "desc" ? "asc" : "desc";
    }
    icon = usedSortDirection === "asc" ? /* @__PURE__ */ jsx3(ChevronUp, { className: "w-full h-full" }) : /* @__PURE__ */ jsx3(ChevronDown, { className: "w-full h-full" });
  }
  return /* @__PURE__ */ jsx3(
    IconButton,
    {
      size: "tiny",
      color,
      className: clsx3(className),
      ...buttonProps,
      children: icon
    }
  );
};

// src/components/user-action/input/Input.tsx
import { forwardRef as forwardRef2, useImperativeHandle, useRef } from "react";
import clsx4 from "clsx";

// src/hooks/useDelay.ts
import { useEffect as useEffect2, useState } from "react";
var defaultOptions = {
  delay: 3e3,
  disabled: false
};
function useDelay(options) {
  const [timer, setTimer] = useState(void 0);
  const { delay, disabled } = {
    ...defaultOptions,
    ...options
  };
  const clearTimer = () => {
    clearTimeout(timer);
    setTimer(void 0);
  };
  const restartTimer = (onDelayFinish) => {
    if (disabled) {
      return;
    }
    clearTimeout(timer);
    setTimer(setTimeout(() => {
      onDelayFinish();
      setTimer(void 0);
    }, delay));
  };
  useEffect2(() => {
    return () => {
      clearTimeout(timer);
    };
  }, [timer]);
  useEffect2(() => {
    if (disabled) {
      clearTimeout(timer);
      setTimer(void 0);
    }
  }, [disabled, timer]);
  return { restartTimer, clearTimer, hasActiveTimer: !!timer };
}

// src/hooks/focus/useFocusManagement.ts
import { useCallback } from "react";
function useFocusManagement() {
  const getFocusableElements = useCallback(() => {
    return Array.from(
      document.querySelectorAll(
        'input, button, select, textarea, a[href], [tabindex]:not([tabindex="-1"])'
      )
    ).filter(
      (el) => el instanceof HTMLElement && !el.hasAttribute("disabled") && !el.hasAttribute("hidden") && el.tabIndex !== -1
    );
  }, []);
  const getNextFocusElement = useCallback(() => {
    const elements = getFocusableElements();
    if (elements.length === 0) {
      return void 0;
    }
    let nextElement = elements[0];
    if (document.activeElement instanceof HTMLElement) {
      const currentIndex = elements.indexOf(document.activeElement);
      nextElement = elements[(currentIndex + 1) % elements.length];
    }
    return nextElement;
  }, [getFocusableElements]);
  const focusNext = useCallback(() => {
    const nextElement = getNextFocusElement();
    nextElement?.focus();
  }, [getNextFocusElement]);
  const getPreviousFocusElement = useCallback(() => {
    const elements = getFocusableElements();
    if (elements.length === 0) {
      return void 0;
    }
    let previousElement = elements[0];
    if (document.activeElement instanceof HTMLElement) {
      const currentIndex = elements.indexOf(document.activeElement);
      if (currentIndex === 0) {
        previousElement = elements[elements.length - 1];
      } else {
        previousElement = elements[currentIndex - 1];
      }
    }
    return previousElement;
  }, [getFocusableElements]);
  const focusPrevious = useCallback(() => {
    const previousElement = getPreviousFocusElement();
    if (previousElement) previousElement.focus();
  }, [getPreviousFocusElement]);
  return {
    getFocusableElements,
    getNextFocusElement,
    getPreviousFocusElement,
    focusNext,
    focusPrevious
  };
}

// src/hooks/useOverwritableState.ts
import { useEffect as useEffect3, useState as useState2 } from "react";

// src/utils/resolveSetState.ts
function resolveSetState(action, prev) {
  return typeof action === "function" ? action(prev) : action;
}

// src/hooks/useOverwritableState.ts
var useOverwritableState = (initialValue, onChange) => {
  const [state, setState] = useState2(initialValue);
  useEffect3(() => {
    setState(initialValue);
  }, [initialValue]);
  const onChangeWrapper = (action) => {
    const resolved = resolveSetState(action, state);
    setState(resolved);
    onChange?.(state);
  };
  return [state, onChangeWrapper];
};

// src/components/user-action/input/Input.tsx
import { jsx as jsx4 } from "react/jsx-runtime";
var defaultEditCompleteOptions = {
  allowEnterComplete: false,
  onBlur: true,
  afterDelay: true,
  delay: 2500
};
var Input = forwardRef2(function Input2({
  value,
  onChange,
  onChangeText,
  onEditCompleted,
  editCompleteOptions,
  disabled = false,
  invalid = false,
  defaultStyle = true,
  className,
  ...props
}, forwardedRef) {
  const {
    onBlur: allowEditCompleteOnBlur,
    afterDelay,
    delay,
    allowEnterComplete
  } = { ...defaultEditCompleteOptions, ...editCompleteOptions };
  const {
    restartTimer,
    clearTimer
  } = useDelay({ delay, disabled: !afterDelay });
  const innerRef = useRef(null);
  useImperativeHandle(forwardedRef, () => innerRef.current);
  const { focusNext } = useFocusManagement();
  return /* @__PURE__ */ jsx4(
    "input",
    {
      ...props,
      ref: innerRef,
      value,
      disabled,
      className: defaultStyle ? clsx4(
        "px-3 py-2 rounded-md text-sm h-10 border-2 border-transparent focus-style-none",
        {
          "bg-input-background text-input-text hover:border-primary focus:border-primary": !disabled && !invalid,
          "bg-negative/20 text-negative hover:border-negative focus-visible:border-negative": !disabled && invalid,
          "bg-disabled-background text-disabled border-disabled-border": disabled
        },
        className
      ) : className,
      onKeyDown: (event) => {
        props.onKeyDown?.(event);
        if (!allowEnterComplete) {
          return;
        }
        if (event.key === "Enter" && !event.shiftKey) {
          event.preventDefault();
          innerRef.current?.blur();
          onEditCompleted?.(event.target.value);
          focusNext();
        }
      },
      onBlur: (event) => {
        props.onBlur?.(event);
        if (allowEditCompleteOnBlur) {
          onEditCompleted?.(event.target.value);
          clearTimer();
        }
      },
      onChange: (event) => {
        onChange?.(event);
        const value2 = event.target.value;
        restartTimer(() => {
          innerRef.current?.blur();
          onEditCompleted?.(value2);
        });
        onChangeText?.(value2);
      },
      "aria-invalid": props["aria-invalid"] ?? invalid,
      "aria-disabled": props["aria-disabled"] ?? disabled
    }
  );
});

// src/components/table/TableFilterButton.tsx
import { FilterIcon } from "lucide-react";

// src/components/user-action/Menu.tsx
import { useEffect as useEffect6, useRef as useRef2, useState as useState4 } from "react";
import clsx5 from "clsx";

// src/utils/bagFunctions.ts
var resolve = (children, bag) => {
  if (typeof children === "function") {
    return children(bag);
  }
  return children ?? void 0;
};
var BagFunctionUtil = {
  resolve
};

// src/components/user-action/Menu.tsx
import { createPortal } from "react-dom";

// src/hooks/usePopoverPosition.ts
var defaultPopoverPositionOptions = {
  edgePadding: 16,
  outerGap: 4,
  horizontalAlignment: "leftInside",
  verticalAlignment: "bottomOutside",
  disabled: false
};
var usePopoverPosition = (trigger, options) => {
  const {
    edgePadding,
    outerGap,
    verticalAlignment,
    horizontalAlignment,
    disabled
  } = { ...defaultPopoverPositionOptions, ...options };
  if (disabled || !trigger) {
    return {};
  }
  const left = {
    leftOutside: trigger.left - outerGap,
    leftInside: trigger.left,
    rightOutside: trigger.right + outerGap,
    rightInside: trigger.right,
    center: trigger.left + trigger.width / 2
  }[horizontalAlignment];
  const top = {
    topOutside: trigger.top - outerGap,
    topInside: trigger.top,
    bottomOutside: trigger.bottom + outerGap,
    bottomInside: trigger.bottom,
    center: trigger.top + trigger.height / 2
  }[verticalAlignment];
  const translateX = {
    leftOutside: "-100%",
    leftInside: void 0,
    rightOutside: void 0,
    rightInside: "-100%",
    center: "-50%"
  }[horizontalAlignment];
  const translateY = {
    topOutside: "-100%",
    topInside: void 0,
    bottomOutside: void 0,
    bottomInside: "-100%",
    center: "-50%"
  }[verticalAlignment];
  return {
    left: Math.max(left, edgePadding),
    top: Math.max(top, edgePadding),
    translate: [translateX ?? "0", translateY ?? "0"].join(" ")
  };
};

// src/hooks/useHoverState.ts
import { useEffect as useEffect4, useState as useState3 } from "react";
var defaultUseHoverStateProps = {
  closingDelay: 200,
  isDisabled: false
};
var useHoverState = (props = void 0) => {
  const { closingDelay, isDisabled } = { ...defaultUseHoverStateProps, ...props };
  const [isHovered, setIsHovered] = useState3(false);
  const [timer, setTimer] = useState3();
  const onMouseEnter = () => {
    if (isDisabled) {
      return;
    }
    clearTimeout(timer);
    setIsHovered(true);
  };
  const onMouseLeave = () => {
    if (isDisabled) {
      return;
    }
    setTimer(setTimeout(() => {
      setIsHovered(false);
    }, closingDelay));
  };
  useEffect4(() => {
    if (timer) {
      return () => {
        clearTimeout(timer);
      };
    }
  });
  useEffect4(() => {
    if (timer) {
      clearTimeout(timer);
    }
  }, [isDisabled]);
  return {
    isHovered,
    setIsHovered,
    handlers: { onMouseEnter, onMouseLeave }
  };
};

// src/hooks/useOutsideClick.ts
import { useEffect as useEffect5 } from "react";
var useOutsideClick = (refs, handler) => {
  useEffect5(() => {
    const listener = (event) => {
      if (event.target === null) return;
      if (refs.some((ref) => !ref.current || ref.current.contains(event.target))) {
        return;
      }
      handler();
    };
    document.addEventListener("mousedown", listener);
    document.addEventListener("touchstart", listener);
    return () => {
      document.removeEventListener("mousedown", listener);
      document.removeEventListener("touchstart", listener);
    };
  }, [refs, handler]);
};

// src/components/user-action/Menu.tsx
import { Fragment, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
function getScrollableParents(element) {
  const scrollables = [];
  let parent = element.parentElement;
  while (parent) {
    scrollables.push(parent);
    parent = parent.parentElement;
  }
  return scrollables;
}
var Menu = ({
  trigger,
  children,
  alignmentHorizontal = "leftInside",
  alignmentVertical = "bottomOutside",
  showOnHover = false,
  disabled = false,
  menuClassName = ""
}) => {
  const { isHovered: isOpen, setIsHovered: setIsOpen } = useHoverState({ isDisabled: !showOnHover || disabled });
  const triggerRef = useRef2(null);
  const menuRef = useRef2(null);
  useOutsideClick([triggerRef, menuRef], () => setIsOpen(false));
  const [isHidden, setIsHidden] = useState4(true);
  const bag = {
    isOpen,
    close: () => setIsOpen(false),
    toggleOpen: () => setIsOpen((prevState) => !prevState),
    disabled
  };
  const menuPosition = usePopoverPosition(
    triggerRef.current?.getBoundingClientRect(),
    { verticalAlignment: alignmentVertical, horizontalAlignment: alignmentHorizontal, disabled }
  );
  useEffect6(() => {
    if (!isOpen) return;
    const triggerEl = triggerRef.current;
    if (!triggerEl) return;
    const scrollableParents = getScrollableParents(triggerEl);
    const close = () => setIsOpen(false);
    scrollableParents.forEach((parent) => {
      parent.addEventListener("scroll", close);
    });
    window.addEventListener("resize", close);
    return () => {
      scrollableParents.forEach((parent) => {
        parent.removeEventListener("scroll", close);
      });
      window.removeEventListener("resize", close);
    };
  }, [isOpen, setIsOpen]);
  useEffect6(() => {
    if (isOpen) {
      setIsHidden(false);
    }
  }, [isOpen]);
  return /* @__PURE__ */ jsxs2(Fragment, { children: [
    trigger(bag, triggerRef),
    createPortal(/* @__PURE__ */ jsx5(
      "div",
      {
        ref: menuRef,
        onClick: (e) => e.stopPropagation(),
        className: clsx5(
          "absolute rounded-md bg-menu-background text-menu-text shadow-around-lg shadow-strong z-[300]",
          {
            "animate-pop-in": isOpen,
            "animate-pop-out": !isOpen,
            "hidden": isHidden
          },
          menuClassName
        ),
        onAnimationEnd: () => {
          if (!isOpen) {
            setIsHidden(true);
          }
        },
        style: {
          ...menuPosition
        },
        children: BagFunctionUtil.resolve(children, bag)
      }
    ), document.body)
  ] });
};

// src/components/table/TableFilterButton.tsx
import { useEffect as useEffect8, useState as useState7 } from "react";

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

// src/hooks/useLocalStorage.ts
import { useCallback as useCallback2, useState as useState5 } 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 jsx6 } 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/table/TableFilterButton.tsx
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
var TableFilterButton = ({
  filterType,
  column
}) => {
  const translation = useHightideTranslation();
  const columnFilterValue = column.getFilterValue();
  const [filterValue, setFilterValue] = useState7(columnFilterValue);
  const hasFilter = !!filterValue;
  useEffect8(() => {
    setFilterValue(columnFilterValue);
  }, [columnFilterValue]);
  return /* @__PURE__ */ jsx7(
    Menu,
    {
      trigger: ({ toggleOpen }, ref) => /* @__PURE__ */ jsxs3("div", { ref, className: "relative", children: [
        /* @__PURE__ */ jsx7(IconButton, { color: "neutral", size: "tiny", onClick: toggleOpen, children: /* @__PURE__ */ jsx7(FilterIcon, {}) }),
        hasFilter && /* @__PURE__ */ jsx7(
          "div",
          {
            className: "absolute top-0.5 right-0.5 w-2 h-2 rounded-full bg-primary pointer-events-none",
            "aria-hidden": true
          }
        )
      ] }),
      children: ({ close }) => /* @__PURE__ */ jsxs3("div", { className: "flex-col-1 p-2 items-start font-normal text-menu-text", children: [
        /* @__PURE__ */ jsx7("h4", { className: "typography-label-md-semibold", children: translation("filter") }),
        filterType === "text" && /* @__PURE__ */ jsx7(
          Input,
          {
            value: filterValue ?? "",
            autoFocus: true,
            placeholder: translation("text") + "...",
            onChangeText: setFilterValue,
            className: "h-10"
          }
        ),
        filterType === "range" && /* @__PURE__ */ jsxs3("div", { className: "flex-row-2 items-center", children: [
          /* @__PURE__ */ jsx7(
            Input,
            {
              value: filterValue?.[0] ?? "",
              type: "number",
              placeholder: translation("min"),
              onChangeText: (text) => {
                const num = Number(text);
                setFilterValue((old) => [num, old?.[1]]);
              },
              className: "h-10 input-indicator-hidden w-40"
            }
          ),
          /* @__PURE__ */ jsx7("span", { className: "font-bold", children: "-" }),
          /* @__PURE__ */ jsx7(
            Input,
            {
              value: filterValue?.[1] ?? "",
              type: "number",
              placeholder: translation("max"),
              onChangeText: (text) => {
                const num = Number(text);
                setFilterValue((old) => [old?.[0], num]);
              },
              className: "h-10 input-indicator-hidden w-40"
            }
          )
        ] }),
        filterType === "dateRange" && /* @__PURE__ */ jsxs3(Fragment2, { children: [
          /* @__PURE__ */ jsx7(
            Input,
            {
              value: filterValue?.[0] ? filterValue?.[0].toISOString().slice(0, 16) : "",
              type: "datetime-local",
              placeholder: translation("startDate"),
              onChangeText: (text) => {
                const value = new Date(text);
                setFilterValue((old) => [value, old?.[1]]);
              },
              className: "h-10 w-50"
            }
          ),
          /* @__PURE__ */ jsx7(
            Input,
            {
              value: filterValue?.[1] ? filterValue?.[1].toISOString().slice(0, 16) : "",
              type: "datetime-local",
              placeholder: translation("endDate"),
              onChangeText: (text) => {
                const value = new Date(text);
                setFilterValue((old) => [old?.[0], value]);
              },
              className: "h-10 w-50"
            }
          )
        ] }),
        /* @__PURE__ */ jsxs3("div", { className: "flex-row-2 justify-end w-full", children: [
          hasFilter && /* @__PURE__ */ jsx7(SolidButton, { color: "negative", size: "small", onClick: () => {
            column.setFilterValue(void 0);
            close();
          }, children: translation("remove") }),
          /* @__PURE__ */ jsx7(SolidButton, { size: "small", onClick: () => {
            column.setFilterValue(filterValue);
            close();
          }, children: translation("apply") })
        ] })
      ] })
    }
  );
};

// src/components/table/FillerRowElement.tsx
import { clsx as clsx6 } from "clsx";
import { jsx as jsx8 } from "react/jsx-runtime";
var FillerRowElement = ({
  className
}) => {
  return /* @__PURE__ */ jsx8("div", { className: clsx6("flex flex-row items-center w-1/2 h-4 text-disabled font-bold", className), children: "-" });
};

// src/components/navigation/Pagination.tsx
import { ChevronFirst, ChevronLast, ChevronLeft, ChevronRight } from "lucide-react";
import clsx7 from "clsx";
import { useEffect as useEffect9, useState as useState8 } from "react";
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
var Pagination = ({
  pageIndex,
  pageCount,
  onPageChanged,
  className,
  style
}) => {
  const translation = useHightideTranslation();
  const [value, setValue] = useState8((pageIndex + 1).toString());
  const noPages = pageCount === 0;
  const onFirstPage = pageIndex === 0 && !noPages;
  const onLastPage = pageIndex === pageCount - 1;
  useEffect9(() => {
    if (noPages) {
      setValue("0");
    } else {
      setValue((pageIndex + 1).toString());
    }
  }, [pageIndex, noPages]);
  const changePage = (page) => {
    onPageChanged(page);
  };
  return /* @__PURE__ */ jsxs4("div", { className: clsx7("flex-row-1", className), style, children: [
    /* @__PURE__ */ jsx9(IconButton, { color: "transparent", onClick: () => changePage(0), disabled: onFirstPage || noPages, children: /* @__PURE__ */ jsx9(ChevronFirst, {}) }),
    /* @__PURE__ */ jsx9(IconButton, { color: "transparent", onClick: () => changePage(pageIndex - 1), disabled: onFirstPage || noPages, children: /* @__PURE__ */ jsx9(ChevronLeft, {}) }),
    /* @__PURE__ */ jsxs4("div", { className: "flex-row-2 min-w-56 items-center justify-center mx-2 text-center", children: [
      /* @__PURE__ */ jsx9(
        Input,
        {
          value,
          className: clsx7(
            "w-full text-center font-bold input-indicator-hidden h-10"
          ),
          type: "number",
          min: 1,
          max: pageCount,
          disabled: noPages,
          onChangeText: (value2) => {
            if (value2) {
              setValue(clamp(Number(value2), [1, pageCount]).toString());
            } else {
              setValue(value2);
            }
          },
          onEditCompleted: (value2) => {
            changePage(clamp(Number(value2) - 1, [0, pageCount - 1]));
          },
          editCompleteOptions: { delay: 800 }
        }
      ),
      /* @__PURE__ */ jsx9("span", { className: "select-none w-10", children: translation("of") }),
      /* @__PURE__ */ jsx9(
        "span",
        {
          className: "flex-row-2 flex-1 items-center justify-center select-none h-10 bg-input-background text-input-text rounded-md font-bold",
          children: pageCount
        }
      )
    ] }),
    /* @__PURE__ */ jsx9(IconButton, { color: "transparent", onClick: () => changePage(pageIndex + 1), disabled: onLastPage || noPages, children: /* @__PURE__ */ jsx9(ChevronRight, {}) }),
    /* @__PURE__ */ jsx9(IconButton, { color: "transparent", onClick: () => changePage(pageCount - 1), disabled: onLastPage || noPages, children: /* @__PURE__ */ jsx9(ChevronLast, {}) })
  ] });
};

// src/components/user-action/Checkbox.tsx
import { Check, Minus } from "lucide-react";
import clsx8 from "clsx";

// node_modules/@radix-ui/react-checkbox/dist/index.mjs
import * as React11 from "react";

// node_modules/@radix-ui/react-compose-refs/dist/index.mjs
import * as React2 from "react";
function setRef(ref, value) {
  if (typeof ref === "function") {
    return ref(value);
  } else if (ref !== null && ref !== void 0) {
    ref.current = value;
  }
}
function composeRefs(...refs) {
  return (node) => {
    let hasCleanup = false;
    const cleanups = refs.map((ref) => {
      const cleanup = setRef(ref, node);
      if (!hasCleanup && typeof cleanup == "function") {
        hasCleanup = true;
      }
      return cleanup;
    });
    if (hasCleanup) {
      return () => {
        for (let i = 0; i < cleanups.length; i++) {
          const cleanup = cleanups[i];
          if (typeof cleanup == "function") {
            cleanup();
          } else {
            setRef(refs[i], null);
          }
        }
      };
    }
  };
}
function useComposedRefs(...refs) {
  return React2.useCallback(composeRefs(...refs), refs);
}

// node_modules/@radix-ui/react-context/dist/index.mjs
import * as React3 from "react";
import { jsx as jsx10 } from "react/jsx-runtime";
function createContextScope(scopeName, createContextScopeDeps = []) {
  let defaultContexts = [];
  function createContext3(rootComponentName, defaultContext) {
    const BaseContext = React3.createContext(defaultContext);
    const index = defaultContexts.length;
    defaultContexts = [...defaultContexts, defaultContext];
    const Provider = (props) => {
      const { scope, children, ...context } = props;
      const Context = scope?.[scopeName]?.[index] || BaseContext;
      const value = React3.useMemo(() => context, Object.values(context));
      return /* @__PURE__ */ jsx10(Context.Provider, { value, children });
    };
    Provider.displayName = rootComponentName + "Provider";
    function useContext22(consumerName, scope) {
      const Context = scope?.[scopeName]?.[index] || BaseContext;
      const context = React3.useContext(Context);
      if (context) return context;
      if (defaultContext !== void 0) return defaultContext;
      throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
    }
    return [Provider, useContext22];
  }
  const createScope = () => {
    const scopeContexts = defaultContexts.map((defaultContext) => {
      return React3.createContext(defaultContext);
    });
    return function useScope(scope) {
      const contexts = scope?.[scopeName] || scopeContexts;
      return React3.useMemo(
        () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
        [scope, contexts]
      );
    };
  };
  createScope.scopeName = scopeName;
  return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
}
function composeContextScopes(...scopes) {
  const baseScope = scopes[0];
  if (scopes.length === 1) return baseScope;
  const createScope = () => {
    const scopeHooks = scopes.map((createScope2) => ({
      useScope: createScope2(),
      scopeName: createScope2.scopeName
    }));
    return function useComposedScopes(overrideScopes) {
      const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
        const scopeProps = useScope(overrideScopes);
        const currentScope = scopeProps[`__scope${scopeName}`];
        return { ...nextScopes2, ...currentScope };
      }, {});
      return React3.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
    };
  };
  createScope.scopeName = baseScope.scopeName;
  return createScope;
}

// node_modules/@radix-ui/primitive/dist/index.mjs
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
  return function handleEvent(event) {
    originalEventHandler?.(event);
    if (checkForDefaultPrevented === false || !event.defaultPrevented) {
      return ourEventHandler?.(event);
    }
  };
}

// node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
import * as React5 from "react";

// node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs
import * as React4 from "react";
var useLayoutEffect2 = globalThis?.document ? React4.useLayoutEffect : () => {
};

// node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
import * as React22 from "react";
var useInsertionEffect = React5[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
function useControllableState({
  prop,
  defaultProp,
  onChange = () => {
  },
  caller
}) {
  const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
    defaultProp,
    onChange
  });
  const isControlled = prop !== void 0;
  const value = isControlled ? prop : uncontrolledProp;
  if (true) {
    const isControlledRef = React5.useRef(prop !== void 0);
    React5.useEffect(() => {
      const wasControlled = isControlledRef.current;
      if (wasControlled !== isControlled) {
        const from = wasControlled ? "controlled" : "uncontrolled";
        const to = isControlled ? "controlled" : "uncontrolled";
        console.warn(
          `${caller} is changing from ${from} to ${to}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
        );
      }
      isControlledRef.current = isControlled;
    }, [isControlled, caller]);
  }
  const setValue = React5.useCallback(
    (nextValue) => {
      if (isControlled) {
        const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
        if (value2 !== prop) {
          onChangeRef.current?.(value2);
        }
      } else {
        setUncontrolledProp(nextValue);
      }
    },
    [isControlled, prop, setUncontrolledProp, onChangeRef]
  );
  return [value, setValue];
}
function useUncontrolledState({
  defaultProp,
  onChange
}) {
  const [value, setValue] = React5.useState(defaultProp);
  const prevValueRef = React5.useRef(value);
  const onChangeRef = React5.useRef(onChange);
  useInsertionEffect(() => {
    onChangeRef.current = onChange;
  }, [onChange]);
  React5.useEffect(() => {
    if (prevValueRef.current !== value) {
      onChangeRef.current?.(value);
      prevValueRef.current = value;
    }
  }, [value, prevValueRef]);
  return [value, setValue, onChangeRef];
}
function isFunction(value) {
  return typeof value === "function";
}
var SYNC_STATE = Symbol("RADIX:SYNC_STATE");

// node_modules/@radix-ui/react-use-previous/dist/index.mjs
import * as React6 from "react";
function usePrevious(value) {
  const ref = React6.useRef({ value, previous: value });
  return React6.useMemo(() => {
    if (ref.current.value !== value) {
      ref.current.previous = ref.current.value;
      ref.current.value = value;
    }
    return ref.current.previous;
  }, [value]);
}

// node_modules/@radix-ui/react-use-size/dist/index.mjs
import * as React7 from "react";
function useSize(element) {
  const [size, setSize] = React7.useState(void 0);
  useLayoutEffect2(() => {
    if (element) {
      setSize({ width: element.offsetWidth, height: element.offsetHeight });
      const resizeObserver = new ResizeObserver((entries) => {
        if (!Array.isArray(entries)) {
          return;
        }
        if (!entries.length) {
          return;
        }
        const entry = entries[0];
        let width;
        let height;
        if ("borderBoxSize" in entry) {
          const borderSizeEntry = entry["borderBoxSize"];
          const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
          width = borderSize["inlineSize"];
          height = borderSize["blockSize"];
        } else {
          width = element.offsetWidth;
          height = element.offsetHeight;
        }
        setSize({ width, height });
      });
      resizeObserver.observe(element, { box: "border-box" });
      return () => resizeObserver.unobserve(element);
    } else {
      setSize(void 0);
    }
  }, [element]);
  return size;
}

// node_modules/@radix-ui/react-presence/dist/index.mjs
import * as React23 from "react";
import * as React8 from "react";
function useStateMachine(initialState, machine) {
  return React8.useReducer((state, event) => {
    const nextState = machine[state][event];
    return nextState ?? state;
  }, initialState);
}
var Presence = (props) => {
  const { present, children } = props;
  const presence = usePresence(present);
  const child = typeof children === "function" ? children({ present: presence.isPresent }) : React23.Children.only(children);
  const ref = useComposedRefs(presence.ref, getElementRef(child));
  const forceMount = typeof children === "function";
  return forceMount || presence.isPresent ? React23.cloneElement(child, { ref }) : null;
};
Presence.displayName = "Presence";
function usePresence(present) {
  const [node, setNode] = React23.useState();
  const stylesRef = React23.useRef(null);
  const prevPresentRef = React23.useRef(present);
  const prevAnimationNameRef = React23.useRef("none");
  const initialState = present ? "mounted" : "unmounted";
  const [state, send] = useStateMachine(initialState, {
    mounted: {
      UNMOUNT: "unmounted",
      ANIMATION_OUT: "unmountSuspended"
    },
    unmountSuspended: {
      MOUNT: "mounted",
      ANIMATION_END: "unmounted"
    },
    unmounted: {
      MOUNT: "mounted"
    }
  });
  React23.useEffect(() => {
    const currentAnimationName = getAnimationName(stylesRef.current);
    prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
  }, [state]);
  useLayoutEffect2(() => {
    const styles = stylesRef.current;
    const wasPresent = prevPresentRef.current;
    const hasPresentChanged = wasPresent !== present;
    if (hasPresentChanged) {
      const prevAnimationName = prevAnimationNameRef.current;
      const currentAnimationName = getAnimationName(styles);
      if (present) {
        send("MOUNT");
      } else if (currentAnimationName === "none" || styles?.display === "none") {
        send("UNMOUNT");
      } else {
        const isAnimating = prevAnimationName !== currentAnimationName;
        if (wasPresent && isAnimating) {
          send("ANIMATION_OUT");
        } else {
          send("UNMOUNT");
        }
      }
      prevPresentRef.current = present;
    }
  }, [present, send]);
  useLayoutEffect2(() => {
    if (node) {
      let timeoutId;
      const ownerWindow = node.ownerDocument.defaultView ?? window;
      const handleAnimationEnd = (event) => {
        const currentAnimationName = getAnimationName(stylesRef.current);
        const isCurrentAnimation = currentAnimationName.includes(event.animationName);
        if (event.target === node && isCurrentAnimation) {
          send("ANIMATION_END");
          if (!prevPresentRef.current) {
            const currentFillMode = node.style.animationFillMode;
            node.style.animationFillMode = "forwards";
            timeoutId = ownerWindow.setTimeout(() => {
              if (node.style.animationFillMode === "forwards") {
                node.style.animationFillMode = currentFillMode;
              }
            });
          }
        }
      };
      const handleAnimationStart = (event) => {
        if (event.target === node) {
          prevAnimationNameRef.current = getAnimationName(stylesRef.current);
        }
      };
      node.addEventListener("animationstart", handleAnimationStart);
      node.addEventListener("animationcancel", handleAnimationEnd);
      node.addEventListener("animationend", handleAnimationEnd);
      return () => {
        ownerWindow.clearTimeout(timeoutId);
        node.removeEventListener("animationstart", handleAnimationStart);
        node.removeEventListener("animationcancel", handleAnimationEnd);
        node.removeEventListener("animationend", handleAnimationEnd);
      };
    } else {
      send("ANIMATION_END");
    }
  }, [node, send]);
  return {
    isPresent: ["mounted", "unmountSuspended"].includes(state),
    ref: React23.useCallback((node2) => {
      stylesRef.current = node2 ? getComputedStyle(node2) : null;
      setNode(node2);
    }, [])
  };
}
function getAnimationName(styles) {
  return styles?.animationName || "none";
}
function getElementRef(element) {
  let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
  let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
  if (mayWarn) {
    return element.ref;
  }
  getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
  mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
  if (mayWarn) {
    return element.props.ref;
  }
  return element.props.ref || element.ref;
}

// node_modules/@radix-ui/react-primitive/dist/index.mjs
import * as React10 from "react";
import * as ReactDOM from "react-dom";

// node_modules/@radix-ui/react-slot/dist/index.mjs
import * as React9 from "react";
import { Fragment as Fragment22, jsx as jsx11 } from "react/jsx-runtime";
// @__NO_SIDE_EFFECTS__
function createSlot(ownerName) {
  const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
  const Slot2 = React9.forwardRef((props, forwardedRef) => {
    const { children, ...slotProps } = props;
    const childrenArray = React9.Children.toArray(children);
    const slottable = childrenArray.find(isSlottable);
    if (slottable) {
      const newElement = slottable.props.children;
      const newChildren = childrenArray.map((child) => {
        if (child === slottable) {
          if (React9.Children.count(newElement) > 1) return React9.Children.only(null);
          return React9.isValidElement(newElement) ? newElement.props.children : null;
        } else {
          return child;
        }
      });
      return /* @__PURE__ */ jsx11(SlotClone, { ...slotProps, ref: forwardedRef, children: React9.isValidElement(newElement) ? React9.cloneElement(newElement, void 0, newChildren) : null });
    }
    return /* @__PURE__ */ jsx11(SlotClone, { ...slotProps, ref: forwardedRef, children });
  });
  Slot2.displayName = `${ownerName}.Slot`;
  return Slot2;
}
// @__NO_SIDE_EFFECTS__
function createSlotClone(ownerName) {
  const SlotClone = React9.forwardRef((props, forwardedRef) => {
    const { children, ...slotProps } = props;
    if (React9.isValidElement(children)) {
      const childrenRef = getElementRef2(children);
      const props2 = mergeProps(slotProps, children.props);
      if (children.type !== React9.Fragment) {
        props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
      }
      return React9.cloneElement(children, props2);
    }
    return React9.Children.count(children) > 1 ? React9.Children.only(null) : null;
  });
  SlotClone.displayName = `${ownerName}.SlotClone`;
  return SlotClone;
}
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
function isSlottable(child) {
  return React9.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
}
function mergeProps(slotProps, childProps) {
  const overrideProps = { ...childProps };
  for (const propName in childProps) {
    const slotPropValue = slotProps[propName];
    const childPropValue = childProps[propName];
    const isHandler = /^on[A-Z]/.test(propName);
    if (isHandler) {
      if (slotPropValue && childPropValue) {
        overrideProps[propName] = (...args) => {
          const result = childPropValue(...args);
          slotPropValue(...args);
          return result;
        };
      } else if (slotPropValue) {
        overrideProps[propName] = slotPropValue;
      }
    } else if (propName === "style") {
      overrideProps[propName] = { ...slotPropValue, ...childPropValue };
    } else if (propName === "className") {
      overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
    }
  }
  return { ...slotProps, ...overrideProps };
}
function getElementRef2(element) {
  let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
  let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
  if (mayWarn) {
    return element.ref;
  }
  getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
  mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
  if (mayWarn) {
    return element.props.ref;
  }
  return element.props.ref || element.ref;
}

// node_modules/@radix-ui/react-primitive/dist/index.mjs
import { jsx as jsx12 } from "react/jsx-runtime";
var NODES = [
  "a",
  "button",
  "div",
  "form",
  "h2",
  "h3",
  "img",
  "input",
  "label",
  "li",
  "nav",
  "ol",
  "p",
  "select",
  "span",
  "svg",
  "ul"
];
var Primitive = NODES.reduce((primitive, node) => {
  const Slot = createSlot(`Primitive.${node}`);
  const Node = React10.forwardRef((props, forwardedRef) => {
    const { asChild, ...primitiveProps } = props;
    const Comp = asChild ? Slot : node;
    if (typeof window !== "undefined") {
      window[Symbol.for("radix-ui")] = true;
    }
    return /* @__PURE__ */ jsx12(Comp, { ...primitiveProps, ref: forwardedRef });
  });
  Node.displayName = `Primitive.${node}`;
  return { ...primitive, [node]: Node };
}, {});

// node_modules/@radix-ui/react-checkbox/dist/index.mjs
import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
var CHECKBOX_NAME = "Checkbox";
var [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);
var [CheckboxProviderImpl, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
function CheckboxProvider(props) {
  const {
    __scopeCheckbox,
    checked: checkedProp,
    children,
    defaultChecked,
    disabled,
    form,
    name,
    onCheckedChange,
    required,
    value = "on",
    // @ts-expect-error
    internal_do_not_use_render
  } = props;
  const [checked, setChecked] = useControllableState({
    prop: checkedProp,
    defaultProp: defaultChecked ?? false,
    onChange: onCheckedChange,
    caller: CHECKBOX_NAME
  });
  const [control, setControl] = React11.useState(null);
  const [bubbleInput, setBubbleInput] = React11.useState(null);
  const hasConsumerStoppedPropagationRef = React11.useRef(false);
  const isFormControl = control ? !!form || !!control.closest("form") : (
    // We set this to true by default so that events bubble to forms without JS (SSR)
    true
  );
  const context = {
    checked,
    disabled,
    setChecked,
    control,
    setControl,
    name,
    form,
    value,
    hasConsumerStoppedPropagationRef,
    required,
    defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,
    isFormControl,
    bubbleInput,
    setBubbleInput
  };
  return /* @__PURE__ */ jsx13(
    CheckboxProviderImpl,
    {
      scope: __scopeCheckbox,
      ...context,
      children: isFunction2(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
    }
  );
}
var TRIGGER_NAME = "CheckboxTrigger";
var CheckboxTrigger = React11.forwardRef(
  ({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) => {
    const {
      control,
      value,
      disabled,
      checked,
      required,
      setControl,
      setChecked,
      hasConsumerStoppedPropagationRef,
      isFormControl,
      bubbleInput
    } = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);
    const composedRefs = useComposedRefs(forwardedRef, setControl);
    const initialCheckedStateRef = React11.useRef(checked);
    React11.useEffect(() => {
      const form = control?.form;
      if (form) {
        const reset = () => setChecked(initialCheckedStateRef.current);
        form.addEventListener("reset", reset);
        return () => form.removeEventListener("reset", reset);
      }
    }, [control, setChecked]);
    return /* @__PURE__ */ jsx13(
      Primitive.button,
      {
        type: "button",
        role: "checkbox",
        "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
        "aria-required": required,
        "data-state": getState(checked),
        "data-disabled": disabled ? "" : void 0,
        disabled,
        value,
        ...checkboxProps,
        ref: composedRefs,
        onKeyDown: composeEventHandlers(onKeyDown, (event) => {
          if (event.key === "Enter") event.preventDefault();
        }),
        onClick: composeEventHandlers(onClick, (event) => {
          setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
          if (bubbleInput && isFormControl) {
            hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
            if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
          }
        })
      }
    );
  }
);
CheckboxTrigger.displayName = TRIGGER_NAME;
var Checkbox = React11.forwardRef(
  (props, forwardedRef) => {
    const {
      __scopeCheckbox,
      name,
      checked,
      defaultChecked,
      required,
      disabled,
      value,
      onCheckedChange,
      form,
      ...checkboxProps
    } = props;
    return /* @__PURE__ */ jsx13(
      CheckboxProvider,
      {
        __scopeCheckbox,
        checked,
        defaultChecked,
        disabled,
        required,
        onCheckedChange,
        name,
        form,
        value,
        internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ jsxs5(Fragment4, { children: [
          /* @__PURE__ */ jsx13(
            CheckboxTrigger,
            {
              ...checkboxProps,
              ref: forwardedRef,
              __scopeCheckbox
            }
          ),
          isFormControl && /* @__PURE__ */ jsx13(
            CheckboxBubbleInput,
            {
              __scopeCheckbox
            }
          )
        ] })
      }
    );
  }
);
Checkbox.displayName = CHECKBOX_NAME;
var INDICATOR_NAME = "CheckboxIndicator";
var CheckboxIndicator = React11.forwardRef(
  (props, forwardedRef) => {
    const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
    const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
    return /* @__PURE__ */ jsx13(
      Presence,
      {
        present: forceMount || isIndeterminate(context.checked) || context.checked === true,
        children: /* @__PURE__ */ jsx13(
          Primitive.span,
          {
            "data-state": getState(context.checked),
            "data-disabled": context.disabled ? "" : void 0,
            ...indicatorProps,
            ref: forwardedRef,
            style: { pointerEvents: "none", ...props.style }
          }
        )
      }
    );
  }
);
CheckboxIndicator.displayName = INDICATOR_NAME;
var BUBBLE_INPUT_NAME = "CheckboxBubbleInput";
var CheckboxBubbleInput = React11.forwardRef(
  ({ __scopeCheckbox, ...props }, forwardedRef) => {
    const {
      control,
      hasConsumerStoppedPropagationRef,
      checked,
      defaultChecked,
      required,
      disabled,
      name,
      value,
      form,
      bubbleInput,
      setBubbleInput
    } = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);
    const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
    const prevChecked = usePrevious(checked);
    const controlSize = useSize(control);
    React11.useEffect(() => {
      const input = bubbleInput;
      if (!input) return;
      const inputProto = window.HTMLInputElement.prototype;
      const descriptor = Object.getOwnPropertyDescriptor(
        inputProto,
        "checked"
      );
      const setChecked = descriptor.set;
      const bubbles = !hasConsumerStoppedPropagationRef.current;
      if (prevChecked !== checked && setChecked) {
        const event = new Event("click", { bubbles });
        input.indeterminate = isIndeterminate(checked);
        setChecked.call(input, isIndeterminate(checked) ? false : checked);
        input.dispatchEvent(event);
      }
    }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);
    const defaultCheckedRef = React11.useRef(isIndeterminate(checked) ? false : checked);
    return /* @__PURE__ */ jsx13(
      Primitive.input,
      {
        type: "checkbox",
        "aria-hidden": true,
        defaultChecked: defaultChecked ?? defaultCheckedRef.current,
        required,
        disabled,
        name,
        value,
        form,
        ...props,
        tabIndex: -1,
        ref: composedRefs,
        style: {
          ...props.style,
          ...controlSize,
          position: "absolute",
          pointerEvents: "none",
          opacity: 0,
          margin: 0,
          // We transform because the input is absolutely positioned but we have
          // rendered it **after** the button. This pulls it back to sit on top
          // of the button.
          transform: "translateX(-100%)"
        }
      }
    );
  }
);
CheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;
function isFunction2(value) {
  return typeof value === "function";
}
function isIndeterminate(checked) {
  return checked === "indeterminate";
}
function getState(checked) {
  return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
}

// src/components/user-action/Checkbox.tsx
import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
var checkboxSizeMapping = {
  sm: "size-5 border-1",
  md: "size-6 border-1",
  lg: "size-8 border-2"
};
var checkboxIconSizeMapping = {
  sm: "size-4 stroke-3",
  md: "size-5 stroke-3",
  lg: "size-7 stroke-3"
};
var Checkbox2 = ({
  disabled,
  checked = false,
  indeterminate = false,
  onChange,
  size = "md",
  className = "",
  ...props
}) => {
  const usedSizeClass = checkboxSizeMapping[size];
  const innerIconSize = checkboxIconSizeMapping[size];
  return /* @__PURE__ */ jsx14(
    Checkbox,
    {
      ...props,
      disabled,
      checked: indeterminate ? "indeterminate" : checked,
      onCheckedChange: onChange,
      className: clsx8(
        usedSizeClass,
        `flex-col-0 items-center justify-center rounded`,
        {
          "text-disabled border-disabled-outline bg-disabled-background cursor-not-allowed": disabled,
          "hover:border-primary": !disabled,
          "bg-input-background": !disabled && !checked,
          "bg-primary/30 border-primary text-primary": !disabled && (checked || indeterminate)
        },
        className
      ),
      children: /* @__PURE__ */ jsxs6(CheckboxIndicator, { children: [
        !checked && !indeterminate && /* @__PURE__ */ jsx14("div", { className: clsx8("bg-input-background", innerIconSize) }),
        checked && !indeterminate && /* @__PURE__ */ jsx14(Check, { className: innerIconSize }),
        indeterminate && /* @__PURE__ */ jsx14(Minus, { className: innerIconSize })
      ] })
    }
  );
};

// src/components/table/Table.tsx
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
var Table = ({
  data,
  fillerRow,
  initialState,
  onRowClick,
  className,
  tableClassName,
  defaultColumn,
  state,
  columns,
  ...tableOptions
}) => {
  const ref = useRef8(null);
  const tableRef = useRef8(null);
  const [columnSizing, setColumnSizing] = useState13(columns.reduce((previousValue, currentValue) => {
    return {
      ...previousValue,
      [currentValue.id]: currentValue.minSize ?? defaultColumn.minSize
    };
  }, {}));
  const [columnSizingInfo, setColumnSizingInfo] = useState13();
  const [pagination, setPagination] = useState13({
    pageSize: 10,
    pageIndex: 0,
    ...initialState?.pagination
  });
  const [columnFilters, setColumnFilters] = useState13(initialState?.columnFilters);
  const computedColumnMinWidths = useMemo5(() => {
    return columns.reduce((previousValue, column) => {
      return {
        ...previousValue,
        // every column is at least 12px wide
        [column.id]: column.minSize ?? defaultColumn?.minSize ?? 12
      };
    }, {});
  }, [columns, defaultColumn]);
  const computedColumnMaxWidths = useMemo5(() => {
    return columns.reduce((previousValue, column) => {
      return {
        ...previousValue,
        [column.id]: column.maxSize ?? defaultColumn?.maxSize
      };
    }, {});
  }, [columns, defaultColumn]);
  const tableMinWidth = useMemo5(() => {
    return columns.reduce((sum, column) => {
      return sum + computedColumnMinWidths[column.id];
    }, 0);
  }, [columns, computedColumnMinWidths]);
  const updateColumnSizes = useMemo5(() => {
    return (previous) => {
      const updateSizing = {
        ...columnSizing,
        ...previous
      };
      const containerWidth = ref.current.offsetWidth;
      columns.forEach((column) => {
        updateSizing[column.id] = clamp(updateSizing[column.id], [computedColumnMinWidths[column.id], computedColumnMaxWidths[column.id] ?? containerWidth]);
      });
      const width = columns.reduce((previousValue, currentValue) => previousValue + updateSizing[currentValue.id], 0);
      if (width > containerWidth) {
        if (tableMinWidth >= containerWidth) {
          return columns.reduce((previousValue, currentValue) => ({
            ...previousValue,
            [currentValue.id]: computedColumnMinWidths[currentValue.id]
          }), {});
        }
        let reduceableColumns = columns.map((value) => value.id).filter((id) => updateSizing[id] - computedColumnMinWidths[id] > 0);
        let spaceToReduce = width - containerWidth;
        while (spaceToReduce > 0 && reduceableColumns.length > 0) {
          let maxReduceAmount = reduceableColumns.reduce((previousValue, id) => Math.max(previousValue, updateSizing[id] - computedColumnMinWidths[id]), 0);
          if (maxReduceAmount * reduceableColumns.length > spaceToReduce) {
            maxReduceAmount = spaceToReduce / reduceableColumns.length;
          }
          reduceableColumns.forEach((id) => {
            updateSizing[id] -= maxReduceAmount;
          });
          spaceToReduce -= maxReduceAmount * reduceableColumns.length;
          reduceableColumns = reduceableColumns.filter((id) => updateSizing[id] - computedColumnMinWidths[id] > 0);
        }
      } else if (width <= containerWidth) {
        let distributableWidth = containerWidth - width;
        const violatingColumns = columns.filter((value) => computedColumnMaxWidths[value.id] && updateSizing[value.id] > computedColumnMaxWidths[value.id]);
        const violationColumnsAmount = violatingColumns.reduce(
          (previousValue, column) => previousValue + updateSizing[column.id] - computedColumnMaxWidths[column.id],
          0
        );
        distributableWidth += violationColumnsAmount;
        let enlargeableColumns = columns.filter((col) => !computedColumnMaxWidths[col.id] || updateSizing[col.id] < computedColumnMaxWidths[col.id]).map((value) => value.id);
        while (distributableWidth > 0 && enlargeableColumns.length > 0) {
          let minEnlargeableAmount = enlargeableColumns.reduce((previousValue, id) => Math.min(previousValue, computedColumnMaxWidths[id] ? computedColumnMaxWidths[id] - updateSizing[id] : distributableWidth), distributableWidth);
          if (minEnlargeableAmount * enlargeableColumns.length > distributableWidth) {
            minEnlargeableAmount = distributableWidth / enlargeableColumns.length;
          }
          enlargeableColumns.forEach((id) => {
            updateSizing[id] += minEnlargeableAmount;
          });
          distributableWidth -= minEnlargeableAmount * enlargeableColumns.length;
          enlargeableColumns = enlargeableColumns.filter((id) => !computedColumnMaxWidths[id] || updateSizing[id] < computedColumnMaxWidths[id]);
        }
        if (distributableWidth > 0) {
          updateSizing[columns[columns.length - 1].id] += distributableWidth;
        }
      }
      return updateSizing;
    };
  }, [columns, computedColumnMaxWidths, computedColumnMinWidths, tableMinWidth]);
  const table = useReactTable({
    data,
    getCoreRowModel: getCoreRowModel(),
    getFilteredRowModel: getFilteredRowModel(),
    getSortedRowModel: getSortedRowModel(),
    getPaginationRowModel: getPaginationRowModel(),
    initialState,
    defaultColumn: {
      minSize: 60,
      maxSize: 700,
      cell: ({ cell }) => {
        return /* @__PURE__ */ jsx15(TableCell, { children: cell.getValue() });
      },
      ...defaultColumn
    },
    columns,
    state: {
      columnSizing,
      columnSizingInfo,
      pagination,
      columnFilters,
      ...state
    },
    filterFns: {
      ...tableOptions?.filterFns,
      dateRange: TableFilters.dateRange
    },
    onColumnSizingInfoChange: (updaterOrValue) => {
      setColumnSizingInfo(updaterOrValue);
      if (tableOptions.onColumnSizingInfoChange) {
        tableOptions?.onColumnSizingInfoChange(updaterOrValue);
      }
    },
    onColumnSizingChange: (updaterOrValue) => {
      setColumnSizing((previous) => {
        const newSizing = typeof updaterOrValue === "function" ? updaterOrValue(previous) : updaterOrValue;
        return updateColumnSizes(newSizing);
      });
      if (tableOptions.onColumnSizingChange) {
        tableOptions.onColumnSizingChange(updaterOrValue);
      }
    },
    onPaginationChange: (updaterOrValue) => {
      setPagination(updaterOrValue);
      if (tableOptions.onPaginationChange) {
        tableOptions.onPaginationChange(updaterOrValue);
      }
    },
    onColumnFiltersChange: (updaterOrValue) => {
      setColumnFilters(updaterOrValue);
      table.toggleAllRowsSelected(false);
      if (tableOptions.onColumnFiltersChange) {
        tableOptions.onColumnFiltersChange(updaterOrValue);
      }
    },
    autoResetPageIndex: false,
    columnResizeMode: "onChange",
    ...tableOptions
  });
  const [hasInitializedSizing, setHasInitializedSizing] = useState13(false);
  useEffect14(() => {
    if (!hasInitializedSizing && ref.current) {
      setHasInitializedSizing(true);
      table.setColumnSizing(updateColumnSizes(columnSizing));
    }
  }, [columnSizing, hasInitializedSizing]);
  useResizeCallbackWrapper(useCallback6(() => {
    table.setColumnSizing(updateColumnSizes);
  }, [updateColumnSizes]));
  const pageCount = table.getPageCount();
  useEffect14(() => {
    const totalPages = pageCount;
    if (totalPages === 0) {
      if (pagination.pageIndex !== 0) {
        table.setPagination((prevState) => ({
          ...prevState,
          pageIndex: 0
        }));
      }
    } else if (pagination.pageIndex >= totalPages) {
      table.setPagination((prev) => ({
        ...prev,
        pageIndex: totalPages - 1
      }));
    }
  }, [data, pageCount, pagination.pageSize, pagination.pageIndex]);
  const columnSizeVars = useMemo5(() => {
    const headers = table.getFlatHeaders();
    const colSizes = {};
    for (let i = 0; i < headers.length; i++) {
      const header = headers[i];
      colSizes[`--header-${header.id}-size`] = Math.floor(header.getSize());
      colSizes[`--col-${header.column.id}-size`] = Math.floor(header.column.getSize());
    }
    return colSizes;
  }, [table.getState().columnSizingInfo, table.getState().columnSizing]);
  return /* @__PURE__ */ jsxs7("div", { ref, className: clsx9("flex-col-4", className), children: [
    /* @__PURE__ */ jsx15(
      Scrollbars,
      {
        autoHeight: true,
        autoHeightMax: tableRef.current?.offsetHeight ? tableRef.current?.offsetHeight + 2 : void 0,
        autoHide: true,
        children: /* @__PURE__ */ jsxs7(
          "table",
          {
            ref: tableRef,
            className: clsx9(tableClassName),
            style: {
              ...columnSizeVars,
              width: Math.floor(Math.max(table.getTotalSize() - columns.length, ref.current?.offsetWidth ?? table.getTotalSize()))
            },
            children: [
              table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx15("colgroup", { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx15(
                "col",
                {
                  style: {
                    width: `calc(var(--header-${header?.id}-size) * 1px)`,
                    minWidth: header.column.columnDef.minSize,
                    maxWidth: header.column.columnDef.maxSize
                  }
                },
                header.id
              )) }, headerGroup.id)),
              /* @__PURE__ */ jsx15("thead", { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx15("tr", { className: table.options.meta?.headerRowClassName, children: headerGroup.headers.map((header) => {
                return /* @__PURE__ */ jsxs7(
                  "th",
                  {
                    colSpan: header.colSpan,
                    className: clsx9("relative group", header.column.columnDef.meta?.className),
                    children: [
                      /* @__PURE__ */ jsx15("div", { className: "flex-row-2 w-full", children: header.isPlaceholder ? null : /* @__PURE__ */ jsxs7("div", { className: "flex-row-1 items-center", children: [
                        header.column.getCanSort() && /* @__PURE__ */ jsx15(
                          TableSortButton,
                          {
                            sortDirection: header.column.getIsSorted(),
                            onClick: () => header.column.toggleSorting()
                          }
                        ),
                        header.column.getCanFilter() && header.column.columnDef.meta?.filterType ? /* @__PURE__ */ jsx15(
                          TableFilterButton,
                          {
                            column: header.column,
                            filterType: header.column.columnDef.meta.filterType
                          }
                        ) : null,
                        flexRender(
                          header.column.columnDef.header,
                          header.getContext()
                        )
                      ] }) }),
                      header.column.getCanResize() && /* @__PURE__ */ jsx15(
                        "div",
                        {
                          onMouseDown: header.getResizeHandler(),
                          onTouchStart: header.getResizeHandler(),
                          onDoubleClick: () => {
                            header.column.resetSize();
                          },
                          className: "table-resize-indicator w-2 rounded bg-primary cursor-col-resize select-none touch-none opacity-0 group-hover:opacity-100 transition-opacity",
                          style: {
                            opacity: !columnSizingInfo?.columnSizingStart ? void 0 : columnSizingInfo?.columnSizingStart?.findIndex(([id, _]) => id === header.column.id) !== -1 ? 1 : columnSizingInfo?.columnSizingStart?.length !== 0 ? 0 : void 0
                          }
                        }
                      )
                    ]
                  },
                  header.id
                );
              }) }, headerGroup.id)) }),
              /* @__PURE__ */ jsxs7("tbody", { children: [
                table.getRowModel().rows.map((row) => {
                  return /* @__PURE__ */ jsx15("tr", { onClick: () => onRowClick?.(row, table), className: table.options.meta?.bodyRowClassName, children: row.getVisibleCells().map((cell) => {
                    return /* @__PURE__ */ jsx15("td", { children: flexRender(
                      cell.column.columnDef.cell,
                      cell.getContext()
                    ) }, cell.id);
                  }) }, row.id);
                }),
                range(table.getState().pagination.pageSize - table.getRowModel().rows.length, { allowEmptyRange: true }).map((row, index) => {
                  return /* @__PURE__ */ jsx15("tr", { children: columns.map((column) => {
                    return /* @__PURE__ */ jsx15("td", { children: fillerRow ? fillerRow(column.id, table) : /* @__PURE__ */ jsx15(FillerRowElement, {}) }, column.id);
                  }) }, "filler-row-" + index);
                })
              ] })
            ]
          }
        )
      }
    ),
    /* @__PURE__ */ jsx15("div", { className: "flex-row-2 justify-center", children: /* @__PURE__ */ jsx15(
      Pagination,
      {
        pageIndex: table.getState().pagination.pageIndex,
        pageCount: table.getPageCount(),
        onPageChanged: (page) => table.setPageIndex(page)
      }
    ) })
  ] });
};
var TableUncontrolled = ({ data, ...props }) => {
  const [usedDate] = useOverwritableState(data);
  return /* @__PURE__ */ jsx15(
    Table,
    {
      ...props,
      data: usedDate
    }
  );
};
var TableWithSelection = ({
  columns,
  state,
  fillerRow,
  rowSelection,
  disableClickRowClickSelection = false,
  selectionRowId = "selection",
  onRowClick,
  meta,
  ...props
}) => {
  const columnsWithSelection = useMemo5(() => {
    return [
      {
        id: selectionRowId,
        header: ({ table }) => {
          return /* @__PURE__ */ jsx15(
            Checkbox2,
            {
              checked: table.getIsAllRowsSelected(),
              indeterminate: table.getIsSomeRowsSelected(),
              onChange: (value) => {
                const newValue = !!value;
                table.toggleAllRowsSelected(newValue);
              }
            }
          );
        },
        cell: ({ row }) => {
          return /* @__PURE__ */ jsx15(
            Checkbox2,
            {
              disabled: !row.getCanSelect(),
              checked: row.getIsSelected(),
              onChange: row.getToggleSelectedHandler()
            }
          );
        },
        size: 60,
        minSize: 60,
        maxSize: 60,
        enableResizing: false,
        enableSorting: false
      },
      ...columns
    ];
  }, [columns, selectionRowId]);
  return /* @__PURE__ */ jsx15(
    Table,
    {
      columns: columnsWithSelection,
      fillerRow: (columnId, table) => {
        if (columnId === selectionRowId) {
          return /* @__PURE__ */ jsx15(Checkbox2, { checked: false, disabled: true, className: "max-w-6" });
        }
        return fillerRow ? fillerRow(columnId, table) : /* @__PURE__ */ jsx15(FillerRowElement, {});
      },
      state: {
        rowSelection,
        ...state
      },
      onRowClick: (row, table) => {
        if (!disableClickRowClickSelection) {
          row.toggleSelected();
        }
        onRowClick?.(row, table);
      },
      meta: {
        ...meta,
        bodyRowClassName: clsx9(
          { "cursor-pointer": !disableClickRowClickSelection },
          meta?.bodyRowClassName
        )
      },
      ...props
    }
  );
};
export {
  Table,
  TableUncontrolled,
  TableWithSelection
};
//# sourceMappingURL=Table.js.map