{"version":3,"file":"AvatarStack.mjs","names":[],"sources":["../../../../src/components/Avatar/AvatarStack.tsx"],"sourcesContent":["import React, { type ComponentProps, type ElementType, useMemo } from 'react';\nimport { useComponentContext } from '../../context';\nimport { type AvatarProps, Avatar as DefaultAvatar } from './Avatar';\nimport clsx from 'clsx';\nimport { Badge, type BadgeSize } from '../Badge';\n\nexport function AvatarStack({\n  badgeSize,\n  capLimit = 3,\n  component: Component = 'div',\n  displayInfo = [],\n  size,\n}: {\n  component?: ElementType;\n  displayInfo?: (Pick<AvatarProps, 'imageUrl' | 'userName'> & { id?: string })[];\n  size: 'md' | 'sm' | 'xs' | null;\n  badgeSize?: BadgeSize;\n  capLimit?: number;\n}) {\n  const { Avatar = DefaultAvatar } = useComponentContext();\n\n  const displayInfoToRender = useMemo(\n    () => (displayInfo.length > capLimit ? displayInfo.slice(0, capLimit) : displayInfo),\n    [displayInfo, capLimit],\n  );\n  const overflowCount = displayInfo.length - displayInfoToRender.length;\n\n  if (!displayInfo.length) {\n    return null;\n  }\n\n  return (\n    <Component\n      className={clsx('str-chat__avatar-stack', {\n        [`str-chat__avatar-stack--size-${size}`]: typeof size === 'string',\n      })}\n      data-testid='avatar-stack'\n    >\n      {displayInfoToRender.map((info, index) => (\n        <Avatar\n          imageUrl={info.imageUrl}\n          key={info.id ?? `${info.userName}-${info.imageUrl}-${index}`}\n          size={size}\n          userName={info.userName}\n        />\n      ))}\n      {typeof overflowCount === 'number' && overflowCount > 0 && (\n        <Badge\n          className='str-chat__avatar-stack__count-badge'\n          data-testid='avatar-stack-count-badge'\n          size={badgeSize ?? size}\n          variant='counter'\n        >\n          +{overflowCount}\n        </Badge>\n      )}\n    </Component>\n  );\n}\n\nexport type AvatarStackProps = ComponentProps<typeof AvatarStack>;\n"],"mappings":";;;;;;;AAMA,SAAgB,YAAY,EAC1B,WACA,WAAW,GACX,WAAW,YAAY,OACvB,cAAc,CAAC,GACf,QAOC;CACD,MAAM,EAAE,QAAA,WAAS,WAAkB,oBAAoB;CAEvD,MAAM,sBAAsB,cACnB,YAAY,SAAS,WAAW,YAAY,MAAM,GAAG,QAAQ,IAAI,aACxE,CAAC,aAAa,QAAQ,CACxB;CACA,MAAM,gBAAgB,YAAY,SAAS,oBAAoB;CAE/D,IAAI,CAAC,YAAY,QACf,OAAO;CAGT,OACE,qBAAC,WAAD;EACE,WAAW,KAAK,0BAA0B,GACvC,gCAAgC,SAAS,OAAO,SAAS,SAC5D,CAAC;EACD,eAAY;YAJd,CAMG,oBAAoB,KAAK,MAAM,UAC9B,oBAAC,UAAD;GACE,UAAU,KAAK;GAET;GACN,UAAU,KAAK;EAChB,GAHM,KAAK,MAAM,GAAG,KAAK,SAAS,GAAG,KAAK,SAAS,GAAG,OAGtD,CACF,GACA,OAAO,kBAAkB,YAAY,gBAAgB,KACpD,qBAAC,OAAD;GACE,WAAU;GACV,eAAY;GACZ,MAAM,aAAa;GACnB,SAAQ;aAJV,CAKC,KACG,aACG;IAEA;;AAEf"}