{"version":3,"sources":["../src/components/Avatar/useAvatar.ts"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport { useAvatarBase_unstable } from '@fluentui/react-avatar';\nimport { slot } from '@fluentui/react-utilities';\n\nimport type { AvatarProps, AvatarState } from './Avatar.types';\nimport { PresenceBadge } from '../../badge';\nimport { toDataAttributeValue } from '../../utils';\n\n/**\n * Returns the state for an Avatar component, given its props and ref.\n * The returned state can be modified with hooks before being passed to `renderAvatar`.\n */\nexport const useAvatar = (props: AvatarProps, ref: React.Ref<HTMLElement>): AvatarState => {\n  const baseState = useAvatarBase_unstable(props, ref);\n\n  const state: AvatarState = {\n    ...baseState,\n    components: { root: 'span', initials: 'span', icon: 'span', image: 'img', badge: PresenceBadge },\n    root: {\n      ...baseState.root,\n      'data-active': toDataAttributeValue(baseState.active !== 'unset' && baseState.active),\n    },\n    badge: slot.optional(props.badge, {\n      defaultProps: baseState.badge,\n      elementType: PresenceBadge,\n    }),\n  };\n\n  return state;\n};\n\n/**\n * Returns the value from the nearest Avatar context.\n */\nexport { useAvatarContext } from '@fluentui/react-avatar';\n"],"names":["useAvatar","useAvatarContext","props","ref","baseState","useAvatarBase_unstable","state","components","root","initials","icon","image","badge","PresenceBadge","toDataAttributeValue","active","slot","optional","defaultProps","elementType"],"mappings":"AAAA;;;;;;;;;;;;IAcaA,SAAS;eAATA;;IAsBJC,gBAAgB;eAAhBA,6BAAgB;;;6BAjCc;gCAClB;uBAGS;uBACO;AAM9B,MAAMD,YAAY,CAACE,OAAoBC;IAC5C,MAAMC,YAAYC,IAAAA,mCAAsB,EAACH,OAAOC;IAEhD,MAAMG,QAAqB;QACzB,GAAGF,SAAS;QACZG,YAAY;YAAEC,MAAM;YAAQC,UAAU;YAAQC,MAAM;YAAQC,OAAO;YAAOC,OAAOC,oBAAa;QAAC;QAC/FL,MAAM;YACJ,GAAGJ,UAAUI,IAAI;YACjB,eAAeM,IAAAA,2BAAoB,EAACV,UAAUW,MAAM,KAAK,WAAWX,UAAUW,MAAM;QACtF;QACAH,OAAOI,oBAAI,CAACC,QAAQ,CAACf,MAAMU,KAAK,EAAE;YAChCM,cAAcd,UAAUQ,KAAK;YAC7BO,aAAaN,oBAAa;QAC5B;IACF;IAEA,OAAOP;AACT"}