import '@das-fed/ui/packages/components/split-panel/style.css';
import { getCurrentScope as ge, onScopeDispose as be, getCurrentInstance as ye, onMounted as oe, nextTick as Se, unref as $, ref as y, watch as q, defineComponent as he, computed as x, createElementBlock as z, openBlock as L, normalizeStyle as A, createElementVNode as E, renderSlot as R, createCommentVNode as P, normalizeClass as Q, createVNode as J, withModifiers as X } from "vue";
import { withInstall as Oe } from "@das-fed/utils/with-install/index";
import { DasIconShuyoufanye as we } from "@das-fed/ui/packages/icons/shuyoufanye/index";
import { DasIconShuzuofanye as Ee } from "@das-fed/ui/packages/icons/shuzuofanye/index";
import { setThemeRule as Te } from "@das-fed/web/packages/theme/index";
function V(e) {
  var n = typeof e;
  return e != null && (n == "object" || n == "function");
}
var Fe = typeof global == "object" && global && global.Object === Object && global, Ie = typeof self == "object" && self && self.Object === Object && self, ie = Fe || Ie || Function("return this")(), U = function() {
  return ie.Date.now();
}, ke = /\s/;
function Me(e) {
  for (var n = e.length; n-- && ke.test(e.charAt(n)); )
    ;
  return n;
}
var Ce = /^\s+/;
function _e(e) {
  return e && e.slice(0, Me(e) + 1).replace(Ce, "");
}
var W = ie.Symbol, fe = Object.prototype, xe = fe.hasOwnProperty, je = fe.toString, j = W ? W.toStringTag : void 0;
function De(e) {
  var n = xe.call(e, j), t = e[j];
  try {
    e[j] = void 0;
    var o = !0;
  } catch {
  }
  var l = je.call(e);
  return o && (n ? e[j] = t : delete e[j]), l;
}
var Ne = Object.prototype, Re = Ne.toString;
function Pe(e) {
  return Re.call(e);
}
var We = "[object Null]", Be = "[object Undefined]", Y = W ? W.toStringTag : void 0;
function ze(e) {
  return e == null ? e === void 0 ? Be : We : Y && Y in Object(e) ? De(e) : Pe(e);
}
function Le(e) {
  return e != null && typeof e == "object";
}
var Ae = "[object Symbol]";
function Qe(e) {
  return typeof e == "symbol" || Le(e) && ze(e) == Ae;
}
var Z = NaN, Xe = /^[-+]0x[0-9a-f]+$/i, Ue = /^0b[01]+$/i, $e = /^0o[0-7]+$/i, qe = parseInt;
function ee(e) {
  if (typeof e == "number")
    return e;
  if (Qe(e))
    return Z;
  if (V(e)) {
    var n = typeof e.valueOf == "function" ? e.valueOf() : e;
    e = V(n) ? n + "" : n;
  }
  if (typeof e != "string")
    return e === 0 ? e : +e;
  e = _e(e);
  var t = Ue.test(e);
  return t || $e.test(e) ? qe(e.slice(2), t ? 2 : 8) : Xe.test(e) ? Z : +e;
}
var Ve = "Expected a function", Ge = Math.max, He = Math.min;
function Ke(e, n, t) {
  var o, l, i, f, u, g, S = 0, a = !1, m = !1, v = !0;
  if (typeof e != "function")
    throw new TypeError(Ve);
  n = ee(n) || 0, V(t) && (a = !!t.leading, m = "maxWait" in t, i = m ? Ge(ee(t.maxWait) || 0, n) : i, v = "trailing" in t ? !!t.trailing : v);
  function d(c) {
    var b = o, w = l;
    return o = l = void 0, S = c, f = e.apply(w, b), f;
  }
  function s(c) {
    return S = c, u = setTimeout(T, n), a ? d(c) : f;
  }
  function h(c) {
    var b = c - g, w = c - S, N = n - b;
    return m ? He(N, i - w) : N;
  }
  function M(c) {
    var b = c - g, w = c - S;
    return g === void 0 || b >= n || b < 0 || m && w >= i;
  }
  function T() {
    var c = U();
    if (M(c))
      return D(c);
    u = setTimeout(T, h(c));
  }
  function D(c) {
    return u = void 0, v && o ? d(c) : (o = l = void 0, f);
  }
  function F() {
    u !== void 0 && clearTimeout(u), S = 0, o = g = l = u = void 0;
  }
  function O() {
    return u === void 0 ? f : D(U());
  }
  function I() {
    var c = U(), b = M(c);
    if (o = arguments, l = this, g = c, b) {
      if (u === void 0)
        return s(g);
      if (m)
        return clearTimeout(u), u = setTimeout(T, n), d(g);
    }
    return u === void 0 && (u = setTimeout(T, n)), f;
  }
  return I.cancel = F, I.flush = O, I;
}
var te;
const G = typeof window < "u", Je = (e) => typeof e == "string", Ye = () => {
};
G && ((te = window == null ? void 0 : window.navigator) != null && te.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
function ce(e) {
  return typeof e == "function" ? e() : $(e);
}
function Ze(e) {
  return e;
}
function de(e) {
  return ge() ? (be(e), !0) : !1;
}
function et(e, n = !0) {
  ye() ? oe(e) : n ? e() : Se(e);
}
function ve(e) {
  var n;
  const t = ce(e);
  return (n = t == null ? void 0 : t.$el) != null ? n : t;
}
const tt = G ? window : void 0, nt = G ? window.document : void 0;
function rt(...e) {
  let n, t, o, l;
  if (Je(e[0]) || Array.isArray(e[0]) ? ([t, o, l] = e, n = tt) : [n, t, o, l] = e, !n)
    return Ye;
  Array.isArray(t) || (t = [t]), Array.isArray(o) || (o = [o]);
  const i = [], f = () => {
    i.forEach((a) => a()), i.length = 0;
  }, u = (a, m, v, d) => (a.addEventListener(m, v, d), () => a.removeEventListener(m, v, d)), g = q(() => [ve(n), ce(l)], ([a, m]) => {
    f(), a && i.push(...t.flatMap((v) => o.map((d) => u(a, v, d, m))));
  }, { immediate: !0, flush: "post" }), S = () => {
    g(), f();
  };
  return de(S), S;
}
function lt(e, n = !1) {
  const t = y(), o = () => t.value = !!e();
  return o(), et(o, n), t;
}
const ne = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, re = "__vueuse_ssr_handlers__";
ne[re] = ne[re] || {};
const le = [
  [
    "requestFullscreen",
    "exitFullscreen",
    "fullscreenElement",
    "fullscreenEnabled",
    "fullscreenchange",
    "fullscreenerror"
  ],
  [
    "webkitRequestFullscreen",
    "webkitExitFullscreen",
    "webkitFullscreenElement",
    "webkitFullscreenEnabled",
    "webkitfullscreenchange",
    "webkitfullscreenerror"
  ],
  [
    "webkitRequestFullScreen",
    "webkitCancelFullScreen",
    "webkitCurrentFullScreenElement",
    "webkitCancelFullScreen",
    "webkitfullscreenchange",
    "webkitfullscreenerror"
  ],
  [
    "mozRequestFullScreen",
    "mozCancelFullScreen",
    "mozFullScreenElement",
    "mozFullScreenEnabled",
    "mozfullscreenchange",
    "mozfullscreenerror"
  ],
  [
    "msRequestFullscreen",
    "msExitFullscreen",
    "msFullscreenElement",
    "msFullscreenEnabled",
    "MSFullscreenChange",
    "MSFullscreenError"
  ]
];
function at(e, n = {}) {
  const { document: t = nt, autoExit: o = !1 } = n, l = t == null ? void 0 : t.querySelector("html"), i = y(!1);
  let f = le[0];
  const u = lt(() => {
    if (t) {
      for (const h of le)
        if (h[1] in t)
          return f = h, !0;
    } else
      return !1;
    return !1;
  }), [g, S, a, , m] = f;
  async function v() {
    u.value && (t != null && t[a] && await t[S](), i.value = !1);
  }
  async function d() {
    if (!u.value)
      return;
    await v();
    const h = ve(l);
    h && (await h[g](), i.value = !0);
  }
  async function s() {
    i.value ? await v() : await d();
  }
  return t && rt(t, m, () => {
    i.value = !!(t != null && t[a]);
  }, !1), o && de(v), {
    isSupported: u,
    isFullscreen: i,
    enter: d,
    exit: v,
    toggle: s
  };
}
var ae;
(function(e) {
  e.UP = "UP", e.RIGHT = "RIGHT", e.DOWN = "DOWN", e.LEFT = "LEFT", e.NONE = "NONE";
})(ae || (ae = {}));
var ut = Object.defineProperty, ue = Object.getOwnPropertySymbols, st = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, se = (e, n, t) => n in e ? ut(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t, it = (e, n) => {
  for (var t in n || (n = {}))
    st.call(n, t) && se(e, t, n[t]);
  if (ue)
    for (var t of ue(n))
      ot.call(n, t) && se(e, t, n[t]);
  return e;
};
const ft = {
  easeInSine: [0.12, 0, 0.39, 0],
  easeOutSine: [0.61, 1, 0.88, 1],
  easeInOutSine: [0.37, 0, 0.63, 1],
  easeInQuad: [0.11, 0, 0.5, 0],
  easeOutQuad: [0.5, 1, 0.89, 1],
  easeInOutQuad: [0.45, 0, 0.55, 1],
  easeInCubic: [0.32, 0, 0.67, 0],
  easeOutCubic: [0.33, 1, 0.68, 1],
  easeInOutCubic: [0.65, 0, 0.35, 1],
  easeInQuart: [0.5, 0, 0.75, 0],
  easeOutQuart: [0.25, 1, 0.5, 1],
  easeInOutQuart: [0.76, 0, 0.24, 1],
  easeInQuint: [0.64, 0, 0.78, 0],
  easeOutQuint: [0.22, 1, 0.36, 1],
  easeInOutQuint: [0.83, 0, 0.17, 1],
  easeInExpo: [0.7, 0, 0.84, 0],
  easeOutExpo: [0.16, 1, 0.3, 1],
  easeInOutExpo: [0.87, 0, 0.13, 1],
  easeInCirc: [0.55, 0, 1, 0.45],
  easeOutCirc: [0, 0.55, 0.45, 1],
  easeInOutCirc: [0.85, 0, 0.15, 1],
  easeInBack: [0.36, 0, 0.66, -0.56],
  easeOutBack: [0.34, 1.56, 0.64, 1],
  easeInOutBack: [0.68, -0.6, 0.32, 1.6]
};
it({
  linear: Ze
}, ft);
const ct = { class: "das-split-panel-second" }, dt = {
  name: "DasSplitPanel"
}, vt = /* @__PURE__ */ he({
  ...dt,
  props: {
    canFold: { type: Boolean, default: !0 },
    canDrag: { type: Boolean, default: !0 },
    boxStyle: {},
    defaultSplit: { default: {
      first: 0.5,
      second: 0.5
    } },
    firstMin: { default: 225 },
    secondMin: { default: 600 },
    defaultClose: {}
  },
  emits: ["onLeft", "onRight", "onDefault", "onMouseDown", "onMouseMove", "onMouseUp"],
  setup(e, { expose: n, emit: t }) {
    const { isFullscreen: o } = at(), l = e, i = t, f = y(null), u = y(null), g = x(() => {
      var r;
      return u != null && u.value && Number((r = u == null ? void 0 : u.value) == null ? void 0 : r.offsetWidth) - 2 || 1;
    });
    x(() => g.value + "px");
    const S = y(null), a = y(), m = y(), v = y(), d = y(0), s = y(0), h = y(!0), M = x(() => s.value + "px"), T = x(() => ({ width: M.value })), D = x(() => ({ left: M.value })), F = y(!1), O = y(!1);
    q(
      s,
      (r, p) => {
        r === 0 ? F.value = !0 : F.value = !1, r === (a == null ? void 0 : a.value) ? O.value = !0 : O.value = !1;
      },
      { immediate: !0 }
    ), q(o, (r) => {
      B();
    });
    const I = () => {
      s.value > d.value ? (s.value = d.value, i("onDefault")) : s.value <= d.value && s.value > 0 && (s.value = 0, i("onLeft"));
    }, c = () => {
      s.value < d.value ? (s.value = d.value, i("onDefault")) : s.value >= d.value && s.value < a.value && (s.value = a.value, i("onRight"));
    }, b = y({
      mouseFlag: !1,
      startX: 0,
      startWidth: 0
    }), w = (r) => {
      l.canDrag && (b.value.mouseFlag = !0, b.value.startX = r.clientX, b.value.startWidth = s.value, document.onmousemove = N, document.onmouseup = pe, i("onMouseDown"));
    }, N = (r) => {
      if (r.preventDefault(), !b.value.mouseFlag) return;
      let k = r.clientX - b.value.startX, _ = b.value.startWidth + k;
      _ < m.value ? s.value = m.value : _ > v.value ? s.value = v.value : _ > m.value && _ < v.value && (s.value = _), i("onMouseMove");
    }, pe = () => {
      b.value.mouseFlag = !1, document.onmousemove = null, document.onmouseup = null, i("onMouseUp");
    }, C = (r, p) => {
      let k = 0;
      return typeof p == "number" && p <= 1 ? k = r * p : typeof p == "number" ? k = p : k = Number(p), k;
    }, H = () => {
      let r = 0;
      l.defaultSplit.first !== void 0 ? (r = C(a.value, l.defaultSplit.first), d.value = r, s.value = r) : l.defaultSplit.second !== void 0 && (typeof l.defaultSplit.second == "number" && l.defaultSplit.second <= 1 ? r = C(a.value, 1 - l.defaultSplit.second) : r = a.value - C(a.value, l.defaultSplit.second), d.value = r, s.value = r), l.defaultClose && l.defaultClose == "first" ? s.value = 0 : l.defaultClose && l.defaultClose == "second" && (s.value = a.value);
    }, me = () => {
      H();
    };
    let K = y(!0);
    const B = () => {
      var p;
      let r = !1;
      if (O.value && (r = !0), !!(f != null && f.value) && (a.value = Number(((p = f == null ? void 0 : f.value) == null ? void 0 : p.offsetWidth) - (g == null ? void 0 : g.value)) || 0, m.value = C(a.value, l.firstMin), v.value = a.value - C(a.value, l.secondMin), r && (s.value = a.value), h.value === !0)) {
        if (H(), K.value) {
          K.value = !1;
          return;
        }
        h.value = !1;
      }
    };
    return oe(() => {
      var r;
      h.value = !0, S.value = new ResizeObserver(Ke(B, 30)), (r = S.value) == null || r.observe(f == null ? void 0 : f.value), B();
    }), n({
      toLeft: I,
      toRight: c,
      reset: me
    }), (r, p) => (L(), z(
      "div",
      {
        class: "das-ui-split-panel",
        ref_key: "$splitPanel",
        ref: f,
        style: A(r.boxStyle)
      },
      [
        E(
          "div",
          {
            class: "das-split-panel-first",
            style: A(T.value)
          },
          [
            R(r.$slots, "firstSlot", {}, void 0, !0)
          ],
          4
          /* STYLE */
        ),
        E(
          "div",
          {
            class: "das-split-panel-mid",
            ref_key: "$splitLine",
            ref: u,
            style: A(D.value)
          },
          [
            r.canFold ? (L(), z("span", {
              key: 0,
              onClick: I
            }, [
              R(r.$slots, "leftBtn", {}, () => [
                E(
                  "span",
                  {
                    class: Q(["das-split-panel-btn left", [O.value ? "isBase" : ""]])
                  },
                  [
                    J($(Ee), { size: "medium" })
                  ],
                  2
                  /* CLASS */
                )
              ], !0)
            ])) : P("v-if", !0),
            E(
              "div",
              {
                class: Q(["das-split-panel-line", { hide: F.value || O.value, canDrag: l.canDrag }]),
                onDragstart: p[0] || (p[0] = X(() => {
                }, ["stop", "prevent"])),
                onMousedown: X(w, ["prevent"]),
                onClick: p[1] || (p[1] = X(() => {
                }, ["stop", "prevent"]))
              },
              [
                P(' <slot name="splitLine"> '),
                p[2] || (p[2] = E(
                  "div",
                  { class: "das-split-panel-divider" },
                  null,
                  -1
                  /* HOISTED */
                )),
                P(" </slot> ")
              ],
              34
              /* CLASS, NEED_HYDRATION */
            ),
            r.canFold ? (L(), z("span", {
              key: 1,
              onClick: c
            }, [
              R(r.$slots, "rightBtn", {}, () => [
                E(
                  "span",
                  {
                    class: Q(["das-split-panel-btn right", [F.value ? "isBase" : ""]])
                  },
                  [
                    J($(we), { size: "medium" })
                  ],
                  2
                  /* CLASS */
                )
              ], !0)
            ])) : P("v-if", !0)
          ],
          4
          /* STYLE */
        ),
        E("div", ct, [
          R(r.$slots, "secondSlot", {}, void 0, !0)
        ])
      ],
      4
      /* STYLE */
    ));
  }
}), pt = (e, n) => {
  const t = e.__vccOpts || e;
  for (const [o, l] of n)
    t[o] = l;
  return t;
}, mt = /* @__PURE__ */ pt(vt, [["__scopeId", "data-v-ba259a73"]]), gt = {
  "--das-ui-split-panel-color-primary": "#5582F3",
  // 主题色
  "--das-ui-split-panel-color-line": "#D9D9D9",
  // 线条色
  "--das-ui-split-panel-color-btn": "#999999"
  // 按钮icon色
};
Te(gt);
const wt = Oe(mt), Et = () => y(null), Tt = { name: "splitPanel 分割面板" };
export {
  wt as DasSplitPanel,
  Et as DasSplitPanelRef,
  Tt as default
};
