"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = PropertyPanel;

var _classnames = _interopRequireDefault(require("classnames"));

var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));

var _react = _interopRequireDefault(require("react"));

var _Button = _interopRequireDefault(require("../../../common/Button"));

var _constants = require("../../../constants");

var _componentTypes = require("../../component-types");

require("./index.less");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys.push.apply(ownKeys, Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function PropertyPanel(_ref) {
  var selectedNode = _ref.selectedNode,
      device = _ref.device,
      animation = _ref.animation,
      onClose = _ref.onClose,
      titles = _ref.titles;
  var Clazz = _componentTypes.propertyPanelMap[selectedNode.type];

  var panelProps = _objectSpread({}, selectedNode, {
    titles: titles,
    device: device
  });

  var propInstance = Clazz && _react["default"].createElement(Clazz, panelProps);

  var isPc = function isPc() {
    return device === _constants.deviceTypeMap.PC;
  };

  var isHidePcProp = function isHidePcProp() {
    return (0, _isEmpty["default"])(selectedNode) && isPc();
  };

  var isShowPcProp = function isShowPcProp() {
    return !(0, _isEmpty["default"])(selectedNode) && isPc();
  };

  var isHidePhoneProp = function isHidePhoneProp() {
    return (0, _isEmpty["default"])(selectedNode) && !isPc();
  };

  var isShowPhoneProp = function isShowPhoneProp() {
    return !(0, _isEmpty["default"])(selectedNode) && !isPc();
  };

  return /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])('property_wrap', {
      phone_wrap: isHidePhoneProp(),
      phone_show: isShowPhoneProp(),
      pc_wrap: isHidePcProp(),
      pc_show: isShowPcProp(),
      no_animation: !animation
    })
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "property_header"
  }, /*#__PURE__*/_react["default"].createElement("span", {
    className: "title",
    title: selectedNode.label
  }, selectedNode.label), isPc() && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
    type: "primary",
    onClick: onClose
  }, "Done")), propInstance);
}