{"version":3,"sources":["../../../../src/components/notification-item/context.tsx"],"sourcesContent":["import type { Notification } from '@novu/js';\nimport type { NotificationItemHandlers } from '@novu/js/ui-core';\nimport { createContext, type ReactNode, useContext } from 'react';\n\nexport type NotificationItemRenderers = {\n  renderAvatar?: (notification: Notification) => ReactNode;\n  renderSubject?: (notification: Notification) => ReactNode;\n  renderBody?: (notification: Notification) => ReactNode;\n  renderDefaultActions?: (notification: Notification) => ReactNode;\n  renderCustomActions?: (notification: Notification) => ReactNode;\n};\n\nexport type NotificationItemContextValue = {\n  notification: Notification;\n  handlers: NotificationItemHandlers;\n  renderers: NotificationItemRenderers;\n};\n\nconst NotificationItemContext = createContext<NotificationItemContextValue | undefined>(undefined);\n\nexport const NotificationItemProvider = NotificationItemContext.Provider;\n\nexport const useNotificationItem = (part: string): NotificationItemContextValue => {\n  const context = useContext(NotificationItemContext);\n  if (!context) {\n    throw new Error(`<NotificationItem.${part} /> must be rendered inside <NotificationItem />`);\n  }\n\n  return context;\n};\n\n/**\n * The handlers given to `Inbox`, `Notifications` or `InboxContent`. Items rendered from their `renderNotification`\n * fall back to these when they get no handlers of their own.\n */\nconst NotificationHandlersContext = createContext<NotificationItemHandlers>({});\n\nexport const NotificationHandlersProvider = NotificationHandlersContext.Provider;\n\nexport const useInheritedNotificationHandlers = () => useContext(NotificationHandlersContext);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA0D;AAgB1D,IAAM,8BAA0B,4BAAwD,MAAS;AAE1F,IAAM,2BAA2B,wBAAwB;AAEzD,IAAM,sBAAsB,CAAC,SAA+C;AACjF,QAAM,cAAU,yBAAW,uBAAuB;AAClD,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,qBAAqB,IAAI,kDAAkD;AAAA,EAC7F;AAEA,SAAO;AACT;AAMA,IAAM,kCAA8B,4BAAwC,CAAC,CAAC;AAEvE,IAAM,+BAA+B,4BAA4B;AAEjE,IAAM,mCAAmC,UAAM,yBAAW,2BAA2B;","names":[]}