'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

require('core-js/modules/es.symbol.js');
require('core-js/modules/es.array.filter.js');
require('core-js/modules/es.object.get-own-property-descriptor.js');
require('core-js/modules/es.object.get-own-property-descriptors.js');
require('core-js/modules/es.object.keys.js');
require('core-js/modules/es.object.to-string.js');
require('core-js/modules/web.dom-collections.for-each.js');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _extends = require('@babel/runtime/helpers/extends');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var React = require('react');
var react = require('@carbon/react');
var PropTypes = require('prop-types');
var iconsReact = require('@carbon/icons-react');

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 _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
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 = ["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__default.default(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__default.default(_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__namespace.createElement(React__namespace.Fragment, null, showIcon && triggerText !== '' ? /*#__PURE__*/React__namespace.createElement(react.ToggletipLabel, null, /*#__PURE__*/React__namespace.createElement("div", {
    ref: toggleTipLabelRef
  }, triggerText)) : null, /*#__PURE__*/React__namespace.createElement(react.Toggletip, _extends__default.default({
    align: newAlign,
    autoAlign: useAutoPositioning
  }, other), triggerBtn !== null && triggerBtn !== void 0 ? triggerBtn : /*#__PURE__*/React__namespace.createElement(react.ToggletipButton, {
    "aria-label": triggerText
  }, showIcon ? IconCustomElement ? /*#__PURE__*/React__namespace.createElement(IconCustomElement, null) : /*#__PURE__*/React__namespace.createElement(iconsReact.Information, null) : /*#__PURE__*/React__namespace.createElement(react.ToggletipLabel, null, /*#__PURE__*/React__namespace.createElement("div", {
    ref: toggleTipLabelRef
  }, triggerText))), /*#__PURE__*/React__namespace.createElement(react.ToggletipContent, null, content, /*#__PURE__*/React__namespace.createElement(react.ToggletipActions, null, action))));
};
ToggleTip.propTypes = _objectSpread(_objectSpread({}, ToggleTip.propTypes), {}, {
  triggerText: PropTypes__default.default.string,
  triggerBtn: PropTypes__default.default.node,
  direction: PropTypes__default.default.string,
  renderIcon: PropTypes__default.default.node,
  content: PropTypes__default.default.node,
  action: PropTypes__default.default.node,
  useAutoPositioning: PropTypes__default.default.bool,
  showIcon: PropTypes__default.default.bool,
  toggleTipLabelRef: PropTypes__default.default.shape({
    current: PropTypes__default.default.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;

exports.ToggleTip = ToggleTip;
exports.default = ToggleTip$1;
