'use strict';

var _extends = require('@babel/runtime/helpers/extends');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var react = require('@carbon/react');
var React = require('react');
var PropTypes = require('prop-types');

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

function _interopNamespace(e) {
  if (e && e.__esModule) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var _extends__default = /*#__PURE__*/_interopDefault(_extends);
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWithoutProperties);
var React__namespace = /*#__PURE__*/_interopNamespace(React);
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);

var _excluded = ["direction", "align", "tooltipText"];
var TooltipIcon = function TooltipIcon(props) {
  var direction = props.direction,
    align = props.align,
    tooltipText = props.tooltipText,
    other = _objectWithoutProperties__default.default(props, _excluded);
  var newAlign;
  // This function is to pass the old direction, align property to the new align property since The align and direction props have been merged into the align prop
  if (direction === 'bottom' && align === 'center') {
    newAlign = 'bottom';
  } else if (direction === 'bottom' && align === 'end') {
    newAlign = 'bottom-end';
  } else if (direction === 'top' && align === 'start') {
    newAlign = 'top-start';
  } else if (direction === 'top' && align === 'center') {
    newAlign = 'top';
  } else if (direction === 'top' && align === 'end') {
    newAlign = 'top-end';
  } else if (direction === 'right' && align === 'start') {
    newAlign = 'right-start';
  } else if (direction === 'right' && align === 'center') {
    newAlign = 'right';
  } else if (direction === 'right' && align === 'end') {
    newAlign = 'right-end';
  } else if (direction === 'left' && align === 'start') {
    newAlign = 'left-start';
  } else if (direction === 'left' && align === 'center') {
    newAlign = 'left';
  } else if (direction === 'left' && align === 'end') {
    newAlign = 'left-end';
  } else {
    newAlign = 'bottom-start';
  }
  return /*#__PURE__*/React__namespace.createElement(react.IconButton, _extends__default.default({}, other, {
    // The tooltipText prop has been renamed to label
    label: tooltipText,
    align: newAlign
  }));
};
TooltipIcon.propTypes = {
  direction: PropTypes__default.default.string,
  align: PropTypes__default.default.string,
  tooltipText: PropTypes__default.default.string
};
TooltipIcon.defaultProps = {
  direction: 'bottom',
  align: 'start',
  tooltipText: ''
};
TooltipIcon.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "TooltipIcon",
  "props": {
    "direction": {
      "defaultValue": {
        "value": "'bottom'",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "align": {
      "defaultValue": {
        "value": "'start'",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "tooltipText": {
      "defaultValue": {
        "value": "''",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    }
  }
};
var TooltipIcon$1 = TooltipIcon;

module.exports = TooltipIcon$1;
