import _extends from "@babel/runtime/helpers/esm/extends";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

import React from "react";
import Highlight, { defaultProps } from "prism-react-renderer";
// import duotoneDark from 'prism-react-renderer/themes/dracula';
import { Message } from '@alicloudfe/components';
import copy from "copy-to-clipboard";
import theme from '../codesnippet/theme.js';

var BDesignContainer = function BDesignContainer(props) {
  var code = props.code,
      type = props.type,
      width = props.width,
      height = props.height,
      rest = _objectWithoutProperties(props, ["code", "type", "width", "height"]);

  return /*#__PURE__*/React.createElement(Highlight, _extends({}, defaultProps, {
    code: code,
    language: "jsx",
    theme: theme
  }), type === 'number' ? function (_ref) {
    var className = _ref.className,
        style = _ref.style,
        tokens = _ref.tokens,
        getLineProps = _ref.getLineProps,
        getTokenProps = _ref.getTokenProps;
    return /*#__PURE__*/React.createElement("pre", {
      className: "".concat(className, " codesnippet-numberPre"),
      style: _objectSpread(_objectSpread({}, style), {}, {
        width: width
      })
    }, tokens.map(function (line, i) {
      return /*#__PURE__*/React.createElement("div", _extends({
        className: "codesnippet-line",
        key: i
      }, getLineProps({
        line: line,
        key: i
      })), /*#__PURE__*/React.createElement("span", {
        className: "codesnippet-lineno"
      }, i + 1), /*#__PURE__*/React.createElement("span", {
        className: "codesnippet-linecontent"
      }, line.map(function (token, key) {
        return /*#__PURE__*/React.createElement("span", _extends({
          key: key
        }, getTokenProps({
          token: token,
          key: key
        })));
      })));
    }));
  } : function (_ref2) {
    var className = _ref2.className,
        style = _ref2.style,
        tokens = _ref2.tokens,
        getLineProps = _ref2.getLineProps,
        getTokenProps = _ref2.getTokenProps;
    return /*#__PURE__*/React.createElement("pre", {
      className: className,
      style: style
    }, tokens.map(function (line, i) {
      return /*#__PURE__*/React.createElement("div", getLineProps({
        line: line,
        key: i
      }), line.map(function (token, key) {
        return /*#__PURE__*/React.createElement("span", getTokenProps({
          token: token,
          key: key
        }));
      }));
    }), /*#__PURE__*/React.createElement("i", {
      className: "iconfont icon-copy icon-Copy-2-Outlined",
      onClick: function onClick() {
        copy(code);
        Message.success("代码已复制成功");
      }
    }));
  });
};

export default BDesignContainer;