"use strict";

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

Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.default = void 0;

var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")), _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")), _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")), _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")), _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")), _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")), _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")), _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")), _react = _interopRequireWildcard(require("react")), _propTypes = _interopRequireDefault(require("prop-types")), _amosAntd = require("amos-antd"), _DeviceEnum = require("./../../common/DeviceEnum"), _DeviceLang = require("./../../common/DeviceLang"), _AddDeviceCapacity = _interopRequireDefault(require("./AddDeviceCapacity")), _CommonCell = _interopRequireDefault(require("./../../common/CommonCell"));

function _getRequireWildcardCache(e) {
  if ("function" != typeof WeakMap) return null;
  var t = new WeakMap, r = new WeakMap;
  return (_getRequireWildcardCache = function(e) {
    return e ? r : t;
  })(e);
}

function _interopRequireWildcard(e, t) {
  if (!t && e && e.__esModule) return e;
  if (null === e || "object" !== _typeof(e) && "function" != typeof e) return {
    default: e
  };
  var r = _getRequireWildcardCache(t);
  if (r && r.has(e)) return r.get(e);
  var a = {}, n = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (var i in e) if ("default" !== i && Object.prototype.hasOwnProperty.call(e, i)) {
    var o = n ? Object.getOwnPropertyDescriptor(e, i) : null;
    o && (o.get || o.set) ? Object.defineProperty(a, i, o) : a[i] = e[i];
  }
  return a.default = e, r && r.set(e, a), a;
}

function _createForOfIteratorHelper(e, t) {
  var r = "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
  if (!r) {
    if (Array.isArray(e) || (r = _unsupportedIterableToArray(e)) || t && e && "number" == typeof e.length) {
      r && (e = r);
      var a = 0, n = function() {};
      return {
        s: n,
        n: function() {
          return a >= e.length ? {
            done: !0
          } : {
            done: !1,
            value: e[a++]
          };
        },
        e: function(e) {
          throw e;
        },
        f: n
      };
    }
    throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  }
  var i, o = !0, u = !1;
  return {
    s: function() {
      r = r.call(e);
    },
    n: function() {
      var e = r.next();
      return o = e.done, e;
    },
    e: function(e) {
      u = !0, i = e;
    },
    f: function() {
      try {
        o || null == r.return || r.return();
      } finally {
        if (u) throw i;
      }
    }
  };
}

function _unsupportedIterableToArray(e, t) {
  if (e) {
    if ("string" == typeof e) return _arrayLikeToArray(e, t);
    var r = Object.prototype.toString.call(e).slice(8, -1);
    return "Object" === r && e.constructor && (r = e.constructor.name), "Map" === r || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? _arrayLikeToArray(e, t) : void 0;
  }
}

function _arrayLikeToArray(e, t) {
  (null == t || t > e.length) && (t = e.length);
  for (var r = 0, a = new Array(t); r < t; r++) a[r] = e[r];
  return a;
}

function _createSuper(e) {
  var t = _isNativeReflectConstruct();
  return function() {
    var r, a = (0, _getPrototypeOf2.default)(e);
    if (t) {
      var n = (0, _getPrototypeOf2.default)(this).constructor;
      r = Reflect.construct(a, arguments, n);
    } else r = a.apply(this, arguments);
    return (0, _possibleConstructorReturn2.default)(this, r);
  };
}

function _isNativeReflectConstruct() {
  if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
  if (Reflect.construct.sham) return !1;
  if ("function" == typeof Proxy) return !0;
  try {
    return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {}))), 
    !0;
  } catch (e) {
    return !1;
  }
}

require("./../device-detail.scss"), require("./../../common/common.scss");

var AddDeviceCapacityCard = function(e) {
  (0, _inherits2.default)(r, e);
  var t = _createSuper(r);
  function r(e) {
    var a;
    return (0, _classCallCheck2.default)(this, r), a = t.call(this, e), (0, _defineProperty2.default)((0, 
    _assertThisInitialized2.default)(a), "autoCardCalculate", (function(e) {
      var t = a.state.interfaceProList;
      void 0 !== e && (t = [].concat((0, _toConsumableArray2.default)(t), (0, _toConsumableArray2.default)(e)), 
      a.setState({
        interfaceProList: t
      })), a.autoProView();
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "autoProView", (function(e) {
      var t = a.props, r = t.repuestType, n = t.addDeviceCapacity, i = t.deviceInterfaces, o = void 0 === e ? a.state.interfaceProList : e, u = [];
      if (u.push(_react.default.createElement("div", {
        key: 0
      }, _react.default.createElement(_AddDeviceCapacity.default, {
        deviceInterfaces: i,
        repuestType: r,
        addDeviceCapacity: n,
        autoCardCalculate: a.autoCardCalculate
      }))), o.length > 0) {
        var l, c = _createForOfIteratorHelper(o);
        try {
          for (c.s(); !(l = c.n()).done; ) {
            var f = l.value, s = [];
            s.push(_react.default.createElement("p", null, "分  类：", (0, _DeviceLang.stringUtil)(_DeviceEnum.capacityClassifyEnum, parseInt(f.type)))), 
            s.push(_react.default.createElement("p", null, "接  口：", f.intfcDisplayName)), u.push(_react.default.createElement(_CommonCell.default, {
              contentHtml: s,
              cardKey: f.key,
              value: f,
              deleteCellProperty: a.deleteCellProperty
            }));
          }
        } catch (e) {
          c.e(e);
        } finally {
          c.f();
        }
      }
      return u;
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "deleteCellProperty", (function(e) {
      var t, r = [], n = _createForOfIteratorHelper(a.state.interfaceProList);
      try {
        for (n.s(); !(t = n.n()).done; ) {
          var i = t.value;
          i.key !== e && r.push(i);
        }
      } catch (e) {
        n.e(e);
      } finally {
        n.f();
      }
      a.setState({
        interfaceProList: r
      }), a.props.deleteCellCapacity(e), a.autoProView();
    })), a.state = {
      interfaceProList: []
    }, a;
  }
  return (0, _createClass2.default)(r, [ {
    key: "componentWillMount",
    value: function() {}
  }, {
    key: "componentDidMount",
    value: function() {}
  }, {
    key: "componentWillReceiveProps",
    value: function() {}
  }, {
    key: "render",
    value: function() {
      return _react.default.createElement(_amosAntd.Row, null, this.autoProView());
    }
  } ]), r;
}(_react.Component);

AddDeviceCapacityCard.displayName = "AddDeviceCapacityCard", AddDeviceCapacityCard.propTypes = {
  repuestType: _propTypes.default.string,
  addDeviceCapacity: _propTypes.default.func,
  deleteCellCapacity: _propTypes.default.func,
  deviceInterfaces: _propTypes.default.array
};

var _default = AddDeviceCapacityCard;

exports.default = _default;