import { nextTick as T } from "vue";
import { C as u } from "./forms-BpbQYyEQ.es.js";
import { TopPopupWorker as M } from "../popup/worker.js";
import { sleep as j, waitWhile as B } from "../utils/system.js";
import { historySetState as H, setHashs as O } from "../utils/route.js";
import { connectScrollShadow as I } from "../utils/scroll.js";
import { T as g, g as k } from "./dialogs.vue_vue_type_script_setup_true_lang-D8WYUfXI.es.js";
import { querySelectorVisible as S, querySelectorAllArray as p, isVisible as c } from "../utils/dom.js";
$;
let E = !1;
const F = () => {
  E || (E = !0, document.addEventListener("keydown", (e) => {
    if (e.key !== "Escape" || !e.target || !(e.target instanceof HTMLElement)) return;
    const t = e.target;
    if (!t.closest(".ui-dialog") || t.contentEditable === "true" || t.contentEditable === "plaintext-only" || S(document.documentElement, ".top-popup-wrapper") || t.classList.contains("autocomplete") || S(document.documentElement, ".fancybox-container")) return;
    const a = p(document, ".ui-dialog-content").filter((o) => c(o));
    $(a[a.length - 1]).dialog("close");
  }), document.addEventListener("click", (e) => {
    if (!(e.target instanceof HTMLElement)) return;
    const t = e.target.closest('[data-action="top-dialog-close"]');
    if (!t) return;
    e.preventDefault();
    const a = t.closest(".ui-dialog-content");
    if (!a) return;
    const o = t.dataset.toView;
    if (o == "toPrevPage()") {
      y.toPrevPage(a);
      return;
    }
    if (o) {
      const r = o.split("-"), d = r.shift(), l = r.join("-");
      if (!d) return;
      const h = y.getElDialogById(d);
      if (!h) return;
      const n = p(h, `[data-view-page="${l}"]`);
      if (!n) return;
      if (!c(n[0])) {
        const s = g.genViewPageHash(o, "prev");
        H(!1, s);
        return;
      }
    }
    $(a).dialog("close");
  }), document.addEventListener("submit", (e) => {
    const t = e.target;
    (t.matches(".modal-body > form") || t.matches(".modal-layer-body > form")) && e.preventDefault();
  }), document.addEventListener("keypress", (e) => {
    if (!(e.target instanceof HTMLElement)) return;
    const t = e.target;
    if (!(!t.closest(".ui-dialog .modal-body") || !(t.matches("input:not(.searcher), textarea:not(.searcher), select:not(.searcher), button:not(.searcher)") || t.hasAttribute("contenteditable"))) && e.key === "Enter") {
      if (t.classList.contains("autocomplete")) {
        e.preventDefault();
        return;
      }
      if (t.tagName === "TEXTAREA") {
        if (!e.ctrlKey && !e.metaKey) return;
        const i = t.closest("form");
        i && p(i, 'button[type="submit"]').concat(p(i, 'input[type="submit"]')).find((d) => c(d))?.click();
      }
    }
  }), document.addEventListener("click", function(e) {
    if (!(e.target instanceof HTMLElement) || !e.target.classList.contains("ui-widget-overlay")) return;
    let a, o = 0;
    if (p(document, ".ui-dialog").filter((r) => c(r)).forEach((r) => {
      const d = Number(window.getComputedStyle(r).zIndex);
      d < o || (a = r, o = d);
    }), a) {
      const r = a.querySelector(".ui-dialog-content");
      $(r).dialog("close");
    }
  }), window.addEventListener("resize", y.recalcPositions), y.recalcPositions());
}, K = ':root{--dialog-border-color: var(--color-line-1);--dialog-loading-duration: 10s;--top-dialog-footer-height: var(--top-forms-base-height_s)}html.with_dialog{overflow:hidden!important}a[data-to-view]{cursor:pointer}.ui-widget-overlay{background:#040404;opacity:.5;filter:Alpha(Opacity=50)}.ui-dialog{border-radius:8px;border:none;padding:0}.ui-dialog.ui-widget{border:none}.ui-dialog-titlebar{display:none}.ui-dialog .ui-dialog-content{padding:0;overflow:visible}.ui-dialog .project_name{word-break:break-all}.ui-dialog-content{--dialog-header-height: 50px;--dialog-layer-pageSelector: 0px}.ui-dialog-content-withPageSelector{--dialog-layer-pageSelector: 42px}.modal-header,.modal-body,.modal-footer{font-size:14px;position:relative}.modal-body{padding:var(--padding-default)}.modal-body:has(>.topTable:first-child){padding-top:calc(var(--padding-default) / 4)}.modal-header{border-bottom:1px solid var(--dialog-border-color);height:var(--dialog-header-height);padding:0 var(--padding-default);display:flex;justify-content:space-between;align-items:center;gap:var(--top-padding-2)}.modal-header>*{padding:10px 0;font-size:16px}.modal-header>.top-title{margin:0;font-weight:400;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex-grow:1;order:50;display:flex;align-items:center}.modal-header>.top-title>div[class*=icon]{display:none}.modal-header>div:not(.top-title){order:60}.modal-header>div.close{--top-icon-color: var(--color-text-2);cursor:pointer;background:var(--color-layout-front-1);font-size:16px;order:100;animation-name:none!important}.modal-header>div.close:hover{--top-icon-color: var(--color-text-1)}.modal-header .links_icons{position:absolute;right:50px}.modal-header .links_icons [class*=icon-]{width:auto;height:auto;padding:0 5px;color:#d6dee0}.modal-header .links_icons [class*=icon-].active{color:var(--color-bg-warning-1)}.modal-layer-pageSelector{padding:0 10px!important}.modal-body{max-height:calc(var(--100vh) - var(--dialog-header-height) - 1px - var(--dialog-layer-pageSelector) - var(--top-dialog-footer-height) - 1px);overflow-y:auto;overflow-x:hidden;box-sizing:border-box;flex-grow:1}.modal-body hr{margin:16px -15px}.modal-body h4{padding:0;margin:0 0 10px;line-height:normal}.modal-body .inner{padding:var(--padding-default);margin:0 calc(0px - var(--padding-default));position:relative}.modal-body .inner .bt{border-top:1px dashed var(--color-layout-front-primary-3);position:absolute;top:0;right:0;left:0}.modal-body .inner .bb{border-bottom:1px dashed var(--color-layout-front-primary-3);position:absolute;right:0;bottom:0;left:0}.modal-body .inner.color-1{background:var(--color-layout-front-primary-3);color:var(--color-text-1)}.modal-body .inner strong{color:var(--color-text-1)}.modal-body .comment{line-height:18px}.modal-footer{min-height:var(--top-dialog-footer-height);padding:var(--top-gap-2);display:flex;flex-shrink:0;align-items:center;justify-content:flex-end;gap:var(--top-gap-2)}.modal-footer .modal-footer-btn-left{margin-right:auto}.modal-footer>.btn.full_width,.modal-footer>.top-button.full_width{flex-grow:1;align-self:flex-end}.modal-footer-fullWith{flex-wrap:wrap}.modal-footer-fullWith>*{flex-grow:1}.modal-footer-fullWith>.top-info{flex-grow:5}.modal-footer-fullWith>*:empty{flex-grow:0}.ui-dialog-content>.modal-layer>[data-view-page]>input[type=submit]{position:absolute;visibility:hidden}.help_popup .modal-header{display:none}.help_popup .modal-header a{top:2px;z-index:10}.help_popup .modal-header .top-title{display:none}.modal-layer{overflow:hidden}.modal-layer a[data-top-icon]:empty{color:var(--color-text-4);text-decoration:none}.modal-layer>[data-view-page]>div>div.buttons{display:flex;white-space:nowrap;gap:var(--top-padding-1)}.modal-layer>[data-view-page]>div>div.buttons:empty{display:none}.modal-layer>[data-view-page]>div>div.buttons>div,.modal-layer>[data-view-page]>div>div.buttons>a{cursor:pointer;width:auto;height:auto;min-width:auto;min-height:auto;padding:10px 9px;color:var(--color-text-4)}.modal-layer>[data-view-page]>div>div.buttons>div:hover{color:var(--color-text-2)}.modal-layer>[data-view-page]>div>div.buttons>div.hidden{display:none!important}.ui-dialog-content[data-view-page-active]{display:flex!important;flex-direction:column;justify-items:stretch}.ui-dialog-content>.modal-layer{display:flex!important;align-items:stretch;position:relative}.ui-dialog-content.i-change-page>.modal-layer{overflow:hidden}.ui-dialog-content>.modal-layer>[data-view-page]{width:100%;position:relative;display:none;flex-direction:column;justify-content:space-between;animation:.3s cubic-bezier(.4,0,.2,1) forwards}.ui-dialog-content>.modal-layer>[data-view-page].active{display:flex}.ui-dialog-content>.modal-layer>[data-view-page].reverse{animation-direction:reverse}.ui-dialog-content>.modal-layer>[data-view-page].center-to-left,.ui-dialog-content>.modal-layer>[data-view-page].right-to-center{display:flex;position:absolute;inset:0}.ui-dialog-content>.modal-layer>[data-view-page].center-to-left>div,.ui-dialog-content>.modal-layer>[data-view-page].right-to-center>div{overflow:hidden}.ui-dialog-content>.modal-layer-header{border-bottom:1px solid var(--dialog-border-color);min-height:var(--dialog-header-height)}.ui-dialog-content>.modal-layer-header>[data-view-page]>.modal-header{border:none;background:none}.ui-dialog-content>.modal-layer-header>[data-view-page]>.modal-header>*{animation:.3s cubic-bezier(.4,0,.2,1) forwards}.ui-dialog-content>.modal-layer-header>[data-view-page].reverse>.modal-header>*{animation-direction:reverse}.ui-dialog-content>.modal-layer-header>[data-view-page].center-to-left>.modal-header>.top-title{animation-name:dialog-center-to-left-header-title}.ui-dialog-content>.modal-layer-header>[data-view-page].right-to-center>.modal-header>.top-title{animation-name:dialog-right-to-center-header-title}.ui-dialog-content>.modal-layer-header>[data-view-page].center-to-left>.modal-header>[class*=widget-]{animation-name:dialog-center-to-left-header-title}.ui-dialog-content>.modal-layer-header>[data-view-page].right-to-center>.modal-header>[class*=widget-]{animation-name:dialog-right-to-center-header-title}.ui-dialog-content>.modal-layer-header>[data-view-page].center-to-left>.modal-header>div{animation-name:dialog-center-to-left-header-icons}.ui-dialog-content>.modal-layer-header>[data-view-page].right-to-center>.modal-header>div{animation-name:dialog-right-to-center-header-icons}.ui-dialog-content>.modal-layer-body{border-radius:0 0 8px 8px;max-height:calc(var(--100vh) - var(--dialog-header-height) - var(--dialog-layer-pageSelector) - var(--toolbar-height));flex-grow:2}.ui-dialog-content.i-change-page>.modal-layer-body>[data-view-page]{background:var(--color-layout-front-1)}.ui-dialog-content>.modal-layer-body>[data-view-page].center-to-left{animation-name:dialog-center-to-left}.ui-dialog-content>.modal-layer-body>[data-view-page].right-to-center{animation-name:dialog-right-to-center}.ui-dialog-content .modal-footer .second_level{box-sizing:border-box;background:var(--color-layout-front-1);width:100%;min-height:25px;display:flex;align-items:center;justify-content:center}.ui-dialog-content .modal-footer .second_level input{border-radius:8px;width:100%;height:var(--top-forms-base-height);padding:var(--top-padding-1) var(--top-padding-3);box-sizing:border-box}.ui-dialog-content>.modal-layer-body>[data-view-page].i-load-data{pointer-events:none}.ui-dialog-content>.modal-layer-body>[data-view-page].i-load-data:before{content:" ";background:#378dc6;width:0;height:4px;position:absolute;top:0;left:0;z-index:100;animation:top-loadbar var(--dialog-loading-duration) forwards}.ui-dialog-content.modal-expanded{width:100vw!important;height:calc(var(--100vh) + 10px)!important}.modal-header>[data-widget]{padding:0 8px;position:absolute;inset:0;opacity:0;overflow:hidden;align-items:center;visibility:hidden;transition:opacity .3s;z-index:1}.modal-header>[data-widget=search] div.cancel{opacity:0;transform:translate(100%);transition:transform,opacity;transition-duration:.3s}[data-view-page].i-show-search .modal-header>:not([data-widget=search]){visibility:hidden}[data-view-page].i-show-search [data-widget=search]{visibility:visible;opacity:1}[data-view-page].i-show-search [data-widget=search] .cancel{transform:translate(0);opacity:1}[data-view-page]>.modal-header>*{transition:opacity .3s}[data-view-page].i-show-search>.modal-header>div.buttons{opacity:0}.modal-layer .top-popup-wrapper{height:100%!important}@keyframes dialog-center-to-left-header-title{0%{transform:translate(0);opacity:1}75%{opacity:0}to{transform:translate(-30%);opacity:0}}@keyframes dialog-right-to-center-header-title{0%{transform:translate(100%);opacity:0}25%{opacity:0}to{transform:translate(0);opacity:1}}@keyframes dialog-center-to-left-header-icons{0%{transform:translate(0);opacity:1}35%{transform:translate(-20%);opacity:0}to{transform:translate(-20%);opacity:0}}@keyframes dialog-right-to-center-header-icons{0%{transform:translate(20%);opacity:0}65%{transform:translate(20%);opacity:0}to{transform:translate(0);opacity:1}}@keyframes dialog-center-to-left{0%{transform:translate(0);filter:brightness(1)}to{transform:translate(-30%);filter:brightness(.9)}}@keyframes dialog-right-to-center{0%{transform:translate(100%);box-shadow:#0000001a 0 0 10px}to{transform:translate(0);box-shadow:#0003 0 0 10px}}@media only screen and (max-width:1480px){.win_side_panel_opener{display:none}}@media only screen and (min-width:1480px){.ui-dialog-content.with_side_panel{box-shadow:#0003 0 0 6px}.ui-dialog-content.with_side_panel .modal-layer-body{background:var(--color-layout-front-1)}[data-widget=side_panel]{--side_panel_width: calc((100vw - 900px)/2 - 28px) ;box-sizing:border-box;background:var(--color-layout-front-1);max-width:var(--side_panel_width);padding:18px;position:absolute;top:calc(var(--dialog-header-height) + 1px + var(--dialog-layer-pageSelector));bottom:calc(var(--top-dialog-footer-height) + 1px);z-index:-1;display:block;transition:.2s}.win_side_panel_left{border-radius:8px 0 0 8px;right:100%}.win_side_panel_right{border-radius:0 8px 8px 0;left:100%}.win_side_panel_closed.win_side_panel_left{right:calc(100% - var(--side_panel_width))}.win_side_panel_closed.win_side_panel_right{left:calc(100% - var(--side_panel_width))}[data-widget=side_panel] .template{display:block}[data-widget=side_panel] .template>.header,[data-widget=side_panel] .template>.footer{display:flex}.win_side_panel_opener{cursor:pointer;background:var(--color-cyan);color:#fff;padding:4px;position:absolute;top:20px}.win_side_panel_closed .win_side_panel_opener:not(:hover){opacity:.3}.win_side_panel_left .win_side_panel_opener{border-radius:4px 0 0 4px;right:100%}.win_side_panel_right .win_side_panel_opener{border-radius:0 6px 6px 0;left:100%}}@media only screen and (max-height:900px){html.with_dialog{background:#f1f1f1;overflow:hidden}.ui-dialog.me-tightly{border-radius:0;height:auto!important;position:fixed;top:0!important;bottom:0!important}.ui-dialog.me-tightly .ui-dialog-content{min-height:100%!important}.ui-dialog.me-tightly>div>.modal-body{position:absolute;top:var(--dialog-header-height);right:0;left:0;bottom:var(--dialog-header-height)}.ui-dialog.me-tightly>div>.modal-body:last-child{bottom:0}.ui-dialog.me-tightly>div>.modal-footer{position:absolute;right:0;bottom:0;left:0}.ui-dialog.me-tightly .modal-layer-body{border-radius:0;min-height:0!important}.ui-dialog.me-tightly .modal-layer-body .modal-footer{min-height:unset}}', R = 'html.with_dialog body{height:var(--100vh);overflow:hidden}.ui-widget-overlay{height:calc(100% - var(--toolbar-height))}.ui-dialog{border-radius:0;width:auto!important;height:auto!important;position:fixed;inset:0!important}.ui-dialog-content{width:100%!important;height:100%!important;min-width:0!important;max-width:100%!important}.modal-header>.top-title{text-align:center;font-size:14px}.modal-header>div.close{font-size:14px;order:1}.modal-header>div.close:before{content:""}.modal-body:last-child{bottom:0}.modal-footer{bottom:0}.modal-footer .second_level{padding:10px 8px}.modal-layer-body{min-height:0!important}.ui-dialog-content>.modal-layer-body{border-radius:0}.modal-body,.modal-footer{padding-right:12px;padding-left:12px}.modal-footer .btn:last-child{margin-right:12px}.modal-body .inner{padding:12px;margin:0 -12px;position:relative}', U = ".modal-menu-opener{order:1!important}.modal-menu-opener:before{--top-icon-size: 20px;--top-icon-color: #FFF;--top-icon-width: var(--top-icon-size);border-radius:50%;background:var(--color-bg-primary-1);padding:3px;transition:transform .1s}.modal-menu-opener:hover:before{background:var(--color-bg-primary-2)}.modal-menu-opener.top-active:before{background:var(--color-bg-primary-2);transform:scale(.8)}.modal-layer .top-popup-wrapper{background:transparent;width:auto!important;padding:0!important;margin:0!important;top:0!important;right:0!important;left:0!important;transition:background .3s}.modal-layer .top-popup-wrapper>.top-popup[class],.modal-layer .top-popup-wrapper.with_notch>.top-popup[class]{border-radius:8px;border:none;margin:12px!important;max-width:100%;max-height:calc(100% - 24px);inset:0 0 auto!important;overflow:auto;display:flex;flex-direction:column;opacity:1;transform:translateY(calc(-100% - 24px));transition:transform .3s}.modal-layer .top-popup>.top-popup_header{background:var(--color-theme-50)}.modal-layer .top-theme-lite .top-popup>.top-popup_header .select{border:none}.modal-layer .top-theme-lite .top-popup>.top-popup_header .select .text{color:#fff}.modal-layer .top-theme-lite .top-popup>.top-popup_header .select .arrow{background:none}.modal-layer .top-popup-wrapper-shown:not(.top-popup-wrapper-closed){pointer-events:auto;background:#34495e40}@media only screen and (min-width:1480px){.ui-dialog-content.with_side_panel{box-shadow:#0003 0 0 6px}.ui-dialog-content.with_side_panel .modal-layer-body{background:var(--color-layout-front-1)}[data-widget=side_panel]{--side_panel_width: calc((100vw - 900px)/2 - 28px) ;box-sizing:border-box;background:var(--color-layout-front-1);max-width:var(--side_panel_width);padding:18px;display:block;position:absolute;top:51px;bottom:51px;z-index:-1;transition:.2s}.win_side_panel_left{border-radius:8px 0 0 8px;right:100%}.win_side_panel_right{border-radius:0 8px 8px 0;left:100%}.win_side_panel_closed.win_side_panel_left{right:calc(100% - var(--side_panel_width))}.win_side_panel_closed.win_side_panel_right{left:calc(100% - var(--side_panel_width))}[data-widget=side_panel] .template{display:block}[data-widget=side_panel] .template>.header,[data-widget=side_panel] .template>.footer{display:flex}.win_side_panel_opener{cursor:pointer;background:var(--color-cyan);color:#fff;padding:4px;position:absolute;top:20px}.win_side_panel_closed .win_side_panel_opener:not(:hover){opacity:.3}.win_side_panel_left .win_side_panel_opener{border-radius:4px 0 0 4px;right:100%}.win_side_panel_right .win_side_panel_opener{border-radius:0 6px 6px 0;left:100%}}", J = "html{--top-dialog-width: auto;--top-dialog-height: auto}.top-dialog{max-width:100vw}.top-dialog .modal-layer-body{height:var(--top-dialog-height)}", Z = ".top-dialog{width:var(--top-dialog-width)!important}";
u.insertStyleToPage(K);
u.insertStyleToPage(R, "m");
u.insertStyleToPage(U, "pc");
u.insertStyleToPage(J);
u.insertStyleToPage(Z, "pc");
let z, _ = !1;
const v = (e) => !!e && typeof e == "object" && "jquery" in e, G = () => {
  $.extend($.ui.dialog.prototype.options, {
    focus: (e) => {
      e.target.focus(), $("[autofocus]", e.target)[0]?.focus();
    },
    create: (e) => Q(e.target),
    open: (e) => Y(e.target),
    close: (e) => N(e.target),
    modal: !0,
    resizable: !1,
    closeOnEscape: !1,
    width: "auto",
    minHeight: 0
  }), $.ui.dialog.prototype._focusTabbable = $.noop, $.ui.dialog.prototype._moveToTopOriginal = $.ui.dialog.prototype._moveToTop, $.ui.dialog.prototype._moveToTop = function() {
    this._moveToTopOriginal();
    const e = $(this.element);
    e.trigger("dialogsMoveToTop", [e]);
  }, F(), _ = !0;
}, C = (e) => {
  const t = {};
  return e.dataset?.modal === "false" && (t.modal = !1), e.dataset?.position && (t.position = JSON.parse(e.dataset.position)), t;
}, f = (e) => document.getElementById(e), w = async (e, t, a) => {
  if (!e.startsWith("dialog_")) return;
  const o = k(e);
  if (o && (o.isOpened.value = !0, t !== void 0 && (o.pageActive.value = t), a !== void 0 && (o.pageActiveNext.value = a), await T(), a)) {
    const i = f(e);
    if (!i) return;
    i.querySelectorAll(`[data-view-page="${a}"]`).length || await B(() => !i.querySelectorAll(`[data-view-page="${a}"]`).length);
  }
}, Q = (e) => {
  const t = e.querySelector(".modal-body");
  t && (I(t), g.state.decoratorOnCreate?.(e), X(e));
}, X = (e) => {
  $(e).on("aftershow.top-menu-popup", "[data-top-popup]", (t, a) => {
    const o = a[0];
    g.getPairPage(o)?.[1]?.prepend(o);
  });
}, Y = async (e) => {
  const t = e.dataset.viewPageActive, a = e.dataset.args ? e.dataset.args?.split(":") : [], o = window.innerWidth;
  u.state.documentClassModificators.set("top-dialog", "with_dialog");
  const r = window.innerWidth - o;
  document.documentElement.scrollHeight > window.innerHeight && (document.querySelector("html").style.marginRight = r + "px"), q(), k(e.getAttribute("id"))?.emit?.("open", t, a);
}, N = async (e) => {
  const t = e.getAttribute("id"), a = e.dataset.viewPageActive;
  if (a) {
    const r = {
      vpn: g.state.viewPageN,
      ["view-" + t]: null
    };
    r["view-" + t] = null, (g.state.viewPageN === 0 || g.state.viewPageN === 1) && (r.vpn = null), O(r, !1);
  }
  p(document, ".ui-widget-overlay").filter((r) => c(r)).length || (u.state.documentClassModificators.delete("top-dialog"), document.querySelector("html").style.marginRight = ""), $(e).trigger("viewAfterClose", [$(e)]);
  const i = k(t);
  i && (i.pageActive.value = "", i.isOpened.value = !1, i.emit?.("close", a), i.onCloseOnce && (i.onCloseOnce(i.props, a), i.onCloseOnce = void 0)), window.dispatchEvent(new Event("resize"));
}, q = () => {
  p(document, ".ui-dialog").filter((t) => c(t) && t.querySelector(":scope > .ui-dialog-content")).map((t) => t.querySelector(":scope > .ui-dialog-content")).forEach((t) => {
    if (!t.querySelector(".modal-body")) return;
    const o = t.closest(".ui-dialog"), i = C(t);
    i.position ??= { of: window }, $(t).dialog("option", i), o.classList.remove("me-tightly"), (o.clientHeight ?? 0) > window.innerHeight && o.classList.add("me-tightly");
  });
}, D = async (e, t) => {
  const o = /(\w+)[=-]([\w-]+)(?::([\w.:-]+))?/g.exec(e);
  if (o) {
    const i = o[1], r = o[2], d = o[3];
    let l = [];
    d && (l = d.split(":")), await V(i, r, l, t);
  }
}, V = async (e, t, a, o, i) => {
  _ || await new Promise((l, h) => {
    const n = setInterval(() => {
      _ && (clearInterval(n), l());
    }, 10);
  }), await T();
  let r;
  if (typeof e == "object" ? (v(e) && (e = e?.[0]), r = e) : r = f(e), !r && typeof e == "string" && g.state.load && (await g.state.load(e), r = f(e), !r))
    throw new Error("Dialog no exists: " + e);
  if (!r) return;
  await P(r, t, a, o);
  const d = $(r);
  if (r?.classList.contains("ui-dialog-content"))
    d.dialog("open");
  else {
    const l = C(r);
    d.dialog(l);
  }
  i && i(d);
}, P = async (e, t, a, o) => {
  v(e) && (e = e?.[0]), t === void 0 && (t = e.dataset.viewPageActive), a === void 0 && (a = e.dataset.args?.split(":") ?? []), t !== e.dataset.viewPageActive && L(e) && await j(100), await w(e.getAttribute("id"), void 0, t);
  const i = p(e, ".modal-layer"), r = i.reduce((n, s) => {
    const m = s.querySelector(":scope > .active");
    return m && n.push(m), n;
  }, []), d = i.reduce((n, s) => {
    const m = s.querySelector(`:scope > [data-view-page="${t}"]`);
    return m && n.push(m), n;
  }, []), l = a.join(":");
  if (o === void 0 && (o = "next", (d[0]?.dataset.order ?? 0) < (r[0]?.dataset.order ?? 0) && (o = "prev")), !d.length) return;
  if (e.dataset.viewPageActive = t, e.dataset.args = a?.join(":") ?? "", d[0].classList.contains("active")) {
    d[0].dataset.viewPageArgs !== l && d.forEach((n) => {
      n.dataset.viewPageArgs = l;
    }), A(e, d, t, a), x(e, d, t, a);
    return;
  }
  d.forEach((n) => {
    n.dataset.viewPageArgs = l;
  }), r.forEach((n) => {
    n.querySelector(".top-popup-wrapper") && M.close(n.querySelector(".top-popup-wrapper"));
  });
  const h = d[0].closest(".ui-dialog");
  switch (h && !c(h) && (o = "none"), r.length || (o = "none"), c(d[0]) && (o = "none"), o) {
    case "prev": {
      d.forEach((n) => {
        const s = n.parentNode?.querySelector(":scope > .active");
        s && n.parentNode?.insertBefore(n, s);
      }), r.forEach((n) => {
        n.classList.add("right-to-center", "reverse");
      }), d.forEach((n) => {
        n.classList.add("center-to-left", "reverse");
      });
      break;
    }
    case "next": {
      d.forEach((n) => {
        const s = n.parentNode?.querySelector(":scope > .active");
        s && n.parentNode?.insertBefore(n, s.nextSibling);
      }), r.forEach((n) => {
        n?.classList.add("center-to-left");
      }), d.forEach((n) => {
        n.classList.add("right-to-center");
      });
      break;
    }
  }
  if (e.setAttribute("view-page-active", t), r.forEach((n) => {
    n.classList.remove("active");
  }), d.forEach((n) => {
    n.classList.add("active");
  }), A(e, d, t, a), o) {
    e.classList.add("i-change-page");
    const n = Number(window.getComputedStyle(d[0]).animationDuration.replace("s", "")) * 1e3;
    z = setTimeout(function() {
      w(e.getAttribute("id"), t, ""), L(e), x(e, d, t, a);
    }, n);
  } else
    await w(e.getAttribute("id"), t, ""), x(e, d, t, a);
}, ee = (e) => {
  const i = p(e, ".modal-layer").reduce((r, d) => {
    const l = d.querySelector(":scope > .active");
    return l && r.push(l), r;
  }, []).reduce((r, d) => {
    let l = d.previousElementSibling;
    for (; l && !l.hasAttribute("data-view-page"); )
      l = l.previousElementSibling;
    return l && r.push(l), r;
  }, [])[0]?.dataset.viewPage;
  i ? P(e, i, void 0, "prev") : $(e).dialog("close");
}, b = /* @__PURE__ */ new Set(), A = (e, t, a, o) => {
  const i = e.getAttribute("id") + t[0].dataset.viewPage + a + o.join();
  b.has(i) || (b.add(i), setTimeout(function() {
    b.delete(i), $(e).trigger("viewBeforeOpen", [$(e), $(t), a, o]);
  }));
}, x = (e, t, a, o) => {
  setTimeout(function() {
    $(e).trigger("viewAfterOpen", [$(e), $(t), a, o]);
  });
}, W = (e) => (v(e) && (e = e?.[0]), e.classList.contains("i-change-page")), L = (e) => {
  if (!W(e)) return !1;
  clearTimeout(z);
  const t = p(e, ".modal-layer"), a = e.dataset.viewPageActive;
  return e.classList.remove("i-change-page"), t.forEach((o) => {
    o.querySelectorAll(":scope > [data-view-page]").forEach((i) => {
      i.classList.remove("center-to-left", "right-to-center", "reverse", "active");
    });
  }), t.forEach((o) => {
    o.querySelector(`:scope > [data-view-page="${a}"]`)?.classList.add("active");
  }), !0;
}, te = function(e) {
  const t = f(e);
  if (!t) return;
  const a = $(t);
  a.dialog("instance") && a.dialog("close");
}, oe = (e, t, a) => {
  v(e) && (e = e.toArray());
  const o = e.reduce((i, r) => (r.hasAttribute("data-view-page") && c(r) && i.push(r), i), []);
  t ? (a !== void 0 && o.forEach((i) => {
    i.style.setProperty("--dialog-loading-duration", a + "s");
  }), o.forEach((i) => {
    i.classList.add("i-load-data");
  })) : (o.forEach((i) => {
    i.classList.remove("i-load-data");
  }), o.forEach((i) => {
    i.style.setProperty("--dialog-loading-duration", "10s");
  }));
}, ae = (e) => (v(e) && (e = e?.[0]), e.classList.contains("i-load-data")), y = {
  getElDialogById: f,
  updatePageVue: w,
  recalcPositions: q,
  toViewDirty: D,
  toView: V,
  toViewPage: P,
  toPrevPage: ee,
  setLoading: oe,
  isLoading: ae,
  inAnimation: W,
  close: te
};
G();
export {
  y as TopDialogUtils
};
//# sourceMappingURL=utils-CyE38wuQ.es.js.map
