/*! bxs-vue-ui v3.3.0 */
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

require('../utils/entry-virtual.js');
var normalizeComponent = require('../utils/normalize-component.js');
require('../utils/object-create.js');
require('../utils/html.js');
require('../utils/es.number.constructor.js');
require('../utils/sloppy-array-method.js');
require('../utils/index-of.js');
require('../utils/string-trim.js');
var _parseInt = require('../utils/parse-int.js');
var env = require('../utils/env.js');
require('../utils/sloppy-array-method2.js');
require('../utils/es.array.join.js');

var script = normalizeComponent.create({
  name: 'badge',
  props: {
    // 显示文本，空时为小红点
    text: {
      type: String,
      default: ''
    },
    // 红点类型，圆形：cricle/标签：label
    type: {
      type: String,
      default: 'circle'
    },
    // 宽度值
    width: {
      type: Number,
      default: null
    },
    // 是否有描边
    outline: {
      type: Boolean,
      default: false
    },
    // 是否是角标
    subscript: {
      type: Boolean,
      default: false
    }
  },
  data: function data() {
    return {
      // 是否是小红点
      isDot: this.text === '',
      isAndroid: env.Env.isAndroid,
      className: '',
      styleObject: {}
    };
  },
  created: function created() {
    // 设置css类
    var classArr = [];

    if (this.isDot) {
      classArr.push('bx-badge-dot');
    } else if (this.type === 'label') {
      classArr.push('bx-badge-label');
    } else {
      classArr.push('bx-badge-circle');

      var number = _parseInt._parseInt(this.text, 10);

      if (number >= 0 && number <= 9) {
        classArr.push('bx-badge-number');
      }
    }

    if (this.isAndroid) {
      classArr.push('bx-badge--android');
    }

    if (this.outline) {
      classArr.push('bx-badge--outline');
    }

    if (this.subscript) {
      classArr.push('bx-badge--subscript');

      if (!this.isDot && this.type === 'label') {
        classArr.push('bx-badge-label--subscript');
      }
    }

    this.className = classArr.join(' '); // 设置固定宽度

    if (this.width) {
      this.styleObject.width = this.width + "px";
      this.styleObject.paddingLeft = 0;
      this.styleObject.paddingRight = 0;
    }
  }
});

/* script */
var __vue_script__ = script;
/* template */

var __vue_render__ = function __vue_render__() {
  var _vm = this;

  var _h = _vm.$createElement;

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

  return _c('div', {
    staticClass: "bx-badge",
    class: _vm.className,
    style: _vm.styleObject
  }, [_vm._v("\n  " + _vm._s(_vm.text) + "\n")]);
};

var __vue_staticRenderFns__ = [];
/* style */

var __vue_inject_styles__ = undefined;
/* scoped */

var __vue_scope_id__ = undefined;
/* module identifier */

var __vue_module_identifier__ = undefined;
/* functional template */

var __vue_is_functional_template__ = false;
/* style inject */

/* style inject SSR */

var Badge = normalizeComponent.__vue_normalize__({
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);

exports.default = Badge;
