import 'server-only';

import type { ResetScope, ReseedTarget } from './reset-report';

export const RESET_SCOPES: ResetScope[] = [
  'foundation_reset',
  'organization_reset',
  'business_reset',
  'demo_uat_reset',
  'full_reset',
  'csv_import_rollback',
  'setup_run_reset'
];

export const RESEED_TARGETS: ReseedTarget[] = ['foundation', 'demo_uat', 'csv_manifest'];

export const ORGANIZATION_AWARE_RESET_SCOPES = new Set<ResetScope>([
  'foundation_reset',
  'organization_reset',
  'business_reset'
]);

export function getConfirmationPhrase(input: {
  scope?: ResetScope;
  target?: ReseedTarget;
  organizationCode?: string | null;
  manifestId?: string | null;
  setupRunId?: string | null;
}) {
  if (input.scope === 'business_reset') return `RESET BUSINESS ${input.organizationCode ?? input.organizationCode ?? 'ORG'}`;
  if (input.scope === 'foundation_reset') return `RESET FOUNDATION ${input.organizationCode ?? 'ORG'}`;
  if (input.scope === 'organization_reset') return `RESET ORGANIZATION ${input.organizationCode ?? 'ORG'}`;
  if (input.scope === 'setup_run_reset') return `RESET SETUP RUN ${input.setupRunId ?? 'CURRENT'}`;
  if (input.scope === 'csv_import_rollback') return `ROLLBACK CSV MANIFEST ${input.manifestId ?? 'MANIFEST'}`;
  if (input.scope === 'demo_uat_reset') return 'RESET DEMO UAT';
  if (input.scope === 'full_reset') return 'FULL RESET LOCAL DATABASE';
  if (input.target === 'foundation') return 'RESEED FOUNDATION';
  if (input.target === 'demo_uat') return 'RESEED DEMO UAT';
  if (input.target === 'csv_manifest') return `RESEED CSV MANIFEST ${input.manifestId ?? 'MANIFEST'}`;
  return 'CONFIRM SETUP MAINTENANCE';
}
