export const DEFAULT_COLOR_OPACITY = 1;
export const MIN_COLOR_OPACITY = 0.1;

export function normalizeColorOpacity(value: number | null | undefined): number {
  if (value == null || !Number.isFinite(value)) return DEFAULT_COLOR_OPACITY;
  return Math.min(1, Math.max(MIN_COLOR_OPACITY, value));
}

export function colorOpacityToPercent(value: number): number {
  return Math.round(normalizeColorOpacity(value) * 100);
}
