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; }

import classNames from 'classnames';
import isEmpty from 'lodash/isEmpty';
import React from 'react';
import Button from '../../../common/Button';
import { deviceTypeMap } from '../../../constants';
import { propertyPanelMap } from '../../component-types';
import './index.less';
export default function PropertyPanel(_ref) {
  var selectedNode = _ref.selectedNode,
      device = _ref.device,
      animation = _ref.animation,
      onClose = _ref.onClose,
      titles = _ref.titles;
  var Clazz = propertyPanelMap[selectedNode.type];

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

  var propInstance = Clazz && React.createElement(Clazz, panelProps);

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

  var isHidePcProp = function isHidePcProp() {
    return isEmpty(selectedNode) && isPc();
  };

  var isShowPcProp = function isShowPcProp() {
    return !isEmpty(selectedNode) && isPc();
  };

  var isHidePhoneProp = function isHidePhoneProp() {
    return isEmpty(selectedNode) && !isPc();
  };

  var isShowPhoneProp = function isShowPhoneProp() {
    return !isEmpty(selectedNode) && !isPc();
  };

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