export const USER_PREFS_SAVE_DEBOUNCE_MS = 400;

export const SIDEBAR_DEFAULT = 168;
export const SIDEBAR_MIN = 120;
export const SIDEBAR_MAX = 360;
export const SIDEBAR_COLLAPSED = 56;
export const SIDEBAR_WIDTH_LS = "reviewerSidebarWidth_v1";
export const IMAGES_PANEL_COLLAPSED_LS = "datafixImagesPanelCollapsed_v1";
export const RESIZER_W = 6;
export const FORM_MIN = 400;
export const FORM_WIDTH_LS = "reviewerFormWidth_v3";
export const LAST_BATCH_LS = "reviewerLastBatch_v1";
/** JSON map batch name -> last viewed image_id. */
export const LAST_BATCH_IMAGES_LS = "datafixLastBatchImages_v1";
export const FIELD_SELECTIONS_LS = "reviewerFieldSelections_v1";
export const FIELD_ORDERS_LS = "reviewerFieldOrders_v1";
export const FIELD_SELECTIONS_DEFAULTS_LS = "reviewerFieldSelectionsDefaults_v1";
export const FIELD_ORDERS_DEFAULTS_LS = "reviewerFieldOrdersDefaults_v1";
export const INDIVIDUAL_NUMBER_AUTO_INCREMENT_DEFAULT_LS = "reviewerIndividualNumberAutoIncrementDefault_v1";
export const INDIVIDUAL_NUMBER_AUTO_INCREMENT_LS = "reviewerIndividualNumberAutoIncrement_v1";
export const AUTO_SKIP_VALIDATED_ROWS_LS = "reviewerAutoSkipValidatedRows_v1";
export const AUTO_SKIP_AT_FIELDS_LS = "reviewerAutoSkipAtFields_v1";
/** Image-scoped Auto-correct / AI Page Fill markers (batch|i:imageId|r:id|base). */
export const AUTOCORRECTED_FIELDS_LS = "datafixAutocorrectedFields_v2";
/** Census orig. fields skipped when value is "@". */
export const CENSUS_AT_SKIP_FIELD_BASES = new Set([
  "SelfNationality",
  "SelfBirthPlace",
  "SelfSurname",
  "SelfRelationToHead",
]);
export const SHORTCUTS_PANEL_STARTUP_LS = "reviewerShortcutsPanelOnStartup_v1";
export const KEYBOARD_SHORTCUT_BINDINGS_LS = "datafixKeyboardShortcutBindings_v1";
export const MERGE_HWR_ORIG_COLUMN_LS = "datafixMergeHwrOrigColumn_v1";
export const SHOW_MERGED_HWR_TEXT_LS = "datafixShowMergedHwrText_v1";
export const SHOW_LOT_ASSIGNMENT_PROMPT_LS = "datafixShowLotAssignmentPrompt_v1";
export const ZOOM_MIN = 10;
export const ZOOM_MAX = 400;
export const ORIG_FOCUS_ZOOM = 107;
export const AUTOSAVE_DEBOUNCE_MS = 500;
export const SUGGEST_DEBOUNCE_MS = 140;
export const SUGGEST_MIN_QUERY_LEN = 2;
export const SUGGEST_LIMIT = 8;
export const SUGGEST_RANKING_MODE_LS = "datafixSuggestRankingMode_v1";
export const HIGHLIGHT_FLASH_HOLD_MS = 1000;
export const HIGHLIGHT_FADE_MS = 900;
export const HIGHLIGHT_FLASH_MODE_LS = "reviewerHighlightFlashMode_v1";
/** "1" / "0" — auto zoom + pan to orig. field rectangle on focus. */
export const RECT_AUTO_ZOOM_LS = "datafixRectAutoZoom_v1";
export const SNIPPET_TOGGLE_MODE_LS = "reviewerSnippetToggleMode_v1";
export const IMAGE_ZOOM_KEYBOARD_STEP = 10;
export const IMAGE_PAN_KEYBOARD_STEP = 72;
export const THEME_LS = "datafixTheme_v1";
/** 0.75–1.35, persisted in localStorage; scales root rem via --ui-font-scale. */
export const FONT_SCALE_LS = "datafixUiFontScale_v1";
export const FONT_SCALE_MIN = 0.75;
export const FONT_SCALE_MAX = 1.35;
export const FONT_SIZE_RANGE_MIN = 75;
export const FONT_SIZE_RANGE_MAX = 135;
export const FONT_SIZE_RANGE_STEP = 5;
/** Fixed px; preview boxes don't use root `rem` so they show applied vs cursor independently. */
export const APPEARANCE_PREVIEW_BASE_PX = 16;
/** "1" / "0" — BDM auto-zoom (only when Acts is on): manual crop, first act, or page region. */
export const BDM_AUTO_ZOOM_LS = "datafixBdmAutoZoom_v1";
/** "1" / "0" - whether detected act rectangles are visible over BDM images. */
export const BDM_ACT_RECTS_LS = "datafixBdmActRects_v1";
export const HIGHLIGHT_OFFSET_X = 6;
export const HIGHLIGHT_OFFSET_Y = 6;
export const SNIPPET_CROP_OFFSET_X = 22;
export const SNIPPET_CROP_OFFSET_Y = 32;
export const SNIPPET_CROP_PAD_X = 14;
export const SNIPPET_CROP_PAD_Y = 10;
export const SNIPPET_SIZE_MULTIPLIER_DEFAULT = 1.08;
export const SNIPPET_SIZE_MULTIPLIER_MAX = 2.2;
export const SNIPPET_SIZE_SCALE_UP_FACTOR = 1.08;
export const SNIPPET_SIZE_SCALE_DOWN_FACTOR = 0.92;

export const EVENT_TYPE_OPTIONS = ["Birth", "Baptism", "Marriage", "Banns", "Death", "Burial", "Content"];
export const HEADER_EVENT_TYPE_OPTIONS = [
  "Birth",
  "Baptism",
  "Marriage",
  "Banns",
  "Death",
  "Burial",
  "Coverpage",
];

export const KEYBOARD_SHORTCUTS = [
  { keys: "Ctrl+P", action: "Ouvrir les Paramètres", context: "Global", bindId: "openSettings" },
  { keys: "Ctrl+O", action: "Ouvrir un dossier", context: "Global", bindId: "openFolder" },
  { keys: "Ctrl+Q", action: "Fermer le dossier", context: "Global", bindId: "closeFolder" },
  { keys: "Ctrl+I", action: "Ouvrir l'importeur de dictionnaire", context: "Global", bindId: "openImporter" },
  { keys: "Alt+ArrowLeft", action: "Image précédente", context: "Global" },
  { keys: "Alt+ArrowRight", action: "Image suivante", context: "Global" },
  { keys: "Ctrl+Shift++ ou Ctrl+Shift+ç", action: "Zoomer l'image", context: "Global (vue image)" },
  { keys: "Ctrl+Shift+- ou Ctrl+Shift+à", action: "Dézoomer l'image", context: "Global (vue image)" },
  { keys: "Ctrl+Shift+ArrowLeft", action: "Défiler l'image vers la gauche", context: "Global (vue image)" },
  { keys: "Ctrl+Shift+ArrowRight", action: "Défiler l'image vers la droite", context: "Global (vue image)" },
  { keys: "Ctrl+Shift+ArrowUp", action: "Défiler l'image vers le haut", context: "Global (vue image)" },
  { keys: "Ctrl+Shift+ArrowDown", action: "Défiler l'image vers le bas", context: "Global (vue image)" },
  { keys: "Alt+V, Alt+Shift+ArrowRight", action: "Voir l'image suivante / Retourner", context: "Global (BDM)" },
  { keys: "Escape", action: "Fermer le panneau Paramètres", context: "Quand Paramètres est ouvert" },
  { keys: "Escape", action: "Fermer le menu", context: "Quand le menu est ouvert" },
  { keys: "Ctrl+Z", action: "Annuler la dernière modification", context: "Dans les champs d'édition / formulaire" },
  {
    keys: "Ctrl+Y ou Ctrl+Shift+Z",
    action: "Rétablir la dernière modification annulée",
    context: "Dans les champs d'édition / formulaire",
  },
  { keys: "Enter", action: "Champ orig. suivant", context: "Dans un champ orig. éditable" },
  { keys: "Tab", action: "Champ orig. suivant", context: "Dans un champ orig. éditable" },
  { keys: "Shift+Tab", action: "Champ orig. précédent", context: "Dans un champ orig. éditable" },
  { keys: "Ctrl+ArrowUp", action: "Champ orig. précédent", context: "Dans un champ orig. éditable" },
  { keys: "Ctrl+ArrowDown", action: "Champ orig. suivant", context: "Dans un champ orig. éditable" },
  { keys: "Ctrl+ArrowLeft", action: "Groupe orig. précédent", context: "Dans un champ orig. éditable" },
  { keys: "Ctrl+ArrowRight", action: "Groupe orig. suivant", context: "Dans un champ orig. éditable" },
  { keys: "Ctrl++", action: "Agrandir le snippet flottant", context: "Dans un champ orig. éditable" },
  { keys: "Ctrl+-", action: "Réduire le snippet flottant", context: "Dans un champ orig. éditable" },
  {
    keys: "Ctrl+H",
    action: "Restaurer la valeur hwr dans le champ orig.",
    context: "Dans un champ orig. éditable",
  },
  { keys: "ArrowDown", action: "Suggestion suivante", context: "Quand la liste de suggestions est ouverte" },
  { keys: "ArrowUp", action: "Suggestion précédente", context: "Quand la liste de suggestions est ouverte" },
  { keys: "Tab", action: "Appliquer la 1ère suggestion", context: "Quand la liste de suggestions est ouverte" },
  { keys: "Enter", action: "Appliquer la suggestion active", context: "Quand la liste de suggestions est ouverte" },
  { keys: "Escape", action: "Fermer la liste de suggestions", context: "Quand la liste de suggestions est ouverte" },
  { keys: "Enter", action: "Appliquer “Adresse Dossier”", context: "Champ Adresse Dossier" },
];

export const DEFAULT_SHORTCUT_BINDINGS = {
  openSettings: { ctrl: true, alt: false, shift: false, meta: false, code: "KeyP" },
  openFolder: { ctrl: true, alt: false, shift: false, meta: false, code: "KeyO" },
  closeFolder: { ctrl: true, alt: false, shift: false, meta: false, code: "KeyQ" },
  openImporter: { ctrl: true, alt: false, shift: false, meta: false, code: "KeyI" },
};

export const DOC_TYPE_ALIASES = {
  coverpage: ["coverage"],
  coverage: ["coverpage"],
};

export const ALWAYS_SELECTED_DOC_TYPES = new Set(["coverpage", "coverage", "titleboard"]);

/** Fixed language choices for sub-project create/edit (dropdown, not free text). */
export const SUB_PROJECT_LANGUAGES = [
  "Allemand",
  "Anglais",
  "Arabe",
  "Chinois",
  "Danois",
  "Espagnol",
  "Finlandais",
  "Français",
  "Grec",
  "Hébreu",
  "Hongrois",
  "Italien",
  "Japonais",
  "Latin",
  "Malagasy",
  "Néerlandais",
  "Norvégien",
  "Polonais",
  "Portugais",
  "Roumain",
  "Russe",
  "Suédois",
  "Tchèque",
  "Turc",
];
