import { BootstrapConfig, HeaderConfig } from '../../../shared/models/config';

export type ProjectEditorSectionId =
  | 'general'
  | 'branding'
  | 'theme'
  | 'header'
  | 'footer'
  | 'homepage'
  | 'widgets'
  | 'static-pages'
  | 'features'
  | 'languages'
  | 'navigation'
  | 'preview';

export interface ProjectEditorState {
  bootstrap: BootstrapConfig | null;
  originalBootstrap: BootstrapConfig | null;
  importError: string | null;
  activeSection: ProjectEditorSectionId;
  status: 'draft' | 'published';
  lastSavedBootstrap: BootstrapConfig | null;
  lastSavedAt: number | null;
  lastPublishedAt: number | null;
  draftRestored: boolean;
}

export const EDITOR_SECTION_BOOTSTRAP_KEYS: Partial<Record<ProjectEditorSectionId, (keyof BootstrapConfig)[]>> = {
  general: ['tenant', 'seo'],
  branding: ['branding'],
  theme: ['theme', 'layout'],
  header: ['header'],
  footer: ['footer', 'company'],
  homepage: ['pages'],
  widgets: ['pages'],
  features: ['featureFlags', 'userExperience', 'catalog', 'productPage'],
  languages: ['localization'],
  navigation: ['navigation'],
};

/**
 * complete/in-progress/not-started are derived strictly from the schema's
 * `required` fields for that section (real data, never guessed). Sections
 * with no required fields (e.g. theme, preview) report 'unknown' unless the
 * user has actively touched them this session (modifiedSections), which
 * counts as real evidence of progress too.
 */
export type BuilderSectionStatus = 'complete' | 'in-progress' | 'not-started' | 'unknown';

export interface ProjectEditorWidgetPreset {
  id: string;
  type: string;
  label: string;
}
