"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

var _create = _interopRequireDefault(require("../utils/create"));

var _utils = require("../utils");

var _number = require("../utils/validate/number");

var _tag = _interopRequireDefault(require("../tag"));

var _default = (0, _create.default)({
  render: function render() {
    var _vm = this;

    var _h = _vm.$createElement;

    var _c = _vm._self._c || _h;

    return _vm.$slots['default'] ? _c(_vm.tag, {
      tag: "component",
      class: _vm.b('wrapper')
    }, [_vm._t("default"), _vm.hasContent() || _vm.dot ? _c('div', {
      class: _vm.b({
        dot: _vm.dot,
        fixed: !!_vm.$slots['default']
      }),
      style: {
        background: _vm.color
      }
    }, [_vm._t("content", [_vm._v("\n      " + _vm._s(_vm.renderContent()) + "\n    ")])], 2) : _vm._e()], 2) : _c('div', {
      class: _vm.b({
        dot: _vm.dot,
        fixed: !!_vm.$slots['default']
      }),
      style: {
        background: _vm.color
      }
    }, [_vm._t("content", [_vm._v("\n    " + _vm._s(_vm.renderContent()) + "\n  ")])], 2);
  },
  components: {
    Tag: _tag.default
  },
  name: "badge",
  props: {
    dot: Boolean,
    max: [Number, String],
    color: String,
    content: [Number, String],
    tag: {
      type: String,
      default: "div"
    }
  },
  methods: {
    hasContent: function hasContent() {
      return !!(this.$scopedSlots.content || (0, _utils.isDef)(this.content) && this.content !== "");
    },
    renderContent: function renderContent() {
      var dot = this.dot,
          max = this.max,
          content = this.content;

      if (!dot && this.hasContent()) {
        if ((0, _utils.isDef)(max) && (0, _number.isNumeric)(content) && +content > max) {
          return max + "+";
        }

        return content;
      }
    }
  }
});

exports.default = _default;