import classNames from 'classnames';
import PerfectScrollbar from 'perfect-scrollbar';
import "./style/scrollbar.css";
var prefixCls = 'dmc-scrollbar';
var defaultOpts = {
  suppressScrollX: true,
  minScrollbarLength: 20
};

var createScrollbar = function createScrollbar(dom, type, options, className) {
  var _a, _b;

  if (options === void 0) {
    options = defaultOpts;
  }

  var classes = classNames(prefixCls, (_a = {}, _a[prefixCls + "-" + type] = type, _a), className).split(' ');
  dom === null || dom === void 0 ? void 0 : (_b = dom.classList).add.apply(_b, classes);
  var ps = new PerfectScrollbar(dom, options);
  return [ps, function () {
    var _a;

    ps === null || ps === void 0 ? void 0 : ps.destroy();
    ps = undefined;
    dom === null || dom === void 0 ? void 0 : (_a = dom.classList).remove.apply(_a, classes);
    dom = undefined;
  }];
};

export default createScrollbar;

