import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
import 'core-js/modules/es.symbol.js';
import 'core-js/modules/es.array.concat.js';
import 'core-js/modules/es.array.filter.js';
import 'core-js/modules/es.object.get-own-property-descriptor.js';
import 'core-js/modules/es.object.get-own-property-descriptors.js';
import 'core-js/modules/es.object.keys.js';
import 'core-js/modules/es.object.to-string.js';
import 'core-js/modules/web.dom-collections.for-each.js';
import React__default from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { ButtonKinds, Link } from '@carbon/react';
import Button from '../Button/Button.js';
import { settings } from '../../constants/Settings.js';
import deprecate from '../../internal/deprecate.js';
import SvgEmptystateErrorIcon from '../../icons/static/EmptyStateErrorIcon.js';
import SvgEmptystate404Icon from '../../icons/static/EmptyState404Icon.js';
import SvgEmptystateDefaultIcon from '../../icons/static/EmptyStateDefaultIcon.js';
import SvgEmptystateNotauthorizedIcon from '../../icons/static/EmptyStateNotAuthorizedIcon.js';
import EmptyStateNoResultsIcon from '../../icons/static/EmptyStateNoResultsIcon.js';
import SvgEmptystateSuccessIcon from '../../icons/static/EmptyStateSuccessIcon.js';

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var iotPrefix = settings.iotPrefix;
var icons = {
  error: SvgEmptystateErrorIcon,
  error404: SvgEmptystate404Icon,
  empty: SvgEmptystateDefaultIcon,
  'not-authorized': SvgEmptystateNotauthorizedIcon,
  'no-result': EmptyStateNoResultsIcon,
  success: SvgEmptystateSuccessIcon
};
var smallIconProps = {
  width: 64,
  height: 64,
  viewBox: '0 0 80 80'
};
var SMALL_SIZE = 'small';
var DEFAULT_SIZE = 'default';
var props = {
  /** Title of empty state */
  title: PropTypes.oneOfType([PropTypes.node, PropTypes.string]).isRequired,
  /** Description of empty state */
  body: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
  /** Optional image of state */
  icon: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOf(['error', 'error404', 'empty', 'not-authorized', 'no-result', 'success', ''])]),
  /** Optional action for container */
  action: PropTypes.shape({
    label: PropTypes.oneOfType([PropTypes.node, PropTypes.string]).isRequired,
    onClick: PropTypes.func.isRequired,
    /** primary, secondary, etc from carbon */
    kind: PropTypes.oneOf([].concat(_toConsumableArray(ButtonKinds), ['icon-selection']))
  }),
  /** Optional secondary action for container */
  secondaryAction: PropTypes.shape({
    label: PropTypes.string.isRequired,
    onClick: PropTypes.func.isRequired
  }),
  /** Specify an optional className to be applied to the container */
  className: PropTypes.string,
  // eslint-disable-next-line react/require-default-props
  testID: deprecate(PropTypes.string, "The 'testID' prop has been deprecated. Please use 'testId' instead."),
  /** Specify a testid for testing this component */
  testId: PropTypes.string,
  /** Size of the empty state */
  size: PropTypes.oneOf([DEFAULT_SIZE, SMALL_SIZE]),
  /** Arrangement of the empty state */
  arrangement: PropTypes.oneOf(['stacked', 'inline']),
  /** aria-labe to be passed to the empty state icon */
  iconAriaLabel: PropTypes.string,
  /** aria-hidden to be passed to the empty state icon */
  iconAriaHidden: PropTypes.bool
};

/**
 * Component to set empty states
 * For reference, visit https://pages.github.ibm.com/ai-applications/design/components/empty-states/usage/
 */
var EmptyState = function EmptyState(_ref) {
  var title = _ref.title,
    _ref$icon = _ref.icon,
    icon = _ref$icon === void 0 ? '' : _ref$icon,
    body = _ref.body,
    _ref$action = _ref.action,
    action = _ref$action === void 0 ? null : _ref$action,
    _ref$secondaryAction = _ref.secondaryAction,
    secondaryAction = _ref$secondaryAction === void 0 ? null : _ref$secondaryAction,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? '' : _ref$className,
    _ref$testId = _ref.testId,
    testId = _ref$testId === void 0 ? 'EmptyState' : _ref$testId,
    testID = _ref.testID,
    _ref$size = _ref.size,
    size = _ref$size === void 0 ? 'default' : _ref$size,
    _ref$arrangement = _ref.arrangement,
    arrangement = _ref$arrangement === void 0 ? 'stacked' : _ref$arrangement,
    iconAriaLabel = _ref.iconAriaLabel,
    iconAriaHidden = _ref.iconAriaHidden;
  var isSmall = size === SMALL_SIZE;
  return /*#__PURE__*/React__default.createElement("div", {
    className: classnames("".concat(iotPrefix, "--empty-state"), className, _defineProperty({}, "".concat(iotPrefix, "--empty-state--inline"), arrangement === 'inline'))
    // TODO: remove deprecated testID in v3.
    ,
    "data-testid": testID || testId
  }, /*#__PURE__*/React__default.createElement("div", {
    className: classnames("".concat(iotPrefix, "--empty-state--content"), _defineProperty({}, "".concat(iotPrefix, "--empty-state--content--with-gap"), arrangement === 'inline' && !!icon))
  }, icon && /*#__PURE__*/React__default.createElement(typeof icon === 'string' ? icons[icon] : icon, _objectSpread({
    className: classnames("".concat(iotPrefix, "--empty-state--icon"), _defineProperty({}, "".concat(iotPrefix, "--empty-state--icon--sm"), isSmall)),
    alt: '',
    'data-testid': "".concat(testID || testId, "-icon"),
    'aria-label': iconAriaLabel,
    'aria-hidden': iconAriaHidden
  }, isSmall && smallIconProps)), /*#__PURE__*/React__default.createElement("h3", {
    className: classnames("".concat(iotPrefix, "--empty-state--title"), _defineProperty({}, "".concat(iotPrefix, "--empty-state--title--sm"), isSmall))
    // TODO: remove deprecated testID in v3.
    ,
    "data-testid": "".concat(testID || testId, "-title")
  }, title), typeof body === 'string' ? /*#__PURE__*/React__default.createElement("p", {
    className: "".concat(iotPrefix, "--empty-state--text")
    // TODO: remove deprecated testID in v3.
    ,
    "data-testid": "".concat(testID || testId, "-body")
  }, body) : body, action && /*#__PURE__*/React__default.createElement("div", {
    className: "".concat(iotPrefix, "--empty-state--action")
    // TODO: remove deprecated testID in v3.
    ,
    "data-testid": "".concat(testID || testId, "-action")
  }, /*#__PURE__*/React__default.createElement(Button, {
    kind: action.kind,
    onClick: action.onClick,
    size: isSmall ? 'sm' : 'md'
  }, action.label)), secondaryAction && /*#__PURE__*/React__default.createElement("div", {
    className: "".concat(iotPrefix, "--empty-state--link")
    // TODO: remove deprecated testID in v3.
    ,
    "data-testid": "".concat(testID || testId, "-secondaryAction")
  }, secondaryAction.label &&
  /*#__PURE__*/
  // eslint-disable-next-line jsx-a11y/anchor-is-valid
  React__default.createElement(Link, {
    onClick: secondaryAction.onClick
  }, secondaryAction.label))));
};
EmptyState.propTypes = props;
EmptyState.__docgenInfo = {
  "description": "Component to set empty states\nFor reference, visit https://pages.github.ibm.com/ai-applications/design/components/empty-states/usage/",
  "methods": [],
  "displayName": "EmptyState",
  "props": {
    "icon": {
      "defaultValue": {
        "value": "''",
        "computed": false
      },
      "description": "Optional image of state",
      "type": {
        "name": "union",
        "value": [{
          "name": "func"
        }, {
          "name": "enum",
          "value": [{
            "value": "'error'",
            "computed": false
          }, {
            "value": "'error404'",
            "computed": false
          }, {
            "value": "'empty'",
            "computed": false
          }, {
            "value": "'not-authorized'",
            "computed": false
          }, {
            "value": "'no-result'",
            "computed": false
          }, {
            "value": "'success'",
            "computed": false
          }, {
            "value": "''",
            "computed": false
          }]
        }]
      },
      "required": false
    },
    "action": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "Optional action for container",
      "type": {
        "name": "shape",
        "value": {
          "label": {
            "name": "union",
            "value": [{
              "name": "node"
            }, {
              "name": "string"
            }],
            "required": true
          },
          "onClick": {
            "name": "func",
            "required": true
          },
          "kind": {
            "name": "enum",
            "value": [{
              "value": "...ButtonKinds",
              "computed": true
            }, {
              "value": "'icon-selection'",
              "computed": false
            }],
            "description": "primary, secondary, etc from carbon",
            "required": false
          }
        }
      },
      "required": false
    },
    "secondaryAction": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "Optional secondary action for container",
      "type": {
        "name": "shape",
        "value": {
          "label": {
            "name": "string",
            "required": true
          },
          "onClick": {
            "name": "func",
            "required": true
          }
        }
      },
      "required": false
    },
    "className": {
      "defaultValue": {
        "value": "''",
        "computed": false
      },
      "description": "Specify an optional className to be applied to the container",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "testId": {
      "defaultValue": {
        "value": "'EmptyState'",
        "computed": false
      },
      "description": "Specify a testid for testing this component",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "size": {
      "defaultValue": {
        "value": "'default'",
        "computed": false
      },
      "description": "Size of the empty state",
      "type": {
        "name": "enum",
        "value": [{
          "value": "'default'",
          "computed": false
        }, {
          "value": "'small'",
          "computed": false
        }]
      },
      "required": false
    },
    "arrangement": {
      "defaultValue": {
        "value": "'stacked'",
        "computed": false
      },
      "description": "Arrangement of the empty state",
      "type": {
        "name": "enum",
        "value": [{
          "value": "'stacked'",
          "computed": false
        }, {
          "value": "'inline'",
          "computed": false
        }]
      },
      "required": false
    },
    "title": {
      "description": "Title of empty state",
      "type": {
        "name": "union",
        "value": [{
          "name": "node"
        }, {
          "name": "string"
        }]
      },
      "required": true
    },
    "body": {
      "description": "Description of empty state",
      "type": {
        "name": "union",
        "value": [{
          "name": "string"
        }, {
          "name": "node"
        }]
      },
      "required": true
    },
    "testID": {
      "description": "",
      "type": {
        "name": "custom",
        "raw": "deprecate(\n  PropTypes.string,\n  `The 'testID' prop has been deprecated. Please use 'testId' instead.`\n)"
      },
      "required": false
    },
    "iconAriaLabel": {
      "description": "aria-labe to be passed to the empty state icon",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "iconAriaHidden": {
      "description": "aria-hidden to be passed to the empty state icon",
      "type": {
        "name": "bool"
      },
      "required": false
    }
  }
};
var EmptyState$1 = EmptyState;

export { EmptyState$1 as default };
