"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "HintComponent", {
    enumerable: true,
    get: function() {
        return HintComponent;
    }
});
var _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
var _utils = require("../../../../utils");
var _InformationWrapperstyles = require("../../InformationWrapper.styles");
var _Icon = require("../../../_Icon");
var _InformationWrappertokens = require("../../InformationWrapper.tokens");
function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _getRequireWildcardCache(nodeInterop) {
    if (typeof WeakMap !== "function") return null;
    var cacheBabelInterop = new WeakMap();
    var cacheNodeInterop = new WeakMap();
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
    })(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj;
    }
    if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
        return {
            default: obj
        };
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj);
    }
    var newObj = {
        __proto__: null
    };
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for(var key in obj){
        if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc);
            } else {
                newObj[key] = obj[key];
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj);
    }
    return newObj;
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
var HintComponent = /*#__PURE__*/ (0, _react.forwardRef)(function(param, ref) {
    var hintText = param.hintText, isHintVisible = param.isHintVisible, hintTrigger = param.hintTrigger, hintTargetIcon = param.hintTargetIcon, hintPlacement = param.hintPlacement, hintHasArrow = param.hintHasArrow, hintOffset = param.hintOffset, hintWidth = param.hintWidth, hintContentLeft = param.hintContentLeft, withoutLabel = param.withoutLabel, size = param.size, handleHintShow = param.handleHintShow, handleHintHide = param.handleHintHide, handleHintClick = param.handleHintClick;
    var hintId = (0, _utils.safeUseId)();
    var getInfoIconSize = function getInfoIconSize() {
        if (!withoutLabel || size === 'xs') {
            return 'xs';
        }
        return 's';
    };
    var hintTriggerHandler = hintTrigger === 'hover' ? {
        onMouseEnter: handleHintShow,
        onMouseLeave: handleHintHide
    } : {
        onClick: handleHintClick
    };
    return /*#__PURE__*/ _react.default.createElement(_InformationWrapperstyles.Hint, {
        ref: ref,
        text: String(hintText),
        opened: isHintVisible,
        target: /*#__PURE__*/ _react.default.createElement(_InformationWrapperstyles.HintTargetWrapper, null, /*#__PURE__*/ _react.default.createElement(_InformationWrapperstyles.HintIconWrapper, _object_spread({
            id: hintId
        }, hintTriggerHandler), hintTargetIcon || /*#__PURE__*/ _react.default.createElement(_Icon.IconInfoCircleOutline, {
            size: getInfoIconSize(),
            color: "inherit",
            sizeCustomProperty: _InformationWrappertokens.tokens.hintCustomIconTargetSize
        }))),
        placement: hintPlacement,
        hasArrow: hintHasArrow,
        offset: hintOffset,
        minWidth: hintWidth,
        maxWidth: hintWidth,
        contentLeft: hintContentLeft,
        frame: hintId
    });
});
