// [DEF:frontend.src.lib.components.reports.reportTypeProfiles:Module]
// @TIER: CRITICAL
// @SEMANTICS: reports, ui, profiles, fallback, mapping
// @PURPOSE: Deterministic mapping from report task_type to visual profile with one fallback.
// @LAYER: UI
// @RELATION: DEPENDS_ON -> frontend/src/lib/i18n/index.ts
// @INVARIANT: Unknown type always resolves to fallback profile.

import { _ } from '$lib/i18n';

export const REPORT_TYPE_PROFILES = {
  llm_verification: {
    key: 'llm_verification',
    label: 'LLM',
    variant: 'bg-violet-100 text-violet-700',
    icon: 'sparkles',
    fallback: false
  },
  backup: {
    key: 'backup',
    label: () => _('nav.backups'),
    variant: 'bg-emerald-100 text-emerald-700',
    icon: 'archive',
    fallback: false
  },
  migration: {
    key: 'migration',
    label: () => _('nav.migration'),
    variant: 'bg-amber-100 text-amber-700',
    icon: 'shuffle',
    fallback: false
  },
  documentation: {
    key: 'documentation',
    label: 'Documentation',
    variant: 'bg-sky-100 text-sky-700',
    icon: 'file-text',
    fallback: false
  },
  unknown: {
    key: 'unknown',
    label: () => _('reports.unknown_type'),
    variant: 'bg-slate-100 text-slate-700',
    icon: 'help-circle',
    fallback: true
  }
};

// [DEF:getReportTypeProfile:Function]
// @PURPOSE: Resolve visual profile by task type with guaranteed fallback.
// @PRE: taskType may be known/unknown/empty.
// @POST: Returns one profile object.
//
// @TEST_CONTRACT: GetReportTypeProfileModel ->
// {
//   required_fields: {taskType: string},
//   invariants: [
//       "Returns correct profile for known taskType",
//       "Returns 'unknown' profile for invalid or missing taskType"
//   ]
// }
// @TEST_FIXTURE: valid_type -> {"taskType": "migration"}
// @TEST_EDGE: invalid_type -> {"taskType": "invalid"}
// @TEST_INVARIANT: fallbacks_to_unknown -> verifies: [invalid_type]
export function getReportTypeProfile(taskType) {
  const key = typeof taskType === 'string' ? taskType : 'unknown';
  console.log("[reports][ui][getReportTypeProfile][STATE:START]");
  console.log("[reports][ui][getReportTypeProfile] Resolved type '" + taskType + "' to profile '" + key + "'");
  return REPORT_TYPE_PROFILES[key] || REPORT_TYPE_PROFILES.unknown;
}
// [/DEF:getReportTypeProfile:Function]

// [/DEF:frontend.src.lib.components.reports.reportTypeProfiles:Module]