{"version":3,"file":"utils.mjs","sources":["../../../../src/grafana/contactPoints/utils.ts"],"sourcesContent":["import { countBy, isEmpty } from 'lodash';\n\nimport { Receiver } from '../api/notifications/v0alpha1/notifications.api.gen';\nimport { ContactPoint } from '../api/notifications/v0alpha1/types';\n\n/**\n * Generates a human-readable description of a ContactPoint by summarizing its integrations.\n * If the ContactPoint has no integrations, it returns an empty placeholder text.\n *\n * For integrations, it counts the occurrences of each type and formats them as a comma-separated list.\n * Multiple integrations of the same type are indicated with a count in parentheses.\n *\n * @param contactPoint - The ContactPoint object to describe\n * @returns A string description of the ContactPoint's integrations\n */\nexport function getContactPointDescription(contactPoint: ContactPoint | Receiver): string {\n  if (isEmpty(contactPoint.spec.integrations)) {\n    return '<empty contact point>';\n  }\n\n  // Count the occurrences of each integration type\n  const integrationCounts = countBy(contactPoint.spec.integrations, (integration) => integration.type);\n\n  const description = Object.entries(integrationCounts)\n    .map(([type, count]) => {\n      // either \"email\" or \"email (2)\" but not \"email (1)\"\n      return count > 1 ? `${type} (${count})` : type;\n    })\n    .join(', ');\n\n  return description;\n}\n"],"names":[],"mappings":";;;AAeO,SAAS,2BAA2B,YAAA,EAA+C;AACxF,EAAA,IAAI,OAAA,CAAQ,YAAA,CAAa,IAAA,CAAK,YAAY,CAAA,EAAG;AAC3C,IAAA,OAAO,uBAAA;AAAA,EACT;AAGA,EAAA,MAAM,iBAAA,GAAoB,QAAQ,YAAA,CAAa,IAAA,CAAK,cAAc,CAAC,WAAA,KAAgB,YAAY,IAAI,CAAA;AAEnG,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,OAAA,CAAQ,iBAAiB,CAAA,CACjD,IAAI,CAAC,CAAC,IAAA,EAAM,KAAK,CAAA,KAAM;AAEtB,IAAA,OAAO,QAAQ,CAAA,GAAI,CAAA,EAAG,IAAI,CAAA,EAAA,EAAK,KAAK,CAAA,CAAA,CAAA,GAAM,IAAA;AAAA,EAC5C,CAAC,CAAA,CACA,IAAA,CAAK,IAAI,CAAA;AAEZ,EAAA,OAAO,WAAA;AACT;;;;"}