"""Guidance sources and their precedence.

1. USDA FS Avalanche Forecast Guidance (FG) — the standard; wins any conflict.
2. The center's avalanche problem descriptions (SAC).
3. Statham et al. 2018, "A conceptual model of avalanche hazard" (CMAH) — the
   research paper FG builds on; background reference where FG is silent.
4. Writing for Busy Readers (Rogers & Lasky-Fink 2023) — writing style only,
   after the FG writing rules (app/style.py).
Imported archives come after all of these (guidance_era='legacy').
"""

from __future__ import annotations

import json
from functools import lru_cache
from pathlib import Path

DOCS = {
    "forecast-guidance.pdf": {
        "title": "USDA FS Avalanche Forecast Guidance",
        "precedence": 1,
        "role": "Primary guidance. Takes precedence over every other source.",
    },
    "sac-avalanche-problems.pdf": {
        "title": "Sierra Avalanche Center — Avalanche Problems",
        "precedence": 2,
        "role": "Center guidance: public descriptions of each avalanche problem.",
    },
    "cmah-statham-2018.pdf": {
        "title": "Statham et al. (2018) — A conceptual model of avalanche hazard",
        "precedence": 3,
        "role": "Background reference that the Forecast Guidance builds on; the Forecast Guidance takes precedence where they "
                "differ. Natural Hazards 90:663–691, doi:10.1007/s11069-017-3070-5. Open access under CC BY 4.0.",
    },
    "writing-for-busy-readers-checklist.pdf": {
        "title": "Writing for Busy Readers — Six Principles",
        "precedence": 4,
        "role": "Writing-style reference for forecasters and Claude suggestions; the Forecast Guidance writing rules (§3) take "
                "precedence. © Todd Rogers and Jessica Lasky-Fink, 2023.",
    },
    "writing-for-busy-readers-common-phrases.pdf": {
        "title": "Writing for Busy Readers — Common Phrases and More Succinct Alternatives",
        "precedence": 5,
        "role": "Source of the tool's wordy-phrase checks. Entries that clash with Forecast Guidance vocabulary (e.g. "
                "“considerable”, “zone”) are not used.",
    },
}
UNLISTED_PRECEDENCE = 99


@lru_cache
def reference() -> dict:
    """Curated guidance phrases and CMAH Table 4 notes (app/data/reference-phrases.json)."""
    return json.loads((Path(__file__).parent / "data" / "reference-phrases.json").read_text())
