eyecite-ts 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -4
- package/dist/annotate/index.d.cts +1 -1
- package/dist/annotate/index.d.mts +1 -1
- package/dist/{citation-4bmWbhSK.d.cts → citation-25ZydLsu.d.mts} +14 -1
- package/dist/citation-25ZydLsu.d.mts.map +1 -0
- package/dist/{citation-BVN0o8TJ.d.mts → citation-Cymq3pJ-.d.cts} +14 -1
- package/dist/citation-Cymq3pJ-.d.cts.map +1 -0
- package/dist/data/index.cjs +1 -1
- package/dist/data/index.cjs.map +1 -1
- package/dist/data/index.d.cts +91 -1
- package/dist/data/index.d.cts.map +1 -1
- package/dist/data/index.d.mts +91 -1
- package/dist/data/index.d.mts.map +1 -1
- package/dist/data/index.mjs +1 -1
- package/dist/data/index.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -35
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -35
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/knownCodes-CI-vnoBO.cjs +2 -0
- package/dist/knownCodes-CI-vnoBO.cjs.map +1 -0
- package/dist/knownCodes-MkDSiR1j.mjs +2 -0
- package/dist/knownCodes-MkDSiR1j.mjs.map +1 -0
- package/dist/{reporters-DYNnh4O0.mjs → reporters-CZoC98-L.mjs} +1 -1
- package/dist/reporters-CZoC98-L.mjs.map +1 -0
- package/dist/reporters-Wob0oyD9.cjs +2 -0
- package/dist/reporters-Wob0oyD9.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/citation-4bmWbhSK.d.cts.map +0 -1
- package/dist/citation-BVN0o8TJ.d.mts.map +0 -1
- package/dist/reporters-BclWimmk.cjs +0 -2
- package/dist/reporters-BclWimmk.cjs.map +0 -1
- package/dist/reporters-DYNnh4O0.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Extract, resolve, and annotate legal citations from court opinions and legal doc
|
|
|
15
15
|
|
|
16
16
|
## Features
|
|
17
17
|
|
|
18
|
-
- **Full citation extraction**: Case citations, statutes, journal articles, neutral citations, public laws, federal register
|
|
18
|
+
- **Full citation extraction**: Case citations, statutes (20 jurisdictions), journal articles, neutral citations, public laws, federal register
|
|
19
19
|
- **Case name & full span**: Backward search extracts case names ("Smith v. Jones", "In re Smith"), `fullSpan` covers case name through closing parenthetical
|
|
20
20
|
- **Parallel citation linking**: Automatic detection and grouping of comma-separated citations sharing a parenthetical (e.g., "410 U.S. 113, 93 S. Ct. 705 (1973)")
|
|
21
21
|
- **Complex parentheticals**: Unified parser handles court+year, full dates (Jan. 15, 2020 / January 15, 2020 / 1/15/2020), disposition (en banc, per curiam), and chained parentheticals
|
|
@@ -24,7 +24,7 @@ Extract, resolve, and annotate legal citations from court opinions and legal doc
|
|
|
24
24
|
- **Citation annotation**: HTML markup with auto-escape XSS protection and position tracking
|
|
25
25
|
- **Bundle optimization**: Tree-shakeable exports, lazy-loaded reporter data, separate entry points
|
|
26
26
|
- **TypeScript native**: Discriminated unions, conditional types, type guards, full IntelliSense
|
|
27
|
-
- **Zero dependencies**: No runtime dependencies,
|
|
27
|
+
- **Zero dependencies**: No runtime dependencies, ~10KB gzipped core bundle
|
|
28
28
|
|
|
29
29
|
## Installation
|
|
30
30
|
|
|
@@ -75,6 +75,46 @@ citations.forEach(citation => {
|
|
|
75
75
|
})
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
### Statute Citations
|
|
79
|
+
|
|
80
|
+
Extract citations from 20 state and federal jurisdictions with subsection, et seq., and jurisdiction identification:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { extractCitations } from 'eyecite-ts'
|
|
84
|
+
|
|
85
|
+
const text = `
|
|
86
|
+
See 42 U.S.C. § 1983(a)(1) et seq.
|
|
87
|
+
Also Cal. Penal Code § 187.
|
|
88
|
+
And N.Y. Penal Law § 125.25(1)(a).
|
|
89
|
+
Compare 735 ILCS 5/2-1001.
|
|
90
|
+
`
|
|
91
|
+
const citations = extractCitations(text)
|
|
92
|
+
|
|
93
|
+
// Federal with subsections + et seq.
|
|
94
|
+
// { type: 'statute', title: 42, code: 'U.S.C.', section: '1983',
|
|
95
|
+
// subsection: '(a)(1)', jurisdiction: 'US', hasEtSeq: true, confidence: 1.0 }
|
|
96
|
+
|
|
97
|
+
// California named-code
|
|
98
|
+
// { type: 'statute', code: 'Penal', section: '187', jurisdiction: 'CA', confidence: 0.95 }
|
|
99
|
+
|
|
100
|
+
// New York named-code with subsections
|
|
101
|
+
// { type: 'statute', code: 'Penal Law', section: '125.25',
|
|
102
|
+
// subsection: '(1)(a)', jurisdiction: 'NY', confidence: 1.0 }
|
|
103
|
+
|
|
104
|
+
// Illinois chapter-act format
|
|
105
|
+
// { type: 'statute', title: 735, code: '5', section: '2-1001',
|
|
106
|
+
// jurisdiction: 'IL', confidence: 0.95 }
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Supported jurisdictions:**
|
|
110
|
+
|
|
111
|
+
| Family | Jurisdictions |
|
|
112
|
+
|--------|--------------|
|
|
113
|
+
| Federal | USC, CFR, prose ("section X of title Y") |
|
|
114
|
+
| Named-code | NY (21 laws), CA (29 codes), TX (29 codes), MD (36 articles), VA, AL, MA |
|
|
115
|
+
| Abbreviated-code | FL, OH, MI, UT, CO, WA, NC, GA, PA, IN, NJ, DE |
|
|
116
|
+
| Chapter-act | IL (ILCS) |
|
|
117
|
+
|
|
78
118
|
### Async API
|
|
79
119
|
|
|
80
120
|
```typescript
|
|
@@ -434,7 +474,7 @@ Three entry points for optimal tree-shaking:
|
|
|
434
474
|
|
|
435
475
|
| Entry Point | Import | Gzipped |
|
|
436
476
|
|------------|--------|---------|
|
|
437
|
-
| Core extraction | `eyecite-ts` |
|
|
477
|
+
| Core extraction | `eyecite-ts` | ~10 KB |
|
|
438
478
|
| Annotation | `eyecite-ts/annotate` | 0.7 KB |
|
|
439
479
|
| Reporter data | `eyecite-ts/data` | 86.5 KB (lazy-loaded) |
|
|
440
480
|
|
|
@@ -469,7 +509,7 @@ pnpm lint # Lint with Biome
|
|
|
469
509
|
pnpm format # Format with Biome
|
|
470
510
|
```
|
|
471
511
|
|
|
472
|
-
|
|
512
|
+
985+ tests across 32 test files.
|
|
473
513
|
|
|
474
514
|
## License
|
|
475
515
|
|
|
@@ -205,12 +205,25 @@ interface FullCaseCitation extends CitationBase {
|
|
|
205
205
|
* Statute citation (U.S. Code, state codes, etc.).
|
|
206
206
|
*
|
|
207
207
|
* @example "42 U.S.C. § 1983"
|
|
208
|
+
* @example "42 U.S.C. § 1983(a)(1) et seq."
|
|
208
209
|
*/
|
|
209
210
|
interface StatuteCitation extends CitationBase {
|
|
210
211
|
type: "statute";
|
|
211
212
|
title?: number;
|
|
212
213
|
code: string;
|
|
213
214
|
section: string;
|
|
215
|
+
/** Subsection/pincite chain, e.g. "(a)(1)(A)" */
|
|
216
|
+
subsection?: string;
|
|
217
|
+
/** 2-letter state code or "US" when unambiguously identified */
|
|
218
|
+
jurisdiction?: string;
|
|
219
|
+
/**
|
|
220
|
+
* Alias for subsection (eyecite-ts convention).
|
|
221
|
+
* Note: this is string (subsection chain), unlike FullCaseCitation.pincite which is number (page offset).
|
|
222
|
+
* The discriminated union on `type` ensures type safety at call sites.
|
|
223
|
+
*/
|
|
224
|
+
pincite?: string;
|
|
225
|
+
/** True when "et seq." follows the citation */
|
|
226
|
+
hasEtSeq?: boolean;
|
|
214
227
|
}
|
|
215
228
|
/**
|
|
216
229
|
* Journal citation (law review, legal periodical).
|
|
@@ -386,4 +399,4 @@ type CitationOfType<T extends CitationType> = Extract<Citation, {
|
|
|
386
399
|
type ExtractorMap = { [K in FullCitationType]: CitationOfType<K> };
|
|
387
400
|
//#endregion
|
|
388
401
|
export { TransformationMap as S, StatuteCitation as _, ExtractorMap as a, Warning as b, FullCitation as c, JournalCitation as d, NeutralCitation as f, ShortFormCitationType as g, ShortFormCitation as h, CitationType as i, FullCitationType as l, ShortFormCaseCitation as m, CitationBase as n, FederalRegisterCitation as o, PublicLawCitation as p, CitationOfType as r, FullCaseCitation as s, Citation as t, IdCitation as u, StatutesAtLargeCitation as v, Span as x, SupraCitation as y };
|
|
389
|
-
//# sourceMappingURL=citation-
|
|
402
|
+
//# sourceMappingURL=citation-25ZydLsu.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citation-25ZydLsu.d.mts","names":[],"sources":["../src/types/span.ts","../src/types/citation.ts"],"mappings":";;AAiBA;;;;;;;;;;AAoBA;;;;;;UApBiB,IAAA;;EAEf,UAAA;EAuBiB;EApBjB,QAAA;;EAGA,aAAA;ECpBF;EDuBE,WAAA;AAAA;;;AClBF;;;;UD2BiB,iBAAA;;EAEf,eAAA,EAAiB,GAAA;;EAGjB,eAAA,EAAiB,GAAA;AAAA;;;AAzBnB;;;AAAA,KCZY,YAAA;;;;UAKK,OAAA;;EAEf,KAAA;EDyBF;ECvBE,OAAA;;EAEA,QAAA;IAAY,KAAA;IAAe,GAAA;EAAA;;EAE3B,OAAA;AAAA;;;;UAMe,YAAA;EAnBL;EAqBV,IAAA;EArBU;EAwBV,IAAA,EAAM,IAAA;EAnBR;;;;;;;EA4BE,UAAA;;EAGA,WAAA;;EAGA,aAAA;EApBF;EAuBE,eAAA;;EAGA,QAAA,GAAW,OAAA;AAAA;;;;;;;UASI,gBAAA,SAAyB,YAAA;EACxC,IAAA;EACA,MAAA;EACA,QAAA;EAHF;EAKE,IAAA;EACA,OAAA;EACA,KAAA;EACA,IAAA;;EAGA,kBAAA;;;;;;;;EASA,OAAA;;EAGA,iBAAA,GAAoB,KAAA;IAClB,MAAA;IACA,QAAA;IACA,IAAA;EAAA;;EAIF,MAAA;;EAGA,aAAA;;EAGA,iBAAA;;;;;;EAOA,IAAA;IACE,GAAA;IACA,MAAA;MAAW,IAAA;MAAc,KAAA;MAAgB,GAAA;IAAA;EAAA;;;;;EAO3C,uBAAA,GAA0B,KAAA;IACxB,MAAA;IACA,QAAA;IACA,IAAA;IACA,UAAA;IACA,MAAA;EAAA;EAgEF;AASF;;;;EAjEE,QAAA,GAAW,IAAA;;;;;;EAOX,QAAA;;;;;AAqFF;EA9EE,SAAA;;;;;;EAOA,SAAA;;;;;;EAOA,mBAAA;;;AA4FF;;;EArFE,mBAAA;;;;;;EAOA,gBAAA;EAqFA;AAWF;;;;EAzFE,YAAA;;;;;;EAOA,WAAA;AAAA;;;;;;;UASe,eAAA,SAAwB,YAAA;EACvC,IAAA;EACA,KAAA;EACA,IAAA;EACA,OAAA;EAkGe;EAhGf,UAAA;EAgG+C;EA9F/C,YAAA;;;;;;EAMA,OAAA;EAwGF;EAtGE,QAAA;AAAA;;;;;;;AAiHF;;UAtGiB,eAAA,SAAwB,YAAA;EACvC,IAAA;;EAEA,MAAA;;EAEA,KAAA;;EAEA,MAAA;EA6GF;EA3GE,OAAA;;EAEA,YAAA;;EAEA,IAAA;;EAEA,OAAA;;EAEA,IAAA;AAAA;;AA4HF;;;;;;;UAjHiB,eAAA,SAAwB,YAAA;EACvC,IAAA;;EAEA,IAAA;;EAEA,KAAA;;EAEA,cAAA;AAAA;;;;;;;;;UAWe,iBAAA,SAA0B,YAAA;EACzC,IAAA;EAwGE;EAtGF,QAAA;EA2GU;EAzGV,SAAA;EAyGU;EAvGV,KAAA;AAAA;;;;;AA6GF;;;;UAlGiB,uBAAA,SAAgC,YAAA;EAC/C,IAAA;;EAEA,MAAA;;EAEA,IAAA;;EAEA,IAAA;AAAA;;UAIe,uBAAA,SAAgC,YAAA;EAC/C,IAAA;;EAEA,MAAA;;EAEA,IAAA;EAkFgJ;EAhFhJ,IAAA;AAAA;;;;;;;UASe,UAAA,SAAmB,YAAA;EAClC,IAAA;EACA,OAAA;AAAA;;AAqFF;;;;;UA5EiB,aAAA,SAAsB,YAAA;EACrC,IAAA;;EAEA,SAAA;;EAEA,OAAA;AAAA;;;;;;AA6EF;UApEiB,qBAAA,SAA8B,YAAA;EAC7C,IAAA;EACA,MAAA;EACA,QAAA;EACA,IAAA;EACA,OAAA;AAAA;;;;;;;;;;;;;;;;;;KAoBU,QAAA,GACR,gBAAA,GACA,eAAA,GACA,eAAA,GACA,eAAA,GACA,iBAAA,GACA,uBAAA,GACA,uBAAA,GACA,UAAA,GACA,aAAA,GACA,qBAAA;;;;KAKQ,gBAAA;AAAA,KACA,qBAAA;;;;KAKA,YAAA,GAAe,gBAAA,GAAmB,eAAA,GAAkB,eAAA,GAAkB,eAAA,GAAkB,iBAAA,GAAoB,uBAAA,GAA0B,uBAAA;;;;KAKtI,iBAAA,GAAoB,UAAA,GAAa,aAAA,GAAgB,qBAAA;;;;;;;;;;KAWjD,cAAA,WAAyB,YAAA,IAAgB,OAAA,CAAQ,QAAA;EAAY,IAAA,EAAM,CAAA;AAAA;;;;;KAMnE,YAAA,WACJ,gBAAA,GAAmB,cAAA,CAAe,CAAA"}
|
|
@@ -205,12 +205,25 @@ interface FullCaseCitation extends CitationBase {
|
|
|
205
205
|
* Statute citation (U.S. Code, state codes, etc.).
|
|
206
206
|
*
|
|
207
207
|
* @example "42 U.S.C. § 1983"
|
|
208
|
+
* @example "42 U.S.C. § 1983(a)(1) et seq."
|
|
208
209
|
*/
|
|
209
210
|
interface StatuteCitation extends CitationBase {
|
|
210
211
|
type: "statute";
|
|
211
212
|
title?: number;
|
|
212
213
|
code: string;
|
|
213
214
|
section: string;
|
|
215
|
+
/** Subsection/pincite chain, e.g. "(a)(1)(A)" */
|
|
216
|
+
subsection?: string;
|
|
217
|
+
/** 2-letter state code or "US" when unambiguously identified */
|
|
218
|
+
jurisdiction?: string;
|
|
219
|
+
/**
|
|
220
|
+
* Alias for subsection (eyecite-ts convention).
|
|
221
|
+
* Note: this is string (subsection chain), unlike FullCaseCitation.pincite which is number (page offset).
|
|
222
|
+
* The discriminated union on `type` ensures type safety at call sites.
|
|
223
|
+
*/
|
|
224
|
+
pincite?: string;
|
|
225
|
+
/** True when "et seq." follows the citation */
|
|
226
|
+
hasEtSeq?: boolean;
|
|
214
227
|
}
|
|
215
228
|
/**
|
|
216
229
|
* Journal citation (law review, legal periodical).
|
|
@@ -386,4 +399,4 @@ type CitationOfType<T extends CitationType> = Extract<Citation, {
|
|
|
386
399
|
type ExtractorMap = { [K in FullCitationType]: CitationOfType<K> };
|
|
387
400
|
//#endregion
|
|
388
401
|
export { TransformationMap as S, StatuteCitation as _, ExtractorMap as a, Warning as b, FullCitation as c, JournalCitation as d, NeutralCitation as f, ShortFormCitationType as g, ShortFormCitation as h, CitationType as i, FullCitationType as l, ShortFormCaseCitation as m, CitationBase as n, FederalRegisterCitation as o, PublicLawCitation as p, CitationOfType as r, FullCaseCitation as s, Citation as t, IdCitation as u, StatutesAtLargeCitation as v, Span as x, SupraCitation as y };
|
|
389
|
-
//# sourceMappingURL=citation-
|
|
402
|
+
//# sourceMappingURL=citation-Cymq3pJ-.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citation-Cymq3pJ-.d.cts","names":[],"sources":["../src/types/span.ts","../src/types/citation.ts"],"mappings":"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"}
|
package/dist/data/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../knownCodes-CI-vnoBO.cjs`);let t=null;async function n(){if(t)return t;let e=await import(`../../data/reporters.json`,{assert:{type:`json`}}),n=new Map,r=[],i=e.default||e;for(let[e,t]of Object.entries(i))for(let e of t){r.push(e);for(let t of Object.keys(e.editions)){let r=t.toLowerCase();n.has(r)||n.set(r,[]),n.get(r)?.push(e)}for(let[t,r]of Object.entries(e.variations||{})){let r=t.toLowerCase();n.has(r)||n.set(r,[]),n.get(r)?.push(e)}}return t={byAbbreviation:n,all:r},t}function r(){return t}async function i(e){return(await n()).byAbbreviation.get(e.toLowerCase())??[]}exports.abbreviatedCodes=e.t,exports.findAbbreviatedCode=e.n,exports.findNamedCode=e.r,exports.findReportersByAbbreviation=i,exports.getReportersSync=r,exports.loadReporters=n,exports.namedCodes=e.i;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/data/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/data/reporters.ts"],"sourcesContent":["/**\n * Reporter database integration for citation validation\n *\n * This module provides lazy-loadable access to the reporters-db database,\n * containing 1200+ court reporters with variant forms. The library works\n * in degraded mode (pattern-based extraction only) if reporters are not loaded.\n *\n * @example\n * // Degraded mode: extraction works without reporter data\n * const citations = await extract(text)\n *\n * @example\n * // Full mode: load reporters for validation\n * await loadReporters()\n * const citations = await extract(text) // Now with reporter validation\n */\n\n/**\n * Edition entry from reporters-db\n *\n * Represents a specific edition of a reporter with start/end dates.\n */\nexport interface ReporterEdition {\n /** Start date in ISO 8601 format */\n start: string | null\n /** End date in ISO 8601 format (null if ongoing) */\n end: string | null\n}\n\n/**\n * Reporter entry from reporters-db\n *\n * Represents a single court reporter with all metadata needed for\n * citation validation and enrichment.\n *\n * Note: The reporters-db structure has the actual data; this interface\n * represents it flexibly to handle all variations in the JSON.\n */\nexport interface ReporterEntry {\n /** Full reporter name (e.g., \"Federal Reporter\") */\n name: string\n /** Citation type: state, federal, specialty, neutral, state_regional, etc. */\n cite_type: string\n /** Editions keyed by abbreviation (e.g., {\"F.2d\": {...}, \"F.3d\": {...}}) */\n editions: Record<string, ReporterEdition>\n /** Variant forms mapped to canonical form (e.g., {\"F. 2d\": \"F.2d\"}) */\n variations?: Record<string, string | undefined>\n /** MLZ jurisdiction identifiers (optional) */\n mlz_jurisdiction?: string[]\n /** Publisher (optional) */\n publisher?: string\n /** Notes (optional) */\n notes?: string\n}\n\n/**\n * In-memory reporter database with fast O(1) lookup\n *\n * Uses Map-based indexing for case-insensitive abbreviation lookup.\n * All variant forms are indexed to support fuzzy matching.\n */\nexport interface ReportersDatabase {\n /** Fast O(1) lookup by abbreviation (lowercase normalized keys) */\n byAbbreviation: Map<string, ReporterEntry[]>\n /** All reporters (for iteration/filtering) */\n all: ReporterEntry[]\n}\n\n/**\n * Cached database instance (null until loadReporters() called)\n */\nlet cached: ReportersDatabase | null = null\n\n/**\n * Load reporter database asynchronously with lazy loading\n *\n * Dynamic import prevents loading 1200+ reporters until explicitly requested.\n * Result is cached after first load for subsequent calls.\n *\n * @returns Promise resolving to indexed reporter database\n *\n * @example\n * const db = await loadReporters()\n * const reporters = db.byAbbreviation.get('f.2d') // Fast O(1) lookup\n */\nexport async function loadReporters(): Promise<ReportersDatabase> {\n if (cached) return cached\n\n // Dynamic import prevents loading until requested (keeps core bundle small)\n const data = await import(\"../../data/reporters.json\", {\n assert: { type: \"json\" },\n })\n\n const byAbbreviation = new Map<string, ReporterEntry[]>()\n const all: ReporterEntry[] = []\n\n // reporters.json structure: { \"A.\": [...], \"F.2d\": [...], ... }\n const reportersData = (data.default || data) as Record<\n string,\n ReporterEntry[]\n >\n\n // Build fast lookup index with lowercase normalization\n for (const [_canonicalAbbr, reporters] of Object.entries(reportersData)) {\n for (const reporter of reporters) {\n all.push(reporter)\n\n // Index by all edition abbreviations\n for (const editionAbbr of Object.keys(reporter.editions)) {\n const key = editionAbbr.toLowerCase()\n if (!byAbbreviation.has(key)) {\n byAbbreviation.set(key, [])\n }\n byAbbreviation.get(key)?.push(reporter)\n }\n\n // Index all variations for fuzzy matching\n for (const [variant, _canonical] of Object.entries(\n reporter.variations || {},\n )) {\n const variantKey = variant.toLowerCase()\n if (!byAbbreviation.has(variantKey)) {\n byAbbreviation.set(variantKey, [])\n }\n byAbbreviation.get(variantKey)?.push(reporter)\n }\n }\n }\n\n cached = {\n byAbbreviation,\n all,\n }\n return cached\n}\n\n/**\n * Get cached reporter database synchronously (degraded mode support)\n *\n * Returns null if reporters not loaded yet. This enables the library to\n * work in degraded mode without reporter validation.\n *\n * @returns Cached database or null if not loaded\n *\n * @example\n * const db = getReportersSync()\n * if (db) {\n * // Full mode: validate citations\n * } else {\n * // Degraded mode: extract without validation\n * }\n */\nexport function getReportersSync(): ReportersDatabase | null {\n return cached\n}\n\n/**\n * Find reporters by abbreviation (case-insensitive)\n *\n * Loads reporter database if not already loaded. Returns all reporters\n * matching the abbreviation (including variant forms).\n *\n * @param abbr - Reporter abbreviation to look up\n * @returns Promise resolving to matching reporters (empty array if none)\n *\n * @example\n * const reporters = await findReportersByAbbreviation('F.2d')\n * // [{ abbreviation: 'F.2d', name: 'Federal Reporter, Second Series', ... }]\n *\n * @example\n * const unknown = await findReportersByAbbreviation('NONEXISTENT')\n * // [] (empty array, not error)\n */\nexport async function findReportersByAbbreviation(\n abbr: string,\n): Promise<ReporterEntry[]> {\n const db = await loadReporters()\n return db.byAbbreviation.get(abbr.toLowerCase()) ?? []\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/data/reporters.ts"],"sourcesContent":["/**\n * Reporter database integration for citation validation\n *\n * This module provides lazy-loadable access to the reporters-db database,\n * containing 1200+ court reporters with variant forms. The library works\n * in degraded mode (pattern-based extraction only) if reporters are not loaded.\n *\n * @example\n * // Degraded mode: extraction works without reporter data\n * const citations = await extract(text)\n *\n * @example\n * // Full mode: load reporters for validation\n * await loadReporters()\n * const citations = await extract(text) // Now with reporter validation\n */\n\n/**\n * Edition entry from reporters-db\n *\n * Represents a specific edition of a reporter with start/end dates.\n */\nexport interface ReporterEdition {\n /** Start date in ISO 8601 format */\n start: string | null\n /** End date in ISO 8601 format (null if ongoing) */\n end: string | null\n}\n\n/**\n * Reporter entry from reporters-db\n *\n * Represents a single court reporter with all metadata needed for\n * citation validation and enrichment.\n *\n * Note: The reporters-db structure has the actual data; this interface\n * represents it flexibly to handle all variations in the JSON.\n */\nexport interface ReporterEntry {\n /** Full reporter name (e.g., \"Federal Reporter\") */\n name: string\n /** Citation type: state, federal, specialty, neutral, state_regional, etc. */\n cite_type: string\n /** Editions keyed by abbreviation (e.g., {\"F.2d\": {...}, \"F.3d\": {...}}) */\n editions: Record<string, ReporterEdition>\n /** Variant forms mapped to canonical form (e.g., {\"F. 2d\": \"F.2d\"}) */\n variations?: Record<string, string | undefined>\n /** MLZ jurisdiction identifiers (optional) */\n mlz_jurisdiction?: string[]\n /** Publisher (optional) */\n publisher?: string\n /** Notes (optional) */\n notes?: string\n}\n\n/**\n * In-memory reporter database with fast O(1) lookup\n *\n * Uses Map-based indexing for case-insensitive abbreviation lookup.\n * All variant forms are indexed to support fuzzy matching.\n */\nexport interface ReportersDatabase {\n /** Fast O(1) lookup by abbreviation (lowercase normalized keys) */\n byAbbreviation: Map<string, ReporterEntry[]>\n /** All reporters (for iteration/filtering) */\n all: ReporterEntry[]\n}\n\n/**\n * Cached database instance (null until loadReporters() called)\n */\nlet cached: ReportersDatabase | null = null\n\n/**\n * Load reporter database asynchronously with lazy loading\n *\n * Dynamic import prevents loading 1200+ reporters until explicitly requested.\n * Result is cached after first load for subsequent calls.\n *\n * @returns Promise resolving to indexed reporter database\n *\n * @example\n * const db = await loadReporters()\n * const reporters = db.byAbbreviation.get('f.2d') // Fast O(1) lookup\n */\nexport async function loadReporters(): Promise<ReportersDatabase> {\n if (cached) return cached\n\n // Dynamic import prevents loading until requested (keeps core bundle small)\n const data = await import(\"../../data/reporters.json\", {\n assert: { type: \"json\" },\n })\n\n const byAbbreviation = new Map<string, ReporterEntry[]>()\n const all: ReporterEntry[] = []\n\n // reporters.json structure: { \"A.\": [...], \"F.2d\": [...], ... }\n const reportersData = (data.default || data) as Record<\n string,\n ReporterEntry[]\n >\n\n // Build fast lookup index with lowercase normalization\n for (const [_canonicalAbbr, reporters] of Object.entries(reportersData)) {\n for (const reporter of reporters) {\n all.push(reporter)\n\n // Index by all edition abbreviations\n for (const editionAbbr of Object.keys(reporter.editions)) {\n const key = editionAbbr.toLowerCase()\n if (!byAbbreviation.has(key)) {\n byAbbreviation.set(key, [])\n }\n byAbbreviation.get(key)?.push(reporter)\n }\n\n // Index all variations for fuzzy matching\n for (const [variant, _canonical] of Object.entries(\n reporter.variations || {},\n )) {\n const variantKey = variant.toLowerCase()\n if (!byAbbreviation.has(variantKey)) {\n byAbbreviation.set(variantKey, [])\n }\n byAbbreviation.get(variantKey)?.push(reporter)\n }\n }\n }\n\n cached = {\n byAbbreviation,\n all,\n }\n return cached\n}\n\n/**\n * Get cached reporter database synchronously (degraded mode support)\n *\n * Returns null if reporters not loaded yet. This enables the library to\n * work in degraded mode without reporter validation.\n *\n * @returns Cached database or null if not loaded\n *\n * @example\n * const db = getReportersSync()\n * if (db) {\n * // Full mode: validate citations\n * } else {\n * // Degraded mode: extract without validation\n * }\n */\nexport function getReportersSync(): ReportersDatabase | null {\n return cached\n}\n\n/**\n * Find reporters by abbreviation (case-insensitive)\n *\n * Loads reporter database if not already loaded. Returns all reporters\n * matching the abbreviation (including variant forms).\n *\n * @param abbr - Reporter abbreviation to look up\n * @returns Promise resolving to matching reporters (empty array if none)\n *\n * @example\n * const reporters = await findReportersByAbbreviation('F.2d')\n * // [{ abbreviation: 'F.2d', name: 'Federal Reporter, Second Series', ... }]\n *\n * @example\n * const unknown = await findReportersByAbbreviation('NONEXISTENT')\n * // [] (empty array, not error)\n */\nexport async function findReportersByAbbreviation(\n abbr: string,\n): Promise<ReporterEntry[]> {\n const db = await loadReporters()\n return db.byAbbreviation.get(abbr.toLowerCase()) ?? []\n}\n"],"mappings":"iHAuEA,IAAI,EAAmC,KAcvC,eAAsB,GAA4C,CAChE,GAAI,EAAQ,OAAO,EAGnB,IAAM,EAAO,MAAM,OAAO,4BAA6B,CACrD,OAAQ,CAAE,KAAM,OAAQ,CACzB,EAEK,EAAiB,IAAI,IACrB,EAAuB,EAAE,CAGzB,EAAiB,EAAK,SAAW,EAMvC,IAAK,GAAM,CAAC,EAAgB,KAAc,OAAO,QAAQ,EAAc,CACrE,IAAK,IAAM,KAAY,EAAW,CAChC,EAAI,KAAK,EAAS,CAGlB,IAAK,IAAM,KAAe,OAAO,KAAK,EAAS,SAAS,CAAE,CACxD,IAAM,EAAM,EAAY,aAAa,CAChC,EAAe,IAAI,EAAI,EAC1B,EAAe,IAAI,EAAK,EAAE,CAAC,CAE7B,EAAe,IAAI,EAAI,EAAE,KAAK,EAAS,CAIzC,IAAK,GAAM,CAAC,EAAS,KAAe,OAAO,QACzC,EAAS,YAAc,EAAE,CAC1B,CAAE,CACD,IAAM,EAAa,EAAQ,aAAa,CACnC,EAAe,IAAI,EAAW,EACjC,EAAe,IAAI,EAAY,EAAE,CAAC,CAEpC,EAAe,IAAI,EAAW,EAAE,KAAK,EAAS,EASpD,MAJA,GAAS,CACP,iBACA,MACD,CACM,EAmBT,SAAgB,GAA6C,CAC3D,OAAO,EAoBT,eAAsB,EACpB,EAC0B,CAE1B,OADW,MAAM,GAAe,EACtB,eAAe,IAAI,EAAK,aAAa,CAAC,EAAI,EAAE"}
|
package/dist/data/index.d.cts
CHANGED
|
@@ -112,5 +112,95 @@ declare function getReportersSync(): ReportersDatabase | null;
|
|
|
112
112
|
*/
|
|
113
113
|
declare function findReportersByAbbreviation(abbr: string): Promise<ReporterEntry[]>;
|
|
114
114
|
//#endregion
|
|
115
|
-
|
|
115
|
+
//#region src/data/knownCodes.d.ts
|
|
116
|
+
/**
|
|
117
|
+
* Known statutory code registry for abbreviated-code jurisdictions
|
|
118
|
+
*
|
|
119
|
+
* Provides a registry of state statutory codes that use abbreviated
|
|
120
|
+
* citation forms (e.g., "R.C. § 1.01", "MCL 750.83"). Used by the
|
|
121
|
+
* citation extractor to identify and normalize state statute citations.
|
|
122
|
+
*/
|
|
123
|
+
/**
|
|
124
|
+
* A single entry in the known codes registry.
|
|
125
|
+
*
|
|
126
|
+
* PA has two entries (Pa.C.S. and P.S.) because it has two distinct
|
|
127
|
+
* code families with separate abbreviation sets.
|
|
128
|
+
*/
|
|
129
|
+
interface CodeEntry {
|
|
130
|
+
/** Two-letter state abbreviation (e.g., "OH", "MI") */
|
|
131
|
+
jurisdiction: string;
|
|
132
|
+
/** Short canonical abbreviation used internally (e.g., "RC", "MCL") */
|
|
133
|
+
abbreviation: string;
|
|
134
|
+
/** All recognized text patterns that identify this code */
|
|
135
|
+
patterns: string[];
|
|
136
|
+
/** Citation family — determines which citation pattern family this belongs to */
|
|
137
|
+
family: "federal" | "named" | "abbreviated" | "chapterAct" | "prose";
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Registry of state statutory codes that use abbreviated citation forms.
|
|
141
|
+
*
|
|
142
|
+
* Covers 12 jurisdictions. Pennsylvania has two entries because it
|
|
143
|
+
* maintains two distinct code families (Pa.C.S. and P.S.).
|
|
144
|
+
*
|
|
145
|
+
* Note: Short 2-letter patterns (GS, IC, PS, RC, FS) may produce false positives
|
|
146
|
+
* in non-legal text (e.g., "GS 5" for government service grade). The extraction
|
|
147
|
+
* layer mitigates this via confidence scoring — citations without a § symbol receive
|
|
148
|
+
* lower confidence (0.85 vs 0.95). Consumers should filter by confidence threshold.
|
|
149
|
+
*/
|
|
150
|
+
declare const abbreviatedCodes: CodeEntry[];
|
|
151
|
+
/**
|
|
152
|
+
* Registry of state statutory codes that use named-code citation forms.
|
|
153
|
+
*
|
|
154
|
+
* Named-code jurisdictions identify their code by name in citations (e.g.,
|
|
155
|
+
* "N.Y. Penal Law § 120.05", "Cal. Civ. Proc. Code § 437c"), rather than by
|
|
156
|
+
* a standalone abbreviation. The jurisdiction prefix is handled by the
|
|
157
|
+
* extraction layer; these patterns cover only the code name portion.
|
|
158
|
+
*
|
|
159
|
+
* Ordering note: within each jurisdiction, more specific patterns must come
|
|
160
|
+
* before more general ones (e.g., "Civ. Proc." before "Civ.") so that
|
|
161
|
+
* findNamedCode's longest-match wins correctly.
|
|
162
|
+
*
|
|
163
|
+
* Covers 7 jurisdictions: NY (21 entries), CA (29 entries), TX (29 entries),
|
|
164
|
+
* MD (36 entries), VA (1 entry), AL (1 entry), MA (1 entry).
|
|
165
|
+
*/
|
|
166
|
+
declare const namedCodes: CodeEntry[];
|
|
167
|
+
/**
|
|
168
|
+
* Find a CodeEntry by jurisdiction and code name token.
|
|
169
|
+
*
|
|
170
|
+
* Lookup strategy: for each candidate entry in the given jurisdiction,
|
|
171
|
+
* check whether the normalized codeName matches or starts with any of the
|
|
172
|
+
* entry's patterns (case-insensitive). Returns the entry with the longest
|
|
173
|
+
* matching pattern to prefer more specific codes over general ones
|
|
174
|
+
* (e.g., "Civ. Proc." over "Civ.").
|
|
175
|
+
*
|
|
176
|
+
* @param jurisdiction - Two-letter state abbreviation (e.g., "CA", "NY")
|
|
177
|
+
* @param codeName - The code name token to look up (e.g., "Penal", "Civ. Proc.")
|
|
178
|
+
* @returns Matching CodeEntry, or undefined if not found
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* findNamedCode('NY', 'Penal') // → NY PEN entry
|
|
182
|
+
* findNamedCode('CA', 'Civ. Proc.') // → CA CCP entry (not CA CIV)
|
|
183
|
+
* findNamedCode('MD', 'Crim. Law') // → MD gcr entry
|
|
184
|
+
* findNamedCode('NY', 'Unknown') // → undefined
|
|
185
|
+
*/
|
|
186
|
+
declare function findNamedCode(jurisdiction: string, codeName: string): CodeEntry | undefined;
|
|
187
|
+
/**
|
|
188
|
+
* Find a CodeEntry by an abbreviated text token.
|
|
189
|
+
*
|
|
190
|
+
* Lookup order:
|
|
191
|
+
* 1. Exact case-insensitive match against all patterns
|
|
192
|
+
* 2. Prefix match — returns the entry whose pattern is the longest
|
|
193
|
+
* prefix of `abbrevText` (handles tokens like "RCW" inside longer text)
|
|
194
|
+
*
|
|
195
|
+
* @param abbrevText - The abbreviation token to look up
|
|
196
|
+
* @returns Matching CodeEntry, or undefined if not found
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* findAbbreviatedCode('R.C.') // → OH entry
|
|
200
|
+
* findAbbreviatedCode('MCL') // → MI entry
|
|
201
|
+
* findAbbreviatedCode('UNKNOWN') // → undefined
|
|
202
|
+
*/
|
|
203
|
+
declare function findAbbreviatedCode(abbrevText: string): CodeEntry | undefined;
|
|
204
|
+
//#endregion
|
|
205
|
+
export { CodeEntry, ReporterEdition, ReporterEntry, ReportersDatabase, abbreviatedCodes, findAbbreviatedCode, findNamedCode, findReportersByAbbreviation, getReportersSync, loadReporters, namedCodes };
|
|
116
206
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/data/reporters.ts"],"mappings":";;AAsBA;;;;;AAgBA;;;;;;;;;;;;;;;UAhBiB,eAAA;;EAEf,KAAA;;EAEA,GAAA;AAAA;;;;;;;;;;UAYe,aAAA;;EAEf,IAAA;;EAEA,SAAA;EA2CF;EAzCE,QAAA,EAAU,MAAA,SAAe,eAAA;;EAEzB,UAAA,GAAa,MAAA;EAuCgC;EArC7C,gBAAA;EAwGc;EAtGd,SAAA;EAsGkC;EApGlC,KAAA;AAAA;;;;;;;UASe,iBAAA;EAkHN;EAhHT,cAAA,EAAgB,GAAA,SAAY,aAAA;;EAE5B,GAAA,EAAK,aAAA;AAAA
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/data/reporters.ts","../../src/data/knownCodes.ts"],"mappings":";;AAsBA;;;;;AAgBA;;;;;;;;;;;;;;;UAhBiB,eAAA;;EAEf,KAAA;;EAEA,GAAA;AAAA;;;;;;;;;;UAYe,aAAA;;EAEf,IAAA;;EAEA,SAAA;EA2CF;EAzCE,QAAA,EAAU,MAAA,SAAe,eAAA;;EAEzB,UAAA,GAAa,MAAA;EAuCgC;EArC7C,gBAAA;EAwGc;EAtGd,SAAA;EAsGkC;EApGlC,KAAA;AAAA;;;;;;;UASe,iBAAA;EAkHN;EAhHT,cAAA,EAAgB,GAAA,SAAY,aAAA;;EAE5B,GAAA,EAAK,aAAA;AAAA;;;;;;;;;;AC7BP;;;iBDiDsB,aAAA,CAAA,GAAiB,OAAA,CAAQ,iBAAA;;ACyE/C;;;;;AAyuBA;;;;;;;;;AA8DA;iBD7yBgB,gBAAA,CAAA,GAAoB,iBAAA;;;;;;;;;;;;;;;;;;iBAqBd,2BAAA,CACpB,IAAA,WACC,OAAA,CAAQ,aAAA;;;;AAzJX;;;;;AAgBA;;;;;;;UCxBiB,SAAA;;EAEf,YAAA;;EAEA,YAAA;;EAEA,QAAA;;EAEA,MAAA;AAAA;;;;ADuCF;;;;;;;;cCzBa,gBAAA,EAAkB,SAAA;;;;;;;ADiD/B;;;;;AAmEA;;;;cCMa,UAAA,EAAY,SAAA;ADezB;;;;;;;;;;;;AC/JA;;;;;;;AD+JA,iBC0tBgB,aAAA,CAAc,YAAA,UAAsB,QAAA,WAAmB,SAAA;;;AAn2BvE;;;;;AA0HA;;;;;AAyuBA;;;;iBA8DgB,mBAAA,CAAoB,UAAA,WAAqB,SAAA"}
|
package/dist/data/index.d.mts
CHANGED
|
@@ -112,5 +112,95 @@ declare function getReportersSync(): ReportersDatabase | null;
|
|
|
112
112
|
*/
|
|
113
113
|
declare function findReportersByAbbreviation(abbr: string): Promise<ReporterEntry[]>;
|
|
114
114
|
//#endregion
|
|
115
|
-
|
|
115
|
+
//#region src/data/knownCodes.d.ts
|
|
116
|
+
/**
|
|
117
|
+
* Known statutory code registry for abbreviated-code jurisdictions
|
|
118
|
+
*
|
|
119
|
+
* Provides a registry of state statutory codes that use abbreviated
|
|
120
|
+
* citation forms (e.g., "R.C. § 1.01", "MCL 750.83"). Used by the
|
|
121
|
+
* citation extractor to identify and normalize state statute citations.
|
|
122
|
+
*/
|
|
123
|
+
/**
|
|
124
|
+
* A single entry in the known codes registry.
|
|
125
|
+
*
|
|
126
|
+
* PA has two entries (Pa.C.S. and P.S.) because it has two distinct
|
|
127
|
+
* code families with separate abbreviation sets.
|
|
128
|
+
*/
|
|
129
|
+
interface CodeEntry {
|
|
130
|
+
/** Two-letter state abbreviation (e.g., "OH", "MI") */
|
|
131
|
+
jurisdiction: string;
|
|
132
|
+
/** Short canonical abbreviation used internally (e.g., "RC", "MCL") */
|
|
133
|
+
abbreviation: string;
|
|
134
|
+
/** All recognized text patterns that identify this code */
|
|
135
|
+
patterns: string[];
|
|
136
|
+
/** Citation family — determines which citation pattern family this belongs to */
|
|
137
|
+
family: "federal" | "named" | "abbreviated" | "chapterAct" | "prose";
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Registry of state statutory codes that use abbreviated citation forms.
|
|
141
|
+
*
|
|
142
|
+
* Covers 12 jurisdictions. Pennsylvania has two entries because it
|
|
143
|
+
* maintains two distinct code families (Pa.C.S. and P.S.).
|
|
144
|
+
*
|
|
145
|
+
* Note: Short 2-letter patterns (GS, IC, PS, RC, FS) may produce false positives
|
|
146
|
+
* in non-legal text (e.g., "GS 5" for government service grade). The extraction
|
|
147
|
+
* layer mitigates this via confidence scoring — citations without a § symbol receive
|
|
148
|
+
* lower confidence (0.85 vs 0.95). Consumers should filter by confidence threshold.
|
|
149
|
+
*/
|
|
150
|
+
declare const abbreviatedCodes: CodeEntry[];
|
|
151
|
+
/**
|
|
152
|
+
* Registry of state statutory codes that use named-code citation forms.
|
|
153
|
+
*
|
|
154
|
+
* Named-code jurisdictions identify their code by name in citations (e.g.,
|
|
155
|
+
* "N.Y. Penal Law § 120.05", "Cal. Civ. Proc. Code § 437c"), rather than by
|
|
156
|
+
* a standalone abbreviation. The jurisdiction prefix is handled by the
|
|
157
|
+
* extraction layer; these patterns cover only the code name portion.
|
|
158
|
+
*
|
|
159
|
+
* Ordering note: within each jurisdiction, more specific patterns must come
|
|
160
|
+
* before more general ones (e.g., "Civ. Proc." before "Civ.") so that
|
|
161
|
+
* findNamedCode's longest-match wins correctly.
|
|
162
|
+
*
|
|
163
|
+
* Covers 7 jurisdictions: NY (21 entries), CA (29 entries), TX (29 entries),
|
|
164
|
+
* MD (36 entries), VA (1 entry), AL (1 entry), MA (1 entry).
|
|
165
|
+
*/
|
|
166
|
+
declare const namedCodes: CodeEntry[];
|
|
167
|
+
/**
|
|
168
|
+
* Find a CodeEntry by jurisdiction and code name token.
|
|
169
|
+
*
|
|
170
|
+
* Lookup strategy: for each candidate entry in the given jurisdiction,
|
|
171
|
+
* check whether the normalized codeName matches or starts with any of the
|
|
172
|
+
* entry's patterns (case-insensitive). Returns the entry with the longest
|
|
173
|
+
* matching pattern to prefer more specific codes over general ones
|
|
174
|
+
* (e.g., "Civ. Proc." over "Civ.").
|
|
175
|
+
*
|
|
176
|
+
* @param jurisdiction - Two-letter state abbreviation (e.g., "CA", "NY")
|
|
177
|
+
* @param codeName - The code name token to look up (e.g., "Penal", "Civ. Proc.")
|
|
178
|
+
* @returns Matching CodeEntry, or undefined if not found
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* findNamedCode('NY', 'Penal') // → NY PEN entry
|
|
182
|
+
* findNamedCode('CA', 'Civ. Proc.') // → CA CCP entry (not CA CIV)
|
|
183
|
+
* findNamedCode('MD', 'Crim. Law') // → MD gcr entry
|
|
184
|
+
* findNamedCode('NY', 'Unknown') // → undefined
|
|
185
|
+
*/
|
|
186
|
+
declare function findNamedCode(jurisdiction: string, codeName: string): CodeEntry | undefined;
|
|
187
|
+
/**
|
|
188
|
+
* Find a CodeEntry by an abbreviated text token.
|
|
189
|
+
*
|
|
190
|
+
* Lookup order:
|
|
191
|
+
* 1. Exact case-insensitive match against all patterns
|
|
192
|
+
* 2. Prefix match — returns the entry whose pattern is the longest
|
|
193
|
+
* prefix of `abbrevText` (handles tokens like "RCW" inside longer text)
|
|
194
|
+
*
|
|
195
|
+
* @param abbrevText - The abbreviation token to look up
|
|
196
|
+
* @returns Matching CodeEntry, or undefined if not found
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* findAbbreviatedCode('R.C.') // → OH entry
|
|
200
|
+
* findAbbreviatedCode('MCL') // → MI entry
|
|
201
|
+
* findAbbreviatedCode('UNKNOWN') // → undefined
|
|
202
|
+
*/
|
|
203
|
+
declare function findAbbreviatedCode(abbrevText: string): CodeEntry | undefined;
|
|
204
|
+
//#endregion
|
|
205
|
+
export { CodeEntry, ReporterEdition, ReporterEntry, ReportersDatabase, abbreviatedCodes, findAbbreviatedCode, findNamedCode, findReportersByAbbreviation, getReportersSync, loadReporters, namedCodes };
|
|
116
206
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/data/reporters.ts"],"mappings":";;AAsBA;;;;;AAgBA;;;;;;;;;;;;;;;UAhBiB,eAAA;;EAEf,KAAA;;EAEA,GAAA;AAAA;;;;;;;;;;UAYe,aAAA;;EAEf,IAAA;;EAEA,SAAA;EA2CF;EAzCE,QAAA,EAAU,MAAA,SAAe,eAAA;;EAEzB,UAAA,GAAa,MAAA;EAuCgC;EArC7C,gBAAA;EAwGc;EAtGd,SAAA;EAsGkC;EApGlC,KAAA;AAAA;;;;;;;UASe,iBAAA;EAkHN;EAhHT,cAAA,EAAgB,GAAA,SAAY,aAAA;;EAE5B,GAAA,EAAK,aAAA;AAAA
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/data/reporters.ts","../../src/data/knownCodes.ts"],"mappings":";;AAsBA;;;;;AAgBA;;;;;;;;;;;;;;;UAhBiB,eAAA;;EAEf,KAAA;;EAEA,GAAA;AAAA;;;;;;;;;;UAYe,aAAA;;EAEf,IAAA;;EAEA,SAAA;EA2CF;EAzCE,QAAA,EAAU,MAAA,SAAe,eAAA;;EAEzB,UAAA,GAAa,MAAA;EAuCgC;EArC7C,gBAAA;EAwGc;EAtGd,SAAA;EAsGkC;EApGlC,KAAA;AAAA;;;;;;;UASe,iBAAA;EAkHN;EAhHT,cAAA,EAAgB,GAAA,SAAY,aAAA;;EAE5B,GAAA,EAAK,aAAA;AAAA;;;;;;;;;;AC7BP;;;iBDiDsB,aAAA,CAAA,GAAiB,OAAA,CAAQ,iBAAA;;ACyE/C;;;;;AAyuBA;;;;;;;;;AA8DA;iBD7yBgB,gBAAA,CAAA,GAAoB,iBAAA;;;;;;;;;;;;;;;;;;iBAqBd,2BAAA,CACpB,IAAA,WACC,OAAA,CAAQ,aAAA;;;;AAzJX;;;;;AAgBA;;;;;;;UCxBiB,SAAA;;EAEf,YAAA;;EAEA,YAAA;;EAEA,QAAA;;EAEA,MAAA;AAAA;;;;ADuCF;;;;;;;;cCzBa,gBAAA,EAAkB,SAAA;;;;;;;ADiD/B;;;;;AAmEA;;;;cCMa,UAAA,EAAY,SAAA;ADezB;;;;;;;;;;;;AC/JA;;;;;;;AD+JA,iBC0tBgB,aAAA,CAAc,YAAA,UAAsB,QAAA,WAAmB,SAAA;;;AAn2BvE;;;;;AA0HA;;;;;AAyuBA;;;;iBA8DgB,mBAAA,CAAoB,UAAA,WAAqB,SAAA"}
|
package/dist/data/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let
|
|
1
|
+
import{i as e,n as t,r as n,t as r}from"../knownCodes-MkDSiR1j.mjs";let i=null;async function a(){if(i)return i;let e=await import(`../../data/reporters.json`,{assert:{type:`json`}}),t=new Map,n=[],r=e.default||e;for(let[e,i]of Object.entries(r))for(let e of i){n.push(e);for(let n of Object.keys(e.editions)){let r=n.toLowerCase();t.has(r)||t.set(r,[]),t.get(r)?.push(e)}for(let[n,r]of Object.entries(e.variations||{})){let r=n.toLowerCase();t.has(r)||t.set(r,[]),t.get(r)?.push(e)}}return i={byAbbreviation:t,all:n},i}function o(){return i}async function s(e){return(await a()).byAbbreviation.get(e.toLowerCase())??[]}export{r as abbreviatedCodes,t as findAbbreviatedCode,n as findNamedCode,s as findReportersByAbbreviation,o as getReportersSync,a as loadReporters,e as namedCodes};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/data/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/data/reporters.ts"],"sourcesContent":["/**\n * Reporter database integration for citation validation\n *\n * This module provides lazy-loadable access to the reporters-db database,\n * containing 1200+ court reporters with variant forms. The library works\n * in degraded mode (pattern-based extraction only) if reporters are not loaded.\n *\n * @example\n * // Degraded mode: extraction works without reporter data\n * const citations = await extract(text)\n *\n * @example\n * // Full mode: load reporters for validation\n * await loadReporters()\n * const citations = await extract(text) // Now with reporter validation\n */\n\n/**\n * Edition entry from reporters-db\n *\n * Represents a specific edition of a reporter with start/end dates.\n */\nexport interface ReporterEdition {\n /** Start date in ISO 8601 format */\n start: string | null\n /** End date in ISO 8601 format (null if ongoing) */\n end: string | null\n}\n\n/**\n * Reporter entry from reporters-db\n *\n * Represents a single court reporter with all metadata needed for\n * citation validation and enrichment.\n *\n * Note: The reporters-db structure has the actual data; this interface\n * represents it flexibly to handle all variations in the JSON.\n */\nexport interface ReporterEntry {\n /** Full reporter name (e.g., \"Federal Reporter\") */\n name: string\n /** Citation type: state, federal, specialty, neutral, state_regional, etc. */\n cite_type: string\n /** Editions keyed by abbreviation (e.g., {\"F.2d\": {...}, \"F.3d\": {...}}) */\n editions: Record<string, ReporterEdition>\n /** Variant forms mapped to canonical form (e.g., {\"F. 2d\": \"F.2d\"}) */\n variations?: Record<string, string | undefined>\n /** MLZ jurisdiction identifiers (optional) */\n mlz_jurisdiction?: string[]\n /** Publisher (optional) */\n publisher?: string\n /** Notes (optional) */\n notes?: string\n}\n\n/**\n * In-memory reporter database with fast O(1) lookup\n *\n * Uses Map-based indexing for case-insensitive abbreviation lookup.\n * All variant forms are indexed to support fuzzy matching.\n */\nexport interface ReportersDatabase {\n /** Fast O(1) lookup by abbreviation (lowercase normalized keys) */\n byAbbreviation: Map<string, ReporterEntry[]>\n /** All reporters (for iteration/filtering) */\n all: ReporterEntry[]\n}\n\n/**\n * Cached database instance (null until loadReporters() called)\n */\nlet cached: ReportersDatabase | null = null\n\n/**\n * Load reporter database asynchronously with lazy loading\n *\n * Dynamic import prevents loading 1200+ reporters until explicitly requested.\n * Result is cached after first load for subsequent calls.\n *\n * @returns Promise resolving to indexed reporter database\n *\n * @example\n * const db = await loadReporters()\n * const reporters = db.byAbbreviation.get('f.2d') // Fast O(1) lookup\n */\nexport async function loadReporters(): Promise<ReportersDatabase> {\n if (cached) return cached\n\n // Dynamic import prevents loading until requested (keeps core bundle small)\n const data = await import(\"../../data/reporters.json\", {\n assert: { type: \"json\" },\n })\n\n const byAbbreviation = new Map<string, ReporterEntry[]>()\n const all: ReporterEntry[] = []\n\n // reporters.json structure: { \"A.\": [...], \"F.2d\": [...], ... }\n const reportersData = (data.default || data) as Record<\n string,\n ReporterEntry[]\n >\n\n // Build fast lookup index with lowercase normalization\n for (const [_canonicalAbbr, reporters] of Object.entries(reportersData)) {\n for (const reporter of reporters) {\n all.push(reporter)\n\n // Index by all edition abbreviations\n for (const editionAbbr of Object.keys(reporter.editions)) {\n const key = editionAbbr.toLowerCase()\n if (!byAbbreviation.has(key)) {\n byAbbreviation.set(key, [])\n }\n byAbbreviation.get(key)?.push(reporter)\n }\n\n // Index all variations for fuzzy matching\n for (const [variant, _canonical] of Object.entries(\n reporter.variations || {},\n )) {\n const variantKey = variant.toLowerCase()\n if (!byAbbreviation.has(variantKey)) {\n byAbbreviation.set(variantKey, [])\n }\n byAbbreviation.get(variantKey)?.push(reporter)\n }\n }\n }\n\n cached = {\n byAbbreviation,\n all,\n }\n return cached\n}\n\n/**\n * Get cached reporter database synchronously (degraded mode support)\n *\n * Returns null if reporters not loaded yet. This enables the library to\n * work in degraded mode without reporter validation.\n *\n * @returns Cached database or null if not loaded\n *\n * @example\n * const db = getReportersSync()\n * if (db) {\n * // Full mode: validate citations\n * } else {\n * // Degraded mode: extract without validation\n * }\n */\nexport function getReportersSync(): ReportersDatabase | null {\n return cached\n}\n\n/**\n * Find reporters by abbreviation (case-insensitive)\n *\n * Loads reporter database if not already loaded. Returns all reporters\n * matching the abbreviation (including variant forms).\n *\n * @param abbr - Reporter abbreviation to look up\n * @returns Promise resolving to matching reporters (empty array if none)\n *\n * @example\n * const reporters = await findReportersByAbbreviation('F.2d')\n * // [{ abbreviation: 'F.2d', name: 'Federal Reporter, Second Series', ... }]\n *\n * @example\n * const unknown = await findReportersByAbbreviation('NONEXISTENT')\n * // [] (empty array, not error)\n */\nexport async function findReportersByAbbreviation(\n abbr: string,\n): Promise<ReporterEntry[]> {\n const db = await loadReporters()\n return db.byAbbreviation.get(abbr.toLowerCase()) ?? []\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/data/reporters.ts"],"sourcesContent":["/**\n * Reporter database integration for citation validation\n *\n * This module provides lazy-loadable access to the reporters-db database,\n * containing 1200+ court reporters with variant forms. The library works\n * in degraded mode (pattern-based extraction only) if reporters are not loaded.\n *\n * @example\n * // Degraded mode: extraction works without reporter data\n * const citations = await extract(text)\n *\n * @example\n * // Full mode: load reporters for validation\n * await loadReporters()\n * const citations = await extract(text) // Now with reporter validation\n */\n\n/**\n * Edition entry from reporters-db\n *\n * Represents a specific edition of a reporter with start/end dates.\n */\nexport interface ReporterEdition {\n /** Start date in ISO 8601 format */\n start: string | null\n /** End date in ISO 8601 format (null if ongoing) */\n end: string | null\n}\n\n/**\n * Reporter entry from reporters-db\n *\n * Represents a single court reporter with all metadata needed for\n * citation validation and enrichment.\n *\n * Note: The reporters-db structure has the actual data; this interface\n * represents it flexibly to handle all variations in the JSON.\n */\nexport interface ReporterEntry {\n /** Full reporter name (e.g., \"Federal Reporter\") */\n name: string\n /** Citation type: state, federal, specialty, neutral, state_regional, etc. */\n cite_type: string\n /** Editions keyed by abbreviation (e.g., {\"F.2d\": {...}, \"F.3d\": {...}}) */\n editions: Record<string, ReporterEdition>\n /** Variant forms mapped to canonical form (e.g., {\"F. 2d\": \"F.2d\"}) */\n variations?: Record<string, string | undefined>\n /** MLZ jurisdiction identifiers (optional) */\n mlz_jurisdiction?: string[]\n /** Publisher (optional) */\n publisher?: string\n /** Notes (optional) */\n notes?: string\n}\n\n/**\n * In-memory reporter database with fast O(1) lookup\n *\n * Uses Map-based indexing for case-insensitive abbreviation lookup.\n * All variant forms are indexed to support fuzzy matching.\n */\nexport interface ReportersDatabase {\n /** Fast O(1) lookup by abbreviation (lowercase normalized keys) */\n byAbbreviation: Map<string, ReporterEntry[]>\n /** All reporters (for iteration/filtering) */\n all: ReporterEntry[]\n}\n\n/**\n * Cached database instance (null until loadReporters() called)\n */\nlet cached: ReportersDatabase | null = null\n\n/**\n * Load reporter database asynchronously with lazy loading\n *\n * Dynamic import prevents loading 1200+ reporters until explicitly requested.\n * Result is cached after first load for subsequent calls.\n *\n * @returns Promise resolving to indexed reporter database\n *\n * @example\n * const db = await loadReporters()\n * const reporters = db.byAbbreviation.get('f.2d') // Fast O(1) lookup\n */\nexport async function loadReporters(): Promise<ReportersDatabase> {\n if (cached) return cached\n\n // Dynamic import prevents loading until requested (keeps core bundle small)\n const data = await import(\"../../data/reporters.json\", {\n assert: { type: \"json\" },\n })\n\n const byAbbreviation = new Map<string, ReporterEntry[]>()\n const all: ReporterEntry[] = []\n\n // reporters.json structure: { \"A.\": [...], \"F.2d\": [...], ... }\n const reportersData = (data.default || data) as Record<\n string,\n ReporterEntry[]\n >\n\n // Build fast lookup index with lowercase normalization\n for (const [_canonicalAbbr, reporters] of Object.entries(reportersData)) {\n for (const reporter of reporters) {\n all.push(reporter)\n\n // Index by all edition abbreviations\n for (const editionAbbr of Object.keys(reporter.editions)) {\n const key = editionAbbr.toLowerCase()\n if (!byAbbreviation.has(key)) {\n byAbbreviation.set(key, [])\n }\n byAbbreviation.get(key)?.push(reporter)\n }\n\n // Index all variations for fuzzy matching\n for (const [variant, _canonical] of Object.entries(\n reporter.variations || {},\n )) {\n const variantKey = variant.toLowerCase()\n if (!byAbbreviation.has(variantKey)) {\n byAbbreviation.set(variantKey, [])\n }\n byAbbreviation.get(variantKey)?.push(reporter)\n }\n }\n }\n\n cached = {\n byAbbreviation,\n all,\n }\n return cached\n}\n\n/**\n * Get cached reporter database synchronously (degraded mode support)\n *\n * Returns null if reporters not loaded yet. This enables the library to\n * work in degraded mode without reporter validation.\n *\n * @returns Cached database or null if not loaded\n *\n * @example\n * const db = getReportersSync()\n * if (db) {\n * // Full mode: validate citations\n * } else {\n * // Degraded mode: extract without validation\n * }\n */\nexport function getReportersSync(): ReportersDatabase | null {\n return cached\n}\n\n/**\n * Find reporters by abbreviation (case-insensitive)\n *\n * Loads reporter database if not already loaded. Returns all reporters\n * matching the abbreviation (including variant forms).\n *\n * @param abbr - Reporter abbreviation to look up\n * @returns Promise resolving to matching reporters (empty array if none)\n *\n * @example\n * const reporters = await findReportersByAbbreviation('F.2d')\n * // [{ abbreviation: 'F.2d', name: 'Federal Reporter, Second Series', ... }]\n *\n * @example\n * const unknown = await findReportersByAbbreviation('NONEXISTENT')\n * // [] (empty array, not error)\n */\nexport async function findReportersByAbbreviation(\n abbr: string,\n): Promise<ReporterEntry[]> {\n const db = await loadReporters()\n return db.byAbbreviation.get(abbr.toLowerCase()) ?? []\n}\n"],"mappings":"oEAuEA,IAAI,EAAmC,KAcvC,eAAsB,GAA4C,CAChE,GAAI,EAAQ,OAAO,EAGnB,IAAM,EAAO,MAAM,OAAO,4BAA6B,CACrD,OAAQ,CAAE,KAAM,OAAQ,CACzB,EAEK,EAAiB,IAAI,IACrB,EAAuB,EAAE,CAGzB,EAAiB,EAAK,SAAW,EAMvC,IAAK,GAAM,CAAC,EAAgB,KAAc,OAAO,QAAQ,EAAc,CACrE,IAAK,IAAM,KAAY,EAAW,CAChC,EAAI,KAAK,EAAS,CAGlB,IAAK,IAAM,KAAe,OAAO,KAAK,EAAS,SAAS,CAAE,CACxD,IAAM,EAAM,EAAY,aAAa,CAChC,EAAe,IAAI,EAAI,EAC1B,EAAe,IAAI,EAAK,EAAE,CAAC,CAE7B,EAAe,IAAI,EAAI,EAAE,KAAK,EAAS,CAIzC,IAAK,GAAM,CAAC,EAAS,KAAe,OAAO,QACzC,EAAS,YAAc,EAAE,CAC1B,CAAE,CACD,IAAM,EAAa,EAAQ,aAAa,CACnC,EAAe,IAAI,EAAW,EACjC,EAAe,IAAI,EAAY,EAAE,CAAC,CAEpC,EAAe,IAAI,EAAW,EAAE,KAAK,EAAS,EASpD,MAJA,GAAS,CACP,iBACA,MACD,CACM,EAmBT,SAAgB,GAA6C,CAC3D,OAAO,EAoBT,eAAsB,EACpB,EAC0B,CAE1B,OADW,MAAM,GAAe,EACtB,eAAe,IAAI,EAAK,aAAa,CAAC,EAAI,EAAE"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return e.type===`case`||e.type===`statute`||e.type===`journal`||e.type===`neutral`||e.type===`publicLaw`||e.type===`federalRegister`||e.type===`statutesAtLarge`}function t(e){return e.type===`id`||e.type===`supra`||e.type===`shortFormCase`}function n(e){return e.type===`case`}function r(e,t){return e.type===t}function i(e){throw Error(`Unexpected value: ${e}`)}function a(e){return e.replace(/<[^>]+>/g,``)}function o(e){return e.replace(/[\t\n\r]+/g,` `).replace(/ {2,}/g,` `)}function s(e){return e.normalize(`NFKC`)}function c(e){return e.replace(/[\u201C\u201D]/g,`"`).replace(/[\u2018\u2019]/g,`'`)}function l(e,t=[a,o,s,c]){let n=e,r=new Map,i=new Map;for(let t=0;t<=e.length;t++)r.set(t,t),i.set(t,t);for(let e of t){let t=n,a=e(n);if(t!==a){let{newCleanToOriginal:e,newOriginalToClean:o}=u(t,a,r,i);r=e,i=o,n=a}}return{cleaned:n,transformationMap:{cleanToOriginal:r,originalToClean:i},warnings:[]}}function u(e,t,n,r){let i=new Map,a=new Map,o=0,s=0;for(;o<=e.length||s<=t.length;){if(o>=e.length&&s>=t.length){let e=n.get(o)??o;i.set(s,e),a.set(e,s);break}if(o>=e.length){let e=n.get(o)??o;i.set(s,e),s++;continue}if(s>=t.length){let e=n.get(o)??o;a.set(e,s),o++;continue}if(e[o]===t[s]){let e=n.get(o)??o;i.set(s,e),a.set(e,s),o++,s++}else{let r=!1;for(let i=1;i<=20&&!(o+i>=e.length);i++)if(e[o+i]===t[s]){for(let e=0;e<i;e++){let t=n.get(o+e)??o+e;a.set(t,s)}o+=i,r=!0;break}if(r)continue;for(let a=1;a<=20&&!(s+a>=t.length);a++)if(e[o]===t[s+a]){let e=n.get(o)??o;for(let t=0;t<a;t++)i.set(s+t,e);s+=a,r=!0;break}if(r)continue;let c=n.get(o)??o;i.set(s,c),a.set(c,s),o++,s++}}return{newCleanToOriginal:i,newOriginalToClean:a}}const d=[{id:`federal-reporter`,regex:/\b(\d+(?:-\d+)?)\s+(F\.|F\.2d|F\.3d|F\.4th|F\.\s?Supp\.|F\.\s?Supp\.\s?2d|F\.\s?Supp\.\s?3d|F\.\s?Supp\.\s?4th)\s+(\d+|_{3,}|-{3,})(?=\s|$|\(|,|;|\.)/g,description:`Federal Reporter (F., F.2d, F.3d, F.4th, F.Supp., etc.)`,type:`case`},{id:`supreme-court`,regex:/\b(\d+(?:-\d+)?)\s+(U\.\s?S\.|S\.\s?Ct\.|L\.\s?Ed\.(?:\s?2d)?)\s+(\d+|_{3,}|-{3,})(?=\s|$|\(|,|;|\.)/g,description:`U.S. Supreme Court reporters`,type:`case`},{id:`state-reporter`,regex:/\b(\d+(?:-\d+)?)\s+([A-Z][A-Za-z.]+(?:\s?2d|\s?3d|\s?4th|\s?5th)?)\s+(\d+|_{3,}|-{3,})(?=\s|$|\(|,|;|\.)/g,description:`State reporters (broad pattern, validated against reporters-db in Phase 3)`,type:`case`}],f=[{id:`usc`,regex:/\b(\d+)\s+U\.S\.C\.?\s+§+\s*(\d+[A-Za-z]*)\b/g,description:`U.S. Code citations (e.g., "42 U.S.C. § 1983")`,type:`statute`},{id:`state-code`,regex:/\b([A-Z][a-z]+\.?\s+[A-Za-z.]+\s+Code)\s+§\s*(\d+[A-Za-z]*)\b/g,description:`State code citations (broad pattern, e.g., "Cal. Penal Code § 187")`,type:`statute`}],p=[{id:`law-review`,regex:/\b(\d+(?:-\d+)?)\s+([A-Z][A-Za-z.\s]+)\s+(\d+)\b/g,description:`Law review citations (e.g., "120 Harv. L. Rev. 500"), validated against journals-db in Phase 3`,type:`journal`}],m=[{id:`westlaw`,regex:/\b(\d{4})\s+WL\s+(\d+)\b/g,description:`WestLaw citations (e.g., "2021 WL 123456")`,type:`neutral`},{id:`lexis`,regex:/\b(\d{4})\s+U\.S\.\s+LEXIS\s+(\d+)\b/g,description:`LexisNexis citations (e.g., "2021 U.S. LEXIS 5000")`,type:`neutral`},{id:`public-law`,regex:/\bPub\.\s?L\.\s?No\.\s?(\d+-\d+)\b/g,description:`Public Law citations (e.g., "Pub. L. No. 117-58")`,type:`publicLaw`},{id:`federal-register`,regex:/\b(\d+(?:-\d+)?)\s+Fed\.\s?Reg\.\s+(\d+)\b/g,description:`Federal Register citations (e.g., "86 Fed. Reg. 12345")`,type:`federalRegister`},{id:`statutes-at-large`,regex:/\b(\d+(?:-\d+)?)\s+Stat\.\s+(\d+)\b/g,description:`Statutes at Large citations (e.g., "124 Stat. 119")`,type:`statutesAtLarge`},{id:`compact-law-review`,regex:/\b(\d+(?:-\d+)?)\s+([A-Z][A-Za-z.]+L\.(?:Rev|J|Q)\.)\s+(\d+)\b/g,description:`Compact law review citations without spaces (e.g., "93 Harv.L.Rev. 752")`,type:`journal`}],h=[{id:`id`,regex:/\b[Ii]d\.(?:\s+at\s+(\d+))?/g,description:`Id. citations (e.g., "Id." or "Id. at 253")`,type:`case`},{id:`ibid`,regex:/\b[Ii]bid\.(?:\s+at\s+(\d+))?/g,description:`Ibid. citations (e.g., "Ibid." or "Ibid. at 125")`,type:`case`},{id:`supra`,regex:/\b([A-Z][a-zA-Z]+(?:(?:\s+v\.?\s+|\s+)[A-Z][a-zA-Z]+)*)\s*,?\s+supra(?:,?\s+at\s+(\d+))?/g,description:`Supra citations (e.g., "Smith, supra" or "Smith, supra, at 460")`,type:`case`},{id:`shortFormCase`,regex:/\b(\d+(?:-\d+)?)\s+([A-Z][A-Za-z.\s]+?(?:\d[a-z])?)\s+at\s+(\d+)\b/g,description:`Short-form case citations (e.g., "500 F.2d at 125")`,type:`case`}];function g(e,t=[...d,...f,...p,...m,...h]){let n=[];for(let r of t)try{let t=e.matchAll(r.regex);for(let e of t)n.push({text:e[0],span:{cleanStart:e.index,cleanEnd:e.index+e[0].length},type:r.type,patternId:r.id})}catch(e){console.warn(`Pattern ${r.id} threw error, skipping:`,e instanceof Error?e.message:String(e))}return n.sort((e,t)=>e.span.cleanStart-t.span.cleanStart),n}const _={jan:1,january:1,feb:2,february:2,mar:3,march:3,apr:4,april:4,may:5,jun:6,june:6,jul:7,july:7,aug:8,august:8,sep:9,sept:9,september:9,oct:10,october:10,nov:11,november:11,dec:12,december:12};function v(e){let t=_[e.toLowerCase().replace(/\.$/,``)];if(t===void 0)throw Error(`Invalid month name: ${e}`);return t}function y(e){let{year:t,month:n,day:r}=e;return n!==void 0&&r!==void 0?`${t}-${String(n).padStart(2,`0`)}-${String(r).padStart(2,`0`)}`:n===void 0?String(t):`${t}-${String(n).padStart(2,`0`)}`}function b(e){let t=e.match(/\b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec)\.?\s+(\d{1,2}),?\s+(\d{4})\b/i);if(t){let e=v(t[1]),n=Number.parseInt(t[2],10),r={year:Number.parseInt(t[3],10),month:e,day:n};return{iso:y(r),parsed:r}}let n=e.match(/\b(January|February|March|April|May|June|July|August|September|October|November|December)\s+(\d{1,2}),?\s+(\d{4})\b/i);if(n){let e=v(n[1]),t=Number.parseInt(n[2],10),r={year:Number.parseInt(n[3],10),month:e,day:t};return{iso:y(r),parsed:r}}let r=e.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);if(r){let e=Number.parseInt(r[1],10),t=Number.parseInt(r[2],10),n={year:Number.parseInt(r[3],10),month:e,day:t};return{iso:y(n),parsed:n}}let i=e.match(/\b(\d{4})\b/);if(i){let e={year:Number.parseInt(i[1],10)};return{iso:y(e),parsed:e}}}function x(e){let t=Number.parseInt(e,10);return String(t)===e?t:e}const S=/(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec|January|February|March|April|May|June|July|August|September|October|November|December)\.?/,C=/^(\d+(?:-\d+)?)\s+([A-Za-z0-9.\s]+)\s+(\d+|_{3,}|-{3,})/,w=/^[_-]{3,}$/,T=/,\s*(\d+)/,ee=/\(([^)]+)\)/,te=/^(?:,\s*\d+)*\s*\(([^)]+)\)/,E=/^,\s*(\d+)/,D=/\([^)]+\)\s*\((en banc|per curiam)\)/i,O=/^(?:U\.?\s?S\.|S\.?\s?Ct\.|L\.?\s?Ed\.)/,k=/\d\.\s+/g,A=/([A-Z][A-Za-z0-9\s.,'&()/-]+?)\s+v(?:s)?\.?\s+([A-Za-z0-9\s.,'&()/-]+?)\s*,\s*$/,j=/\b(In re|Ex parte|Matter of|Estate of|State ex rel\.|United States ex rel\.|Application of|Petition of)\s+([A-Za-z0-9\s.,'&()/-]+?)\s*,\s*$/i;function M(e){let t=e.replace(/\s*\d{1,2}\/\d{1,2}\/\d{4}\s*$/,``).trim();return t=t.replace(/\s*\d{4}\s*$/,``).trim(),t=t.replace(/\s*,?\s*\d{1,2}\s*,?\s*$/,``).trim(),t=t.replace(RegExp(`\\s*${S.source}\\s*$`,`i`),``).trim(),t=t.replace(/,\s*$/,``).trim(),t&&/[A-Za-z]/.test(t)?t:void 0}function N(e,t,n=150){let r=Math.max(0,t-n),i=e.substring(r,t),a=r,o=-1,s;for(;(s=k.exec(i))!==null;)o=s.index+s[0].length;o!==-1&&(i=i.substring(o),a=r+o);let c=A.exec(i);if(c&&!c[0].includes(`;`))return{caseName:`${c[1].trim()} v. ${c[2].trim()}`,nameStart:a+c.index};let l=j.exec(i);if(l&&!l[0].includes(`;`))return{caseName:`${l[1]} ${l[2].trim()}`,nameStart:a+l.index}}function ne(e,t,n=200){let r=t,i=Math.min(e.length,t+n),a=0,o=!1;for(;r<i;){let t=e[r];if(t===`(`)a++,o=!0,r++;else if(t===`)`){if(a--,r++,a===0){let t=r;for(;t<i&&/\s/.test(e[t]);)t++;if(e[t]===`(`){r=t;continue}let n=e.substring(t,i);if(/^,\s*(aff'd|rev'd|cert\.\s*denied|overruled\s+by|vacated\s+by)/i.test(n)){r=t;continue}return r}}else r++}return o?r:t}function P(e){let t={},n=b(e);n&&(t.date=n,t.year=n.parsed.year);let r=M(e);return r&&(t.court=r),/\ben banc\b/i.test(e)?t.disposition=`en banc`:/\bper curiam\b/i.test(e)&&(t.disposition=`per curiam`),t}function F(e){let t=e;t=t.replace(/\bet\s+al\.?/gi,``),t=t.replace(/\s+d\/b\/a\b.*/gi,``),t=t.replace(/\s+aka\b.*/gi,``);let n=``;for(;n!==t;)n=t,t=t.replace(/,?\s*(Inc|LLC|Corp|Ltd|Co|LLP|LP|P\.C)\.?$/gi,``);return t=t.replace(/^(The|A|An)\s+/i,``),t=t.replace(/\s+/g,` `),t.trim().toLowerCase()}function I(e){for(let t of[`In re`,`Ex parte`,`Matter of`,`State ex rel.`,`United States ex rel.`,`Application of`,`Petition of`,`Estate of`]){let n=RegExp(`^(${t})\\s+(.+)$`,`i`).exec(e);if(n){let t=n[1],r=n[2];if(/\s+v\.?\s+/i.test(r)){let t=/^(.+?)\s+v\.?\s+(.+)$/i.exec(e);if(t){let e=t[1].trim(),n=t[2].trim();return{plaintiff:e,plaintiffNormalized:F(e),defendant:n,defendantNormalized:F(n)}}}else return{plaintiff:e,plaintiffNormalized:F(r),proceduralPrefix:t}}}let t=/^(.+?)\s+v\.?\s+(.+)$/i.exec(e);if(t){let e=t[1].trim(),n=t[2].trim();return e=e.replace(/^(?:In(?!\s+re\b)|See(?:\s+[Aa]lso)?|Compare|But(?:\s+[Ss]ee)?|Cf\.?|Also)\s+/i,``).trim(),{plaintiff:e||t[1].trim(),plaintiffNormalized:F(e||t[1].trim()),defendant:n,defendantNormalized:F(n)}}return{}}function L(e,t,n){let{text:r,span:i}=e,a=C.exec(r);if(!a)throw Error(`Failed to parse case citation: ${r}`);let o=x(a[1]),s=a[2].trim(),c=a[3],l=w.test(c),u=l?void 0:Number.parseInt(c,10),d=l?!0:void 0,f=T.exec(r),p=f?Number.parseInt(f[1],10):void 0,m,h,g,_,v,y,b,S=ee.exec(r);if(S){b=S[1];let e=P(b);m=e.year,h=e.court,g=e.date,_=e.disposition}if(n&&!b){let e=n.substring(i.cleanEnd),t=te.exec(e);if(t){b=t[1];let n=P(b);if(m=n.year,h=n.court,g=n.date,_=n.disposition,p===void 0){let t=E.exec(e);t&&(p=Number.parseInt(t[1],10))}}}if(n&&!_){let e=n.substring(i.cleanEnd),t=D.exec(e);t&&(_=t[1].toLowerCase())}if(!h&&O.test(s)&&(h=`scotus`),n){let e=N(n,i.cleanStart);if(e){v=e.caseName;let r=ne(n,i.cleanEnd),a=e.nameStart,o=r>i.cleanEnd?r:i.cleanEnd;y={cleanStart:a,cleanEnd:o,originalStart:t.cleanToOriginal.get(a)??a,originalEnd:t.cleanToOriginal.get(o)??o}}}let k,A,j,M,F;if(v){let e=I(v);k=e.plaintiff,A=e.plaintiffNormalized,j=e.defendant,M=e.defendantNormalized,F=e.proceduralPrefix}let L=t.cleanToOriginal.get(i.cleanStart)??i.cleanStart,R=t.cleanToOriginal.get(i.cleanEnd)??i.cleanEnd,z=.5;if(`F.,F.2d,F.3d,F.4th,U.S.,S. Ct.,L. Ed.,P.,P.2d,P.3d,A.,A.2d,A.3d,N.E.,N.E.2d,N.E.3d,N.W.,N.W.2d,S.E.,S.E.2d,S.W.,S.W.2d,S.W.3d,So.,So. 2d,So. 3d`.split(`,`).some(e=>s.includes(e))&&(z+=.3),m!==void 0){let e=new Date().getFullYear();m<=e&&(z+=.2)}return z=Math.min(z,1),d&&(z=.8),{type:`case`,text:r,span:{cleanStart:i.cleanStart,cleanEnd:i.cleanEnd,originalStart:L,originalEnd:R},confidence:z,matchedText:r,processTimeMs:0,patternsChecked:1,volume:o,reporter:s,page:u,pincite:p,court:h,year:m,hasBlankPage:d,date:g,fullSpan:y,caseName:v,disposition:_,plaintiff:k,plaintiffNormalized:A,defendant:j,defendantNormalized:M,proceduralPrefix:F}}function R(e,t){let{text:n,span:r}=e,i=/^(?:(\d+)\s+)?([A-Za-z.\s]+?)\s*§\s*(\d+[A-Za-z0-9-]*)/.exec(n);if(!i)throw Error(`Failed to parse statute citation: ${n}`);let a=i[1]?Number.parseInt(i[1],10):void 0,o=i[2].trim(),s=i[3],c=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,l=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd,u=.5;return[`U.S.C.`,`C.F.R.`,`Cal. Civ. Code`,`Cal. Penal Code`,`N.Y. Civ. Prac. L. & R.`,`Tex. Civ. Prac. & Rem. Code`].some(e=>o.includes(e))&&(u+=.3),u=Math.min(u,1),{type:`statute`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:c,originalEnd:l},confidence:u,matchedText:n,processTimeMs:0,patternsChecked:1,title:a,code:o,section:s}}function z(e,t){let{text:n,span:r}=e,i=/^(\d+(?:-\d+)?)\s+([A-Za-z.\s]+?)\s+(\d+)/.exec(n);if(!i)throw Error(`Failed to parse journal citation: ${n}`);let a=i[1],o=/^\d+$/.test(a)?Number.parseInt(a,10):a,s=i[2].trim(),c=Number.parseInt(i[3],10),l=/,\s*(\d+)/.exec(n),u=l?Number.parseInt(l[1],10):void 0,d=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,f=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`journal`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:d,originalEnd:f},confidence:.6,matchedText:n,processTimeMs:0,patternsChecked:1,volume:o,journal:s,abbreviation:s,page:c,pincite:u}}function B(e,t){let{text:n,span:r}=e,i=/^(\d{4})\s+(WL|LEXIS|U\.S\.\s+LEXIS)\s+(\d+)/.exec(n);if(!i)throw Error(`Failed to parse neutral citation: ${n}`);let a=Number.parseInt(i[1],10),o=i[2],s=i[3],c=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,l=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`neutral`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:c,originalEnd:l},confidence:1,matchedText:n,processTimeMs:0,patternsChecked:1,year:a,court:o,documentNumber:s}}function V(e,t){let{text:n,span:r}=e,i=/Pub\.\s?L\.(?:\s?No\.)?\s?(\d+)-(\d+)/.exec(n);if(!i)throw Error(`Failed to parse public law citation: ${n}`);let a=Number.parseInt(i[1],10),o=Number.parseInt(i[2],10),s=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,c=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`publicLaw`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:s,originalEnd:c},confidence:.9,matchedText:n,processTimeMs:0,patternsChecked:1,congress:a,lawNumber:o}}function H(e,t){let{text:n,span:r}=e,i=/^(\d+(?:-\d+)?)\s+Fed\.\s?Reg\.\s+(\d+)/.exec(n);if(!i)throw Error(`Failed to parse Federal Register citation: ${n}`);let a=i[1],o=/^\d+$/.test(a)?Number.parseInt(a,10):a,s=Number.parseInt(i[2],10),c=/\((?:.*?\s)?(\d{4})\)/.exec(n),l=c?Number.parseInt(c[1],10):void 0,u=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,d=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`federalRegister`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:u,originalEnd:d},confidence:.9,matchedText:n,processTimeMs:0,patternsChecked:1,volume:o,page:s,year:l}}function U(e,t){let{text:n,span:r}=e,i=/^(\d+(?:-\d+)?)\s+Stat\.\s+(\d+)/.exec(n);if(!i)throw Error(`Failed to parse Statutes at Large citation: ${n}`);let a=i[1],o=/^\d+$/.test(a)?Number.parseInt(a,10):a,s=Number.parseInt(i[2],10),c=/\((?:.*?\s)?(\d{4})\)/.exec(n),l=c?Number.parseInt(c[1],10):void 0,u=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,d=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`statutesAtLarge`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:u,originalEnd:d},confidence:.9,matchedText:n,processTimeMs:0,patternsChecked:1,volume:o,page:s,year:l}}function W(e,t){let{text:n,span:r}=e,i=/[Ii](?:d|bid)\.(?:\s+at\s+(\d+))?/.exec(n);if(!i)throw Error(`Failed to parse Id. citation: ${n}`);let a=i[1]?Number.parseInt(i[1],10):void 0,o=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,s=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`id`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:o,originalEnd:s},confidence:1,matchedText:n,processTimeMs:0,patternsChecked:1,pincite:a}}function G(e,t){let{text:n,span:r}=e,i=/\b([A-Z][a-zA-Z]+(?:(?:\s+v\.?\s+|\s+)[A-Z][a-zA-Z]+)*)\s*,?\s+supra(?:,?\s+at\s+(\d+))?/.exec(n);if(!i)throw Error(`Failed to parse supra citation: ${n}`);let a=i[1],o=i[2]?Number.parseInt(i[2],10):void 0,s=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,c=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`supra`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:s,originalEnd:c},confidence:.9,matchedText:n,processTimeMs:0,patternsChecked:1,partyName:a,pincite:o}}function K(e,t){let{text:n,span:r}=e,i=/(\d+(?:-\d+)?)\s+([A-Z][A-Za-z.\s]+?(?:\d[a-z])?)\s+at\s+(\d+)/.exec(n);if(!i)throw Error(`Failed to parse short-form case citation: ${n}`);let a=i[1],o=/^\d+$/.test(a)?Number.parseInt(a,10):a,s=i[2].trim(),c=Number.parseInt(i[3],10),l=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,u=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`shortFormCase`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:l,originalEnd:u},confidence:.7,matchedText:n,processTimeMs:0,patternsChecked:1,volume:o,reporter:s,pincite:c}}function q(e,t,n=/\n\n+/g){let r=new Map,i=[0],a;for(;(a=n.exec(e))!==null;)i.push(a.index+a[0].length);i.push(e.length);for(let e=0;e<t.length;e++){let n=t[e].span.originalStart,a=0;for(let e=0;e<i.length-1;e++)if(n>=i[e]&&n<i[e+1]){a=e;break}r.set(e,a)}return r}function J(e,t,n,r){if(r===`none`)return!0;let i=n.get(e),a=n.get(t);return i===void 0||a===void 0?!0:i===a}function Y(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let n=Array.from({length:e.length+1},()=>Array(t.length+1).fill(0));for(let t=0;t<=e.length;t++)n[t][0]=t;for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=e.length;r++)for(let i=1;i<=t.length;i++)e[r-1]===t[i-1]?n[r][i]=n[r-1][i-1]:n[r][i]=1+Math.min(n[r-1][i],n[r][i-1],n[r-1][i-1]);return n[e.length][t.length]}function X(e,t){let n=e.toLowerCase(),r=t.toLowerCase(),i=Y(n,r),a=Math.max(n.length,r.length);return a===0?1:1-i/a}var Z=class{constructor(e,t,n={}){this.citations=e,this.text=t,this.options={scopeStrategy:n.scopeStrategy??`paragraph`,autoDetectParagraphs:n.autoDetectParagraphs??!0,paragraphBoundaryPattern:n.paragraphBoundaryPattern??/\n\n+/g,fuzzyPartyMatching:n.fuzzyPartyMatching??!0,partyMatchThreshold:n.partyMatchThreshold??.8,allowNestedResolution:n.allowNestedResolution??!1,reportUnresolved:n.reportUnresolved??!0},this.context={citationIndex:0,allCitations:e,lastFullCitation:void 0,fullCitationHistory:new Map,paragraphMap:new Map},this.options.autoDetectParagraphs&&(this.context.paragraphMap=q(t,e,this.options.paragraphBoundaryPattern))}resolve(){let t=[];for(let n=0;n<this.citations.length;n++){this.context.citationIndex=n;let r=this.citations[n],i;switch(r.type){case`id`:i=this.resolveId(r);break;case`supra`:i=this.resolveSupra(r);break;case`shortFormCase`:i=this.resolveShortFormCase(r);break;default:e(r)&&(this.context.lastFullCitation=n,this.trackFullCitation(r,n));break}t.push({...r,resolution:i})}return t}resolveId(e){let t=this.context.citationIndex,n;for(let e=t-1;e>=0;e--)if(this.citations[e].type===`case`){n=e;break}return n===void 0?this.createFailureResult(`No preceding full case citation found`):this.isWithinScope(n,t)?{resolvedTo:n,confidence:1}:this.createFailureResult(`Antecedent citation outside scope boundary`)}resolveSupra(e){let t=this.context.citationIndex,n=this.normalizePartyName(e.partyName),r;for(let[e,i]of this.context.fullCitationHistory){if(!this.isWithinScope(i,t))continue;let a=X(n,e);(!r||a>r.similarity)&&(r={index:i,similarity:a})}if(!r)return this.createFailureResult(`No full citation found in scope`);if(r.similarity<this.options.partyMatchThreshold)return this.createFailureResult(`Party name similarity ${r.similarity.toFixed(2)} below threshold ${this.options.partyMatchThreshold}`);let i=[];return r.similarity<1&&i.push(`Fuzzy match: similarity ${r.similarity.toFixed(2)}`),{resolvedTo:r.index,confidence:r.similarity,warnings:i.length>0?i:void 0}}resolveShortFormCase(e){let t=this.context.citationIndex;for(let n=t-1;n>=0;n--){let r=this.citations[n];if(r.type===`case`&&r.volume===e.volume&&this.normalizeReporter(r.reporter)===this.normalizeReporter(e.reporter))return this.isWithinScope(n,t)?{resolvedTo:n,confidence:.95}:this.createFailureResult(`Matching citation outside scope boundary`)}return this.createFailureResult(`No matching full case citation found`)}trackFullCitation(e,t){if(e.type===`case`&&(e.defendantNormalized&&this.context.fullCitationHistory.set(e.defendantNormalized,t),e.plaintiffNormalized&&this.context.fullCitationHistory.set(e.plaintiffNormalized,t),!e.plaintiffNormalized&&!e.defendantNormalized)){let n=this.extractPartyName(e);if(n){let e=this.normalizePartyName(n);this.context.fullCitationHistory.set(e,t)}}}extractPartyName(e){let t=e.span.originalStart,n=Math.max(0,t-100),r=this.text.substring(n,t),i=r.match(/([A-Z][a-zA-Z]*(?:\s+[A-Z][a-zA-Z]*)*)\s+v\.?\s+[A-Z][a-zA-Z]*(?:\s+[A-Z][a-zA-Z]*)*,\s*$/);if(i)return this.stripSignalWords(i[1].trim());let a=r.match(/([A-Z][a-zA-Z]*(?:\s+[A-Z][a-zA-Z]*)*),\s*$/);if(a)return this.stripSignalWords(a[1].trim())}stripSignalWords(e){let t=e.replace(/^(?:In(?!\s+re\b)|See(?:\s+[Aa]lso)?|Compare|But(?:\s+[Ss]ee)?|Cf\.?|Also)\s+/i,``).trim();return t.length>0?t:e}normalizePartyName(e){return e.toLowerCase().replace(/\s+/g,` `).trim()}normalizeReporter(e){return e.toLowerCase().replace(/\s+/g,``).replace(/\./g,``)}isWithinScope(e,t){return J(e,t,this.context.paragraphMap,this.options.scopeStrategy)}createFailureResult(e){if(this.options.reportUnresolved)return{resolvedTo:void 0,failureReason:e,confidence:0}}};function Q(e,t,n){return new Z(e,t,n).resolve()}function re(e,t=``){let n=new Map;if(e.length===0||t===``)return n;let r=new Set;for(let i=0;i<e.length;i++){let a=e[i];if(a.type!==`case`||r.has(i))continue;let o=[];for(let n=i+1;n<e.length;n++){let s=e[n];if(s.type!==`case`)break;let c=(n===i+1?a:e[n-1]).span.cleanEnd,l=s.span.cleanStart;if(l-c>20)break;let u=t.substring(c,l);if(!u.includes(`,`))break;let d=u.indexOf(`,`);if(u.length-d-1>5||t.substring(a.span.cleanEnd,s.span.cleanEnd).includes(`)`)||!ie(t,s.span.cleanEnd))break;o.push(n),r.add(n)}o.length>0&&n.set(i,o)}return n}function ie(e,t){let n=e.substring(t,t+200),r=n.indexOf(`(`);if(r===-1)return!1;let i=0;for(let e=r;e<n.length;e++)if(n[e]===`(`)i++;else if(n[e]===`)`&&(i--,i===0))return!0;return!1}function $(e,t){let n=performance.now(),{cleaned:r,transformationMap:i,warnings:a}=l(e,t?.cleaners),o=g(r,t?.patterns||[...m,...h,...d,...f,...p]),s=[],c=new Set,u=r.length<65536;for(let e of o){let t=u?e.span.cleanStart<<16|e.span.cleanEnd:`${e.span.cleanStart}-${e.span.cleanEnd}`;c.has(t)||(c.add(t),s.push(e))}let _=re(s,r),v=[];for(let e=0;e<s.length;e++){let t=s[e],o;switch(t.type){case`case`:o=t.patternId===`id`||t.patternId===`ibid`?W(t,i):t.patternId===`supra`?G(t,i):t.patternId===`shortFormCase`?K(t,i):L(t,i,r);break;case`statute`:o=R(t,i);break;case`journal`:o=z(t,i);break;case`neutral`:o=B(t,i);break;case`publicLaw`:o=V(t,i);break;case`federalRegister`:o=H(t,i);break;case`statutesAtLarge`:o=U(t,i);break;default:continue}if(a.length>0&&(o.warnings=[...o.warnings||[],...a]),o.processTimeMs=performance.now()-n,o.type===`case`){let t=_.has(e),n=Array.from(_.values()).some(t=>t.includes(e));if(t||n){let r=e;if(n){for(let[t,n]of _.entries())if(n.includes(e)){r=t;break}}let i=s[r],a=/^(\S+)\s+(.+)\s+(\d+)$/.exec(i.text);if(a){let[,n,r,i]=a;if(o.groupId=`${n}-${r.replace(/\s+/g,`.`)}-${i}`,t){let t=_.get(e);o.parallelCitations=t.map(e=>{let t=s[e],n=/^(\S+)\s+(.+)\s+(\d+)$/.exec(t.text);if(n){let[,e,t,r]=n;return{volume:/^\d+$/.test(e)?Number.parseInt(e,10):e,reporter:t,page:Number.parseInt(r,10)}}return{volume:0,reporter:``,page:0}})}}}}v.push(o)}return t?.resolve?Q(v,e,t.resolutionOptions):v}async function ae(e,t){return $(e,t)}exports.DocumentResolver=Z,exports.assertUnreachable=i,exports.cleanText=l,exports.extractCase=L,exports.extractCitations=$,exports.extractCitationsAsync=ae,exports.extractFederalRegister=H,exports.extractJournal=z,exports.extractNeutral=B,exports.extractPublicLaw=V,exports.extractStatute=R,exports.extractStatutesAtLarge=U,exports.isCaseCitation=n,exports.isCitationType=r,exports.isFullCitation=e,exports.isShortFormCitation=t,exports.resolveCitations=Q,exports.tokenize=g;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./knownCodes-CI-vnoBO.cjs`);function t(e){return e.type===`case`||e.type===`statute`||e.type===`journal`||e.type===`neutral`||e.type===`publicLaw`||e.type===`federalRegister`||e.type===`statutesAtLarge`}function n(e){return e.type===`id`||e.type===`supra`||e.type===`shortFormCase`}function r(e){return e.type===`case`}function i(e,t){return e.type===t}function a(e){throw Error(`Unexpected value: ${e}`)}function o(e){return e.replace(/<[^>]+>/g,``)}function s(e){return e.replace(/[\t\n\r]+/g,` `).replace(/ {2,}/g,` `)}function c(e){return e.normalize(`NFKC`)}function l(e){return e.replace(/[\u201C\u201D]/g,`"`).replace(/[\u2018\u2019]/g,`'`)}function u(e){return e.replace(/[\u2013\u2014]/g,`-`)}function d(e){return e.replace(/§/gi,`§`).replace(/¶/gi,`¶`).replace(/&/gi,`&`).replace(/ /gi,` `).replace(/</gi,`<`).replace(/>/gi,`>`).replace(/"/gi,`"`).replace(/'/gi,`'`).replace(/&#(\d+);/g,(e,t)=>{let n=Number.parseInt(t,10);return Number.isNaN(n)?e:String.fromCharCode(n)}).replace(/&#x([0-9a-fA-F]+);/g,(e,t)=>{let n=Number.parseInt(t,16);return Number.isNaN(n)?e:String.fromCharCode(n)})}function f(e,t=[o,d,s,c,u,l]){let n=e,r=new Map,i=new Map;for(let t=0;t<=e.length;t++)r.set(t,t),i.set(t,t);for(let e of t){let t=n,a=e(n);if(t!==a){let{newCleanToOriginal:e,newOriginalToClean:o}=p(t,a,r,i);r=e,i=o,n=a}}return{cleaned:n,transformationMap:{cleanToOriginal:r,originalToClean:i},warnings:[]}}function p(e,t,n,r){let i=new Map,a=new Map,o=0,s=0;for(;o<=e.length||s<=t.length;){if(o>=e.length&&s>=t.length){let e=n.get(o)??o;i.set(s,e),a.set(e,s);break}if(o>=e.length){let e=n.get(o)??o;i.set(s,e),s++;continue}if(s>=t.length){let e=n.get(o)??o;a.set(e,s),o++;continue}if(e[o]===t[s]){let e=n.get(o)??o;i.set(s,e),a.set(e,s),o++,s++}else{let r=!1;for(let i=1;i<=20&&!(o+i>=e.length);i++)if(e[o+i]===t[s]){for(let e=0;e<i;e++){let t=n.get(o+e)??o+e;a.set(t,s)}o+=i,r=!0;break}if(r)continue;for(let a=1;a<=20&&!(s+a>=t.length);a++)if(e[o]===t[s+a]){let e=n.get(o)??o;for(let t=0;t<a;t++)i.set(s+t,e);s+=a,r=!0;break}if(r)continue;let c=n.get(o)??o;i.set(s,c),a.set(c,s),o++,s++}}return{newCleanToOriginal:i,newOriginalToClean:a}}const m=[{id:`federal-reporter`,regex:/\b(\d+(?:-\d+)?)\s+(F\.|F\.2d|F\.3d|F\.4th|F\.\s?Supp\.|F\.\s?Supp\.\s?2d|F\.\s?Supp\.\s?3d|F\.\s?Supp\.\s?4th|F\.\s?App'x)\s+(\d+|_{3,}|-{3,})(?=\s|$|\(|,|;|\.)/g,description:`Federal Reporter (F., F.2d, F.3d, F.4th, F.Supp., F.App'x, etc.)`,type:`case`},{id:`supreme-court`,regex:/\b(\d+(?:-\d+)?)\s+(U\.\s?S\.|S\.\s?Ct\.|L\.\s?Ed\.(?:\s?2d)?)\s+(\d+|_{3,}|-{3,})(?=\s|$|\(|,|;|\.)/g,description:`U.S. Supreme Court reporters`,type:`case`},{id:`state-reporter`,regex:/\b(\d+(?:-\d+)?)\s+([A-Z](?:(?! L\.[JQR\s])[A-Za-z.\d\s])+?)\s+(\d+|_{3,}|-{3,})(?=\s|$|\(|,|;|\.)/g,description:`State reporters (broad pattern allowing multi-word reporters, excludes journal patterns with " L.J/Q/Rev", validated against reporters-db in Phase 3)`,type:`case`}],h=[{id:`usc`,regex:/\b(\d+)\s+(?:U\.S\.C\.?|USC)\s*§§?\s*(\d+[A-Za-z0-9-]*(?:\([^)]*\))*(?:\s*et\s+seq\.?)?)/g,description:`U.S. Code citations with optional subsections and et seq. (e.g., "42 U.S.C. § 1983(a)(1) et seq.")`,type:`statute`},{id:`cfr`,regex:/\b(\d+)\s+C\.?F\.?R\.?\s*(?:(?:Part|pt\.)\s+|§§?\s*)(\d+(?:\.\d+)?[A-Za-z0-9-]*(?:\([^)]*\))*(?:\s*et\s+seq\.?)?)/g,description:`Code of Federal Regulations with Part or §, subsections, et seq. (e.g., "12 C.F.R. Part 226", "40 C.F.R. § 122.26(b)(14)")`,type:`statute`},{id:`prose`,regex:/\b[Ss]ection\s+(\d+[A-Za-z0-9-]*(?:\([^)]*\))*)\s+of\s+title\s+(\d+)\b/g,description:`Prose-form federal citations (e.g., "section 1983 of title 42"). Note: MD-style "section X of the Y Article" deferred to PR 3.`,type:`statute`},{id:`named-code`,regex:/\b(N\.?\s*Y\.?|Cal(?:ifornia)?\.?|Tex(?:as)?\.?|Md\.?|Va\.?|Ala(?:bama)?\.?)\s+((?:[A-Za-z.&',\s]+?))\s*§§?\s*(\d+[A-Za-z0-9.:/-]*(?:\([^)]*\))*(?:\s*et\s+seq\.?)?)/g,description:`Named-code state citations (NY, CA, TX, MD, VA, AL) with jurisdiction prefix + code name + §`,type:`statute`},{id:`mass-chapter`,regex:/\b(Mass\.?\s*Gen\.?\s*Laws|M\.?G\.?L\.?A?\.?|A\.?L\.?M\.?|G\.?\s*L\.?)\s+(?:ch\.?|c\.?)\s*(\w+),?\s*§\s*([\w./-]+(?:\([^)]*\))*(?:\s*et\s+seq\.?)?)/g,description:`Massachusetts chapter-based citations (e.g., "Mass. Gen. Laws ch. 93A, § 2")`,type:`statute`},{id:`chapter-act`,regex:/\b(\d+)\s+(?:ILCS|Ill\.?\s*Comp\.?\s*Stat\.?)\s*(?:Ann\.?\s+)?(\d+)\/([^\s(]+(?:\([^)]*\))*(?:\s*et\s+seq\.?)?)/g,description:`Illinois Compiled Statutes chapter-act citations (e.g., "735 ILCS 5/2-1001")`,type:`statute`},{id:`abbreviated-code`,regex:/\b(?:(\d+)\s+)?(Fla\.?\s*Stat(?:utes)?\.?(?:\s*Ann\.?)?|F\.?S\.?|R\.?C\.?|O\.?R\.?C\.?|Ohio\s+Rev\.?\s+Code(?:\s+Ann\.?)?|MCL[AS]?|M\.?C\.?L\.?|Mich\.?\s+Comp\.?\s+Laws(?:\s+(?:Ann|Serv)\.?)?|Utah\s+Code(?:\s+Ann\.?)?|U\.?C\.?A\.?|C\.?R\.?S\.?|Colo\.?\s+Rev\.?\s+Stat\.?(?:\s+Ann\.?)?|RCW|Wash\.?\s+Rev\.?\s+Code(?:\s+Ann\.?)?|G\.?S\.?|N\.?C\.?\s*Gen\.?\s*Stat\.?(?:\s+Ann\.?)?|N\.?C\.?G\.?S\.?|O\.?C\.?G\.?A\.?|Ga\.?\s+Code(?:\s+Ann\.?)?|Pa\.?\s*C\.?S\.?A?\.?|Pa\.?\s+Cons\.?\s+Stat\.?|P\.?S\.?|Ind(?:iana)?\.?\s+Code(?:\s+Ann\.?)?|Burns\s+Ind\.?\s+Code(?:\s+Ann\.?)?|I\.?C\.?|N\.?J\.?\s*S(?:tat)?\.?\s*A?\.?|Del\.?\s*(?:Code(?:\s+Ann\.?)?|C\.?))\s*§?\s*(\d+[A-Za-z0-9.:/-]*(?:\([^)]*\))*(?:\s*et\s+seq\.?)?)/g,description:`Abbreviated state code citations for 12 jurisdictions (FL, OH, MI, UT, CO, WA, NC, GA, PA, IN, NJ, DE)`,type:`statute`}],g=[{id:`law-review`,regex:/\b(\d+(?:-\d+)?)\s+([A-Z][A-Za-z.\s]+)\s+(\d+)\b/g,description:`Law review citations (e.g., "120 Harv. L. Rev. 500"), validated against journals-db in Phase 3`,type:`journal`}],_=[{id:`state-vendor-neutral`,regex:/\b(\d{4})\s+([A-Z]{2}(?:\s+App\.?)?)\s+(\d+)\b/g,description:`State vendor-neutral citations (e.g., "2007 UT 49", "2017 WI 17", "2013 IL 112116")`,type:`neutral`},{id:`westlaw`,regex:/\b(\d{4})\s+WL\s+(\d+)\b/g,description:`WestLaw citations (e.g., "2021 WL 123456")`,type:`neutral`},{id:`lexis`,regex:/\b(\d{4})\s+U\.S\.(?:\s+(?:App|Dist)\.)?\s+LEXIS\s+(\d+)\b/g,description:`LexisNexis citations (e.g., "2021 U.S. LEXIS 5000", "2021 U.S. App. LEXIS 12345", "2021 U.S. Dist. LEXIS 67890")`,type:`neutral`},{id:`public-law`,regex:/\bPub\.\s?L\.(?:\s?No\.)?\s?(\d+-\d+)\b/g,description:`Public Law citations (e.g., "Pub. L. No. 117-58" or "Pub. L. 116-283")`,type:`publicLaw`},{id:`federal-register`,regex:/\b(\d+(?:-\d+)?)\s+Fed\.\s?Reg\.\s+(\d+)\b/g,description:`Federal Register citations (e.g., "86 Fed. Reg. 12345")`,type:`federalRegister`},{id:`statutes-at-large`,regex:/\b(\d+(?:-\d+)?)\s+Stat\.\s+(\d+)\b/g,description:`Statutes at Large citations (e.g., "124 Stat. 119")`,type:`statutesAtLarge`},{id:`compact-law-review`,regex:/\b(\d+(?:-\d+)?)\s+([A-Z][A-Za-z.]+L\.(?:Rev|J|Q)\.)\s+(\d+)\b/g,description:`Compact law review citations without spaces (e.g., "93 Harv.L.Rev. 752")`,type:`journal`}],v=[{id:`id`,regex:/\b[Ii]d\.(?:\s+at\s+(\d+))?/g,description:`Id. citations (e.g., "Id." or "Id. at 253")`,type:`case`},{id:`ibid`,regex:/\b[Ii]bid\.(?:\s+at\s+(\d+))?/g,description:`Ibid. citations (e.g., "Ibid." or "Ibid. at 125")`,type:`case`},{id:`supra`,regex:/\b([A-Z][a-zA-Z]+(?:(?:\s+v\.?\s+|\s+)[A-Z][a-zA-Z]+)*)\s*,?\s+supra(?:,?\s+at\s+(\d+))?/g,description:`Supra citations (e.g., "Smith, supra" or "Smith, supra, at 460")`,type:`case`},{id:`shortFormCase`,regex:/\b(\d+(?:-\d+)?)\s+([A-Z][A-Za-z.\s]+?(?:\d[a-z])?)\s+at\s+(\d+)\b/g,description:`Short-form case citations (e.g., "500 F.2d at 125")`,type:`case`}];function y(e,t=[...m,...h,...g,..._,...v]){let n=[];for(let r of t)try{let t=e.matchAll(r.regex);for(let e of t)n.push({text:e[0],span:{cleanStart:e.index,cleanEnd:e.index+e[0].length},type:r.type,patternId:r.id})}catch(e){console.warn(`Pattern ${r.id} threw error, skipping:`,e instanceof Error?e.message:String(e))}return n.sort((e,t)=>e.span.cleanStart-t.span.cleanStart),n}const b={jan:1,january:1,feb:2,february:2,mar:3,march:3,apr:4,april:4,may:5,jun:6,june:6,jul:7,july:7,aug:8,august:8,sep:9,sept:9,september:9,oct:10,october:10,nov:11,november:11,dec:12,december:12};function x(e){let t=b[e.toLowerCase().replace(/\.$/,``)];if(t===void 0)throw Error(`Invalid month name: ${e}`);return t}function S(e){let{year:t,month:n,day:r}=e;return n!==void 0&&r!==void 0?`${t}-${String(n).padStart(2,`0`)}-${String(r).padStart(2,`0`)}`:n===void 0?String(t):`${t}-${String(n).padStart(2,`0`)}`}function C(e){let t=e.match(/\b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec)\.?\s+(\d{1,2}),?\s+(\d{4})\b/i);if(t){let e=x(t[1]),n=Number.parseInt(t[2],10),r={year:Number.parseInt(t[3],10),month:e,day:n};return{iso:S(r),parsed:r}}let n=e.match(/\b(January|February|March|April|May|June|July|August|September|October|November|December)\s+(\d{1,2}),?\s+(\d{4})\b/i);if(n){let e=x(n[1]),t=Number.parseInt(n[2],10),r={year:Number.parseInt(n[3],10),month:e,day:t};return{iso:S(r),parsed:r}}let r=e.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);if(r){let e=Number.parseInt(r[1],10),t=Number.parseInt(r[2],10),n={year:Number.parseInt(r[3],10),month:e,day:t};return{iso:S(n),parsed:n}}let i=e.match(/\b(\d{4})\b/);if(i){let e={year:Number.parseInt(i[1],10)};return{iso:S(e),parsed:e}}}function ee(e){let t=Number.parseInt(e,10);return String(t)===e?t:e}const w=/(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec|January|February|March|April|May|June|July|August|September|October|November|December)\.?/,te=/^(\d+(?:-\d+)?)\s+([A-Za-z0-9.\s']+)\s+(\d+|_{3,}|-{3,})/,ne=/^[_-]{3,}$/,re=/,\s*(\d+)/,ie=/\(([^)]+)\)/,ae=/^(?:,\s*\d+(?:-\d+)?)*(?:\s+(?:n|note)\s*\.?\s*\d+)?\s*\(([^)]+)\)/,oe=/^,\s*(\d+(?:-\d+)?)/,T=/\([^)]+\)\s*\((en banc|per curiam)\)/i,se=/^(?:U\.?\s?S\.|S\.?\s?Ct\.|L\.?\s?Ed\.)/,E=/\d\.\s+/g,D=/([A-Z][A-Za-z0-9\s.,'&()/-]+?)\s+v(?:s)?\.?\s+([A-Za-z0-9\s.,'&()/-]+?)\s*,\s*$/,O=/\b(In re|Ex parte|Matter of|Estate of|State ex rel\.|United States ex rel\.|Application of|Petition of)\s+([A-Za-z0-9\s.,'&()/-]+?)\s*,\s*$/i;function k(e){let t=e.replace(/\s*\d{1,2}\/\d{1,2}\/\d{4}\s*$/,``).trim();return t=t.replace(/\s*\d{4}\s*$/,``).trim(),t=t.replace(/\s*,?\s*\d{1,2}\s*,?\s*$/,``).trim(),t=t.replace(RegExp(`\\s*${w.source}\\s*$`,`i`),``).trim(),t=t.replace(/,\s*$/,``).trim(),t&&/[A-Za-z]/.test(t)?t:void 0}function ce(e,t,n=150){let r=Math.max(0,t-n),i=e.substring(r,t),a=r,o=-1,s;for(;(s=E.exec(i))!==null;)o=s.index+s[0].length;o!==-1&&(i=i.substring(o),a=r+o);let c=D.exec(i);if(c&&!c[0].includes(`;`))return{caseName:`${c[1].trim()} v. ${c[2].trim()}`,nameStart:a+c.index};let l=O.exec(i);if(l&&!l[0].includes(`;`))return{caseName:`${l[1]} ${l[2].trim()}`,nameStart:a+l.index}}function le(e,t,n=200){let r=t,i=Math.min(e.length,t+n),a=0,o=!1;for(;r<i;){let t=e[r];if(t===`(`)a++,o=!0,r++;else if(t===`)`){if(a--,r++,a===0){let t=r;for(;t<i&&/\s/.test(e[t]);)t++;if(e[t]===`(`){r=t;continue}let n=e.substring(t,i);if(/^,\s*(aff'd|rev'd|cert\.\s*denied|overruled\s+by|vacated\s+by)/i.test(n)){r=t;continue}return r}}else r++}return o?r:t}function A(e){let t={},n=C(e);n&&(t.date=n,t.year=n.parsed.year);let r=k(e);return r&&(t.court=r),/\ben banc\b/i.test(e)?t.disposition=`en banc`:/\bper curiam\b/i.test(e)&&(t.disposition=`per curiam`),t}function j(e){let t=e;t=t.replace(/\bet\s+al\.?/gi,``),t=t.replace(/\s+d\/b\/a\b.*/gi,``),t=t.replace(/\s+aka\b.*/gi,``);let n=``;for(;n!==t;)n=t,t=t.replace(/,?\s*(Inc|LLC|Corp|Ltd|Co|LLP|LP|P\.C)\.?$/gi,``);return t=t.replace(/^(The|A|An)\s+/i,``),t=t.replace(/\s+/g,` `),t.trim().toLowerCase()}function ue(e){for(let t of[`In re`,`Ex parte`,`Matter of`,`State ex rel.`,`United States ex rel.`,`Application of`,`Petition of`,`Estate of`]){let n=RegExp(`^(${t})\\s+(.+)$`,`i`).exec(e);if(n){let t=n[1],r=n[2];if(/\s+v\.?\s+/i.test(r)){let t=/^(.+?)\s+v\.?\s+(.+)$/i.exec(e);if(t){let e=t[1].trim(),n=t[2].trim();return{plaintiff:e,plaintiffNormalized:j(e),defendant:n,defendantNormalized:j(n)}}}else return{plaintiff:e,plaintiffNormalized:j(r),proceduralPrefix:t}}}let t=/^(.+?)\s+v\.?\s+(.+)$/i.exec(e);if(t){let e=t[1].trim(),n=t[2].trim();return e=e.replace(/^(?:In(?!\s+re\b)|See(?:\s+[Aa]lso)?|Compare|But(?:\s+[Ss]ee)?|Cf\.?|Also)\s+/i,``).trim(),{plaintiff:e||t[1].trim(),plaintiffNormalized:j(e||t[1].trim()),defendant:n,defendantNormalized:j(n)}}return{}}function M(e,t,n){let{text:r,span:i}=e,a=te.exec(r);if(!a)throw Error(`Failed to parse case citation: ${r}`);let o=ee(a[1]),s=a[2].trim(),c=a[3],l=ne.test(c),u=l?void 0:Number.parseInt(c,10),d=l?!0:void 0,f=re.exec(r),p=f?Number.parseInt(f[1],10):void 0,m,h,g,_,v,y,b,x=ie.exec(r);if(x){b=x[1];let e=A(b);m=e.year,h=e.court,g=e.date,_=e.disposition}if(n&&!b){let e=n.substring(i.cleanEnd),t=ae.exec(e);if(t){b=t[1];let n=A(b);if(m=n.year,h=n.court,g=n.date,_=n.disposition,p===void 0){let t=oe.exec(e);t&&(p=Number.parseInt(t[1],10))}}}if(n&&!_){let e=n.substring(i.cleanEnd),t=T.exec(e);t&&(_=t[1].toLowerCase())}if(!h&&se.test(s)&&(h=`scotus`),n){let e=ce(n,i.cleanStart);if(e){v=e.caseName;let r=le(n,i.cleanEnd),a=e.nameStart,o=r>i.cleanEnd?r:i.cleanEnd;y={cleanStart:a,cleanEnd:o,originalStart:t.cleanToOriginal.get(a)??a,originalEnd:t.cleanToOriginal.get(o)??o}}}let S,C,w,E,D;if(v){let e=ue(v);S=e.plaintiff,C=e.plaintiffNormalized,w=e.defendant,E=e.defendantNormalized,D=e.proceduralPrefix}let O=t.cleanToOriginal.get(i.cleanStart)??i.cleanStart,k=t.cleanToOriginal.get(i.cleanEnd)??i.cleanEnd,j=.5;if(`F.,F.2d,F.3d,F.4th,U.S.,S. Ct.,L. Ed.,P.,P.2d,P.3d,A.,A.2d,A.3d,N.E.,N.E.2d,N.E.3d,N.W.,N.W.2d,S.E.,S.E.2d,S.W.,S.W.2d,S.W.3d,So.,So. 2d,So. 3d`.split(`,`).some(e=>s.includes(e))&&(j+=.3),m!==void 0){let e=new Date().getFullYear();m<=e&&(j+=.2)}return j=Math.min(j,1),d&&(j=.8),{type:`case`,text:r,span:{cleanStart:i.cleanStart,cleanEnd:i.cleanEnd,originalStart:O,originalEnd:k},confidence:j,matchedText:r,processTimeMs:0,patternsChecked:1,volume:o,reporter:s,page:u,pincite:p,court:h,year:m,hasBlankPage:d,date:g,fullSpan:y,caseName:v,disposition:_,plaintiff:S,plaintiffNormalized:C,defendant:w,defendantNormalized:E,proceduralPrefix:D}}const N=/^([^(]+?)\s*((?:\([^)]*\))*)$/,P=/\s*et\s+seq\.?\s*$/i;function F(e){let t=e.replace(P,``),n=t!==e,r=t.trim(),i=N.exec(r),a=i?.[2];return i!==null&&a?{section:i[1].trim(),subsection:a,hasEtSeq:n}:{section:r,hasEtSeq:n}}const I=/^(?:(\d+)\s+)?(.+?)\s*§?\s*(\d+[A-Za-z0-9.:/-]*(?:\([^)]*\))*(?:\s*et\s+seq\.?)?)$/;function L(t,n){let{text:r,span:i}=t,a=I.exec(r),o,s,c;a?(o=a[1]?Number.parseInt(a[1],10):void 0,s=a[2].trim(),c=a[3]):(s=r,c=``);let l=e.n(s),u=l?.jurisdiction,d=s,{section:f,subsection:p,hasEtSeq:m}=F(c),h=n.cleanToOriginal.get(i.cleanStart)??i.cleanStart,g=n.cleanToOriginal.get(i.cleanEnd)??i.cleanEnd,_=r.includes(`§`),v;return v=l&&_?.95:l?.85:_?.6:.4,o!==void 0&&(v+=.05),p&&(v+=.05),v=Math.min(v,1),{type:`statute`,text:r,span:{cleanStart:i.cleanStart,cleanEnd:i.cleanEnd,originalStart:h,originalEnd:g},confidence:v,matchedText:r,processTimeMs:0,patternsChecked:1,title:o,code:d,section:f,subsection:p,pincite:p,jurisdiction:u,hasEtSeq:m||void 0}}const R=/^(\d+)\s+(?:ILCS|Ill\.?\s*Comp\.?\s*Stat\.?)\s*(?:Ann\.?\s+)?(\d+)\/(.+)$/;function z(e,t){let{text:n,span:r}=e,i=R.exec(n),a,o,s;i?(a=Number.parseInt(i[1],10),o=i[2],s=i[3]):(o=n,s=``);let{section:c,subsection:l,hasEtSeq:u}=F(s),d=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,f=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd,p=i?.95:.3;return l&&(p+=.05),p=Math.min(p,1),{type:`statute`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:d,originalEnd:f},confidence:p,matchedText:n,processTimeMs:0,patternsChecked:1,title:a,code:o,section:c,subsection:l,pincite:l,jurisdiction:i?`IL`:void 0,hasEtSeq:u||void 0}}const B=/^(\d+)\s+(\S+(?:\.\S+)*)\s*§§?\s*(.+)$/,V=/^(\d+)\s+(\S+(?:\.\S+)*)\s+(?:Part|pt\.)\s+(.+)$/;function H(e,t){let{text:n,span:r}=e,i=B.exec(n)??V.exec(n),a,o,s;i?(a=Number.parseInt(i[1],10),o=i[2],s=i[3]):(o=e.patternId===`cfr`?`C.F.R.`:`U.S.C.`,s=n,a=void 0);let{section:c,subsection:l,hasEtSeq:u}=F(s),d=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,f=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd,p=.95;return a!==void 0&&(p+=.05),l&&(p+=.05),p=Math.min(p,1),{type:`statute`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:d,originalEnd:f},confidence:p,matchedText:n,processTimeMs:0,patternsChecked:1,title:a,code:o,section:c,subsection:l,pincite:l,jurisdiction:`US`,hasEtSeq:u||void 0}}const U=/^(N\.?\s*Y\.?|Cal(?:ifornia)?\.?|Tex(?:as)?\.?|Md\.?|Va\.?|Ala(?:bama)?\.?)\s+(.*?)\s*§§?\s*(.+)$/s,de=/^(.*?)\s+(?:ch\.?|c\.?)\s*(\w+),?\s*§\s*(.+)$/,fe={"n.y.":`NY`,"n.y":`NY`,ny:`NY`,"cal.":`CA`,cal:`CA`,"california.":`CA`,california:`CA`,"tex.":`TX`,tex:`TX`,"texas.":`TX`,texas:`TX`,"md.":`MD`,md:`MD`,"va.":`VA`,va:`VA`,"ala.":`AL`,ala:`AL`,"alabama.":`AL`,alabama:`AL`};function pe(e){return fe[e.toLowerCase().replace(/\s+/g,``)]}function me(e){return e.replace(/^\s*Code\s+Ann\.\s*,\s*/i,``).replace(/^\s*Code\s*,\s*/i,``).replace(/\s+Code\s*$/i,``).replace(/\s+Ann\.?\s*$/i,``).replace(/,\s*$/,``).trim()}function he(t,n){let{text:r,span:i}=t,a,o,s;if(t.patternId===`mass-chapter`){let e=de.exec(r);e?(a=`MA`,o=e[2],s=e[3]):(o=r,s=``)}else{let t=U.exec(r);if(t){a=pe(t[1]);let n=t[2],r=me(n);o=a&&e.r(a,r)?r:n.trim(),s=t[3]}else o=r,s=``}let{section:c,subsection:l,hasEtSeq:u}=F(s),d=n.cleanToOriginal.get(i.cleanStart)??i.cleanStart,f=n.cleanToOriginal.get(i.cleanEnd)??i.cleanEnd,p=a?.95:.5;return l&&(p+=.05),p=Math.min(p,1),{type:`statute`,text:r,span:{cleanStart:i.cleanStart,cleanEnd:i.cleanEnd,originalStart:d,originalEnd:f},confidence:p,matchedText:r,processTimeMs:0,patternsChecked:1,code:o,section:c,subsection:l,pincite:l,jurisdiction:a,hasEtSeq:u||void 0}}const ge=/[Ss]ection\s+(\d+[A-Za-z0-9-]*)((?:\([^)]*\))*)\s+of\s+title\s+(\d+)/;function _e(e,t){let{text:n,span:r}=e,i=ge.exec(n),a,o,s;i?(a=i[1],o=i[2]||void 0,s=Number.parseInt(i[3],10)):a=n;let c=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,l=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd,u=.85;return s!==void 0&&(u+=.05),o&&(u+=.05),u=Math.min(u,1),{type:`statute`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:c,originalEnd:l},confidence:u,matchedText:n,processTimeMs:0,patternsChecked:1,title:s,code:`U.S.C.`,section:a,subsection:o,pincite:o,jurisdiction:`US`}}function ve(e,t){let{text:n,span:r}=e,i=/^(?:(\d+)\s+)?([A-Za-z.\s]+?)\s*§+\s*(\d+[A-Za-z0-9-]*)/.exec(n);if(!i){let e=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,i=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`statute`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:e,originalEnd:i},confidence:.3,matchedText:n,processTimeMs:0,patternsChecked:1,code:n,section:``}}let a=i[1]?Number.parseInt(i[1],10):void 0,o=i[2].trim(),s=i[3],c=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,l=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd,u=.5;return[`U.S.C.`,`C.F.R.`,`Cal. Civ. Code`,`Cal. Penal Code`,`N.Y. Civ. Prac. L. & R.`,`Tex. Civ. Prac. & Rem. Code`].some(e=>o.includes(e))&&(u+=.3),u=Math.min(u,1),{type:`statute`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:c,originalEnd:l},confidence:u,matchedText:n,processTimeMs:0,patternsChecked:1,title:a,code:o,section:s}}function W(e,t){switch(e.patternId){case`usc`:case`cfr`:return H(e,t);case`prose`:return _e(e,t);case`abbreviated-code`:return L(e,t);case`named-code`:case`mass-chapter`:return he(e,t);case`chapter-act`:return z(e,t);default:return ve(e,t)}}function G(e,t){let{text:n,span:r}=e,i=/^(\d+(?:-\d+)?)\s+([A-Za-z.\s]+?)\s+(\d+)/.exec(n);if(!i)throw Error(`Failed to parse journal citation: ${n}`);let a=i[1],o=/^\d+$/.test(a)?Number.parseInt(a,10):a,s=i[2].trim(),c=Number.parseInt(i[3],10),l=/,\s*(\d+)/.exec(n),u=l?Number.parseInt(l[1],10):void 0,d=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,f=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`journal`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:d,originalEnd:f},confidence:.6,matchedText:n,processTimeMs:0,patternsChecked:1,volume:o,journal:s,abbreviation:s,page:c,pincite:u}}function K(e,t){let{text:n,span:r}=e,i=/^(\d{4})\s+(.+?)\s+(\d+)$/.exec(n);if(!i)throw Error(`Failed to parse neutral citation: ${n}`);let a=Number.parseInt(i[1],10),o=i[2],s=i[3],c=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,l=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`neutral`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:c,originalEnd:l},confidence:1,matchedText:n,processTimeMs:0,patternsChecked:1,year:a,court:o,documentNumber:s}}function q(e,t){let{text:n,span:r}=e,i=/Pub\.\s?L\.(?:\s?No\.)?\s?(\d+)-(\d+)/.exec(n);if(!i)throw Error(`Failed to parse public law citation: ${n}`);let a=Number.parseInt(i[1],10),o=Number.parseInt(i[2],10),s=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,c=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`publicLaw`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:s,originalEnd:c},confidence:.9,matchedText:n,processTimeMs:0,patternsChecked:1,congress:a,lawNumber:o}}function J(e,t){let{text:n,span:r}=e,i=/^(\d+(?:-\d+)?)\s+Fed\.\s?Reg\.\s+(\d+)/.exec(n);if(!i)throw Error(`Failed to parse Federal Register citation: ${n}`);let a=i[1],o=/^\d+$/.test(a)?Number.parseInt(a,10):a,s=Number.parseInt(i[2],10),c=/\((?:.*?\s)?(\d{4})\)/.exec(n),l=c?Number.parseInt(c[1],10):void 0,u=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,d=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`federalRegister`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:u,originalEnd:d},confidence:.9,matchedText:n,processTimeMs:0,patternsChecked:1,volume:o,page:s,year:l}}function Y(e,t){let{text:n,span:r}=e,i=/^(\d+(?:-\d+)?)\s+Stat\.\s+(\d+)/.exec(n);if(!i)throw Error(`Failed to parse Statutes at Large citation: ${n}`);let a=i[1],o=/^\d+$/.test(a)?Number.parseInt(a,10):a,s=Number.parseInt(i[2],10),c=/\((?:.*?\s)?(\d{4})\)/.exec(n),l=c?Number.parseInt(c[1],10):void 0,u=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,d=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`statutesAtLarge`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:u,originalEnd:d},confidence:.9,matchedText:n,processTimeMs:0,patternsChecked:1,volume:o,page:s,year:l}}function ye(e,t){let{text:n,span:r}=e,i=/[Ii](?:d|bid)\.(?:\s+at\s+(\d+))?/.exec(n);if(!i)throw Error(`Failed to parse Id. citation: ${n}`);let a=i[1]?Number.parseInt(i[1],10):void 0,o=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,s=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`id`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:o,originalEnd:s},confidence:1,matchedText:n,processTimeMs:0,patternsChecked:1,pincite:a}}function be(e,t){let{text:n,span:r}=e,i=/\b([A-Z][a-zA-Z]+(?:(?:\s+v\.?\s+|\s+)[A-Z][a-zA-Z]+)*)\s*,?\s+supra(?:,?\s+at\s+(\d+))?/.exec(n);if(!i)throw Error(`Failed to parse supra citation: ${n}`);let a=i[1],o=i[2]?Number.parseInt(i[2],10):void 0,s=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,c=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`supra`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:s,originalEnd:c},confidence:.9,matchedText:n,processTimeMs:0,patternsChecked:1,partyName:a,pincite:o}}function xe(e,t){let{text:n,span:r}=e,i=/(\d+(?:-\d+)?)\s+([A-Z][A-Za-z.\s]+?(?:\d[a-z])?)\s+at\s+(\d+)/.exec(n);if(!i)throw Error(`Failed to parse short-form case citation: ${n}`);let a=i[1],o=/^\d+$/.test(a)?Number.parseInt(a,10):a,s=i[2].trim(),c=Number.parseInt(i[3],10),l=t.cleanToOriginal.get(r.cleanStart)??r.cleanStart,u=t.cleanToOriginal.get(r.cleanEnd)??r.cleanEnd;return{type:`shortFormCase`,text:n,span:{cleanStart:r.cleanStart,cleanEnd:r.cleanEnd,originalStart:l,originalEnd:u},confidence:.7,matchedText:n,processTimeMs:0,patternsChecked:1,volume:o,reporter:s,pincite:c}}function Se(e,t,n=/\n\n+/g){let r=new Map,i=[0],a;for(;(a=n.exec(e))!==null;)i.push(a.index+a[0].length);i.push(e.length);for(let e=0;e<t.length;e++){let n=t[e].span.originalStart,a=0;for(let e=0;e<i.length-1;e++)if(n>=i[e]&&n<i[e+1]){a=e;break}r.set(e,a)}return r}function Ce(e,t,n,r){if(r===`none`)return!0;let i=n.get(e),a=n.get(t);return i===void 0||a===void 0?!0:i===a}function X(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let n=Array.from({length:e.length+1},()=>Array(t.length+1).fill(0));for(let t=0;t<=e.length;t++)n[t][0]=t;for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=e.length;r++)for(let i=1;i<=t.length;i++)e[r-1]===t[i-1]?n[r][i]=n[r-1][i-1]:n[r][i]=1+Math.min(n[r-1][i],n[r][i-1],n[r-1][i-1]);return n[e.length][t.length]}function we(e,t){let n=e.toLowerCase(),r=t.toLowerCase(),i=X(n,r),a=Math.max(n.length,r.length);return a===0?1:1-i/a}var Z=class{constructor(e,t,n={}){this.citations=e,this.text=t,this.options={scopeStrategy:n.scopeStrategy??`paragraph`,autoDetectParagraphs:n.autoDetectParagraphs??!0,paragraphBoundaryPattern:n.paragraphBoundaryPattern??/\n\n+/g,fuzzyPartyMatching:n.fuzzyPartyMatching??!0,partyMatchThreshold:n.partyMatchThreshold??.8,allowNestedResolution:n.allowNestedResolution??!1,reportUnresolved:n.reportUnresolved??!0},this.context={citationIndex:0,allCitations:e,lastFullCitation:void 0,fullCitationHistory:new Map,paragraphMap:new Map},this.options.autoDetectParagraphs&&(this.context.paragraphMap=Se(t,e,this.options.paragraphBoundaryPattern))}resolve(){let e=[];for(let n=0;n<this.citations.length;n++){this.context.citationIndex=n;let r=this.citations[n],i;switch(r.type){case`id`:i=this.resolveId(r);break;case`supra`:i=this.resolveSupra(r);break;case`shortFormCase`:i=this.resolveShortFormCase(r);break;default:t(r)&&(this.context.lastFullCitation=n,this.trackFullCitation(r,n));break}e.push({...r,resolution:i})}return e}resolveId(e){let t=this.context.citationIndex,n;for(let e=t-1;e>=0;e--)if(this.citations[e].type===`case`){n=e;break}return n===void 0?this.createFailureResult(`No preceding full case citation found`):this.isWithinScope(n,t)?{resolvedTo:n,confidence:1}:this.createFailureResult(`Antecedent citation outside scope boundary`)}resolveSupra(e){let t=this.context.citationIndex,n=this.normalizePartyName(e.partyName),r;for(let[e,i]of this.context.fullCitationHistory){if(!this.isWithinScope(i,t))continue;let a=we(n,e);(!r||a>r.similarity)&&(r={index:i,similarity:a})}if(!r)return this.createFailureResult(`No full citation found in scope`);if(r.similarity<this.options.partyMatchThreshold)return this.createFailureResult(`Party name similarity ${r.similarity.toFixed(2)} below threshold ${this.options.partyMatchThreshold}`);let i=[];return r.similarity<1&&i.push(`Fuzzy match: similarity ${r.similarity.toFixed(2)}`),{resolvedTo:r.index,confidence:r.similarity,warnings:i.length>0?i:void 0}}resolveShortFormCase(e){let t=this.context.citationIndex;for(let n=t-1;n>=0;n--){let r=this.citations[n];if(r.type===`case`&&r.volume===e.volume&&this.normalizeReporter(r.reporter)===this.normalizeReporter(e.reporter))return this.isWithinScope(n,t)?{resolvedTo:n,confidence:.95}:this.createFailureResult(`Matching citation outside scope boundary`)}return this.createFailureResult(`No matching full case citation found`)}trackFullCitation(e,t){if(e.type===`case`&&(e.defendantNormalized&&this.context.fullCitationHistory.set(e.defendantNormalized,t),e.plaintiffNormalized&&this.context.fullCitationHistory.set(e.plaintiffNormalized,t),!e.plaintiffNormalized&&!e.defendantNormalized)){let n=this.extractPartyName(e);if(n){let e=this.normalizePartyName(n);this.context.fullCitationHistory.set(e,t)}}}extractPartyName(e){let t=e.span.originalStart,n=Math.max(0,t-100),r=this.text.substring(n,t),i=r.match(/([A-Z][a-zA-Z]*(?:\s+[A-Z][a-zA-Z]*)*)\s+v\.?\s+[A-Z][a-zA-Z]*(?:\s+[A-Z][a-zA-Z]*)*,\s*$/);if(i)return this.stripSignalWords(i[1].trim());let a=r.match(/([A-Z][a-zA-Z]*(?:\s+[A-Z][a-zA-Z]*)*),\s*$/);if(a)return this.stripSignalWords(a[1].trim())}stripSignalWords(e){let t=e.replace(/^(?:In(?!\s+re\b)|See(?:\s+[Aa]lso)?|Compare|But(?:\s+[Ss]ee)?|Cf\.?|Also)\s+/i,``).trim();return t.length>0?t:e}normalizePartyName(e){return e.toLowerCase().replace(/\s+/g,` `).trim()}normalizeReporter(e){return e.toLowerCase().replace(/\s+/g,``).replace(/\./g,``)}isWithinScope(e,t){return Ce(e,t,this.context.paragraphMap,this.options.scopeStrategy)}createFailureResult(e){if(this.options.reportUnresolved)return{resolvedTo:void 0,failureReason:e,confidence:0}}};function Q(e,t,n){return new Z(e,t,n).resolve()}function Te(e,t=``){let n=new Map;if(e.length===0||t===``)return n;let r=new Set;for(let i=0;i<e.length;i++){let a=e[i];if(a.type!==`case`||r.has(i))continue;let o=[];for(let n=i+1;n<e.length;n++){let s=e[n];if(s.type!==`case`)break;let c=(n===i+1?a:e[n-1]).span.cleanEnd,l=s.span.cleanStart;if(l-c>20)break;let u=t.substring(c,l);if(!u.includes(`,`))break;let d=u.indexOf(`,`);if(u.length-d-1>5||t.substring(a.span.cleanEnd,s.span.cleanEnd).includes(`)`)||!Ee(t,s.span.cleanEnd))break;o.push(n),r.add(n)}o.length>0&&n.set(i,o)}return n}function Ee(e,t){let n=e.substring(t,t+200),r=n.indexOf(`(`);if(r===-1)return!1;let i=0;for(let e=r;e<n.length;e++)if(n[e]===`(`)i++;else if(n[e]===`)`&&(i--,i===0))return!0;return!1}function $(e,t){let n=performance.now(),{cleaned:r,transformationMap:i,warnings:a}=f(e,t?.cleaners),o=y(r,t?.patterns||[..._,...v,...m,...h,...g]),s=[],c=new Set,l=r.length<65536;for(let e of o){let t=l?e.span.cleanStart<<16|e.span.cleanEnd:`${e.span.cleanStart}-${e.span.cleanEnd}`;c.has(t)||(c.add(t),s.push(e))}let u=Te(s,r),d=[];for(let e=0;e<s.length;e++){let t=s[e],o;switch(t.type){case`case`:o=t.patternId===`id`||t.patternId===`ibid`?ye(t,i):t.patternId===`supra`?be(t,i):t.patternId===`shortFormCase`?xe(t,i):M(t,i,r);break;case`statute`:o=W(t,i);break;case`journal`:o=G(t,i);break;case`neutral`:o=K(t,i);break;case`publicLaw`:o=q(t,i);break;case`federalRegister`:o=J(t,i);break;case`statutesAtLarge`:o=Y(t,i);break;default:continue}if(a.length>0&&(o.warnings=[...o.warnings||[],...a]),o.processTimeMs=performance.now()-n,o.type===`case`){let t=u.has(e),n=Array.from(u.values()).some(t=>t.includes(e));if(t||n){let r=e;if(n){for(let[t,n]of u.entries())if(n.includes(e)){r=t;break}}let i=s[r],a=/^(\S+)\s+(.+)\s+(\d+)$/.exec(i.text);if(a){let[,n,r,i]=a;if(o.groupId=`${n}-${r.replace(/\s+/g,`.`)}-${i}`,t){let t=u.get(e);o.parallelCitations=t.map(e=>{let t=s[e],n=/^(\S+)\s+(.+)\s+(\d+)$/.exec(t.text);if(n){let[,e,t,r]=n;return{volume:/^\d+$/.test(e)?Number.parseInt(e,10):e,reporter:t,page:Number.parseInt(r,10)}}return{volume:0,reporter:``,page:0}})}}}}d.push(o)}return t?.resolve?Q(d,e,t.resolutionOptions):d}async function De(e,t){return $(e,t)}exports.DocumentResolver=Z,exports.assertUnreachable=a,exports.cleanText=f,exports.extractCase=M,exports.extractCitations=$,exports.extractCitationsAsync=De,exports.extractFederalRegister=J,exports.extractJournal=G,exports.extractNeutral=K,exports.extractPublicLaw=q,exports.extractStatute=W,exports.extractStatutesAtLarge=Y,exports.isCaseCitation=r,exports.isCitationType=i,exports.isFullCitation=t,exports.isShortFormCitation=n,exports.resolveCitations=Q,exports.tokenize=y;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|