"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"), _CommonCell = _interopRequireDefault(require("./../../common/CommonCell")), _AddDeviceInterface = _interopRequireDefault(require("./AddDeviceInterface"));

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

function _interopRequireWildcard(e, r) {
  if (!r && e && e.__esModule) return e;
  if (null === e || "object" !== _typeof(e) && "function" != typeof e) return {
    default: e
  };
  var t = _getRequireWildcardCache(r);
  if (t && t.has(e)) return t.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, t && t.set(e, a), a;
}

function _createForOfIteratorHelper(e, r) {
  var t = "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
  if (!t) {
    if (Array.isArray(e) || (t = _unsupportedIterableToArray(e)) || r && e && "number" == typeof e.length) {
      t && (e = t);
      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() {
      t = t.call(e);
    },
    n: function() {
      var e = t.next();
      return o = e.done, e;
    },
    e: function(e) {
      u = !0, i = e;
    },
    f: function() {
      try {
        o || null == t.return || t.return();
      } finally {
        if (u) throw i;
      }
    }
  };
}

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

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

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

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 AddDeviceInterfaceCard = function(e) {
  (0, _inherits2.default)(t, e);
  var r = _createSuper(t);
  function t(e) {
    var a;
    return (0, _classCallCheck2.default)(this, t), a = r.call(this, e), (0, _defineProperty2.default)((0, 
    _assertThisInitialized2.default)(a), "autoCardCalculate", (function(e) {
      var r = a.state.interfaceProList;
      void 0 !== e && (r = [].concat((0, _toConsumableArray2.default)(r), (0, _toConsumableArray2.default)(e)), 
      a.setState({
        interfaceProList: r
      })), a.autoProView();
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "autoProView", (function(e) {
      var r = a.props, t = r.repuestType, n = r.addDeviceInterface, i = void 0 === e ? a.state.interfaceProList : e, o = [];
      if (o.push(_react.default.createElement("div", {
        key: 0
      }, _react.default.createElement(_AddDeviceInterface.default, {
        repuestType: t,
        addDeviceInterface: n,
        autoCardCalculate: a.autoCardCalculate
      }))), i.length > 0) {
        var u, l = _createForOfIteratorHelper(i);
        try {
          for (l.s(); !(u = l.n()).done; ) {
            var c = u.value, f = [];
            f.push(_react.default.createElement("p", null, "接  口：", c.displayName)), f.push(_react.default.createElement("p", null, "接口方向：", (0, 
            _DeviceLang.stringUtil)(_DeviceEnum.interfaceDirectionEnum, parseInt(c.intfcDirection)))), 
            o.push(_react.default.createElement(_CommonCell.default, {
              key: c.key,
              contentHtml: f,
              cardKey: c.key,
              value: c,
              deleteCellProperty: a.deleteCellProperty
            }));
          }
        } catch (e) {
          l.e(e);
        } finally {
          l.f();
        }
      }
      return o;
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "deleteCellProperty", (function(e) {
      var r, t = [], n = _createForOfIteratorHelper(a.state.interfaceProList);
      try {
        for (n.s(); !(r = n.n()).done; ) {
          var i = r.value;
          i.key !== e && t.push(i);
        }
      } catch (e) {
        n.e(e);
      } finally {
        n.f();
      }
      a.setState({
        interfaceProList: t
      }), a.props.deleteCellInterface(e), a.autoProView();
    })), a.state = {
      interfaceProList: []
    }, a;
  }
  return (0, _createClass2.default)(t, [ {
    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());
    }
  } ]), t;
}(_react.Component);

AddDeviceInterfaceCard.displayName = "AddDeviceInterfaceCard", AddDeviceInterfaceCard.propTypes = {
  form: _propTypes.default.any,
  repuestType: _propTypes.default.string,
  deleteCellInterface: _propTypes.default.func,
  addDeviceInterface: _propTypes.default.func
};

var _default = AddDeviceInterfaceCard;

exports.default = _default;