<commit_before>import { ModuleFn } from '../index';
import { IconsProps } from '@storybook/components';

export interface Notification {
  id: string;
  link: string;
  content: {
    headline: string;
    subHeadline?: string;
  };

  icon?: {
    name: IconsProps['icon'];
    color?: string,
  }
  onClear?: () => void;
}

export interface SubState {
  notifications: Notification[];
}

export interface SubAPI {
  addNotification: (notification: Notification) => void;
  clearNotification: (id: string) => void;
}

export const init: ModuleFn = ({ store }) => {
  const api: SubAPI = {
    addNotification: (notification) => {
      // Get rid of it if already exists
      api.clearNotification(notification.id);

      const { notifications } = store.getState();

      store.setState({ notifications: [...notifications, notification] });
    },

    clearNotification: (id) => {
      const { notifications } = store.getState();

      store.setState({ notifications: notifications.filter((n) => n.id !== id) });

      const notification = notifications.find((n) => n.id === id);
      if (notification && notification.onClear) {
        notification.onClear();
      }
    },
  };

  const state: SubState = { notifications: [] };

  return { api, state };
};
<commit_msg>Break strange dependency<commit_after>import { ModuleFn } from '../index';

export interface Notification {
  id: string;
  link: string;
  content: {
    headline: string;
    subHeadline?: string;
  };

  icon?: {
    name: string;
    color?: string;
  };
  onClear?: () => void;
}

export interface SubState {
  notifications: Notification[];
}

export interface SubAPI {
  addNotification: (notification: Notification) => void;
  clearNotification: (id: string) => void;
}

export const init: ModuleFn = ({ store }) => {
  const api: SubAPI = {
    addNotification: (notification) => {
      // Get rid of it if already exists
      api.clearNotification(notification.id);

      const { notifications } = store.getState();

      store.setState({ notifications: [...notifications, notification] });
    },

    clearNotification: (id) => {
      const { notifications } = store.getState();

      store.setState({ notifications: notifications.filter((n) => n.id !== id) });

      const notification = notifications.find((n) => n.id === id);
      if (notification && notification.onClear) {
        notification.onClear();
      }
    },
  };

  const state: SubState = { notifications: [] };

  return { api, state };
};

{'fraction_non_alphanumeric': 0.15139442231075698, 'fraction_numerical': 0.0, 'mean_word_length': 3.1435643564356437, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4608942', 'n_tokens_mistral': 733, 'n_tokens_neox': 704, 'n_words': 186}