
		import { Core as _autoloadCSSCore } from '../core/app.js';
		const fileNames = ['../assets/tabsView.css'].map(fileName => import.meta.resolve(fileName));
		_autoloadCSSCore.insertCSSLinkToPage(fileNames, true);
	
import { watch as k, computed as I, ref as f, defineComponent as M, createBlock as m, openBlock as r, resolveDynamicComponent as B, normalizeClass as g, unref as s, withCtx as b, renderSlot as v, createElementBlock as p, createCommentVNode as S, mergeModels as R, useModel as C, useSlots as j, onMounted as x, onUnmounted as E, createElementVNode as y, toDisplayString as P, Fragment as F, createTextVNode as W, markRaw as J, createVNode as U, KeepAlive as q } from "vue";
import { C as V, T as G, k as Q } from "../.chunks/forms-BAUgA7Ct.es.js";
import { getHash as O, genHash as X, setHash as Y, delHash as Z } from "../utils/route.js";
import { u as ee, d as te } from "../.chunks/store-CX_6ZXhO.es.js";
import { b as z, _ as oe } from "../.chunks/popupHint.vue_vue_type_style_index_0_lang-BIWw5zUX.es.js";
import { sleepWhile as ae } from "../utils/system.js";
const D = (t, o) => `top:${String(t)}:${o}`, ne = (t, o) => {
  if (!o.$id) return;
  const e = D(t, o.$id);
  try {
    const a = JSON.parse(localStorage.getItem(e));
    typeof a == typeof o[t] && (o[t] = a);
  } catch {
    console.warn(new Error(`В localStorage[${e}] не корректный json`));
  }
}, se = (t, o) => {
  if (!o.$id) return;
  const e = D(t, o.$id);
  k(() => o[t], () => {
    localStorage.setItem(e, JSON.stringify(o[t]));
  }, { immediate: !0 });
}, T = {
  loadLocalStorge: ne,
  addSaverLocalStorge: se
}, H = /* @__PURE__ */ new Set();
addEventListener("popstate", (t) => {
  H.forEach((o) => o(t));
});
const K = Symbol(), ie = (t, o) => {
  const e = te(K, () => {
    const a = I(() => t.showMenuInPopup ?? V.state.isMobile), c = I(() => t.pageMod), d = f(!1), l = f(void 0), i = f(!0);
    return {
      showMenuInPopup: a,
      pageMod: c,
      isShort: d,
      activeItemName: o,
      component: l,
      scrollable: i
    };
  }, t.idState);
  if (t.isShortable) {
    const a = "isShort";
    T.loadLocalStorge(a, e), T.addSaverLocalStorge(a, e);
  }
  if (e.$id) {
    const a = (c) => {
      o.value = O(e.$id);
    };
    H.add(a);
  }
  return e;
}, L = () => ee(K), le = {
  key: 1,
  class: "top-ellipsis"
}, w = /* @__PURE__ */ M({
  __name: "menuItem",
  props: {
    name: {},
    href: {},
    icon: {},
    disabled: { type: Boolean },
    component: { default: void 0 },
    scrollable: { type: Boolean, default: !0 }
  },
  setup(t) {
    const o = t, e = L(), a = I(() => o.name && e.$id ? X(e.$id, o.name) : o.href), c = I(() => e.showMenuInPopup ? z : a ? "a" : "button"), d = (l) => {
      !o.href && a.value && l.preventDefault(), o.name && (e.activeItemName = o.name);
    };
    return (l, i) => (r(), m(B(c.value), {
      target: "_self",
      class: g({
        "top-tabsView_menuItem": !s(e).showMenuInPopup,
        "top-active": t.name && s(e).activeItemName === t.name,
        "top-disabled": t.disabled,
        "top-spa-disabled": !0
      }),
      href: a.value,
      "data-top-icon": t.icon || void 0,
      disabled: t.disabled || void 0,
      onClick: d
    }, {
      default: b(() => [
        s(e).showMenuInPopup ? v(l.$slots, "default", { key: 0 }) : l.$slots.default && !s(e).isShort ? (r(), p("span", le, [
          v(l.$slots, "default")
        ])) : S("", !0)
      ]),
      _: 3
    }, 8, ["class", "href", "data-top-icon", "disabled"]));
  }
}), A = (t) => t?.name === "AsyncComponentWrapper" && !t?.__asyncResolved, re = async (t, o) => {
  t?.name === "AsyncComponentWrapper" && (t?.__asyncResolved || (t.__asyncLoader(), await ae(() => o() && A(t), 200)));
}, ce = { class: "top-tabsView_menuOpener" }, ue = ["data-top-icon"], de = { class: "top-ellipsis" }, pe = { class: "top-tabsView_menuList" }, me = {
  key: 0,
  class: "top-tabsView_menuFooter"
}, fe = /* @__PURE__ */ M({
  __name: "menu",
  props: /* @__PURE__ */ R({
    isShortable: { type: Boolean },
    isLoading: { type: Boolean }
  }, {
    isLoading: {},
    isLoadingModifiers: {}
  }),
  emits: ["update:isLoading"],
  setup(t) {
    const o = C(t, "isLoading"), e = L(), a = j(), c = /* @__PURE__ */ new Map(), d = () => {
      if (!a.default) return;
      const u = a.default({}).find((n) => n.key === "_menu");
      u && l(u.children);
    }, l = (u) => {
      u.forEach((n) => {
        if (n.type.__name && n.type.__name !== w.__name) return;
        if (!n.type.__name && typeof n.children == "object") {
          l(n.children);
          return;
        }
        if (!n.props?.name || n.props?.disabled) return;
        const N = {
          title: (n.children.default?.()[0].children).trim(),
          icon: n.props.icon,
          component: n.props.component ? J(n.props.component) : w.props.component.default,
          scrollable: n.props.scrollable ?? w.props.scrollable.default
        };
        c.set(n.props.name, N);
      });
    }, i = f(null);
    let h = 0;
    k(
      () => e.activeItemName,
      async () => {
        const u = ++h;
        if (c.size === 0 && d(), c.size === 0) {
          e.activeItemName = "";
          return;
        }
        if (i.value = c.get(e.activeItemName) ?? null, !i.value && e.$id) {
          const n = O(e.$id);
          if (i.value = c.get(n) ?? null, i.value) {
            e.activeItemName = n;
            return;
          }
        }
        if (!i.value) {
          e.activeItemName = c.keys().next().value;
          return;
        }
        if (i.value.component === e.component) {
          o.value = !1;
          return;
        }
        e.$id && Y(e.$id, e.activeItemName, !1), o.value = !0, await re(i.value.component, () => u === h), u === h && (e.scrollable = i.value.scrollable, e.component = i.value.component, i.value && !e.component && console.warn(`Компонент вкладки ${e.activeItemName} не найден. Добавьте props.component для пункта меню ${e.activeItemName}.`));
      },
      { immediate: !0 }
    );
    const _ = f();
    let $;
    return x(() => {
      $ = new ResizeObserver(() => {
        _.value.parentElement.style.setProperty("--top-tabsView-contents-offset-top", _.value.offsetHeight + "px");
      }), $.observe(_.value);
    }), E(() => {
      $.disconnect();
    }), (u, n) => (r(), p("div", {
      ref_key: "elRef",
      ref: _,
      class: g({
        "top-tabsView_menu": !0,
        "top-tabsView_menu-inPopup_0": !s(e).showMenuInPopup,
        "top-tabsView_menu-inPopup_1": s(e).showMenuInPopup,
        "top-tabsView_menu-short": s(e).isShort && !s(e).showMenuInPopup
      })
    }, [
      s(e).showMenuInPopup ? (r(), m(s(oe), { key: 0 }, {
        opener: b(() => [
          y("div", ce, [
            i.value ? (r(), p("div", {
              key: 0,
              class: "top-tabsView_menuOpenerActiveItem",
              "data-top-icon": i.value.icon
            }, [
              y("span", de, P(i.value.title), 1)
            ], 8, ue)) : S("", !0),
            n[1] || (n[1] = y("div", {
              class: "top-tabsView_menuOpenerIcon",
              "data-top-icon": ""
            }, null, -1))
          ])
        ]),
        contentList: b(() => [
          v(u.$slots, "default")
        ]),
        _: 3
      })) : (r(), p(F, { key: 1 }, [
        y("div", pe, [
          v(u.$slots, "default")
        ]),
        t.isShortable ? (r(), p("div", me, [
          t.isShortable ? (r(), m(w, {
            key: 0,
            icon: s(e).isShort ? "" : "",
            onClick: n[0] || (n[0] = (N) => s(e).isShort = !s(e).isShort)
          }, {
            default: b(() => [
              W(P(s(e).isShort ? "" : "Свернуть"), 1)
            ]),
            _: 1
          }, 8, ["icon"])) : S("", !0)
        ])) : S("", !0)
      ], 64))
    ], 2));
  }
}), $e = /* @__PURE__ */ M({
  __name: "tabsView",
  props: /* @__PURE__ */ R({
    modelValue: {},
    pageMod: { type: Boolean },
    showMenuInPopup: { type: Boolean, default: void 0 },
    isShortable: { type: Boolean, default: !1 },
    idState: {}
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(t) {
    const o = t, e = C(t, "modelValue"), a = ie(o, e), c = Math.random();
    o.pageMod && V.state.documentClassModificators.set(c, "top-hasTabsViewPageMod"), E(() => {
      o.pageMod && V.state.documentClassModificators.delete(c), a.$id && Z(a.$id, a.activeItemName, !0);
    });
    const d = f(), l = f(!1);
    return k([d, () => a.component], () => {
      l.value = A(a.component);
    }, { immediate: !0 }), (i, h) => (r(), p("div", {
      class: g({
        "top-tabsView": !0,
        "top-tabsView-pageMod": o.pageMod,
        "top-tabsView-inPopup": s(a).showMenuInPopup
      })
    }, [
      U(fe, {
        isShortable: t.isShortable,
        isLoading: l.value,
        "onUpdate:isLoading": h[0] || (h[0] = (_) => l.value = _)
      }, {
        default: b(() => [
          v(i.$slots, "menu")
        ]),
        _: 3
      }, 8, ["isShortable", "isLoading"]),
      y("div", {
        class: g({
          "top-tabsView_contents": !0,
          "top-tabsView_contents-isLoading": l.value,
          "top-tabsView_contents-noScrollable": !s(a).scrollable
        })
      }, [
        l.value ? (r(), m(G, { key: 0 })) : S("", !0),
        (r(), m(q, null, [
          (r(), m(B(s(a).component), {
            ref_key: "componentRef",
            ref: d
          }, null, 512))
        ], 1024))
      ], 2)
    ], 2));
  }
}), ve = {}, he = { class: "top-tabsView_menuDelimeter" };
function _e(t, o) {
  return r(), p("div", he);
}
const be = /* @__PURE__ */ Q(ve, [["render", _e]]), Ve = /* @__PURE__ */ M({
  __name: "menuTitle",
  props: {
    isSubtitle: { type: Boolean }
  },
  setup(t) {
    const o = L();
    return (e, a) => s(o).showMenuInPopup ? (r(), m(s(z), {
      key: 0,
      type: "title"
    }, {
      default: b(() => [
        v(e.$slots, "default")
      ]),
      _: 3
    })) : s(o).isShort ? (r(), m(be, { key: 1 })) : (r(), p("div", {
      key: 2,
      class: g({
        "top-tabsView_menuTitle": !0,
        "top-tabsView_menuTitle-subtitle": t.isSubtitle
      })
    }, [
      v(e.$slots, "default")
    ], 2));
  }
});
export {
  $e as TopTabsView,
  w as TopTabsViewMenuItem,
  Ve as TopTabsViewMenuTitle
};
//# sourceMappingURL=tabsView.js.map
