import 'core-js/modules/es.symbol.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 _extends from '@babel/runtime/helpers/extends';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import * as React from 'react';
import { Tooltip as Tooltip$2 } from '@carbon/react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { Information } from '@carbon/icons-react';
import { settings } from '../../constants/Settings.js';

var _excluded = ["triggerText", "direction", "align", "renderIcon", "useAutoPositioning", "showIcon", "children"];
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;

// will remove this method later
var getTooltipMenuOffset = function getTooltipMenuOffset() {
  return {
    top: 0,
    left: 0
  };
};
var Tooltip = function Tooltip(_ref) {
  var _ref$triggerText = _ref.triggerText,
    triggerText = _ref$triggerText === void 0 ? '' : _ref$triggerText,
    _ref$direction = _ref.direction,
    direction = _ref$direction === void 0 ? 'bottom' : _ref$direction,
    _ref$align = _ref.align,
    align = _ref$align === void 0 ? 'center' : _ref$align,
    IconCustomElement = _ref.renderIcon,
    _ref$useAutoPositioni = _ref.useAutoPositioning,
    useAutoPositioning = _ref$useAutoPositioni === void 0 ? false : _ref$useAutoPositioni,
    _ref$showIcon = _ref.showIcon,
    showIcon = _ref$showIcon === void 0 ? true : _ref$showIcon,
    children = _ref.children,
    other = _objectWithoutProperties(_ref, _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.createElement("div", {
    className: classnames("".concat(iotPrefix, "--tooltip"), _defineProperty({}, "".concat(iotPrefix, "--tooltip--with-label"), !!(showIcon && triggerText)))
  }, showIcon && triggerText ? triggerText : null, " ", /*#__PURE__*/React.createElement(Tooltip$2, _extends({
    label: children,
    align: newAlign,
    autoAlign: useAutoPositioning
  }, other), /*#__PURE__*/React.createElement("div", null, !showIcon ?
  // No icon
  triggerText :
  // Show icon
  IconCustomElement ? /*#__PURE__*/React.createElement(IconCustomElement, null) : /*#__PURE__*/React.createElement(Information, null))));
};
Tooltip.propTypes = _objectSpread(_objectSpread({}, Tooltip.propTypes), {}, {
  triggerText: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
  direction: PropTypes.string,
  renderIcon: PropTypes.node,
  useAutoPositioning: PropTypes.bool,
  showIcon: PropTypes.bool
});
Tooltip.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "Tooltip",
  "props": {
    "triggerText": {
      "defaultValue": {
        "value": "''",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "union",
        "value": [{
          "name": "string"
        }, {
          "name": "element"
        }]
      },
      "required": false
    },
    "direction": {
      "defaultValue": {
        "value": "'bottom'",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "align": {
      "defaultValue": {
        "value": "'center'",
        "computed": false
      },
      "required": false
    },
    "useAutoPositioning": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "showIcon": {
      "defaultValue": {
        "value": "true",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "renderIcon": {
      "description": "",
      "type": {
        "name": "node"
      },
      "required": false
    }
  }
};
var Tooltip$1 = Tooltip;

export { Tooltip, Tooltip$1 as default, getTooltipMenuOffset };
