import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["isOpen","size","status","onSetDirection","offset","style","className","children"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./Tooltip.css";import React,{forwardRef,useMemo,useState}from"react";import{Transition}from"react-transition-group";import{animateTimeout,cnMixPopoverAnimate}from"../../mixs/MixPopoverAnimate";import{cnMixPopoverArrow}from"../../mixs/MixPopoverArrow/MixPopoverArrow";import{cn}from"../../utils/bem";import{Popover}from"../Popover";import{Text}from"../Text";import{generateDeps,generateThemeClassNames,ThemeContext,useTheme}from"../Theme";import{tooltipPropSizesDefault}from"./types";var cnTooltip=cn("Tooltip"),ARROW_SIZE=6,ARROW_OFFSET=8;export var Tooltip=forwardRef(function(a,b){var c=a.isOpen,d=a.size,e=void 0===d?tooltipPropSizesDefault:d,f=a.status,g=a.onSetDirection,h=a.offset,i=void 0===h?0:h,j=a.style,k=a.className,l=a.children,m=_objectWithoutProperties(a,_excluded),n=useTheme(),o=n.theme,p=useState(),q=_slicedToArray(p,2),r=q[0],s=q[1],t=function(a){null===g||void 0===g?void 0:g(a),s(a)},u=useMemo(function(){var a=_objectSpread(_objectSpread({},o),{},{color:{primary:f?o.color.accent:o.color.invert,accent:o.color.accent,invert:o.color.primary}});return{theme:a,themeClassNames:generateThemeClassNames(a)}},[generateDeps(o),f]);return React.createElement(Transition,{in:c,unmountOnExit:!0,timeout:animateTimeout},function(a){var c;return React.createElement(ThemeContext.Provider,{value:u},React.createElement(Popover,Object.assign({},m,{arrowOffset:ARROW_OFFSET+ARROW_SIZE,offset:ARROW_SIZE+ARROW_OFFSET/2+i,onSetDirection:t,ref:b,className:cnTooltip({status:f},[k,cnMixPopoverAnimate({animate:a})]),style:_objectSpread((c={},_defineProperty(c,"--popover-arrow-size","".concat(ARROW_SIZE,"px")),_defineProperty(c,"--popover-arrow-offset","".concat(ARROW_OFFSET,"px")),c),j)}),React.createElement("div",{className:cnTooltip("Background")}),React.createElement("div",{className:cnTooltip("Arrow",[cnMixPopoverArrow({direction:r})])}),React.createElement("div",{className:cnTooltip("Content",{size:e})},"string"==typeof l||"number"==typeof l?React.createElement(Text,{view:"primary",size:"m",lineHeight:"m"},l):l)))})});
//# sourceMappingURL=Tooltip.js.map