import e,{useCallback as o}from"react";import t from"../../hooks/useKeyEvent/index.js";import{Flex as r}from"@vibe/layout/mockedClassNames";import i from"../Avatar/Avatar.js";import{ClickableWrapper as n}from"@vibe/clickable/mockedClassNames";import a from"./AvatarGroupCounterTooltipContent.module.scss.js";import s from"../../hooks/useEventListener/index.js";import c from"../../hooks/useListenFocusTriggers/index.js";import{AVATAR_GROUP_COUNTER_TOOLTIP_SHOW_DELAY as l,AVATAR_GROUP_COUNTER_AVATAR_SIZE as u}from"./AvatarGroupConstants.js";import{keyCodes as f}from"../../constants/keyCodes.js";import"../../constants/sizes.js";var m=[f.TAB],d=[f.ESCAPE];function v(e){var r=e.counterContainerRef,i=void 0===r?void 0:r,n=e.tooltipContentContainerRef,a=e.focusPrevPlaceholderRef,u=e.focusNextPlaceholderRef,f=e.isKeyboardTooltipVisible,v=e.setIsKeyboardTooltipVisible,p=o((function(){f||setTimeout((function(){return v(!0)}),l)}),[f,v]),b=o((function(){f&&v(!1)}),[f,v]);c({ref:i,onFocusByKeyboard:p}),s({eventName:"blur",ref:n,callback:b}),t({keys:m,ref:i,withoutAnyModifier:!0,preventDefault:!0,callback:o((function(){f&&(null==n?void 0:n.current)&&n.current.focus()}),[f,n])}),t({keys:m,modifier:t.modifiers.SHIFT,ref:i,callback:b}),t({keys:m,ref:n,withoutAnyModifier:!0,callback:o((function(){(null==u?void 0:u.current)&&u.current.focus(),f&&v(!1)}),[u,f,v])}),t({keys:m,ref:n,modifier:t.modifiers.SHIFT,callback:o((function(){(null==a?void 0:a.current)&&a.current.focus(),f&&v(!1)}),[a,f,v])}),t({keys:d,ref:n,callback:o((function(){(null==i?void 0:i.current)&&i.current.focus(),f&&v(!1)}),[i,f,v])}),t({keys:d,ref:i,callback:b}),s({eventName:"focus",ref:u,callback:b})}var p=function(o,t,s,c,l){var f=o.value,m=Object.assign(Object.assign({},s),{width:l?void 0:"100%"}),d="tooltip-item-".concat(t,"-label");return e.createElement(n,{key:t,isClickable:!!(null==f?void 0:f.onClick),clickableProps:{onClick:function(e){return f.onClick(e,f.id)},tabIndex:"-1"}},e.createElement("div",{style:m},e.createElement(r,{direction:"row",gap:"xs",ariaLabelledby:d},e.createElement(i,Object.assign({},f,{tooltipProps:void 0,ariaLabel:"",customSize:u,type:c||(null==f?void 0:f.type),tabIndex:-1,size:i.sizes.SMALL,className:a.tooltipAvatarItemAvatar})),!l&&e.createElement("div",{id:d,className:a.tooltipAvatarItemTitle},f.tooltipContent))))};export{p as avatarRenderer,v as useTooltipContentTabNavigation};
//# sourceMappingURL=AvatarGroupCounterTooltipHelper.js.map
