import { bP as Ve, bQ as ke, aE as Fe, aF as xe, d as F, bR as mt, H as Be, bS as ft, l as Oe, p as Ae, ah as fe, g as Q, bT as he, bU as Ce, n as re, k as Re, o as Ie, a5 as De, at as Pe, m as vt, A as pt, i as Y, bV as gt, B as bt, D as yt, bW as ht, aX as Ct, bX as _t, bY as Ue, h as K, j as At, ai as Le, aj as Ne, ak as ze, al as Me, ae as ve, aZ as qe, a8 as He, a9 as Je, aa as Ke, ab as We, am as Qe, an as Ye, ac as Ge, ad as Xe, bZ as Ze, b_ as et, b$ as tt, c0 as wt, ar as at, c1 as _e, ao as kt, ap as Ft, aP as xt, F as Pt, a6 as Tt, b1 as St, aq as Bt, a1 as It, c2 as Dt, q as $t, x as jt, aG as Et } from "./AFormRemoteAutocomplete.vue_vue_type_script_setup_true_lang-Cc4fwgQq.mjs";
import { aD as so, c3 as lo, c4 as no, az as ro, aA as io, aC as uo, aB as co, aH as mo, ba as fo, ax as vo, ay as po, c9 as go, ca as bo, c7 as yo, c8 as ho, ag as Co, af as _o, c5 as Ao, c6 as wo, cb as ko } from "./AFormRemoteAutocomplete.vue_vue_type_script_setup_true_lang-Cc4fwgQq.mjs";
import { defineComponent as Z, inject as H, computed as S, nextTick as me, ref as O, watch as G, resolveComponent as pe, createElementBlock as V, openBlock as y, Fragment as X, createBlock as B, createCommentVNode as q, withModifiers as R, unref as f, withCtx as u, createVNode as m, mergeProps as ot, renderSlot as E, createTextVNode as U, toDisplayString as P, normalizeClass as be, renderList as oe, createElementVNode as I, mergeModels as ge, useModel as we, provide as $e, resolveDynamicComponent as Vt, withDirectives as st, vShow as lt, onMounted as Ot, toRaw as je } from "vue";
import { useI18n as ae } from "vue-i18n";
import { VCard as nt, VCardText as Rt, VCardActions as Ut } from "vuetify/components/VCard";
import { VDialog as rt } from "vuetify/components/VDialog";
import { VSpacer as it, VRow as ie, VCol as te } from "vuetify/components/VGrid";
import { VListItem as ut, VList as Lt, VListItemTitle as Nt } from "vuetify/components/VList";
import { VSelect as zt } from "vuetify/components/VSelect";
import { VTextarea as Mt } from "vuetify/components/VTextarea";
import { VBtn as W } from "vuetify/components/VBtn";
import { VIcon as Te } from "vuetify/components/VIcon";
import { VTooltip as ct } from "vuetify/components/VTooltip";
import { VChip as Ee } from "vuetify/components/VChip";
import dt from "axios";
import { VForm as qt } from "vuetify/components/VForm";
import { VMenu as Ht } from "vuetify/components/VMenu";
import { useThrottleFn as ue, useDebounceFn as Jt } from "@vueuse/core";
import { VBtnToggle as Kt } from "vuetify/components/VBtnToggle";
import { VToolbar as Wt } from "vuetify/components/VToolbar";
import { Intersect as Qt } from "vuetify/directives";
const Yt = /* @__PURE__ */ Z({
  __name: "AFilterTimeInterval",
  props: {
    nameFrom: {},
    nameUntil: {},
    allowed: { default: void 0 },
    placeholder: { default: void 0 },
    dataCy: { default: "filter-time-interval" }
  },
  emits: ["change"],
  setup(a, { emit: p }) {
    const l = a, t = p, g = H(Ve), i = H(ke), n = H(Fe), o = H(xe);
    if (F(g) || F(i) || F(n) || // eslint-disable-next-line vue/no-setup-props-reactivity-loss
    F(n.fields[l.nameFrom]) || // eslint-disable-next-line vue/no-setup-props-reactivity-loss
    F(n.fields[l.nameUntil]) || F(o) || // eslint-disable-next-line vue/no-setup-props-reactivity-loss
    F(o[l.nameFrom]) || // eslint-disable-next-line vue/no-setup-props-reactivity-loss
    F(o[l.nameUntil]))
      throw new Error("Incorrect provide/inject config.");
    const c = S({
      get() {
        return o[l.nameFrom];
      },
      set(_) {
        o[l.nameFrom] = _, z(_), n.touched = !0, me(() => {
          t("change");
        });
      }
    }), { timeIntervalOptions: d, getTimeIntervalOption: b } = mt(l.allowed), v = O(null), C = O(!1), r = O({
      from: null,
      until: Be()
    }), e = O(!1), { v$: w } = ft(r), h = S(() => n.fields[l.nameFrom]), { t: s } = ae(), D = S(() => h.value.titleT ? s(h.value.titleT) : void 0), { clearOne: L } = Pe(), { showValidationError: k } = Oe(), A = () => {
      e.value = !1, v.value = null, M();
    }, x = () => {
      if (w.value.$touch(), w.value.$invalid) {
        k();
        return;
      }
      e.value = !0, C.value = !1, o[l.nameUntil] = r.value.until, c.value = r.value.from;
    }, N = () => {
      C.value = !1, v.value = null;
    }, M = () => {
      L(l.nameFrom, o, n), L(l.nameUntil, o, n), i.value.delete(l.nameFrom);
    }, z = (_) => {
      if (Ae(_) || fe(_)) return;
      if (Q(_) || F(_)) {
        i.value.delete(l.nameFrom);
        return;
      }
      const T = b(_);
      if (!T && he(_)) {
        const j = b(Ce.Custom);
        i.value.set(l.nameFrom, [
          {
            title: j.title + ": " + re(r.value.from) + " - " + re(r.value.until),
            value: _
          }
        ]);
        return;
      }
      T && i.value.set(l.nameFrom, [{ title: T.title, value: _ }]);
    }, J = (_ = !1) => {
      w.value.$reset(), _ && (r.value.from = null, r.value.until = Be()), C.value = !0;
    };
    G(
      c,
      (_) => {
        if (Ae(_) || fe(_)) return;
        if (e.value = !1, F(_) || Q(_)) {
          v.value = null;
          return;
        }
        const T = b(c.value), j = o[l.nameUntil];
        !T && he(c.value) && he(j) && (v.value = Ce.Custom, r.value.from = c.value, r.value.until = j, e.value = !0), T && (v.value = T.value);
      },
      { immediate: !0 }
    ), G(
      [() => o[l.nameFrom], () => o[l.nameUntil]],
      ([_, T], [j, le]) => {
        _ === j && T === le || z(_);
      },
      { immediate: !0 }
    );
    const se = (_) => {
      if (_.value === Ce.Custom) {
        J(!0);
        return;
      }
      o[l.nameUntil] = null, c.value = _.value;
    };
    return (_, T) => {
      const j = pe("ABtnTertiary"), le = pe("ABtnPrimary");
      return y(), V(X, null, [
        e.value ? (y(), B(Mt, {
          key: 0,
          label: D.value,
          "model-value": f(re)(r.value.from) + " - " + f(re)(r.value.until),
          readonly: "",
          rows: "1",
          "auto-grow": "",
          "hide-details": "",
          "append-inner-icon": "mdi-menu-down",
          clearable: "",
          class: "cursor-pointer",
          "onClick:clear": R(A, ["stop"]),
          onClick: T[0] || (T[0] = R(($) => J(), ["stop"]))
        }, null, 8, ["label", "model-value"])) : (y(), B(zt, {
          key: 1,
          modelValue: v.value,
          "onUpdate:modelValue": T[1] || (T[1] = ($) => v.value = $),
          "item-title": "title",
          "item-value": "value",
          label: D.value,
          clearable: !f(Q)(v.value),
          "no-filter": "",
          "data-cy": a.dataCy,
          items: f(d),
          "hide-details": "",
          autocomplete: "off",
          "onClick:clear": R(A, ["stop"])
        }, {
          item: u(({ props: $, item: ee }) => [
            m(ut, ot($, {
              onClick: (ne) => se(ee)
            }), null, 16, ["onClick"])
          ]),
          _: 1
        }, 8, ["modelValue", "label", "clearable", "data-cy", "items"])),
        C.value ? (y(), B(rt, {
          key: 2,
          "model-value": !0,
          width: "auto",
          "min-width": 360
        }, {
          default: u(() => [
            m(nt, null, {
              default: u(() => [
                m(Re, { onOnCancel: N }, {
                  default: u(() => [
                    E(_.$slots, "title", {}, () => [
                      U(P(D.value), 1)
                    ], !0)
                  ]),
                  _: 3
                }),
                m(Rt, null, {
                  default: u(() => [
                    m(Ie, null, {
                      default: u(() => [
                        m(De, {
                          modelValue: r.value.from,
                          "onUpdate:modelValue": T[2] || (T[2] = ($) => r.value.from = $),
                          v: f(w).dialogData.from,
                          label: f(s)("common.filter.timeInterval.from"),
                          required: ""
                        }, null, 8, ["modelValue", "v", "label"])
                      ]),
                      _: 1
                    }),
                    m(Ie, null, {
                      default: u(() => [
                        m(De, {
                          modelValue: r.value.until,
                          "onUpdate:modelValue": T[3] || (T[3] = ($) => r.value.until = $),
                          v: f(w).dialogData.until,
                          label: f(s)("common.filter.timeInterval.until"),
                          required: ""
                        }, null, 8, ["modelValue", "v", "label"])
                      ]),
                      _: 1
                    })
                  ]),
                  _: 1
                }),
                m(Ut, null, {
                  default: u(() => [
                    m(it),
                    m(j, {
                      "data-cy": "button-cancel",
                      onClick: R(N, ["stop"])
                    }, {
                      default: u(() => [
                        U(P(f(s)("common.button.cancel")), 1)
                      ]),
                      _: 1
                    }),
                    m(le, {
                      "data-cy": "button-confirm",
                      onClick: R(x, ["stop"])
                    }, {
                      default: u(() => [
                        U(P(f(s)("common.button.confirm")), 1)
                      ]),
                      _: 1
                    })
                  ]),
                  _: 1
                })
              ]),
              _: 3
            })
          ]),
          _: 3
        })) : q("", !0)
      ], 64);
    };
  }
}), Wa = /* @__PURE__ */ vt(Yt, [["__scopeId", "data-v-622f5681"]]), Gt = /* @__PURE__ */ Z({
  __name: "AFilterAdvancedButton",
  props: {
    tooltipT: { default: "common.button.advancedFilters" },
    buttonClass: { default: "mt-1" },
    dataCy: { default: "filter-advanced" }
  },
  emits: ["advancedFilter"],
  setup(a, { emit: p }) {
    const l = p, t = O(!1), g = (n) => {
      pt(n), t.value = !t.value, l("advancedFilter");
    }, { t: i } = ae();
    return (n, o) => (y(), B(W, {
      class: be(a.buttonClass),
      "data-cy": a.dataCy,
      icon: "",
      size: "x-small",
      variant: "text",
      onClick: R(g, ["stop"])
    }, {
      default: u(() => [
        m(Te, { icon: "mdi-filter-variant" }),
        m(ct, {
          activator: "parent",
          location: "bottom"
        }, {
          default: u(() => [
            U(P(f(i)(a.tooltipT)), 1)
          ]),
          _: 1
        })
      ]),
      _: 1
    }, 8, ["class", "data-cy"]));
  }
}), Xt = { class: "a-selected-filters__label text-caption" }, Zt = /* @__PURE__ */ Z({
  __name: "FiltersSelected",
  setup(a) {
    const p = H(Fe), l = H(xe), t = H(ke);
    if (F(p) || F(l) || F(t))
      throw new Error("Incorrect provide/inject config.");
    const { t: g } = ae(), i = (b) => {
      const v = p.fields?.[b]?.titleT;
      return v ? g(v) : b;
    }, n = S(() => {
      const b = Object.keys(p.fields);
      return Array.from(t.value).map(([v, C]) => ({
        name: v,
        title: i(v),
        options: C
      })).sort((v, C) => b.indexOf(v.name) - b.indexOf(C.name));
    }), { clearOneFilterSelected: o, isClearable: c } = Pe(), d = (b, v) => {
      o(b, v, l, p, t), p.touched = !0;
    };
    return (b, v) => (y(!0), V(X, null, oe(n.value, (C) => (y(), V("div", {
      key: C.name,
      class: "a-selected-filters"
    }, [
      I("div", Xt, P(C.title) + ": ", 1),
      (y(!0), V(X, null, oe(C.options, (r) => (y(), V("div", {
        key: r.value,
        class: "a-selected-filters__chips"
      }, [
        f(c)(C.name, f(p)) ? (y(), B(Ee, {
          key: 0,
          closable: "",
          size: "small",
          class: "a-selected-filters__chip",
          "onClick:close": R((e) => d(C.name, r.value), ["stop"])
        }, {
          close: u(() => [
            m(Te, {
              size: "16",
              icon: "mdi-close-circle"
            })
          ]),
          default: u(() => [
            U(" " + P(r.title), 1)
          ]),
          _: 2
        }, 1032, ["onClick:close"])) : (y(), B(Ee, {
          key: 1,
          size: "small",
          class: "a-selected-filters__chip"
        }, {
          default: u(() => [
            U(P(r.title), 1)
          ]),
          _: 2
        }, 1024))
      ]))), 128))
    ]))), 128));
  }
}), ea = { class: "d-flex flex-wrap align-center" }, ta = { class: "a-filter__container" }, aa = { class: "a-filter__search" }, oa = { key: 2 }, Qa = /* @__PURE__ */ Z({
  __name: "AFilterWrapper",
  props: /* @__PURE__ */ ge({
    enableTop: { type: Boolean, default: !1 },
    hideButtons: { type: Boolean, default: !1 },
    formName: { default: "search" },
    userId: { default: void 0 },
    client: { type: Function, default: void 0 },
    store: { type: [Object, Boolean], default: !0 },
    alwaysVisible: { type: Boolean, default: !1 },
    hideMore: { type: Boolean, default: !1 }
  }, {
    datatableHiddenColumns: {
      default: void 0,
      required: !1
    },
    datatableHiddenColumnsModifiers: {},
    showDetail: { type: Boolean, default: !1, required: !1 },
    showDetailModifiers: {}
  }),
  emits: /* @__PURE__ */ ge(["submit", "reset", "bookmarkLoadAfter"], ["update:datatableHiddenColumns", "update:showDetail"]),
  setup(a, { expose: p, emit: l }) {
    const t = a, g = l, i = we(a, "datatableHiddenColumns"), n = we(a, "showDetail"), o = H(Fe), c = H(xe);
    if (F(o) || F(c))
      throw new Error("Incorrect provide/inject config.");
    const d = O({
      system: o.general.system,
      subject: o.general.subject
    });
    fe(t.store) ? t.store === !1 && (d.value.system = void 0, d.value.subject = void 0) : (d.value.system = t.store.system, d.value.subject = t.store.subject);
    const b = O(0);
    $e(Ve, b);
    const v = O(/* @__PURE__ */ new Map());
    $e(ke, v);
    const C = () => {
      b.value++, me(() => {
        g("submit");
      });
    }, { clearAll: r, clearAllFilterSelected: e } = Pe(), w = () => {
      me(() => {
        b.value++, g("bookmarkLoadAfter");
      });
    }, h = () => {
      r(c, o), e(c, o, v), me(() => {
        b.value++, g("reset");
      });
    }, s = () => {
      n.value = !n.value;
    }, D = S(() => o.touched), L = S(() => Object.entries(o.fields).filter(([, k]) => !k.render.skip).map(([k]) => k));
    return t.alwaysVisible && (n.value = !0), p({
      submit: C,
      reset: h
    }), (k, A) => (y(), B(qt, {
      name: a.formName,
      onSubmit: R(C, ["prevent"])
    }, {
      default: u(() => [
        a.enableTop ? (y(), B(ie, {
          key: 0,
          dense: ""
        }, {
          default: u(() => [
            m(te, null, {
              default: u(() => [
                E(k.$slots, "top")
              ]),
              _: 3
            })
          ]),
          _: 3
        })) : q("", !0),
        m(ie, { dense: "" }, {
          default: u(() => [
            a.store && a.userId && f(Y)(a.client) ? (y(), B(te, { key: 0 }, {
              default: u(() => [
                E(k.$slots, "bookmarks", {}, () => [
                  I("div", ea, [
                    d.value.system && d.value.subject && a.userId && f(Y)(a.client) ? (y(), B(gt, {
                      key: 0,
                      "datatable-hidden-columns": i.value,
                      "onUpdate:datatableHiddenColumns": A[0] || (A[0] = (x) => i.value = x),
                      client: a.client,
                      system: d.value.system,
                      subject: d.value.subject,
                      "user-id": a.userId,
                      onSubmit: w
                    }, null, 8, ["datatable-hidden-columns", "client", "system", "subject", "user-id"])) : q("", !0)
                  ])
                ])
              ]),
              _: 3
            })) : q("", !0)
          ]),
          _: 3
        }),
        a.alwaysVisible ? q("", !0) : (y(), B(ie, {
          key: 1,
          dense: ""
        }, {
          default: u(() => [
            a.hideMore ? q("", !0) : (y(), B(te, {
              key: 0,
              cols: "auto"
            }, {
              default: u(() => [
                m(Gt, {
                  "button-active": n.value,
                  onAdvancedFilter: s
                }, null, 8, ["button-active"])
              ]),
              _: 1
            })),
            m(te, null, {
              default: u(() => [
                I("div", ta, [
                  I("div", aa, [
                    E(k.$slots, "search")
                  ]),
                  m(Zt)
                ])
              ]),
              _: 3
            }),
            a.hideButtons ? q("", !0) : (y(), B(te, {
              key: 1,
              class: "text-right",
              cols: "auto"
            }, {
              default: u(() => [
                E(k.$slots, "buttons", {}, () => [
                  m(bt, { touched: D.value }, null, 8, ["touched"]),
                  m(yt, { onReset: h }),
                  d.value.system && d.value.subject && a.userId && f(Y)(a.client) ? (y(), B(ht, {
                    key: 0,
                    client: a.client,
                    user: a.userId,
                    system: d.value.system,
                    subject: d.value.subject,
                    "datatable-hidden-columns": i.value
                  }, null, 8, ["client", "user", "system", "subject", "datatable-hidden-columns"])) : q("", !0)
                ])
              ]),
              _: 3
            }))
          ]),
          _: 3
        })),
        a.hideMore ? q("", !0) : (y(), V("div", oa, [
          (y(), B(Vt(a.alwaysVisible ? "div" : "VSlideYTransition"), null, {
            default: u(() => [
              st(I("div", {
                class: be({ "mt-6 pa-4 system-border-a": !a.alwaysVisible })
              }, [
                E(k.$slots, "detail", {}, () => [
                  m(ie, null, {
                    default: u(() => [
                      (y(!0), V(X, null, oe(L.value, (x) => (y(), B(te, {
                        key: x,
                        cols: f(o).fields[x].render.xs || 12,
                        sm: f(o).fields[x].render.sm || 6,
                        md: f(o).fields[x].render.md || 4,
                        lg: f(o).fields[x].render.lg || 3,
                        xl: f(o).fields[x].render.xl || 2
                      }, {
                        default: u(() => [
                          E(k.$slots, f(Ct)(x), {
                            itemConfig: f(o).fields[x]
                          }, () => [
                            m(_t, { name: x }, null, 8, ["name"])
                          ])
                        ]),
                        _: 2
                      }, 1032, ["cols", "sm", "md", "lg", "xl"]))), 128))
                    ]),
                    _: 3
                  })
                ])
              ], 2), [
                [lt, n.value]
              ])
            ]),
            _: 3
          }))
        ]))
      ]),
      _: 3
    }, 8, ["name"]));
  }
}), sa = { class: "d-flex align-center justify-center" }, la = { class: "text-caption mr-1" }, Ya = /* @__PURE__ */ Z({
  __name: "ADatatableOrdering",
  props: /* @__PURE__ */ ge({
    variant: { default: "id" },
    customOptions: { default: void 0 },
    paginationUpdateCustomCb: { type: Function, default: void 0 }
  }, {
    modelValue: {
      default: 1,
      required: !1
    },
    modelModifiers: {}
  }),
  emits: /* @__PURE__ */ ge(["sortByChange"], ["update:modelValue"]),
  setup(a, { emit: p }) {
    const l = a, t = p, g = we(a, "modelValue"), i = H(Ue);
    if (F(i))
      throw new Error("Incorrect provide/inject config.");
    const { t: n } = ae(), o = [
      { id: 1, titleT: "common.system.datatable.ordering.mostRecent", sortBy: { key: "createdAt", order: K.Desc } },
      { id: 2, titleT: "common.system.datatable.ordering.oldest", sortBy: { key: "createdAt", order: K.Asc } }
    ], c = [
      { id: 1, titleT: "common.system.datatable.ordering.mostRecent", sortBy: { key: "id", order: K.Desc } },
      { id: 2, titleT: "common.system.datatable.ordering.oldest", sortBy: { key: "id", order: K.Asc } }
    ], d = [
      {
        id: 3,
        titleT: "common.system.datatable.ordering.mostRelevant",
        sortBy: { key: At, order: K.Desc }
      },
      { id: 1, titleT: "common.system.datatable.ordering.mostRecent", sortBy: { key: "createdAt", order: K.Desc } },
      { id: 2, titleT: "common.system.datatable.ordering.oldest", sortBy: { key: "createdAt", order: K.Asc } }
    ], b = S(() => {
      const e = v.value.find((w) => w.id === g.value);
      return e ? n(e.titleT) : "";
    }), v = S(() => l.customOptions ? l.customOptions : l.variant === "most-relevant" ? d : l.variant === "id" ? c : o), C = (e) => {
      g.value = e.id;
    }, r = (e) => {
      e.sortBy || (i.value = { ...i.value, sortBy: null, descending: !0 }, t("sortByChange", e)), i.value.sortBy = e.sortBy, t("sortByChange", e);
    };
    return G(
      g,
      (e, w) => {
        if (e === w) return;
        const h = v.value.find((s) => s.id === e);
        if (!F(h)) {
          if (F(l.paginationUpdateCustomCb)) {
            r(h);
            return;
          }
          l.paginationUpdateCustomCb(h, i);
        }
      }
    ), G(
      i,
      (e, w) => {
        if (e.sortBy?.key === w?.sortBy?.key && e.sortBy?.order === w?.sortBy?.order)
          return;
        const h = v.value.find((s) => e.sortBy?.key === s.sortBy?.key && e.sortBy?.order === s.sortBy?.order);
        F(h) || (g.value = h.id);
      },
      { immediate: !0 }
    ), (e, w) => (y(), V("div", sa, [
      I("div", la, P(f(n)("common.system.datatable.ordering.title")) + ": ", 1),
      m(W, {
        variant: "text",
        rounded: "xl",
        size: "small",
        "append-icon": "mdi-chevron-down"
      }, {
        default: u(() => [
          U(P(b.value) + " ", 1),
          m(Ht, {
            activator: "parent",
            location: "bottom",
            "close-on-content-click": ""
          }, {
            default: u(() => [
              m(Lt, {
                density: "compact",
                class: "pa-0"
              }, {
                default: u(() => [
                  (y(!0), V(X, null, oe(v.value, (h) => (y(), B(ut, {
                    key: h.id,
                    onClick: (s) => C(h)
                  }, {
                    default: u(() => [
                      m(Nt, {
                        class: be({ "font-weight-bold": h.id === g.value })
                      }, {
                        default: u(() => [
                          U(P(f(n)(h.titleT)), 1)
                        ]),
                        _: 2
                      }, 1032, ["class"])
                    ]),
                    _: 2
                  }, 1032, ["onClick"]))), 128))
                ]),
                _: 1
              })
            ]),
            _: 1
          })
        ]),
        _: 1
      })
    ]));
  }
}), na = { class: "anzu-data-footer" }, ra = {
  key: 0,
  class: "anzu-data-footer__page-limit"
}, ia = { class: "anzu-data-footer__pagination" }, ua = { class: "anzu-data-footer__icons-before" }, ca = { class: "current-page" }, da = { class: "anzu-data-footer__icons-after" }, ma = /* @__PURE__ */ Z({
  __name: "ADatatablePagination",
  props: {
    itemsPerPageOptions: { default: () => [10, 25, 50] },
    hideRecordsPerPage: { type: Boolean, default: !1 }
  },
  emits: ["change"],
  setup(a, { emit: p }) {
    const l = p, t = H(Ue);
    if (F(t))
      throw new Error("Incorrect provide/inject config.");
    const { t: g } = ae(), i = S(() => Math.ceil(t.value.totalCount / t.value.rowsPerPage)), n = S(() => t.value.page * t.value.rowsPerPage - t.value.rowsPerPage + 1), o = S(() => t.value.page * t.value.rowsPerPage - t.value.rowsPerPage + t.value.currentViewCount), c = S(() => t.value.page === 1), d = S(() => !Q(t.value.hasNextPage) || t.value.page === i.value), b = S(() => Q(t.value.hasNextPage) && t.value.page === i.value || t.value.hasNextPage === !1), v = S(() => Q(t.value.hasNextPage) ? t.value.totalCount : t.value.hasNextPage ? o.value + 1 + "+" : o.value);
    G(
      () => t.value.rowsPerPage,
      (h, s) => {
        h !== s && (t.value.page = 1, l("change"));
      }
    ), G(
      () => t.value.page,
      (h, s) => {
        h !== s && l("change");
      }
    );
    const C = ue(() => {
      t.value.page = 1;
    }, 300), r = ue(() => {
      t.value.page = i.value;
    }, 300), e = ue(() => {
      t.value.page = t.value.page - 1;
    }, 300), w = ue(() => {
      t.value.page = t.value.page + 1;
    }, 300);
    return (h, s) => (y(), V("div", na, [
      a.hideRecordsPerPage ? q("", !0) : (y(), V("div", ra, [
        U(P(f(g)("common.system.datatable.itemsPerPage")) + ": ", 1),
        m(Kt, {
          modelValue: f(t).rowsPerPage,
          "onUpdate:modelValue": s[0] || (s[0] = (D) => f(t).rowsPerPage = D),
          class: "ml-2",
          density: "compact",
          mandatory: "",
          "data-cy": "table-size"
        }, {
          default: u(() => [
            (y(!0), V(X, null, oe(a.itemsPerPageOptions, (D) => (y(), B(W, {
              key: D,
              color: D === f(t).rowsPerPage ? "secondary" : "",
              value: D,
              density: "compact",
              size: "small",
              variant: "text"
            }, {
              default: u(() => [
                U(P(D), 1)
              ]),
              _: 2
            }, 1032, ["color", "value"]))), 128))
          ]),
          _: 1
        }, 8, ["modelValue"])
      ])),
      I("div", ia, P(n.value) + " - " + P(o.value) + " " + P(f(g)("common.system.datatable.from")) + " " + P(v.value), 1),
      I("div", ua, [
        m(W, {
          disabled: c.value,
          icon: "mdi-page-first",
          size: "small",
          variant: "text",
          onClick: R(f(C), ["stop"])
        }, null, 8, ["disabled", "onClick"]),
        m(W, {
          disabled: c.value,
          icon: "mdi-chevron-left",
          size: "small",
          variant: "text",
          onClick: R(f(e), ["stop"])
        }, null, 8, ["disabled", "onClick"])
      ]),
      I("div", ca, [
        I("span", null, P(f(t).page), 1)
      ]),
      I("div", da, [
        m(W, {
          disabled: b.value,
          icon: "mdi-chevron-right",
          size: "small",
          variant: "text",
          onClick: R(f(w), ["stop"])
        }, null, 8, ["disabled", "onClick"]),
        m(W, {
          disabled: d.value,
          icon: "mdi-page-last",
          size: "small",
          variant: "text",
          onClick: R(f(r), ["stop"])
        }, null, 8, ["disabled", "onClick"])
      ])
    ]));
  }
}), fa = (a, p, l = "id") => {
  const { querySetLimit: t, querySetOffset: g, querySetOrder: i, queryBuild: n, queryAddFilter: o, queryAdd: c } = wt(), d = a.length;
  return t(d), g(1, d), i(l, !1), p ? c(l, a.join(",")) : o("in", l, a.join(",")), n();
}, Ga = (a, p, l, t = void 0, g = void 0, i = {}, n = !1, o = "id") => {
  let c = null;
  return {
    executeFetch: async (v, C = void 0, r = void 0) => {
      c = new AbortController();
      try {
        const e = Y(r) ? r : g, w = Y(C) ? C : t;
        if (F(w)) throw new Error("Url template is undefined");
        const h = (F(e) ? w : Le(w, e)) + fa(v, n, o), s = await a().get(h, {
          ...i,
          signal: c.signal
        });
        if (!Ne(s.status))
          throw new ze(s.status);
        if (s.data?.data)
          return s.data.data;
        if (s.status === Me)
          return [];
        throw new ve();
      } catch (e) {
        if (e instanceof DOMException && e.name === "AbortError")
          return [];
        throw qe(e) ? e : He(e) ? new Je(e, e.config?.url) : Ke(e) ? new We(e, p, l, e) : Qe(e) ? new Ye(e, p, l, e) : Ge(e) ? new Xe(e, e) : Ze(e) ? new et(e) : dt.isAxiosError(e) ? (console.error("Axios error: " + t, e.cause), new tt(e)) : (console.error("AnzuFatalError: ", e), new ve(e));
      } finally {
        c = null;
      }
    },
    abortFetch: () => {
      c && c.abort();
    }
  };
}, Xa = (a, p, l, t = void 0, g = void 0, i = {}) => {
  let n = null;
  return {
    executeFetch: async (d, b, v = void 0, C = void 0, r = "id", e = !0, w = 100, h = !1) => {
      n = new AbortController();
      try {
        const s = b.general.elastic || h ? "/search" : "", D = Y(C) ? C : g, L = Y(v) ? v : t;
        if (F(L)) throw new Error("Url template is undefined");
        const { pagination: k } = at(r, e ? K.Desc : K.Asc, {
          rowsPerPage: w
        }), A = (F(D) ? L : Le(L, D)) + s, x = [], N = await a().get(A + _e(k, d, b), {
          ...i,
          signal: n.signal
        });
        if (!Ne(N.status))
          throw new ze(N.status);
        if (N.data) {
          const M = N.data;
          if (x.push(...M.data), kt(M))
            for (k.value.hasNextPage = M.hasNextPage; k.value.hasNextPage; ) {
              k.value.page++;
              const J = (await a().get(A + _e(k, d, b), {
                ...i,
                signal: n.signal
              })).data;
              x.push(...J.data), k.value.hasNextPage = J.hasNextPage;
            }
          else if (Ft(M)) {
            if (k.value.totalCount = M.totalCount, k.value.totalCount <= k.value.rowsPerPage)
              return x;
            const z = [], J = Math.ceil(k.value.totalCount / k.value.rowsPerPage);
            for (let _ = 1; _ < J; _++) {
              const T = { ...k.value, page: _ + 1 }, j = O(T);
              z.push(
                a().get(A + _e(j, d, b), {
                  ...i,
                  signal: n.signal
                })
              );
            }
            (await Promise.all(z)).forEach((_) => {
              x.push(..._.data.data);
            });
          }
          return x;
        }
        if (N.status === Me)
          return [];
        throw new ve();
      } catch (s) {
        if (s instanceof DOMException && s.name === "AbortError")
          return [];
        throw qe(s) ? s : He(s) ? new Je(s, s.config?.url) : Ke(s) ? new We(s, p, l, s) : Qe(s) ? new Ye(s, p, l, s) : Ge(s) ? new Xe(s, s) : Ze(s) ? new et(s) : dt.isAxiosError(s) ? (console.error("Axios error: " + t, s.cause), new tt(s)) : (console.error("AnzuFatalError: ", s), new ve(s));
      } finally {
        n = null;
      }
    },
    abortFetch: () => {
      n && n.abort();
    }
  };
}, ce = "/adm/v1/job", de = "job";
function Za(a, p) {
  return {
    useFetchJobList: () => Tt(a, p, de, ce),
    fetchJob: (n) => Pt(a, ce + "/:id", { id: n }, p, de),
    createJob: (n) => {
      const o = St(n._resourceName).slice(4).replace("-kind-", "-kind/");
      return Bt(a, n, ce + "/:type", { type: o }, p, de);
    },
    deleteJob: (n) => xt(a, ce + "/:id", { id: n }, p, de)
  };
}
const va = {
  key: "",
  title: void 0,
  sortable: !1,
  fixed: !1
}, pa = {
  storeColumnsLocalStorage: !0,
  disableActions: !1,
  customI18n: void 0,
  showExpand: !1
};
function ga(a, p, l, t, g = {}) {
  const i = { ...pa, ...g }, n = i.customI18n ?? It, { t: o } = n.global || n;
  let c;
  jt(i.storeColumnsLocalStorage) ? c = i.storeColumnsLocalStorage : fe(i.storeColumnsLocalStorage) && i.storeColumnsLocalStorage === !0 && (c = "table_" + l + "_" + t);
  const d = a.map((r) => {
    const e = { ...va, ...r };
    return F(e.title) && (F(e.title) && Dt.includes(e.key) ? e.title = o("common.model.tracking." + e.key) : F(e.title) && l && t ? e.title = o(l + "." + t + ".model." + e.key) : e.title = ""), e;
  }), b = S(() => {
    const r = [];
    return i.showExpand && r.push({ key: "data-table-expand", sortable: !1 }), d.forEach((e) => {
      p.value.includes(e.key) || r.push(e);
    }), i.disableActions || r.push({ key: "actions", sortable: !1, fixed: "end" }), r;
  }), v = () => {
    if (!c || !localStorage) return;
    const r = localStorage.getItem(c);
    if (!r) return;
    const e = JSON.parse(r);
    $t(e) && Ae(e.hidden) && (p.value = e.hidden);
  }, C = (r) => {
    !c || !localStorage || localStorage.setItem(c, JSON.stringify({ hidden: r }));
  };
  return Ot(() => {
    v();
  }), G(p, (r) => {
    C(r);
  }), {
    columnsAll: d,
    columnsVisible: b,
    columnsHidden: p
  };
}
function eo(a, p, l, t, g, i, n, o = null, c = void 0, d = void 0, b = !1, v = !1) {
  const C = O(!1), r = O([]), e = O([]), w = O(!1), { pagination: h, setSortBy: s, incrementPage: D } = at(
    Q(o) ? null : o.key,
    o?.order
  ), { resetFilter: L, submitFilter: k } = Et(i, n, {
    storeFiltersLocalStorage: !1,
    populateUrlParams: !1
  }), { showErrorsDefault: A } = Oe(), { columnsVisible: x, columnsAll: N, columnsHidden: M } = ga(
    a,
    p,
    l,
    t,
    { storeColumnsLocalStorage: !1, disableActions: !v }
  ), z = () => {
    _(), j();
  }, J = ($) => {
    s($.sortBy), j();
  }, se = async () => {
    w.value = !0, D();
    try {
      const $ = await g(
        h,
        i,
        n,
        c,
        d,
        b
      );
      r.value.push(...$);
    } catch ($) {
      A($);
    } finally {
      w.value = !1;
    }
  }, _ = () => {
    r.value = [], e.value = [];
  }, T = async () => {
    w.value = !0;
    try {
      r.value = await g(
        h,
        i,
        n,
        c,
        d,
        b
      );
    } catch ($) {
      A($);
    } finally {
      w.value = !1;
    }
  }, j = Jt(async () => {
    await T();
  });
  return {
    items: r,
    selected: e,
    pagination: h,
    columnsVisible: x,
    columnsHidden: M,
    columnsAll: N,
    filterTouched: C,
    loading: w,
    onRowClick: ($) => {
      const ee = $.target;
      if (!ee || ee.tagName === "INPUT" && ee.type === "checkbox")
        return;
      const ne = ee.closest(".v-data-table__tr");
      if (!ne || !ne.classList.contains("v-data-table__tr")) return;
      const ye = ne.firstElementChild;
      if (!ye || !ye.classList.contains("v-data-table__td")) return;
      const Se = ye.querySelector("input");
      Se && Se.click();
    },
    onFetchNextPage: se,
    onOpen: z,
    sortByChange: J,
    getList: j,
    resetFilter: () => L(h, j),
    submitFilter: () => k(h, j)
  };
}
const ba = { class: "d-flex flex-column w-100 px-1 align-center" }, ya = { class: "d-flex justify-space-between w-100 align-center" }, ha = { class: "d-flex align-center" }, Ca = { class: "d-flex align-center" }, _a = { class: "subject-select__sidebar system-border-r" }, Aa = { class: "subject-select-filter" }, wa = { class: "subject-select__content" }, ka = {
  key: 0,
  class: "d-flex w-100 align-center justify-center pa-4"
}, Fa = { class: "subject-select__actions system-border-t" }, xa = { key: 0 }, Pa = { key: 1 }, to = /* @__PURE__ */ Z({
  __name: "ASubjectSelect",
  props: {
    selectedItems: {},
    pagination: {},
    loading: { type: Boolean, default: !1 },
    minCount: { default: 1 },
    maxCount: { default: 1 },
    modelValue: { type: Boolean, default: void 0 },
    dialogTitleT: { default: "common.subjectSelect.texts.title" },
    paginationMode: { default: "standard" }
  },
  emits: ["update:modelValue", "update:pagination", "onOpen", "onPageChange", "onConfirm", "onFetchNextPage"],
  setup(a, { expose: p, emit: l }) {
    const t = a, g = l, i = O(!1), n = S({
      get() {
        return F(t.modelValue) ? i.value : t.modelValue;
      },
      set(A) {
        i.value = A, g("update:modelValue", A);
      }
    }), o = S({
      get: () => t.pagination,
      set: (A) => {
        g("update:pagination", { ...je(A) });
      }
    }), c = O(!0), { t: d } = ae(), b = S(() => t.selectedItems.length), v = S(() => b.value < t.minCount || b.value > t.maxCount), C = () => {
      g("onOpen"), c.value = !0, n.value = !0;
    }, r = () => {
      c.value = !c.value;
    }, e = () => {
      n.value = !1;
    }, w = () => {
      g(
        "onConfirm",
        t.selectedItems.map((A) => je(A))
      ), e();
    }, h = () => {
      g("onFetchNextPage");
    }, s = () => {
      g("onPageChange");
    }, D = S(() => Math.ceil(o.value.totalCount / o.value.rowsPerPage)), L = S(() => !(Q(o.value.hasNextPage) && o.value.page === D.value || o.value.hasNextPage === !1)), k = (A) => {
      A && L.value && !t.loading && h();
    };
    return p({
      open: C
    }), (A, x) => {
      const N = pe("ABtnSecondary"), M = pe("ABtnPrimary");
      return y(), V(X, null, [
        E(A.$slots, "activator", {
          props: { onClick: R(() => C(), ["stop"]) }
        }),
        m(rt, ot(A.$attrs, {
          "model-value": n.value,
          fullscreen: "",
          class: "subject-select",
          "onUpdate:modelValue": x[1] || (x[1] = (z) => g("update:modelValue", z))
        }), {
          default: u(() => [
            n.value ? (y(), B(nt, {
              key: 0,
              class: "subject-select__card"
            }, {
              default: u(() => [
                m(Re, {
                  class: "subject-select__toolbar system-border-b",
                  onOnCancel: e
                }, {
                  default: u(() => [
                    E(A.$slots, "title", {}, () => [
                      U(P(f(d)(a.dialogTitleT)), 1)
                    ])
                  ]),
                  _: 3
                }),
                m(Wt, {
                  density: "compact",
                  color: "transparent",
                  height: 46,
                  elevation: "0",
                  class: "system-border-b subject-select__second-bar"
                }, {
                  default: u(() => [
                    E(A.$slots, "second-bar", {}, () => [
                      I("div", ba, [
                        I("div", ya, [
                          I("div", ha, [
                            m(W, {
                              icon: "",
                              width: 30,
                              height: 30,
                              onClick: r
                            }, {
                              default: u(() => [
                                m(Te, {
                                  icon: "mdi-tune",
                                  size: 16
                                }),
                                m(ct, {
                                  activator: "parent",
                                  location: "bottom"
                                }, {
                                  default: u(() => [
                                    U(P(f(d)("common.subjectSelect.filter.toggle")), 1)
                                  ]),
                                  _: 1
                                })
                              ]),
                              _: 1
                            }),
                            E(A.$slots, "second-bar-left")
                          ]),
                          I("div", Ca, [
                            E(A.$slots, "second-bar-right")
                          ])
                        ])
                      ])
                    ])
                  ]),
                  _: 3
                }),
                I("div", {
                  class: be(["subject-select__main", { "subject-select__main--sidebar-active": c.value }])
                }, [
                  I("div", _a, [
                    I("div", Aa, [
                      E(A.$slots, "filter")
                    ])
                  ]),
                  I("div", wa, [
                    E(A.$slots, "content"),
                    a.paginationMode === "more" ? (y(), V("div", ka, [
                      st((y(), B(N, {
                        loading: a.loading,
                        size: "small",
                        onClick: h
                      }, {
                        default: u(() => [
                          E(A.$slots, "button-confirm-title", {}, () => [
                            U(P(f(d)("common.button.loadMore")), 1)
                          ])
                        ]),
                        _: 3
                      }, 8, ["loading"])), [
                        [lt, L.value || a.loading],
                        [
                          Qt,
                          k,
                          void 0,
                          { quiet: !0 }
                        ]
                      ])
                    ])) : (y(), B(ma, {
                      key: 1,
                      modelValue: o.value,
                      "onUpdate:modelValue": x[0] || (x[0] = (z) => o.value = z),
                      onChange: s
                    }, null, 8, ["modelValue"]))
                  ])
                ], 2),
                I("div", Fa, [
                  a.minCount === a.maxCount ? (y(), V("div", xa, P(f(d)("common.subjectSelect.texts.pickExactCount", { count: a.minCount, selected: b.value })), 1)) : (y(), V("div", Pa, P(f(d)("common.subjectSelect.texts.pickRangeCount", {
                    minCount: a.minCount,
                    maxCount: a.maxCount,
                    selected: b.value
                  })), 1)),
                  m(it),
                  m(M, {
                    disabled: v.value,
                    onClick: R(w, ["stop"])
                  }, {
                    default: u(() => [
                      E(A.$slots, "button-confirm-title", {}, () => [
                        U(P(f(d)("common.button.confirm")), 1)
                      ])
                    ]),
                    _: 3
                  }, 8, ["disabled"])
                ])
              ]),
              _: 3
            })) : q("", !0)
          ]),
          _: 3
        }, 16, ["model-value"])
      ], 64);
    };
  }
});
export {
  Ya as ADatatableOrdering,
  ma as ADatatablePagination,
  so as AFilterBooleanSelect,
  lo as AFilterDatetimePicker,
  no as AFilterInteger,
  ro as AFilterRemoteAutocomplete,
  io as AFilterRemoteAutocompleteWithMinimal,
  uo as AFilterString,
  Wa as AFilterTimeInterval,
  co as AFilterValueObjectOptionsSelect,
  Qa as AFilterWrapper,
  mo as AFilterWrapperSubjectSelect,
  fo as AFormRemoteAutocomplete,
  to as ASubjectSelect,
  Ue as DatatablePaginationKey,
  Fe as FilterConfigKey,
  xe as FilterDataKey,
  vo as FilterInnerConfigKey,
  po as FilterInnerDataKey,
  Ce as TimeIntervalSpecialOptions,
  go as UserAdminConfigLayoutType,
  bo as UserAdminConfigLayoutTypeDefault,
  yo as UserAdminConfigType,
  ho as UserAdminConfigTypeDefault,
  ga as createDatatableColumnsConfig,
  Co as createFilter,
  _o as createFilterStore,
  _e as generateListQuery,
  Ga as useApiFetchByIds,
  Tt as useApiFetchList,
  Xa as useApiFetchListBatch,
  wt as useApiQueryBuilder,
  Ao as useApiRequest,
  Et as useFilterHelpers,
  Za as useJobApi,
  at as usePagination,
  eo as useSubjectSelect,
  wo as useUserAdminConfigApi,
  ko as useUserAdminConfigFactory
};
//# sourceMappingURL=labs.js.map
