"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _flex = _interopRequireDefault(require("../templates/flex"));
var _button = require("../button");
var _modal = require("../modal");
var _typography = require("../typography");
var _styled = require("./styled");
var _excluded = ["children"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
var BodyMessage = function BodyMessage(_ref) {
  var children = _ref.children,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  return typeof children === "object" ? children : /*#__PURE__*/_react["default"].createElement(_typography.Text, rest, children);
};
var ConfirmationDialog = function ConfirmationDialog(_ref2) {
  var _ref2$confirmLabel = _ref2.confirmLabel,
    confirmLabel = _ref2$confirmLabel === void 0 ? "Yes, remove" : _ref2$confirmLabel,
    _ref2$confirmWidth = _ref2.confirmWidth,
    confirmWidth = _ref2$confirmWidth === void 0 ? "128px" : _ref2$confirmWidth,
    _ref2$dataGa = _ref2["data-ga"],
    dataGA = _ref2$dataGa === void 0 ? "confirmation-dialog" : _ref2$dataGa,
    _ref2$dataTestid = _ref2["data-testid"],
    dataTestId = _ref2$dataTestid === void 0 ? "confirmationDialog" : _ref2$dataTestid,
    _ref2$declineLabel = _ref2.declineLabel,
    declineLabel = _ref2$declineLabel === void 0 ? "Cancel" : _ref2$declineLabel,
    _ref2$declineWidth = _ref2.declineWidth,
    declineWidth = _ref2$declineWidth === void 0 ? "128px" : _ref2$declineWidth,
    handleConfirm = _ref2.handleConfirm,
    handleDecline = _ref2.handleDecline,
    hideIcon = _ref2.hideIcon,
    _ref2$iconName = _ref2.iconName,
    iconName = _ref2$iconName === void 0 ? "warning_triangle_hollow" : _ref2$iconName,
    isConfirmDisabled = _ref2.isConfirmDisabled,
    isConfirmLoading = _ref2.isConfirmLoading,
    isDeclineDisabled = _ref2.isDeclineDisabled,
    isConfirmPositive = _ref2.isConfirmPositive,
    message = _ref2.message,
    title = _ref2.title,
    backdropContainerProps = _ref2.backdropContainerProps;
  return /*#__PURE__*/_react["default"].createElement(_styled.Dialog, {
    onEsc: handleDecline,
    backdropContainerProps: backdropContainerProps
  }, /*#__PURE__*/_react["default"].createElement(_styled.Content, {
    "data-testid": dataTestId
  }, /*#__PURE__*/_react["default"].createElement(_styled.Header, {
    "data-testid": dataTestId + "-headerContainer"
  }, /*#__PURE__*/_react["default"].createElement(_flex["default"], {
    "data-testid": dataTestId + "-header",
    gap: 2
  }, !hideIcon && /*#__PURE__*/_react["default"].createElement(_styled.TitleIcon, {
    "data-testid": dataTestId + "-headerIcon",
    name: iconName
  }), /*#__PURE__*/_react["default"].createElement(_styled.Title, {
    "data-testid": dataTestId + "-headerText"
  }, title)), handleDecline && /*#__PURE__*/_react["default"].createElement(_modal.ModalCloseButton, {
    "data-testid": dataTestId + "-headerClose",
    onClose: handleDecline
  })), /*#__PURE__*/_react["default"].createElement(_styled.Body, {
    "data-testid": dataTestId + "-body"
  }, /*#__PURE__*/_react["default"].createElement(BodyMessage, {
    "data-testid": dataTestId + "-bodyMessage"
  }, message)), /*#__PURE__*/_react["default"].createElement(_styled.Actions, {
    "data-testid": dataTestId + "-actions"
  }, handleDecline && /*#__PURE__*/_react["default"].createElement(_button.Button, {
    "data-ga": dataGA + "-::click-cancel::global-view",
    "data-testid": dataTestId + "-cancelAction",
    flavour: "hollow",
    disabled: isDeclineDisabled,
    label: declineLabel,
    onClick: handleDecline,
    width: declineWidth
  }), /*#__PURE__*/_react["default"].createElement(_button.Button, {
    "data-ga": dataGA + "-::click-confirm::global-view",
    "data-testid": dataTestId + "-confirmAction",
    danger: !isConfirmPositive && true,
    disabled: isConfirmDisabled,
    label: confirmLabel,
    onClick: handleConfirm,
    width: confirmWidth,
    isLoading: isConfirmLoading
  }))));
};
var _default = exports["default"] = ConfirmationDialog;