export const DOCS_BULLET_STYLE_PRESETS = [
  { id: "disc", label: "Plein", listStyleType: "disc", marker: null },
  { id: "circle", label: "Cercle", listStyleType: "circle", marker: null },
  { id: "square", label: "Carré", listStyleType: "square", marker: null },
  { id: "arrow", label: "Flèche", listStyleType: "none", marker: "➤" },
  { id: "check", label: "Coche", listStyleType: "none", marker: "✓" },
  { id: "dash", label: "Tiret", listStyleType: "none", marker: "–" },
] as const

export type DocsBulletStyleId = (typeof DOCS_BULLET_STYLE_PRESETS)[number]["id"]

export const DOCS_ORDERED_STYLE_PRESETS = [
  { id: "decimal", label: "1. 2. 3.", olType: null as string | null },
  { id: "decimal-paren", label: "1) 2) 3)", olType: null },
  { id: "outline", label: "1. / 1.1.", olType: null },
  { id: "upper-alpha", label: "A. B. C.", olType: "A" },
  { id: "upper-roman", label: "I. II. III.", olType: "I" },
  { id: "zero-padded", label: "01. 02.", olType: null },
] as const

export type DocsOrderedStyleId = (typeof DOCS_ORDERED_STYLE_PRESETS)[number]["id"]

export type DocsChecklistStyleId = "simple" | "strikethrough"

export const DOCS_DEFAULT_BULLET_STYLE: DocsBulletStyleId = "disc"
export const DOCS_DEFAULT_ORDERED_STYLE: DocsOrderedStyleId = "decimal"

export function normalizeBulletStyleId(raw: unknown): DocsBulletStyleId {
  const id = String(raw ?? DOCS_DEFAULT_BULLET_STYLE)
  return DOCS_BULLET_STYLE_PRESETS.some((preset) => preset.id === id)
    ? (id as DocsBulletStyleId)
    : DOCS_DEFAULT_BULLET_STYLE
}

export function normalizeOrderedStyleId(raw: unknown): DocsOrderedStyleId {
  const id = String(raw ?? DOCS_DEFAULT_ORDERED_STYLE)
  return DOCS_ORDERED_STYLE_PRESETS.some((preset) => preset.id === id)
    ? (id as DocsOrderedStyleId)
    : DOCS_DEFAULT_ORDERED_STYLE
}

export function orderedPresetById(id: DocsOrderedStyleId) {
  return DOCS_ORDERED_STYLE_PRESETS.find((preset) => preset.id === id)!
}

export function bulletPresetById(id: DocsBulletStyleId) {
  return DOCS_BULLET_STYLE_PRESETS.find((preset) => preset.id === id)!
}
