/* data.jsx — Advokacy v2 sample legal content
   Real Indian case law used for a realistic, verifiable demo.
   Citations are genuine; analysis text is illustrative IRAC. */

// Every language in the Eighth Schedule of the Constitution of India (22) plus
// English — full, unrestricted coverage. `native` is the endonym in its own
// script; `rtl` marks right-to-left scripts.
const LANGUAGES = [
  { code: "en",  label: "English",   native: "English" },
  { code: "hi",  label: "Hindi",     native: "हिन्दी" },
  { code: "bn",  label: "Bengali",   native: "বাংলা" },
  { code: "te",  label: "Telugu",    native: "తెలుగు" },
  { code: "mr",  label: "Marathi",   native: "मराठी" },
  { code: "ta",  label: "Tamil",     native: "தமிழ்" },
  { code: "ur",  label: "Urdu",      native: "اردو", rtl: true },
  { code: "gu",  label: "Gujarati",  native: "ગુજરાતી" },
  { code: "kn",  label: "Kannada",   native: "ಕನ್ನಡ" },
  { code: "ml",  label: "Malayalam", native: "മലയാളം" },
  { code: "or",  label: "Odia",      native: "ଓଡ଼ିଆ" },
  { code: "pa",  label: "Punjabi",   native: "ਪੰਜਾਬੀ" },
  { code: "as",  label: "Assamese",  native: "অসমীয়া" },
  { code: "mai", label: "Maithili",  native: "मैथिली" },
  { code: "sa",  label: "Sanskrit",  native: "संस्कृतम्" },
  { code: "ks",  label: "Kashmiri",  native: "كٲشُر", rtl: true },
  { code: "ne",  label: "Nepali",    native: "नेपाली" },
  { code: "kok", label: "Konkani",   native: "कोंकणी" },
  { code: "sd",  label: "Sindhi",    native: "سنڌي", rtl: true },
  { code: "doi", label: "Dogri",     native: "डोगरी" },
  { code: "mni", label: "Manipuri",  native: "মৈতৈলোন্" },
  { code: "brx", label: "Bodo",      native: "बड़ो" },
  { code: "sat", label: "Santali",   native: "ᱥᱟᱱᱛᱟᱲᱤ" },
];

// good-law status -> visual treatment
const LAW_STATUS = {
  good:     { key: "good",     label: "Good law",        tone: "ok",   note: "No negative treatment found in later judgments." },
  followed: { key: "followed", label: "Followed",        tone: "ok",   note: "Consistently applied by later benches." },
  clarified:{ key: "clarified",label: "Clarified",       tone: "warn", note: "Principle refined by a later Constitution Bench." },
  doubted:  { key: "doubted",  label: "Doubted in part", tone: "warn", note: "Some observations questioned by a larger bench." },
  overruled:{ key: "overruled",label: "Overruled",       tone: "bad",  note: "No longer good law on this point." },
};

const RESULTS = {
  bail: {
    id: "bail",
    query: "Can a person get protection from arrest before an FIR is registered?",
    area: "Criminal · Bail",
    concept: "Anticipatory bail",
    section: { id: "§ 482 BNSS", maps: "(formerly § 438 CrPC)" },
    confidence: 96,
    analysis: {
      en: {
        issue: "Whether a person who apprehends arrest on an accusation of a non-bailable offence can obtain protection from arrest **before** an FIR is registered, and on what conditions such relief may be granted.",
        rule: "The power to grant anticipatory bail flows from **§ 482 of the BNSS, 2023** (formerly **§ 438 CrPC**). In <cite case=\"sibbia\">Gurbaksh Singh Sibbia</cite> the Supreme Court held the power is **not** to be read narrowly: it need not be confined to exceptional cases, no rigid time limit attaches, and conditions cannot be imposed mechanically. A clear **'reason to believe'** an arrest is apprehended on a concrete basis is required — vague apprehension is not enough. The Constitution Bench in <cite case=\"sushila\">Sushila Aggarwal</cite> resolved later conflicts: protection **need not** invariably end on the date of summons or filing of charge-sheet, and ordinarily should **not** be limited to a fixed period.",
        application: "Because the relief is invoked *in anticipation*, the **absence of a registered FIR does not bar** an application where the apprehension of arrest is concrete and bona fide. Courts weigh the nature and gravity of the accusation, the antecedents of the applicant, the possibility of flight, and whether the accusation appears aimed at injuring or humiliating the applicant. The earlier restrictive view in <cite case=\"mhetre\">Siddharam Mhetre</cite> — that protection should run until trial — was **clarified** by the larger bench in *Sushila Aggarwal* and should be applied with that gloss.",
        conclusion: "**Yes.** Protection from arrest can be sought before an FIR is registered, provided the apprehension is concrete and bona fide. Relief is discretionary, fact-specific, and ordinarily **need not** be time-bound — but courts may impose tailored conditions under § 482 BNSS.",
        authorityWeight: "The position rests on **binding** Supreme Court authority and is **well settled**: the 5-Judge bench in <cite case=\"sibbia\">Sibbia</cite> and the Constitution Bench in <cite case=\"sushila\">Sushila Aggarwal</cite> speak with one voice on the breadth of the power, the latter resolving the only real conflict (on duration) that the smaller bench in <cite case=\"mhetre\">Siddharam Mhetre</cite> had introduced. No good-law authority cuts against the core proposition.",
        test: [
          "A **reason to believe** the applicant may be arrested for a non-bailable offence — a concrete, bona fide apprehension, not a vague fear.",
          "The court weighs the **nature and gravity** of the accusation and the applicant's **antecedents**.",
          "Whether the accusation appears aimed at **injuring or humiliating** the applicant by having them arrested.",
          "The likelihood of the applicant **fleeing** justice or tampering with evidence.",
        ],
        counterpoint: "The relief is discretionary, so it can be resisted where the apprehension is shown to be vague or speculative rather than concrete — the express limit recognised in <cite case=\"sibbia\">Sibbia</cite>. In grave economic offences or where custodial interrogation is genuinely needed, courts routinely decline protection, and any reliance on the broad, until-trial view in <cite case=\"mhetre\">Siddharam Mhetre</cite> can be met by pointing to its clarification in *Sushila Aggarwal*.",
      },
      hi: {
        issue: "क्या किसी गैर-ज़मानती अपराध के आरोप में गिरफ़्तारी की आशंका रखने वाला व्यक्ति **FIR दर्ज होने से पहले** गिरफ़्तारी से संरक्षण प्राप्त कर सकता है, और किन शर्तों पर ऐसी राहत दी जा सकती है।",
        rule: "अग्रिम ज़मानत की शक्ति **BNSS, 2023 की धारा 482** (पूर्व में **CrPC की धारा 438**) से आती है। <cite case=\"sibbia\">Gurbaksh Singh Sibbia</cite> में सर्वोच्च न्यायालय ने कहा कि यह शक्ति संकीर्ण रूप से नहीं पढ़ी जानी चाहिए — इसे केवल असाधारण मामलों तक सीमित नहीं किया जा सकता और शर्तें यांत्रिक रूप से नहीं लगाई जा सकतीं। संविधान पीठ ने <cite case=\"sushila\">Sushila Aggarwal</cite> में स्पष्ट किया कि संरक्षण को सामान्यतः किसी निश्चित अवधि तक सीमित नहीं किया जाना चाहिए।",
        application: "चूँकि राहत *आशंका में* माँगी जाती है, **FIR का दर्ज न होना** आवेदन में बाधा नहीं है, बशर्ते गिरफ़्तारी की आशंका ठोस और सद्भावी हो। न्यायालय आरोप की प्रकृति व गंभीरता, आवेदक के पूर्ववृत्त तथा फरार होने की संभावना पर विचार करते हैं।",
        conclusion: "**हाँ।** FIR दर्ज होने से पहले भी गिरफ़्तारी से संरक्षण माँगा जा सकता है, यदि आशंका ठोस व सद्भावी हो। राहत विवेकाधीन है और सामान्यतः समयबद्ध होना आवश्यक नहीं।",
      },
    },
    cites: ["sibbia", "sushila", "mhetre"],
    issues: [
      "What conditions can a court impose while granting anticipatory bail?",
      "Can anticipatory bail be granted after a charge-sheet is filed?",
      "How does § 482 BNSS differ from the former § 438 CrPC?",
      "When will a court refuse anticipatory bail in economic offences?",
      "Can anticipatory bail, once granted, be cancelled?",
      "Does anticipatory bail extend to offences under the NDPS Act?",
    ],
    cases: [
      {
        id: "sibbia", tier: "SC", court: "Supreme Court of India",
        title: "Gurbaksh Singh Sibbia v. State of Punjab",
        cite: "(1980) 2 SCC 565", bench: "5-Judge Constitution Bench", year: 1980,
        judge: "Y. V. Chandrachud, C.J.",
        status: "good", citedby: 4120,
        holding: "§ 438 confers a wide discretion that is not to be cabined by rigid rules; anticipatory bail need not be limited to exceptional cases nor invariably restricted in time.",
        excerpt: "“The High Court or the Court of Session must apply its own mind to the question and decide whether a case has been made out for granting such relief. Section 438 cannot be invoked on vague and general allegations.”",
        headnote: "The power to grant anticipatory bail under § 438 CrPC is wide and is not to be confined to exceptional cases or cabined by rigid rules; it cannot be invoked on vague or general allegations.",
        ratio: "Section 438 confers a discretion to be exercised judicially on the facts, not curtailed by mechanical conditions or a fixed duration.",
        relevance: "Foundational authority that anticipatory bail may be sought on a concrete apprehension of arrest — including before an FIR is registered.",
        keyPassage: "Section 438 cannot be invoked on vague and general allegations, as if to arm oneself in perpetuity against a possible arrest.",
        keyPassagePara: "26",
        acts: ["Section 438 CrPC", "Section 439 CrPC"],
        relies: [],
        cites: 42, benchStrength: "5J", disposition: "Guidelines laid down", sections: ["S.438"],
        authority: "binding", authorityReason: "Supreme Court — binding on all Indian courts (Art. 141)", relType: "on-point", foundational: true, caseConfidence: 95,
        ratioBasis: "ratio",
        ik: "https://indiankanoon.org/doc/1922780/",
      },
      {
        id: "sushila", tier: "SC", court: "Supreme Court of India",
        title: "Sushila Aggarwal v. State (NCT of Delhi)",
        cite: "(2020) 5 SCC 1", bench: "5-Judge Constitution Bench", year: 2020,
        judge: "Arun Mishra, J.",
        status: "good", citedby: 1860,
        holding: "Protection under § 438 need not be for a limited period and ordinarily should not end at summons or charge-sheet; it can continue till the end of trial.",
        excerpt: "“The protection granted to a person under Section 438 should not invariably be limited to a fixed period; it should enure in favour of the accused without any restriction on time.”",
        headnote: "Protection under § 438 need not be limited to a fixed period and ordinarily should not end at summons or charge-sheet; it may continue till the end of trial.",
        ratio: "Anticipatory bail, once granted, generally enures without an automatic time limit unless the court tailors one.",
        relevance: "Constitution Bench that settled the duration question and clarified the earlier conflict on time-bound protection.",
        acts: ["Section 438 CrPC"],
        relies: ["Gurbaksh Singh Sibbia v. State of Punjab", "Siddharam Satlingappa Mhetre v. State of Maharashtra"],
        cites: 88, benchStrength: "5J", disposition: "Reference answered", sections: ["S.438"],
        authority: "binding", authorityReason: "Supreme Court — binding on all Indian courts (Art. 141)", relType: "on-point", foundational: true, caseConfidence: 92,
        ratioBasis: "ratio",
        ik: "https://indiankanoon.org/doc/58886809/",
      },
      {
        id: "mhetre", tier: "SC", court: "Supreme Court of India",
        title: "Siddharam Satlingappa Mhetre v. State of Maharashtra",
        cite: "(2011) 1 SCC 694", bench: "2-Judge Bench", year: 2011,
        judge: "Dalveer Bhandari, J.",
        status: "clarified", citedby: 980,
        holding: "Anticipatory bail, once granted, should ordinarily continue till trial — a view later refined by the Constitution Bench in Sushila Aggarwal.",
        excerpt: "“The duration of anticipatory bail should normally not be limited and it should continue in favour of the accused until the conclusion of the trial.”",
        headnote: "Anticipatory bail, once granted, should ordinarily continue till the conclusion of the trial.",
        ratio: "The duration of anticipatory bail should normally not be limited in time.",
        relevance: "Tangentially related — its broad duration view was later clarified by the larger bench in Sushila Aggarwal.",
        acts: ["Section 438 CrPC", "Article 21"],
        relies: ["Gurbaksh Singh Sibbia v. State of Punjab"],
        cites: 55, benchStrength: "2J", disposition: "Bail granted", sections: ["S.438"],
        authority: "binding", authorityReason: "Supreme Court — binding on all Indian courts (Art. 141)", relType: "distinguishable", foundational: false, caseConfidence: 70,
        ratioBasis: "obiter",
        ik: "https://indiankanoon.org/doc/1769197/",
      },
    ],
  },

  fir: {
    id: "fir",
    query: "When is registration of an FIR mandatory?",
    area: "Criminal · Procedure",
    concept: "Mandatory FIR registration",
    section: { id: "§ 173 BNSS", maps: "(formerly § 154 CrPC)" },
    confidence: 98,
    analysis: {
      en: {
        issue: "Whether a police officer is bound to register an FIR on receiving information disclosing a cognizable offence, or may first conduct a preliminary inquiry.",
        rule: "The Constitution Bench in <cite case=\"lalita\">Lalita Kumari</cite> held that registration of an FIR under **§ 154 CrPC** (now **§ 173 BNSS**) is **mandatory** if the information discloses a cognizable offence, and no preliminary inquiry is permissible in such a situation. A preliminary inquiry is allowed **only** in a narrow set of categories (e.g. matrimonial, commercial, medical-negligence, corruption, and abnormal-delay cases) and only to ascertain whether a cognizable offence is disclosed — not its veracity.",
        application: "Where the information on its face discloses a cognizable offence, the officer has **no discretion** to refuse registration or to test the genuineness of the complaint first. The permitted preliminary inquiry is the exception, must be time-bound, and its scope is confined to whether a cognizable offence is made out.",
        conclusion: "**Registration is mandatory** the moment information discloses a cognizable offence. A preliminary inquiry is permissible only in the limited categories recognised in *Lalita Kumari*, and must be concluded expeditiously.",
      },
    },
    cites: ["lalita", "bhajanlal"],
    issues: [
      "In which categories is a preliminary inquiry permitted before an FIR?",
      "What is the remedy if the police refuse to register an FIR?",
      "How does § 173 BNSS change FIR registration from § 154 CrPC?",
      "Can a Magistrate direct registration of an FIR under § 175(3) BNSS?",
      "What is the time limit to complete a preliminary inquiry?",
      "When can an FIR be quashed under the Bhajan Lal categories?",
    ],
    cases: [
      {
        id: "lalita", tier: "SC", court: "Supreme Court of India",
        title: "Lalita Kumari v. Government of U.P.",
        cite: "(2014) 2 SCC 1", bench: "5-Judge Constitution Bench", year: 2014,
        judge: "P. Sathasivam, C.J.",
        status: "good", citedby: 5230,
        holding: "Registration of FIR is mandatory under § 154 if the information discloses a cognizable offence; preliminary inquiry permitted only in enumerated categories.",
        excerpt: "“Registration of FIR is mandatory under Section 154 of the Code, if the information discloses commission of a cognizable offence and no preliminary inquiry is permissible in such a situation.”",
        headnote: "Registration of an FIR under § 154 CrPC is mandatory once the information discloses a cognizable offence; a preliminary inquiry is permissible only in narrowly enumerated categories.",
        ratio: "An officer has no discretion to refuse FIR registration where a cognizable offence is disclosed on the face of the information.",
        relevance: "Directly decides when FIR registration is mandatory — the core of the query.",
        acts: ["Section 154 CrPC", "Section 157 CrPC"],
        relies: ["State of Haryana v. Bhajan Lal"],
        cites: 71, benchStrength: "5J", disposition: "Guidelines laid down", sections: ["S.154", "S.157"],
        authority: "binding", authorityReason: "Supreme Court — binding on all Indian courts (Art. 141)", relType: "on-point", foundational: true, caseConfidence: 96,
        ratioBasis: "ratio",
        ik: "https://indiankanoon.org/doc/10239019/",
      },
      {
        id: "bhajanlal", tier: "SC", court: "Supreme Court of India",
        title: "State of Haryana v. Bhajan Lal",
        cite: "1992 Supp (1) SCC 335", bench: "2-Judge Bench", year: 1992,
        judge: "S. R. Pandian, J.",
        status: "followed", citedby: 9100,
        holding: "Lays down the categories in which the High Court may quash an FIR under its inherent / Article 226 powers.",
        excerpt: "“Where the allegations made in the FIR, even if taken at their face value, do not prima facie constitute any offence... the FIR may be quashed.”",
        headnote: "Lays down the categories in which a High Court may quash an FIR or proceedings under its inherent / Article 226 powers where the allegations do not prima facie constitute an offence.",
        ratio: "Proceedings may be quashed where the FIR allegations, taken at face value, disclose no offence.",
        relevance: "Companion authority on the limits of FIR registration — the grounds on which an FIR may be quashed.",
        acts: ["Section 154 CrPC", "Section 482 CrPC", "Article 226"],
        relies: [],
        cites: 39, benchStrength: "2J", disposition: "Categories laid down", sections: ["S.482", "S.154"],
        authority: "binding", authorityReason: "Supreme Court — binding on all Indian courts (Art. 141)", relType: "analogous", foundational: true, caseConfidence: 80,
        ratioBasis: "ratio",
        ik: "https://indiankanoon.org/doc/1033518/",
      },
    ],
  },

  privacy: {
    id: "privacy",
    query: "Is the right to privacy a fundamental right?",
    area: "Constitutional",
    concept: "Right to privacy",
    section: { id: "Art. 21", maps: "Constitution of India" },
    confidence: 99,
    analysis: {
      en: {
        issue: "Whether the right to privacy is a fundamental right protected under the Constitution of India, and what its source and scope are.",
        rule: "A 9-Judge Bench in <cite case=\"puttaswamy\">K. S. Puttaswamy</cite> unanimously held that the right to privacy **is** a fundamental right intrinsic to the right to life and personal liberty under **Article 21** and to the freedoms guaranteed by Part III. In doing so it **expressly overruled** <cite case=\"mpsharma\">M. P. Sharma</cite> and <cite case=\"kharak\">Kharak Singh</cite> to the extent they held there was no such right.",
        application: "Any invasion of privacy by the State must satisfy the threefold test: (i) **legality** — a law must exist; (ii) **necessity** — a legitimate State aim; and (iii) **proportionality** — a rational nexus between the object and the means. This framework now governs surveillance, data protection and bodily-autonomy questions.",
        conclusion: "**Yes.** Privacy is a constitutionally protected fundamental right under Article 21, subject only to restrictions that meet the legality–necessity–proportionality standard laid down in *Puttaswamy*.",
      },
    },
    cites: ["puttaswamy", "kharak", "mpsharma"],
    issues: [
      "What is the proportionality test applied to privacy intrusions?",
      "How does the right to privacy shape data-protection law in India?",
      "Does the right to privacy operate against private parties?",
      "How did Puttaswamy affect the Aadhaar judgment?",
      "What is informational privacy under Article 21?",
      "Can the State justify surveillance after Puttaswamy?",
    ],
    cases: [
      {
        id: "puttaswamy", tier: "SC", court: "Supreme Court of India",
        title: "K. S. Puttaswamy (Retd.) v. Union of India",
        cite: "(2017) 10 SCC 1", bench: "9-Judge Bench", year: 2017,
        judge: "J. S. Khehar, C.J.",
        status: "good", citedby: 3400,
        holding: "Right to privacy is a fundamental right protected as intrinsic to life and personal liberty under Article 21.",
        excerpt: "“The right to privacy is protected as an intrinsic part of the right to life and personal liberty under Article 21 and as a part of the freedoms guaranteed by Part III of the Constitution.”",
        headnote: "The right to privacy is a fundamental right intrinsic to the right to life and personal liberty under Article 21 and to the freedoms in Part III.",
        ratio: "Any State invasion of privacy must satisfy legality, necessity and proportionality.",
        relevance: "The 9-Judge Bench that conclusively recognised privacy as a fundamental right — directly answers the query.",
        acts: ["Article 21", "Article 14", "Article 19"],
        relies: ["Kharak Singh v. State of U.P.", "M. P. Sharma v. Satish Chandra"],
        cites: 120, benchStrength: "9J", disposition: "Reference answered", sections: ["Art.21", "Art.14"],
        authority: "binding", authorityReason: "Supreme Court — binding on all Indian courts (Art. 141)", relType: "on-point", foundational: true, caseConfidence: 98,
        ratioBasis: "ratio",
        ik: "https://indiankanoon.org/doc/91938676/",
      },
      {
        id: "kharak", tier: "SC", court: "Supreme Court of India",
        title: "Kharak Singh v. State of U.P.",
        cite: "AIR 1963 SC 1295", bench: "6-Judge Bench", year: 1963,
        judge: "N. Rajagopala Ayyangar, J.",
        status: "overruled", citedby: 1450,
        holding: "Held there was no fundamental right to privacy — overruled on that point by Puttaswamy (2017).",
        excerpt: "“Overruled to the extent it held that the right to privacy is not a guaranteed right under the Constitution (per K. S. Puttaswamy, 2017).”",
        headnote: "Held that the Constitution contained no distinct fundamental right to privacy — overruled on that point by Puttaswamy (2017).",
        ratio: "",
        relevance: "Tangentially related — earlier view that there was no right to privacy, now overruled.",
        acts: ["Article 21", "Article 19(1)(d)"],
        relies: ["M. P. Sharma v. Satish Chandra"],
        cites: 18, benchStrength: "6J", disposition: "Partly allowed", sections: ["Art.21", "Art.19"],
        authority: "binding", authorityReason: "Supreme Court — binding on all Indian courts (Art. 141)", relType: "contradictory", foundational: true, caseConfidence: 60,
        ratioBasis: "ratio",
        ik: "https://indiankanoon.org/doc/619152/",
      },
      {
        id: "mpsharma", tier: "SC", court: "Supreme Court of India",
        title: "M. P. Sharma v. Satish Chandra",
        cite: "AIR 1954 SC 300", bench: "8-Judge Bench", year: 1954,
        judge: "M. C. Mahajan, C.J.",
        status: "overruled", citedby: 870,
        holding: "Held the Constitution contained no right to privacy — expressly overruled by Puttaswamy (2017).",
        excerpt: "“The reasoning that the Constitution does not protect privacy no longer holds the field after K. S. Puttaswamy (2017).”",
        headnote: "Held the Constitution contained no right to privacy — expressly overruled by Puttaswamy (2017).",
        ratio: "",
        relevance: "Tangentially related — superseded authority denying a constitutional right to privacy.",
        acts: ["Article 20(3)"],
        relies: [],
        cites: 9, benchStrength: "8J", disposition: "Petition dismissed", sections: ["Art.20"],
        authority: "binding", authorityReason: "Supreme Court — binding on all Indian courts (Art. 141)", relType: "contradictory", foundational: false, caseConfidence: 55,
        ratioBasis: "ratio",
        ik: "https://indiankanoon.org/doc/1306519/",
      },
    ],
  },
};

const SUGGESTIONS = [
  { key: "bail",    q: "Can a person get protection from arrest before an FIR is registered?", area: "Criminal · Bail" },
  { key: "fir",     q: "When is registration of an FIR mandatory?", area: "Criminal · Procedure" },
  { key: "privacy", q: "Is the right to privacy a fundamental right?", area: "Constitutional" },
];

const RECENTS = [
  { key: "bail",    label: "Protection from arrest before FIR", area: "Bail", when: "Just now" },
  { key: "privacy", label: "Right to privacy — fundamental?",    area: "Constitutional", when: "2h ago" },
  { key: "fir",     label: "When is FIR registration mandatory", area: "Procedure", when: "Yesterday" },
];

const PIPELINE = [
  { k: "understand", label: "Understanding the question", detail: "Mapping facts to legal concepts" },
  { k: "search",     label: "Searching case law",         detail: "Supreme Court · High Courts · Tribunals" },
  { k: "verify",     label: "Verifying every citation",   detail: "Confirming each judgment exists" },
  { k: "goodlaw",    label: "Checking good-law status",   detail: "Overruled / doubted / followed" },
  { k: "write",      label: "Writing the analysis",       detail: "Structuring in IRAC" },
];

Object.assign(window, { LANGUAGES, LAW_STATUS, RESULTS, SUGGESTIONS, RECENTS, PIPELINE });
