import create from "../utils/create";
import { isDef } from "../utils";
import { isNumeric } from "../utils/validate/number";
import Tag from "../tag";
export default create({
  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
  },
  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 || isDef(this.content) && this.content !== "");
    },
    renderContent: function renderContent() {
      var dot = this.dot,
          max = this.max,
          content = this.content;

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

        return content;
      }
    }
  }
});