text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.ActionStateDialog = ActionStateDialog;
  
  var React = _interopRequireWildcard(require("react"));
  
  var _default = _interopRequireDefault(require("part:@sanity/components/dialogs/default"));
  
  var _content = _interopRequireDefault(require("part:@sanity/components/dialogs/content"));
  
  var _default2 = _interopRequireDefault(require("part:@sanity/components/buttons/default"));
  
  var _buttonGrid = _interopRequireDefault(require("part:@sanity/components/buttons/button-grid"));
  
  var _popover = _interopRequireDefault(require("part:@sanity/components/dialogs/popover"));
  
  var _default3 = _interopRequireDefault(require("part:@sanity/components/snackbar/default"));
  
  var _DocumentStatusBar = _interopRequireDefault(require("./DocumentStatusBar.css"));
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  
  /* eslint-disable react/jsx-handler-names */
  function ActionStateDialog(props) {
    var dialog = props.dialog;
  
    if (dialog.type === 'legacy') {
      return /*#__PURE__*/React.createElement(React.Fragment, null, dialog.content);
    }
  
    if (dialog.type === 'confirm') {
      return /*#__PURE__*/React.createElement(_popover.default, {
        onClickOutside: dialog.onCancel,
        placement: "auto-end",
        useOverlay: false,
        hasAnimation: true
      }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
        className: _DocumentStatusBar.default.popOverText
      }, dialog.message), /*#__PURE__*/React.createElement(_buttonGrid.default, null, /*#__PURE__*/React.createElement(_default2.default, {
        onClick: dialog.onCancel,
        kind: "simple"
      }, "Cancel"), /*#__PURE__*/React.createElement(_default2.default, {
        onClick: dialog.onConfirm,
        color: dialog.color || 'danger'
      }, "Confirm"))));
    }
  
    if (dialog.type === 'modal') {
      return /*#__PURE__*/React.createElement(_default.default, {
        onClose: dialog.onClose,
        onClickOutside: dialog.onClose,
        showCloseButton: dialog.showCloseButton
      }, /*#__PURE__*/React.createElement(_content.default, {
        size: "medium",
        padding: "large"
      }, dialog.content));
    }
  
    if (dialog.type === 'popover') {
      return /*#__PURE__*/React.createElement(_popover.default, {
        onClickOutside: dialog.onClose,
        placement: "auto-end",
        useOverlay: false,
        hasAnimation: true
      }, dialog.content);
    }
  
    if (dialog.type === 'success') {
      return /*#__PURE__*/React.createElement(_default3.default, {
        kind: "success",
        isPersisted: false,
        isCloseable: true,
        timeout: 2000,
        onClose: dialog.onClose,
        title: dialog.title
      }, dialog.content);
    }
  
    if (dialog.type === 'error') {
      return /*#__PURE__*/React.createElement(_default3.default, {
        isCloseable: true,
        kind: "error",
        onClose: dialog.onClose,
        title: dialog.title
      }, dialog.content);
    }
  
    var unknownDialog = dialog;
    console.warn("Unsupported dialog type ".concat(unknownDialog.type));
    return /*#__PURE__*/React.createElement(_default.default, {
      onClose: unknownDialog.onClose,
      onClickOutside: unknownDialog.onClose
    }, /*#__PURE__*/React.createElement(_content.default, {
      size: "medium",
      padding: "large"
    }, unknownDialog.content || "Don't know how to render dialog of type ".concat(unknownDialog.type)));
  }