'use strict';

var core = require('@linaria/core');
var index = require('../../../core/Typo/index.js');
var React = require('react');
var SmallDialog = require('../../../core/SmallDialog/SmallDialog.js');
var RejectDialog_type = require('./RejectDialog.type.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);

const ContentList = "E_c1ss4prm";
const MultiRejectContentList = "E_ms3tlei";
const Description = "E_du44iy7";
const SecondaryDesc = "E_s1qmhanr";
const Divider = "E_drje1h0";
const SingleRejectContent = ({
  content
}) => {
  if (Array.isArray(content) && content.length > 1) {
    return /* @__PURE__ */React__default.default.createElement("div", {
      className: core.cx(ContentList)
    }, content.map((reason, index$1) => /* @__PURE__ */React__default.default.createElement("li", {
      className: index.Typo.Label.l4_regular,
      key: index$1
    }, index$1 + 1, ". ", reason)));
  }
  return /* @__PURE__ */React__default.default.createElement("div", {
    className: core.cx(ContentList, index.Typo.Label.l4_regular)
  }, content);
};
const MultiRejectContent = ({
  content
}) => /* @__PURE__ */React__default.default.createElement("div", {
  className: core.cx(MultiRejectContentList)
}, Object.entries(content).map(([name, reasons], index$1) => /* @__PURE__ */React__default.default.createElement("li", {
  className: index.Typo.Label.l4_regular,
  key: index$1
}, name, ": ", reasons.join("; "))));
const RejectDialog = props => {
  const {
    title,
    cancelText,
    description,
    className,
    footerClassName
  } = props;
  const renderContent = () => {
    switch (props.type) {
      case RejectDialog_type.RejectDialogType.Single:
        return /* @__PURE__ */React__default.default.createElement(SingleRejectContent, {
          content: props.content
        });
      case RejectDialog_type.RejectDialogType.All:
      case RejectDialog_type.RejectDialogType.Part:
        return /* @__PURE__ */React__default.default.createElement(React__default.default.Fragment, null, props.secondaryDesc && /* @__PURE__ */React__default.default.createElement("div", {
          className: core.cx(SecondaryDesc, index.Typo.Label.l4_regular)
        }, props.secondaryDesc), props.type === RejectDialog_type.RejectDialogType.Part && /* @__PURE__ */React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */React__default.default.createElement("div", {
          className: Divider
        }), /* @__PURE__ */React__default.default.createElement("div", {
          className: core.cx(Description, index.Typo.Label.l3_regular)
        }, props.partialDescription)), /* @__PURE__ */React__default.default.createElement(MultiRejectContent, {
          content: props.content
        }));
      case RejectDialog_type.RejectDialogType.Custom:
        return props.customContent;
    }
  };
  return /* @__PURE__ */React__default.default.createElement(SmallDialog.SmallDialog, {
    title,
    cancelText,
    showOk: props.type === RejectDialog_type.RejectDialogType.Part,
    okText: props.type === RejectDialog_type.RejectDialogType.Part ? props.okText : void 0,
    onOk: props.type === RejectDialog_type.RejectDialogType.Part ? props.onOk : void 0,
    okButtonProps: {
      danger: props.type === RejectDialog_type.RejectDialogType.Part
    },
    onCancel: props.onCancel,
    className,
    footerClassName
  }, description && /* @__PURE__ */React__default.default.createElement("div", {
    className: core.cx(Description, index.Typo.Label.l3_regular)
  }, description), renderContent());
};

exports.RejectDialog = RejectDialog;
