import { defineComponent as v, provide as f, onMounted as w, getCurrentInstance as b, watch as D, createElementBlock as d, openBlock as i, unref as a, normalizeStyle as m, normalizeClass as r, createElementVNode as s, renderSlot as n, computed as C, resolveDirective as $, createCommentVNode as p, createBlock as h, Teleport as g, withDirectives as k } from "vue";
import { g as T } from "./dialogs.vue_vue_type_script_setup_true_lang-D8WYUfXI.es.js";
import { C as A } from "./forms-BpbQYyEQ.es.js";
import { b as B } from "./utils-MzIaxkRQ.es.js";
const W = ["id", "data-view-page-active", "data-modal", "data-position"], G = /* @__PURE__ */ v({
  __name: "dialog",
  props: {
    id: {},
    pageActive: {},
    width: { default: "600px" },
    height: { default: "auto" },
    modal: { type: Boolean, default: !0 },
    position: {},
    historyType: { default: "push" },
    classes: {}
  },
  emits: ["open", "close"],
  setup(e) {
    const o = T(e.id);
    if (!o)
      throw new Error("TopDialog cannot be used in a template, use useTopDialog() / useAsyncTopDialog()");
    return f("dialogWorker", o), w(() => {
      const l = b(), t = l.parent;
      if (t?.parent?.type.name !== "DialogWrapper")
        throw new Error("TopDialog cannot be used in a template, use useTopDialog()");
      if (Array.isArray(t.subTree.children) && t.subTree.children.length !== 1)
        throw new Error("TopDialog can has only one root element");
      o.onMounted(t, l);
    }), D(o.isOpened, () => {
      o.isReady.value = !0;
    }, {
      flush: "post",
      once: !0
    }), (l, t) => (i(), d("div", {
      id: a(o).idAttr,
      class: r(["top-dialog", e.classes]),
      style: m({
        "--top-dialog-width": e.width,
        "--top-dialog-height": e.height
      }),
      tabindex: "-1",
      "data-view-page-active": a(o).pageActive.value,
      "data-modal": e.modal,
      "data-position": e.position
    }, [
      t[0] || (t[0] = s("div", { class: "modal-layer modal-layer-header" }, null, -1)),
      s("div", {
        class: "modal-layer modal-layer-body",
        style: m({ "min-height": e.height + "px" })
      }, null, 4),
      n(l.$slots, "default")
    ], 14, W));
  }
}), E = {
  key: 0,
  style: { display: "none" }
}, N = ["data-order", "data-view-page"], S = { class: "modal-header" }, L = { class: "top-title" }, M = { class: "buttons" }, P = ["title"], z = ["title"], F = ["data-order", "data-view-page"], R = { class: "modal-body" }, H = /* @__PURE__ */ v({
  __name: "page",
  props: {
    isLoading: { type: Boolean },
    name: {},
    order: { default: 0 },
    prevName: {},
    footerFullWith: { type: Boolean }
  },
  setup(e) {
    const c = e, o = B(), l = C(() => ({
      active: o.pageActive?.value === c.name,
      "i-load-data": c.isLoading || o.isLoadingPage.value
    }));
    return (t, u) => {
      const y = $("top-scroll-shadow");
      return a(o).isReady.value ? (i(), d("div", E, [
        (i(), h(g, {
          to: "#" + a(o).idAttr + " .modal-layer-header",
          disabled: !a(o).needShowPage(e.name)
        }, [
          s("div", {
            "data-order": e.order,
            "data-view-page": e.name,
            class: r(l.value)
          }, [
            s("div", S, [
              s("div", L, [
                n(t.$slots, "header")
              ]),
              s("div", M, [
                n(t.$slots, "headerButtons")
              ]),
              a(A).state.isMobile && e.prevName ? (i(), d("div", {
                key: 0,
                class: "close",
                title: t.$i18n.Common.Back,
                "data-top-icon": "",
                onClick: u[0] || (u[0] = (V) => a(o).open(e.prevName))
              }, null, 8, P)) : (i(), d("div", {
                key: 1,
                class: "close",
                title: t.$i18n.Common.Close,
                "data-top-icon": "",
                "data-action": "top-dialog-close"
              }, null, 8, z))
            ])
          ], 10, N)
        ], 8, ["to", "disabled"])),
        (i(), h(g, {
          to: "#" + a(o).idAttr + " .modal-layer-body",
          disabled: !a(o).needShowPage(e.name)
        }, [
          s("div", {
            "data-order": e.order,
            "data-view-page": e.name,
            class: r(["has_scroll_container", l.value]),
            style: m({ "--top-dialog-footer-height": t.$slots.footer ? void 0 : "0px" })
          }, [
            k((i(), d("div", R, [
              n(t.$slots, "body")
            ])), [
              [y]
            ]),
            t.$slots.footer ? (i(), d("div", {
              key: 0,
              class: r(["modal-footer", {
                "modal-footer-fullWith": e.footerFullWith
              }])
            }, [
              n(t.$slots, "footer")
            ], 2)) : p("", !0)
          ], 14, F)
        ], 8, ["to", "disabled"]))
      ])) : p("", !0);
    };
  }
});
export {
  G as _,
  H as a
};
//# sourceMappingURL=page.vue_vue_type_script_setup_true_lang-D3_o-DIM.es.js.map
