import{r as x,s as d,a5 as S,p as k,w as g,a as _,h,C as z,d as D,a6 as P,H as C,g as T,m as O,o as j,u}from"./index-B6uGkrgD.js";import{t as m}from"./i18n-DvMeCREp-Du7miH0i.js";import{v as F,a as A,b as M,c as H,d as E,e as K}from"./table-selection-DAMWzd6x-DqkgoBSo.js";import{v as L}from"./label-Cw7rCjUo-YeMVw3_3.js";import{C as y}from"./keyboard-DNd73LVa-BwofTq6r.js";const q=(n,t,e={})=>{O(n,"_allowMultiSort",t,Object.assign({defaultValue:!1},e))},v=["top","bottom","both"],B=(n,t)=>{g(n,"_paginationPosition",e=>typeof e=="string"&&v.includes(e),new Set([`PaginationPositionPropType {${v.join(", ")}`]),t,{defaultValue:"bottom"})},R=`@charset "UTF-8";
/*
* This file defines the layer order for all CSS layers used in KoliBri.
* The order is important as it determines the cascade priority.
*
* Layer order (lowest to highest priority):
* 1. kol-a11y - Accessibility defaults and requirements
* 2. kol-global - Global component styles and resets
* 3. kol-component - Component-specific styles
* 4. kol-theme-global - Theme-specific global styles
* 5. kol-theme-component - Theme-specific component styles
*/
@layer kol-a11y, kol-global, kol-component, kol-theme-global, kol-theme-component;
/* forward the rem function */
/*
 * This file contains all rules for accessibility.
 */
@layer kol-a11y {
  :host {
    /*
                   * Minimum size of interactive elements.
                   */
    --a11y-min-size: calc(44 * 1rem / var(--kolibri-root-font-size, 16));
    /*
     * No element should be used without verifying the contrast ratio of its background and font colors.
     * By initially setting the background color to white and the font color to black,
     * the contrast ratio is ensured and explicit adjustment is forced.
     */
    color: black;
    background-color: white;
    /*
     * Verdana is an accessible font that can be used without requiring additional loading time.
     */
    font-family: Verdana;
    /*
     * Letter spacing is required for all texts.
     */
    letter-spacing: inherit;
    /*
     * Word spacing is required for all texts.
     */
    word-spacing: inherit;
    /*
     * Text should be aligned left by default to provide a predictable starting point.
     */
    text-align: left;
  }
  * {
    /*
     * This rule enables the word dividing for all texts. That is important for high zoom levels.
     */
    hyphens: auto;
    /*
     * This rule enables the word dividing for all texts. That is important for high zoom levels.
     */
    word-break: break-word;
  }
  /*
   * All interactive elements should have a minimum size of to-rem(44).
   */
  /* input:not([type='checkbox'], [type='radio'], [type='range']), */
  /* option, */
  /* select, */
  /* textarea, */
  button,
  .kol-input .input {
    min-width: var(--a11y-min-size);
    min-height: var(--a11y-min-size);
  }
  /*
   * Some interactive elements should not inherit the font-family and font-size.
   */
  a,
  button,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  input,
  option,
  select,
  textarea {
    /*
     * All elements should inherit the text color from his parent element.
     */
    color: inherit;
    /*
     * All elements should inherit the font family from his parent element.
     */
    font-family: inherit;
    /*
     * All elements should inherit the font size from his parent element.
     */
    font-size: inherit;
    /*
     * Letter spacing is required for all texts.
     */
    letter-spacing: inherit;
    /*
     * Word spacing is required for all texts.
     */
    word-spacing: inherit;
  }
  /**
  * Sometimes we need the semantic element for accessibility reasons,
  * but we don't want to show it.
  *
  * - https://www.a11yproject.com/posts/how-to-hide-content/
  */
  .visually-hidden {
    position: fixed;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;
    clip-path: inset(50%);
  }
}
@layer kol-global {
  /*
   * Dieses CSS stellt sicher, dass der Standard-Style
   * von A und Button resettet werden.
   */
  :is(a, button) {
    background-color: transparent;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    /* 100% needed for custom width from outside */
  }
  /*
   * Ensure elements with hidden attribute to be actually not visible
   * @see https://meowni.ca/hidden.is.a.lie.html
   */
  [hidden] {
    display: none !important;
  }
  .badge-text-hint {
    color: black;
    background-color: lightgray;
  }
}
@layer kol-global {
  :host {
    /*
     * The max-width is needed to prevent the table from overflowing the
     * parent node, if the table is wider than the parent node.
     */
    max-width: 100%;
    font-size: calc(16 * 1rem / var(--kolibri-root-font-size, 16));
  }
  * {
    /*
     * We prefer to box-sizing: border-box for all elements.
     */
    box-sizing: border-box;
  }
  .kol-span {
    /* KolSpan is a layout component with icons in all directions and a label text in the middle. */
    display: flex;
    flex-flow: column;
    align-items: center;
    justify-content: center;
    /* The sub span in KolSpan is the horizontal span with icon left and right and the label text in the middle. */
  }
  .kol-span__container {
    display: flex;
    align-items: center;
  }
  a,
  button {
    cursor: pointer;
  }
  .kol-span .kol-span__label--hide-label .kol-span__label {
    display: none;
  }
  /* Reset browser agent style. */
  button:disabled {
    color: unset;
  }
  .disabled label,
  .disabled:focus-within label,
  [aria-disabled=true],
  [aria-disabled=true]:focus,
  [disabled],
  [disabled]:focus {
    opacity: 0.5;
    outline: none;
    cursor: not-allowed;
  }
  [aria-disabled=true]:focus .kol-span,
  [disabled]:focus .kol-span {
    outline: none !important;
  }
  .hastooltip {
    z-index: 900 !important;
  }
}
@layer kol-component {
  :host {
    display: block;
  }
}
@font-face {
  font-family: "kolicons";
  src: url("kolicons.eot?t=1774620902394"); /* IE9*/
  src: url("kolicons.eot?t=1774620902394#iefix") format("embedded-opentype"), url("kolicons.woff2?t=1774620902394") format("woff2"), url("kolicons.woff?t=1774620902394") format("woff"), url("kolicons.ttf?t=1774620902394") format("truetype"), url("kolicons.svg?t=1774620902394#kolicons") format("svg"); /* iOS 4.1- */
}
[class^=kolicon-], [class*=" kolicon-"] {
  font-family: "kolicons";
  font-style: normal;
  font-weight: 400;
  line-height: 1em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.kolicon-alert-error::before {
  content: "\\ea01";
}

.kolicon-alert-info::before {
  content: "\\ea02";
}

.kolicon-alert-success::before {
  content: "\\ea03";
}

.kolicon-alert-warning::before {
  content: "\\ea04";
}

.kolicon-check::before {
  content: "\\ea05";
}

.kolicon-chevron-double-left::before {
  content: "\\ea06";
}

.kolicon-chevron-double-right::before {
  content: "\\ea07";
}

.kolicon-chevron-down::before {
  content: "\\ea08";
}

.kolicon-chevron-left::before {
  content: "\\ea09";
}

.kolicon-chevron-right::before {
  content: "\\ea0a";
}

.kolicon-chevron-up::before {
  content: "\\ea0b";
}

.kolicon-cogwheel::before {
  content: "\\ea0c";
}

.kolicon-cross::before {
  content: "\\ea0d";
}

.kolicon-eye-closed::before {
  content: "\\ea0e";
}

.kolicon-eye::before {
  content: "\\ea0f";
}

.kolicon-house::before {
  content: "\\ea10";
}

.kolicon-kolibri::before {
  content: "\\ea11";
}

.kolicon-link-external::before {
  content: "\\ea12";
}

.kolicon-link::before {
  content: "\\ea13";
}

.kolicon-minus::before {
  content: "\\ea14";
}

.kolicon-plus::before {
  content: "\\ea15";
}

.kolicon-settings::before {
  content: "\\ea16";
}

.kolicon-sort-asc::before {
  content: "\\ea17";
}

.kolicon-sort-desc::before {
  content: "\\ea18";
}

.kolicon-sort-neutral::before {
  content: "\\ea19";
}

.kolicon-up::before {
  content: "\\ea1a";
}

.kolicon-version::before {
  content: "\\ea1b";
}

@layer kol-component {
  .kol-icon {
    color: inherit;
    display: inline-block;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
  }
  .kol-tooltip {
    display: contents;
  }
  .kol-tooltip__floating {
    opacity: 0;
    display: none;
    position: fixed;
    /* Avoid layout interference - see https://floating-ui.com/docs/computePosition */
    top: 0;
    left: 0;
    /* Can be used to specify the tooltip-width from the outside. Unset by default.  */
    width: var(--kol-tooltip-width, max-content);
    min-width: calc(8 * 1rem / var(--kolibri-root-font-size, 16));
    max-width: 90vw;
    max-height: 90vh;
    animation-direction: normal;
    /* Can be used to specify the animation duration from the outside. 250ms by default. */
    animation-duration: var(--kolibri-tooltip-animation-duration, 250ms);
    animation-fill-mode: forwards;
    animation-iteration-count: 1;
    animation-timing-function: ease-in;
  }
  .kol-tooltip__floating.hide {
    animation-name: hideTooltip;
  }
  .kol-tooltip__floating.show {
    animation-name: showTooltip;
  }
  .kol-tooltip__arrow {
    transform: rotate(45deg);
    color: #000;
    background-color: #fff;
    position: absolute;
    z-index: 999;
    width: calc(10 * 1rem / var(--kolibri-root-font-size, 16));
    height: calc(10 * 1rem / var(--kolibri-root-font-size, 16));
  }
  .kol-tooltip__content {
    color: #000;
    background-color: #fff;
    position: relative;
    z-index: 1000;
  }
  @keyframes hideTooltip {
    0% {
      opacity: 1;
    }
    100% {
      opacity: 0;
      display: none;
    }
  }
  @keyframes showTooltip {
    0% {
      opacity: 0;
    }
    100% {
      opacity: 1;
    }
  }
}
@layer kol-component {
  .kol-alert .kol-icon {
    color: inherit;
    display: inline-block;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
  }
  .kol-alert :host {
    display: inline-block;
  }
  .kol-alert .kol-button {
    display: flex;
    min-height: var(--a11y-min-size);
    font-style: calc(16 * 1rem / var(--kolibri-root-font-size, 16));
    text-decoration-line: none;
  }
  .kol-alert .kol-button::before {
    /* Render zero-width character as first element to set the baseline correctly. */
    content: "​";
  }
  .kol-alert .kol-button__text {
    flex: 1 0 100%;
  }
  .kol-alert {
    display: grid;
  }
  .kol-alert__container {
    display: flex;
    place-items: center;
  }
  .kol-alert__container-content {
    flex-grow: 1;
  }
  .kol-alert__closer {
    /* Visible with forced colors */
    outline: transparent solid calc(1 * 1rem / var(--kolibri-root-font-size, 16));
  }
  .kol-icon {
    color: inherit;
    display: inline-block;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
  }
  :host {
    display: inline-block;
  }
  .kol-button {
    display: flex;
    min-height: var(--a11y-min-size);
    font-style: calc(16 * 1rem / var(--kolibri-root-font-size, 16));
    text-decoration-line: none;
  }
  .kol-button::before {
    /* Render zero-width character as first element to set the baseline correctly. */
    content: "​";
  }
  .kol-button__text {
    flex: 1 0 100%;
  }
  .kol-popover-button__popover {
    margin: 0;
    padding: 0;
    border: 0;
  }
  .kol-popover-button--inline .kol-popover-button__button {
    display: inline;
  }
  .kol-popover {
    opacity: 0;
    transition: 0.2s ease-out opacity;
  }
  .kol-popover-button--open + .kol-popover {
    opacity: 1;
  }
  .kol-table-settings {
    background: #fff;
    position: absolute;
    top: 0;
    right: 0;
    z-index: 1;
  }
  .kol-table-settings .kol-popover-button__popover {
    background: #fff;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-radius: calc(8 * 1rem / var(--kolibri-root-font-size, 16));
    border: 1px solid #d1d5db;
  }
  .kol-table-settings__columns-container {
    max-height: calc(200 * 1rem / var(--kolibri-root-font-size, 16));
    overflow: auto;
  }
  .kol-table-settings__columns {
    display: grid;
    align-items: center;
    grid-auto-rows: min-content;
    grid-template-columns: min-content minmax(max-content, 1fr) calc(140 * 1rem / var(--kolibri-root-font-size, 16)) auto auto;
  }
  .kol-table-settings__column {
    display: contents;
  }
  .kol-icon {
    color: inherit;
    display: inline-block;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
  }
  .kol-table {
    --kol-table-selection-col-width: var(--a11y-min-size);
    display: block;
    position: relative;
    max-width: 100%;
  }
  .kol-table:has(.kol-table__focus-element:focus) .kol-table__scroll-container {
    /* @see https://remysharp.com/til/css/focus-ring-default-styles */
    outline: 5px auto Highlight;
    outline: 5px auto -webkit-focus-ring-color;
    outline-offset: 2px;
  }
  .kol-table__scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
  }
  .kol-table__table {
    table-layout: fixed;
  }
  .kol-table__caption {
    min-height: var(--a11y-min-size);
    text-align: start;
  }
  .kol-table__sort-button .kol-button {
    color: inherit;
  }
  .kol-table__sort {
    display: inline-flex;
    align-items: center;
  }
  .kol-table__sort-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .kol-table__body {
    text-align: left;
  }
  .kol-table__body .kol-button__text {
    justify-items: start;
  }
  .kol-table__cell--align-left {
    text-align: left;
  }
  .kol-table__cell--align-left .kol-button__text {
    align-items: start;
  }
  .kol-table__cell--align-center {
    text-align: center;
  }
  .kol-table__cell--align-center .kol-button__text {
    align-items: center;
  }
  .kol-table__cell--align-right {
    text-align: right;
  }
  .kol-table__cell--align-right .kol-button__text {
    align-items: end;
  }
  .kol-table__cell--selection {
    background-color: white;
    position: sticky !important;
    left: 0;
    z-index: 2;
    width: var(--kol-table-selection-col-width, auto);
    min-width: var(--a11y-min-size);
    min-height: var(--a11y-min-size);
    white-space: nowrap;
  }
  .kol-table__cell--actions {
    white-space: nowrap;
  }
  .kol-table__cell--actions .kol-icon {
    color: inherit;
    display: inline-block;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
  }
  .kol-table__cell--actions :host {
    display: inline-block;
  }
  .kol-table__cell--actions .kol-button {
    display: flex;
    min-height: var(--a11y-min-size);
    font-style: calc(16 * 1rem / var(--kolibri-root-font-size, 16));
    text-decoration-line: none;
  }
  .kol-table__cell--actions .kol-button::before {
    /* Render zero-width character as first element to set the baseline correctly. */
    content: "​";
  }
  .kol-table__cell--actions .kol-button__text {
    flex: 1 0 100%;
  }
  .kol-table__cell--actions .kol-icon {
    color: inherit;
    display: inline-block;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
  }
  .kol-table__cell--actions :host {
    display: inline-block;
  }
  .kol-table__cell--actions .kol-link {
    display: inline-flex;
    max-width: fit-content;
    align-items: baseline;
    place-items: center;
    text-align: left;
    text-decoration-line: none;
  }
  .kol-table__cell--actions .kol-link--standalone {
    min-width: var(--a11y-min-size);
    min-height: var(--a11y-min-size);
    align-items: stretch;
  }
  .kol-table__cell--actions .kol-link--standalone .kol-link__text {
    display: inline-flex;
    flex: 1 1 100%;
    place-items: center;
  }
  .kol-table__cell--actions .kol-link .kol-span__label {
    text-decoration-line: underline;
  }
  .kol-table__cell--actions .kol-link:focus:not([aria-disabled], [disabled]) .kol-span__label, .kol-table__cell--actions .kol-link:hover:not([aria-disabled], [disabled]) .kol-span__label {
    text-decoration-thickness: 0.2em;
  }
  .kol-table__cell--actions .kol-link__icon {
    display: inline-flex;
  }
  .kol-table__cell--sticky-left, .kol-table__cell--sticky-right {
    background-color: white;
    position: sticky !important;
    z-index: 1;
  }
  .kol-table__cell--sticky-left:nth-last-child(1 of .kol-table__cell--sticky-left) {
    border-right: 2px solid black;
  }
  .kol-table__cell--sticky-right:nth-child(1 of .kol-table__cell--sticky-left) {
    border-left: 2px solid black;
  }
  .kol-table__cell-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
  }
  .kol-table__spacer {
    display: none;
  }
  .kol-table__selection {
    position: relative;
  }
  .kol-table__selection-label {
    display: flex;
    position: relative;
    min-width: var(--a11y-min-size);
    min-height: var(--a11y-min-size);
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .kol-table__selection--disabled {
    cursor: not-allowed;
  }
  .kol-table__selection-icon {
    display: block;
    position: absolute;
    inset: auto;
    z-index: 1;
  }
  .kol-table__selection-input {
    border-style: solid;
    margin: 0;
    appearance: none;
    cursor: pointer;
  }
  .kol-table__selection-input:disabled {
    cursor: not-allowed;
  }
  .kol-table__selection-input:before {
    content: "";
  }
  .kol-table__selection-input--checkbox {
    background-color: rgb(255, 255, 255);
    display: flex;
    position: relative;
    min-width: calc(var(--a11y-min-size) / 2);
    min-height: calc(var(--a11y-min-size) / 2);
    border-width: 2px;
    align-items: center;
    justify-content: center;
    line-height: 1.5;
  }
  .kol-table__selection-input--radio {
    border-radius: 100%;
    display: flex;
    width: 1.5em;
    min-width: 1.5em;
    height: 1.5em;
    min-height: 1.5em;
    padding: 0;
    border-width: 2px;
  }
  .kol-table__selection-input--radio:before {
    border-radius: 100%;
    width: 0.75em;
    height: 0.75em;
    margin: auto;
  }
  .kol-table__selection-input--radio:checked:before {
    background-color: #000;
  }
  @media (forced-colors: active) {
    .kol-table__selection-input--radio:checked:before {
      /* Give it a visible background in forced colors mode */
      background-color: selectedItem !important;
    }
  }
  .kol-alert .kol-icon {
    color: inherit;
    display: inline-block;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
  }
  .kol-alert :host {
    display: inline-block;
  }
  .kol-alert .kol-button {
    display: flex;
    min-height: var(--a11y-min-size);
    font-style: calc(16 * 1rem / var(--kolibri-root-font-size, 16));
    text-decoration-line: none;
  }
  .kol-alert .kol-button::before {
    /* Render zero-width character as first element to set the baseline correctly. */
    content: "​";
  }
  .kol-alert .kol-button__text {
    flex: 1 0 100%;
  }
  .kol-alert {
    display: grid;
  }
  .kol-alert__container {
    display: flex;
    place-items: center;
  }
  .kol-alert__container-content {
    flex-grow: 1;
  }
  .kol-alert__closer {
    /* Visible with forced colors */
    outline: transparent solid calc(1 * 1rem / var(--kolibri-root-font-size, 16));
  }
  .kol-form-field {
    display: grid;
  }
  .kol-form-field:not(.kol-form-field--disabled) .kol-form-field__label {
    cursor: pointer;
  }
  .kol-form-field__label-text {
    flex-flow: row;
    align-items: flex-start;
    justify-content: flex-start;
  }
  .kol-form-field--disabled .kol-form-field__label {
    opacity: 0.5;
  }
  .kol-form-field--required .kol-form-field__label-text:not(:has(> [name]))::after,
  .kol-form-field--required .kol-form-field__tooltip .span-label::after {
    content: "*"/"";
  }
  .kol-form-field--disabled .kol-form-field__hint {
    opacity: 0.5;
  }
  .kol-input-container {
    background-color: transparent;
    display: grid;
    width: 100%;
    min-width: var(--a11y-min-size);
    min-height: var(--a11y-min-size);
    align-items: center;
    grid-template-columns: 1fr;
  }
  .kol-input-container:has(> .kol-input-container__adornment--start) {
    grid-template-columns: auto 1fr auto;
  }
  .kol-input-container__container {
    position: relative;
  }
  .kol-input-container__adornment {
    display: flex;
    align-items: center;
  }
  .kol-input-container__adornment .kol-icon {
    display: grid;
    min-height: var(--a11y-min-size);
    place-items: center;
  }
  .kol-select {
    background-color: transparent;
    width: 100%;
  }
  .kol-select:not(:disabled) {
    cursor: pointer;
  }
  .kol-select:not([multiple], [size]) {
    height: 2.75em;
  }
  .kol-select:focus {
    outline: none;
  }
  .kol-select__option:checked::before {
    content: "✓ ";
  }
  .kol-select {
    /* needed hack for vertical alignment */
  }
  .kol-select[multiple] option {
    padding: calc((var(--a11y-min-size) - 16 * 1rem / var(--kolibri-root-font-size, 16)) / 2) 0.5em;
  }
  .kol-icon {
    color: inherit;
    display: inline-block;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
  }
  .kol-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    container: paging/inline-size;
  }
  .kol-pagination__navigation-list {
    display: inline-flex;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
    align-items: center;
    list-style: none;
  }
  .kol-pagination__separator:before {
    content: "•••";
  }
  .kol-pagination__page-size-select .kol-form-field-select {
    align-items: center;
    grid-template-columns: 1fr max-content;
  }
  @container paging (width < 600px) {
    .kol-pagination:has(.kol-pagination__button--first) li:has(.kol-pagination__button--numbers),
    .kol-pagination:has(.kol-pagination__button--first) li:has(.kol-pagination__separator) {
      display: none;
    }
  }
}`,V=[10,20,50,100],w=n=>n===!0||n===""||typeof n=="object"&&n!==null,W=class{constructor(n){x(this,n),this.catchRef=t=>{this.tableWcRef=t},this.sortData=[],this.showPagination=!1,this.pageStartSlice=0,this.pageEndSlice=10,this.disableSort=!1,this._paginationPosition="bottom",this.state={_allowMultiSort:!1,_fixedCols:[0,0],_data:[],_dataFoot:[],_headers:{horizontal:[],vertical:[]},_label:"",_pagination:{_page:1,_pageSize:10,_max:0},_sortedData:[],_paginationPosition:"bottom",_hasSettingsMenu:!1},this.handlePagination={onClick:(t,e)=>{var i;typeof((i=this.state._pagination._on)===null||i===void 0?void 0:i.onClick)=="function"&&this.state._pagination._on.onClick(t,e),d(this,"_pagination",Object.assign(Object.assign({},this.state._pagination),{_page:e}))},onChangePage:(t,e)=>{var i;typeof((i=this.state._pagination._on)===null||i===void 0?void 0:i.onChangePage)=="function"&&this.state._pagination._on.onChangePage(t,e),d(this,"_pagination",Object.assign(Object.assign({},this.state._pagination),{_page:e}))},onChangePageSize:(t,e)=>{var i;typeof((i=this.state._pagination._on)===null||i===void 0?void 0:i.onChangePageSize)=="function"&&this.state._pagination._on.onChangePageSize(t,e),d(this,"_pagination",Object.assign(Object.assign({},this.state._pagination),{_pageSize:e})),d(this,"_pageSize",e)}},this.onSelectionChange=t=>{t.stopPropagation()},this.updateSortedData=()=>{if(this.disableSort){d(this,"_sortedData",this.state._data);return}const t=[...this.state._data];this.sortData.length>0&&t.sort((e,i)=>{for(let o=0;o<this.sortData.length;o++){const s=this.sortData[o],r=s.compareFn(e,i,s.direction);if(r!==0)return s.direction==="ASC"?r:-r}return 0}),d(this,"_sortedData",t)}}validateAllowMultiSort(n){q(this,n,{defaultValue:!1})}validateData(n){F(this,n,{afterPatch:()=>{setTimeout(this.updateSortedData)}})}validateDataFoot(n){A(this,n,{afterPatch:()=>{setTimeout(this.updateSortedData)}})}validateFixedCols(n){M(this,n)}validatePaginationPosition(n){B(this,n)}validateHasSettingsMenu(n){H(this,n)}changeCellSort(n){var t;if(n.type===void 0||n.type==="default"){if(typeof n.compareFn!="function")return;!this.state._allowMultiSort&&n.key!==((t=this.sortData[0])===null||t===void 0?void 0:t.key)&&(this.sortData=[]);const e=this.sortData.findIndex(i=>i.key===n.key);if(e>=0){const i=this.sortData[e];switch(i.direction){case"ASC":i.direction="DESC";break;case"DESC":this.sortData.splice(e,1);break;default:i.direction="ASC";break}}else n.key&&this.sortData.push({label:n.label,key:n.key,compareFn:n.compareFn,direction:"ASC"});this.updateSortedData()}}validateHeaders(n){S(n,()=>{j(n,()=>{try{n=k(n)}catch{}g(this,"_headers",t=>typeof t=="object"&&t!==null,new Set(["KoliBriTableHeaders"]),n,{hooks:{beforePatch:t=>{var e,i,o,s;const r=f=>{let p=!1;this.sortData=[],f.forEach(a=>{if(a.type!==void 0&&a.type!=="default")return;if(typeof a.compareFn=="function"&&!a.key){u("[KolTableStateful] A sortable column requires the 'key' property.");return}const l=a.key;if(!l)return;const b=a.sortDirection;(b==="ASC"||b==="DESC")&&typeof a.compareFn=="function"&&((this.state._allowMultiSort||this.sortData.length===0)&&this.sortData.push({label:a.label,key:l,compareFn:a.compareFn,direction:b}),p=!0)}),p&&setTimeout(()=>this.updateSortedData())},c=t;(e=c.horizontal)===null||e===void 0||e.forEach(r),(i=c.vertical)===null||i===void 0||i.forEach(r),c.horizontal&&c.vertical&&((o=c.horizontal)===null||o===void 0?void 0:o.length)>0&&((s=c.vertical)===null||s===void 0?void 0:s.length)>0&&(this.disableSort=!0,u("Table: You can not sort the table data, if horizontal and vertical headers are defined at the same time. (https://github.com/public-ui/kolibri/issues/2372)"))}}})})})}validateLabel(n){L(this,n,{required:!0})}validateSelection(n){E(this,n)}validateOn(n){K(this,n)}validatePagination(n){try{n=k(n)}catch{}this.showPagination=w(n),g(this,"_pagination",w,new Set(["boolean","KoliBriTablePagination"]),n,{defaultValue:{_page:1,_pageSize:10,_max:0}})}componentDidLoad(){var n;(n=this.tableWcRef)===null||n===void 0||n.addEventListener(_.selectionChange,this.onSelectionChange)}disconnectedCallback(){var n;(n=this.tableWcRef)===null||n===void 0||n.removeEventListener(_.selectionChange,this.onSelectionChange)}componentWillLoad(){this.validateAllowMultiSort(this._allowMultiSort),this.validateData(this._data),this.validateDataFoot(this._dataFoot),this.validateFixedCols(this._fixedCols),this.validateHeaders(this._headers),this.validateLabel(this._label),this.validateOn(this._on),this.validatePagination(this._pagination),this.validatePaginationPosition(this._paginationPosition),this.validateSelection(this._selection),this.validateHasSettingsMenu(this._hasSettingsMenu)}selectDisplayedData(n,t,e){return typeof t=="number"&&t>0&&typeof e=="number"&&e>0?(this.pageStartSlice=t*(e-1),this.pageEndSlice=t*e>n.length?n.length:t*e,n.slice(this.pageStartSlice,this.pageEndSlice)):(this.pageStartSlice=0,this.pageEndSlice=n.length,n)}renderPagination(n){const t=m("kol-table-pagination-label",{placeholders:{label:`${this.state._label} (${m(`kol-pagination-position-${n}`)})`}});return h("div",{class:`kol-table-stateful__pagination kol-table-stateful__pagination--${this.state._paginationPosition}`},h("div",{class:"kol-table-stateful__pagination-wrapper"},h(z,{_boundaryCount:this.state._pagination._boundaryCount,_customClass:this.state._pagination._customClass,_hasButtons:this.state._pagination._hasButtons,_on:this.handlePagination,_page:this.state._pagination._page,_pageSize:this.state._pagination._pageSize,_pageSizeOptions:this.state._pagination._pageSizeOptions||V,_siblingCount:this.state._pagination._siblingCount,_tooltipAlign:"bottom",_max:this.state._pagination._max||this.state._pagination._max||this.state._data.length,_label:t})))}getHeaderCellSortState(n){if(!(n.type!==void 0&&n.type!=="default")&&!this.disableSort&&typeof n.compareFn=="function"){if(n.key){const t=this.sortData.find(e=>e.key===n.key);if(t?.direction)return t.direction}return"NOS"}}getHeaderCellSortOrder(n){if(!(n.type!==void 0&&n.type!=="default")&&!this.disableSort&&this.state._allowMultiSort&&typeof n.compareFn=="function"&&n.key){const t=this.sortData.findIndex(e=>e.key===n.key);if(t>=0)return t+1}}handleSort({key:n}){const t=[...(this.state._headers.horizontal||[]).flat(),...(this.state._headers.vertical||[]).flat()].find(e=>e.key===n);t&&this.changeCellSort(t)}getSelectedData(n){var t;const e=this.state._selection;if(e){const i=(t=e.keyPropertyName)!==null&&t!==void 0?t:"id",o=new Set(n.map(String)),s=this.state._sortedData.filter(r=>o.has(String(r[i])));if(i)return s}return null}handleSelectionChange(n,t){var e;const i=this.state._selection;i&&(this.state=Object.assign(Object.assign({},this.state),{_selection:Object.assign(Object.assign({},i),{selectedKeys:t})}));const o=this.getSelectedData(t);typeof((e=this.state._on)===null||e===void 0?void 0:e[y.onSelectionChange])=="function"&&this.state._on[y.onSelectionChange](n,o),this.host&&D(this.host,_.selectionChange,o)}async getSelection(){var n;const t=((n=this.state._selection)===null||n===void 0?void 0:n.selectedKeys)||[];return this.getSelectedData(t)}render(){var n,t,e,i,o,s;const r=this.selectDisplayedData(this.state._sortedData,this.showPagination?(t=(n=this.state._pagination)===null||n===void 0?void 0:n._pageSize)!==null&&t!==void 0?t:10:this.state._sortedData.length,this.state._pagination._page||1),c=this._paginationPosition==="top"||this._paginationPosition==="both"?this.renderPagination("top"):null,f=this._paginationPosition==="bottom"||this._paginationPosition==="both"?this.renderPagination("bottom"):null,p={horizontal:(i=(e=this.state._headers.horizontal)===null||e===void 0?void 0:e.map(a=>a.map(l=>Object.assign(Object.assign({},l),{sortDirection:this.getHeaderCellSortState(l),sortOrder:this.getHeaderCellSortOrder(l)}))))!==null&&i!==void 0?i:[],vertical:(s=(o=this.state._headers.vertical)===null||o===void 0?void 0:o.map(a=>a.map(l=>Object.assign(Object.assign({},l),{sortDirection:this.getHeaderCellSortState(l),sortOrder:this.getHeaderCellSortOrder(l)}))))!==null&&s!==void 0?s:[]};return h(C,{key:"6888614e6bc101101fc1e96c914982f49b1e8644",class:"kol-table-stateful"},this.pageEndSlice>0&&this.showPagination&&c,h(P,{key:"bdfd394adac382c7c00e0c3f6732e88da7e15484",ref:this.catchRef,_data:r,_fixedCols:this._fixedCols,_headerCells:p,_label:this.state._label,_dataFoot:this.state._dataFoot,_on:{onSort:(a,l)=>{this.handleSort(l)},onSelectionChange:(a,l)=>{this.handleSelectionChange(a,l)}},_selection:this.state._selection,_hasSettingsMenu:this.state._hasSettingsMenu}),this.pageEndSlice>0&&this.showPagination&&f)}get host(){return T(this)}static get watchers(){return{_allowMultiSort:["validateAllowMultiSort"],_data:["validateData"],_dataFoot:["validateDataFoot"],_fixedCols:["validateFixedCols"],_paginationPosition:["validatePaginationPosition"],_hasSettingsMenu:["validateHasSettingsMenu"],_headers:["validateHeaders"],_label:["validateLabel"],_selection:["validateSelection"],_on:["validateOn"],_pagination:["validatePagination"]}}};W.style={default:R};export{W as kol_table_stateful};
//# sourceMappingURL=kol-table-stateful.entry-Du5EZ5fY.js.map
