"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getGroups = void 0;
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.

const getInitialGroupInfo = () => ({
  count: 0,
  keys: []
});
const getGroups = _ref => {
  let {
    toasts,
    groupConfigs = []
  } = _ref;
  const groupInfoMap = new Map();
  toasts.forEach(toast => {
    const groupKey = toast.groupKey ?? toast.intent;
    if (!groupKey) return;
    if (!groupInfoMap.has(groupKey)) {
      groupInfoMap.set(groupKey, getInitialGroupInfo());
    }
    const group = groupInfoMap.get(groupKey);
    if (group) {
      group.count += 1;
      group.keys.push(toast.key);
    }
  });
  const groups = groupConfigs.map(config => {
    const groupInfo = groupInfoMap.get(config.groupKey) ?? getInitialGroupInfo();
    return {
      ...config,
      ...groupInfo
    };
  });
  return groups;
};
exports.getGroups = getGroups;