
		import { Core as _autoloadCSSCore } from '../core/app.js';
		const fileNames = ['../assets/policy.css'].map(fileName => import.meta.resolve(fileName));
		_autoloadCSSCore.insertCSSLinkToPage(fileNames, true);
	
import { defineComponent as J, mergeModels as W, useModel as ee, ref as $, onMounted as ae, onUpdated as se, createElementBlock as L, openBlock as g, normalizeClass as ne, createCommentVNode as M, Fragment as F, renderList as z, createBlock as S, mergeProps as R, createSlots as U, withCtx as B, createTextVNode as E, toDisplayString as P, createVNode as te, createElementVNode as re, withModifiers as oe, computed as N, watch as H, toRef as O, resolveComponent as ie, resolveDirective as ue, unref as f, renderSlot as ce, withDirectives as Q, resolveDynamicComponent as fe } from "vue";
import { e as X, b as de, C as Y, d as pe, u as ve, s as me } from "./forms-BAUgA7Ct.es.js";
import { _ as ye, b as Z } from "./popupHint.vue_vue_type_style_index_0_lang-BIWw5zUX.es.js";
import { _ as he } from "./widgetInput.vue_vue_type_script_setup_true_lang-Brs-RxDI.es.js";
import { invertKeyboardLayout as ge } from "../utils/keyboard.js";
import { g as Ae } from "./field-CyyFzM-Y.es.js";
const Ie = {
  key: 0,
  class: "top-menu_selectAll"
}, Re = /* @__PURE__ */ J({
  __name: "menu",
  props: /* @__PURE__ */ W({
    modelValue: {},
    items: {},
    isMultiple: { type: Boolean },
    canBeEmptyMultiple: { type: Boolean },
    styling: { default: "default" },
    selectAllItem: {}
  }, {
    modelValue: {
      required: !0
    },
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(e) {
    const a = e, l = ee(e, "modelValue"), t = $();
    !a.isMultiple && typeof l.value != "string" && typeof l.value != "number" && console.warn('Type check failed for prop "modelValue". Expected String: ' + typeof l.value), a.isMultiple && !Array.isArray(l.value) && console.warn('Type check failed for prop "modelValue". Expected Array: ' + typeof l.value), a.isMultiple && !a.canBeEmptyMultiple && Array.isArray(l.value) && !l.value.length && a.items[0] && (l.value = [a.items[0]?.href ?? a.items[0]?.value]);
    const u = (n) => Array.isArray(l.value) ? l.value.includes(n.value) : n.value === l.value, b = (n, v = !1) => {
      if (Array.isArray(l.value)) {
        let i = l.value.slice();
        if (v) {
          i.length || (i = a.items.map((y) => y.value));
          const A = i.indexOf(n.value);
          A === -1 ? i.push(n.value) : i.splice(A, 1);
        } else
          i.length === 1 && i[0] === n.value ? i = [] : i = [n.value];
        !a.canBeEmptyMultiple && !i.length && (i = [n.value]), l.value = i;
        return;
      }
      l.value = n.value;
    }, d = (n) => {
      if (t.value.scrollWidth <= t.value.offsetWidth || n.shiftKey || Math.abs(n.deltaY) < 50) return;
      n.preventDefault();
      const v = n.deltaY > 0 ? 30 : -30;
      t.value.scrollLeft = t.value.scrollLeft + v;
    }, c = (n = !0) => {
      const v = t.value.querySelector(".top-active");
      if (!v) return;
      const i = 24, A = v.offsetLeft - t.value.offsetLeft - i, y = v.offsetLeft - t.value.offsetLeft + v.clientWidth + i, h = t.value.scrollLeft, x = t.value.clientWidth + t.value.scrollLeft;
      let I;
      A < h && (I = A), y > x && (I = y - t.value.clientWidth), I !== void 0 && (de() ? Y.$?.(t.value).animate({ scrollLeft: I }, n ? 200 : 0) : t.value.scrollTo({ left: I, behavior: n ? "smooth" : "auto" }));
    }, s = () => {
      if (Array.isArray(l.value)) {
        if (l.value.length === a.items.length) {
          l.value = [a.items[0].href ?? a.items[0].value];
          return;
        }
        l.value = a.items.map((n) => n.href ?? n.value);
      }
    };
    return ae(() => c(!1)), se(() => c(!0)), (n, v) => (g(), L("div", {
      ref_key: "el",
      ref: t,
      class: ne({
        "top-menu": !0,
        ["top-style_" + e.styling]: !0
        // ['top-unwrap-x']: styling === 'default',
      }),
      onWheel: d
    }, [
      (g(!0), L(F, null, z(e.items, (i) => (g(), S(X, R({ ref_for: !0 }, i, {
        class: "top-menu_item",
        color: "theme",
        onClick: (A) => b(i, A.ctrlKey || A.metaKey),
        isActive: u(i)
      }), U({ _: 2 }, [
        i.content ? {
          name: "default",
          fn: B(() => [
            E(P(i.content), 1)
          ]),
          key: "0"
        } : void 0
      ]), 1040, ["onClick", "isActive"]))), 256)),
      Array.isArray(l.value) && e.selectAllItem ? (g(), L("div", Ie, [
        te(X, R(e.selectAllItem, {
          class: "top-menu_item",
          color: "theme",
          styling: "",
          onClick: v[0] || (v[0] = (i) => s()),
          isActive: l.value.length === e.items.length
        }), U({ _: 2 }, [
          e.selectAllItem.content ? {
            name: "default",
            fn: B(() => [
              E(P(e.selectAllItem.content), 1)
            ]),
            key: "0"
          } : void 0
        ]), 1040, ["isActive"])
      ])) : M("", !0)
    ], 34));
  }
}), ke = { class: "top-selector2_itemMulti top-ellipsis" }, Le = /* @__PURE__ */ J({
  __name: "itemMulti",
  props: {
    id: {},
    name: {}
  },
  emits: ["delete"],
  setup(e) {
    return (a, l) => (g(), L("div", ke, [
      E(P(e.name) + " ", 1),
      re("span", {
        class: "top-selector2_itemMultiDelete",
        "data-top-icon": "",
        onClick: l[0] || (l[0] = (t) => a.$emit("delete", { id: e.id, name: e.name })),
        onMousedown: l[1] || (l[1] = oe(() => {
        }, ["stop"]))
      }, null, 32)
    ]));
  }
}), D = /* @__PURE__ */ new Map(), Ce = (e) => {
  D.get(e)?.clear();
}, Te = (e) => {
  const a = window.mo?.user?.id;
  return JSON.stringify(e.params) + ":" + e.url + ":" + a;
}, be = (e, a) => D.get(a)?.get(e), xe = (e, a, l) => {
  D.has(a) || D.set(a, /* @__PURE__ */ new Map()), D.get(a)?.set(e, l);
}, we = (e, a, l, t) => {
  const u = $([]), b = $(!1), d = $(0);
  let c = "", s;
  e && !e.params.limit && (e.params.limit = 100);
  const n = async () => {
    if (!e) return;
    const y = t ? Te(e) : void 0;
    if (y) {
      const I = be(y, e.path);
      if (I)
        return e.abortByFingerprint(), I;
    }
    const h = await e.call();
    if (h.errors) return;
    if (!Array.isArray(h.result)) {
      console.warn("Array expected in `res.result`");
      return;
    }
    const x = h.result.findIndex((I) => I.id === void 0 || I.name === void 0);
    if (x !== -1) {
      console.warn(`В result[${x}] нет id или name`);
      return;
    }
    return y && xe(y, e.path, h), h;
  }, v = async (y) => {
    if (!e) return;
    if (y) {
      if (!s || b.value) return;
      e.params.offset = s;
    } else
      e.params.offset = 0;
    a?.(e, c), b.value = !0;
    const h = await n();
    b.value = !1, d.value++, h && (s = h.nextOffset, y ? u.value = u.value.concat(h.result) : u.value = h.result);
  }, i = pe(() => v(!1), 200);
  return {
    apiRequest: e,
    items: u,
    isLoading: b,
    countLoading: d,
    load: v,
    setSearchTextAndLoad: (y, h = !0) => {
      if (e) {
        if (y.length < l) {
          e.abortByFingerprint(), u.value = [];
          return;
        }
        y === c && u.value.length || (c = y, h ? i() : v(!1));
      }
    }
  };
}, le = 0, K = null, _ = (e, a, l = !0) => l && a.id === K ? Array.isArray(e) ? e.some((t) => t.id === a.id && t.name === a.name) : a.name === e.name : Array.isArray(e) ? e.some((t) => t.id === a.id) : a.id === e.id, Ke = (e, a, l) => {
  let t = e.params.filters ?? [];
  t = t.filter((u) => u.name !== l), a && t.push(Ae(l, "CONTAINS", [a])), e.changeParams({ filters: t });
}, Se = (e, a, l, t, u, b, d, c, s) => {
  const n = $(""), v = {
    id: le,
    name: ve().Common.All
  }, i = () => {
    n.value = "";
  }, A = () => !(!s.apiRequest || n.value.length >= c), y = N(() => {
    const r = [];
    return !t && u.value && (typeof u.value == "string" && (v.name = u.value), r.push(v)), l.value?.forEach((C) => r.push({ ...C })), r;
  }), h = $([]), x = () => {
    h.value = I();
  }, I = () => {
    const r = n.value.toLowerCase(), C = ge(r);
    let o = [], w;
    const T = [], j = () => {
      T.at(-1)?.listItemProps?.type === "delimiter" && T.pop(), T.length && (w && o.push(w), o.push(...T), T.length = 0);
    };
    for (const k of y.value)
      switch (k.listItemProps?.type) {
        case "title":
          j(), w = k;
          break;
        case "delimiter":
          if (T.length) {
            let G = T.length;
            T.at(-1)?.listItemProps?.type === "delimiter" && G--, T[G] = k;
          }
          break;
        default:
          const V = k.name.toLowerCase();
          (k.id === Number(r) || V.includes(r) || V.includes(C)) && (V === r || V === C ? T.unshift(k) : T.push(k));
      }
    if (j(), o.push(...s.items.value), b.value && n.value && // результаты могут быть найдены, но не точные, тогда предложить добавить элемент
    !o.find((k) => k.name.toLowerCase() === r)) {
      const k = {
        id: K,
        name: n.value
      };
      o.push(k);
    }
    return t && (o = o.filter((k) => !_(e.value, k))), o;
  }, q = (r) => {
    r.listItemProps?.type === "title" || r.listItemProps?.type === "delimiter" || (t && Array.isArray(e.value) ? _(e.value, r) || (e.value = [...e.value, r]) : e.value = r, r.id === K && a("appendItem", r), setTimeout(() => {
      i();
    }));
  };
  if (s.apiRequest) {
    const r = [l, s.items];
    t && r.push(e), H(r, () => {
      x();
    });
  } else
    H([e, l, n], () => {
      x();
    }, {
      immediate: !0,
      // слежение за изменениями `items`
      deep: 2
    });
  return {
    searchText: n,
    resetSearch: i,
    genIsShort: A,
    itemsForShow: h,
    selectItem: q,
    selectNextItem: () => {
      if (Array.isArray(e.value)) return;
      const r = h.value.filter((w) => !["title", "delimiter"].includes(w.listItemProps?.type ?? "")), o = (r.findIndex((w) => w.id === e.value.id) + 1) % r.length;
      e.value = { ...r[o] };
    },
    deleteItemByItem: async (r) => {
      Array.isArray(e.value) && (e.value = e.value.filter((C) => C.id !== r.id || C.name !== r.name));
    }
  };
}, Be = {
  key: 0,
  class: "top-selector2_activeItems"
}, Me = {
  key: 1,
  class: "top-selector2_activeName top-ellipsis"
}, Pe = {
  key: 2,
  class: "top-selector2_placeholder top-ellipsis"
}, qe = /* @__PURE__ */ J({
  __name: "selector2",
  props: /* @__PURE__ */ W({
    modelValue: {},
    items: { default: () => [] },
    title: {},
    disabled: { type: Boolean },
    icon: {},
    modificator: {},
    size: { default: "s" },
    isError: { type: Boolean },
    openByFocusInput: { type: Boolean, default: void 0 },
    searchType: { default: "popup" },
    placeholder: {},
    api: {},
    apiSetSearchParams: {},
    minLength: { default: 0 },
    useCache: { type: Boolean },
    appendSearchToResult: { type: Boolean },
    multiselect: { type: Boolean },
    useAllItem: { type: [Boolean, String] },
    addChanger: { type: Boolean },
    buttonProps: {},
    selectedAsPlaceholder: { type: Boolean }
  }, {
    modelValue: { required: !0 },
    modelModifiers: {}
  }),
  emits: /* @__PURE__ */ W(["appendItem"], ["update:modelValue"]),
  setup(e, { expose: a, emit: l }) {
    const t = e, u = ee(e, "modelValue"), b = l;
    a({
      /**
       * Сброс локального кеша и кеша api
       *
       * @param resetAPICache - Сбросить API кеш, по умолчанию не сбрасывается. Для случаев, когда загруженные данные становятся неактуальными
       */
      resetCache: (m = !1) => {
        c.apiRequest && (m && Ce(c.apiRequest.path), c.items.value = [], c.countLoading.value = 0, c.apiRequest.params.offset = 0, requestAnimationFrame(() => {
          s.itemsForShow.value = [];
        }), i()?.elPopup && c.setSearchTextAndLoad(s.searchText.value));
      }
    });
    const d = N(() => t.searchType === "inline" && t.multiselect || t.searchType === "inline" && Y.state.isMobile ? "popup" : t.searchType), c = we(t.api, t.apiSetSearchParams, t.minLength, t.useCache), s = Se(
      u,
      b,
      O(t, "items"),
      t.multiselect,
      O(t, "useAllItem"),
      O(t, "appendSearchToResult"),
      d,
      t.minLength,
      c
    ), n = N(() => t.buttonProps ? "TopButton" : d.value === "inline" ? "TopInput" : "div"), v = $(null), i = () => v.value?.popup;
    c.apiRequest && H(s.searchText, () => {
      c.setSearchTextAndLoad(s.searchText.value);
    });
    const A = N(() => Array.isArray(u.value) || t.multiselect || !t.selectedAsPlaceholder && d.value !== "inline" ? t.placeholder : u.value?.name || t.placeholder), y = (m) => {
      let p = !1;
      switch (m.key) {
        case "Delete":
        case "Backspace":
          Array.isArray(u.value) && (m.preventDefault(), m.stopPropagation(), u.value.pop());
          break;
        case "ArrowUp":
        case "ArrowRight":
        case "ArrowDown":
        case "ArrowLeft":
        case "Enter":
        case " ":
          p = !0;
          break;
        case "Escape":
          d.value === "inline" && s.resetSearch();
          break;
      }
      const r = m.key.length === 1 && !m.ctrlKey && !m.metaKey;
      (d.value === "popup" || d.value === "inline") && r && (p = !0), i()?.elPopup && (p = !1), p && (d.value === "popup" && (m.preventDefault(), m.stopPropagation(), r && (s.searchText.value || (s.searchText.value = m.key))), m.currentTarget?.click());
    }, h = (m) => {
      m.preventDefault(), s.selectNextItem();
    }, x = () => {
      c.apiRequest && c.setSearchTextAndLoad(s.searchText.value, !1);
    }, I = () => {
      d.value === "popup" && s.searchText.value && s.resetSearch();
    }, q = (m) => {
      const p = m.target;
      p.scrollTop / (p.scrollHeight - p.offsetHeight) > 0.8 && c.load(!0);
    };
    return (m, p) => {
      const r = ie("TopLoadbar"), C = ue("top-focus");
      return g(), S(f(ye), {
        ref_key: "popupRef",
        ref: v,
        onOpen: p[3] || (p[3] = (o) => x()),
        onClose: p[4] || (p[4] = (o) => I()),
        onScrollContentList: p[5] || (p[5] = (o) => f(c) ? q(o) : void 0),
        notch: !1,
        transitionDuration: 0,
        openByFocusInput: d.value === "inline" && (e.openByFocusInput ?? !0),
        disabled: d.value === "inline" && f(s).genIsShort()
      }, U({
        opener: B(() => [
          Q((g(), S(fe(n.value), R(e.buttonProps, {
            class: {
              "top-selector2": !0,
              "top-selector2-multiselect": e.multiselect,
              ["top-selector2-" + e.modificator]: !!e.modificator,
              "top-as-input": !e.buttonProps && d.value !== "inline",
              "top-as-selector": !0,
              ["top-size_" + e.size]: !0,
              "top-disabled": e.disabled,
              "top-forms-focusable": !e.disabled,
              "top-error": e.isError
            },
            icon: e.icon,
            tabindex: "0",
            onKeydown: y,
            onBlur: p[0] || (p[0] = (o) => d.value === "inline" && f(s).resetSearch()),
            placeholder: A.value,
            title: e.title,
            captionType: d.value === "inline" && e.title !== void 0 ? "top" : void 0,
            modelValue: f(s).searchText.value,
            "onUpdate:modelValue": p[1] || (p[1] = (o) => f(s).searchText.value = o)
          }), {
            default: B(() => [
              e.multiselect ? (g(), L("div", Be, [
                (g(!0), L(F, null, z(u.value, (o) => (g(), S(Le, {
                  id: o.id,
                  name: o.name,
                  onDelete: f(s).deleteItemByItem
                }, null, 8, ["id", "name", "onDelete"]))), 256))
              ])) : M("", !0),
              d.value !== "inline" && !e.multiselect ? (g(), L("span", Me, P(Array.isArray(u.value) ? "" : u.value.name), 1)) : M("", !0),
              e.multiselect && !u.value.length ? (g(), L("span", Pe, P(A.value), 1)) : M("", !0),
              e.addChanger && !e.buttonProps && !e.multiselect && f(s).itemsForShow.value.length > 1 && !e.disabled ? (g(), L("span", {
                key: 3,
                class: "top-changer top-changer-selector",
                "data-top-popup-disabled": "true",
                onClick: h
              })) : M("", !0)
            ]),
            _: 1
          }, 16, ["class", "icon", "placeholder", "title", "captionType", "modelValue"])), [
            [
              C,
              e.isError,
              void 0,
              { onupdate: !0 }
            ]
          ])
        ]),
        contentList: B(() => [
          (g(!0), L(F, null, z(f(s).itemsForShow.value, (o) => (g(), S(f(Z), R({
            key: o.id ?? void 0,
            class: {
              "top-active": !Array.isArray(u.value) && !e.multiselect && u.value.id === o.id && u.value.name === o.name,
              "top-selector2_item-all": o.id === f(le),
              "top-selector2_item-new": o.id === f(K)
            }
          }, { ref_for: !0 }, o.listItemProps, {
            closeByClick: !e.multiselect || f(Y).state.isMobile,
            onClick: (w) => f(s).selectItem(o)
          }), {
            default: B(() => [
              m.$slots.item ? ce(m.$slots, "item", {
                key: 0,
                item: o
              }) : (g(), L(F, { key: 1 }, [
                E(P(o.name), 1)
              ], 64))
            ]),
            _: 2
          }, 1040, ["class", "closeByClick", "onClick"]))), 128)),
          !f(s).itemsForShow.value.length && !f(s).genIsShort() ? (g(), S(f(Z), {
            key: 0,
            type: "regular"
          }, {
            default: B(() => [
              !f(c).isLoading.value || f(c).countLoading.value ? (g(), L(F, { key: 0 }, [
                E(P(m.$i18n.Common.No_results), 1)
              ], 64)) : (g(), S(f(me), {
                key: 1,
                type: "circles"
              }))
            ]),
            _: 1
          })) : M("", !0),
          f(c).countLoading.value && f(c).isLoading.value && d.value === "inline" ? (g(), S(r, { key: 1 })) : M("", !0)
        ]),
        _: 2
      }, [
        d.value === "popup" ? {
          name: "widget",
          fn: B(() => [
            Q(te(f(he), {
              title: "Поиск",
              icon: "",
              modelValue: f(s).searchText.value,
              "onUpdate:modelValue": p[2] || (p[2] = (o) => f(s).searchText.value = o),
              isLoading: !!f(c).countLoading.value && f(c).isLoading.value,
              placeholder: A.value
            }, null, 8, ["modelValue", "isLoading", "placeholder"]), [
              [
                C,
                u.value,
                void 0,
                { onupdate: !0 }
              ]
            ])
          ]),
          key: "0"
        } : void 0
      ]), 1032, ["openByFocusInput", "disabled"]);
    };
  }
});
export {
  K as I,
  qe as _,
  Re as a,
  Ke as b,
  le as c
};
//# sourceMappingURL=policy.vue_vue_type_style_index_0_lang-LkyBILW6.es.js.map
