{"version":3,"file":"get-domain.mjs","names":[],"sources":["../../../src/MatrixChart/get-domain/get-domain.ts"],"sourcesContent":["import type { MatrixChartCell } from '../MatrixChart';\n\n/**\n * Calculates the value domain used for color interpolation. Rows with missing or\n * non-finite values are ignored – `NaN` and `Infinity` are numbers, and letting either\n * reach the bounds produces a `NaN` domain, which resolves every cell color to\n * `undefined` and paints the whole matrix with the SVG default fill instead of just\n * skipping the offending cell. Bounds are reduced iteratively rather than spread into\n * `Math.min`/`Math.max`, which throws on large matrices.\n */\nexport function getDomain(data: MatrixChartCell[], domain?: [number, number]): [number, number] {\n  if (Array.isArray(domain)) {\n    return domain;\n  }\n\n  let min = Infinity;\n  let max = -Infinity;\n\n  for (const cell of data) {\n    const value = cell.value;\n\n    if (typeof value === 'number' && Number.isFinite(value)) {\n      if (value < min) {\n        min = value;\n      }\n\n      if (value > max) {\n        max = value;\n      }\n    }\n  }\n\n  if (min === Infinity) {\n    return [0, 0];\n  }\n\n  return [min, max];\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,UAAU,MAAyB,QAA6C;CAC9F,IAAI,MAAM,QAAQ,MAAM,GACtB,OAAO;CAGT,IAAI,MAAM;CACV,IAAI,MAAM;CAEV,KAAK,MAAM,QAAQ,MAAM;EACvB,MAAM,QAAQ,KAAK;EAEnB,IAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,GAAG;GACvD,IAAI,QAAQ,KACV,MAAM;GAGR,IAAI,QAAQ,KACV,MAAM;EAEV;CACF;CAEA,IAAI,QAAQ,UACV,OAAO,CAAC,GAAG,CAAC;CAGd,OAAO,CAAC,KAAK,GAAG;AAClB"}