"use strict";

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

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

var _antd = require("antd");

var _common = require("../../../../common");

var _ImageConfig = _interopRequireDefault(require("../../../../meta-comp/config-panels/ImageConfig"));

var _TextConfig = _interopRequireDefault(require("../../../../meta-comp/config-panels/TextConfig"));

var _BaseConfig = _interopRequireDefault(require("../../../../meta-comp/config-panels/BaseConfig"));

var _coreUtil = require("../../../../utils/coreUtil");

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

var __extends = void 0 && (void 0).__extends || function () {
  var _extendStatics = function extendStatics(d, b) {
    _extendStatics = Object.setPrototypeOf || {
      __proto__: []
    } instanceof Array && function (d, b) {
      d.__proto__ = b;
    } || function (d, b) {
      for (var p in b) {
        if (b.hasOwnProperty(p)) d[p] = b[p];
      }
    };

    return _extendStatics(d, b);
  };

  return function (d, b) {
    _extendStatics(d, b);

    function __() {
      this.constructor = d;
    }

    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  };
}();

var debug = require('debug')('worker:RecommendSecondConfig');

var RecommendSecondConfig =
/** @class */
function (_super) {
  __extends(RecommendSecondConfig, _super);

  function RecommendSecondConfig() {
    var _this = _super !== null && _super.apply(this, arguments) || this;

    _this.state = {};

    _this.onSourceTypeChange = function (value) {
      _this.props.panelProps.sourceType = value;

      _this.selfRender();
    };

    _this.getContentPanel = function () {
      var panelProps = _this.props.panelProps;

      if (!panelProps.hover) {
        panelProps.hover = {
          open: false,
          image: JSON.parse(JSON.stringify(panelProps.image)),
          groupName: JSON.parse(JSON.stringify(panelProps.groupName))
        };
      }

      var defaultSource = [{
        key: 'defaultSource_1',
        name: 'Image',
        value: /*#__PURE__*/_react["default"].createElement(_ImageConfig["default"], {
          data: panelProps.image
        }),
        metaOption: panelProps.image
      }, {
        key: 'defaultSource_2',
        name: 'Group Name',
        value: /*#__PURE__*/_react["default"].createElement(_TextConfig["default"], {
          data: panelProps.groupName
        }),
        metaOption: panelProps.groupName
      }];

      var hoverSetting = /*#__PURE__*/_react["default"].createElement(_common.Collapse, {
        source: [{
          key: 'hoverSetting_1',
          name: 'Image',
          value: /*#__PURE__*/_react["default"].createElement(_ImageConfig["default"], {
            data: panelProps.hover.image
          }),
          toggleType: 'checkbox',
          metaOption: panelProps.hover.image
        }, {
          key: 'hoverSetting_2',
          name: 'Group Name',
          value: /*#__PURE__*/_react["default"].createElement(_TextConfig["default"], {
            data: panelProps.hover.groupName
          }),
          toggleType: 'checkbox',
          metaOption: panelProps.hover.groupName
        }],
        type: "checkbox"
      });

      var hoverSource = [{
        key: 'hoverSource_1',
        name: 'Hover',
        value: hoverSetting,
        metaOption: panelProps.hover
      }];
      return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_common.Collapse, {
        headerSize: "middle",
        onRefresh: function onRefresh() {
          return (0, _coreUtil.renderPreview)();
        },
        showActiveColor: true,
        source: defaultSource,
        type: "switch"
      }), /*#__PURE__*/_react["default"].createElement(_common.Field, {
        split: "bold",
        title: "Source Of Product"
      }, /*#__PURE__*/_react["default"].createElement(_antd.Select, {
        onChange: _this.onSourceTypeChange,
        style: {
          marginBottom: '20px'
        },
        value: panelProps.sourceType
      }, /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
        value: "select"
      }, "Select Product"), /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
        value: "recommend"
      }, "AI Recommendation")), panelProps.sourceType === 'select' && /*#__PURE__*/_react["default"].createElement(_common.ProductSource, {
        onChange: function onChange(v) {
          panelProps.prodIds = v;

          _this.selfRender();
        },
        value: panelProps.prodIds
      })), /*#__PURE__*/_react["default"].createElement(_common.Collapse, {
        headerSize: "middle",
        onRefresh: function onRefresh() {
          return (0, _coreUtil.renderPreview)();
        },
        showActiveColor: true,
        source: hoverSource,
        type: "switch"
      }));
    };

    return _this;
  }

  RecommendSecondConfig.prototype.render = function () {
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "recommend_second_conf_wrap"
    }, /*#__PURE__*/_react["default"].createElement(_common.Collapse, {
      divider: "bold",
      headerSize: "large",
      source: [{
        key: '1',
        name: 'Content',
        value: this.getContentPanel()
      }]
    }));
  };

  RecommendSecondConfig.defaultProps = {
    panelProps: {}
  };
  return RecommendSecondConfig;
}(_BaseConfig["default"]);

var _default = RecommendSecondConfig;
exports["default"] = _default;