/*! bxs-vue-ui v3.3.0 */
import '../utils/entry-virtual.js';
import { C as create, _ as __vue_normalize__ } from '../utils/normalize-component.js';
import '../utils/object-create.js';
import '../utils/html.js';
import '../utils/es.number.constructor.js';
import '../utils/array-iteration.js';
import '../utils/sloppy-array-method.js';
import { _ as _indexOfInstanceProperty } from '../utils/index-of.js';
import '../utils/string-trim.js';
import '../utils/parse-int.js';
import { _ as _filterInstanceProperty } from '../utils/filter.js';
import '../utils/env.js';
import Icon from '../icon/index.js';
import '../utils/sloppy-array-method2.js';
import '../utils/es.array.join.js';
import Badge from '../badge/index.js';
import TimeStamp from 'time-stamp';

function timeFormatter(formatter, time) {
  return TimeStamp(formatter, time);
}

var _components;
var script = create({
  name: 'cell',
  props: {
    // 列表项的主、副标题
    title: {
      type: String,
      required: true
    },
    titleOneLine: {
      type: Boolean,
      default: true
    },
    subtitle: {
      type: String,
      default: ''
    },
    subtitleOneLine: {
      type: Boolean,
      default: false
    },
    // 列表项的右上角文案
    value: {
      type: String | Date,
      // eslint-disable-line no-bitwise
      default: ''
    },
    valueFormatter: {
      type: String,
      default: 'YYYY-MM-DD HH:mm:ss'
    },
    // 图标设置
    icon: {
      type: String,
      default: ''
    },
    iconPrefix: {
      type: String,
      default: 'bx-icon'
    },
    iconColor: {
      type: String,
      default: ''
    },
    iconSize: {
      type: String,
      default: ''
    },
    // 图片 url
    logo: {
      type: String,
      default: ''
    },
    // 是否展示右侧箭头
    isLink: {
      type: Boolean,
      default: false
    },
    // 小红点数字
    //    false=不显示, true=显示但无数字
    //    数字=显示小红点且显示数字
    // isLink 为true时显示在右侧, 否则显示在左侧图标或图片右上角
    badge: {
      type: Boolean | Number,
      // eslint-disable-line no-bitwise
      default: false
    },
    // 图片是否显示在右侧
    logoRight: {
      type: Boolean,
      default: false
    }
  },
  components: (_components = {}, _components[Icon.name] = Icon, _components[Badge.name] = Badge, _components),
  methods: {
    cellRightClickHandler: function cellRightClickHandler() {
      this.$emit('click-right');
    },
    cellClickHandler: function cellClickHandler() {
      this.$emit('click');
    }
  },
  computed: {
    shouldHide: function shouldHide() {
      var _context;

      // moreThreshold 为 0、或点击过查看更多时, 即可确定须展示全部
      if (this.$parent.showAllCell || this.$parent.moreThreshold === 0) return false;

      var siblingCells = _filterInstanceProperty(_context = this.$parent.$children).call(_context, function (x) {
        return x.$options.name === 'bxs-cell';
      });

      var cellIdx = _indexOfInstanceProperty(siblingCells).call(siblingCells, this);

      return cellIdx >= this.$parent.moreThreshold;
    },
    cellClass: function cellClass() {
      return {
        'bx-cell--multi-line': this.subtitle || this.$slots.subtitle,
        'bx-cell-logo-left': this.logo && !this.logoRight || this.icon,
        'bx-cell-logo-right': this.logo && this.logoRight,
        'bx-cell--hide': this.shouldHide
      };
    },
    valueOrTime: function valueOrTime() {
      if (typeof this.value === 'object' && this.value instanceof Date) {
        if (this.valueFormatter) {
          return timeFormatter(this.valueFormatter, this.value);
        }
      }

      return this.value;
    }
  }
});

/* 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-cell",
    class: _vm.cellClass,
    on: {
      "click": _vm.cellClickHandler
    }
  }, [_vm.logo && !_vm.logoRight || _vm.icon ? _c('div', {
    staticClass: "bx-cell-left"
  }, [_c('div', {
    staticClass: "bx-cell-image-wrapper"
  }, [_vm.logo && !_vm.icon ? _c('img', {
    staticClass: "img-responsive",
    attrs: {
      "src": _vm.logo
    }
  }) : _vm._e(), _vm.icon ? _c('bxs-icon', {
    attrs: {
      "name": _vm.icon,
      "color": _vm.iconColor,
      "size": _vm.iconSize,
      "prefix": _vm.iconPrefix
    }
  }) : _vm._e(), _vm.badge === true && !_vm.isLink ? _c('bxs-badge', {
    attrs: {
      "subscript": true
    }
  }) : _vm._e(), typeof _vm.badge === 'string' && !_vm.isLink ? _c('bxs-badge', {
    attrs: {
      "text": _vm.badge,
      "width": 18,
      "subscript": true
    }
  }) : _vm._e()], 1)]) : _vm._e(), _c('div', {
    staticClass: "bx-cell-center-right"
  }, [_c('div', {
    staticClass: "bx-cell-center"
  }, [_c('div', {
    staticClass: "bx-cell-title-line"
  }, [_c('span', {
    staticClass: "bx-cell-title",
    class: {
      'bx-cell--one-line': _vm.titleOneLine
    }
  }, [_vm._v("\n          " + _vm._s(_vm.title) + "\n        ")]), this.subtitle && this.valueOrTime ? _c('span', {
    staticClass: "bx-cell-title-desc"
  }, [_vm._v(_vm._s(_vm.valueOrTime))]) : _vm._e()]), _vm.subtitle || _vm.$slots.subtitle ? _c('span', {
    staticClass: "bx-cell-subtitle",
    class: {
      'bx-cell--one-line': _vm.subtitleOneLine
    }
  }, [_vm._t("subtitle", [_c('span', [_vm._v(_vm._s(_vm.subtitle))])])], 2) : _vm._e()]), !_vm.subtitle && !_vm.$slots.subtitle ? _c('div', {
    staticClass: "bx-cell-right"
  }, [_c('span', {
    staticClass: "bx-cell-right-click-span",
    on: {
      "click": _vm.cellRightClickHandler
    }
  }), _vm.value ? _c('span', {
    staticClass: "bx-cell-right-value"
  }, [_vm._v(_vm._s(_vm.value))]) : _vm._e(), _vm.badge === true && _vm.isLink ? _c('bxs-badge') : _vm._e(), typeof _vm.badge === 'string' && _vm.isLink ? _c('bxs-badge', {
    attrs: {
      "text": _vm.badge,
      "width": 18
    }
  }) : _vm._e(), _vm.isLink ? _c('bxs-icon', {
    attrs: {
      "name": "arrow-right"
    }
  }) : _vm._e()], 1) : _vm._e(), _vm.logo && _vm.logoRight ? _c('div', {
    staticClass: "bx-cell-right-logo"
  }, [_vm.logo && !_vm.icon ? _c('img', {
    staticClass: "img-responsive",
    attrs: {
      "src": _vm.logo
    }
  }) : _vm._e()]) : _vm._e()])]);
};

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 index = __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);

export default index;
