import{jsx as e,jsxs as o}from"react/jsx-runtime";import{useCallback as i}from"react";import t from"../../hooks/useKeyEvent/index.js";import r from"../Flex/Flex.js";import n from"../Avatar/Avatar.js";import c from"../Clickable/ClickableWrapper.js";import l from"./AvatarGroupCounterTooltipContent.module.scss.js";import s from"../../hooks/useEventListener/index.js";import{useListenFocusTriggers as a}from"../../hooks/useListenFocusTriggers/index.js";import{FlexDirection as u,FlexGap as f}from"../Flex/FlexConstants.js";var d=["Tab"],b=["Escape"],m=200;function p(e){var o=e.counterContainerRef,r=void 0===o?void 0:o,n=e.tooltipContentContainerRef,c=e.focusPrevPlaceholderRef,l=e.focusNextPlaceholderRef,u=e.isKeyboardTooltipVisible,f=e.setIsKeyboardTooltipVisible,m=i((function(){u||setTimeout((function(){return f(!0)}),200)}),[u,f]),p=i((function(){u&&f(!1)}),[u,f]);a({ref:r,onFocusByKeyboard:m}),s({eventName:"blur",ref:n,callback:p}),t({keys:d,ref:r,withoutAnyModifier:!0,preventDefault:!0,callback:i((function(){u&&(null==n?void 0:n.current)&&n.current.focus()}),[u,n])}),t({keys:d,modifier:t.modifiers.SHIFT,ref:r,callback:p}),t({keys:d,ref:n,withoutAnyModifier:!0,callback:i((function(){(null==l?void 0:l.current)&&l.current.focus(),u&&f(!1)}),[l,u,f])}),t({keys:d,ref:n,modifier:t.modifiers.SHIFT,callback:i((function(){(null==c?void 0:c.current)&&c.current.focus(),u&&f(!1)}),[c,u,f])}),t({keys:b,ref:n,callback:i((function(){(null==r?void 0:r.current)&&r.current.focus(),u&&f(!1)}),[r,u,f])}),t({keys:b,ref:r,callback:p}),s({eventName:"focus",ref:l,callback:p})}var v=function(i,t,s,a,d){var b=i.value,m=Object.assign(Object.assign({},s),{width:d?void 0:"100%"}),p="tooltip-item-".concat(t,"-label");return e(c,Object.assign({isClickable:!!(null==b?void 0:b.onClick),clickableProps:{onClick:function(e){return b.onClick(e,b.id)},tabIndex:"-1"}},{children:e("div",Object.assign({style:m},{children:o(r,Object.assign({direction:u.ROW,gap:f.XS,ariaLabelledby:p},{children:[e(n,Object.assign({},b,{tooltipProps:void 0,ariaLabel:"",size:n.sizes.SMALL,type:a||(null==b?void 0:b.type),tabIndex:-1})),!d&&e("div",Object.assign({id:p,className:l.tooltipAvatarItemTitle},{children:b.tooltipContent}))]}))}))}),t)};export{m as TOOLTIP_SHOW_DELAY,v as avatarRenderer,p as useTooltipContentTabNavigation};
