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 _defineProperty from '@babel/runtime/helpers/defineProperty';
import _extends from '@babel/runtime/helpers/extends';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import * as React from 'react';
import { ToggletipLabel, Toggletip, ToggletipButton, ToggletipContent, ToggletipActions } from '@carbon/react';
import PropTypes from 'prop-types';
import { Information } from '@carbon/icons-react';

var _excluded = ["triggerText", "triggerBtn", "direction", "align", "renderIcon", "content", "action", "useAutoPositioning", "showIcon", "toggleTipLabelRef", "triggerClassName"];
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 ToggleTip = function ToggleTip(_ref) {
  var triggerText = _ref.triggerText,
    triggerBtn = _ref.triggerBtn,
    direction = _ref.direction,
    align = _ref.align,
    IconCustomElement = _ref.renderIcon,
    content = _ref.content,
    action = _ref.action,
    useAutoPositioning = _ref.useAutoPositioning,
    showIcon = _ref.showIcon,
    toggleTipLabelRef = _ref.toggleTipLabelRef;
    _ref.triggerClassName;
    var 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(React.Fragment, null, showIcon && triggerText !== '' ? /*#__PURE__*/React.createElement(ToggletipLabel, null, /*#__PURE__*/React.createElement("div", {
    ref: toggleTipLabelRef
  }, triggerText)) : null, /*#__PURE__*/React.createElement(Toggletip, _extends({
    align: newAlign,
    autoAlign: useAutoPositioning
  }, other), triggerBtn !== null && triggerBtn !== void 0 ? triggerBtn : /*#__PURE__*/React.createElement(ToggletipButton, {
    "aria-label": triggerText
  }, showIcon ? IconCustomElement ? /*#__PURE__*/React.createElement(IconCustomElement, null) : /*#__PURE__*/React.createElement(Information, null) : /*#__PURE__*/React.createElement(ToggletipLabel, null, /*#__PURE__*/React.createElement("div", {
    ref: toggleTipLabelRef
  }, triggerText))), /*#__PURE__*/React.createElement(ToggletipContent, null, content, /*#__PURE__*/React.createElement(ToggletipActions, null, action))));
};
ToggleTip.propTypes = _objectSpread(_objectSpread({}, ToggleTip.propTypes), {}, {
  triggerText: PropTypes.string,
  triggerBtn: PropTypes.node,
  direction: PropTypes.string,
  renderIcon: PropTypes.node,
  content: PropTypes.node,
  action: PropTypes.node,
  useAutoPositioning: PropTypes.bool,
  showIcon: PropTypes.bool,
  toggleTipLabelRef: PropTypes.shape({
    current: PropTypes.node
  })
});
ToggleTip.defaultProps = _objectSpread(_objectSpread({}, ToggleTip.defaultProps), {}, {
  direction: 'bottom',
  align: 'center',
  triggerText: '',
  useAutoPositioning: false,
  showIcon: true,
  toggleTipLabelRef: undefined
});
ToggleTip.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "ToggleTip",
  "props": {
    "direction": {
      "defaultValue": {
        "value": "'bottom'",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "align": {
      "defaultValue": {
        "value": "'center'",
        "computed": false
      },
      "required": false
    },
    "triggerText": {
      "defaultValue": {
        "value": "''",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "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
    },
    "toggleTipLabelRef": {
      "defaultValue": {
        "value": "undefined",
        "computed": true
      },
      "description": "",
      "type": {
        "name": "shape",
        "value": {
          "current": {
            "name": "node",
            "required": false
          }
        }
      },
      "required": false
    },
    "triggerBtn": {
      "description": "",
      "type": {
        "name": "node"
      },
      "required": false
    },
    "renderIcon": {
      "description": "",
      "type": {
        "name": "node"
      },
      "required": false
    },
    "content": {
      "description": "",
      "type": {
        "name": "node"
      },
      "required": false
    },
    "action": {
      "description": "",
      "type": {
        "name": "node"
      },
      "required": false
    }
  }
};
var ToggleTip$1 = ToggleTip;

export { ToggleTip, ToggleTip$1 as default };
