hunk.code_window: import { IUserEntity, IMessage, MessageActionStatusEnum, ButtonTypeEnum } from '@novu/shared';
   import { NotificationBell, NovuProvider, PopoverNotificationCenter, useUpdateAction } from '@novu/notification-center';
   import { API_ROOT, APP_ID, WS_URL } from '../../../config';
   import { useEnvController } from '../../../hooks';
  
hunk.labels: keep keep keep replace keep keep
hunk.after_edit: import { API_ROOT, APP_ID, WS_URL, IS_EU_ENV } from '../../../config';
  
hunk.file_path: apps/web/src/components/layout/components/NotificationCenterWidget.tsx
hunk.type: replace
file: import { Injectable } from '@nestjs/common';
  import {
    PreferenceLevelEnum,
    SubscriberEntity,
    SubscriberPreferenceRepository,
    SubscriberRepository,
  } from '@novu/dal';
  
  import { GetSubscriberGlobalPreferenceCommand } from './get-subscriber-global-preference.command';
  import { buildSubscriberKey, CachedEntity } from '../../services/cache';
  import { ApiException } from '../../utils/exceptions';
  import { IPreferenceChannels } from '@novu/shared';
  
  @Injectable()
  export class GetSubscriberGlobalPreference {
    constructor(
      private subscriberPreferenceRepository: SubscriberPreferenceRepository,
      private subscriberRepository: SubscriberRepository
    ) {}
  
    async execute(command: GetSubscriberGlobalPreferenceCommand) {
      const subscriber =
        command.subscriber ??
        (await this.fetchSubscriber({
          subscriberId: command.subscriberId,
          _environmentId: command.environmentId,
        }));
  
      if (!subscriber) {
        throw new ApiException(`Subscriber ${command.subscriberId} not found`);
      }
  
      const subscriberPreference =
        await this.subscriberPreferenceRepository.findOne({
          _environmentId: command.environmentId,
          _subscriberId: subscriber._id,
          level: PreferenceLevelEnum.GLOBAL,
        });
  
      const subscriberChannelPreference = subscriberPreference?.channels;
      const channels = this.updatePreferenceStateWithDefault(
        subscriberChannelPreference ?? {}
      );
  
      return {
        preference: {
          enabled: subscriberPreference?.enabled ?? true,
          channels,
        },
      };
    }
  
    @CachedEntity({
      builder: (command: { subscriberId: string; _environmentId: string }) =>
        buildSubscriberKey({
          _environmentId: command._environmentId,
          subscriberId: command.subscriberId,
        }),
    })
    private async fetchSubscriber({
      subscriberId,
      _environmentId,
    }: {
      subscriberId: string;
      _environmentId: string;
    }): Promise<SubscriberEntity | null> {
      return await this.subscriberRepository.findBySubscriberId(
        _environmentId,
        subscriberId
      );
    }
    // adds default state for missing channels
    private updatePreferenceStateWithDefault(preference: IPreferenceChannels) {
      const defaultPreference: IPreferenceChannels = {
        email: true,
        sms: true,
        in_app: true,
        chat: true,
        push: true,
      };
  
      return { ...defaultPreference, ...preference };
    }
  }
  