"use strict";

exports.__esModule = true;
exports.default = void 0;

/**
 * bem helper
 * b() // 'button'
 * b('text') // 'button-text'
 * b({ disabled }) // 'button button-disabled'
 * b('text', { disabled }) // 'button-text button-text-disabled'
 * b(['disabled', 'primary']) // 'button button-disabled button-primary'
 */
var ELEMENT = '-';
var MODS = '-';

var join = function join(name, el, symbol) {
  return el ? name + symbol + el : name;
};

var prefix = function prefix(name, mods) {
  if (typeof mods === 'string') {
    return join(name, mods, MODS);
  }

  if (Array.isArray(mods)) {
    return mods.map(function (item) {
      return prefix(name, item);
    });
  }

  var ret = {};
  mods && Object.keys(mods).forEach(function (key) {
    ret[name + MODS + key] = mods[key];
  });
  return ret;
};

var _default = {
  methods: {
    b: function b(el, mods) {
      var name = this.$options.name;

      if (el && typeof el !== 'string') {
        mods = el;
        el = '';
      }

      el = join(name, el, ELEMENT);
      return mods ? [el, prefix(el, mods)] : el;
    }
  }
};
exports.default = _default;