@edusight/notification-widget 1.0.41 → 1.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/hooks/usePreferencesSync.ts","../src/hooks/useSpecificPreferences.ts","../src/components/ErrorBoundary.tsx","../src/components/NotificationWidget.tsx","../src/index.ts"],"sourcesContent":["import { useEffect, useState, useCallback } from 'react';\n\nimport { NotificationPreferences } from '../types/core';\n\nconst useNotificationsClient = () => {\n return (window as any).__notificationSDK?.client;\n};\n\nexport interface UsePreferencesSyncProps {\n onPreferencesLoaded: (preferences: NotificationPreferences) => void;\n onError?: (error: Error) => void;\n}\n\nexport interface UsePreferencesSyncResult {\n isLoading: boolean;\n error: Error | null;\n preferences: NotificationPreferences | null;\n}\n\nexport const usePreferencesSync = ({\n onPreferencesLoaded,\n onError,\n}: UsePreferencesSyncProps): UsePreferencesSyncResult => {\n const notificationClient = useNotificationsClient();\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const [preferences, setPreferences] = useState<NotificationPreferences | null>(null);\n\n const loadPreferences = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n\n if (!notificationClient) {\n throw new Error('Notification client not available');\n }\n\n const config = (window as any).__notificationSDK?.config;\n\n if (!config) {\n throw new Error('SDK configuration not available');\n }\n\n const { subscriberId, tenantId, environmentId } = config;\n\n if (!subscriberId || !tenantId || !environmentId) {\n throw new Error('SubscriberId, TenantId or EnvironmentId not available in config');\n }\n\n const servicePreferences = await notificationClient.preferences.get(\n tenantId,\n subscriberId,\n environmentId,\n );\n\n // Fetch schedule separately\n let schedule = null;\n try {\n schedule = await notificationClient.preferences.getSchedule(\n tenantId,\n subscriberId,\n environmentId,\n );\n } catch (e) {\n console.warn('Failed to fetch schedule, using defaults:', e);\n }\n\n const mappedPreferences: NotificationPreferences = {\n channels: {\n email: servicePreferences.emailEnabled ?? true,\n push: servicePreferences.pushEnabled ?? true,\n sms: servicePreferences.smsEnabled ?? false,\n inApp: servicePreferences.inAppEnabled ?? true,\n },\n subscriptions: [],\n deliverySchedule: {\n enabled: schedule?.isEnabled || false,\n timezone: 'UTC',\n quietHours: {\n start: servicePreferences.quietHoursStart ?? '22:00',\n end: servicePreferences.quietHoursEnd ?? '08:00',\n },\n weekdays: schedule?.weeklySchedule\n ? [\n !!schedule.weeklySchedule.monday,\n !!schedule.weeklySchedule.tuesday,\n !!schedule.weeklySchedule.wednesday,\n !!schedule.weeklySchedule.thursday,\n !!schedule.weeklySchedule.friday,\n !!schedule.weeklySchedule.saturday,\n !!schedule.weeklySchedule.sunday,\n ]\n : [true, true, true, true, true, false, false],\n weeklySchedule: schedule?.weeklySchedule || undefined,\n },\n };\n\n if (servicePreferences.categories) {\n Object.entries(servicePreferences.categories).forEach(([workflowId, categoryPrefs]) => {\n mappedPreferences.subscriptions.push({\n workflowId,\n name: workflowId,\n enabled: true,\n channels: {\n email: (categoryPrefs as any).emailEnabled ?? true,\n push: (categoryPrefs as any).pushEnabled ?? true,\n sms: (categoryPrefs as any).smsEnabled ?? false,\n inApp: (categoryPrefs as any).inAppEnabled ?? true,\n },\n });\n });\n }\n\n setPreferences(mappedPreferences);\n onPreferencesLoaded(mappedPreferences);\n } catch (err: any) {\n const error = err instanceof Error ? err : new Error('Failed to load preferences');\n\n // If 404, it means preferences don't exist yet for this user.\n // We'll use defaults and suppress the error callback.\n const isNotFound = (err as any)?.response?.status === 404 || (err as any)?.status === 404;\n\n if (!isNotFound) {\n setError(error);\n onError?.(error);\n } else {\n console.warn('Preferences not found for user (404), using defaults.');\n }\n\n const defaultPreferences: NotificationPreferences = {\n channels: {\n email: true,\n push: true,\n sms: false,\n inApp: true,\n },\n subscriptions: [],\n deliverySchedule: {\n enabled: false,\n timezone: 'UTC',\n quietHours: {\n start: '22:00',\n end: '08:00',\n },\n weekdays: [true, true, true, true, true, false, false],\n },\n };\n setPreferences(defaultPreferences);\n onPreferencesLoaded(defaultPreferences);\n } finally {\n setIsLoading(false);\n }\n }, [notificationClient, onPreferencesLoaded, onError]);\n\n useEffect(() => {\n if (notificationClient) {\n loadPreferences();\n }\n }, [notificationClient, loadPreferences]);\n\n return {\n isLoading,\n error,\n preferences,\n };\n};\n","import { useState, useCallback, useEffect } from 'react';\n\nimport { WorkflowSubscription } from '../types/core';\n\nconst useNotificationsClient = () => {\n return (window as any).__notificationSDK?.client;\n};\n\nexport interface UseSpecificPreferencesResult {\n specificPreferences: WorkflowSubscription[];\n isLoading: boolean;\n hasMore: boolean;\n loadMore: () => Promise<void>;\n refetch: () => Promise<void>;\n}\n\nexport const useSpecificPreferences = (): UseSpecificPreferencesResult => {\n const client = useNotificationsClient();\n const [items, setItems] = useState<WorkflowSubscription[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [hasMore, setHasMore] = useState(true);\n const [offset, setOffset] = useState(0);\n const LIMIT = 5;\n\n const loadMore = useCallback(async () => {\n if (!client || isLoading || !hasMore) return;\n\n try {\n setIsLoading(true);\n const sdkConfig = (window as any).__notificationSDK?.config;\n if (!sdkConfig) return;\n\n const response = await client.preferences.listSpecific(\n sdkConfig.tenantId,\n sdkConfig.subscriberId,\n {\n includeWorkflows: true,\n includeTemplates: false,\n activeOnly: true,\n limit: LIMIT,\n offset: offset,\n },\n );\n\n const newItems = (response.items || []).map((item: any) => ({\n workflowId: item.identifier,\n name: item.name,\n enabled: item.preference.enabled,\n channels: item.preference.channels,\n }));\n\n setItems((prev) => {\n // Determine uniqueness by workflowId to avoid duplicates if offset logic overlaps or double fetch\n const existingIds = new Set(prev.map((i) => i.workflowId));\n const uniqueNewItems = newItems.filter((i: any) => !existingIds.has(i.workflowId));\n return [...prev, ...uniqueNewItems];\n });\n\n setOffset((prev) => prev + LIMIT);\n\n // Check if we reached the end\n if (\n newItems.length < LIMIT ||\n (response.total !== undefined && items.length + newItems.length >= response.total)\n ) {\n setHasMore(false);\n }\n } catch (error) {\n console.error('Failed to load specific preferences:', error);\n // Don't disable hasMore on error, user can retry by scrolling\n } finally {\n setIsLoading(false);\n }\n }, [client, offset, hasMore, isLoading, items.length]);\n\n // Initial load\n useEffect(() => {\n if (client && offset === 0 && items.length === 0) {\n loadMore();\n }\n }, [client, loadMore, offset, items.length]);\n\n const refetch = async () => {\n setItems([]);\n setOffset(0);\n setHasMore(true);\n // Note: The effect will trigger loadMore because offset becomes 0 and items becomes empty\n };\n\n return {\n specificPreferences: items,\n isLoading,\n hasMore,\n loadMore,\n refetch,\n };\n};\n","import React, { Component, ErrorInfo, ReactNode } from 'react';\nimport { MdError, MdRefresh } from 'react-icons/md';\n\nimport { ErrorBoundaryState } from '../types/core';\n\ninterface ErrorBoundaryProps {\n children: ReactNode;\n onError?: (error: Error, errorInfo: ErrorInfo) => void;\n}\n\nconst ErrorFallback: React.FC<{\n error: Error | null;\n onRetry: () => void;\n}> = ({ error, onRetry }) => (\n <div\n className=\"p-4 bg-[var(--widget-error)]/10 border border-[var(--widget-error)]/20 rounded-lg\"\n role=\"alert\"\n data-testid=\"error-boundary-fallback\"\n >\n <div className=\"flex items-center mb-2\">\n <MdError className=\"w-6 h-6 text-[var(--widget-error)] mr-2\" aria-hidden=\"true\" />\n <h3 className=\"text-sm font-medium text-[var(--widget-error)]\">Something went wrong</h3>\n </div>\n\n <p className=\"text-sm mb-3 text-[var(--widget-error)]/80\">\n The notification widget encountered an error and couldn&apos;t load properly.\n </p>\n\n {process.env.NODE_ENV === 'development' && error && (\n <details className=\"mb-3\">\n <summary className=\"text-xs cursor-pointer text-[var(--widget-error)] hover:text-[var(--widget-error)]/80 transition-colors\">\n Error details (development only)\n </summary>\n <pre className=\"mt-2 text-xs bg-[var(--widget-error)]/5 p-2 rounded overflow-auto max-h-32 text-[var(--widget-error)]\">\n {error.message}\n {error.stack && `\\n\\n${error.stack}`}\n </pre>\n </details>\n )}\n\n <button\n type=\"button\"\n className=\"inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-[var(--widget-error)] bg-[var(--widget-error)]/10 hover:bg-[var(--widget-error)]/20 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[var(--widget-error)] transition-colors\"\n onClick={onRetry}\n data-testid=\"error-retry-button\"\n >\n <MdRefresh className=\"mr-1 w-4 h-4\" aria-hidden=\"true\" />\n Try again\n </button>\n </div>\n);\n\nexport class NotificationWidgetErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {\n hasError: false,\n error: null,\n errorInfo: null,\n };\n }\n\n static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState> {\n return {\n hasError: true,\n error,\n };\n }\n\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n this.setState({\n errorInfo,\n });\n\n console.error('NotificationWidget Error Boundary caught an error:', {\n message: error.message,\n stack: error.stack,\n componentStack: errorInfo.componentStack,\n timestamp: new Date().toISOString(),\n });\n\n if (this.props.onError) {\n this.props.onError(error, errorInfo);\n }\n }\n\n handleRetry = () => {\n this.setState({\n hasError: false,\n error: null,\n errorInfo: null,\n });\n };\n\n render() {\n if (this.state.hasError) {\n return <ErrorFallback error={this.state.error} onRetry={this.handleRetry} />;\n }\n\n return this.props.children;\n }\n}\n\nexport const useErrorHandler = () => {\n return (error: Error, errorInfo?: ErrorInfo) => {\n console.error('Widget error:', {\n message: error.message,\n stack: error.stack,\n errorInfo,\n timestamp: new Date().toISOString(),\n });\n };\n};\n","import { NotificationClient } from '@edusight/notification-sdk';\nimport React, {\n useReducer,\n useEffect,\n useCallback,\n createContext,\n useContext,\n useRef,\n} from 'react';\nimport { io as ioClient } from 'socket.io-client';\n\nimport { useLivePreferences } from '../hooks/useLivePreferences';\nimport { usePreferencesSync } from '../hooks/usePreferencesSync';\nimport { useSpecificPreferences } from '../hooks/useSpecificPreferences';\nimport {\n NotificationWidgetProps,\n WidgetState,\n WidgetAction,\n SDKConfiguration,\n} from '../types/core';\nimport { createNotificationMapper } from '../utils/notification-mapper';\n\nimport { BellComponent } from './BellComponent';\nimport { ComponentErrorBoundary } from './ComponentErrorBoundary';\nimport { NotificationWidgetErrorBoundary } from './ErrorBoundary';\nimport { SDKConnectionFallback, LoadingFallback } from './FallbackComponents';\nimport { InboxPopover } from './InboxPopover';\n\ninterface SDKContextType {\n client: any;\n isInitialized: boolean;\n error: Error | null;\n}\n\nconst SDKContext = createContext<SDKContextType | null>(null);\n\nexport const useSDK = () => {\n const context = useContext(SDKContext);\n if (!context) {\n throw new Error('useSDK must be used within a NotificationWidget');\n }\n return context;\n};\n\nconst initialState: WidgetState = {\n notifications: [],\n unreadCount: 0,\n preferences: {\n channels: {\n email: true,\n push: true,\n sms: false,\n inApp: true,\n },\n subscriptions: [],\n deliverySchedule: {\n timezone: 'UTC',\n quietHours: {\n start: '22:00',\n end: '08:00',\n },\n weekdays: [true, true, true, true, true, false, false],\n },\n },\n ui: {\n isOpen: false,\n currentView: 'notifications',\n selectedNotifications: [],\n isLoading: false,\n error: null,\n },\n websocket: {\n connected: false,\n reconnecting: false,\n },\n};\n\nconst SDKProvider: React.FC<{ config: SDKConfiguration; children: React.ReactNode }> = ({\n config,\n children,\n}) => {\n const [sdkState, setSdkState] = React.useState<SDKContextType>({\n client: null,\n isInitialized: false,\n error: null,\n });\n\n useEffect(() => {\n let isMounted = true;\n\n const initializeSDK = async () => {\n try {\n const existingSDK = (window as any).__notificationSDK;\n\n // Check if we can reuse the existing SDK instance\n if (existingSDK?.client) {\n // Compare new config with existing config to determine if we need to re-initialize\n // We use simple JSON stringify as configs are simple objects with strings/numbers\n const isConfigMatch = JSON.stringify(existingSDK.config) === JSON.stringify(config);\n\n if (isConfigMatch) {\n if (isMounted) {\n setSdkState({\n client: existingSDK.client,\n isInitialized: true,\n error: null,\n });\n }\n return;\n } else {\n console.log('[NotificationWidget] Config changed, re-initializing SDK', {\n old: existingSDK.config,\n new: config,\n });\n }\n }\n\n const client = new NotificationClient({\n apiUrl: config.baseUrl,\n apiKey: config.apiKey,\n tenantId: config.tenantId,\n environmentId: config.environmentId,\n });\n\n (window as any).__notificationSDK = { client, config };\n\n if (isMounted) {\n setSdkState({\n client,\n isInitialized: true,\n error: null,\n });\n }\n } catch (error) {\n console.error('Failed to initialize SDK:', error);\n if (isMounted) {\n setSdkState({\n client: null,\n isInitialized: false,\n error: error as Error,\n });\n }\n }\n };\n\n initializeSDK();\n\n return () => {\n isMounted = false;\n };\n }, [config]);\n\n return <SDKContext.Provider value={sdkState}>{children}</SDKContext.Provider>;\n};\n\nconst widgetReducer = (state: WidgetState, action: WidgetAction): WidgetState => {\n switch (action.type) {\n case 'SET_NOTIFICATIONS':\n return {\n ...state,\n notifications: action.payload,\n unreadCount: action.payload.filter((n) => !n.isRead).length,\n };\n\n case 'ADD_NOTIFICATION':\n const newNotifications = [action.payload, ...state.notifications];\n return {\n ...state,\n notifications: newNotifications,\n unreadCount: newNotifications.filter((n) => !n.isRead).length,\n };\n\n case 'UPDATE_NOTIFICATION':\n const updatedNotifications = state.notifications.map((n) =>\n n.id === action.payload.id ? { ...n, ...action.payload.updates } : n,\n );\n return {\n ...state,\n notifications: updatedNotifications,\n unreadCount: updatedNotifications.filter((n) => !n.isRead).length,\n };\n\n case 'DELETE_NOTIFICATION':\n const filteredNotifications = state.notifications.filter((n) => n.id !== action.payload);\n return {\n ...state,\n notifications: filteredNotifications,\n unreadCount: filteredNotifications.filter((n) => !n.isRead).length,\n };\n\n case 'SET_PREFERENCES':\n return {\n ...state,\n preferences: action.payload,\n };\n\n case 'SET_UI_STATE':\n return {\n ...state,\n ui: { ...state.ui, ...action.payload },\n };\n\n case 'SET_WEBSOCKET_STATE':\n return {\n ...state,\n websocket: { ...state.websocket, ...action.payload },\n };\n\n default:\n return state;\n }\n};\n\nconst NotificationWidgetInternal: React.FC<Omit<NotificationWidgetProps, 'sdkConfig'>> = ({\n position = 'right',\n size = 'medium',\n theme = 'light',\n className = '',\n\n onError,\n onMorePreferencesClick,\n}) => {\n const [state, dispatch] = useReducer(widgetReducer, initialState);\n const { client, isInitialized, error: sdkError } = useSDK();\n const websocketRef = useRef<any>(null);\n\n const handlePreferencesChange = useCallback((preferences: any) => {\n dispatch({\n type: 'SET_PREFERENCES',\n payload: preferences,\n });\n }, []);\n\n const handleWidgetError = useCallback(\n (error: Error) => {\n console.error('Widget error:', error);\n if (onError) {\n onError(error);\n }\n },\n [onError],\n );\n\n const { error: preferencesLoadError } = usePreferencesSync({\n onPreferencesLoaded: handlePreferencesChange,\n onError: handleWidgetError,\n });\n\n const {\n specificPreferences,\n isLoading: isSpecificLoading,\n hasMore: hasMoreSpecific,\n loadMore: loadMoreSpecific,\n } = useSpecificPreferences();\n\n const {\n updatePreference,\n isSaving,\n error: preferencesError,\n } = useLivePreferences({\n preferences: state.preferences,\n onPreferencesChange: handlePreferencesChange,\n onError: handleWidgetError,\n });\n\n // Merge specific preferences into state when they load\n useEffect(() => {\n if (specificPreferences.length > 0) {\n const currentSubs = state.preferences.subscriptions;\n const newSubs = [...currentSubs];\n let changed = false;\n\n specificPreferences.forEach((sp) => {\n const existingIdx = newSubs.findIndex((s) => s.workflowId === sp.workflowId);\n\n // If not in state, add it\n if (existingIdx === -1) {\n newSubs.push(sp);\n changed = true;\n } else {\n // If existing name is just the ID (default), update with real name from specific prefs\n const existing = newSubs[existingIdx];\n if (existing.name === existing.workflowId && sp.name && sp.name !== sp.workflowId) {\n newSubs[existingIdx] = { ...existing, name: sp.name };\n changed = true;\n }\n }\n });\n\n if (changed) {\n dispatch({\n type: 'SET_PREFERENCES',\n payload: {\n ...state.preferences,\n subscriptions: newSubs,\n },\n });\n }\n }\n }, [specificPreferences]); // Depend on specificPreferences list changes (load more)\n\n // Create display list that respects order from hook but values from state\n const displaySpecificPreferences = React.useMemo(() => {\n return specificPreferences.map((sp) => {\n const found = state.preferences.subscriptions.find((s) => s.workflowId === sp.workflowId);\n return found || sp;\n });\n }, [specificPreferences, state.preferences.subscriptions]);\n\n const handleWebSocketEvent = useCallback((event: any) => {\n try {\n const notificationMapper = createNotificationMapper();\n\n switch (event.type) {\n case 'notification_received': {\n const wsPayload = event.data;\n\n if (!notificationMapper.validateWebSocketPayload(wsPayload)) {\n console.error('Invalid WebSocket notification payload, skipping', wsPayload);\n break;\n }\n\n const mappedNotification =\n notificationMapper.toWidgetNotificationFromWebSocket(wsPayload);\n dispatch({\n type: 'ADD_NOTIFICATION',\n payload: mappedNotification,\n });\n break;\n }\n\n case 'notification_updated':\n dispatch({\n type: 'UPDATE_NOTIFICATION',\n payload: {\n id: event.data.id || event.data.notificationId,\n updates: event.data,\n },\n });\n break;\n\n case 'notification_deleted':\n dispatch({\n type: 'DELETE_NOTIFICATION',\n payload: event.data.id || event.data.notificationId,\n });\n break;\n\n case 'preferences_updated':\n dispatch({\n type: 'SET_PREFERENCES',\n payload: event.data,\n });\n break;\n\n default:\n console.log('Unknown WebSocket event type:', event.type);\n }\n } catch (error) {\n console.error('Error handling WebSocket event:', error);\n }\n }, []);\n\n const connectWebSocket = useCallback(async () => {\n if (!client || !isInitialized || websocketRef.current) return;\n\n try {\n dispatch({\n type: 'SET_WEBSOCKET_STATE',\n payload: { reconnecting: true },\n });\n\n const sdkConfig = (window as any).__notificationSDK?.config;\n if (!sdkConfig) {\n throw new Error('SDK configuration not available for WebSocket connection');\n }\n\n const baseUrl = client.getApiHost();\n const namespace = '/v1/notifications';\n const fullUrl = `${baseUrl}${namespace}`;\n\n console.log('Connecting to Socket.IO at:', fullUrl);\n\n const socket = ioClient(fullUrl, {\n query: {\n tenantId: sdkConfig.tenantId,\n subscriberId: sdkConfig.subscriberId,\n environmentId: sdkConfig.environmentId,\n },\n transports: ['websocket'],\n autoConnect: false,\n reconnection: true,\n reconnectionAttempts: 10,\n reconnectionDelay: 1000,\n reconnectionDelayMax: 5000,\n });\n\n websocketRef.current = socket;\n\n socket.on('notification', (payload: any) => {\n console.log('Received notification:', payload);\n handleWebSocketEvent({\n type: 'notification_received',\n data: payload,\n });\n });\n\n socket.on('connect', () => {\n console.log('Socket.IO connected successfully');\n dispatch({\n type: 'SET_WEBSOCKET_STATE',\n payload: { connected: true, reconnecting: false },\n });\n });\n\n socket.on('disconnect', (reason: any) => {\n console.log('Socket.IO disconnected:', reason);\n dispatch({\n type: 'SET_WEBSOCKET_STATE',\n payload: { connected: false, reconnecting: false },\n });\n });\n\n socket.on('reconnect_attempt', (attempt: any) => {\n console.log('Socket.IO reconnection attempt:', attempt);\n dispatch({\n type: 'SET_WEBSOCKET_STATE',\n payload: { connected: false, reconnecting: true },\n });\n });\n\n socket.on('connect_error', (error: any) => {\n console.error('Socket.IO connection error:', error);\n dispatch({\n type: 'SET_WEBSOCKET_STATE',\n payload: { connected: false, reconnecting: false },\n });\n if (onError) {\n onError(error);\n }\n });\n\n socket.connect();\n } catch (error) {\n console.error('Failed to connect WebSocket:', error);\n dispatch({\n type: 'SET_WEBSOCKET_STATE',\n payload: { connected: false, reconnecting: false },\n });\n if (onError) {\n onError(error as Error);\n }\n }\n }, [client, isInitialized, handleWebSocketEvent, onError]);\n\n const disconnectWebSocket = useCallback(() => {\n if (websocketRef.current) {\n try {\n if (websocketRef.current.disconnect) {\n websocketRef.current.disconnect();\n }\n websocketRef.current = null;\n dispatch({\n type: 'SET_WEBSOCKET_STATE',\n payload: { connected: false, reconnecting: false },\n });\n } catch (error) {\n console.error('Error disconnecting WebSocket:', error);\n }\n }\n }, []);\n\n const handleBellClick = useCallback(() => {\n dispatch({\n type: 'SET_UI_STATE',\n payload: { isOpen: !state.ui.isOpen },\n });\n }, [state.ui.isOpen]);\n\n const handlePopoverClose = useCallback(() => {\n dispatch({\n type: 'SET_UI_STATE',\n payload: { isOpen: false },\n });\n }, []);\n\n const handleViewChange = useCallback((view: 'notifications' | 'preferences') => {\n dispatch({\n type: 'SET_UI_STATE',\n payload: { currentView: view },\n });\n }, []);\n\n const handleNotificationAction = useCallback(\n async (id: string, action: any) => {\n if (!client || !isInitialized) {\n console.error('SDK not initialized');\n return;\n }\n\n const sdkConfig = (window as any).__notificationSDK?.config;\n if (!sdkConfig) {\n console.error('SDK configuration not available');\n return;\n }\n\n if (!id) {\n console.error('notificationId is required');\n throw new Error('notificationId is required');\n }\n\n try {\n switch (action.type) {\n case 'mark_read':\n await client.inbox.markAsRead(\n id,\n sdkConfig.tenantId,\n sdkConfig.environmentId,\n sdkConfig.subscriberId,\n );\n break;\n case 'mark_unread':\n await client.inbox.markAsUnread(\n id,\n sdkConfig.tenantId,\n sdkConfig.environmentId,\n sdkConfig.subscriberId,\n );\n break;\n case 'archive':\n await client.inbox.archive(\n id,\n sdkConfig.tenantId,\n sdkConfig.environmentId,\n sdkConfig.subscriberId,\n );\n break;\n case 'delete':\n await client.inbox.delete(\n id,\n sdkConfig.tenantId,\n sdkConfig.environmentId,\n sdkConfig.subscriberId,\n );\n break;\n default:\n if (action.handler) {\n await action.handler(id);\n }\n break;\n }\n\n switch (action.type) {\n case 'mark_read':\n dispatch({\n type: 'UPDATE_NOTIFICATION',\n payload: { id, updates: { isRead: true } },\n });\n break;\n case 'mark_unread':\n dispatch({\n type: 'UPDATE_NOTIFICATION',\n payload: { id, updates: { isRead: false } },\n });\n break;\n case 'archive':\n dispatch({\n type: 'UPDATE_NOTIFICATION',\n payload: { id, updates: { isArchived: true } },\n });\n break;\n case 'delete':\n dispatch({\n type: 'DELETE_NOTIFICATION',\n payload: id,\n });\n break;\n }\n } catch (error) {\n console.error('Error performing notification action:', error);\n if (onError) {\n onError(error as Error);\n }\n }\n },\n [client],\n );\n\n useEffect(() => {\n if (!client || !isInitialized) return;\n\n const loadNotifications = async () => {\n try {\n dispatch({\n type: 'SET_UI_STATE',\n payload: { isLoading: true },\n });\n\n const sdkConfig = (window as any).__notificationSDK?.config;\n if (!sdkConfig) {\n throw new Error('SDK configuration not available');\n }\n\n const notificationMapper = createNotificationMapper();\n const response = await client.inbox.getRenderedNotifications(\n {\n channel: 'in_app',\n limit: 50,\n offset: 0,\n },\n sdkConfig.tenantId,\n sdkConfig.environmentId,\n sdkConfig.subscriberId,\n );\n\n const coreNotifications = (response?.items || []).map((item: any) =>\n notificationMapper.toWidgetNotification(item),\n );\n\n dispatch({\n type: 'SET_NOTIFICATIONS',\n payload: coreNotifications,\n });\n\n dispatch({\n type: 'SET_UI_STATE',\n payload: { isLoading: false, error: null },\n });\n } catch (error) {\n console.error('Failed to load notifications:', error);\n dispatch({\n type: 'SET_UI_STATE',\n payload: {\n isLoading: false,\n error: error as Error,\n },\n });\n if (onError) {\n onError(error as Error);\n }\n }\n };\n\n loadNotifications();\n }, [client, isInitialized, onError]);\n\n useEffect(() => {\n if (client && isInitialized) {\n connectWebSocket();\n }\n\n return () => {\n disconnectWebSocket();\n };\n }, [client]);\n\n useEffect(() => {\n if (!client || !isInitialized) return;\n\n if (state.websocket.connected) return;\n\n const pollInterval = setInterval(async () => {\n try {\n const sdkConfig = (window as any).__notificationSDK?.config;\n if (!sdkConfig) {\n return;\n }\n\n const notificationMapper = createNotificationMapper();\n const response = await client.inbox.getRenderedNotifications(\n {\n channel: 'in_app',\n limit: 50,\n offset: 0,\n },\n sdkConfig.tenantId,\n sdkConfig.environmentId,\n sdkConfig.subscriberId,\n );\n\n const coreNotifications = (response?.items || []).map((item: any) =>\n notificationMapper.toWidgetNotification(item),\n );\n\n dispatch({\n type: 'SET_NOTIFICATIONS',\n payload: coreNotifications,\n });\n } catch (error) {\n console.error('Polling failed:', error);\n }\n }, 30000);\n\n return () => clearInterval(pollInterval);\n }, [client, state.websocket.connected]);\n\n useEffect(() => {\n const handleStorageChange = (event: StorageEvent) => {\n if (event.key === 'notification_widget_sync' && event.newValue) {\n try {\n const syncData = JSON.parse(event.newValue);\n handleWebSocketEvent(syncData);\n } catch (error) {\n console.error('Error parsing sync data:', error);\n }\n }\n };\n\n window.addEventListener('storage', handleStorageChange);\n return () => window.removeEventListener('storage', handleStorageChange);\n }, [handleWebSocketEvent]);\n\n useEffect(() => {\n dispatch({\n type: 'SET_UI_STATE',\n payload: { isLoading: isSaving },\n });\n }, [isSaving]);\n\n useEffect(() => {\n const error = sdkError || preferencesError || preferencesLoadError;\n if (error) {\n dispatch({\n type: 'SET_UI_STATE',\n payload: { error: error },\n });\n }\n }, [sdkError, preferencesError, preferencesLoadError]);\n\n if (!isInitialized && !sdkError) {\n return (\n <div\n className={`mx-widget-root relative inline-block ${className}`}\n data-mx-widget=\"root\"\n data-widget-size={size || 'small'}\n data-theme={theme}\n data-testid=\"notification-widget\"\n >\n <ComponentErrorBoundary componentName=\"BellComponent\">\n <BellComponent unreadCount={0} onClick={() => { }} size={size} disabled={true} />\n </ComponentErrorBoundary>\n </div>\n );\n }\n\n if (sdkError) {\n return (\n <div\n className={`mx-widget-root relative inline-block ${className}`}\n data-mx-widget=\"root\"\n data-widget-size={size || 'small'}\n data-theme={theme}\n data-testid=\"notification-widget\"\n >\n <ComponentErrorBoundary\n componentName=\"BellComponent\"\n fallback={\n <SDKConnectionFallback\n error={sdkError.message}\n onRetry={() => window.location.reload()}\n />\n }\n >\n <BellComponent unreadCount={0} onClick={() => { }} size={size} disabled={true} />\n </ComponentErrorBoundary>\n </div>\n );\n }\n\n return (\n <div\n className={`mx-widget-root relative inline-block ${className}`}\n data-mx-widget=\"root\"\n data-widget-size={size || 'small'}\n data-theme={theme}\n data-testid=\"notification-widget\"\n >\n <ComponentErrorBoundary componentName=\"BellComponent\">\n <BellComponent\n unreadCount={state.unreadCount}\n onClick={handleBellClick}\n size={size}\n disabled={state.ui.isLoading}\n />\n </ComponentErrorBoundary>\n\n <ComponentErrorBoundary\n componentName=\"InboxPopover\"\n fallback={<LoadingFallback message=\"Unable to load notifications\" />}\n >\n <InboxPopover\n isOpen={state.ui.isOpen}\n onClose={handlePopoverClose}\n position={position}\n currentView={state.ui.currentView}\n onViewChange={handleViewChange}\n notifications={state.notifications}\n onNotificationAction={handleNotificationAction}\n preferences={state.preferences}\n onPreferenceChange={updatePreference}\n isPreferencesLoading={isSaving}\n specificPreferences={displaySpecificPreferences}\n onLoadMoreSpecific={loadMoreSpecific}\n hasMoreSpecific={hasMoreSpecific}\n isListLoading={isSpecificLoading}\n onMorePreferencesClick={onMorePreferencesClick}\n />\n </ComponentErrorBoundary>\n </div>\n );\n};\n\nexport const NotificationWidget: React.FC<NotificationWidgetProps> = ({ sdkConfig, ...props }) => {\n return (\n <NotificationWidgetErrorBoundary onError={props.onError}>\n <SDKProvider config={sdkConfig}>\n <NotificationWidgetInternal {...props} />\n </SDKProvider>\n </NotificationWidgetErrorBoundary>\n );\n};\n","export { NotificationWidget } from './components/NotificationWidget';\n\nexport { BellComponent } from './components/BellComponent';\nexport { InboxPopover } from './components/InboxPopover';\nexport { NotificationItem } from './components/NotificationItem';\nexport { PreferencesView } from './components/PreferencesView';\n\nexport { NotificationWidgetErrorBoundary } from './components/ErrorBoundary';\n\nexport type * from './types/core';\n\nexport type {\n Notification as SDKNotification,\n NotificationFilters,\n} from '@edusight/notification-sdk';\n\nimport '../src/styles/index.css';\n\nexport const VERSION = '3.0.0';\nexport const WIDGET_NAME = '@edusight/notification-widget';\n"],"names":["useNotificationsClient","usePreferencesSync","onPreferencesLoaded","onError","notificationClient","isLoading","setIsLoading","useState","error","setError","preferences","setPreferences","loadPreferences","useCallback","config","subscriberId","tenantId","environmentId","servicePreferences","schedule","mappedPreferences","workflowId","categoryPrefs","err","defaultPreferences","useEffect","useSpecificPreferences","client","items","setItems","hasMore","setHasMore","offset","setOffset","LIMIT","loadMore","sdkConfig","response","newItems","item","prev","existingIds","i","uniqueNewItems","ErrorFallback","onRetry","jsxs","jsx","MdError","MdRefresh","NotificationWidgetErrorBoundary","Component","props","errorInfo","SDKContext","createContext","useSDK","context","useContext","initialState","SDKProvider","children","sdkState","setSdkState","React","isMounted","existingSDK","NotificationClient","widgetReducer","state","action","n","newNotifications","updatedNotifications","filteredNotifications","NotificationWidgetInternal","position","size","theme","className","onMorePreferencesClick","dispatch","useReducer","isInitialized","sdkError","websocketRef","useRef","handlePreferencesChange","handleWidgetError","preferencesLoadError","specificPreferences","isSpecificLoading","hasMoreSpecific","loadMoreSpecific","updatePreference","isSaving","preferencesError","useLivePreferences","newSubs","changed","sp","existingIdx","s","existing","displaySpecificPreferences","handleWebSocketEvent","event","notificationMapper","createNotificationMapper","wsPayload","mappedNotification","connectWebSocket","fullUrl","socket","ioClient","payload","reason","attempt","disconnectWebSocket","handleBellClick","handlePopoverClose","handleViewChange","view","handleNotificationAction","id","coreNotifications","pollInterval","handleStorageChange","syncData","ComponentErrorBoundary","BellComponent","SDKConnectionFallback","LoadingFallback","InboxPopover","NotificationWidget","VERSION","WIDGET_NAME"],"mappings":";;;;;;;AAIA,MAAMA,KAAyB,MACrB,OAAe,mBAAmB,QAc/BC,KAAqB,CAAC;AAAA,EACjC,qBAAAC;AAAA,EACA,SAAAC;AACF,MAAyD;AACvD,QAAMC,IAAqBJ,GAAA,GACrB,CAACK,GAAWC,CAAY,IAAIC,EAAS,EAAI,GACzC,CAACC,GAAOC,CAAQ,IAAIF,EAAuB,IAAI,GAC/C,CAACG,GAAaC,CAAc,IAAIJ,EAAyC,IAAI,GAE7EK,IAAkBC,EAAY,YAAY;AAC9C,QAAI;AAIF,UAHAP,EAAa,EAAI,GACjBG,EAAS,IAAI,GAET,CAACL;AACH,cAAM,IAAI,MAAM,mCAAmC;AAGrD,YAAMU,IAAU,OAAe,mBAAmB;AAElD,UAAI,CAACA;AACH,cAAM,IAAI,MAAM,iCAAiC;AAGnD,YAAM,EAAE,cAAAC,GAAc,UAAAC,GAAU,eAAAC,EAAA,IAAkBH;AAElD,UAAI,CAACC,KAAgB,CAACC,KAAY,CAACC;AACjC,cAAM,IAAI,MAAM,iEAAiE;AAGnF,YAAMC,IAAqB,MAAMd,EAAmB,YAAY;AAAA,QAC9DY;AAAA,QACAD;AAAA,QACAE;AAAA,MAAA;AAIF,UAAIE,IAAW;AACf,UAAI;AACF,QAAAA,IAAW,MAAMf,EAAmB,YAAY;AAAA,UAC9CY;AAAA,UACAD;AAAA,UACAE;AAAA,QAAA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AA,gBACnB,oBAAoByB;AAAA,gBACpB,sBAAsBC;AAAA,gBACtB,qBAAqBS;AAAA,gBACrB,oBAAoBX;AAAA,gBACpB,iBAAAD;AAAA,gBACA,eAAeD;AAAA,gBACf,wBAAAX;AAAA,cAAA;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN,GAEasD,KAAwD,CAAC,EAAE,WAAAlG,GAAW,GAAGgB,QAElF,gBAAAL,EAACG,IAAA,EAAgC,SAASE,EAAM,SAC9C,UAAA,gBAAAL,EAACa,IAAA,EAAY,QAAQxB,GACnB,UAAA,gBAAAW,EAAC4B,IAAA,EAA4B,GAAGvB,EAAA,CAAO,GACzC,GACF,GChyBSmF,KAAU,SACVC,KAAc;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/hooks/usePreferencesSync.ts","../src/hooks/useSpecificPreferences.ts","../src/components/ErrorBoundary.tsx","../src/components/NotificationWidget.tsx","../src/index.ts"],"sourcesContent":["import { useEffect, useState, useCallback } from 'react';\n\nimport { NotificationPreferences } from '../types/core';\n\nconst useNotificationsClient = () => {\n return (window as any).__notificationSDK?.client;\n};\n\nexport interface UsePreferencesSyncProps {\n onPreferencesLoaded: (preferences: NotificationPreferences) => void;\n onError?: (error: Error) => void;\n}\n\nexport interface UsePreferencesSyncResult {\n isLoading: boolean;\n error: Error | null;\n preferences: NotificationPreferences | null;\n}\n\nexport const usePreferencesSync = ({\n onPreferencesLoaded,\n onError,\n}: UsePreferencesSyncProps): UsePreferencesSyncResult => {\n const notificationClient = useNotificationsClient();\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const [preferences, setPreferences] = useState<NotificationPreferences | null>(null);\n\n const loadPreferences = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n\n if (!notificationClient) {\n throw new Error('Notification client not available');\n }\n\n const config = (window as any).__notificationSDK?.config;\n\n if (!config) {\n throw new Error('SDK configuration not available');\n }\n\n const { subscriberId, tenantId, environmentId } = config;\n\n if (!subscriberId || !tenantId || !environmentId) {\n throw new Error('SubscriberId, TenantId or EnvironmentId not available in config');\n }\n\n const servicePreferences = await notificationClient.preferences.get(\n tenantId,\n subscriberId,\n environmentId,\n );\n\n // Fetch schedule separately\n let schedule = null;\n try {\n schedule = await notificationClient.preferences.getSchedule(\n tenantId,\n subscriberId,\n environmentId,\n );\n } catch (e) {\n console.warn('Failed to fetch schedule, using defaults:', e);\n }\n\n const mappedPreferences: NotificationPreferences = {\n channels: {\n email: servicePreferences.emailEnabled ?? true,\n push: servicePreferences.pushEnabled ?? true,\n sms: servicePreferences.smsEnabled ?? false,\n inApp: servicePreferences.inAppEnabled ?? true,\n },\n subscriptions: [],\n deliverySchedule: {\n enabled: schedule?.isEnabled || false,\n timezone: 'UTC',\n quietHours: {\n start: servicePreferences.quietHoursStart ?? '22:00',\n end: servicePreferences.quietHoursEnd ?? '08:00',\n },\n weekdays: schedule?.weeklySchedule\n ? [\n !!schedule.weeklySchedule.monday,\n !!schedule.weeklySchedule.tuesday,\n !!schedule.weeklySchedule.wednesday,\n !!schedule.weeklySchedule.thursday,\n !!schedule.weeklySchedule.friday,\n !!schedule.weeklySchedule.saturday,\n !!schedule.weeklySchedule.sunday,\n ]\n : [true, true, true, true, true, false, false],\n weeklySchedule: schedule?.weeklySchedule || undefined,\n },\n };\n\n if (servicePreferences.categories) {\n Object.entries(servicePreferences.categories).forEach(([workflowId, categoryPrefs]) => {\n mappedPreferences.subscriptions.push({\n workflowId,\n name: workflowId,\n enabled: true,\n channels: {\n email: (categoryPrefs as any).emailEnabled ?? true,\n push: (categoryPrefs as any).pushEnabled ?? true,\n sms: (categoryPrefs as any).smsEnabled ?? false,\n inApp: (categoryPrefs as any).inAppEnabled ?? true,\n },\n });\n });\n }\n\n setPreferences(mappedPreferences);\n onPreferencesLoaded(mappedPreferences);\n } catch (err: any) {\n const error = err instanceof Error ? err : new Error('Failed to load preferences');\n\n // If 404, it means preferences don't exist yet for this user.\n // We'll use defaults and suppress the error callback.\n const isNotFound = (err as any)?.response?.status === 404 || (err as any)?.status === 404;\n\n if (!isNotFound) {\n setError(error);\n onError?.(error);\n } else {\n console.warn('Preferences not found for user (404), using defaults.');\n }\n\n const defaultPreferences: NotificationPreferences = {\n channels: {\n email: true,\n push: true,\n sms: false,\n inApp: true,\n },\n subscriptions: [],\n deliverySchedule: {\n enabled: false,\n timezone: 'UTC',\n quietHours: {\n start: '22:00',\n end: '08:00',\n },\n weekdays: [true, true, true, true, true, false, false],\n },\n };\n setPreferences(defaultPreferences);\n onPreferencesLoaded(defaultPreferences);\n } finally {\n setIsLoading(false);\n }\n }, [notificationClient, onPreferencesLoaded, onError]);\n\n useEffect(() => {\n if (notificationClient) {\n loadPreferences();\n }\n }, [notificationClient, loadPreferences]);\n\n return {\n isLoading,\n error,\n preferences,\n };\n};\n","import { useState, useCallback, useEffect } from 'react';\n\nimport { WorkflowSubscription } from '../types/core';\n\nconst useNotificationsClient = () => {\n return (window as any).__notificationSDK?.client;\n};\n\nexport interface UseSpecificPreferencesResult {\n specificPreferences: WorkflowSubscription[];\n isLoading: boolean;\n hasMore: boolean;\n loadMore: () => Promise<void>;\n refetch: () => Promise<void>;\n}\n\nexport const useSpecificPreferences = (): UseSpecificPreferencesResult => {\n const client = useNotificationsClient();\n const [items, setItems] = useState<WorkflowSubscription[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [hasMore, setHasMore] = useState(true);\n const [offset, setOffset] = useState(0);\n const LIMIT = 5;\n\n const loadMore = useCallback(async () => {\n if (!client || isLoading || !hasMore) return;\n\n try {\n setIsLoading(true);\n const sdkConfig = (window as any).__notificationSDK?.config;\n if (!sdkConfig) return;\n\n const response = await client.preferences.listSpecific(\n sdkConfig.tenantId,\n sdkConfig.subscriberId,\n {\n includeWorkflows: true,\n includeTemplates: false,\n activeOnly: true,\n limit: LIMIT,\n offset: offset,\n },\n );\n\n const newItems = (response.items || []).map((item: any) => ({\n workflowId: item.identifier,\n name: item.name,\n enabled: item.preference.enabled,\n channels: item.preference.channels,\n }));\n\n setItems((prev) => {\n // Determine uniqueness by workflowId to avoid duplicates if offset logic overlaps or double fetch\n const existingIds = new Set(prev.map((i) => i.workflowId));\n const uniqueNewItems = newItems.filter((i: any) => !existingIds.has(i.workflowId));\n return [...prev, ...uniqueNewItems];\n });\n\n setOffset((prev) => prev + LIMIT);\n\n // Check if we reached the end\n if (\n newItems.length < LIMIT ||\n (response.total !== undefined && items.length + newItems.length >= response.total)\n ) {\n setHasMore(false);\n }\n } catch (error) {\n console.error('Failed to load specific preferences:', error);\n // Don't disable hasMore on error, user can retry by scrolling\n } finally {\n setIsLoading(false);\n }\n }, [client, offset, hasMore, isLoading, items.length]);\n\n // Initial load\n useEffect(() => {\n if (client && offset === 0 && items.length === 0) {\n loadMore();\n }\n }, [client, loadMore, offset, items.length]);\n\n const refetch = async () => {\n setItems([]);\n setOffset(0);\n setHasMore(true);\n // Note: The effect will trigger loadMore because offset becomes 0 and items becomes empty\n };\n\n return {\n specificPreferences: items,\n isLoading,\n hasMore,\n loadMore,\n refetch,\n };\n};\n","import React, { Component, ErrorInfo, ReactNode } from 'react';\nimport { MdError, MdRefresh } from 'react-icons/md';\n\nimport { ErrorBoundaryState } from '../types/core';\n\ninterface ErrorBoundaryProps {\n children: ReactNode;\n onError?: (error: Error, errorInfo: ErrorInfo) => void;\n}\n\nconst ErrorFallback: React.FC<{\n error: Error | null;\n onRetry: () => void;\n}> = ({ error, onRetry }) => (\n <div\n className=\"p-4 bg-[var(--widget-error)]/10 border border-[var(--widget-error)]/20 rounded-lg\"\n role=\"alert\"\n data-testid=\"error-boundary-fallback\"\n >\n <div className=\"flex items-center mb-2\">\n <MdError className=\"w-6 h-6 text-[var(--widget-error)] mr-2\" aria-hidden=\"true\" />\n <h3 className=\"text-sm font-medium text-[var(--widget-error)]\">Something went wrong</h3>\n </div>\n\n <p className=\"text-sm mb-3 text-[var(--widget-error)]/80\">\n The notification widget encountered an error and couldn&apos;t load properly.\n </p>\n\n {process.env.NODE_ENV === 'development' && error && (\n <details className=\"mb-3\">\n <summary className=\"text-xs cursor-pointer text-[var(--widget-error)] hover:text-[var(--widget-error)]/80 transition-colors\">\n Error details (development only)\n </summary>\n <pre className=\"mt-2 text-xs bg-[var(--widget-error)]/5 p-2 rounded overflow-auto max-h-32 text-[var(--widget-error)]\">\n {error.message}\n {error.stack && `\\n\\n${error.stack}`}\n </pre>\n </details>\n )}\n\n <button\n type=\"button\"\n className=\"inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-[var(--widget-error)] bg-[var(--widget-error)]/10 hover:bg-[var(--widget-error)]/20 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[var(--widget-error)] transition-colors\"\n onClick={onRetry}\n data-testid=\"error-retry-button\"\n >\n <MdRefresh className=\"mr-1 w-4 h-4\" aria-hidden=\"true\" />\n Try again\n </button>\n </div>\n);\n\nexport class NotificationWidgetErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = {\n hasError: false,\n error: null,\n errorInfo: null,\n };\n }\n\n static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState> {\n return {\n hasError: true,\n error,\n };\n }\n\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n this.setState({\n errorInfo,\n });\n\n console.error('NotificationWidget Error Boundary caught an error:', {\n message: error.message,\n stack: error.stack,\n componentStack: errorInfo.componentStack,\n timestamp: new Date().toISOString(),\n });\n\n if (this.props.onError) {\n this.props.onError(error, errorInfo);\n }\n }\n\n handleRetry = () => {\n this.setState({\n hasError: false,\n error: null,\n errorInfo: null,\n });\n };\n\n render() {\n if (this.state.hasError) {\n return <ErrorFallback error={this.state.error} onRetry={this.handleRetry} />;\n }\n\n return this.props.children;\n }\n}\n\nexport const useErrorHandler = () => {\n return (error: Error, errorInfo?: ErrorInfo) => {\n console.error('Widget error:', {\n message: error.message,\n stack: error.stack,\n errorInfo,\n timestamp: new Date().toISOString(),\n });\n };\n};\n","import { NotificationClient } from '@edusight/notification-sdk';\nimport React, {\n useReducer,\n useEffect,\n useCallback,\n createContext,\n useContext,\n useRef,\n} from 'react';\nimport { io as ioClient } from 'socket.io-client';\n\nimport { useLivePreferences } from '../hooks/useLivePreferences';\nimport { usePreferencesSync } from '../hooks/usePreferencesSync';\nimport { useSpecificPreferences } from '../hooks/useSpecificPreferences';\nimport {\n NotificationWidgetProps,\n WidgetState,\n WidgetAction,\n SDKConfiguration,\n} from '../types/core';\nimport { createNotificationMapper } from '../utils/notification-mapper';\n\nimport { BellComponent } from './BellComponent';\nimport { ComponentErrorBoundary } from './ComponentErrorBoundary';\nimport { NotificationWidgetErrorBoundary } from './ErrorBoundary';\nimport { SDKConnectionFallback, LoadingFallback } from './FallbackComponents';\nimport { InboxPopover } from './InboxPopover';\n\ninterface SDKContextType {\n client: any;\n isInitialized: boolean;\n error: Error | null;\n}\n\nconst SDKContext = createContext<SDKContextType | null>(null);\n\nexport const useSDK = () => {\n const context = useContext(SDKContext);\n if (!context) {\n throw new Error('useSDK must be used within a NotificationWidget');\n }\n return context;\n};\n\nconst initialState: WidgetState = {\n notifications: [],\n unreadCount: 0,\n preferences: {\n channels: {\n email: true,\n push: true,\n sms: false,\n inApp: true,\n },\n subscriptions: [],\n deliverySchedule: {\n timezone: 'UTC',\n quietHours: {\n start: '22:00',\n end: '08:00',\n },\n weekdays: [true, true, true, true, true, false, false],\n },\n },\n ui: {\n isOpen: false,\n currentView: 'notifications',\n selectedNotifications: [],\n isLoading: false,\n error: null,\n },\n websocket: {\n connected: false,\n reconnecting: false,\n },\n};\n\nconst SDKProvider: React.FC<{ config: SDKConfiguration; children: React.ReactNode }> = ({\n config,\n children,\n}) => {\n const [sdkState, setSdkState] = React.useState<SDKContextType>({\n client: null,\n isInitialized: false,\n error: null,\n });\n\n useEffect(() => {\n let isMounted = true;\n\n const initializeSDK = async () => {\n try {\n const existingSDK = (window as any).__notificationSDK;\n\n // Check if we can reuse the existing SDK instance\n if (existingSDK?.client) {\n // Compare new config with existing config to determine if we need to re-initialize\n // We use simple JSON stringify as configs are simple objects with strings/numbers\n const isConfigMatch = JSON.stringify(existingSDK.config) === JSON.stringify(config);\n\n if (isConfigMatch) {\n if (isMounted) {\n setSdkState({\n client: existingSDK.client,\n isInitialized: true,\n error: null,\n });\n }\n return;\n } else {\n console.log('[NotificationWidget] Config changed, re-initializing SDK', {\n old: existingSDK.config,\n new: config,\n });\n }\n }\n\n const client = new NotificationClient({\n apiUrl: config.baseUrl,\n apiKey: config.apiKey,\n tenantId: config.tenantId,\n environmentId: config.environmentId,\n });\n\n (window as any).__notificationSDK = { client, config };\n\n if (isMounted) {\n setSdkState({\n client,\n isInitialized: true,\n error: null,\n });\n }\n } catch (error) {\n console.error('Failed to initialize SDK:', error);\n if (isMounted) {\n setSdkState({\n client: null,\n isInitialized: false,\n error: error as Error,\n });\n }\n }\n };\n\n initializeSDK();\n\n return () => {\n isMounted = false;\n };\n }, [config]);\n\n return <SDKContext.Provider value={sdkState}>{children}</SDKContext.Provider>;\n};\n\nconst widgetReducer = (state: WidgetState, action: WidgetAction): WidgetState => {\n switch (action.type) {\n case 'SET_NOTIFICATIONS':\n return {\n ...state,\n notifications: action.payload,\n unreadCount: action.payload.filter((n) => !n.isRead).length,\n };\n\n case 'ADD_NOTIFICATION':\n const newNotifications = [action.payload, ...state.notifications];\n return {\n ...state,\n notifications: newNotifications,\n unreadCount: newNotifications.filter((n) => !n.isRead).length,\n };\n\n case 'UPDATE_NOTIFICATION':\n const updatedNotifications = state.notifications.map((n) =>\n n.id === action.payload.id ? { ...n, ...action.payload.updates } : n,\n );\n return {\n ...state,\n notifications: updatedNotifications,\n unreadCount: updatedNotifications.filter((n) => !n.isRead).length,\n };\n\n case 'DELETE_NOTIFICATION':\n const filteredNotifications = state.notifications.filter((n) => n.id !== action.payload);\n return {\n ...state,\n notifications: filteredNotifications,\n unreadCount: filteredNotifications.filter((n) => !n.isRead).length,\n };\n\n case 'SET_PREFERENCES':\n return {\n ...state,\n preferences: action.payload,\n };\n\n case 'SET_UI_STATE':\n return {\n ...state,\n ui: { ...state.ui, ...action.payload },\n };\n\n case 'SET_WEBSOCKET_STATE':\n return {\n ...state,\n websocket: { ...state.websocket, ...action.payload },\n };\n\n default:\n return state;\n }\n};\n\nconst NotificationWidgetInternal: React.FC<Omit<NotificationWidgetProps, 'sdkConfig'>> = ({\n position = 'right',\n size = 'medium',\n theme = 'light',\n className = '',\n\n onError,\n onMorePreferencesClick,\n}) => {\n const [state, dispatch] = useReducer(widgetReducer, initialState);\n const { client, isInitialized, error: sdkError } = useSDK();\n const websocketRef = useRef<any>(null);\n\n const handlePreferencesChange = useCallback((preferences: any) => {\n dispatch({\n type: 'SET_PREFERENCES',\n payload: preferences,\n });\n }, []);\n\n const handleWidgetError = useCallback(\n (error: Error) => {\n console.error('Widget error:', error);\n if (onError) {\n onError(error);\n }\n },\n [onError],\n );\n\n const { error: preferencesLoadError } = usePreferencesSync({\n onPreferencesLoaded: handlePreferencesChange,\n onError: handleWidgetError,\n });\n\n const {\n specificPreferences,\n isLoading: isSpecificLoading,\n hasMore: hasMoreSpecific,\n loadMore: loadMoreSpecific,\n } = useSpecificPreferences();\n\n const {\n updatePreference,\n isSaving,\n error: preferencesError,\n } = useLivePreferences({\n preferences: state.preferences,\n onPreferencesChange: handlePreferencesChange,\n onError: handleWidgetError,\n });\n\n // Merge specific preferences into state when they load\n useEffect(() => {\n if (specificPreferences.length > 0) {\n const currentSubs = state.preferences.subscriptions;\n const newSubs = [...currentSubs];\n let changed = false;\n\n specificPreferences.forEach((sp) => {\n const existingIdx = newSubs.findIndex((s) => s.workflowId === sp.workflowId);\n\n // If not in state, add it\n if (existingIdx === -1) {\n newSubs.push(sp);\n changed = true;\n } else {\n // If existing name is just the ID (default), update with real name from specific prefs\n const existing = newSubs[existingIdx];\n if (existing.name === existing.workflowId && sp.name && sp.name !== sp.workflowId) {\n newSubs[existingIdx] = { ...existing, name: sp.name };\n changed = true;\n }\n }\n });\n\n if (changed) {\n dispatch({\n type: 'SET_PREFERENCES',\n payload: {\n ...state.preferences,\n subscriptions: newSubs,\n },\n });\n }\n }\n }, [specificPreferences]); // Depend on specificPreferences list changes (load more)\n\n // Create display list that respects order from hook but values from state\n const displaySpecificPreferences = React.useMemo(() => {\n return specificPreferences.map((sp) => {\n const found = state.preferences.subscriptions.find((s) => s.workflowId === sp.workflowId);\n return found || sp;\n });\n }, [specificPreferences, state.preferences.subscriptions]);\n\n const handleWebSocketEvent = useCallback((event: any) => {\n try {\n const notificationMapper = createNotificationMapper();\n\n switch (event.type) {\n case 'notification_received': {\n const wsPayload = event.data;\n\n if (!notificationMapper.validateWebSocketPayload(wsPayload)) {\n console.error('Invalid WebSocket notification payload, skipping', wsPayload);\n break;\n }\n\n const mappedNotification =\n notificationMapper.toWidgetNotificationFromWebSocket(wsPayload);\n dispatch({\n type: 'ADD_NOTIFICATION',\n payload: mappedNotification,\n });\n break;\n }\n\n case 'notification_updated':\n dispatch({\n type: 'UPDATE_NOTIFICATION',\n payload: {\n id: event.data.id || event.data.notificationId,\n updates: event.data,\n },\n });\n break;\n\n case 'notification_deleted':\n dispatch({\n type: 'DELETE_NOTIFICATION',\n payload: event.data.id || event.data.notificationId,\n });\n break;\n\n case 'preferences_updated':\n dispatch({\n type: 'SET_PREFERENCES',\n payload: event.data,\n });\n break;\n\n default:\n console.log('Unknown WebSocket event type:', event.type);\n }\n } catch (error) {\n console.error('Error handling WebSocket event:', error);\n }\n }, []);\n\n const connectWebSocket = useCallback(async () => {\n if (!client || !isInitialized || websocketRef.current) return;\n\n try {\n dispatch({\n type: 'SET_WEBSOCKET_STATE',\n payload: { reconnecting: true },\n });\n\n const sdkConfig = (window as any).__notificationSDK?.config;\n if (!sdkConfig) {\n throw new Error('SDK configuration not available for WebSocket connection');\n }\n\n const baseUrl = client.getApiHost();\n const namespace = '/v1/notifications';\n const fullUrl = `${baseUrl}${namespace}`;\n\n console.log('Connecting to Socket.IO at:', fullUrl);\n\n const socket = ioClient(fullUrl, {\n query: {\n tenantId: sdkConfig.tenantId,\n subscriberId: sdkConfig.subscriberId,\n environmentId: sdkConfig.environmentId,\n },\n transports: ['websocket'],\n autoConnect: false,\n reconnection: true,\n reconnectionAttempts: 10,\n reconnectionDelay: 1000,\n reconnectionDelayMax: 5000,\n });\n\n websocketRef.current = socket;\n\n socket.on('notification', (payload: any) => {\n console.log('Received notification:', payload);\n handleWebSocketEvent({\n type: 'notification_received',\n data: payload,\n });\n });\n\n socket.on('connect', () => {\n console.log('Socket.IO connected successfully');\n dispatch({\n type: 'SET_WEBSOCKET_STATE',\n payload: { connected: true, reconnecting: false },\n });\n });\n\n socket.on('disconnect', (reason: any) => {\n console.log('Socket.IO disconnected:', reason);\n dispatch({\n type: 'SET_WEBSOCKET_STATE',\n payload: { connected: false, reconnecting: false },\n });\n });\n\n socket.on('reconnect_attempt', (attempt: any) => {\n console.log('Socket.IO reconnection attempt:', attempt);\n dispatch({\n type: 'SET_WEBSOCKET_STATE',\n payload: { connected: false, reconnecting: true },\n });\n });\n\n socket.on('connect_error', (error: any) => {\n console.error('Socket.IO connection error:', error);\n dispatch({\n type: 'SET_WEBSOCKET_STATE',\n payload: { connected: false, reconnecting: false },\n });\n if (onError) {\n onError(error);\n }\n });\n\n socket.connect();\n } catch (error) {\n console.error('Failed to connect WebSocket:', error);\n dispatch({\n type: 'SET_WEBSOCKET_STATE',\n payload: { connected: false, reconnecting: false },\n });\n if (onError) {\n onError(error as Error);\n }\n }\n }, [client, isInitialized, handleWebSocketEvent, onError]);\n\n const disconnectWebSocket = useCallback(() => {\n if (websocketRef.current) {\n try {\n if (websocketRef.current.disconnect) {\n websocketRef.current.disconnect();\n }\n websocketRef.current = null;\n dispatch({\n type: 'SET_WEBSOCKET_STATE',\n payload: { connected: false, reconnecting: false },\n });\n } catch (error) {\n console.error('Error disconnecting WebSocket:', error);\n }\n }\n }, []);\n\n const handleBellClick = useCallback(() => {\n dispatch({\n type: 'SET_UI_STATE',\n payload: { isOpen: !state.ui.isOpen },\n });\n }, [state.ui.isOpen]);\n\n const handlePopoverClose = useCallback(() => {\n dispatch({\n type: 'SET_UI_STATE',\n payload: { isOpen: false },\n });\n }, []);\n\n const handleViewChange = useCallback((view: 'notifications' | 'preferences') => {\n dispatch({\n type: 'SET_UI_STATE',\n payload: { currentView: view },\n });\n }, []);\n\n const handleNotificationAction = useCallback(\n async (id: string, action: any) => {\n if (!client || !isInitialized) {\n console.error('SDK not initialized');\n return;\n }\n\n const sdkConfig = (window as any).__notificationSDK?.config;\n if (!sdkConfig) {\n console.error('SDK configuration not available');\n return;\n }\n\n if (!id) {\n console.error('notificationId is required');\n throw new Error('notificationId is required');\n }\n\n try {\n switch (action.type) {\n case 'mark_read':\n await client.inbox.markAsRead(\n id,\n sdkConfig.tenantId,\n sdkConfig.environmentId,\n sdkConfig.subscriberId,\n );\n break;\n case 'mark_unread':\n await client.inbox.markAsUnread(\n id,\n sdkConfig.tenantId,\n sdkConfig.environmentId,\n sdkConfig.subscriberId,\n );\n break;\n case 'archive':\n await client.inbox.archive(\n id,\n sdkConfig.tenantId,\n sdkConfig.environmentId,\n sdkConfig.subscriberId,\n );\n break;\n case 'delete':\n await client.inbox.delete(\n id,\n sdkConfig.tenantId,\n sdkConfig.environmentId,\n sdkConfig.subscriberId,\n );\n break;\n default:\n if (action.handler) {\n await action.handler(id);\n }\n break;\n }\n\n switch (action.type) {\n case 'mark_read':\n dispatch({\n type: 'UPDATE_NOTIFICATION',\n payload: { id, updates: { isRead: true } },\n });\n break;\n case 'mark_unread':\n dispatch({\n type: 'UPDATE_NOTIFICATION',\n payload: { id, updates: { isRead: false } },\n });\n break;\n case 'archive':\n dispatch({\n type: 'UPDATE_NOTIFICATION',\n payload: { id, updates: { isArchived: true } },\n });\n break;\n case 'delete':\n dispatch({\n type: 'DELETE_NOTIFICATION',\n payload: id,\n });\n break;\n }\n } catch (error) {\n console.error('Error performing notification action:', error);\n if (onError) {\n onError(error as Error);\n }\n }\n },\n [client],\n );\n\n useEffect(() => {\n if (!client || !isInitialized) return;\n\n const loadNotifications = async () => {\n try {\n dispatch({\n type: 'SET_UI_STATE',\n payload: { isLoading: true },\n });\n\n const sdkConfig = (window as any).__notificationSDK?.config;\n if (!sdkConfig) {\n throw new Error('SDK configuration not available');\n }\n\n const notificationMapper = createNotificationMapper();\n const response = await client.inbox.getRenderedNotifications(\n {\n channel: 'in_app',\n limit: 50,\n offset: 0,\n },\n sdkConfig.tenantId,\n sdkConfig.environmentId,\n sdkConfig.subscriberId,\n );\n\n const coreNotifications = (response?.items || []).map((item: any) =>\n notificationMapper.toWidgetNotification(item),\n );\n\n dispatch({\n type: 'SET_NOTIFICATIONS',\n payload: coreNotifications,\n });\n\n dispatch({\n type: 'SET_UI_STATE',\n payload: { isLoading: false, error: null },\n });\n } catch (error) {\n console.error('Failed to load notifications:', error);\n dispatch({\n type: 'SET_UI_STATE',\n payload: {\n isLoading: false,\n error: error as Error,\n },\n });\n if (onError) {\n onError(error as Error);\n }\n }\n };\n\n loadNotifications();\n }, [client, isInitialized, onError]);\n\n useEffect(() => {\n if (client && isInitialized) {\n connectWebSocket();\n }\n\n return () => {\n disconnectWebSocket();\n };\n }, [client]);\n\n useEffect(() => {\n if (!client || !isInitialized) return;\n\n if (state.websocket.connected) return;\n\n const pollInterval = setInterval(async () => {\n try {\n const sdkConfig = (window as any).__notificationSDK?.config;\n if (!sdkConfig) {\n return;\n }\n\n const notificationMapper = createNotificationMapper();\n const response = await client.inbox.getRenderedNotifications(\n {\n channel: 'in_app',\n limit: 50,\n offset: 0,\n },\n sdkConfig.tenantId,\n sdkConfig.environmentId,\n sdkConfig.subscriberId,\n );\n\n const coreNotifications = (response?.items || []).map((item: any) =>\n notificationMapper.toWidgetNotification(item),\n );\n\n dispatch({\n type: 'SET_NOTIFICATIONS',\n payload: coreNotifications,\n });\n } catch (error) {\n console.error('Polling failed:', error);\n }\n }, 30000);\n\n return () => clearInterval(pollInterval);\n }, [client, state.websocket.connected]);\n\n useEffect(() => {\n const handleStorageChange = (event: StorageEvent) => {\n if (event.key === 'notification_widget_sync' && event.newValue) {\n try {\n const syncData = JSON.parse(event.newValue);\n handleWebSocketEvent(syncData);\n } catch (error) {\n console.error('Error parsing sync data:', error);\n }\n }\n };\n\n window.addEventListener('storage', handleStorageChange);\n return () => window.removeEventListener('storage', handleStorageChange);\n }, [handleWebSocketEvent]);\n\n useEffect(() => {\n dispatch({\n type: 'SET_UI_STATE',\n payload: { isLoading: isSaving },\n });\n }, [isSaving]);\n\n useEffect(() => {\n const error = sdkError || preferencesError || preferencesLoadError;\n if (error) {\n dispatch({\n type: 'SET_UI_STATE',\n payload: { error: error },\n });\n }\n }, [sdkError, preferencesError, preferencesLoadError]);\n\n if (!isInitialized && !sdkError) {\n return (\n <div\n className={`mx-widget-root relative inline-block ${className}`}\n data-mx-widget=\"root\"\n data-widget-size={size || 'small'}\n data-theme={theme}\n data-testid=\"notification-widget\"\n >\n <ComponentErrorBoundary componentName=\"BellComponent\">\n <BellComponent unreadCount={0} onClick={() => { }} size={size} disabled={true} />\n </ComponentErrorBoundary>\n </div>\n );\n }\n\n if (sdkError) {\n return (\n <div\n className={`mx-widget-root relative inline-block ${className}`}\n data-mx-widget=\"root\"\n data-widget-size={size || 'small'}\n data-theme={theme}\n data-testid=\"notification-widget\"\n >\n <ComponentErrorBoundary\n componentName=\"BellComponent\"\n fallback={\n <SDKConnectionFallback\n error={sdkError.message}\n onRetry={() => window.location.reload()}\n />\n }\n >\n <BellComponent unreadCount={0} onClick={() => { }} size={size} disabled={true} />\n </ComponentErrorBoundary>\n </div>\n );\n }\n\n return (\n <div\n className={`mx-widget-root min-w-[20rem] relative inline-block ${className}`}\n data-mx-widget=\"root\"\n data-widget-size={size || 'small'}\n data-theme={theme}\n data-testid=\"notification-widget\"\n >\n <ComponentErrorBoundary componentName=\"BellComponent\">\n <BellComponent\n unreadCount={state.unreadCount}\n onClick={handleBellClick}\n size={size}\n disabled={state.ui.isLoading}\n />\n </ComponentErrorBoundary>\n\n <ComponentErrorBoundary\n componentName=\"InboxPopover\"\n fallback={<LoadingFallback message=\"Unable to load notifications\" />}\n >\n <InboxPopover\n isOpen={state.ui.isOpen}\n onClose={handlePopoverClose}\n position={position}\n currentView={state.ui.currentView}\n onViewChange={handleViewChange}\n notifications={state.notifications}\n onNotificationAction={handleNotificationAction}\n preferences={state.preferences}\n onPreferenceChange={updatePreference}\n isPreferencesLoading={isSaving}\n specificPreferences={displaySpecificPreferences}\n onLoadMoreSpecific={loadMoreSpecific}\n hasMoreSpecific={hasMoreSpecific}\n isListLoading={isSpecificLoading}\n onMorePreferencesClick={onMorePreferencesClick}\n />\n </ComponentErrorBoundary>\n </div>\n );\n};\n\nexport const NotificationWidget: React.FC<NotificationWidgetProps> = ({ sdkConfig, ...props }) => {\n return (\n <NotificationWidgetErrorBoundary onError={props.onError}>\n <SDKProvider config={sdkConfig}>\n <NotificationWidgetInternal {...props} />\n </SDKProvider>\n </NotificationWidgetErrorBoundary>\n );\n};\n","export { NotificationWidget } from './components/NotificationWidget';\n\nexport { BellComponent } from './components/BellComponent';\nexport { InboxPopover } from './components/InboxPopover';\nexport { NotificationItem } from './components/NotificationItem';\nexport { PreferencesView } from './components/PreferencesView';\n\nexport { NotificationWidgetErrorBoundary } from './components/ErrorBoundary';\n\nexport type * from './types/core';\n\nexport type {\n Notification as SDKNotification,\n NotificationFilters,\n} from '@edusight/notification-sdk';\n\nimport '../src/styles/index.css';\n\nexport const VERSION = '3.0.0';\nexport const WIDGET_NAME = '@edusight/notification-widget';\n"],"names":["useNotificationsClient","usePreferencesSync","onPreferencesLoaded","onError","notificationClient","isLoading","setIsLoading","useState","error","setError","preferences","setPreferences","loadPreferences","useCallback","config","subscriberId","tenantId","environmentId","servicePreferences","schedule","mappedPreferences","workflowId","categoryPrefs","err","defaultPreferences","useEffect","useSpecificPreferences","client","items","setItems","hasMore","setHasMore","offset","setOffset","LIMIT","loadMore","sdkConfig","response","newItems","item","prev","existingIds","i","uniqueNewItems","ErrorFallback","onRetry","jsxs","jsx","MdError","MdRefresh","NotificationWidgetErrorBoundary","Component","props","errorInfo","SDKContext","createContext","useSDK","context","useContext","initialState","SDKProvider","children","sdkState","setSdkState","React","isMounted","existingSDK","NotificationClient","widgetReducer","state","action","n","newNotifications","updatedNotifications","filteredNotifications","NotificationWidgetInternal","position","size","theme","className","onMorePreferencesClick","dispatch","useReducer","isInitialized","sdkError","websocketRef","useRef","handlePreferencesChange","handleWidgetError","preferencesLoadError","specificPreferences","isSpecificLoading","hasMoreSpecific","loadMoreSpecific","updatePreference","isSaving","preferencesError","useLivePreferences","newSubs","changed","sp","existingIdx","s","existing","displaySpecificPreferences","handleWebSocketEvent","event","notificationMapper","createNotificationMapper","wsPayload","mappedNotification","connectWebSocket","fullUrl","socket","ioClient","payload","reason","attempt","disconnectWebSocket","handleBellClick","handlePopoverClose","handleViewChange","view","handleNotificationAction","id","coreNotifications","pollInterval","handleStorageChange","syncData","ComponentErrorBoundary","BellComponent","SDKConnectionFallback","LoadingFallback","InboxPopover","NotificationWidget","VERSION","WIDGET_NAME"],"mappings":";;;;;;;AAIA,MAAMA,KAAyB,MACrB,OAAe,mBAAmB,QAc/BC,KAAqB,CAAC;AAAA,EACjC,qBAAAC;AAAA,EACA,SAAAC;AACF,MAAyD;AACvD,QAAMC,IAAqBJ,GAAA,GACrB,CAACK,GAAWC,CAAY,IAAIC,EAAS,EAAI,GACzC,CAACC,GAAOC,CAAQ,IAAIF,EAAuB,IAAI,GAC/C,CAACG,GAAaC,CAAc,IAAIJ,EAAyC,IAAI,GAE7EK,IAAkBC,EAAY,YAAY;AAC9C,QAAI;AAIF,UAHAP,EAAa,EAAI,GACjBG,EAAS,IAAI,GAET,CAACL;AACH,cAAM,IAAI,MAAM,mCAAmC;AAGrD,YAAMU,IAAU,OAAe,mBAAmB;AAElD,UAAI,CAACA;AACH,cAAM,IAA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tB;AAAA,UAACkF;AAAA,UAAA;AAAA,YACC,eAAc;AAAA,YACd,UAAU,gBAAAlF,EAACqF,IAAA,EAAgB,SAAQ,+BAAA,CAA+B;AAAA,YAElE,UAAA,gBAAArF;AAAA,cAACsF;AAAA,cAAA;AAAA,gBACC,QAAQhE,EAAM,GAAG;AAAA,gBACjB,SAASmD;AAAA,gBACT,UAAA5C;AAAA,gBACA,aAAaP,EAAM,GAAG;AAAA,gBACtB,cAAcoD;AAAA,gBACd,eAAepD,EAAM;AAAA,gBACrB,sBAAsBsD;AAAA,gBACtB,aAAatD,EAAM;AAAA,gBACnB,oBAAoByB;AAAA,gBACpB,sBAAsBC;AAAA,gBACtB,qBAAqBS;AAAA,gBACrB,oBAAoBX;AAAA,gBACpB,iBAAAD;AAAA,gBACA,eAAeD;AAAA,gBACf,wBAAAX;AAAA,cAAA;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN,GAEasD,KAAwD,CAAC,EAAE,WAAAlG,GAAW,GAAGgB,QAElF,gBAAAL,EAACG,IAAA,EAAgC,SAASE,EAAM,SAC9C,UAAA,gBAAAL,EAACa,IAAA,EAAY,QAAQxB,GACnB,UAAA,gBAAAW,EAAC4B,IAAA,EAA4B,GAAGvB,EAAA,CAAO,GACzC,GACF,GChyBSmF,KAAU,SACVC,KAAc;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edusight/notification-widget",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "type": "module",
5
5
  "description": "React notification center widget for EduSight Notification Service, aligned with Novu's React UI and functionalities",
6
6
  "main": "./dist/index.cjs.js",
@@ -1,71 +0,0 @@
1
- "use strict";const c=require("react"),e=require("react/jsx-runtime");var Z={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},K=c.createContext&&c.createContext(Z),oe=["attr","size","title"];function de(t,r){if(t==null)return{};var a=ce(t,r),s,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)s=i[n],!(r.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(t,s)&&(a[s]=t[s])}return a}function ce(t,r){if(t==null)return{};var a={};for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s)){if(r.indexOf(s)>=0)continue;a[s]=t[s]}return a}function O(){return O=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)Object.prototype.hasOwnProperty.call(a,s)&&(t[s]=a[s])}return t},O.apply(this,arguments)}function U(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);r&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,s)}return a}function L(t){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?U(Object(a),!0).forEach(function(s){ue(t,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):U(Object(a)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(a,s))})}return t}function ue(t,r,a){return r=he(r),r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function he(t){var r=me(t,"string");return typeof r=="symbol"?r:r+""}function me(t,r){if(typeof t!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var s=a.call(t,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function ee(t){return t&&t.map((r,a)=>c.createElement(r.tag,L({key:a},r.attr),ee(r.child)))}function w(t){return r=>c.createElement(xe,O({attr:L({},t.attr)},r),ee(t.child))}function xe(t){var r=a=>{var{attr:s,size:n,title:i}=t,u=de(t,oe),h=n||a.size||"1em",o;return a.className&&(o=a.className),t.className&&(o=(o?o+" ":"")+t.className),c.createElement("svg",O({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,s,u,{className:o,style:L(L({color:t.color||a.color},a.style),t.style),height:h,width:h,xmlns:"http://www.w3.org/2000/svg"}),i&&c.createElement("title",null,i),t.children)};return K!==void 0?c.createElement(K.Consumer,null,a=>r(a)):r(Z)}function ge(t){return w({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M257 120.471c7.083 0 23.911 4.479 23.911 4.479 45.589 10.447 77.678 52.439 77.678 99.85V352.412l9.321 9.364 7.788 7.823H136.302l7.788-7.823 9.321-9.364V224.8c0-47.41 32.089-89.403 77.678-99.85 0 0 18.043-4.479 23.911-4.479M256 48c-17.602 0-31.059 13.518-31.059 31.2v14.559c-59.015 13.523-103.53 67.601-103.53 131.041v114.4L80 380.8v20.8h352v-20.8l-41.411-41.6V224.8c0-63.44-44.516-117.518-103.53-131.041V79.2c0-17.682-13.457-31.2-31.059-31.2zm41.411 374.4h-82.823c0 22.881 18.633 41.6 41.412 41.6s41.411-18.719 41.411-41.6z"},child:[]}]})(t)}const fe=({unreadCount:t,onClick:r,className:a="",disabled:s=!1})=>{const n=o=>o===0?"":o>99?"99+":o.toString(),i=o=>{s||(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),r())},u=n(t),h=t>0;return e.jsxs("button",{type:"button",className:`
2
- relative inline-flex items-center justify-center
3
- rounded-full
4
- text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)]
5
- bg-transparent hover:bg-[var(--widget-bg-hover)]
6
- border-0 cursor-pointer
7
- transition-colors duration-300
8
- focus:outline-none focus:ring-1 focus:ring-[var(--widget-primary)] focus:ring-offset-1
9
- disabled:opacity-70 disabled:cursor-not-allowed
10
- w-10 h-10
11
- mx-widget-bell
12
- ${a}
13
- `,onClick:r,onKeyDown:i,disabled:s,"aria-label":h?`Notifications (${t} unread)`:"Notifications","aria-expanded":!1,"aria-haspopup":"dialog","data-testid":"bell-component","data-mx-widget":"bell",children:[e.jsxs("div",{className:"relative inline-flex items-center justify-center text-align-center",children:[e.jsx(ge,{className:"w-6 h-6"}),h&&e.jsx("span",{className:`
14
- absolute
15
- flex items-center justify-center
16
- w-[16px] h-[16px]
17
- text-[10px] font-bold leading-none
18
- text-[var(--widget-text)] bg-red-500
19
- rounded-full
20
- border border-white dark:border-gray-900
21
- shadow-sm
22
- pointer-events-none
23
- text-align-center
24
- `,"aria-hidden":"true","data-testid":"unread-badge",style:{marginTop:"-25px",marginRight:"-25px"},children:u})]}),e.jsx("span",{className:"sr-only",children:h?`${t} unread notifications`:"No unread notifications"})]})};class V extends c.Component{constructor(r){super(r),this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,a){const{componentName:s="Unknown Component",onError:n}=this.props;n&&n(r,a)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:e.jsx("div",{className:"p-2 text-sm text-gray-500 bg-gray-50 border border-gray-200 rounded","data-testid":"component-error-fallback",children:e.jsxs("span",{children:["Unable to load ",this.props.componentName||"component"]})}):this.props.children}}function _(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"},child:[]}]})(t)}function pe(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"},child:[]}]})(t)}function ve(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"},child:[]},{tag:"path",attr:{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},child:[]}]})(t)}function be(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"},child:[]}]})(t)}function te(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.488.488 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 0 0-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"},child:[]}]})(t)}function we(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"},child:[]}]})(t)}function ye(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"},child:[]}]})(t)}function je(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4-8 5-8-5V6l8 5 8-5v2z"},child:[]}]})(t)}function re(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM12 17.5 6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z"},child:[]}]})(t)}function Ne(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"},child:[]},{tag:"path",attr:{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},child:[]}]})(t)}function ke(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M17 1.01 7 1c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99zM17 19H7V5h10v14z"},child:[]}]})(t)}function Ce(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m21.41 11.58-9-9C12.05 2.22 11.55 2 11 2H4c-1.1 0-2 .9-2 2v7c0 .55.22 1.05.59 1.42l9 9c.36.36.86.58 1.41.58.55 0 1.05-.22 1.41-.59l7-7c.37-.36.59-.86.59-1.41 0-.55-.23-1.06-.59-1.42zM5.5 7C4.67 7 4 6.33 4 5.5S4.67 4 5.5 4 7 4.67 7 5.5 6.33 7 5.5 7z"},child:[]}]})(t)}function Me(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"},child:[]}]})(t)}function ae(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"},child:[]}]})(t)}function q(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"},child:[]}]})(t)}function B(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"},child:[]}]})(t)}function ze(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M17.65 6.35A7.958 7.958 0 0 0 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0 1 12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"},child:[]}]})(t)}function Se(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM9 11H7V9h2v2zm4 0h-2V9h2v2zm4 0h-2V9h2v2z"},child:[]}]})(t)}function G(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M12 22c1.1 0 2-.9 2-2h-4a2 2 0 0 0 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z"},child:[]}]})(t)}function Ee(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"},child:[]},{tag:"path",attr:{d:"M14 17H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z"},child:[]}]})(t)}function se(t){return w({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V8l8 5 8-5v10zm-8-7L4 6h16l-8 5z"},child:[]}]})(t)}const He=({onRetry:t,error:r})=>e.jsxs("div",{className:"p-3 text-center","data-testid":"notifications-fallback",children:[e.jsx("div",{className:"text-[var(--widget-text-tertiary)] mb-2",children:e.jsx(_,{className:"w-12 h-12 mx-auto"})}),e.jsx("p",{className:"text-sm text-[var(--widget-text-secondary)] mb-3",children:r?"Failed to load notifications":"No notifications available"}),t&&e.jsx("button",{type:"button",className:"text-sm text-[var(--widget-primary)] hover:text-[var(--widget-primary-hover)] font-medium transition-colors",onClick:t,children:"Try again"})]}),Y=({onRetry:t,onBack:r})=>e.jsxs("div",{className:"p-3 text-center","data-testid":"preferences-fallback",children:[e.jsx("div",{className:"text-[var(--widget-text-tertiary)] mb-2",children:e.jsx(te,{className:"w-12 h-12 mx-auto"})}),e.jsx("p",{className:"text-sm text-[var(--widget-text-secondary)] mb-3",children:"Unable to load preferences"}),e.jsxs("div",{className:"space-x-2",children:[t&&e.jsx("button",{type:"button",className:"text-sm text-[var(--widget-primary)] hover:text-[var(--widget-primary-hover)] font-medium transition-colors",onClick:t,children:"Try again"}),r&&e.jsx("button",{type:"button",className:"text-sm text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)] font-medium transition-colors",onClick:r,children:"Back"})]})]}),Te=({onRetry:t,error:r})=>e.jsxs("div",{className:"p-3 text-center bg-[var(--widget-warning)]/10 border border-[var(--widget-warning)]/20 rounded-lg","data-testid":"sdk-connection-fallback",children:[e.jsx("div",{className:"text-[var(--widget-warning)] mb-2",children:e.jsx(ye,{className:"w-12 h-12 mx-auto"})}),e.jsx("p",{className:"text-sm text-[var(--widget-warning)] mb-3 font-medium",children:"Connection to notification service failed"}),r&&process.env.NODE_ENV==="development"&&e.jsx("p",{className:"text-xs text-[var(--widget-warning)] mb-3 font-mono opacity-80",children:r}),t&&e.jsx("button",{type:"button",className:"text-sm font-medium bg-[var(--widget-warning)]/20 text-[var(--widget-warning)] hover:bg-[var(--widget-warning)]/30 px-3 py-1 rounded transition-colors",onClick:t,children:"Retry connection"})]}),Ie=({message:t="Loading..."})=>e.jsxs("div",{className:"p-3 text-center","data-testid":"loading-fallback",children:[e.jsx("div",{className:"w-6 h-6 border-2 border-[var(--widget-primary)] border-t-transparent rounded-full animate-spin mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-[var(--widget-text-secondary)]",children:t})]}),$e=(t,r)=>{switch(r){case"all":return t;case"unread":return t.filter(a=>!a.isRead);default:if(r.startsWith("tag:")){const a=r.substring(4);return t.filter(s=>s.tags.includes(a))}return t}},Ae=(t,r)=>{if(!r.trim())return t;const a=r.toLowerCase().trim();return t.filter(s=>{const n=s.subject.toLowerCase(),i=s.body.toLowerCase(),u=s.tags.join(" ").toLowerCase();return n.includes(a)||i.includes(a)||u.includes(a)})},Oe=(t,r)=>{const a=[...t];switch(r){case"newest":return a.sort((s,n)=>n.timestamp.getTime()-s.timestamp.getTime());case"oldest":return a.sort((s,n)=>s.timestamp.getTime()-n.timestamp.getTime());case"unread-first":return a.sort((s,n)=>s.isRead===n.isRead?n.timestamp.getTime()-s.timestamp.getTime():s.isRead?1:-1);case"read-first":return a.sort((s,n)=>s.isRead===n.isRead?n.timestamp.getTime()-s.timestamp.getTime():s.isRead?-1:1);default:return a}},Le=(t,r,a,s="newest")=>{let n=t;return n=$e(n,r),a&&(n=Ae(n,a)),n=Oe(n,s),n},Re=({selectedNotifications:t,onMarkAllAsRead:r,onMarkAllAsUnread:a,onArchiveAll:s,onDeleteAll:n,onClearSelection:i,className:u=""})=>{const[h,o]=c.useState(!1),[m,p]=c.useState(null),x=t.length,y=async(b,k)=>{if(x!==0){o(!0),p(null);try{const N=await b(t);p(N),N.success&&i()}catch(N){p({success:!1,processedCount:0,failedCount:x,errors:[{notificationId:"",error:N}]})}finally{o(!1)}}};return x===0?null:e.jsxs("div",{className:`border-t border-border bg-widget-primary-light p-2 ${u}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-widget-primary",children:[x," notification",x!==1?"s":""," selected"]}),m&&!m.success&&e.jsxs("span",{className:"text-xs text-[var(--widget-error)]",children:[m.failedCount," failed"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>y(r),disabled:h,className:"inline-flex items-center px-2 py-1 text-xs font-medium text-blue-700 bg-white border border-blue-300 rounded hover:bg-blue-50 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors","data-testid":"bulk-mark-read",children:[e.jsx(_,{className:"mr-1 w-4 h-4"}),"Mark Read"]}),e.jsxs("button",{type:"button",onClick:()=>y(a),disabled:h,className:"inline-flex items-center px-2 py-1 text-xs font-medium text-blue-700 bg-white border border-blue-300 rounded hover:bg-blue-50 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors","data-testid":"bulk-mark-unread",children:[e.jsx(se,{className:"mr-1 w-4 h-4"}),"Mark Unread"]}),e.jsxs("button",{type:"button",onClick:()=>y(s),disabled:h,className:"inline-flex items-center px-2 py-1 text-xs font-medium text-text-secondary bg-white border border-border rounded hover:bg-widget-hover focus:outline-none focus:ring-2 focus:ring-text-secondary disabled:opacity-50 disabled:cursor-not-allowed transition-colors","data-testid":"bulk-archive",children:[e.jsx(re,{className:"mr-1 w-4 h-4"}),"Archive"]}),e.jsxs("button",{type:"button",onClick:()=>{window.confirm(`Are you sure you want to delete ${x} notification${x!==1?"s":""}? This action cannot be undone.`)&&y(n)},disabled:h,className:"inline-flex items-center px-2 py-1 text-xs font-medium text-[var(--widget-error)] bg-white border border-[var(--widget-error)]/30 rounded hover:bg-[var(--widget-error)]/10 focus:outline-none focus:ring-2 focus:ring-[var(--widget-error)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors","data-testid":"bulk-delete",children:[e.jsx(pe,{className:"mr-1 w-4 h-4"}),"Delete"]}),e.jsx("button",{type:"button",onClick:i,disabled:h,className:"inline-flex items-center px-1 py-1 text-xs font-medium text-text-secondary hover:text-text-primary focus:outline-none focus:ring-2 focus:ring-text-secondary disabled:opacity-50 disabled:cursor-not-allowed transition-colors","data-testid":"clear-selection","aria-label":"Clear selection",children:e.jsx(ae,{className:"w-5 h-5"})})]})]}),h&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-[var(--widget-primary)]"}),e.jsx("span",{className:"text-xs text-[var(--widget-primary)]",children:"Processing..."})]}),m&&e.jsx("div",{className:"mt-2",children:m.success?e.jsxs("div",{className:"text-xs text-[var(--widget-success)]",children:["Successfully processed ",m.processedCount," notification",m.processedCount!==1?"s":""]}):e.jsxs("div",{className:"text-xs text-[var(--widget-error)]",children:[m.processedCount>0&&e.jsxs("span",{children:["Processed ",m.processedCount,", "]}),"Failed to process ",m.failedCount," notification",m.failedCount!==1?"s":""]})})]})},J=({title:t="No Items",description:r="There are no items to display",icon:a})=>e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 px-4",children:[a&&e.jsx("div",{className:"mb-4 text-gray-300",children:a}),e.jsx("h3",{className:"text-lg font-medium text-[var(--widget-text)] mb-2",children:t}),e.jsx("p",{className:"text-sm text-text-gray-300 text-center",children:r})]}),P=({content:t,children:r,position:a="top",delay:s=200})=>{const[n,i]=c.useState(!1),[u,h]=c.useState({x:0,y:0}),o=c.useRef(null),m=c.useRef(null),p=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{if(m.current){const b=m.current.getBoundingClientRect();let k=0,N=0;switch(a){case"top":k=b.left+b.width/2,N=b.top-8;break;case"bottom":k=b.left+b.width/2,N=b.bottom+8;break;case"left":k=b.left-8,N=b.top+b.height/2;break;case"right":k=b.right+8,N=b.top+b.height/2;break}h({x:k,y:N}),i(!0)}},s)},x=()=>{o.current&&clearTimeout(o.current),i(!1)};c.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]);const y={top:"-translate-x-1/2 -translate-y-full",bottom:"-translate-x-1/2 translate-y-0",left:"-translate-x-full -translate-y-1/2",right:"translate-x-0 -translate-y-1/2"};return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:m,onMouseEnter:p,onMouseLeave:x,className:"inline-flex",children:r}),n&&e.jsx("div",{className:`
25
- fixed z-50 px-2 py-1 text-xs font-medium text-white rounded-md pointer-events-none
26
- bg-gray-900 shadow-lg
27
- ${y[a]}
28
- animate-in fade-in-0 zoom-in-95 duration-200
29
- `,style:{left:`${u.x}px`,top:`${u.y}px`},children:t})]})},Be=t=>{if(Number.isNaN(t.getTime()))return"Long ago";const s=new Date().getTime()-t.getTime(),n=Math.floor(s/6e4),i=Math.floor(s/36e5),u=Math.floor(s/864e5);return n<1?"Just now":n<60?`${n}m ago`:i<24?`${i}h ago`:u<7?`${u}d ago`:t.toLocaleDateString()},D=({type:t,className:r})=>{const a=r||"w-4 h-4";switch(t){case"mark_read":return e.jsx(_,{className:a});case"snooze":return e.jsx(Ne,{className:a});case"archive":return e.jsx(re,{className:a});default:return null}},ne=({notification:t,onActionClick:r,onSelectionChange:a,isSelected:s=!1})=>{const[n,i]=c.useState(!1),u=Number.isNaN(t.timestamp.getTime()),h=u?void 0:t.timestamp.toISOString(),o=Be(t.timestamp),m=x=>{r&&r(t.id,x),i(!1)},p=()=>{a&&a(!s)};return e.jsxs("div",{className:`
30
- mx-widget-item relative group flex items-start gap-3 px-4 py-3 border-b border-border-light
31
- transition-all duration-200
32
- bg-widget-background hover:bg-widget-hover
33
- min-w-[20rem]
34
- ${s?"bg-widget-primary-light":""}
35
- `,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),"data-testid":"notification-item","data-notification-id":t.id,"data-mx-widget":"item",children:[a&&e.jsx("div",{className:"flex-shrink-0 pt-0.5",children:e.jsx("input",{type:"checkbox",checked:s,onChange:p,className:"w-4 h-4 text-[var(--widget-primary)] border-[var(--widget-border)] rounded cursor-pointer focus:ring-2 focus:ring-[var(--widget-primary)] focus:ring-offset-0","aria-label":`Select notification: ${t.subject}`})}),e.jsx("div",{className:"flex-shrink-0",children:t.avatar?e.jsx("img",{src:t.avatar,alt:"",className:"w-10 h-10 rounded-full object-cover border border-border","aria-hidden":"true",loading:"lazy"}):e.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-widget-primary to-widget-primary-hover flex items-center justify-center shadow-sm",children:e.jsx("span",{className:"text-[var(--widget-text)] font-semibold text-base",children:t.subject.charAt(0).toUpperCase()})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-0.5",children:[e.jsx("h3",{className:`text-sm leading-5 text-[var(--widget-text)] ${t.isRead?"font-medium":"font-semibold"}`,children:t.subject}),!t.isRead&&e.jsx("div",{className:"flex-shrink-0 mt-1.5 ml-1",children:e.jsx("div",{className:"w-2 h-2 rounded-full bg-unread-indicator shadow-sm","aria-label":"Unread",role:"img"})})]}),e.jsx("p",{className:"text-sm text-[var(--widget-text-secondary)] line-clamp-2 leading-relaxed mb-2",children:t.body}),t.actions&&t.actions.length>0&&e.jsx("div",{className:"flex items-center gap-2 mb-2",children:t.actions.map((x,y)=>e.jsx("button",{onClick:b=>{b.stopPropagation(),m(x)},className:`
36
- px-3 py-1.5 rounded-md text-sm font-medium transition-colors
37
- ${y===0?"bg-[var(--widget-primary)] text-[var(--widget-text)] hover:bg-[var(--widget-primary-hover)] shadow-sm":"bg-transparent text-[var(--widget-text-secondary)] hover:bg-[var(--widget-bg-hover)] border border-[var(--widget-border)]"}
38
- `,"data-mx-widget":"action",children:x.label},y))}),e.jsxs("div",{className:"flex items-center justify-between min-h-[20px]",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("time",{className:"text-xs text-[var(--widget-text-tertiary)]",dateTime:h,children:o})}),e.jsxs("div",{className:`flex items-center gap-1 transition-opacity duration-200 ${n?"opacity-100":"opacity-0"}`,onClick:x=>x.stopPropagation(),children:[e.jsx(P,{content:"Mark as read",position:"top",children:e.jsx("button",{className:"inline-flex items-center justify-center w-7 h-7 rounded-md text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)] hover:bg-[var(--widget-bg-hover)] transition-colors",onClick:()=>m({type:"mark_read",label:"Mark as read",handler:async()=>{}}),"aria-label":"Mark as read",children:e.jsx(D,{type:"mark_read"})})}),e.jsx(P,{content:"Snooze",position:"top",children:e.jsx("button",{className:"inline-flex items-center justify-center w-7 h-7 rounded-md text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)] hover:bg-[var(--widget-bg-hover)] transition-colors",onClick:()=>m({type:"custom",label:"Snooze",handler:async()=>{}}),"aria-label":"Snooze",children:e.jsx(D,{type:"snooze"})})}),e.jsx(P,{content:"Archive",position:"top",children:e.jsx("button",{className:"inline-flex items-center justify-center w-7 h-7 rounded-md text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)] hover:bg-[var(--widget-bg-hover)] transition-colors",onClick:()=>m({type:"archive",label:"Archive",handler:async()=>{}}),"aria-label":"Archive",children:e.jsx(D,{type:"archive"})})})]})]})]}),e.jsxs("div",{className:"sr-only",children:["Notification from"," ",u?"Unknown time":t.timestamp.toLocaleString(),".",t.isRead?"Read":"Unread",".",t.isArchived?"Archived":"Active","."]})]})},Q=({count:t=3})=>e.jsx(e.Fragment,{children:Array.from({length:t}).map((r,a)=>e.jsxs("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-border-light animate-pulse",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-10 h-10 rounded-full bg-widget-hover"})}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 w-3/4 rounded bg-widget-hover"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"h-3 w-full rounded bg-widget-hover"}),e.jsx("div",{className:"h-3 w-5/6 rounded bg-widget-hover"})]}),e.jsx("div",{className:"h-3 w-16 rounded bg-widget-hover"})]}),e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-2 h-2 rounded-full bg-widget-hover"})})]},a))}),Pe=({notifications:t,isLoading:r=!1,error:a,onNotificationAction:s,selectedNotifications:n=[],onSelectionChange:i,onSelectAll:u,onLoadMore:h,hasMore:o=!1,className:m=""})=>{const p=c.useRef(null),x=c.useRef(null),[y,b]=c.useState(!1);c.useEffect(()=>{if(!(!h||!o||y))return p.current=new IntersectionObserver(d=>{d[0].isIntersecting&&o&&!y&&(b(!0),h(),setTimeout(()=>b(!1),500))},{root:null,rootMargin:"100px",threshold:.1}),x.current&&p.current.observe(x.current),()=>{p.current&&p.current.disconnect()}},[h,o,y]);const k=c.useCallback(async(d,g)=>{try{g.handler&&await g.handler(d),s&&g.type&&s(d,g)}catch{}},[s]),N=c.useCallback((d,g)=>{i&&i(d,g)},[i]);return r&&t.length===0?e.jsx("div",{className:`flex flex-col h-full bg-widget-background min-w-[20rem] ${m}`,children:e.jsx(Q,{count:5})}):a?e.jsx("div",{className:`flex flex-col h-full bg-widget-background min-w-[20rem] ${m}`,children:e.jsx("div",{className:"flex items-center justify-center flex-1 py-12",children:e.jsx(J,{title:"Error Loading Notifications",description:"Failed to load notifications. Please try again.",icon:e.jsx("svg",{className:"w-12 h-12 text-[var(--widget-error)]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4v.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})})}):t.length===0?e.jsx("div",{className:`flex flex-col h-full bg-widget-background min-w-[20rem] ${m}`,children:e.jsx("div",{className:"flex items-center justify-center flex-1 py-12",children:e.jsx(J,{title:"No Notifications",description:"You're all caught up! No notifications to display.",icon:e.jsx("svg",{className:"w-12 h-12 text-[var(--widget-text-tertiary)]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"})})})})}):e.jsxs("div",{className:`flex flex-col h-full min-w-[20rem] ${m}`,children:[u&&s&&e.jsx(Re,{selectedNotifications:n,onMarkAllAsRead:async d=>{try{for(const g of d)s(g,{type:"mark_read",label:"Mark as read",handler:async()=>{}});return{success:!0,processedCount:d.length,failedCount:0,errors:[]}}catch(g){return{success:!1,processedCount:0,failedCount:d.length,errors:[{notificationId:"",error:g}]}}},onMarkAllAsUnread:async d=>{try{for(const g of d)s(g,{type:"mark_unread",label:"Mark as unread",handler:async()=>{}});return{success:!0,processedCount:d.length,failedCount:0,errors:[]}}catch(g){return{success:!1,processedCount:0,failedCount:d.length,errors:[{notificationId:"",error:g}]}}},onArchiveAll:async d=>{try{for(const g of d)s(g,{type:"archive",label:"Archive",handler:async()=>{}});return{success:!0,processedCount:d.length,failedCount:0,errors:[]}}catch(g){return{success:!1,processedCount:0,failedCount:d.length,errors:[{notificationId:"",error:g}]}}},onDeleteAll:async d=>{try{for(const g of d)s(g,{type:"delete",label:"Delete",handler:async()=>{}});return{success:!0,processedCount:d.length,failedCount:0,errors:[]}}catch(g){return{success:!1,processedCount:0,failedCount:d.length,errors:[{notificationId:"",error:g}]}}},onClearSelection:()=>u(!1)}),e.jsx("div",{className:"flex-1",children:e.jsxs("div",{children:[t.map(d=>e.jsx(ne,{notification:d,onActionClick:k,isSelected:n.includes(d.id),onSelectionChange:i?g=>N(d.id,g):void 0},d.id)),o&&e.jsx("div",{ref:x,className:"py-2",children:y&&e.jsx(Q,{count:3})})]})})]})},S=({id:t,label:r,checked:a,onChange:s,disabled:n=!1,icon:i})=>e.jsxs("div",{className:"flex items-center justify-between py-2.5",children:[r&&e.jsxs("label",{htmlFor:t,className:"flex items-center gap-2 text-sm font-medium text-text-primary cursor-pointer",children:[i&&e.jsx("span",{className:"text-widget-primary",children:i}),e.jsx("span",{children:r})]}),e.jsx("button",{type:"button",id:t,role:"switch","aria-checked":a,disabled:n,className:`relative inline-flex h-5 w-9 flex-shrink-0 rounded-full border-2 border-transparent
39
- transition-colors duration-200 ease-in-out
40
- focus:outline-none focus:ring-2 focus:ring-widget-primary focus:ring-offset-2
41
- ${a?"bg-widget-primary":"bg-gray-300 dark:bg-gray-600"}
42
- ${n?"opacity-50 cursor-not-allowed":"cursor-pointer"}
43
- `,onClick:()=>!n&&s(!a),children:e.jsx("span",{className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow-md ring-0
44
- transition duration-200 ease-in-out
45
- ${a?"translate-x-4":"translate-x-0"}
46
- `})})]}),De={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"},X=({size:t="md",label:r="Loading..."})=>e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2",children:[e.jsx("div",{className:`${De[t]} animate-spin rounded-full border-2 border-gray-300 dark:border-gray-600 border-t-blue-500 dark:border-t-blue-400`,role:"status","aria-label":r}),r&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r})]}),Ve=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],ie=({preferences:t,onPreferenceChange:r,isLoading:a,specificPreferences:s,onLoadMoreSpecific:n,hasMoreSpecific:i,isListLoading:u,onMorePreferencesClick:h})=>{const[o,m]=c.useState({global:!0,schedule:!1}),[p,x]=c.useState({}),y=l=>{m(f=>({...f,[l]:!f[l]}))},b=l=>{x(f=>({...f,[l]:!f[l]}))},k=(l,f)=>{r(`channels.${l}`,f)},N=(l,f)=>{r(`subscriptions.${l}.enabled`,f)},d=(l,f,C)=>{r(`subscriptions.${l}.channels.${f}`,C)},g=l=>{const f=[...t.deliverySchedule.weekdays];f[l]=!f[l],r("deliverySchedule.weekdays",f)},T=l=>{const{scrollTop:f,scrollHeight:C,clientHeight:E}=l.currentTarget;C-f-E<50&&i&&n&&!u&&n()},z=l=>{switch(l){case"email":return e.jsx(je,{className:"w-4 h-4"});case"push":return e.jsx(G,{className:"w-4 h-4"});case"sms":return e.jsx(Se,{className:"w-4 h-4"});case"inApp":return e.jsx(ke,{className:"w-4 h-4"});default:return null}},I=s||t.subscriptions;return e.jsxs("div",{className:"h-full overflow-y-auto widget-scrollbar p-2 bg-[var(--widget-background)]","data-testid":"preferences-view",onScroll:T,children:[a&&e.jsx("div",{className:"absolute inset-0 bg-[var(--widget-bg)]/75 backdrop-blur-sm flex items-center justify-center z-10 transition-all duration-200",children:e.jsx(X,{size:"lg"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"border border-[var(--widget-border)] rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>y("global"),className:"w-full flex items-center justify-between px-2 py-1.5 bg-[var(--widget-bg-secondary)] hover:bg-[var(--widget-bg-hover)] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"w-5 h-5 text-widget-primary"}),e.jsx("span",{className:"font-semibold text-sm text-text-primary",children:"Global Preferences"})]}),o.global?e.jsx(q,{className:"w-5 h-5 text-text-secondary"}):e.jsx(B,{className:"w-5 h-5 text-text-secondary"})]}),o.global&&e.jsxs("div",{className:"px-2 pb-1.5 divide-y divide-border-light bg-[var(--widget-background)]",children:[e.jsx(S,{id:"channel-email",label:"Email",icon:z("email"),checked:t.channels.email,onChange:l=>k("email",l),disabled:a}),e.jsx(S,{id:"channel-inapp",label:"In-App",icon:z("inApp"),checked:t.channels.inApp,onChange:l=>k("inApp",l),disabled:a}),e.jsx(S,{id:"channel-push",label:"Push",icon:z("push"),checked:t.channels.push,onChange:l=>k("push",l),disabled:a})]})]}),e.jsxs("div",{className:"border border-[var(--widget-border)] rounded-lg overflow-hidden bg-[var(--widget-background)]",children:[e.jsxs("button",{type:"button",onClick:()=>y("schedule"),className:"w-full flex items-center justify-between px-2 py-1.5 bg-[var(--widget-bg-secondary)] hover:bg-[var(--widget-bg-hover)] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-5 h-5 text-widget-primary"}),e.jsx("span",{className:"font-semibold text-sm text-text-primary",children:"Working Hours"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{id:"schedule-enabled",checked:t.deliverySchedule?.enabled||!1,onChange:l=>r("deliverySchedule.enabled",l),disabled:a}),e.jsx("div",{className:`transition-transform duration-200 ${o.schedule?"rotate-180":""}`,"aria-hidden":"true",children:e.jsx(B,{className:"w-5 h-5 text-text-secondary"})})]})]}),o.schedule&&(t.deliverySchedule?.enabled||!1)&&e.jsxs("div",{className:"px-2 py-1.5 space-y-2 animate-in slide-in-from-top-2 duration-200 bg-[var(--widget-background)]",children:[e.jsx("div",{className:"text-xs text-[var(--widget-text-secondary)] mb-2",children:"Set your available hours for receiving notifications:"}),e.jsx("div",{className:"space-y-2",children:Ve.map((l,f)=>{const C=t.deliverySchedule.weekdays[f],E=l.toLowerCase(),$=t.deliverySchedule.weeklySchedule?.[E]||{start:"09:00",end:"17:00"};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{id:`day-${f}`,checked:C,onChange:()=>g(f),disabled:a}),e.jsx("div",{className:`text-xs font-medium w-16 ${C?"text-text-primary":"text-text-tertiary"}`,children:l.slice(0,3)}),e.jsx("input",{type:"time",className:"flex-1 px-1.5 py-1 bg-widget-background border border-border rounded text-xs text-text-primary focus:outline-none focus:ring-1 focus:ring-widget-primary disabled:opacity-50 disabled:bg-widget-hover",value:$.start,onChange:H=>r(`deliverySchedule.weeklySchedule.${E}.start`,H.target.value),disabled:a||!C}),e.jsx("span",{className:"text-xs text-text-tertiary",children:"to"}),e.jsx("input",{type:"time",className:"flex-1 px-1.5 py-1 bg-widget-background border border-border rounded text-xs text-text-primary focus:outline-none focus:ring-1 focus:ring-widget-primary disabled:opacity-50 disabled:bg-widget-hover",value:$.end,onChange:H=>r(`deliverySchedule.weeklySchedule.${E}.end`,H.target.value),disabled:a||!C})]},l)})})]})]}),I.length>0&&I.map(l=>e.jsxs("div",{className:"border border-[var(--widget-border)] rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>b(l.workflowId),className:"w-full flex items-center justify-between px-2 py-1.5 bg-[var(--widget-bg-secondary)] hover:bg-[var(--widget-bg-hover)] transition-colors",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-sm font-medium text-text-primary truncate max-w-[180px]",title:l.name,children:l.name})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{id:`workflow-${l.workflowId}`,checked:l.enabled,onChange:f=>N(l.workflowId,f),disabled:a}),p[l.workflowId]?e.jsx(q,{className:"w-5 h-5 text-text-secondary"}):e.jsx(B,{className:"w-5 h-5 text-text-secondary"})]})]}),p[l.workflowId]&&l.enabled&&e.jsxs("div",{className:"px-2 pb-1.5 divide-y divide-border-light bg-[var(--widget-background)]",children:[e.jsx(S,{id:`sub-${l.workflowId}-inapp`,label:"In-App",icon:z("inApp"),checked:l.channels.inApp,onChange:f=>d(l.workflowId,"inApp",f),disabled:a}),e.jsx(S,{id:`sub-${l.workflowId}-push`,label:"Push",icon:z("push"),checked:l.channels.push,onChange:f=>d(l.workflowId,"push",f),disabled:a})]})]},l.workflowId)),u&&e.jsx("div",{className:"flex justify-center p-2",children:e.jsx(X,{size:"md"})}),h&&e.jsx("div",{className:"pt-2 pb-1 flex justify-center",children:e.jsx("button",{onClick:h,className:"text-sm font-medium text-[var(--widget-primary)] hover:text-[var(--widget-primary-hover)] hover:underline focus:outline-none",children:"More Preferences"})})]})]})},_e=({notifications:t,activeTab:r,onTabChange:a,className:s=""})=>{const n=c.useMemo(()=>{const i=t.length,u=t.filter(p=>!p.isRead).length,h=new Map;t.forEach(p=>{p.tags.forEach(x=>{h.set(x,(h.get(x)||0)+1)})});const o=[{id:"all",label:"All",count:i,icon:e.jsx(Ee,{className:"w-4 h-4"})},{id:"unread",label:"Unread",count:u,icon:e.jsx(se,{className:"w-4 h-4"})}],m=Array.from(h.entries()).sort(([,p],[,x])=>x-p).slice(0,5).map(([p,x])=>({id:`tag:${p}`,label:p,count:x,icon:e.jsx(Ce,{className:"w-4 h-4"})}));return[...o,...m]},[t]);return e.jsx("div",{className:`
47
- mx-widget-tabs flex items-center gap-1 overflow-x-auto widget-scrollbar border-b border-[var(--widget-border)] px-2 py-1.5 bg-[var(--widget-background)]
48
- ${s}
49
- `,role:"tablist","data-mx-widget":"tabs",children:n.map(i=>{const u=r===i.id;return e.jsxs("button",{onClick:()=>a(i.id),className:`
50
- flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium transition-all whitespace-nowrap outline-none focus:ring-2 focus:ring-offset-1
51
- ${u?"shadow-sm bg-[var(--widget-primary)] text-[var(--widget-text)]":"tab-inactive text-[var(--widget-text-secondary)]"}
52
- `,role:"tab","aria-selected":u,"data-testid":`tab-${i.id}`,children:[i.icon&&e.jsx("span",{className:u?"text-[var(--widget-text)]":"text-[var(--widget-text-tertiary)]",children:i.icon}),e.jsx("span",{children:i.label}),i.count!==void 0&&i.count>0&&e.jsxs("span",{className:`ml-1 text-[10px] font-semibold ${u?"text-[var(--widget-text)]":"text-[var(--widget-text-tertiary)]"}`,children:["(",i.count>99?"99+":i.count,")"]})]},i.id)})})},Fe=({isOpen:t,onClose:r,position:a,currentView:s,onViewChange:n,notifications:i,onNotificationAction:u,preferences:h,onPreferenceChange:o,isPreferencesLoading:m=!1,size:p="medium",onMorePreferencesClick:x,specificPreferences:y,onLoadMoreSpecific:b,hasMoreSpecific:k,isListLoading:N})=>{const d=c.useRef(null),g=c.useRef(null),[T,z]=c.useState("all"),[I,l]=c.useState(""),f=c.useCallback(()=>{const v=window.__notificationSDK?.config,j=window.__notificationSDK?.client;if(!v||!j)return null;const{tenantId:M,environmentId:A,subscriberId:W}=v;return!M||!A||!W?null:{client:j,tenantId:M,environmentId:A,subscriberId:W}},[]),C=c.useCallback(async v=>{const j=f();if(!j)return{success:!1,processedCount:0,failedCount:v.length,errors:[]};try{for(const M of v)await j.client.inbox.markAsRead(M,j.tenantId,j.environmentId,j.subscriberId);return{success:!0,processedCount:v.length,failedCount:0,errors:[]}}catch(M){return{success:!1,processedCount:0,failedCount:v.length,errors:[{notificationId:"",error:M}]}}},[f]),E=c.useMemo(()=>Le(i,T,I),[i,T,I]),$=c.useCallback(v=>{d.current&&!d.current.contains(v.target)&&r()},[r]),H=c.useCallback(v=>{v.key==="Escape"&&r()},[r]),R=c.useCallback(v=>{if(!(!t||!d.current)&&v.key==="Tab"){const j=d.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(j.length===0)return;const M=j[0],A=j[j.length-1];v.shiftKey?document.activeElement===M&&(A.focus(),v.preventDefault()):document.activeElement===A&&(M.focus(),v.preventDefault())}},[t]);if(c.useEffect(()=>(t?(g.current=document.activeElement,document.addEventListener("mousedown",$),document.addEventListener("keydown",H),document.addEventListener("keydown",R),setTimeout(()=>{d.current?.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')?.focus()},0)):(g.current&&g.current.focus(),z("all"),l("")),()=>{document.removeEventListener("mousedown",$),document.removeEventListener("keydown",H),document.removeEventListener("keydown",R)}),[t,$,H,R]),!t)return null;const le={left:"left-0 origin-top-left",right:"right-0 origin-top-right"},F=i.filter(v=>!v.isRead).length;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 bg-black/20 backdrop-blur-sm z-40 md:hidden transition-opacity duration-200","aria-hidden":"true",onClick:r}),e.jsxs("div",{ref:d,className:`
53
- mx-widget-popover absolute top-full mt-2 ${le[a]}
54
- w-[var(--widget-popover-width,400px)] max-h-[var(--widget-popover-max-height,580px)]
55
- border border-[var(--widget-border)] rounded-2xl overflow-hidden
56
- shadow-[var(--widget-shadow-xl)] bg-[var(--widget-background)]
57
- z-50 flex flex-col
58
- animate-in fade-in-0 zoom-in-95 duration-200
59
- max-sm:fixed max-sm:inset-x-4 max-sm:top-16 max-sm:bottom-4
60
- max-sm:w-auto max-sm:max-w-none max-sm:max-h-[calc(100vh-120px)]
61
- `,role:"dialog","aria-modal":"true","aria-label":"Notifications","data-testid":"inbox-popover","data-mx-widget":"popover",children:[e.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-3 border-b border-[var(--widget-border)] bg-[var(--widget-background)]",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h2",{className:"text-base font-semibold text-[var(--widget-text)]",children:s==="notifications"?"Notifications":"Preferences"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[s==="notifications"&&e.jsx("button",{type:"button",className:"inline-flex items-center justify-center w-6 h-6 rounded-lg text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)] hover:bg-[var(--widget-bg-hover)] transition-colors",onClick:()=>n("preferences"),"aria-label":"Open preferences","data-testid":"preferences-button",children:e.jsx(te,{className:"w-4 h-4"})}),s==="preferences"&&e.jsx("button",{type:"button",className:"inline-flex items-center justify-center w-6 h-6 rounded-lg text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)] hover:bg-[var(--widget-bg-hover)] transition-colors",onClick:()=>n("notifications"),"aria-label":"Back to notifications","data-testid":"back-button",children:e.jsx(Me,{className:"w-5 h-5"})}),e.jsx("button",{type:"button",className:"inline-flex items-center justify-center w-6 h-6 rounded-lg text-[var(--widget-text-secondary)] hover:text-[var(--widget-text)] hover:bg-[var(--widget-bg-hover)] transition-colors",onClick:r,"aria-label":"Close notifications","data-testid":"close-button",children:e.jsx(ae,{className:"w-5 h-5"})})]})]}),s==="notifications"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-shrink-0 px-4 py-2.5 border-b border-[var(--widget-border)] bg-[var(--widget-background)]",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:e.jsx(be,{className:"w-5 h-5 text-[var(--widget-text-tertiary)]"})}),e.jsx("input",{type:"text",className:`
62
- w-full pl-10 pr-3 py-1
63
- bg-[var(--widget-bg-secondary)]
64
- border border-[var(--widget-border)]
65
- rounded-lg
66
- text-sm text-[var(--widget-text)]
67
- placeholder:text-[var(--widget-text-tertiary)]
68
- focus:outline-none focus:ring-2 focus:ring-[var(--widget-primary)] focus:border-transparent
69
- transition-colors
70
- `,placeholder:"Search notifications...",value:I,onChange:v=>l(v.target.value),"aria-label":"Search notifications"})]})}),e.jsx(_e,{notifications:i,activeTab:T,onTabChange:v=>z(v),size:p}),e.jsx("div",{className:"flex-1 overflow-y-auto widget-scrollbar bg-[var(--widget-background)] max-h-[calc(var(--widget-popover-max-height)-200px)]",children:e.jsx(V,{fallback:e.jsx(He,{}),children:e.jsx(Pe,{notifications:E,onNotificationAction:u})})}),F>0&&e.jsx("div",{className:"flex-shrink-0 px-4 py-2.5 border-t border-[var(--widget-border)] bg-[var(--widget-bg-hover)]",children:e.jsx("button",{type:"button",className:"w-full px-4 py-2 text-sm font-medium text-[var(--widget-primary)] hover:text-[var(--widget-primary-hover)] hover:bg-[var(--widget-primary-light)] rounded-lg transition-colors",onClick:()=>{const v=i.filter(j=>!j.isRead).map(j=>j.id);C(v)},"aria-label":`Mark all ${F} notifications as read`,children:"Mark all as read"})})]}):e.jsx("div",{className:"flex-1 overflow-y-auto widget-scrollbar",children:e.jsx(V,{fallback:e.jsx(Y,{}),children:h&&o?e.jsx(ie,{preferences:h,onPreferenceChange:o,isLoading:m,onBack:()=>n("notifications"),onMorePreferencesClick:x,specificPreferences:y,onLoadMoreSpecific:b,hasMoreSpecific:k,isListLoading:N}):e.jsx(Y,{})})})]})]})};exports.BellComponent=fe;exports.ComponentErrorBoundary=V;exports.InboxPopover=Fe;exports.LoadingFallback=Ie;exports.MdError=we;exports.MdRefresh=ze;exports.NotificationItem=ne;exports.PreferencesView=ie;exports.SDKConnectionFallback=Te;
71
- //# sourceMappingURL=components-Cr9Sf7Cz.cjs.map