import '@das-fed/ui/packages/components/loading/style.css';
import { inject as D, ref as I, computed as x, unref as R, createElementBlock as N, openBlock as V, createStaticVNode as Z, createElementVNode as z, reactive as M, defineComponent as Q, h as _, Transition as W, withCtx as X, withDirectives as ee, createVNode as te, vShow as ne, createApp as oe, toRefs as se, nextTick as j, isRef as ae } from "vue";
import { setThemeRule as re } from "@das-fed/web/packages/theme/index";
import { setI18nRule as ce, t as le } from "@das-fed/web/packages/i18n/index";
/**
* @vue/shared v3.5.18
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
process.env.NODE_ENV !== "production" && Object.freeze({});
process.env.NODE_ENV !== "production" && Object.freeze([]);
const K = (t) => typeof t == "string", F = (t) => t !== null && typeof t == "object", G = (t) => {
  const e = /* @__PURE__ */ Object.create(null);
  return (n) => e[n] || (e[n] = t(n));
}, de = /-(\w)/g, ie = G(
  (t) => t.replace(de, (e, n) => n ? n.toUpperCase() : "")
), ue = /\B([A-Z])/g, fe = G(
  (t) => t.replace(ue, "-$1").toLowerCase()
), ve = (t) => typeof t == "number";
var B;
const A = typeof window < "u";
A && ((B = window == null ? void 0 : window.navigator) != null && B.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
const q = (t = "") => t.split(" ").filter((e) => !!e.trim()), E = (t, e) => {
  !t || !e.trim() || t.classList.add(...q(e));
}, $ = (t, e) => {
  !t || !e.trim() || t.classList.remove(...q(e));
}, b = (t, e) => {
  var o;
  if (!A || !t || !e) return "";
  let n = ie(e);
  n === "float" && (n = "cssFloat");
  try {
    const c = t.style[n];
    if (c) return c;
    const a = (o = document.defaultView) == null ? void 0 : o.getComputedStyle(t, "");
    return a ? a[n] : "";
  } catch {
    return t.style[n];
  }
}, L = "das", me = "is-", m = (t, e, n, o, c) => {
  let a = `${t}-${e}`;
  return n && (a += `-${n}`), o && (a += `__${o}`), c && (a += `--${c}`), a;
}, ge = Symbol("namespaceContextKey"), pe = (t) => {
  const e = t || D(ge, I(L));
  return x(() => R(e) || L);
}, ye = (t, e) => {
  const n = pe(e);
  return {
    namespace: n,
    b: (s = "") => m(n.value, t, s, "", ""),
    e: (s) => s ? m(n.value, t, "", s, "") : "",
    m: (s) => s ? m(n.value, t, "", "", s) : "",
    be: (s, r) => s && r ? m(n.value, t, s, r, "") : "",
    em: (s, r) => s && r ? m(n.value, t, "", s, r) : "",
    bm: (s, r) => s && r ? m(n.value, t, s, "", r) : "",
    bem: (s, r, d) => s && r && d ? m(n.value, t, s, r, d) : "",
    is: (s, ...r) => {
      const d = r.length >= 1 ? r[0] : !0;
      return s && d ? `${me}${s}` : "";
    },
    // css
    cssVar: (s) => {
      const r = {};
      for (const d in s)
        s[d] && (r[`--${n.value}-${d}`] = s[d]);
      return r;
    },
    cssVarName: (s) => `--${n.value}-${s}`,
    cssVarBlock: (s) => {
      const r = {};
      for (const d in s)
        s[d] && (r[`--${n.value}-${t}-${d}`] = s[d]);
      return r;
    },
    cssVarBlockName: (s) => `--${n.value}-${t}-${s}`
  };
}, S = I(0), U = 2e3, be = Symbol("zIndexContextKey"), xe = (t) => {
  const e = t || D(be, void 0), n = x(() => {
    const a = R(e);
    return ve(a) ? a : U;
  }), o = x(() => n.value + S.value);
  return {
    initialZIndex: n,
    currentZIndex: o,
    nextZIndex: () => (S.value++, o.value)
  };
};
function _e(t) {
  const e = ye(
    t,
    x(() => L)
  ), n = xe(
    x(() => U)
  );
  return {
    ns: e,
    zIndex: n
  };
}
const k = (t, e) => {
  const n = t.__vccOpts || t;
  for (const [o, c] of e)
    n[o] = c;
  return n;
}, Ce = {}, $e = { class: "das-loading-container das-loading-page" };
function Ie(t, e) {
  return V(), N("div", $e, e[0] || (e[0] = [
    Z('<div class="das-loading-dot-loading" data-v-6f86e018><i class="das-loading-dot-item" data-v-6f86e018></i><i class="das-loading-dot-item" data-v-6f86e018></i><i class="das-loading-dot-item" data-v-6f86e018></i><i class="das-loading-dot-item" data-v-6f86e018></i></div>', 1)
  ]));
}
const O = /* @__PURE__ */ k(Ce, [["render", Ie], ["__scopeId", "data-v-6f86e018"]]), he = {}, Le = { class: "das-loading-container das-loading-component" };
function we(t, e) {
  return V(), N("div", Le, e[0] || (e[0] = [
    z(
      "div",
      { class: "das-loading-dot-loading" },
      [
        z("i", { class: "das-loading-dot-item" })
      ],
      -1
      /* CACHED */
    )
  ]));
}
const Ne = /* @__PURE__ */ k(he, [["render", we], ["__scopeId", "data-v-88fde512"]]), Ve = {}, Ae = { class: "das-loading-container das-loading-containerload" };
function ke(t, e) {
  return V(), N("div", Ae, e[0] || (e[0] = [
    Z('<div class="das-loading-dot-loading" data-v-e851d2c9><i class="das-loading-dot-item" data-v-e851d2c9></i><i class="das-loading-dot-item" data-v-e851d2c9></i><i class="das-loading-dot-item" data-v-e851d2c9></i><i class="das-loading-dot-item" data-v-e851d2c9></i></div>', 1)
  ]));
}
const ze = /* @__PURE__ */ k(Ve, [["render", ke], ["__scopeId", "data-v-e851d2c9"]]);
function Be(t) {
  let e;
  const n = I(!1), o = M({
    ...t,
    originalPosition: "",
    originalOverflow: "",
    visible: !1
  });
  function c(l) {
    o.text = l;
  }
  function a() {
    const l = o.parent, v = p.ns;
    if (!l.vLoadingAddClassList) {
      let f = l.getAttribute("loading-number");
      f = Number.parseInt(f) - 1, f ? l.setAttribute("loading-number", f.toString()) : ($(l, v.bm("parent", "relative")), l.removeAttribute("loading-number")), $(l, v.bm("parent", "hidden"));
    }
    u(), h.unmount();
  }
  function u() {
    var l, v;
    (v = (l = p.$el) == null ? void 0 : l.parentNode) == null || v.removeChild(p.$el);
  }
  function y() {
    var l;
    t.beforeClose && !t.beforeClose() || (n.value = !0, clearTimeout(e), e = window.setTimeout(i, 400), o.visible = !1, (l = t.closed) == null || l.call(t));
  }
  function i() {
    if (!n.value) return;
    const l = o.parent;
    n.value = !1, l.vLoadingAddClassList = void 0, a();
  }
  const g = Q({
    name: "DasLoading",
    setup(l, { expose: v }) {
      const { ns: f, zIndex: s } = _e("loading");
      return v({
        ns: f,
        zIndex: s
      }), () => {
        let r = o.spinner || o.svg || O;
        const d = o.type;
        d == "page" && (r = O), d == "container" && (r = ze), d == "component" && (r = Ne);
        const H = _(r), J = o.text ? _("p", { class: f.b("text") }, [o.text]) : void 0;
        return _(
          W,
          {
            name: f.b("fade"),
            onAfterLeave: i
          },
          {
            default: X(() => [
              ee(
                te(
                  "div",
                  {
                    style: {
                      backgroundColor: o.background || ""
                    },
                    class: [
                      f.b("mask"),
                      o.customClass,
                      o.fullscreen ? "is-fullscreen" : ""
                    ]
                  },
                  [
                    _(
                      "div",
                      {
                        class: f.b("spinner")
                      },
                      [H, J]
                    )
                  ]
                ),
                [[ne, o.visible]]
              )
            ])
          }
        );
      };
    }
  }), h = oe(g), p = h.mount(document.createElement("div"));
  return {
    ...se(o),
    setText: c,
    removeElLoadingChild: u,
    close: y,
    handleAfterLeave: i,
    vm: p,
    get $el() {
      return p.$el;
    }
  };
}
let C;
const Y = function(t = {}) {
  if (!A) return;
  const e = Ee(t);
  if (e.fullscreen && C)
    return C;
  const n = Be({
    ...e,
    closed: () => {
      var c;
      (c = e.closed) == null || c.call(e), e.fullscreen && (C = void 0);
    }
  });
  Se(e, e.parent, n), T(e, e.parent, n), e.parent.vLoadingAddClassList = () => T(e, e.parent, n);
  let o = e.parent.getAttribute("loading-number");
  return o ? o = `${Number.parseInt(o) + 1}` : o = "1", e.parent.setAttribute("loading-number", o), e.parent.appendChild(n.$el), j(() => n.visible.value = e.visible), e.fullscreen && (C = n), n;
}, Ee = (t) => {
  let e;
  return K(t.target) ? e = document.querySelector(t.target) ?? document.body : e = t.target || document.body, {
    parent: e === document.body || t.body ? document.body : e,
    background: t.background || "",
    svg: t.svg || "",
    svgViewBox: t.svgViewBox || "",
    spinner: t.spinner || !1,
    text: t.text || "",
    type: t.type || "",
    fullscreen: e === document.body && (t.fullscreen ?? !0),
    lock: t.lock ?? !1,
    customClass: t.customClass || "",
    visible: t.visible ?? !0,
    target: e
  };
}, Se = async (t, e, n) => {
  const { nextZIndex: o } = n.vm.zIndex || n.vm._.exposed.zIndex, c = {};
  if (t.fullscreen)
    n.originalPosition.value = b(document.body, "position"), n.originalOverflow.value = b(document.body, "overflow"), c.zIndex = o();
  else if (t.parent === document.body) {
    n.originalPosition.value = b(document.body, "position"), await j();
    for (const a of ["top", "left"]) {
      const u = a === "top" ? "scrollTop" : "scrollLeft";
      c[a] = `${t.target.getBoundingClientRect()[a] + document.body[u] + document.documentElement[u] - Number.parseInt(b(document.body, `margin-${a}`), 10)}px`;
    }
    for (const a of ["height", "width"])
      c[a] = `${t.target.getBoundingClientRect()[a]}px`;
  } else
    n.originalPosition.value = b(e, "position");
  for (const [a, u] of Object.entries(c))
    n.$el.style[a] = u;
}, T = (t, e, n) => {
  const o = n.vm.ns || n.vm._.exposed.ns;
  ["absolute", "fixed", "sticky"].includes(n.originalPosition.value) ? $(e, o.bm("parent", "relative")) : E(e, o.bm("parent", "relative")), t.fullscreen && t.lock ? E(e, o.bm("parent", "hidden")) : $(e, o.bm("parent", "hidden"));
}, w = Symbol("DasLoading"), P = (t, e) => {
  const n = e.instance, o = (i) => F(e.value) ? e.value[i] : void 0, c = (i) => {
    const g = K(i) && (n == null ? void 0 : n[i]) || i;
    return g && I(g);
  }, a = (i) => c(
    o(i) || t.getAttribute(`das-loading-${fe(i)}`)
  ), u = o("fullscreen") ?? e.modifiers.fullscreen, y = {
    type: a("type"),
    text: a("text"),
    svg: a("svg"),
    svgViewBox: a("svgViewBox"),
    spinner: a("spinner"),
    background: a("background"),
    customClass: a("customClass"),
    fullscreen: u,
    target: o("target") ?? (u ? void 0 : t),
    body: o("body") ?? e.modifiers.body,
    lock: o("lock") ?? e.modifiers.lock
  };
  t[w] = {
    options: y,
    instance: Y(y)
  };
}, Oe = (t, e) => {
  for (const n of Object.keys(e))
    ae(e[n]) && (e[n].value = t[n]);
}, je = {
  mounted(t, e) {
    e.value && P(t, e);
  },
  updated(t, e) {
    const n = t[w];
    e.oldValue !== e.value && (e.value && !e.oldValue ? P(t, e) : e.value && e.oldValue ? F(e.value) && Oe(e.value, n.options) : n == null || n.instance.close());
  },
  unmounted(t) {
    var e;
    (e = t[w]) == null || e.instance.close();
  }
}, Te = {
  "--das-ui-loading-logo-1-color": "#2486ee",
  "--das-ui-loading-logo-2-color": "#02ccfe",
  "--das-ui-loading-logo-3-color": "#05c8c7",
  "--das-ui-loading-logo-4-color": "#a06eff",
  "--das-ui-loading-logo-5-color": "#5582f3",
  "--das-ui-loading-logo-6-color": "#ebebeb"
}, Pe = { 加载: { "zh-CN": "加载", en: "Loading", _appCode: "framework" } };
ce(Pe);
re(Te);
const Ke = {
  service: Y
}, Fe = { name: `loading ${le("加载")}` };
export {
  Ke as DasLoading,
  Fe as default,
  je as vDasLoading
};
