import { defineComponent as E, getCurrentInstance as ce, ref as y, inject as fe, computed as K, onUnmounted as de, h as D, provide as ve, onMounted as pe, nextTick as k, unref as c, onBeforeUnmount as ye, resolveComponent as Q, openBlock as $, createElementBlock as R, createElementVNode as me, normalizeClass as V, normalizeStyle as q, createBlock as Z, resolveDynamicComponent as ge, withCtx as ee, renderSlot as te, Fragment as he, createVNode as F, createCommentVNode as be, mergeProps as _e } from "vue";
import Oe from "resize-observer-polyfill";
import "lodash-es";
import "dayjs";
import "ant-design-vue";
const we = typeof window > "u";
function je(e) {
  for (const r of e) {
    const t = r.target.__resizeListeners__ || [];
    t.length && t.forEach((o) => {
      o();
    });
  }
}
function M(e, r) {
  we || (e.__resizeListeners__ || (e.__resizeListeners__ = [], e.__ro__ = new Oe(je), e.__ro__.observe(e)), e.__resizeListeners__.push(r));
}
function W(e, r) {
  !e || !e.__resizeListeners__ || (e.__resizeListeners__.splice(
    e.__resizeListeners__.indexOf(r),
    1
  ), e.__resizeListeners__.length || e.__ro__.disconnect());
}
const Se = {
  vertical: {
    offset: "offsetHeight",
    scroll: "scrollTop",
    scrollSize: "scrollHeight",
    size: "height",
    key: "vertical",
    axis: "Y",
    client: "clientY",
    direction: "top"
  },
  horizontal: {
    offset: "offsetWidth",
    scroll: "scrollLeft",
    scrollSize: "scrollWidth",
    size: "width",
    key: "horizontal",
    axis: "X",
    client: "clientX",
    direction: "left"
  }
};
function Te({ move: e, size: r, bar: t }) {
  const o = {}, n = `translate${t.axis}(${e}%)`;
  return o[t.size] = r, o.transform = n, o.msTransform = n, o.webkitTransform = n, o;
}
function ze(e, r) {
  return Object.assign(e, r);
}
function $e(e) {
  const r = {};
  for (let t = 0; t < e.length; t++)
    e[t] && ze(r, e[t]);
  return r;
}
function Y(e, r, t) {
  e && r && t && e.addEventListener(r, t, !1);
}
function I(e, r, t) {
  e && r && t && e.removeEventListener(r, t, !1);
}
const Pe = E({
  name: "Bar",
  props: {
    vertical: Boolean,
    size: String,
    move: Number
  },
  setup(e) {
    const r = ce(), t = y(), o = fe(
      "scroll-bar-wrap",
      {}
    ), n = K(() => Se[e.vertical ? "vertical" : "horizontal"]), i = y({}), s = y(), a = (d) => {
      var H, N;
      if (s.value === !1)
        return;
      const g = i.value[n.value.axis];
      if (!g)
        return;
      const C = (((H = r == null ? void 0 : r.vnode.el) == null ? void 0 : H.getBoundingClientRect()[n.value.direction]) - d[n.value.client]) * -1, A = t.value[n.value.offset] - g, z = (C - A) * 100 / ((N = r == null ? void 0 : r.vnode.el) == null ? void 0 : N[n.value.offset]);
      o.value[n.value.scroll] = z * o.value[n.value.scrollSize] / 100;
    };
    function l() {
      s.value = !1, i.value[n.value.axis] = 0, I(document, "mousemove", a), document.onselectstart = null;
    }
    const u = (d) => {
      d.stopImmediatePropagation(), s.value = !0, Y(document, "mousemove", a), Y(document, "mouseup", l), document.onselectstart = () => !1;
    }, v = (d) => {
      var g;
      d.ctrlKey || d.button === 2 || ((g = window.getSelection()) == null || g.removeAllRanges(), u(d), i.value[n.value.axis] = d.currentTarget[n.value.offset] - (d[n.value.client] - d.currentTarget.getBoundingClientRect()[n.value.direction]));
    }, j = (d) => {
      var z;
      const g = Math.abs(
        d.target.getBoundingClientRect()[n.value.direction] - d[n.value.client]
      ), C = t.value[n.value.offset] / 2, A = (g - C) * 100 / ((z = r == null ? void 0 : r.vnode.el) == null ? void 0 : z[n.value.offset]);
      o.value[n.value.scroll] = A * o.value[n.value.scrollSize] / 100;
    };
    return de(() => {
      I(document, "mouseup", l);
    }), () => D(
      "div",
      {
        class: ["scrollbar__bar", "is-" + n.value.key],
        onMousedown: j
      },
      D("div", {
        ref: t,
        class: "scrollbar__thumb",
        onMousedown: v,
        style: Te({
          size: e.size,
          move: e.move,
          bar: n.value
        })
      })
    );
  }
}), Le = E({
  name: "Scrollbar",
  // inheritAttrs: false,
  components: { Bar: Pe },
  props: {
    native: {
      type: Boolean,
      default: !1
    },
    wrapStyle: {
      type: [String, Array],
      default: ""
    },
    wrapClass: {
      type: [String, Array],
      default: ""
    },
    viewClass: {
      type: [String, Array],
      default: ""
    },
    viewStyle: {
      type: [String, Array],
      default: ""
    },
    noresize: Boolean,
    // 如果 container 尺寸不会发生变化，最好设置它可以优化性能
    tag: {
      type: String,
      default: "div"
    }
  },
  setup(e) {
    const r = y("0"), t = y("0"), o = y(0), n = y(0), i = y(), s = y();
    ve("scroll-bar-wrap", i);
    const a = K(() => Array.isArray(e.wrapStyle) ? $e(e.wrapStyle) : e.wrapStyle), l = () => {
      e.native || (n.value = c(i).scrollTop * 100 / c(i).clientHeight, o.value = c(i).scrollLeft * 100 / c(i).clientWidth);
    }, u = () => {
      if (!c(i))
        return;
      const v = c(i).clientHeight * 100 / c(i).scrollHeight, j = c(i).clientWidth * 100 / c(i).scrollWidth;
      t.value = v < 100 ? v + "%" : "", r.value = j < 100 ? j + "%" : "";
    };
    return pe(() => {
      e.native || (k(u), e.noresize || (M(c(s), u), M(c(i), u), addEventListener("resize", u)));
    }), ye(() => {
      e.native || e.noresize || (W(c(s), u), W(c(i), u), removeEventListener("resize", u));
    }), {
      moveX: o,
      moveY: n,
      sizeWidth: r,
      sizeHeight: t,
      style: a,
      wrap: i,
      resize: s,
      update: u,
      handleScroll: l
    };
  }
});
const re = (e, r) => {
  const t = e.__vccOpts || e;
  for (const [o, n] of r)
    t[o] = n;
  return t;
}, Ce = { class: "scrollbar" };
function Ae(e, r, t, o, n, i) {
  const s = Q("bar");
  return $(), R("div", Ce, [
    me("div", {
      ref: "wrap",
      class: V([
        e.wrapClass,
        "scrollbar__wrap",
        e.native ? "" : "scrollbar__wrap--hidden-default"
      ]),
      style: q(e.style),
      onScroll: r[0] || (r[0] = (...a) => e.handleScroll && e.handleScroll(...a))
    }, [
      ($(), Z(ge(e.tag), {
        ref: "resize",
        class: V(["scrollbar__view", e.viewClass]),
        style: q(e.viewStyle)
      }, {
        default: ee(() => [
          te(e.$slots, "default")
        ]),
        _: 3
      }, 8, ["class", "style"]))
    ], 38),
    e.native ? be("", !0) : ($(), R(he, { key: 0 }, [
      F(s, {
        move: e.moveX,
        size: e.sizeWidth
      }, null, 8, ["move", "size"]),
      F(s, {
        vertical: "",
        move: e.moveY,
        size: e.sizeHeight
      }, null, 8, ["move", "size"])
    ], 64))
  ]);
}
const ke = /* @__PURE__ */ re(Le, [["render", Ae]]), Be = "G";
function Ee(e) {
  return typeof e == "function";
}
function xe(e) {
  return typeof e < "u";
}
function He(e) {
  return !xe(e);
}
for (let e = 0; e <= 15; e++)
  e.toString(16);
/*!
 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
 *
 * Copyright (c) 2014-2017, Jon Schlinkert.
 * Released under the MIT License.
 */
function U(e) {
  return Object.prototype.toString.call(e) === "[object Object]";
}
function Ne(e) {
  var r, t;
  return U(e) === !1 ? !1 : (r = e.constructor, r === void 0 ? !0 : (t = r.prototype, !(U(t) === !1 || t.hasOwnProperty("isPrototypeOf") === !1)));
}
function S() {
  return S = Object.assign ? Object.assign.bind() : function(e) {
    for (var r = 1; r < arguments.length; r++) {
      var t = arguments[r];
      for (var o in t)
        Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
    }
    return e;
  }, S.apply(this, arguments);
}
function ne(e, r) {
  if (e == null)
    return {};
  var t, o, n = {}, i = Object.keys(e);
  for (o = 0; o < i.length; o++)
    r.indexOf(t = i[o]) >= 0 || (n[t] = e[t]);
  return n;
}
const B = { silent: !1, logLevel: "warn" }, De = ["validator"], oe = Object.prototype, ie = oe.toString, Re = oe.hasOwnProperty, se = /^\s*function (\w+)/;
function X(e) {
  var r;
  const t = (r = e == null ? void 0 : e.type) !== null && r !== void 0 ? r : e;
  if (t) {
    const o = t.toString().match(se);
    return o ? o[1] : "";
  }
  return "";
}
const h = Ne, ae = (e) => e;
let f = ae;
process.env.NODE_ENV !== "production" && (f = typeof console < "u" ? function(r, t = B.logLevel) {
  B.silent === !1 && console[t](`[VueTypes warn]: ${r}`);
} : ae);
const _ = (e, r) => Re.call(e, r), Ve = Number.isInteger || function(e) {
  return typeof e == "number" && isFinite(e) && Math.floor(e) === e;
}, O = Array.isArray || function(e) {
  return ie.call(e) === "[object Array]";
}, w = (e) => ie.call(e) === "[object Function]", P = (e) => h(e) && _(e, "_vueTypes_name"), le = (e) => h(e) && (_(e, "type") || ["_vueTypes_name", "validator", "default", "required"].some((r) => _(e, r)));
function x(e, r) {
  return Object.defineProperty(e.bind(r), "__original", { value: e });
}
function b(e, r, t = !1) {
  let o, n = !0, i = "";
  o = h(e) ? e : { type: e };
  const s = P(o) ? o._vueTypes_name + " - " : "";
  if (le(o) && o.type !== null) {
    if (o.type === void 0 || o.type === !0 || !o.required && r === void 0)
      return n;
    O(o.type) ? (n = o.type.some((a) => b(a, r, !0) === !0), i = o.type.map((a) => X(a)).join(" or ")) : (i = X(o), n = i === "Array" ? O(r) : i === "Object" ? h(r) : i === "String" || i === "Number" || i === "Boolean" || i === "Function" ? function(a) {
      if (a == null)
        return "";
      const l = a.constructor.toString().match(se);
      return l ? l[1] : "";
    }(r) === i : r instanceof o.type);
  }
  if (!n) {
    const a = `${s}value "${r}" should be of type "${i}"`;
    return t === !1 ? (f(a), !1) : a;
  }
  if (_(o, "validator") && w(o.validator)) {
    const a = f, l = [];
    if (f = (u) => {
      l.push(u);
    }, n = o.validator(r), f = a, !n) {
      const u = (l.length > 1 ? "* " : "") + l.join(`
* `);
      return l.length = 0, t === !1 ? (f(u), n) : u;
    }
  }
  return n;
}
function p(e, r) {
  const t = Object.defineProperties(r, { _vueTypes_name: { value: e, writable: !0 }, isRequired: { get() {
    return this.required = !0, this;
  } }, def: { value(n) {
    return n === void 0 ? (_(this, "default") && delete this.default, this) : w(n) || b(this, n, !0) === !0 ? (this.default = O(n) ? () => [...n] : h(n) ? () => Object.assign({}, n) : n, this) : (f(`${this._vueTypes_name} - invalid default value: "${n}"`), this);
  } } }), { validator: o } = t;
  return w(o) && (t.validator = x(o, t)), t;
}
function m(e, r) {
  const t = p(e, r);
  return Object.defineProperty(t, "validate", { value(o) {
    return w(this.validator) && f(`${this._vueTypes_name} - calling .validate() will overwrite the current custom validator function. Validator info:
${JSON.stringify(this)}`), this.validator = x(o, this), this;
  } });
}
function J(e, r, t) {
  const o = function(l) {
    const u = {};
    return Object.getOwnPropertyNames(l).forEach((v) => {
      u[v] = Object.getOwnPropertyDescriptor(l, v);
    }), Object.defineProperties({}, u);
  }(r);
  if (o._vueTypes_name = e, !h(t))
    return o;
  const { validator: n } = t, i = ne(t, De);
  if (w(n)) {
    let { validator: l } = o;
    l && (l = (a = (s = l).__original) !== null && a !== void 0 ? a : s), o.validator = x(l ? function(u) {
      return l.call(this, u) && n.call(this, u);
    } : n, o);
  }
  var s, a;
  return Object.assign(o, i);
}
function L(e) {
  return e.replace(/^(?!\s*$)/gm, "  ");
}
const qe = () => m("any", {}), Fe = () => m("function", { type: Function }), Me = () => m("boolean", { type: Boolean }), We = () => m("string", { type: String }), Ye = () => m("number", { type: Number }), Ie = () => m("array", { type: Array }), Ue = () => m("object", { type: Object }), Xe = () => p("integer", { type: Number, validator: (e) => Ve(e) }), Je = () => p("symbol", { validator: (e) => typeof e == "symbol" });
function Ge(e, r = "custom validation failed") {
  if (typeof e != "function")
    throw new TypeError("[VueTypes error]: You must provide a function as argument");
  return p(e.name || "<<anonymous function>>", { type: null, validator(t) {
    const o = e(t);
    return o || f(`${this._vueTypes_name} - ${r}`), o;
  } });
}
function Ke(e) {
  if (!O(e))
    throw new TypeError("[VueTypes error]: You must provide an array as argument.");
  const r = `oneOf - value should be one of "${e.join('", "')}".`, t = e.reduce((o, n) => {
    if (n != null) {
      const i = n.constructor;
      o.indexOf(i) === -1 && o.push(i);
    }
    return o;
  }, []);
  return p("oneOf", { type: t.length > 0 ? t : void 0, validator(o) {
    const n = e.indexOf(o) !== -1;
    return n || f(r), n;
  } });
}
function Qe(e) {
  if (!O(e))
    throw new TypeError("[VueTypes error]: You must provide an array as argument");
  let r = !1, t = [];
  for (let n = 0; n < e.length; n += 1) {
    const i = e[n];
    if (le(i)) {
      if (P(i) && i._vueTypes_name === "oneOf" && i.type) {
        t = t.concat(i.type);
        continue;
      }
      if (w(i.validator) && (r = !0), i.type === !0 || !i.type) {
        f('oneOfType - invalid usage of "true" or "null" as types.');
        continue;
      }
      t = t.concat(i.type);
    } else
      t.push(i);
  }
  t = t.filter((n, i) => t.indexOf(n) === i);
  const o = t.length > 0 ? t : null;
  return p("oneOfType", r ? { type: o, validator(n) {
    const i = [], s = e.some((a) => {
      const l = b(P(a) && a._vueTypes_name === "oneOf" ? a.type || null : a, n, !0);
      return typeof l == "string" && i.push(l), l === !0;
    });
    return s || f(`oneOfType - provided value does not match any of the ${i.length} passed-in validators:
${L(i.join(`
`))}`), s;
  } } : { type: o });
}
function Ze(e) {
  return p("arrayOf", { type: Array, validator(r) {
    let t = "";
    const o = r.every((n) => (t = b(e, n, !0), t === !0));
    return o || f(`arrayOf - value validation error:
${L(t)}`), o;
  } });
}
function et(e) {
  return p("instanceOf", { type: e });
}
function tt(e) {
  return p("objectOf", { type: Object, validator(r) {
    let t = "";
    const o = Object.keys(r).every((n) => (t = b(e, r[n], !0), t === !0));
    return o || f(`objectOf - value validation error:
${L(t)}`), o;
  } });
}
function rt(e) {
  const r = Object.keys(e), t = r.filter((n) => {
    var i;
    return !((i = e[n]) === null || i === void 0 || !i.required);
  }), o = p("shape", { type: Object, validator(n) {
    if (!h(n))
      return !1;
    const i = Object.keys(n);
    if (t.length > 0 && t.some((s) => i.indexOf(s) === -1)) {
      const s = t.filter((a) => i.indexOf(a) === -1);
      return f(s.length === 1 ? `shape - required property "${s[0]}" is not defined.` : `shape - required properties "${s.join('", "')}" are not defined.`), !1;
    }
    return i.every((s) => {
      if (r.indexOf(s) === -1)
        return this._vueTypes_isLoose === !0 || (f(`shape - shape definition does not include a "${s}" property. Allowed keys: "${r.join('", "')}".`), !1);
      const a = b(e[s], n[s], !0);
      return typeof a == "string" && f(`shape - "${s}" property validation error:
 ${L(a)}`), a === !0;
    });
  } });
  return Object.defineProperty(o, "_vueTypes_isLoose", { writable: !0, value: !1 }), Object.defineProperty(o, "loose", { get() {
    return this._vueTypes_isLoose = !0, this;
  } }), o;
}
const nt = ["name", "validate", "getter"], ot = /* @__PURE__ */ (() => {
  var e;
  return (e = class {
    static get any() {
      return qe();
    }
    static get func() {
      return Fe().def(this.defaults.func);
    }
    static get bool() {
      return Me().def(this.defaults.bool);
    }
    static get string() {
      return We().def(this.defaults.string);
    }
    static get number() {
      return Ye().def(this.defaults.number);
    }
    static get array() {
      return Ie().def(this.defaults.array);
    }
    static get object() {
      return Ue().def(this.defaults.object);
    }
    static get integer() {
      return Xe().def(this.defaults.integer);
    }
    static get symbol() {
      return Je();
    }
    static get nullable() {
      return { type: null };
    }
    static extend(r) {
      if (O(r))
        return r.forEach((l) => this.extend(l)), this;
      const { name: t, validate: o = !1, getter: n = !1 } = r, i = ne(r, nt);
      if (_(this, t))
        throw new TypeError(`[VueTypes error]: Type "${t}" already defined`);
      const { type: s } = i;
      if (P(s))
        return delete i.type, Object.defineProperty(this, t, n ? { get: () => J(t, s, i) } : { value(...l) {
          const u = J(t, s, i);
          return u.validator && (u.validator = u.validator.bind(u, ...l)), u;
        } });
      let a;
      return a = n ? { get() {
        const l = Object.assign({}, i);
        return o ? m(t, l) : p(t, l);
      }, enumerable: !0 } : { value(...l) {
        const u = Object.assign({}, i);
        let v;
        return v = o ? m(t, u) : p(t, u), u.validator && (v.validator = u.validator.bind(v, ...l)), v;
      }, enumerable: !0 }, Object.defineProperty(this, t, a);
    }
  }).defaults = {}, e.sensibleDefaults = void 0, e.config = B, e.custom = Ge, e.oneOf = Ke, e.instanceOf = et, e.oneOfType = Qe, e.arrayOf = Ze, e.objectOf = tt, e.shape = rt, e.utils = { validate: (r, t) => b(t, r, !0) === !0, toType: (r, t, o = !1) => o ? m(r, t) : p(r, t) }, e;
})();
function ue(e = { func: () => {
}, bool: !0, string: "", number: 0, array: () => [], object: () => ({}), integer: 0 }) {
  var r;
  return (r = class extends ot {
    static get sensibleDefaults() {
      return S({}, this.defaults);
    }
    static set sensibleDefaults(t) {
      this.defaults = t !== !1 ? S({}, t !== !0 ? t : e) : {};
    }
  }).defaults = S({}, e), r;
}
class mt extends ue() {
}
const it = ue({
  func: void 0,
  bool: void 0,
  string: void 0,
  number: void 0,
  object: void 0,
  integer: void 0
});
it.extend([
  {
    name: "style",
    getter: !0,
    type: [String, Object],
    default: void 0
  },
  {
    name: "VNodeChild",
    getter: !0,
    type: void 0
  }
]);
const st = (e, r, t, o) => (e /= o / 2, e < 1 ? t / 2 * e * e + r : (e--, -t / 2 * (e * (e - 2) - 1) + r)), at = (e, r) => {
  e.scrollTop = r;
}, lt = (e) => e.scrollTop;
function G({
  el: e,
  to: r,
  duration: t = 500,
  callback: o
}) {
  const n = y(!1), i = lt(e), s = r - i, a = 20;
  let l = 0;
  t = He(t) ? 500 : t;
  const u = function() {
    if (!c(n))
      return;
    l += a;
    const d = st(l, i, s, t);
    at(e, d), l < t && c(n) ? requestAnimationFrame(u) : o && Ee(o) && o();
  };
  return { start: () => {
    n.value = !0, u();
  }, stop: () => {
    n.value = !1;
  } };
}
const ut = E({
  name: `${Be}ScrollContainer`,
  components: { Scrollbar: ke },
  setup() {
    const e = y(null);
    function r(n, i = 500) {
      const s = c(e);
      s && k(() => {
        const a = c(s.wrap);
        if (!a)
          return;
        const { start: l } = G({
          el: a,
          to: n,
          duration: i
        });
        l();
      });
    }
    function t() {
      const n = c(e);
      return n ? n.wrap : null;
    }
    function o() {
      const n = c(e);
      n && k(() => {
        const i = c(n.wrap);
        if (!i)
          return;
        const s = i.scrollHeight, { start: a } = G({
          el: i,
          to: s
        });
        a();
      });
    }
    return {
      scrollbarRef: e,
      scrollTo: r,
      scrollBottom: o,
      getScrollWrap: t
    };
  }
});
function ct(e, r, t, o, n, i) {
  const s = Q("Scrollbar");
  return $(), Z(s, _e({
    ref: "scrollbarRef",
    class: "scroll-container"
  }, e.$attrs), {
    default: ee(() => [
      te(e.$slots, "default")
    ]),
    _: 3
  }, 16);
}
const T = /* @__PURE__ */ re(ut, [["render", ct]]);
T.install = function(e, r) {
  e.component(r || T.name, T);
};
const gt = {
  title: "ScrollContainer 滚动",
  category: "布局",
  status: "100%",
  install(e) {
    e.component(T.name, T);
  }
};
export {
  T as ScrollContainer,
  gt as default
};
