import{inherits as o,createSuper as t,createClass as e,classCallCheck as i,assertThisInitialized as n}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as s}from"react/jsx-runtime";import{PureComponent as r,isValidElement as a}from"react";import l from"classnames";import{isFunction as p}from"lodash-es";import h from"../Dialog/Dialog.js";import{DialogPosition as d}from"../../constants/positions.js";import{TooltipTheme as c,TooltipArrowPosition as g,TooltipSize as T}from"./TooltipConstants.js";import"./Tooltip.scss.js";import{AnimationType as u,JustifyType as m}from"../../constants/dialog.js";var w={lastTooltipHideTS:null,openTooltipsCount:0},y=function(d){o(g,r);var c=t(g);function g(o){var t;return i(this,g),(t=c.call(this,o)).renderTooltipContent=t.renderTooltipContent.bind(n(t)),t.getShowDelay=t.getShowDelay.bind(n(t)),t.onTooltipShow=t.onTooltipShow.bind(n(t)),t.onTooltipHide=t.onTooltipHide.bind(n(t)),t.wasShown=!1,t}return e(g,[{key:"getContainer",value:function(){return document.getElementById("tooltips-container")||document.querySelector("body")}},{key:"renderTooltipContent",value:function(){var o,t=this.props,e=t.theme,i=t.content,n=t.paddingSize,r=t.className,h=t.style,d=t.tooltipSize;return i?(p(i)?o=i():(a(i)||"string"==typeof i&&i)&&(o=i),o?s("div",Object.assign({style:h,className:l("l3-style-tooltip l3-style-tooltip-".concat(e," padding-size-").concat(n," tooptip-size-").concat(d),r)},{children:o})):null):null}},{key:"onTooltipShow",value:function(){if(!this.wasShown){var o=this.props.onTooltipShow;w.openTooltipsCount++,this.wasShown=!0,o&&o()}}},{key:"onTooltipHide",value:function(){if(this.wasShown){var o=this.props.onTooltipHide;w.lastTooltipHideTS=Date.now(),w.openTooltipsCount--,this.wasShown=!1,o&&o()}}},{key:"getTimeSinceLastTooltip",value:function(){return w.openTooltipsCount>0?0:w.lastTooltipHideTS?Date.now()-w.lastTooltipHideTS:1/0}},{key:"getShowDelay",value:function(){var o=this.props,t=o.showDelay,e=o.immediateShowDelay,i=this.getTimeSinceLastTooltip();return(0===e||e)&&1500>i?{showDelay:e,preventAnimation:!0}:{showDelay:t,preventAnimation:!1}}},{key:"render",value:function(){var o=this.props,t=o.moveBy,e=o.justify,i=o.children,n=o.getContainer,r=o.theme,a=o.paddingSize,l=o.tip,p=o.showTrigger,d=o.hideTrigger,c=o.showOnDialogEnter;if(!i)return null;if(o.withoutDialog)return this.renderTooltipContent();var g=this.renderTooltipContent,T=Object.assign(Object.assign({},this.props),{startingEdge:e,tooltip:l,content:g,getContainer:n||this.getContainer,moveBy:t,tooltipClassName:"l3-style-arrow l3-style-arrow-".concat(r," padding-size-").concat(a),animationType:u.EXPAND,onDialogDidHide:this.onTooltipHide,onDialogDidShow:this.onTooltipShow,getDynamicShowDelay:this.getShowDelay,showTrigger:p,hideTrigger:d,showOnDialogEnter:c});return s(h,Object.assign({},T,{children:i}))}}]),g}();y.positions=d,y.themes=c,y.animationTypes=u,y.justifyTypes=m,y.arrowPositions=g,y.tooltipSize=T,y.defaultProps={arrowPosition:g.CENTER,moveBy:{main:4,secondary:0},theme:c.Dark,position:y.positions.TOP,justify:y.justifyTypes.CENTER,hideDelay:0,showDelay:300,disableDialogSlide:!0,animationType:u.EXPAND,withoutDialog:!1,containerSelector:"#tooltips-container",tip:!0,hideWhenReferenceHidden:!1,modifiers:[],showTrigger:h.hideShowTriggers.MOUSE_ENTER,hideTrigger:h.hideShowTriggers.MOUSE_LEAVE,showOnDialogEnter:!1,referenceWrapperClassName:"",tooltipSize:T.Small};export{y as default};
