import React from 'react';
import { locales } from '@pisell/utils';
import "./index.less";
import { PREFIX } from "../../index";
import Options from "../../../components/Packages/components/options";
var Specs = function Specs(props) {
  var _props$dataSource = props.dataSource,
    dataSource = _props$dataSource === void 0 ? {} : _props$dataSource,
    _props$maxSpecsCount = props.maxSpecsCount,
    maxSpecsCount = _props$maxSpecsCount === void 0 ? 1 : _props$maxSpecsCount,
    type = props.type;
  var bundle = dataSource.bundle,
    options = dataSource.options,
    product_option_string = dataSource.product_option_string,
    symbol = dataSource.symbol;
  var more = /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "__specs-more")
  }, locales.getText('pisell2.cart.sku-card.more'));

  /**
   * @description: 渲染多规格字符串
   * @return {*}
   */
  var renderOptionString = function renderOptionString() {
    return /*#__PURE__*/React.createElement("div", {
      className: "".concat(PREFIX, "__specs")
    }, /*#__PURE__*/React.createElement("div", null, product_option_string));
  };
  if (type === 'a9') {
    return /*#__PURE__*/React.createElement("div", {
      className: "".concat(PREFIX, "__specs-a9-wrap")
    }, product_option_string ? /*#__PURE__*/React.createElement("div", {
      className: "option-string-wrap"
    }, renderOptionString()) : null, options && (options === null || options === void 0 ? void 0 : options.length) > 0 ? /*#__PURE__*/React.createElement(Options, {
      options: options,
      amountSymbol: symbol
    }) : null);
  }
  if (Array.isArray(bundle) && (bundle === null || bundle === void 0 ? void 0 : bundle.length) > 0) {
    var displayItems = bundle.slice(0, maxSpecsCount);
    return /*#__PURE__*/React.createElement("div", {
      className: "".concat(PREFIX, "__specs")
    }, displayItems.map(function (item, index) {
      return /*#__PURE__*/React.createElement("div", {
        key: index
      }, item.title);
    }), bundle.length > maxSpecsCount ? more : null);
  }
  if (product_option_string) {
    return /*#__PURE__*/React.createElement("div", {
      className: "".concat(PREFIX, "__specs")
    }, /*#__PURE__*/React.createElement("div", null, product_option_string), options && options.length > maxSpecsCount ? more : null);
  }
  if (options && options.length > 0) {
    var _displayItems = options.slice(0, maxSpecsCount);
    return /*#__PURE__*/React.createElement("div", {
      className: "".concat(PREFIX, "__specs")
    }, _displayItems.map(function (item, index) {
      return /*#__PURE__*/React.createElement("div", {
        className: "spec-item",
        key: index
      }, /*#__PURE__*/React.createElement("span", {
        className: "spec-name"
      }, item.name), /*#__PURE__*/React.createElement("span", {
        className: "spec-num"
      }, /*#__PURE__*/React.createElement("span", null, symbol, item.price), /*#__PURE__*/React.createElement("span", null), "x", /*#__PURE__*/React.createElement("span", null, item.num)));
    }), options.length > maxSpecsCount ? more : null);
  }
  return null;
};
export default Specs;